Use the common attr and action parsing infrastructure in syn filter. Some checks have been rearranged or become more stringent due to using common infrastructure. In particular, group attr was ignored previously but is now explicitly rejected.
Signed-off-by: Anatoly Burakov <[email protected]> --- drivers/net/intel/ixgbe/ixgbe_flow.c | 130 +++++++-------------------- 1 file changed, 32 insertions(+), 98 deletions(-) diff --git a/drivers/net/intel/ixgbe/ixgbe_flow.c b/drivers/net/intel/ixgbe/ixgbe_flow.c index 7695d57e2a..0aa96f04bb 100644 --- a/drivers/net/intel/ixgbe/ixgbe_flow.c +++ b/drivers/net/intel/ixgbe/ixgbe_flow.c @@ -922,38 +922,13 @@ ixgbe_parse_ethertype_filter(struct rte_eth_dev *dev, const struct rte_flow_attr * item->last should be NULL. */ static int -cons_parse_syn_filter(const struct rte_flow_attr *attr, - const struct rte_flow_item pattern[], - const struct rte_flow_action actions[], - struct rte_eth_syn_filter *filter, - struct rte_flow_error *error) +cons_parse_syn_filter(const struct rte_flow_attr *attr, const struct rte_flow_item pattern[], + const struct rte_flow_action_queue *q_act, struct rte_eth_syn_filter *filter, + struct rte_flow_error *error) { const struct rte_flow_item *item; - const struct rte_flow_action *act; const struct rte_flow_item_tcp *tcp_spec; const struct rte_flow_item_tcp *tcp_mask; - const struct rte_flow_action_queue *act_q; - - if (!pattern) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM_NUM, - NULL, "NULL pattern."); - return -rte_errno; - } - - if (!actions) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION_NUM, - NULL, "NULL action."); - return -rte_errno; - } - - if (!attr) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR, - NULL, "NULL attribute."); - return -rte_errno; - } /* the first not void item should be MAC or IPv4 or IPv6 or TCP */ @@ -1061,63 +1036,7 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr, return -rte_errno; } - /* check if the first not void action is QUEUE. */ - act = next_no_void_action(actions, NULL); - if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE) { - memset(filter, 0, sizeof(struct rte_eth_syn_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - act, "Not supported action."); - return -rte_errno; - } - - act_q = (const struct rte_flow_action_queue *)act->conf; - filter->queue = act_q->index; - if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM) { - memset(filter, 0, sizeof(struct rte_eth_syn_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - act, "Not supported action."); - return -rte_errno; - } - - /* check if the next not void item is END */ - act = next_no_void_action(actions, act); - if (act->type != RTE_FLOW_ACTION_TYPE_END) { - memset(filter, 0, sizeof(struct rte_eth_syn_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - act, "Not supported action."); - return -rte_errno; - } - - /* parse attr */ - /* must be input direction */ - if (!attr->ingress) { - memset(filter, 0, sizeof(struct rte_eth_syn_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, - attr, "Only support ingress."); - return -rte_errno; - } - - /* not supported */ - if (attr->egress) { - memset(filter, 0, sizeof(struct rte_eth_syn_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, - attr, "Not support egress."); - return -rte_errno; - } - - /* not supported */ - if (attr->transfer) { - memset(filter, 0, sizeof(struct rte_eth_syn_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, - attr, "No support for transfer."); - return -rte_errno; - } + filter->queue = q_act->index; /* Support 2 priorities, the lowest or highest. */ if (!attr->priority) { @@ -1128,7 +1047,7 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr, memset(filter, 0, sizeof(struct rte_eth_syn_filter)); rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, - attr, "Not support priority."); + attr, "Priority can be 0 or 0xFFFFFFFF"); return -rte_errno; } @@ -1136,15 +1055,27 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr, } static int -ixgbe_parse_syn_filter(struct rte_eth_dev *dev, - const struct rte_flow_attr *attr, - const struct rte_flow_item pattern[], - const struct rte_flow_action actions[], - struct rte_eth_syn_filter *filter, - struct rte_flow_error *error) +ixgbe_parse_syn_filter(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, + const struct rte_flow_item pattern[], const struct rte_flow_action actions[], + struct rte_eth_syn_filter *filter, struct rte_flow_error *error) { int ret; struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct ci_flow_actions parsed_actions; + struct ci_flow_actions_check_param ap_param = { + .allowed_types = (const enum rte_flow_action_type[]){ + /* only queue is allowed here */ + RTE_FLOW_ACTION_TYPE_QUEUE, + RTE_FLOW_ACTION_TYPE_END + }, + .driver_ctx = dev, + .check = ixgbe_flow_actions_check, + .max_actions = 1, + }; + struct ci_flow_attr_check_param attr_param = { + .allow_priority = true, + }; + const struct rte_flow_action *action; if (hw->mac.type != ixgbe_mac_82599EB && hw->mac.type != ixgbe_mac_X540 && @@ -1154,16 +1085,19 @@ ixgbe_parse_syn_filter(struct rte_eth_dev *dev, hw->mac.type != ixgbe_mac_E610) return -ENOTSUP; - ret = cons_parse_syn_filter(attr, pattern, - actions, filter, error); - - if (filter->queue >= dev->data->nb_rx_queues) - return -rte_errno; + /* validate attributes */ + ret = ci_flow_check_attr(attr, &attr_param, error); + if (ret) + return ret; + /* parse requested actions */ + ret = ci_flow_check_actions(actions, &ap_param, &parsed_actions, error); if (ret) return ret; - return 0; + action = parsed_actions.actions[0]; + + return cons_parse_syn_filter(attr, pattern, action->conf, filter, error); } /** -- 2.47.3

