net/mlx5: unify validation of drop action
According to PRM: "Drop action is mutually-exclusive with any other action, except for Count action". In current code this limitation is checked separately in validation function of each action. This patch removes the discrete checks, and adds a single check common for all actions. Signed-off-by: Dekel Peled <dekelp@mellanox.com> Acked-by: Ori Kam <orika@mellanox.com> Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
This commit is contained in:
parent
5507cb7927
commit
70faf9ae0a
@ -905,11 +905,6 @@ mlx5_flow_validate_action_flag(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 flag in same flow");
|
||||
if (action_flags & MLX5_FLOW_ACTION_MARK)
|
||||
return rte_flow_error_set(error, EINVAL,
|
||||
RTE_FLOW_ERROR_TYPE_ACTION, NULL,
|
||||
@ -961,10 +956,6 @@ mlx5_flow_validate_action_mark(const struct rte_flow_action *action,
|
||||
&mark->id,
|
||||
"mark id must in 0 <= id < "
|
||||
RTE_STR(MLX5_FLOW_MARK_MAX));
|
||||
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,
|
||||
@ -996,24 +987,10 @@ mlx5_flow_validate_action_mark(const struct rte_flow_action *action,
|
||||
* 0 on success, a negative errno value otherwise and rte_errno is set.
|
||||
*/
|
||||
int
|
||||
mlx5_flow_validate_action_drop(uint64_t action_flags,
|
||||
mlx5_flow_validate_action_drop(uint64_t action_flags __rte_unused,
|
||||
const struct rte_flow_attr *attr,
|
||||
struct rte_flow_error *error)
|
||||
{
|
||||
if (action_flags & MLX5_FLOW_ACTION_FLAG)
|
||||
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,
|
||||
"can't drop and mark in same flow");
|
||||
if (action_flags & (MLX5_FLOW_FATE_ACTIONS |
|
||||
MLX5_FLOW_FATE_ESWITCH_ACTIONS))
|
||||
return rte_flow_error_set(error, EINVAL,
|
||||
RTE_FLOW_ERROR_TYPE_ACTION, NULL,
|
||||
"can't have 2 fate actions in"
|
||||
" same flow");
|
||||
if (attr->egress)
|
||||
return rte_flow_error_set(error, ENOTSUP,
|
||||
RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
|
||||
|
@ -1912,10 +1912,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 +1981,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 +2165,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 +2197,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 +2243,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 +2286,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 +5027,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) &&
|
||||
|
@ -1255,6 +1255,18 @@ flow_verbs_validate(struct rte_eth_dev *dev,
|
||||
"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");
|
||||
if (!(action_flags & MLX5_FLOW_FATE_ACTIONS))
|
||||
return rte_flow_error_set(error, EINVAL,
|
||||
RTE_FLOW_ERROR_TYPE_ACTION, actions,
|
||||
|
Loading…
Reference in New Issue
Block a user