net/mlx5: block pop VLAN action on Tx
[dpdk.git] / drivers / net / mlx5 / mlx5_flow_dv.c
index 59ece01..9dc08ce 100644 (file)
@@ -1634,6 +1634,12 @@ flow_dv_validate_action_pop_vlan(struct rte_eth_dev *dev,
                                          RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
                                          NULL,
                                          "pop vlan action is not supported");
+       if (attr->egress)
+               return rte_flow_error_set(error, ENOTSUP,
+                                         RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
+                                         NULL,
+                                         "pop vlan action not supported for "
+                                         "egress");
        /*
         * Check for inconsistencies:
         *  fail strip_vlan in a flow that matches packets without VLAN tags.
@@ -1741,6 +1747,12 @@ flow_dv_validate_action_push_vlan(uint64_t action_flags,
 {
        const struct rte_flow_action_of_push_vlan *push_vlan = action->conf;
 
+       if (attr->ingress)
+               return rte_flow_error_set(error, ENOTSUP,
+                                         RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
+                                         NULL,
+                                         "push VLAN action not supported for "
+                                         "ingress");
        if (push_vlan->ethertype != RTE_BE16(RTE_ETHER_TYPE_VLAN) &&
            push_vlan->ethertype != RTE_BE16(RTE_ETHER_TYPE_QINQ))
                return rte_flow_error_set(error, EINVAL,
@@ -1912,10 +1924,6 @@ flow_dv_validate_action_flag(struct rte_eth_dev *dev,
        if (ret < 0)
                return ret;
        assert(ret > 0);
-       if (action_flags & MLX5_FLOW_ACTION_DROP)
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ACTION, NULL,
-                                         "can't drop and flag in same flow");
        if (action_flags & MLX5_FLOW_ACTION_MARK)
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_ACTION, NULL,
@@ -1985,10 +1993,6 @@ flow_dv_validate_action_mark(struct rte_eth_dev *dev,
                                          RTE_FLOW_ERROR_TYPE_ACTION_CONF,
                                          &mark->id,
                                          "mark id exceeds the limit");
-       if (action_flags & MLX5_FLOW_ACTION_DROP)
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ACTION, NULL,
-                                         "can't drop and mark in same flow");
        if (action_flags & MLX5_FLOW_ACTION_FLAG)
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_ACTION, NULL,
@@ -2173,10 +2177,6 @@ flow_dv_validate_action_l2_encap(uint64_t action_flags,
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_ACTION, action,
                                          "configuration cannot be null");
-       if (action_flags & MLX5_FLOW_ACTION_DROP)
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ACTION, NULL,
-                                         "can't drop and encap in same flow");
        if (action_flags & (MLX5_FLOW_ENCAP_ACTIONS | MLX5_FLOW_DECAP_ACTIONS))
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_ACTION, NULL,
@@ -2209,10 +2209,6 @@ flow_dv_validate_action_l2_decap(uint64_t action_flags,
                                 const struct rte_flow_attr *attr,
                                 struct rte_flow_error *error)
 {
-       if (action_flags & MLX5_FLOW_ACTION_DROP)
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ACTION, NULL,
-                                         "can't drop and decap in same flow");
        if (action_flags & (MLX5_FLOW_ENCAP_ACTIONS | MLX5_FLOW_DECAP_ACTIONS))
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_ACTION, NULL,
@@ -2259,10 +2255,6 @@ flow_dv_validate_action_raw_encap(uint64_t action_flags,
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_ACTION, action,
                                          "configuration cannot be null");
-       if (action_flags & MLX5_FLOW_ACTION_DROP)
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ACTION, NULL,
-                                         "can't drop and encap in same flow");
        if (action_flags & MLX5_FLOW_ENCAP_ACTIONS)
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_ACTION, NULL,
@@ -2306,10 +2298,6 @@ flow_dv_validate_action_raw_decap(uint64_t action_flags,
 {
        const struct rte_flow_action_raw_decap *decap   = action->conf;
 
-       if (action_flags & MLX5_FLOW_ACTION_DROP)
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ACTION, NULL,
-                                         "can't drop and decap in same flow");
        if (action_flags & MLX5_FLOW_ENCAP_ACTIONS)
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_ACTION, NULL,
@@ -5051,6 +5039,18 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
                                                  "action not supported");
                }
        }
+       /*
+        * Validate the drop action mutual exclusion with other actions.
+        * Drop action is mutually-exclusive with any other action, except for
+        * Count action.
+        */
+       if ((action_flags & MLX5_FLOW_ACTION_DROP) &&
+           (action_flags & ~(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_COUNT)))
+               return rte_flow_error_set(error, EINVAL,
+                                         RTE_FLOW_ERROR_TYPE_ACTION, NULL,
+                                         "Drop action is mutually-exclusive "
+                                         "with any other action, except for "
+                                         "Count action");
        /* Eswitch has few restrictions on using items and actions */
        if (attr->transfer) {
                if (!mlx5_flow_ext_mreg_supported(dev) &&