Add common flow attr/action parsing infrastructure to Intel PMD's
Subsystems (3)
PATCH v5 25/27 net/ice: use common action checks for FDIR
In reply to Anatoly BurakovFrom: Vladimir Medvedkin <[email protected]>
Use the common flow action checking parsing infrastructure for checking flow actions for FDIR filter.
--- drivers/net/intel/ice/ice_fdir_filter.c | 376 +++++++++++++----------- 1 file changed, 204 insertions(+), 172 deletions(-)
drivers/net/intel/ice/ice_fdir_filter.c +204 -172
@@ -1695,177 +1695,6 @@ static struct ice_flow_engine ice_fdir_engine = { .rule_size = sizeof(struct ice_fdir_filter_conf), }; -static int -ice_fdir_parse_action_qregion (struct ice_pf *pf, -struct rte_flow_error *error, -const struct rte_flow_action *act, -struct ice_fdir_filter_conf *filter) -{ -const struct rte_flow_action_rss *rss = act->conf; -uint32_t i; - -if (act->type !=RTE_FLOW_ACTION_TYPE_RSS ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid action." ); -return -rte_errno; - } - -if (rss->queue_num <=1 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Queue region size can't be 0 or 1." ); -return -rte_errno; - } - -/* check if queue index for queue region is continuous */ -for (i =0 ; i < rss->queue_num -1 ; i++) { -if (rss->queue[i +1 ] != rss->queue[i] +1 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Discontinuous queue region" ); -return -rte_errno; - } - } - -if (rss->queue[rss->queue_num -1 ] >= pf->dev_data->nb_rx_queues) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid queue region indexes." ); -return -rte_errno; - } - -if (!(rte_is_power_of_2 (rss->queue_num) && - (rss->queue_num <=ICE_FDIR_MAX_QREGION_SIZE ))) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"The region size should be any of the following values:" -"1, 2, 4, 8, 16, 32, 64, 128 as long as the total number " -"of queues do not exceed the VSI allocation." ); -return -rte_errno; - } - - filter->input.q_index = rss->queue[0 ]; - filter->input.q_region =rte_fls_u32 (rss->queue_num) -1 ; - filter->input.dest_ctl =ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QGROUP ; - -return 0 ; -} - -static int -ice_fdir_parse_action (struct ice_adapter *ad, -const struct rte_flow_action actions[], -struct rte_flow_error *error, -struct ice_fdir_filter_conf *filter) -{ -struct ice_pf *pf = &ad->pf; -const struct rte_flow_action_queue *act_q; -const struct rte_flow_action_mark *mark_spec =NULL ; -const struct rte_flow_action_count *act_count; -uint32_t dest_num =0 ; -uint32_t mark_num =0 ; -uint32_t counter_num =0 ; -int ret; - -for (; actions->type !=RTE_FLOW_ACTION_TYPE_END ; actions++) { -switch (actions->type) { -case RTE_FLOW_ACTION_TYPE_VOID : -break ; -case RTE_FLOW_ACTION_TYPE_QUEUE : - dest_num++; - - act_q = actions->conf; - filter->input.q_index = act_q->index; -if (filter->input.q_index >= - pf->dev_data->nb_rx_queues) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid queue for FDIR." ); -return -rte_errno; - } - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX ; -break ; -case RTE_FLOW_ACTION_TYPE_DROP : - dest_num++; - - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DROP_PKT ; -break ; -case RTE_FLOW_ACTION_TYPE_PASSTHRU : - dest_num++; - - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER ; -break ; -case RTE_FLOW_ACTION_TYPE_RSS : - dest_num++; - - ret =ice_fdir_parse_action_qregion (pf, - error, actions, filter); -if (ret) -return ret; -break ; -case RTE_FLOW_ACTION_TYPE_MARK : - mark_num++; - filter->mark_flag =1 ; - mark_spec = actions->conf; - filter->input.fltr_id = mark_spec->id; - filter->input.fdid_prio =ICE_FXD_FLTR_QW1_FDID_PRI_ONE ; -break ; -case RTE_FLOW_ACTION_TYPE_COUNT : - counter_num++; - - act_count = actions->conf; - filter->input.cnt_ena =ICE_FXD_FLTR_QW0_STAT_ENA_PKTS ; -memcpy (&filter->act_count, act_count, -sizeof (filter->act_count)); - -break ; -default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Invalid action." ); -return -rte_errno; - } - } - -if (dest_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Unsupported action combination" ); -return -rte_errno; - } - -if (mark_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Too many mark actions" ); -return -rte_errno; - } - -if (counter_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Too many count actions" ); -return -rte_errno; - } - -if (dest_num + mark_num + counter_num ==0 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Empty action" ); -return -rte_errno; - } - -/* set default action to PASSTHRU mode, in "mark/count only" case. */ -if (dest_num ==0 ) - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER ; - -return 0 ; -} static int ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
@@ -2804,6 +2633,188 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,return 0 ; } +static int +ice_fdir_parse_action (struct ice_adapter *ad, +const struct ci_flow_actions *actions, +struct rte_flow_error *error) +{ +struct ice_pf *pf = &ad->pf; +struct ice_fdir_filter_conf *filter = &pf->fdir.conf; +bool dest_set = false; +size_t i; + +for (i =0 ; i < actions->count; i++) { +const struct rte_flow_action *act = actions->actions[i]; + +switch (act->type) { +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *act_q = act->conf; + dest_set = true; + + filter->input.q_index = act_q->index; + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX ; +break ; + } +case RTE_FLOW_ACTION_TYPE_DROP : + dest_set = true; + + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DROP_PKT ; +break ; +case RTE_FLOW_ACTION_TYPE_PASSTHRU : + dest_set = true; + + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER ; +break ; +case RTE_FLOW_ACTION_TYPE_RSS : + { +const struct rte_flow_action_rss *rss = act->conf; + dest_set = true; + + filter->input.q_index = rss->queue[0 ]; + filter->input.q_region =rte_fls_u32 (rss->queue_num) -1 ; + filter->input.dest_ctl =ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QGROUP ; + +break ; + } +case RTE_FLOW_ACTION_TYPE_MARK : + { +const struct rte_flow_action_mark *mark_spec = act->conf; + filter->mark_flag =1 ; + filter->input.fltr_id = mark_spec->id; + filter->input.fdid_prio =ICE_FXD_FLTR_QW1_FDID_PRI_ONE ; +break ; + } +case RTE_FLOW_ACTION_TYPE_COUNT : + { +const struct rte_flow_action_count *act_count = act->conf; + + filter->input.cnt_ena =ICE_FXD_FLTR_QW0_STAT_ENA_PKTS ; +rte_memcpy (&filter->act_count, act_count, +sizeof (filter->act_count)); +break ; + } +default : +/* Should not happen */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"Invalid action." ); + } + } + +/* set default action to PASSTHRU mode, in "mark/count only" case. */ +if (!dest_set) { + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER ; + } + +return 0 ; +} + +static int +ice_fdir_check_action_qregion (struct ice_pf *pf, +struct rte_flow_error *error, +const struct rte_flow_action_rss *rss) +{ +if (rss->queue_num <=1 ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"Queue region size can't be 0 or 1." ); + } + +if (rss->queue[rss->queue_num -1 ] >= pf->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"Invalid queue region indexes." ); + } + +if (!(rte_is_power_of_2 (rss->queue_num) && + (rss->queue_num <=ICE_FDIR_MAX_QREGION_SIZE ))) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"The region size should be any of the following values:" +"2, 4, 8, 16, 32, 64, 128 as long as the total number " +"of queues do not exceed the VSI allocation." ); + +return 0 ; +} + +static int +ice_fdir_check_action (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +struct ice_adapter *ad = param->driver_ctx; +struct ice_pf *pf = &ad->pf; +uint32_t dest_num =0 ; +uint32_t mark_num =0 ; +uint32_t counter_num =0 ; +size_t i; +int ret; + +for (i =0 ; i < actions->count; i++) { +const struct rte_flow_action *act = actions->actions[i]; + +switch (act->type) { +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *act_q = act->conf; + dest_num++; + +if (act_q->index >= pf->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act, +"Invalid queue for FDIR." ); + } +break ; + } +case RTE_FLOW_ACTION_TYPE_DROP : + dest_num++; +break ; +case RTE_FLOW_ACTION_TYPE_PASSTHRU : + dest_num++; +break ; +case RTE_FLOW_ACTION_TYPE_RSS : + { +const struct rte_flow_action_rss *rss = act->conf; + + dest_num++; + ret =ice_fdir_check_action_qregion (pf, error, rss); +if (ret) +return ret; +break ; + } +case RTE_FLOW_ACTION_TYPE_MARK : + { + mark_num++; +break ; + } +case RTE_FLOW_ACTION_TYPE_COUNT : + { + counter_num++; +break ; + } +default : +/* Should not happen */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"Invalid action." ); + } + } + +if (dest_num >1 || mark_num >1 || counter_num >1 ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Unsupported action combination" ); + } + +return 0 ; +} + static int ice_fdir_parse(struct ice_adapter *ad, struct ice_pattern_match_item *array,
@@ -2814,6 +2825,22 @@ ice_fdir_parse(struct ice_adapter *ad,void **meta, struct rte_flow_error *error) { + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_PASSTHRU , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_MARK , +RTE_FLOW_ACTION_TYPE_COUNT , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =3 , + .check = ice_fdir_check_action, + .driver_ctx = ad, + .rss_queues_contig = true, + };struct ice_pf *pf = &ad->pf;struct ice_fdir_filter_conf *filter = &pf->fdir.conf;struct ice_pattern_match_item *item =NULL ;
@@ -2826,6 +2853,11 @@ ice_fdir_parse(struct ice_adapter *ad,return ret;memset (filter,0 ,sizeof (*filter)); + + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret) +return ret; + item =ice_search_pattern_match_item (ad, pattern, array, array_len, error);
@@ -2854,7 +2886,7 @@ ice_fdir_parse(struct ice_adapter *ad, goto error; } - ret =ice_fdir_parse_action (ad, actions, error, filter); + ret =ice_fdir_parse_action (ad, &parsed_actions, error);if (ret) goto error;
Signature · 1 line
2.47.3
PATCH v5 26/27 net/ice: use common action checks for switch
In reply to Anatoly BurakovFrom: Vladimir Medvedkin <[email protected]>
Use the common flow action checking parsing infrastructure for checking flow actions for switch filter.
--- drivers/net/intel/ice/ice_switch_filter.c | 371 +++++++++++----------- 1 file changed, 185 insertions(+), 186 deletions(-)
drivers/net/intel/ice/ice_switch_filter.c +185 -186
@@ -35,6 +35,8 @@#define ICE_IPV4_PROTO_NVGRE 0x002F#define ICE_SW_PRI_BASE 6 +#define ICE_SW_MAX_QUEUES 128 +#define ICE_SW_INSET_ETHER ( \ ICE_INSET_DMAC | ICE_INSET_SMAC | ICE_INSET_ETHERTYPE)#define ICE_SW_INSET_MAC_VLAN ( \
@@ -1527,85 +1529,38 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[], }static int -ice_switch_parse_dcf_action (struct ice_dcf_adapter *ad, -const struct rte_flow_action *actions, +ice_switch_parse_dcf_action (const struct rte_flow_action *action,uint32_t priority,struct rte_flow_error *error,struct ice_adv_rule_info *rule_info) {const struct rte_flow_action_ethdev *act_ethdev; -const struct rte_flow_action *action;const struct rte_eth_dev *repr_dev;enum rte_flow_action_type action_type; -uint16_t rule_port_id, backer_port_id; -for (action = actions; action->type != -RTE_FLOW_ACTION_TYPE_END ; action++) { - action_type = action->type; -switch (action_type) { -case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR : - rule_info->sw_act.fltr_act =ICE_FWD_TO_VSI ; - act_ethdev = action->conf; - -if (!rte_eth_dev_is_valid_port (act_ethdev->port_id)) - goto invalid_port_id; - -/* For traffic to original DCF port */ - rule_port_id = ad->parent.pf.dev_data->port_id; - -if (rule_port_id != act_ethdev->port_id) - goto invalid_port_id; - - rule_info->sw_act.vsi_handle =0 ; - -break ; - -invalid_port_id: -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid port_id" ); -return -rte_errno; - -case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT : - rule_info->sw_act.fltr_act =ICE_FWD_TO_VSI ; - act_ethdev = action->conf; - -if (!rte_eth_dev_is_valid_port (act_ethdev->port_id)) - goto invalid; - - repr_dev = &rte_eth_devices[act_ethdev->port_id]; - -if (!repr_dev->data) - goto invalid; - - rule_port_id = ad->parent.pf.dev_data->port_id; - backer_port_id = repr_dev->data->backer_port_id; - -if (backer_port_id != rule_port_id) - goto invalid; - - rule_info->sw_act.vsi_handle = repr_dev->data->representor_id; -break ; - -invalid: -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid ethdev_port_id" ); -return -rte_errno; - -case RTE_FLOW_ACTION_TYPE_DROP : - rule_info->sw_act.fltr_act =ICE_DROP_PACKET ; -break ; - -default : -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid action type" ); -return -rte_errno; - } + action_type = action->type; +switch (action_type) { +case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR : + rule_info->sw_act.fltr_act =ICE_FWD_TO_VSI ; + rule_info->sw_act.vsi_handle =0 ; +break ; + +case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT : + rule_info->sw_act.fltr_act =ICE_FWD_TO_VSI ; + act_ethdev = action->conf; + repr_dev = &rte_eth_devices[act_ethdev->port_id]; + rule_info->sw_act.vsi_handle = repr_dev->data->representor_id; +break ; + +case RTE_FLOW_ACTION_TYPE_DROP : + rule_info->sw_act.fltr_act =ICE_DROP_PACKET ; +break ; + +default : +/* Should never reach */ +rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Invalid action type" ); +return -rte_errno; } rule_info->sw_act.src = rule_info->sw_act.vsi_handle;
@@ -1621,73 +1576,38 @@ ice_switch_parse_dcf_action(struct ice_dcf_adapter *ad,static int ice_switch_parse_action (struct ice_pf *pf, -const struct rte_flow_action *actions, +const struct rte_flow_action *action,uint32_t priority,struct rte_flow_error *error,struct ice_adv_rule_info *rule_info) {struct ice_vsi *vsi = pf->main_vsi; -struct rte_eth_dev_data *dev_data = pf->adapter->pf.dev_data;const struct rte_flow_action_queue *act_q;const struct rte_flow_action_rss *act_qgrop; -uint16_t base_queue, i; -const struct rte_flow_action *action; +uint16_t base_queue;enum rte_flow_action_type action_type; -uint16_t valid_qgrop_number[MAX_QGRP_NUM_TYPE ] = { -2 ,4 ,8 ,16 ,32 ,64 ,128 }; base_queue = pf->base_queue + vsi->base_queue; -for (action = actions; action->type != -RTE_FLOW_ACTION_TYPE_END ; action++) { - action_type = action->type; -switch (action_type) { -case RTE_FLOW_ACTION_TYPE_RSS : - act_qgrop = action->conf; -if (act_qgrop->queue_num <=1 ) - goto error; - rule_info->sw_act.fltr_act = -ICE_FWD_TO_QGRP ; - rule_info->sw_act.fwd_id.q_id = - base_queue + act_qgrop->queue[0 ]; -for (i =0 ; i <MAX_QGRP_NUM_TYPE ; i++) { -if (act_qgrop->queue_num == - valid_qgrop_number[i]) -break ; - } -if (i ==MAX_QGRP_NUM_TYPE ) - goto error; -if ((act_qgrop->queue[0 ] + - act_qgrop->queue_num) > - dev_data->nb_rx_queues) - goto error1; -for (i =0 ; i < act_qgrop->queue_num -1 ; i++) -if (act_qgrop->queue[i +1 ] != - act_qgrop->queue[i] +1 ) - goto error2; - rule_info->sw_act.qgrp_size = - act_qgrop->queue_num; -break ; -case RTE_FLOW_ACTION_TYPE_QUEUE : - act_q = action->conf; -if (act_q->index >= dev_data->nb_rx_queues) - goto error; - rule_info->sw_act.fltr_act = -ICE_FWD_TO_Q ; - rule_info->sw_act.fwd_id.q_id = - base_queue + act_q->index; -break ; - -case RTE_FLOW_ACTION_TYPE_DROP : - rule_info->sw_act.fltr_act = -ICE_DROP_PACKET ; -break ; - -case RTE_FLOW_ACTION_TYPE_VOID : -break ; - -default : - goto error; - } + action_type = action->type; +switch (action_type) { +case RTE_FLOW_ACTION_TYPE_RSS : + act_qgrop = action->conf; + rule_info->sw_act.fltr_act =ICE_FWD_TO_QGRP ; + rule_info->sw_act.fwd_id.q_id = base_queue + act_qgrop->queue[0 ]; + rule_info->sw_act.qgrp_size = act_qgrop->queue_num; +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : + act_q = action->conf; + rule_info->sw_act.fltr_act =ICE_FWD_TO_Q ; + rule_info->sw_act.fwd_id.q_id = base_queue + act_q->index; +break ; +case RTE_FLOW_ACTION_TYPE_DROP : + rule_info->sw_act.fltr_act =ICE_DROP_PACKET ; +break ; +default : +rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Invalid action type or queue number" ); +return -rte_errno; } rule_info->sw_act.vsi_handle = vsi->idx;
@@ -1699,65 +1619,120 @@ ice_switch_parse_action(struct ice_pf *pf, rule_info->priority =ICE_SW_PRI_BASE - priority;return 0 ; - -error: -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid action type or queue number" ); -return -rte_errno; - -error1: -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid queue region indexes" ); -return -rte_errno; - -error2: -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Discontinuous queue region" ); -return -rte_errno; }static int -ice_switch_check_action (const struct rte_flow_action *actions, -struct rte_flow_error *error) +ice_switch_dcf_action_check (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) { +struct ice_dcf_adapter *ad = param->driver_ctx;const struct rte_flow_action *action;enum rte_flow_action_type action_type; -uint16_t actions_num =0 ; - -for (action = actions; action->type != -RTE_FLOW_ACTION_TYPE_END ; action++) { - action_type = action->type; -switch (action_type) { -case RTE_FLOW_ACTION_TYPE_RSS : -case RTE_FLOW_ACTION_TYPE_QUEUE : -case RTE_FLOW_ACTION_TYPE_DROP : -case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT : -case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR : - actions_num++; -break ; -case RTE_FLOW_ACTION_TYPE_VOID : -continue ; -default : -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid action type" ); -return -rte_errno; +const struct rte_flow_action_ethdev *act_ethdev; +const struct rte_eth_dev *repr_dev; + + action = actions->actions[0 ]; + action_type = action->type; + +switch (action_type) { +case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR : +case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT : + { +uint16_t expected_port_id, backer_port_id; + act_ethdev = action->conf; + +if (!rte_eth_dev_is_valid_port (act_ethdev->port_id)) + goto invalid_port_id; + + expected_port_id = ad->parent.pf.dev_data->port_id; + +if (action_type ==RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR ) { +if (expected_port_id != act_ethdev->port_id) + goto invalid_port_id; + }else { + repr_dev = &rte_eth_devices[act_ethdev->port_id]; + +if (!repr_dev->data) + goto invalid_port_id; + + backer_port_id = repr_dev->data->backer_port_id; + +if (backer_port_id != expected_port_id) + goto invalid_port_id; } + +break ; +invalid_port_id: +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid port ID" ); + } +case RTE_FLOW_ACTION_TYPE_DROP : +break ; +default : +/* Should never reach */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid action type" ); } -if (actions_num !=1 ) { -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid action number" ); -return -rte_errno; +return 0 ; +} + +static int +ice_switch_action_check (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +struct ice_adapter *ad = param->driver_ctx; +struct ice_pf *pf = &ad->pf; +struct rte_eth_dev_data *dev_data = pf->dev_data; +const struct rte_flow_action *action = actions->actions[0 ]; + +switch (action->type) { +case RTE_FLOW_ACTION_TYPE_RSS : + { +const struct rte_flow_action_rss *act_qgrop; + act_qgrop = action->conf; + +/* Check bounds on number of queues */ +if (act_qgrop->queue_num <2 || act_qgrop->queue_num >ICE_SW_MAX_QUEUES ) + goto err_rss; + +/* must be power of 2 */ +if (!rte_is_power_of_2 (act_qgrop->queue_num)) + goto err_rss; + +/* queues are monotonous and contiguous so check last queue */ +if ((act_qgrop->queue[0 ] + act_qgrop->queue_num) > dev_data->nb_rx_queues) + goto err_rss; + +break ; +err_rss: +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid queue region" ); + } +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *act_q; + act_q = action->conf; +if (act_q->index >= dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid queue" ); + } + +break ; + } +case RTE_FLOW_ACTION_TYPE_DROP : +break ; +default : +/* Should never reach */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid action type" ); }return 0 ;
@@ -1788,11 +1763,39 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,struct ci_flow_attr_check_param attr_param = { .allow_priority = true, }; +struct ci_flow_actions parsed_actions = {0 }; +struct ci_flow_actions_check_param dcf_param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT , +RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =1 , + .check = ice_switch_dcf_action_check, + }; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =1 , + .check = ice_switch_action_check, + .driver_ctx = ad, + .rss_queues_contig = true, + }; ret =ci_flow_check_attr (attr, &attr_param, error);if (ret)return ret; + ret =ci_flow_check_actions (actions, (ad->hw.dcf_enabled) ? &dcf_param : ¶m, + &parsed_actions, error); +if (ret) + goto error; +/* Allow only two priority values - 0 or 1 */ if (attr->priority >1 ) { rte_flow_error_set(error, EINVAL,
@@ -1870,16 +1873,12 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,memset (&rule_info,0 ,sizeof (rule_info)); rule_info.tun_type = tun_type; - ret =ice_switch_check_action (actions, error); -if (ret) - goto error; -if (ad->hw.dcf_enabled) - ret =ice_switch_parse_dcf_action ((void *)ad, actions, attr->priority, - error, &rule_info); + ret =ice_switch_parse_dcf_action (parsed_actions.actions[0 ], + attr->priority, error, &rule_info);else - ret =ice_switch_parse_action (pf, actions, attr->priority, error, - &rule_info); + ret =ice_switch_parse_action (pf, parsed_actions.actions[0 ], + attr->priority, error, &rule_info);if (ret) goto error;
Signature · 1 line
2.47.3
PATCH v5 27/27 net/ice: use common action checks for ACL
In reply to Anatoly BurakovFrom: Vladimir Medvedkin <[email protected]>
Use the common flow action checking parsing infrastructure for checking flow actions for ACL filter.
--- drivers/net/intel/ice/ice_acl_filter.c | 143 +++++++++++++++---------- 1 file changed, 84 insertions(+), 59 deletions(-)
drivers/net/intel/ice/ice_acl_filter.c +84 -59
@@ -645,60 +645,6 @@ ice_acl_filter_free(struct rte_flow *flow) flow->rule =NULL ; } -static int -ice_acl_parse_action(__rte_unused struct ice_adapter *ad, -const struct rte_flow_action actions[], -struct rte_flow_error *error, -struct ice_acl_conf *filter) -{ -struct ice_pf *pf = &ad->pf; -const struct rte_flow_action_queue *act_q; -uint32_t dest_num =0 ; - -for (; actions->type !=RTE_FLOW_ACTION_TYPE_END ; actions++) { -switch (actions->type) { -case RTE_FLOW_ACTION_TYPE_VOID : -break ; -case RTE_FLOW_ACTION_TYPE_DROP : - dest_num++; - - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DROP_PKT ; -break ; -case RTE_FLOW_ACTION_TYPE_QUEUE : - dest_num++; - - act_q = actions->conf; - filter->input.q_index = act_q->index; -if (filter->input.q_index >= - pf->dev_data->nb_rx_queues) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid queue for FDIR." ); -return -rte_errno; - } - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX ; -break ; -default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Invalid action." ); -return -rte_errno; - } - } - -if (dest_num ==0 || dest_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Unsupported action combination" ); -return -rte_errno; - } - -return 0 ; -} - static int ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad, const struct rte_flow_item pattern[],
@@ -966,6 +912,69 @@ ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad,return 0 ; } +static int +ice_acl_parse_action (const struct ci_flow_actions *actions, +struct ice_acl_conf *filter, +struct rte_flow_error *error) +{ +const struct rte_flow_action *act = actions->actions[0 ]; + +switch (act->type) { +case RTE_FLOW_ACTION_TYPE_DROP : + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DROP_PKT ; +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *act_q = act->conf; + + filter->input.q_index = act_q->index; + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX ; +break ; + } +default : +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"Invalid action." ); + } + +return 0 ; +} + +static int +ice_acl_parse_action_check (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +struct ice_adapter *ad = param->driver_ctx; +struct ice_pf *pf = &ad->pf; +const struct rte_flow_action *act = actions->actions[0 ]; + +switch (act->type) { +case RTE_FLOW_ACTION_TYPE_DROP : +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *act_q = act->conf; + +if (act_q->index >= pf->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"Invalid queue for ACL." ); + } +break ; + } +default : +/* shouldn't happen */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"Invalid action." ); + } + +return 0 ; +} + static int ice_acl_parse(struct ice_adapter *ad, struct ice_pattern_match_item *array,
@@ -976,17 +985,33 @@ ice_acl_parse(struct ice_adapter *ad,void **meta, struct rte_flow_error *error) { + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =1 , + .check = ice_acl_parse_action_check, + .driver_ctx = ad, + };struct ice_pf *pf = &ad->pf;struct ice_acl_conf *filter = &pf->acl.conf;struct ice_pattern_match_item *item =NULL ;uint64_t input_set;int ret; - ret =ci_flow_check_attr (attr,NULL , error); -if (ret) -return ret; -memset (filter,0 ,sizeof (*filter)); + + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; + + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret) +return ret; + item =ice_search_pattern_match_item (ad, pattern, array, array_len, error);if (!item)
@@ -1005,7 +1030,7 @@ ice_acl_parse(struct ice_adapter *ad, goto error; } - ret =ice_acl_parse_action (ad, actions, error, filter); + ret =ice_acl_parse_action (&parsed_actions, filter, error);if (ret) goto error;
Signature · 1 line
2.47.3
Quoted 22 lines · Anatoly Burakov
This patchset introduces common flow attr/action checking infrastructure to some Intel PMD's (IXGBE, I40E, IAVF, and ICE). The aim is to reduce code duplication, simplify implementation of new parsers/verification of existing ones, and make action/attr handling more consistent across drivers.
v5:
- Add missing patch for component/class name compile time constant
- Fixed missing RSS queue contiguousness checksv4:
- First few commits were integrated as part of a different patchset
- Added more logging to common infrastructure
- RSS validation now allows discontiguous queue lists by default
- Fixed some checks being too stringent and failing common validationv3:
- Rebase on latest next-net-intel
- Added 4 new commits that have to do with not usingrte_eth_devinrte_flow
- Converted the remaining commits to use adapter structures everywhere
- Minor fixes in how return values are handled
- Fixed incorrect check in i40e RSS validation
Quoted 6 lines
v2:
- Rebase on latest main
- Now depends on series 37585 [1][1] https://patches.dpdk.org/project/dpdk/list/?series=37585
While I haven't worked through the details patch-by-patch, the whole concept seems good, and the implementation parts I have looked at seem fine. Any new versions should be applicable ok to main, since the net and net-intel trees have now been pulled, which means we'll get a good AI review too. For now, LGTM
Quoted 62 lines
Anatoly Burakov (21):
eal/common: add token concatenation macronet/intel/common: add common flow action parsingnet/intel/common: add common flow attr validation net/ixgbe: use common checks in ethertype filter net/ixgbe: use common checks in syn filter net/ixgbe: use common checks in L2 tunnel filter net/ixgbe: use common checks in ntuple filter net/ixgbe: use common checks in security filter net/ixgbe: use common checks in FDIR filters net/ixgbe: use common checks in RSS filter net/i40e: use common flow attribute checks net/i40e: refactor RSS flow parameter checks net/i40e: use common action checks for ethertype net/i40e: use common action checks for FDIR net/i40e: use common action checks for tunnel net/iavf: use common flow attribute checks net/iavf: use common action checks for IPsec net/iavf: use common action checks for hash net/iavf: use common action checks for FDIR net/iavf: use common action checks for fsub net/iavf: use common action checks for flow queryBruce Richardson (1):
build: add build defines for component name and classVladimir Medvedkin (5):
net/ice: use common flow attribute checks
net/ice: use common action checks for hash
net/ice: use common action checks for FDIR
net/ice: use common action checks for switch
net/ice: use common action checks for ACLdrivers/meson.build | 2 + drivers/net/intel/common/flow_check.h | 347 ++++++ drivers/net/intel/common/log.h | 40 + drivers/net/intel/i40e/i40e_ethdev.h | 1 - drivers/net/intel/i40e/i40e_flow.c | 433 +++----- drivers/net/intel/i40e/i40e_hash.c | 438 +++++--- drivers/net/intel/i40e/i40e_hash.h | 2 +- drivers/net/intel/iavf/iavf_fdir.c | 368 +++--- drivers/net/intel/iavf/iavf_fsub.c | 262 ++--- drivers/net/intel/iavf/iavf_generic_flow.c | 107 +- drivers/net/intel/iavf/iavf_generic_flow.h | 2 +- drivers/net/intel/iavf/iavf_hash.c | 153 +-- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 43 +- drivers/net/intel/ice/ice_acl_filter.c | 146 ++- drivers/net/intel/ice/ice_fdir_filter.c | 384 ++++--- drivers/net/intel/ice/ice_generic_flow.c | 59 +- drivers/net/intel/ice/ice_generic_flow.h | 2 +- drivers/net/intel/ice/ice_hash.c | 189 ++-- drivers/net/intel/ice/ice_switch_filter.c | 389 +++---- drivers/net/intel/ixgbe/ixgbe_flow.c | 1166 +++++++------------- lib/eal/include/rte_common.h | 4 + lib/meson.build | 2 + 22 files changed, 2271 insertions(+), 2268 deletions(-) create mode 100644 drivers/net/intel/common/flow_check.h create mode 100644 drivers/net/intel/common/log.hSignature · 1 line
2.47.3
v6 cover Add common flow attr/action parsing infrastructure to Intel PMD's
In reply to Anatoly BurakovThis patchset introduces common flow attr/action checking infrastructure to some Intel PMD's (IXGBE, I40E, IAVF, and ICE). The aim is to reduce code duplication, simplify implementation of new parsers/verification of existing ones, and make action/attr handling more consistent across drivers.
v6:
- Increase max number of actions to 32
- Add missing flow item types from list of types needing conf
- Improved egress/ingress handling
- ixgbe: allow mark and drop combination of actions
- ixgbe: fix set-then-reset when initializing rules for fdir engine
v5:
- Add missing patch for component/class name compile time constant
- Fixed missing RSS queue contiguousness checks
v4:
- First few commits were integrated as part of a different patchset
- Added more logging to common infrastructure
- RSS validation now allows discontiguous queue lists by default
- Fixed some checks being too stringent and failing common validation
v3:
- Rebase on latest next-net-intel
- Added 4 new commits that have to do with not using rte_eth_dev in rte_flow
- Converted the remaining commits to use adapter structures everywhere
- Minor fixes in how return values are handled
- Fixed incorrect check in i40e RSS validation
v2:
- Rebase on latest main
- Now depends on series 37585 [1]
[1] https://patches.dpdk.org/project/dpdk/list/?series=37585
Anatoly Burakov (21):
eal/common: add token concatenation macro net/intel/common: add common flow action parsing net/intel/common: add common flow attr validation net/ixgbe: use common checks in ethertype filter net/ixgbe: use common checks in syn filter net/ixgbe: use common checks in L2 tunnel filter net/ixgbe: use common checks in ntuple filter net/ixgbe: use common checks in security filter net/ixgbe: use common checks in FDIR filters net/ixgbe: use common checks in RSS filter net/i40e: use common flow attribute checks net/i40e: refactor RSS flow parameter checks net/i40e: use common action checks for ethertype net/i40e: use common action checks for FDIR net/i40e: use common action checks for tunnel net/iavf: use common flow attribute checks net/iavf: use common action checks for IPsec net/iavf: use common action checks for hash net/iavf: use common action checks for FDIR net/iavf: use common action checks for fsub net/iavf: use common action checks for flow query
Bruce Richardson (1):
build: add build defines for component name and class
Vladimir Medvedkin (5):
net/ice: use common flow attribute checks
net/ice: use common action checks for hash
net/ice: use common action checks for FDIR
net/ice: use common action checks for switch
net/ice: use common action checks for ACL
drivers/meson.build | 2 + drivers/net/intel/common/flow_check.h | 349 ++++++ drivers/net/intel/common/log.h | 40 + drivers/net/intel/i40e/i40e_ethdev.h | 1 - drivers/net/intel/i40e/i40e_flow.c | 433 +++----- drivers/net/intel/i40e/i40e_hash.c | 438 +++++--- drivers/net/intel/i40e/i40e_hash.h | 2 +- drivers/net/intel/iavf/iavf_fdir.c | 368 +++---- drivers/net/intel/iavf/iavf_fsub.c | 262 ++--- drivers/net/intel/iavf/iavf_generic_flow.c | 107 +- drivers/net/intel/iavf/iavf_generic_flow.h | 2 +- drivers/net/intel/iavf/iavf_hash.c | 153 +-- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 43 +- drivers/net/intel/ice/ice_acl_filter.c | 146 ++- drivers/net/intel/ice/ice_fdir_filter.c | 384 ++++--- drivers/net/intel/ice/ice_generic_flow.c | 59 +- drivers/net/intel/ice/ice_generic_flow.h | 2 +- drivers/net/intel/ice/ice_hash.c | 189 ++-- drivers/net/intel/ice/ice_switch_filter.c | 389 +++---- drivers/net/intel/ixgbe/ixgbe_flow.c | 1161 +++++++------------- lib/eal/include/rte_common.h | 4 + lib/meson.build | 2 + 22 files changed, 2264 insertions(+), 2272 deletions(-) create mode 100644 drivers/net/intel/common/flow_check.h create mode 100644 drivers/net/intel/common/log.h
Signature · 1 line
2.47.3
PATCH v6 1/27 build: add build defines for component name and class
From: Bruce Richardson <[email protected]>
When building each component, pass in -D flags to define for it the component class and name. This allows any files which may be used multiple times to identify what component is including them.
--- drivers/meson.build | 2 ++ lib/meson.build | 2 ++ 2 files changed, 4 insertions(+)
drivers/meson.build +2 -0
@@ -263,6 +263,8 @@ foreach subpath:subdirs enabled_drivers += name lib_name = '_'.join(['rte', class, name]) + cflags += '-DRTE_COMPONENT_CLASS=pmd_' + class + cflags += '-DRTE_COMPONENT_NAME=' + name cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=' + '.'.join([log_prefix, name]) if annotate_locks and cc.get_id() == 'clang' cflags += '-DRTE_ANNOTATE_LOCKS'
lib/meson.build +2 -0
@@ -237,6 +237,8 @@ foreach l:libraries cflags += '-DRTE_USE_FUNCTION_VERSIONING' endif cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=lib.' + l + cflags += '-DRTE_COMPONENT_CLASS=lib' + cflags += '-DRTE_COMPONENT_NAME=' + name if annotate_locks and cc.get_id() == 'clang' cflags += '-DRTE_ANNOTATE_LOCKS' cflags += '-Wthread-safety'
Signature · 1 line
2.47.3
PATCH v6 2/27 eal/common: add token concatenation macro
In reply to Anatoly BurakovAdd RTE_CONCAT() macro to enable token concatenation with proper macro expansion.
--- lib/eal/include/rte_common.h | 4 ++++ 1 file changed, 4 insertions(+)
lib/eal/include/rte_common.h +4 -0
@@ -918,6 +918,10 @@ __extension__ typedef uint64_t RTE_MARKER64[0];/** Take a macro value and get a string version of it */ #define RTE_STR (x) _RTE_STR(x) +/** Concatenate two tokens after expanding macros in both. */ +#define _RTE_CONCAT2 (a, b) a ## b +#define RTE_CONCAT (a, b) _RTE_CONCAT2(a, b) +/** * ISO C helpers to modify format strings using variadic macros. * This is a replacement for the ", ## __VA_ARGS__" GNU extension.
Signature · 1 line
2.47.3
PATCH v6 3/27 net/intel/common: add common flow action parsing
In reply to Anatoly BurakovCurrently, each driver has their own code for action parsing, which results in a lot of duplication and subtle mismatches in behavior between drivers.
Add common infrastructure, based on the following assumptions:
- All drivers support at most 32 actions at once, but usually far less
- Not every action is supported by all drivers
- We can check a few common things to filter out obviously wrong actions
- Driver performs semantic checks on all valid actions
So, the intention is to reject everything we can reasonably reject at the outset without knowing anything about the drivers, parametrize what is trivial to parametrize, and leave the rest for the driver to implement.
While we're at it, also add logging infrastructure for Intel common code, using the new component name defines that are automatically passed to each DPDK driver as it is being built.
--- drivers/net/intel/common/flow_check.h | 279 ++++++++++++++++++++++++++ drivers/net/intel/common/log.h | 40 ++++ 2 files changed, 319 insertions(+) create mode 100644 drivers/net/intel/common/flow_check.h create mode 100644 drivers/net/intel/common/log.h
drivers/net/intel/common/flow_check.h new file +279 -0
@@ -0,0 +1,279 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2025 Intel Corporation +*/ + +#ifndef _COMMON_INTEL_FLOW_CHECK_H_ +#define _COMMON_INTEL_FLOW_CHECK_H_ + +#include <bus_pci_driver.h> +#include <ethdev_driver.h> + +#include "log.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* +* Common attr and action validation code for Intel drivers. +*/ + +/** +* Maximum number of actions that can be stored in a parsed action list. +*/ +#define CI_FLOW_PARSED_ACTIONS_MAX 32 + +/* Actions that are reasonably expected to have a conf structure */ +static const enum rte_flow_action_type need_conf[] = { +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_VF , +RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR , +RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT , +RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP , +RTE_FLOW_ACTION_TYPE_PROG , +RTE_FLOW_ACTION_TYPE_COUNT , +RTE_FLOW_ACTION_TYPE_MARK , +RTE_FLOW_ACTION_TYPE_SECURITY , +RTE_FLOW_ACTION_TYPE_END +}; + +/** +* Is action type in this list of action types? +*/ +static inline bool +ci_flow_action_type_in_list (const enum rte_flow_action_type type, +const enum rte_flow_action_type list[]) +{ +size_t i =0 ; +while (list[i] !=RTE_FLOW_ACTION_TYPE_END ) { +if (type == list[i]) +return true; + i++; + } +return false; +} + +/* Forward declarations */ +struct ci_flow_actions ; +struct ci_flow_actions_check_param ; + +static inline const char * +ci_flow_action_type_to_str (enum rte_flow_action_type type) +{ +const char *name =NULL ; +int ret; + + ret =rte_flow_conv (RTE_FLOW_CONV_OP_ACTION_NAME_PTR , + &name,sizeof (name), (const void *)(uintptr_t )type,NULL ); +if (ret <0 || name ==NULL ) +return "UNKNOWN" ; + +return name; +} + +/** +* Driver-specific action list validation callback. +* +* Performs driver-specific validation of action parameter list. +* Called after all actions have been parsed and added to the list, +* allowing validation based on the complete action set. +* +* @param actions +* The complete list of parsed actions (for context-dependent validation). +* @param driver_ctx +* Opaque driver context (e.g., adapter/queue configuration). +* @param error +* Pointer to rte_flow_error for reporting failures. +* @return +* 0 on success, negative errno on failure. +*/ +typedef int (*ci_flow_actions_check_fn )(const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error); + +/** +* List of actions that we know we've validated. +*/ +struct ci_flow_actions { +/* Number of actions in the list. */ +uint8_t count; +/* Parsed actions array. */ +struct rte_flow_action const *actions[CI_FLOW_PARSED_ACTIONS_MAX ]; +}; + +/** +* Parameters for action list validation. Any element can be NULL/0 as checks are only performed +* against constraints specified. +*/ +struct ci_flow_actions_check_param { +/** +* Driver-specific context pointer (e.g., adapter/queue configuration). Can be NULL. +*/ +void *driver_ctx; +/** +* Driver-specific action list validation callback. Can be NULL. +*/ +ci_flow_actions_check_fn check; +/** +* Allowed action types for this parse parameter. Must be terminated with +* RTE_FLOW_ACTION_TYPE_END. Can be NULL. +*/ +const enum rte_flow_action_type *allowed_types; +size_t max_actions;/**< Maximum number of actions allowed. */ +bool rss_queues_contig;/**< If true, RSS queues must be contiguous. */ +}; + +static inline int +__flow_action_check_rss (const struct rte_flow_action_rss *rss, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +uint32_t qnum, q; + + qnum = rss->queue_num; + +/* either we have both queues and queue number, or we have neither */ +if ((qnum ==0 ) != (rss->queue ==NULL )) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"If queue number is specified, queue array must also be specified" ); + } +/* check if queues are monotonic */ +for (q =1 ; q < qnum; q++) { +if (rss->queue[q] < rss->queue[q -1 ]) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"RSS queues must be in ascending order" ); + } +/* if user has requested contiguousness, check that as well */ +if (param ==NULL || !param->rss_queues_contig) +continue ; +if (rss->queue[q] != rss->queue[0 ] + q) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"RSS queues must be contiguous" ); + } + } + +/* either we have both key and key length, or we have neither */ +if ((rss->key_len ==0 ) != (rss->key ==NULL )) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"If RSS key is specified, key length must also be specified" ); + } +return 0 ; +} + +static inline int +__flow_action_check_generic (const struct rte_flow_action *action, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +/* is this action in our allowed list? */ +if (param !=NULL && param->allowed_types !=NULL && + !ci_flow_action_type_in_list (action->type, param->allowed_types)) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Unsupported action" ); + } +/* do we need to validate presence of conf? */ +if (ci_flow_action_type_in_list (action->type, need_conf)) { +if (action->conf ==NULL ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , action, +"Action requires configuration" ); + } + } + +/* type-specific validation */ +switch (action->type) { +case RTE_FLOW_ACTION_TYPE_RSS : + { +const struct rte_flow_action_rss *rss = + (const struct rte_flow_action_rss *)action->conf; +int ret; + + ret =__flow_action_check_rss (rss, param, error); +if (ret <0 ) +return ret; +break ; + } +default : +/* no specific validation */ +break ; + } + +return 0 ; +} + +/** +* Validate and parse a list of rte_flow_action into a parsed action list. +* +* @param actions pointer to array of rte_flow_action, terminated by RTE_FLOW_ACTION_TYPE_END +* @param param pointer to ci_flow_actions_check_param structure (can be NULL) +* @param parsed_actions pointer to ci_flow_actions structure to store parsed actions +* @param error pointer to rte_flow_error structure for error reporting +* +* @return 0 on success, negative errno on failure. +*/ +static inline int +ci_flow_check_actions (const struct rte_flow_action *actions, +const struct ci_flow_actions_check_param *param, +struct ci_flow_actions *parsed_actions, +struct rte_flow_error *error) +{ +size_t i =0 ; +int ret; + +if (actions ==NULL ) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , +NULL ,"Missing actions" ); + } + +/* reset the list */ + *parsed_actions = (struct ci_flow_actions ){0 }; + +while (actions[i].type !=RTE_FLOW_ACTION_TYPE_END ) { +const struct rte_flow_action *action = &actions[i++]; + +/* skip VOID actions */ +if (action->type ==RTE_FLOW_ACTION_TYPE_VOID ) +continue ; + +/* generic validation for actions - this will check against param as well */ + ret =__flow_action_check_generic (action, param, error); +if (ret <0 ) +return ret; + +/* check against global maximum number of actions */ +if (parsed_actions->count >=RTE_DIM (parsed_actions->actions)) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Too many actions" ); + } +/* user may have specified a maximum number of actions */ +if (param !=NULL && param->max_actions !=0 && + parsed_actions->count >= param->max_actions) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Too many actions" ); + } +/* add action to the list */ +CI_DRV_LOG (DEBUG ,"Parsed action %u: type=%s" , parsed_actions->count, +ci_flow_action_type_to_str (action->type)); + parsed_actions->actions[parsed_actions->count++] = action; + } + +/* now, call into user validation if specified */ +if (param !=NULL && param->check !=NULL ) { + ret = param->check (parsed_actions, param, error); +if (ret <0 ) +return ret; + } +/* if we didn't parse anything, valid action list is empty */ +return parsed_actions->count ==0 ? -EINVAL :0 ; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _COMMON_INTEL_FLOW_CHECK_H_ */
drivers/net/intel/common/log.h new file +40 -0
@@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2026 Intel Corporation +*/ + +#ifndef _COMMON_INTEL_LOG_H_ +#define _COMMON_INTEL_LOG_H_ + +#include <rte_log.h> + +/* +* Common logging for shared Intel driver code. +* +* This header must only be included from driver translation units, where the +* build system has already defined RTE_COMPONENT_NAME (e.g. "iavf"). It uses +* that token to reference the per-driver logtype variable that every Intel +* driver registers (e.g. iavf_logtype_driver), so no additional setup is +* needed beyond what each driver already provides. +* +* Usage: CI_DRV_LOG(DEBUG, "format %s", arg); +*/ + +#ifndef RTE_COMPONENT_NAME +/* CI_DRV_LOG is a no-op when included outside a driver build context. */ +#define CI_DRV_LOG (level, fmt, ...) do { } while (0) +#else /* RTE_COMPONENT_NAME */ + +/* Resolves to the per-driver logtype variable, e.g. iavf_logtype_driver. */ +#define CI_DRV_LOGTYPE RTE_CONCAT(RTE_COMPONENT_NAME, _logtype_driver) + +/* Forward-declare the logtype so shared headers need not include driver headers. */ +extern int CI_DRV_LOGTYPE ; + +#define CI_DRV_LOG (level, fmt, ...) \ + rte_log(RTE_LOG_##level, CI_DRV_LOGTYPE, \ + "PMD_INTEL_COMMON: %s(): " fmt "\n", \ + __func__, ##__VA_ARGS__) + +#endif /* RTE_COMPONENT_NAME */ + +#endif /* _COMMON_INTEL_LOG_H_ */
Signature · 1 line
2.47.3
Re: [PATCH v6 03/27] net/intel/common: add common flow action parsing
Quoted 26 lines · Anatoly Burakov
Currently, each driver has their own code for action parsing, which results in a lot of duplication and subtle mismatches in behavior between drivers.
Add common infrastructure, based on the following assumptions:
- All drivers support at most 32 actions at once, but usually far less
- Not every action is supported by all drivers
- We can check a few common things to filter out obviously wrong actions
- Driver performs semantic checks on all valid actionsSo, the intention is to reject everything we can reasonably reject at the outset without knowing anything about the drivers, parametrize what is trivial to parametrize, and leave the rest for the driver to implement.
While we're at it, also add logging infrastructure for Intel common code, using the new component name defines that are automatically passed to each DPDK driver as it is being built.
Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/common/flow_check.h | 279 ++++++++++++++++++++++++++ drivers/net/intel/common/log.h | 40 ++++ 2 files changed, 319 insertions(+) create mode 100644 drivers/net/intel/common/flow_check.h create mode 100644 drivers/net/intel/common/log.h
<snip>
Quoted 52 lines
drivers/net/intel/common/flow_check.h new file +52
-0+/** +* Validate and parse a list of rte_flow_action into a parsed action list. +* +* @param actions pointer to array of rte_flow_action, terminated by RTE_FLOW_ACTION_TYPE_END +* @param param pointer to ci_flow_actions_check_param structure (can be NULL) +* @param parsed_actions pointer to ci_flow_actions structure to store parsed actions +* @param error pointer to rte_flow_error structure for error reporting +* +* @return 0 on success, negative errno on failure. +*/ +static inline int +ci_flow_check_actions (const struct rte_flow_action *actions, +const struct ci_flow_actions_check_param *param, +struct ci_flow_actions *parsed_actions, +struct rte_flow_error *error) +{ +size_t i =0 ; +int ret; + +if (actions ==NULL ) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , +NULL ,"Missing actions" ); + } + +/* reset the list */ + *parsed_actions = (struct ci_flow_actions ){0 }; + +while (actions[i].type !=RTE_FLOW_ACTION_TYPE_END ) { +const struct rte_flow_action *action = &actions[i++]; + +/* skip VOID actions */ +if (action->type ==RTE_FLOW_ACTION_TYPE_VOID ) +continue ; + +/* generic validation for actions - this will check against param as well */ + ret =__flow_action_check_generic (action, param, error); +if (ret <0 ) +return ret; + +/* check against global maximum number of actions */ +if (parsed_actions->count >=RTE_DIM (parsed_actions->actions)) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Too many actions" ); + } +/* user may have specified a maximum number of actions */ +if (param !=NULL && param->max_actions !=0 && + parsed_actions->count >= param->max_actions) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Too many actions" ); + } +/* add action to the list */ + CI_DRV_LOG(DEBUG, "Parsed action %u: type=%s", parsed_actions->count,
drivers/net/intel/common/flow_check.h line 270
Quoted 10 lines
drivers/net/intel/common/flow_check.h new file +10
-0+ ci_flow_action_type_to_str(action->type)); + parsed_actions->actions[parsed_actions->count++] = action; + } + +/* now, call into user validation if specified */ +if (param !=NULL && param->check !=NULL ) { + ret = param->check (parsed_actions, param, error); +if (ret <0 ) +return ret; + }
Running an AI review on this code myself, it highlights the fact that we are missing a check for an empty parsed_actions array here, and not all check handlers verify the length as being >0 before dereferencing. For example, in patch 10, the callbacks don't explicitly check for empty lists I think it would be reasonable to have the return -EINVAL before this callback check, right?
Quoted 7 lines
drivers/net/intel/common/flow_check.h new file +7
-0+/* if we didn't parse anything, valid action list is empty */ +return parsed_actions->count ==0 ? -EINVAL :0 ; +} + +#ifdef __cplusplus +} +#endif
<snip>
Re: [PATCH v6 03/27] net/intel/common: add common flow action parsing
Quoted 91 lines · Bruce Richardson
Quoted 26 lines · Anatoly Burakov
Currently, each driver has their own code for action parsing, which results in a lot of duplication and subtle mismatches in behavior between drivers.
Add common infrastructure, based on the following assumptions:
- All drivers support at most 32 actions at once, but usually far less
- Not every action is supported by all drivers
- We can check a few common things to filter out obviously wrong actions
- Driver performs semantic checks on all valid actionsSo, the intention is to reject everything we can reasonably reject at the outset without knowing anything about the drivers, parametrize what is trivial to parametrize, and leave the rest for the driver to implement.
While we're at it, also add logging infrastructure for Intel common code, using the new component name defines that are automatically passed to each DPDK driver as it is being built.
Signed-off-by Anatoly Burakov <[email protected]>--- drivers/net/intel/common/flow_check.h | 279 ++++++++++++++++++++++++++ drivers/net/intel/common/log.h | 40 ++++ 2 files changed, 319 insertions(+)create mode 100644
drivers/net/intel/common/flow_check.hcreate mode 100644drivers/net/intel/common/log.h<snip>
Quoted 61 lines
drivers/net/intel/common/flow_check.h new file +61
-0+/** +* Validate and parse a list of rte_flow_action into a parsed action list. +* +* @param actions pointer to array of rte_flow_action, terminated by RTE_FLOW_ACTION_TYPE_END +* @param param pointer to ci_flow_actions_check_param structure (can be NULL) +* @param parsed_actions pointer to ci_flow_actions structure to store parsed actions +* @param error pointer to rte_flow_error structure for error reporting +* +* @return 0 on success, negative errno on failure. +*/ +static inline int +ci_flow_check_actions (const struct rte_flow_action *actions, +const struct ci_flow_actions_check_param *param, +struct ci_flow_actions *parsed_actions, +struct rte_flow_error *error) +{ +size_t i =0 ; +int ret; + +if (actions ==NULL ) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , +NULL ,"Missing actions" ); + } + +/* reset the list */ + *parsed_actions = (struct ci_flow_actions ){0 }; + +while (actions[i].type !=RTE_FLOW_ACTION_TYPE_END ) { +const struct rte_flow_action *action = &actions[i++]; + +/* skip VOID actions */ +if (action->type ==RTE_FLOW_ACTION_TYPE_VOID ) +continue ; + +/* generic validation for actions - this will check against param as well */ + ret =__flow_action_check_generic (action, param, error); +if (ret <0 ) +return ret; + +/* check against global maximum number of actions */ +if (parsed_actions->count >=RTE_DIM (parsed_actions->actions)) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Too many actions" ); + } +/* user may have specified a maximum number of actions */ +if (param !=NULL && param->max_actions !=0 && + parsed_actions->count >= param->max_actions) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Too many actions" ); + } +/* add action to the list */ +CI_DRV_LOG (DEBUG ,"Parsed action %u: type=%s" , parsed_actions->count, +ci_flow_action_type_to_str (action->type)); + parsed_actions->actions[parsed_actions->count++] = action; + } + +/* now, call into user validation if specified */ +if (param !=NULL && param->check !=NULL ) { + ret = param->check (parsed_actions, param, error); +if (ret <0 ) +return ret;
Quoted 8 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ }Running an AI review on this code myself, it highlights the fact that we are missing a check for an empty
parsed_actionsarray here, and not all check handlers verify the length as being >0 before dereferencing. For example, in patch 10, the callbacks don't explicitly check for empty lists I think it would be reasonable to have the return-EINVALbefore this callback check, right?
Yep, that is correct. Empty list should fail *before* we go into use callbacks. It is safe in the sense that references are never invalid, and well-behaved callbacks should check count, but that only reasonably applies to callbacks expecting multiple actions, but not just one.
Quoted 9 lines
Quoted 8 lines
drivers/net/intel/common/flow_check.h new file +7
-0+/* if we didn't parse anything, valid action list is empty */ +return parsed_actions->count ==0 ? -EINVAL :0 ; +} + +#ifdef __cplusplus +} +#endif <snip>
Signature · 2 lines
Thanks, Anatoly
PATCH v6 4/27 net/intel/common: add common flow attr validation
In reply to Anatoly BurakovThere are a lot of commonalities between what kinds of flow attr each Intel driver supports. Add a helper function that will validate attr based on common requirements and (optional) parameter checks.
Things we check for:
- Rejecting NULL attr (obviously)
- Ingress/egress according to requested params
- Transfer, group, and priority are not allowed unless requested
--- drivers/net/intel/common/flow_check.h | 70 +++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)
drivers/net/intel/common/flow_check.h +70 -0
@@ -57,6 +57,7 @@ ci_flow_action_type_in_list(const enum rte_flow_action_type type,/* Forward declarations */ struct ci_flow_actions ;struct ci_flow_actions_check_param ; +struct ci_flow_attr_check_param ;static inline const char *ci_flow_action_type_to_str (enum rte_flow_action_type type)
@@ -272,6 +273,75 @@ ci_flow_check_actions(const struct rte_flow_action *actions,return parsed_actions->count ==0 ? -EINVAL :0 ; } +/** +* Parameter structure for attr check. +*/ +struct ci_flow_attr_check_param { +bool allow_priority;/**< True if priority attribute is allowed. */ +bool allow_transfer;/**< True if transfer attribute is allowed. */ +bool allow_group;/**< True if group attribute is allowed. */ +bool require_egress;/**< True if egress attribute is required. */ +}; + +/** +* Validate rte_flow_attr structure against specified constraints. +* +* @param attr Pointer to rte_flow_attr structure to validate. +* @param attr_param Pointer to ci_flow_attr_check_param structure specifying constraints. +* @param error Pointer to rte_flow_error structure for error reporting. +* +* @return 0 on success, negative errno on failure. +*/ +static inline int +ci_flow_check_attr (const struct rte_flow_attr *attr, +const struct ci_flow_attr_check_param *attr_param, +struct rte_flow_error *error) +{ +if (attr ==NULL ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , attr, +"NULL attribute" ); + } + +/* a rule can only be ingress or egress, never both or neither. */ +if (attr_param !=NULL && attr_param->require_egress) { +if (attr->egress !=1 || attr->ingress !=0 ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_EGRESS , attr, +"Egress attribute is required" ); + } + }else { +if (attr->ingress !=1 || attr->egress !=0 ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_INGRESS , attr, +"Ingress attribute is required" ); + } + } + +/* May not be supported */ +if (attr->transfer && (attr_param ==NULL || !attr_param->allow_transfer)) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER , attr, +"Transfer not supported" ); + } + +/* May not be supported */ +if (attr->group && (attr_param ==NULL || !attr_param->allow_group)) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_GROUP , attr, +"Group not supported" ); + } + +/* May not be supported */ +if (attr->priority && (attr_param ==NULL || !attr_param->allow_priority)) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , attr, +"Priority not supported" ); + } + +return 0 ; +} + #ifdef __cplusplus }#endif
Signature · 1 line
2.47.3
PATCH v6 5/27 net/ixgbe: use common checks in ethertype filter
In reply to Anatoly BurakovUse the common attr and action parsing infrastructure in ethertype. This allows us to remove some checks as they are no longer necessary (such as whether DROP flag was set - if we do not accept DROP actions, we do not set the DROP flag), as well as make some checks more stringent (such as rejecting more than one action).
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 190 ++++++++++----------------- 1 file changed, 73 insertions(+), 117 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +73 -117
@@ -46,6 +46,8 @@#include "base/ixgbe_phy.h" #include "rte_pmd_ixgbe.h" +#include "../common/flow_check.h" +#define IXGBE_MIN_N_TUPLE_PRIO 1#define IXGBE_MAX_N_TUPLE_PRIO 7
@@ -124,6 +126,41 @@ const struct rte_flow_action *next_no_void_action( } } +/* +* All ixgbe engines mostly check the same stuff, so use a common check. +*/ +static int +ixgbe_flow_actions_check (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +const struct rte_flow_action *action; +struct rte_eth_dev_data *dev_data = param->driver_ctx; +size_t idx; + +for (idx =0 ; idx < actions->count; idx++) { + action = actions->actions[idx]; + +switch (action->type) { +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *queue = action->conf; +if (queue->index >= dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + action, +"queue index out of range" ); + } +break ; + } +default : +/* no specific validation */ +break ; + } + } +return 0 ; +} +/** * Please be aware there's an assumption for all the parsers. * rte_flow_item is using big endian, rte_flow_attr and
@@ -725,38 +762,14 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,* item->last should be NULL. */ static int -cons_parse_ethertype_filter (const struct rte_flow_attr *attr, -const struct rte_flow_item *pattern, -const struct rte_flow_action *actions, -struct rte_eth_ethertype_filter *filter, -struct rte_flow_error *error) +cons_parse_ethertype_filter (const struct rte_flow_item *pattern, +const struct rte_flow_action *action, +struct rte_eth_ethertype_filter *filter, +struct rte_flow_error *error) {const struct rte_flow_item *item; -const struct rte_flow_action *act;const struct rte_flow_item_eth *eth_spec;const struct rte_flow_item_eth *eth_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; - } item =next_no_void_pattern (pattern,NULL );/* The first non-void item should be MAC. */
@@ -826,87 +839,30 @@ cons_parse_ethertype_filter(const struct rte_flow_attr *attr,return -rte_errno; } -/* Parse action */ - - act =next_no_void_action (actions,NULL ); -if (act->type !=RTE_FLOW_ACTION_TYPE_QUEUE && - act->type !=RTE_FLOW_ACTION_TYPE_DROP ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - -if (act->type ==RTE_FLOW_ACTION_TYPE_QUEUE ) { - act_q = (const struct rte_flow_action_queue *)act->conf; - filter->queue = act_q->index; - }else { - filter->flags |=RTE_ETHTYPE_FLAGS_DROP ; - } - -/* Check if the next non-void item is END */ - act =next_no_void_action (actions, act); -if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -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) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_INGRESS , - attr,"Only support ingress." ); -return -rte_errno; - } - -/* Not supported */ -if (attr->egress) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_EGRESS , - attr,"Not support egress." ); -return -rte_errno; - } - -/* Not supported */ -if (attr->transfer) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER , - attr,"No support for transfer." ); -return -rte_errno; - } - -/* Not supported */ -if (attr->priority) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , - attr,"Not support priority." ); -return -rte_errno; - } - -/* Not supported */ -if (attr->group) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_GROUP , - attr,"Not support group." ); -return -rte_errno; - } + filter->queue = ((const struct rte_flow_action_queue *)action->conf)->index;return 0 ; }static int -ixgbe_parse_ethertype_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_ethertype_filter *filter, -struct rte_flow_error *error) +ixgbe_parse_ethertype_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_ethertype_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 + }, + .max_actions =1 , + .driver_ctx = dev->data, + .check = ixgbe_flow_actions_check + }; +const struct rte_flow_action *action; if (hw->mac.type != ixgbe_mac_82599EB && hw->mac.type != ixgbe_mac_X540 &&
@@ -916,19 +872,27 @@ ixgbe_parse_ethertype_filter(struct rte_eth_dev *dev, hw->mac.type != ixgbe_mac_E610)return -ENOTSUP ; - ret =cons_parse_ethertype_filter (attr, pattern, - actions, filter, error); +/* validate attributes */ + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; +/* parse requested actions */ + ret =ci_flow_check_actions (actions, &ap_param, &parsed_actions, error);if (ret)return ret; -if (filter->queue >= dev->data->nb_rx_queues) { -memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , -NULL ,"queue index much too big" ); -return -rte_errno; +/* only one action is supported */ +if (parsed_actions.count >1 ) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + parsed_actions.actions[1 ], +"Only one action can be specified at a time" ); } + action = parsed_actions.actions[0 ]; + + ret =cons_parse_ethertype_filter (pattern, action, filter, error); +if (ret) +return ret;if (filter->ether_type ==RTE_ETHER_TYPE_IPV4 || filter->ether_type ==RTE_ETHER_TYPE_IPV6 ) {
@@ -947,14 +911,6 @@ ixgbe_parse_ethertype_filter(struct rte_eth_dev *dev,return -rte_errno; } -if (filter->flags &RTE_ETHTYPE_FLAGS_DROP ) { -memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , -NULL ,"drop option is unsupported" ); -return -rte_errno; - } -return 0 ; }
Signature · 1 line
2.47.3
PATCH v6 6/27 net/ixgbe: use common checks in syn filter
In reply to Anatoly BurakovUse 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.
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 130 +++++++-------------------- 1 file changed, 32 insertions(+), 98 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +32 -98
@@ -935,38 +935,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 */
@@ -1074,63 +1049,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) {
@@ -1141,7 +1060,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; }
@@ -1149,15 +1068,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->data, + .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 &&
@@ -1167,16 +1098,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); }/**
Signature · 1 line
2.47.3
PATCH v6 7/27 net/ixgbe: use common checks in L2 tunnel filter
In reply to Anatoly BurakovUse the common attr and action parsing infrastructure in L2 tunnel filter. Some checks have become more stringent as a result, in particular, group attribute is now explicitly rejected instead of being ignored.
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 149 +++++++++------------------ 1 file changed, 48 insertions(+), 101 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +48 -101
@@ -136,6 +136,7 @@ ixgbe_flow_actions_check(const struct ci_flow_actions *actions, {const struct rte_flow_action *action;struct rte_eth_dev_data *dev_data = param->driver_ctx; +struct ixgbe_adapter *ad =IXGBE_DEV_PRIVATE_TO_ADAPTER (dev_data->dev_private);size_t idx;for (idx =0 ; idx < actions->count; idx++) {
@@ -153,6 +154,17 @@ ixgbe_flow_actions_check(const struct ci_flow_actions *actions, }break ; } +case RTE_FLOW_ACTION_TYPE_VF : + { +const struct rte_flow_action_vf *vf = action->conf; +if (vf->id >= ad->max_vfs) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + action, +"VF id out of range" ); + } +break ; + }default :/* no specific validation */ break ;
@@ -882,12 +894,6 @@ ixgbe_parse_ethertype_filter(struct rte_eth_dev *dev, const struct rte_flow_attrif (ret)return ret; -/* only one action is supported */ -if (parsed_actions.count >1 ) { -return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - parsed_actions.actions[1 ], -"Only one action can be specified at a time" ); - } action = parsed_actions.actions[0 ]; ret =cons_parse_ethertype_filter (pattern, action, filter, error);
@@ -1133,40 +1139,16 @@ ixgbe_parse_syn_filter(struct rte_eth_dev *dev, const struct rte_flow_attr *attr*/ static int cons_parse_l2_tn_filter (struct rte_eth_dev *dev, -const struct rte_flow_attr *attr,const struct rte_flow_item pattern[], -const struct rte_flow_action actions[], +const struct rte_flow_action *action,struct ixgbe_l2_tunnel_conf *filter,struct rte_flow_error *error) {const struct rte_flow_item *item;const struct rte_flow_item_e_tag *e_tag_spec;const struct rte_flow_item_e_tag *e_tag_mask; -const struct rte_flow_action *act; -const struct rte_flow_action_vf *act_vf;struct ixgbe_adapter *ad =IXGBE_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); -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 e-tag. */ item =next_no_void_pattern (pattern,NULL );if (item->type !=RTE_FLOW_ITEM_TYPE_E_TAG ) {
@@ -1224,71 +1206,13 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev,return -rte_errno; } -/* parse attr */ -/* must be input direction */ -if (!attr->ingress) { -memset (filter,0 ,sizeof (struct ixgbe_l2_tunnel_conf )); -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 ixgbe_l2_tunnel_conf )); -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 ixgbe_l2_tunnel_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER , - attr,"No support for transfer." ); -return -rte_errno; - } - -/* not supported */ -if (attr->priority) { -memset (filter,0 ,sizeof (struct ixgbe_l2_tunnel_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , - attr,"Not support priority." ); -return -rte_errno; - } - -/* check if the first not void action is VF or PF. */ - act =next_no_void_action (actions,NULL ); -if (act->type !=RTE_FLOW_ACTION_TYPE_VF && - act->type !=RTE_FLOW_ACTION_TYPE_PF ) { -memset (filter,0 ,sizeof (struct ixgbe_l2_tunnel_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - -if (act->type ==RTE_FLOW_ACTION_TYPE_VF ) { - act_vf = (const struct rte_flow_action_vf *)act->conf; +if (action->type ==RTE_FLOW_ACTION_TYPE_VF ) { +const struct rte_flow_action_vf *act_vf = action->conf; filter->pool = act_vf->id; }else { filter->pool = ad->max_vfs; } -/* 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 ixgbe_l2_tunnel_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } -return 0 ; }
@@ -1300,29 +1224,52 @@ ixgbe_parse_l2_tn_filter(struct rte_eth_dev *dev,struct ixgbe_l2_tunnel_conf *l2_tn_filter, struct rte_flow_error *error) { + struct rte_eth_dev_data *dev_data = dev->data; +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 vf/pf is allowed here */ +RTE_FLOW_ACTION_TYPE_VF , +RTE_FLOW_ACTION_TYPE_PF , +RTE_FLOW_ACTION_TYPE_END + }, + .driver_ctx = dev_data, + .check = ixgbe_flow_actions_check, + .max_actions =1 , + };int ret =0 ; -struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct ixgbe_adapter *ad =IXGBE_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); -uint16_t vf_num; - - ret =cons_parse_l2_tn_filter (dev, attr, pattern, - actions, l2_tn_filter, error); +const struct rte_flow_action *action;if (hw->mac.type != ixgbe_mac_X550 && hw->mac.type != ixgbe_mac_X550EM_x && hw->mac.type != ixgbe_mac_X550EM_a && hw->mac.type != ixgbe_mac_E610) { -memset (l2_tn_filter,0 ,sizeof (struct ixgbe_l2_tunnel_conf ));rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM ,NULL ,"Not supported by L2 tunnel filter" );return -rte_errno; } - vf_num = ad->max_vfs; +/* validate attributes */ + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; -if (l2_tn_filter->pool > vf_num) -return -rte_errno; +/* parse requested actions */ + ret =ci_flow_check_actions (actions, &ap_param, &parsed_actions, error); +if (ret) +return ret; + +/* only one action is supported */ +if (parsed_actions.count >1 ) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + parsed_actions.actions[1 ], +"Only one action can be specified at a time" ); + } + action = parsed_actions.actions[0 ]; + + ret =cons_parse_l2_tn_filter (dev, pattern, action, l2_tn_filter, error);return ret; }
Signature · 1 line
2.47.3
PATCH v6 8/27 net/ixgbe: use common checks in ntuple filter
In reply to Anatoly BurakovUse the common attr and action parsing infrastructure in ntuple filter. As a result, some checks have become more stringent, in particular the group attribute is now explicitly rejected instead of being ignored.
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 133 ++++++++------------------- 1 file changed, 36 insertions(+), 97 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +36 -97
@@ -210,12 +210,11 @@ ixgbe_flow_actions_check(const struct ci_flow_actions *actions,static int cons_parse_ntuple_filter (const struct rte_flow_attr *attr,const struct rte_flow_item pattern[], -const struct rte_flow_action actions[], +const struct rte_flow_action_queue *q_act,struct rte_eth_ntuple_filter *filter,struct rte_flow_error *error) {const struct rte_flow_item *item; -const struct rte_flow_action *act;const struct rte_flow_item_ipv4 *ipv4_spec;const struct rte_flow_item_ipv4 *ipv4_mask;const struct rte_flow_item_tcp *tcp_spec;
@@ -231,24 +230,11 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,struct rte_flow_item_eth eth_null;struct rte_flow_item_vlan vlan_null; -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; +/* Priority must be 16-bit */ +if (attr->priority >UINT16_MAX ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , attr, +"Priority must be 16-bit" ); }memset (ð_null,0 ,sizeof (struct rte_flow_item_eth ));
@@ -535,70 +521,11 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, action: -/** -* n-tuple only supports forwarding, -* 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_ntuple_filter )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - item,"Not supported action." ); -return -rte_errno; - } - filter->queue = - ((const struct rte_flow_action_queue *)act->conf)->index; + filter->queue = q_act->index; -/* 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_ntuple_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_ntuple_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_ntuple_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_ntuple_filter )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER , - attr,"No support for transfer." ); -return -rte_errno; - } - -if (attr->priority >0xFFFF ) { -memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , - attr,"Error priority." ); -return -rte_errno; - } filter->priority = (uint16_t )attr->priority; -if (attr->priority <IXGBE_MIN_N_TUPLE_PRIO || - attr->priority >IXGBE_MAX_N_TUPLE_PRIO ) - filter->priority =1 ; +if (attr->priority <IXGBE_MIN_N_TUPLE_PRIO || attr->priority >IXGBE_MAX_N_TUPLE_PRIO ) + filter->priority =1 ;return 0 ; }
@@ -718,15 +645,40 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,struct rte_eth_ntuple_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_attr_check_param attr_param = { + .allow_priority = true, + }; +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->data, + .check = ixgbe_flow_actions_check, + .max_actions =1 , + }; +const struct rte_flow_action *action; +int ret;if (hw->mac.type != ixgbe_mac_82599EB && hw->mac.type != ixgbe_mac_X540)return -ENOTSUP ; - ret =cons_parse_ntuple_filter (attr, pattern, actions, filter, error); +/* 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; + action = parsed_actions.actions[0 ]; + + ret =cons_parse_ntuple_filter (attr, pattern, action->conf, filter, error);if (ret)return ret;
@@ -739,19 +691,6 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,return -rte_errno; } -/* Ixgbe doesn't support many priorities. */ -if (filter->priority <IXGBE_MIN_N_TUPLE_PRIO || - filter->priority >IXGBE_MAX_N_TUPLE_PRIO ) { -memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , -NULL ,"Priority not supported by ntuple filter" ); -return -rte_errno; - } - -if (filter->queue >= dev->data->nb_rx_queues) -return -rte_errno; -/* fixed value for ixgbe */ filter->flags =RTE_5TUPLE_FLAGS ;return 0 ;
Signature · 1 line
2.47.3
PATCH v6 9/27 net/ixgbe: use common checks in security filter
In reply to Anatoly BurakovUse the common attr and action parsing infrastructure in security filter. As a result, some checks have become more stringent. In particular, group attribute is now explicitly rejected instead of being ignored.
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 62 ++++++++++------------------ 1 file changed, 22 insertions(+), 40 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +22 -40
@@ -539,7 +539,16 @@ ixgbe_parse_security_filter(struct rte_eth_dev *dev, const struct rte_flow_attrconst struct rte_flow_action_security *security;struct rte_security_session *session;const struct rte_flow_item *item; -const struct rte_flow_action *act; +struct ci_flow_actions parsed_actions; +struct ci_flow_actions_check_param ap_param = { + .allowed_types = (const enum rte_flow_action_type []){ +/* only security is allowed here */ +RTE_FLOW_ACTION_TYPE_SECURITY , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =1 , + }; +const struct rte_flow_action *action;struct ip_spec spec;int ret;
@@ -551,45 +560,18 @@ ixgbe_parse_security_filter(struct rte_eth_dev *dev, const struct rte_flow_attr hw->mac.type != ixgbe_mac_E610)return -ENOTSUP ; -if (pattern ==NULL ) { -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM_NUM , -NULL ,"NULL pattern." ); -return -rte_errno; - } -if (actions ==NULL ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION_NUM , -NULL ,"NULL action." ); -return -rte_errno; - } -if (attr ==NULL ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR , -NULL ,"NULL attribute." ); -return -rte_errno; - } +/* validate attributes */ + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; -/* check if next non-void action is security */ - act =next_no_void_action (actions,NULL ); -if (act->type !=RTE_FLOW_ACTION_TYPE_SECURITY ) { -return rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); - } - security = act->conf; -if (security ==NULL ) { -return rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"NULL security action config." ); - } -/* check if the next not void item is END */ - act =next_no_void_action (actions, act); -if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -return rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); - } +/* parse requested actions */ + ret =ci_flow_check_actions (actions, &ap_param, &parsed_actions, error); +if (ret) +return ret; + + action = parsed_actions.actions[0 ]; + security = action->conf;/* get the IP pattern*/ item =next_no_void_pattern (pattern,NULL );
@@ -629,7 +611,7 @@ ixgbe_parse_security_filter(struct rte_eth_dev *dev, const struct rte_flow_attr ret =ixgbe_crypto_add_ingress_sa_from_flow (session, &spec);if (ret) {rte_flow_error_set (error, -ret, -RTE_FLOW_ERROR_TYPE_ACTION , act, +RTE_FLOW_ERROR_TYPE_ACTION , action,"Failed to add security session." );return -rte_errno; }
Signature · 1 line
2.47.3
PATCH v6 10/27 net/ixgbe: use common checks in FDIR filters
In reply to Anatoly BurakovUse the common attr and action parsing infrastructure in flow director filters (both tunnel and normal). As a result, some checks have become more stringent, in particular group attribute is now explicitly rejected instead of being ignored.
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 319 ++++++++++++--------------- 1 file changed, 138 insertions(+), 181 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +138 -181
@@ -1195,111 +1195,6 @@ ixgbe_parse_l2_tn_filter(struct rte_eth_dev *dev,return ret; } -/* Parse to get the attr and action info of flow director rule. */ -static int -ixgbe_parse_fdir_act_attr (const struct rte_flow_attr *attr, -const struct rte_flow_action actions[], -struct ixgbe_fdir_rule *rule, -struct rte_flow_error *error) -{ -const struct rte_flow_action *act; -const struct rte_flow_action_queue *act_q; -const struct rte_flow_action_mark *mark; - -/* parse attr */ -/* must be input direction */ -if (!attr->ingress) { -memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -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 (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -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 (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER , - attr,"No support for transfer." ); -return -rte_errno; - } - -/* not supported */ -if (attr->priority) { -memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , - attr,"Not support priority." ); -return -rte_errno; - } - -/* check if the first not void action is QUEUE or DROP. */ - act =next_no_void_action (actions,NULL ); -if (act->type !=RTE_FLOW_ACTION_TYPE_QUEUE && - act->type !=RTE_FLOW_ACTION_TYPE_DROP ) { -memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - -if (act->type ==RTE_FLOW_ACTION_TYPE_QUEUE ) { - act_q = (const struct rte_flow_action_queue *)act->conf; - rule->queue = act_q->index; - }else {/* drop */ -/* signature mode does not support drop action. */ -if (rule->mode ==RTE_FDIR_MODE_SIGNATURE ) { -memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - rule->fdirflags =IXGBE_FDIRCMD_DROP ; - } - -/* check if the next not void item is MARK */ - act =next_no_void_action (actions, act); -if ((act->type !=RTE_FLOW_ACTION_TYPE_MARK ) && - (act->type !=RTE_FLOW_ACTION_TYPE_END )) { -memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - - rule->soft_id =0 ; - -if (act->type ==RTE_FLOW_ACTION_TYPE_MARK ) { - mark = (const struct rte_flow_action_mark *)act->conf; - rule->soft_id = mark->id; - act =next_no_void_action (actions, act); - } - -/* check if the next not void item is END */ -if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - -return 0 ; -} -/* search next no void pattern and skip fuzzy */ static inline const struct rte_flow_item *next_no_fuzzy_pattern(
@@ -1406,9 +1301,8 @@ static inline uint8_t signature_match(const struct rte_flow_item pattern[])*/ static int ixgbe_parse_fdir_filter_normal (struct rte_eth_dev *dev, -const struct rte_flow_attr *attr,const struct rte_flow_item pattern[], -const struct rte_flow_action actions[], +const struct ci_flow_actions *parsed_actions,struct ixgbe_fdir_rule *rule,struct rte_flow_error *error) {
@@ -1429,30 +1323,13 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev,const struct rte_flow_item_vlan *vlan_mask;const struct rte_flow_item_raw *raw_mask;const struct rte_flow_item_raw *raw_spec; +const struct rte_flow_action *fwd_action, *aux_action; +struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private);uint8_t j; -struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); - -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; - } + fwd_action = parsed_actions->actions[0 ]; +/* can be NULL */ + aux_action = parsed_actions->actions[1 ];/** * Some fields may not be provided. Set spec to 0 and mask to default
@@ -1466,29 +1343,51 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev, rule->mask.dst_port_mask =0 ; rule->mask.src_port_mask =0 ; -/** -* The first not void item should be -* MAC or IPv4 or TCP or UDP or SCTP. -*/ - item =next_no_fuzzy_pattern (pattern,NULL ); -if (item->type !=RTE_FLOW_ITEM_TYPE_ETH && - item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && - item->type !=RTE_FLOW_ITEM_TYPE_IPV6 && - item->type !=RTE_FLOW_ITEM_TYPE_TCP && - item->type !=RTE_FLOW_ITEM_TYPE_UDP && - item->type !=RTE_FLOW_ITEM_TYPE_SCTP ) { -memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , - item,"Not supported by fdir filter" ); -return -rte_errno; - } - +/* check if this is a signature match */ if (signature_match (pattern)) rule->mode =RTE_FDIR_MODE_SIGNATURE ;else rule->mode =RTE_FDIR_MODE_PERFECT ; +/* set up action */ +if (fwd_action->type ==RTE_FLOW_ACTION_TYPE_QUEUE ) { +const struct rte_flow_action_queue *q_act = fwd_action->conf; + rule->queue = q_act->index; + }else { +/* signature mode does not support drop action. */ +if (rule->mode ==RTE_FDIR_MODE_SIGNATURE ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , fwd_action, +"Signature mode does not support drop action." ); +return -rte_errno; + } + rule->fdirflags =IXGBE_FDIRCMD_DROP ; + } + +/* set up mark action */ +if (aux_action !=NULL && aux_action->type ==RTE_FLOW_ACTION_TYPE_MARK ) { +const struct rte_flow_action_mark *m_act = aux_action->conf; + rule->soft_id = m_act->id; + } + +/** +* The first not void item should be +* MAC or IPv4 or TCP or UDP or SCTP. +*/ + item =next_no_fuzzy_pattern (pattern,NULL ); +if (item->type !=RTE_FLOW_ITEM_TYPE_ETH && + item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && + item->type !=RTE_FLOW_ITEM_TYPE_IPV6 && + item->type !=RTE_FLOW_ITEM_TYPE_TCP && + item->type !=RTE_FLOW_ITEM_TYPE_UDP && + item->type !=RTE_FLOW_ITEM_TYPE_SCTP ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } +/*Not supported last point for range*/ if (item->last) { rte_flow_error_set(error, EINVAL,
@@ -2083,7 +1982,7 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev, rule->mask.l4_proto_match = (rule->ixgbe_fdir.formatted.flow_type &IXGBE_ATR_L4TYPE_MASK ) !=0 ; -return ixgbe_parse_fdir_act_attr (attr, actions, rule, error); +return 0 ; }#define NVGRE_PROTOCOL 0x6558
@@ -2126,9 +2025,8 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev,* item->last should be NULL. */ static int -ixgbe_parse_fdir_filter_tunnel (const struct rte_flow_attr *attr, -const struct rte_flow_item pattern[], -const struct rte_flow_action actions[], +ixgbe_parse_fdir_filter_tunnel (const struct rte_flow_item pattern[], +const struct ci_flow_actions *parsed_actions,struct ixgbe_fdir_rule *rule,struct rte_flow_error *error) {
@@ -2141,28 +2039,12 @@ ixgbe_parse_fdir_filter_tunnel(const struct rte_flow_attr *attr,const struct rte_flow_item_eth *eth_mask;const struct rte_flow_item_vlan *vlan_spec;const struct rte_flow_item_vlan *vlan_mask; +const struct rte_flow_action *fwd_action, *aux_action;uint32_t j; -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; - } + fwd_action = parsed_actions->actions[0 ]; +/* can be NULL */ + aux_action = parsed_actions->actions[1 ];/** * Some fields may not be provided. Set spec to 0 and mask to default
@@ -2172,6 +2054,20 @@ ixgbe_parse_fdir_filter_tunnel(const struct rte_flow_attr *attr,memset (&rule->mask,0xFF ,sizeof (struct ixgbe_hw_fdir_mask )); rule->mask.vlan_tci_mask =0 ; +/* set up queue/drop action */ +if (fwd_action->type ==RTE_FLOW_ACTION_TYPE_QUEUE ) { +const struct rte_flow_action_queue *q_act = fwd_action->conf; + rule->queue = q_act->index; + }else { + rule->fdirflags =IXGBE_FDIRCMD_DROP ; + } + +/* set up mark action */ +if (aux_action !=NULL && aux_action->type ==RTE_FLOW_ACTION_TYPE_MARK ) { +const struct rte_flow_action_mark *mark = aux_action->conf; + rule->soft_id = mark->id; + } +/** * The first not void item should be * MAC or IPv4 or IPv6 or UDP or VxLAN.
@@ -2572,7 +2468,43 @@ ixgbe_parse_fdir_filter_tunnel(const struct rte_flow_attr *attr,* Do nothing. */ -return ixgbe_parse_fdir_act_attr (attr, actions, rule, error); +return 0 ; +} + +/* +* Check flow director actions +*/ +static int +ixgbe_fdir_actions_check (const struct ci_flow_actions *parsed_actions, + const struct ci_flow_actions_check_param *param __rte_unused, +struct rte_flow_error *error) +{ +const enum rte_flow_action_type fwd_actions[] = { +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_END + }; +const struct rte_flow_action *action; + +/* do the generic checks first */ +int ret =ixgbe_flow_actions_check (parsed_actions, param, error); +if (ret) +return ret; + +/* first action must be a forwarding action */ + action = parsed_actions->actions[0 ]; +if (!ci_flow_action_type_in_list (action->type, fwd_actions)) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"First action must be QUEUE or DROP" ); + } + +/* second action, if specified, must not be a forwarding action */ + action = parsed_actions->actions[1 ]; +if (action !=NULL &&ci_flow_action_type_in_list (action->type, fwd_actions)) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Conflicting actions" ); + } +return 0 ; } static int
@@ -2585,22 +2517,47 @@ ixgbe_parse_fdir_filter(struct rte_eth_dev *dev, {int ret;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_adapter *adapter =IXGBE_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); +struct rte_eth_fdir_conf *fdir_conf =IXGBE_DEV_PRIVATE_TO_FDIR_CONF (adapter); +struct ci_flow_actions parsed_actions; +struct ci_flow_actions_check_param ap_param = { + .allowed_types = (const enum rte_flow_action_type []){ +/* queue/mark/drop allowed here */ +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_MARK , +RTE_FLOW_ACTION_TYPE_END + }, + .driver_ctx = dev->data, + .check = ixgbe_fdir_actions_check + };if (hw->mac.type != ixgbe_mac_82599EB && - hw->mac.type != ixgbe_mac_X540 && - hw->mac.type != ixgbe_mac_X550 && - hw->mac.type != ixgbe_mac_X550EM_x && - hw->mac.type != ixgbe_mac_X550EM_a && - hw->mac.type != ixgbe_mac_E610) + hw->mac.type != ixgbe_mac_X540 && + hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a && + hw->mac.type != ixgbe_mac_E610)return -ENOTSUP ; - ret =ixgbe_parse_fdir_filter_normal (dev, attr, pattern, - actions, rule, error); +/* validate attributes */ + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; + +/* parse requested actions */ + ret =ci_flow_check_actions (actions, &ap_param, &parsed_actions, error); +if (ret) +return ret; + + fdir_conf->drop_queue =IXGBE_FDIR_DROP_QUEUE ; + + ret =ixgbe_parse_fdir_filter_normal (dev, pattern, &parsed_actions, rule, error);if (!ret)return 0 ; -return ixgbe_parse_fdir_filter_tunnel (attr, pattern, - actions, rule, error); +return ixgbe_parse_fdir_filter_tunnel (pattern, &parsed_actions, + rule, error); } static int
Signature · 1 line
2.47.3
PATCH v6 11/27 net/ixgbe: use common checks in RSS filter
In reply to Anatoly BurakovUse the common attr and action parsing infrastructure in RSS filter. As a result, some checks have become more stringent, in particular:
- the group attribute is now explicitly rejected instead of being ignored
- the priority attribute was previously allowed but rejected values bigger than 0xFFFF despite not using priority anywhere - it is now rejected
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 196 +++++++++++---------------- 1 file changed, 79 insertions(+), 117 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +79 -117
@@ -112,20 +112,6 @@ const struct rte_flow_item *next_no_void_pattern( } } -static inline -const struct rte_flow_action *next_no_void_action ( -const struct rte_flow_action actions[], -const struct rte_flow_action *cur) -{ -const struct rte_flow_action *next = - cur ? cur +1 : &actions[0 ]; -while (1 ) { -if (next->type !=RTE_FLOW_ACTION_TYPE_VOID ) -return next; - next++; - } -} -/* * All ixgbe engines mostly check the same stuff, so use a common check. */
@@ -2680,6 +2666,56 @@ ixgbe_fdir_flow_program(struct rte_eth_dev *dev,return 0 ; } +/* Flow actions check specific to RSS filter */ +static int +ixgbe_flow_actions_check_rss (const struct ci_flow_actions *parsed_actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +const struct rte_flow_action *action = parsed_actions->actions[0 ]; +const struct rte_flow_action_rss *rss_act = action->conf; +struct rte_eth_dev_data *dev_data = param->driver_ctx; +const size_t rss_key_len =sizeof (((struct ixgbe_rte_flow_rss_conf *)0 )->key); +size_t q_idx, q; + +/* check if queue list is not empty */ +if (rss_act->queue_num ==0 ) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss_act, +"RSS queue list is empty" ); + } + +/* check if each RSS queue is valid */ +for (q_idx =0 ; q_idx < rss_act->queue_num; q_idx++) { + q = rss_act->queue[q_idx]; +if (q >= dev_data->nb_rx_queues) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss_act, +"Invalid RSS queue specified" ); + } + } + +/* only support default hash function */ +if (rss_act->func !=RTE_ETH_HASH_FUNCTION_DEFAULT ) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss_act, +"Non-default RSS hash functions are not supported" ); + } +/* levels aren't supported */ +if (rss_act->level) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss_act, +"A nonzero RSS encapsulation level is not supported" ); + } +/* check key length */ +if (rss_act->key_len !=0 && rss_act->key_len != rss_key_len) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss_act, +"RSS key must be exactly 40 bytes long" ); + } +return 0 ; +} + static int ixgbe_parse_rss_filter(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
@@ -2687,109 +2723,35 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev,struct ixgbe_rte_flow_rss_conf *rss_conf, struct rte_flow_error *error) { - const struct rte_flow_action *act; -const struct rte_flow_action_rss *rss; -uint16_t n; - -/** -* rss only supports forwarding, -* check if the first not void action is RSS. -*/ - act =next_no_void_action (actions,NULL ); -if (act->type !=RTE_FLOW_ACTION_TYPE_RSS ) { -memset (rss_conf,0 ,sizeof (struct ixgbe_rte_flow_rss_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - - rss = (const struct rte_flow_action_rss *)act->conf; - -if (!rss || !rss->queue_num) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act, -"no valid queues" ); -return -rte_errno; - } - -for (n =0 ; n < rss->queue_num; n++) { -if (rss->queue[n] >= dev->data->nb_rx_queues) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act, -"queue id > max number of queues" ); -return -rte_errno; - } - } - -if (rss->func !=RTE_ETH_HASH_FUNCTION_DEFAULT ) -return rte_flow_error_set - (error,ENOTSUP ,RTE_FLOW_ERROR_TYPE_ACTION , act, -"non-default RSS hash functions are not supported" ); -if (rss->level) -return rte_flow_error_set - (error,ENOTSUP ,RTE_FLOW_ERROR_TYPE_ACTION , act, -"a nonzero RSS encapsulation level is not supported" ); -if (rss->key_len && rss->key_len !=RTE_DIM (rss_conf->key)) -return rte_flow_error_set - (error,ENOTSUP ,RTE_FLOW_ERROR_TYPE_ACTION , act, -"RSS hash key must be exactly 40 bytes" ); -if (rss->queue_num >RTE_DIM (rss_conf->queue)) -return rte_flow_error_set - (error,ENOTSUP ,RTE_FLOW_ERROR_TYPE_ACTION , act, -"too many queues for RSS context" ); -if (ixgbe_rss_conf_init (rss_conf, rss)) -return rte_flow_error_set - (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , act, -"RSS context initialization failure" ); - -/* 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 (rss_conf,0 ,sizeof (struct ixgbe_rte_flow_rss_conf )); -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 (rss_conf,0 ,sizeof (struct ixgbe_rte_flow_rss_conf )); -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 (rss_conf,0 ,sizeof (struct ixgbe_rte_flow_rss_conf )); -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 (rss_conf,0 ,sizeof (struct ixgbe_rte_flow_rss_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER , - attr,"No support for transfer." ); -return -rte_errno; - } - -if (attr->priority >0xFFFF ) { -memset (rss_conf,0 ,sizeof (struct ixgbe_rte_flow_rss_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , - attr,"Error priority." ); -return -rte_errno; - } + struct ci_flow_actions parsed_actions; +struct ci_flow_actions_check_param ap_param = { + .allowed_types = (const enum rte_flow_action_type []){ +/* only rss allowed here */ +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_END + }, + .driver_ctx = dev->data, + .check = ixgbe_flow_actions_check_rss, + .max_actions =1 , + }; +int ret; +const struct rte_flow_action *action; + +/* validate attributes */ + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; + +/* parse requested actions */ + ret =ci_flow_check_actions (actions, &ap_param, &parsed_actions, error); +if (ret) +return ret; + action = parsed_actions.actions[0 ]; + +if (ixgbe_rss_conf_init (rss_conf, action->conf)) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"RSS context initialization failure" );return 0 ; }
Signature · 1 line
2.47.3
PATCH v6 12/27 net/i40e: use common flow attribute checks
In reply to Anatoly BurakovThere is no need to call the same attribute checks in multiple places when there are no cases where we do otherwise. Therefore, remove all the attribute check calls from all filter call paths and instead check the attributes once at the very beginning of flow validation, and use common flow attribute checks instead of driver-local ones.
--- drivers/net/intel/i40e/i40e_ethdev.h | 1 - drivers/net/intel/i40e/i40e_flow.c | 121 +++------------------------ 2 files changed, 10 insertions(+), 112 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.h +0 -1
@@ -1315,7 +1315,6 @@ struct i40e_filter_ctx { }; typedef int (*parse_filter_t)(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_flow_error *error,
drivers/net/intel/i40e/i40e_flow.c +10 -111
302 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH v6 13/27 net/i40e: refactor RSS flow parameter checks
In reply to Anatoly BurakovCurrently, the hash parser parameter checks are somewhat confusing as they have multiple mutually exclusive code paths and requirements, and it's difficult to reason about them because RSS flow parsing is interspersed with validation checks.
To address that, refactor hash engine error checking to perform almost all validation at the beginning, with only happy paths being implemented in actual parsing functions.
Some parameter combinations that were previously ignored (and perhaps produced a warning) are now explicitly rejected:
- if no pattern is specified, RSS types are rejected
- for queue lists and regions, RSS key is rejected
--- drivers/net/intel/i40e/i40e_flow.c | 13 +- drivers/net/intel/i40e/i40e_hash.c | 438 ++++++++++++++++++----------- drivers/net/intel/i40e/i40e_hash.h | 2 +- 3 files changed, 275 insertions(+), 178 deletions(-)
drivers/net/intel/i40e/i40e_flow.c +6 -7
@@ -3816,6 +3816,7 @@ i40e_flow_check(struct rte_eth_dev *dev,if (ret) {return ret; } +/* action and pattern validation will happen in each respective engine */ if (!pattern) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
@@ -3830,13 +3831,11 @@ i40e_flow_check(struct rte_eth_dev *dev,return -rte_errno; } -/* Get the non-void item of action */ -while ((actions + i)->type ==RTE_FLOW_ACTION_TYPE_VOID ) - i++; - -if ((actions + i)->type ==RTE_FLOW_ACTION_TYPE_RSS ) { - filter_ctx->type =RTE_ETH_FILTER_HASH ; -return i40e_hash_parse (dev, pattern, actions + i, &filter_ctx->rss_conf, error); +/* try parsing as RSS */ + filter_ctx->type =RTE_ETH_FILTER_HASH ; + ret =i40e_hash_parse (dev, pattern, actions, &filter_ctx->rss_conf, error); +if (!ret) { +return ret; } i =0 ;
drivers/net/intel/i40e/i40e_hash.c +268 -170
527 lines not on this page · raw message
drivers/net/intel/i40e/i40e_hash.h +1 -1
@@ -13,7 +13,7 @@extern "C" {#endif -int i40e_hash_parse(const struct rte_eth_dev *dev, +int i40e_hash_parse(struct rte_eth_dev *dev, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], struct i40e_rte_flow_rss_conf *rss_conf,
Signature · 1 line
2.47.3
PATCH v6 14/27 net/i40e: use common action checks for ethertype
In reply to Anatoly BurakovUse the common flow action checking parsing infrastructure for checking flow actions for ethertype filter.
--- drivers/net/intel/i40e/i40e_flow.c | 56 +++++++++++++----------------- 1 file changed, 24 insertions(+), 32 deletions(-)
drivers/net/intel/i40e/i40e_flow.c +24 -32
@@ -1448,43 +1448,35 @@ i40e_flow_parse_ethertype_action(struct rte_eth_dev *dev,struct rte_flow_error *error, struct rte_eth_ethertype_filter *filter) { - struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); -const struct rte_flow_action *act; -const struct rte_flow_action_queue *act_q; -uint32_t index =0 ; + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param ac_param = { + .allowed_types = (enum rte_flow_action_type []) { +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_END , + }, + .max_actions =1 , + }; +const struct rte_flow_action *action; +int ret; -/* Check if the first non-void action is QUEUE or DROP. */ -NEXT_ITEM_OF_ACTION (act, actions, index); -if (act->type !=RTE_FLOW_ACTION_TYPE_QUEUE && - act->type !=RTE_FLOW_ACTION_TYPE_DROP ) { -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } + ret =ci_flow_check_actions (actions, &ac_param, &parsed_actions, error); +if (ret) +return ret; + action = parsed_actions.actions[0 ]; -if (act->type ==RTE_FLOW_ACTION_TYPE_QUEUE ) { - act_q = act->conf; +if (action->type ==RTE_FLOW_ACTION_TYPE_QUEUE ) { +const struct rte_flow_action_queue *act_q = action->conf; +/* check queue index */ +if (act_q->index >= dev->data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid queue index" ); + } filter->queue = act_q->index; -if (filter->queue >= pf->dev_data->nb_rx_queues) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Invalid queue ID for" -" ethertype_filter." ); -return -rte_errno; - } - }else { + }else if (action->type ==RTE_FLOW_ACTION_TYPE_DROP ) { filter->flags |=RTE_ETHTYPE_FLAGS_DROP ; } - -/* Check if the next non-void item is END */ - index++; -NEXT_ITEM_OF_ACTION (act, actions, index); -if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } -return 0 ; }
Signature · 1 line
2.47.3
PATCH v6 15/27 net/i40e: use common action checks for FDIR
In reply to Anatoly BurakovUse the common flow action checking parsing infrastructure for checking flow actions for flow director filter.
--- drivers/net/intel/i40e/i40e_flow.c | 139 ++++++++++++++++------------- 1 file changed, 76 insertions(+), 63 deletions(-)
drivers/net/intel/i40e/i40e_flow.c +76 -63
@@ -2486,28 +2486,49 @@ i40e_flow_parse_fdir_action(struct rte_eth_dev *dev, struct i40e_fdir_filter_conf *filter) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); -const struct rte_flow_action *act; -const struct rte_flow_action_queue *act_q; -const struct rte_flow_action_mark *mark_spec =NULL ; -uint32_t index =0 ; +struct ci_flow_actions parsed_actions = {0 }; +struct ci_flow_actions_check_param ac_param = { + .allowed_types = (enum rte_flow_action_type []) { +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_PASSTHRU , +RTE_FLOW_ACTION_TYPE_MARK , +RTE_FLOW_ACTION_TYPE_FLAG , +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =2 , + }; +const struct rte_flow_action *first, *second; +int ret; -/* Check if the first non-void action is QUEUE or DROP or PASSTHRU. */ -NEXT_ITEM_OF_ACTION (act, actions, index); -switch (act->type) { + ret =ci_flow_check_actions (actions, &ac_param, &parsed_actions, error); +if (ret) +return ret; + first = parsed_actions.actions[0 ]; +/* can be NULL */ + second = parsed_actions.actions[1 ]; + +switch (first->type) {case RTE_FLOW_ACTION_TYPE_QUEUE : - act_q = act->conf; + { +const struct rte_flow_action_queue *act_q = first->conf; +/* check against PF constraints */ +if (!filter->input.flow_ext.is_vf && act_q->index >= pf->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , first, +"Invalid queue ID for FDIR" ); + } +/* check against VF constraints */ +if (filter->input.flow_ext.is_vf && act_q->index >= pf->vf_nb_qps) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , first, +"Invalid queue ID for FDIR" ); + } filter->action.rx_queue = act_q->index; -if ((!filter->input.flow_ext.is_vf && - filter->action.rx_queue >= pf->dev_data->nb_rx_queues) || - (filter->input.flow_ext.is_vf && - filter->action.rx_queue >= pf->vf_nb_qps)) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid queue ID for FDIR." ); -return -rte_errno; - } filter->action.behavior =I40E_FDIR_ACCEPT ;break ; + }case RTE_FLOW_ACTION_TYPE_DROP : filter->action.behavior =I40E_FDIR_REJECT ;break ;
@@ -2515,69 +2536,61 @@ i40e_flow_parse_fdir_action(struct rte_eth_dev *dev, filter->action.behavior =I40E_FDIR_PASSTHRU ;break ;case RTE_FLOW_ACTION_TYPE_MARK : + { +const struct rte_flow_action_mark *act_m = first->conf; filter->action.behavior =I40E_FDIR_PASSTHRU ; - mark_spec = act->conf; filter->action.report_status =I40E_FDIR_REPORT_ID ; - filter->soft_id = mark_spec->id; -break ; + filter->soft_id = act_m->id; +break ; + }default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid action." ); -return -rte_errno; +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , first, +"Invalid first action for FDIR" ); } -/* Check if the next non-void item is MARK or FLAG or END. */ - index++; -NEXT_ITEM_OF_ACTION (act, actions, index); -switch (act->type) { +/* do we have another? */ +if (second ==NULL ) +return 0 ; + +switch (second->type) {case RTE_FLOW_ACTION_TYPE_MARK : -if (mark_spec) { -/* Double MARK actions requested */ -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid action." ); -return -rte_errno; + { +const struct rte_flow_action_mark *act_m = second->conf; +/* only one mark action can be specified */ +if (first->type ==RTE_FLOW_ACTION_TYPE_MARK ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , second, +"Invalid second action for FDIR" ); } - mark_spec = act->conf; filter->action.report_status =I40E_FDIR_REPORT_ID ; - filter->soft_id = mark_spec->id; + filter->soft_id = act_m->id;break ; + }case RTE_FLOW_ACTION_TYPE_FLAG : -if (mark_spec) { -/* MARK + FLAG not supported */ -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid action." ); -return -rte_errno; + { +/* mark + flag is unsupported */ +if (first->type ==RTE_FLOW_ACTION_TYPE_MARK ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , second, +"Invalid second action for FDIR" ); } filter->action.report_status =I40E_FDIR_NO_REPORT_STATUS ;break ; + }case RTE_FLOW_ACTION_TYPE_RSS : -if (filter->action.behavior !=I40E_FDIR_PASSTHRU ) { -/* RSS filter won't be next if FDIR did not pass thru */ -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid action." ); -return -rte_errno; +/* RSS filter only can be after passthru or mark */ +if (first->type !=RTE_FLOW_ACTION_TYPE_PASSTHRU && + first->type !=RTE_FLOW_ACTION_TYPE_MARK ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , second, +"Invalid second action for FDIR" ); }break ; -case RTE_FLOW_ACTION_TYPE_END : -return 0 ;default : -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - act,"Invalid action." ); -return -rte_errno; - } - -/* Check if the next non-void item is END */ - index++; -NEXT_ITEM_OF_ACTION (act, actions, index); -if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Invalid action." ); -return -rte_errno; +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , second, +"Invalid second action for FDIR" ); }return 0 ;
Signature · 1 line
2.47.3
PATCH v6 16/27 net/i40e: use common action checks for tunnel
In reply to Anatoly BurakovUse the common flow action checking parsing infrastructure for checking flow actions for flow director tunnel filter. As a result, more stringent checks are performed against parametersm specifically the following:
- reject NULL conf for VF action (instead of attempt at NULL dereference)
- second action was expected to be QUEUE but if it wasn't it was ignored
--- drivers/net/intel/i40e/i40e_flow.c | 104 +++++++++++++---------------- 1 file changed, 48 insertions(+), 56 deletions(-)
drivers/net/intel/i40e/i40e_flow.c +48 -56
@@ -1107,15 +1107,6 @@ static struct i40e_valid_pattern i40e_supported_patterns[] = { { pattern_fdir_ipv6_sctp, i40e_flow_parse_l4_cloud_filter }, }; -#define NEXT_ITEM_OF_ACTION (act, actions, index) \ - do { \ - act = actions + index; \ - while (act->type == RTE_FLOW_ACTION_TYPE_VOID) { \ - index++; \ - act = actions + index; \ - } \ - } while (0) -/* Find the first VOID or non-VOID item pointer */ static const struct rte_flow_item *i40e_find_first_item (const struct rte_flow_item *item,bool is_void)
@@ -2629,61 +2620,62 @@ i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev, struct i40e_tunnel_filter_conf *filter) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); -const struct rte_flow_action *act;const struct rte_flow_action_queue *act_q; -const struct rte_flow_action_vf *act_vf; -uint32_t index =0 ; +struct ci_flow_actions parsed_actions = {0 }; +struct ci_flow_actions_check_param ac_param = { + .allowed_types = (enum rte_flow_action_type []) { +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_PF , +RTE_FLOW_ACTION_TYPE_VF , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =2 , + }; +const struct rte_flow_action *first, *second; +int ret; -/* Check if the first non-void action is PF or VF. */ -NEXT_ITEM_OF_ACTION (act, actions, index); -if (act->type !=RTE_FLOW_ACTION_TYPE_PF && - act->type !=RTE_FLOW_ACTION_TYPE_VF ) { -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } + ret =ci_flow_check_actions (actions, &ac_param, &parsed_actions, error); +if (ret) +return ret; + first = parsed_actions.actions[0 ]; +/* can be NULL */ + second = parsed_actions.actions[1 ]; -if (act->type ==RTE_FLOW_ACTION_TYPE_VF ) { - act_vf = act->conf; - filter->vf_id = act_vf->id; +/* first action must be PF or VF */ +if (first->type ==RTE_FLOW_ACTION_TYPE_VF ) { +const struct rte_flow_action_vf *vf = first->conf; +if (vf->id >= pf->vf_num) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , first, +"Invalid VF ID for tunnel filter" ); +return -rte_errno; + } + filter->vf_id = vf->id; filter->is_to_vf =1 ; -if (filter->vf_id >= pf->vf_num) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Invalid VF ID for tunnel filter" ); -return -rte_errno; - } + }else if (first->type !=RTE_FLOW_ACTION_TYPE_PF ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , first, +"Unsupported action" ); } -/* Check if the next non-void item is QUEUE */ - index++; -NEXT_ITEM_OF_ACTION (act, actions, index); -if (act->type ==RTE_FLOW_ACTION_TYPE_QUEUE ) { - act_q = act->conf; - filter->queue_id = act_q->index; -if ((!filter->is_to_vf) && - (filter->queue_id >= pf->dev_data->nb_rx_queues)) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Invalid queue ID for tunnel filter" ); -return -rte_errno; - }else if (filter->is_to_vf && - (filter->queue_id >= pf->vf_nb_qps)) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Invalid queue ID for tunnel filter" ); -return -rte_errno; - } - } +/* check if second action is QUEUE */ +if (second ==NULL ) +return 0 ; -/* Check if the next non-void item is END */ - index++; -NEXT_ITEM_OF_ACTION (act, actions, index); -if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; + act_q = second->conf; +/* check queue ID for PF flow */ +if (!filter->is_to_vf && act_q->index >= pf->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , act_q, +"Invalid queue ID for tunnel filter" ); + } +/* check queue ID for VF flow */ +if (filter->is_to_vf && act_q->index >= pf->vf_nb_qps) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , act_q, +"Invalid queue ID for tunnel filter" ); } + filter->queue_id = act_q->index;return 0 ; }
Signature · 1 line
2.47.3
PATCH v6 17/27 net/iavf: use common flow attribute checks
In reply to Anatoly BurakovReplace custom attr checks with a call to common checks. Flow subscription engine supports priority but other engines don't, so we move the attribute checks into the engines.
--- drivers/net/intel/iavf/iavf_fdir.c | 8 ++- drivers/net/intel/iavf/iavf_fsub.c | 20 ++++++- drivers/net/intel/iavf/iavf_generic_flow.c | 67 +++------------------- drivers/net/intel/iavf/iavf_generic_flow.h | 2 +- drivers/net/intel/iavf/iavf_hash.c | 10 ++-- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 8 ++- 6 files changed, 43 insertions(+), 72 deletions(-)
drivers/net/intel/iavf/iavf_fdir.c +5 -3
@@ -17,6 +17,7 @@#include "iavf.h" #include "iavf_generic_flow.h" +#include "../common/flow_check.h" #include "virtchnl.h" #include "iavf_rxtx.h"
@@ -1594,7 +1595,7 @@ iavf_fdir_parse(struct iavf_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error) {
@@ -1605,8 +1606,9 @@ iavf_fdir_parse(struct iavf_adapter *ad,memset (filter,0 ,sizeof (*filter)); -if (priority >=1 ) -return -rte_errno; + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; item =iavf_search_pattern_match_item (pattern, array, array_len, error);if (!item)
drivers/net/intel/iavf/iavf_fsub.c +18 -2
@@ -20,6 +20,7 @@#include <rte_flow.h> #include <iavf.h> #include "iavf_generic_flow.h" +#include "../common/flow_check.h" #define MAX_QGRP_NUM_TYPE 7#define IAVF_IPV6_ADDR_LENGTH 16
@@ -650,12 +651,15 @@ iavf_fsub_parse(struct iavf_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error) { struct iavf_fsub_conf *filter;struct iavf_pattern_match_item *pattern_match_item =NULL ; +struct ci_flow_attr_check_param attr_param = { + .allow_priority = true, + };int ret =0 ; filter =rte_zmalloc (NULL ,sizeof (*filter),0 );
@@ -666,6 +670,18 @@ iavf_fsub_parse(struct iavf_adapter *ad,return -ENOMEM ; } + ret =ci_flow_check_attr (attr, &attr_param, error); +if (ret) + goto error; + +if (attr->priority >1 ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , + attr,"Only support priority 0 and 1." ); + ret = -rte_errno; + goto error; + } +/* search flow subscribe pattern */ pattern_match_item =iavf_search_pattern_match_item (pattern, array, array_len, error);
@@ -687,7 +703,7 @@ iavf_fsub_parse(struct iavf_adapter *ad, goto error;/* parse flow subscribe pattern action */ - ret =iavf_fsub_parse_action ((void *)ad, actions, priority, + ret =iavf_fsub_parse_action ((void *)ad, actions, attr->priority, error, filter); error:
drivers/net/intel/iavf/iavf_generic_flow.c +8 -59
124 lines not on this page · raw message
drivers/net/intel/iavf/iavf_generic_flow.h +1 -1
@@ -471,7 +471,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error);
drivers/net/intel/iavf/iavf_hash.c +6 -4
@@ -22,6 +22,7 @@#include "iavf_log.h" #include "iavf.h" #include "iavf_generic_flow.h" +#include "../common/flow_check.h" #define IAVF_PHINT_NONE 0#define IAVF_PHINT_GTPU BIT_ULL(0)
@@ -86,7 +87,7 @@ iavf_hash_parse_pattern_action(struct iavf_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error);
@@ -1521,7 +1522,7 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error) {
@@ -1530,8 +1531,9 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,uint64_t phint =IAVF_PHINT_NONE ;int ret =0 ; -if (priority >=1 ) -return -rte_errno; + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; rss_meta_ptr =rte_zmalloc (NULL ,sizeof (*rss_meta_ptr),0 );if (!rss_meta_ptr) {
drivers/net/intel/iavf/iavf_ipsec_crypto.c +5 -3
@@ -14,6 +14,7 @@#include "iavf_rxtx.h" #include "iavf_log.h" #include "iavf_generic_flow.h" +#include "../common/flow_check.h" #include "iavf_ipsec_crypto.h" #include "iavf_ipsec_crypto_capabilities.h"
@@ -1953,15 +1954,16 @@ iavf_ipsec_flow_parse(struct iavf_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error) { struct iavf_pattern_match_item *item = NULL;int ret =-1 ; -if (priority >=1 ) -return -rte_errno; + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; item =iavf_search_pattern_match_item (pattern, array, array_len, error);if (item && item->meta) {
Signature · 1 line
2.47.3
PATCH v6 18/27 net/iavf: use common action checks for IPsec
In reply to Anatoly BurakovUse the common flow action checking parsing infrastructure for checking flow actions for IPsec filter.
--- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 35 ++++++++++------------ 1 file changed, 15 insertions(+), 20 deletions(-)
drivers/net/intel/iavf/iavf_ipsec_crypto.c +15 -20
@@ -1745,26 +1745,12 @@ parse_udp_item(const struct rte_flow_item_udp *item, struct rte_udp_hdr *udp) udp->src_port = item->hdr.src_port; } -static int -has_security_action (const struct rte_flow_action actions[], -const void **session) -{ -/* only {SECURITY; END} supported */ -if (actions[0 ].type ==RTE_FLOW_ACTION_TYPE_SECURITY && - actions[1 ].type ==RTE_FLOW_ACTION_TYPE_END ) { - *session = actions[0 ].conf; -return true; - } -return false; -} -static struct iavf_ipsec_flow_item *iavf_ipsec_flow_item_parse (struct rte_eth_dev *ethdev,const struct rte_flow_item pattern[], -const struct rte_flow_action actions[], +const struct rte_security_session *session,uint32_t type) { -const void *session;struct iavf_ipsec_flow_item *ipsec_flow =rte_malloc ("security-flow-rule" ,sizeof (struct iavf_ipsec_flow_item ),0 );
@@ -1831,9 +1817,6 @@ iavf_ipsec_flow_item_parse(struct rte_eth_dev *ethdev, goto flow_cleanup; } -if (!has_security_action (actions, &session)) - goto flow_cleanup; -if (!iavf_ipsec_crypto_action_valid (ethdev, session, ipsec_flow->spi)) goto flow_cleanup;
@@ -1958,6 +1941,14 @@ iavf_ipsec_flow_parse(struct iavf_adapter *ad,void **meta, struct rte_flow_error *error) { + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_SECURITY , +RTE_FLOW_ACTION_TYPE_END , + }, + .max_actions =1 , + };struct iavf_pattern_match_item *item =NULL ;int ret =-1 ;
@@ -1965,12 +1956,16 @@ iavf_ipsec_flow_parse(struct iavf_adapter *ad,if (ret)return ret; + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret <0 ) +return ret; + item =iavf_search_pattern_match_item (pattern, array, array_len, error);if (item && item->meta) { +const struct rte_security_session *session = parsed_actions.actions[0 ]->conf;uint32_t type = (uint64_t )(item->meta);struct iavf_ipsec_flow_item *fi = -iavf_ipsec_flow_item_parse (ad->vf.eth_dev, - pattern, actions, type); +iavf_ipsec_flow_item_parse (ad->vf.eth_dev, pattern, session, type);if (fi && meta) { *meta = fi; ret =0 ;
Signature · 1 line
2.47.3
PATCH v6 19/27 net/iavf: use common action checks for hash
In reply to Anatoly BurakovUse the common flow action checking parsing infrastructure for checking flow actions for hash filter.
--- drivers/net/intel/iavf/iavf_hash.c | 143 +++++++++++++++-------------- 1 file changed, 72 insertions(+), 71 deletions(-)
drivers/net/intel/iavf/iavf_hash.c +72 -71
@@ -1429,95 +1429,81 @@ iavf_any_invalid_rss_type(enum rte_eth_hash_function rss_func, }static int -iavf_hash_parse_action (struct iavf_pattern_match_item *match_item, -const struct rte_flow_action actions[], -uint64_t pattern_hint,struct iavf_rss_meta *rss_meta, -struct rte_flow_error *error) +iavf_hash_parse_rss_type (struct iavf_pattern_match_item *match_item, +const struct rte_flow_action_rss *rss, +uint64_t pattern_hint,struct iavf_rss_meta *rss_meta, +struct rte_flow_error *error) { -enum rte_flow_action_type action_type; -const struct rte_flow_action_rss *rss; -const struct rte_flow_action *action;uint64_t rss_type; -/* Supported action is RSS. */ -for (action = actions; action->type != -RTE_FLOW_ACTION_TYPE_END ; action++) { - action_type = action->type; -switch (action_type) { -case RTE_FLOW_ACTION_TYPE_RSS : - rss = action->conf; - rss_type = rss->types; + rss_meta->rss_algorithm = rss->func ==RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ ? +VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC : +VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC ; -if (rss->func == -RTE_ETH_HASH_FUNCTION_SIMPLE_XOR ){ - rss_meta->rss_algorithm = -VIRTCHNL_RSS_ALG_XOR_ASYMMETRIC ; -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"function simple_xor is not supported" ); - }else if (rss->func == -RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ ) { - rss_meta->rss_algorithm = -VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC ; - }else { - rss_meta->rss_algorithm = -VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC ; - } +/* If pattern type is raw, no need to refine rss type */ +if (pattern_hint ==IAVF_PHINT_RAW ) +return 0 ; -if (rss->level) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"a nonzero RSS encapsulation level is not supported" ); +/** +* Check simultaneous use of SRC_ONLY and DST_ONLY +* of the same level. +*/ + rss_type =rte_eth_rss_hf_refine (rss->types); -if (rss->key_len) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"a nonzero RSS key_len is not supported" ); +if (iavf_any_invalid_rss_type (rss->func, rss_type, match_item->input_set_mask)) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"RSS type not supported" ); + } -if (rss->queue_num) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"a non-NULL RSS queue is not supported" ); +memcpy (&rss_meta->proto_hdrs, match_item->meta,sizeof (struct virtchnl_proto_hdrs )); -/* If pattern type is raw, no need to refine rss type */ -if (pattern_hint ==IAVF_PHINT_RAW ) -break ; +iavf_refine_proto_hdrs (&rss_meta->proto_hdrs, rss_type, pattern_hint); -/** -* Check simultaneous use of SRC_ONLY and DST_ONLY -* of the same level. -*/ - rss_type =rte_eth_rss_hf_refine (rss_type); +return 0 ; +} -if (iavf_any_invalid_rss_type (rss->func, rss_type, - match_item->input_set_mask)) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , - action,"RSS type not supported" ); +static int +iavf_hash_parse_action_check (const struct ci_flow_actions *actions, + const struct ci_flow_actions_check_param *param __rte_unused, +struct rte_flow_error *error) +{ +const struct rte_flow_action_rss *rss = actions->actions[0 ]->conf; -memcpy (&rss_meta->proto_hdrs, match_item->meta, -sizeof (struct virtchnl_proto_hdrs )); +/* filter out unsupported RSS functions */ +switch (rss->func) { +case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR : +case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT : +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"Selected RSS hash function not supported" ); +default : +break ; + } -iavf_refine_proto_hdrs (&rss_meta->proto_hdrs, - rss_type, pattern_hint); -break ; +if (rss->level !=0 ) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"Nonzero RSS encapsulation level is not supported" ); + } -case RTE_FLOW_ACTION_TYPE_END : -break ; +if (rss->key_len !=0 ) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"RSS key is not supported" ); + } -default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"Invalid action." ); -return -rte_errno; - } +if (rss->queue_num !=0 ) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"RSS queue region is not supported" ); }return 0 ; } static int -iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad, +iavf_hash_parse_pattern_action(struct iavf_adapter *ad, struct iavf_pattern_match_item *array, uint32_t array_len, const struct rte_flow_item pattern[],
@@ -1526,6 +1512,17 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,void **meta, struct rte_flow_error *error) { + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =1 , + .driver_ctx = ad, + .check = iavf_hash_parse_action_check, + }; +const struct rte_flow_action_rss *rss;struct iavf_pattern_match_item *pattern_match_item;struct iavf_rss_meta *rss_meta_ptr;uint64_t phint =IAVF_PHINT_NONE ;
@@ -1535,6 +1532,10 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,if (ret)return ret; + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret) +return ret; + rss_meta_ptr =rte_zmalloc (NULL ,sizeof (*rss_meta_ptr),0 );if (!rss_meta_ptr) { rte_flow_error_set(error, EINVAL,
@@ -1567,8 +1568,8 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad, } } - ret =iavf_hash_parse_action (pattern_match_item, actions, phint, - rss_meta_ptr, error); + rss = parsed_actions.actions[0 ]->conf; + ret =iavf_hash_parse_rss_type (pattern_match_item, rss, phint, rss_meta_ptr, error); error:if (!ret && meta)
Signature · 1 line
2.47.3
PATCH v6 20/27 net/iavf: use common action checks for FDIR
In reply to Anatoly BurakovUse the common flow action checking parsing infrastructure for checking flow actions for FDIR filter.
--- drivers/net/intel/iavf/iavf_fdir.c | 360 +++++++++++++---------------- 1 file changed, 158 insertions(+), 202 deletions(-)
drivers/net/intel/iavf/iavf_fdir.c +158 -202
@@ -443,204 +443,6 @@ static struct iavf_flow_engine iavf_fdir_engine = { .rule_size = sizeof(struct iavf_fdir_conf), }; -static int -iavf_fdir_parse_action_qregion (struct iavf_adapter *ad, -struct rte_flow_error *error, -const struct rte_flow_action *act, -struct virtchnl_filter_action *filter_action) -{ -struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (ad); -const struct rte_flow_action_rss *rss = act->conf; -uint32_t i; - -if (act->type !=RTE_FLOW_ACTION_TYPE_RSS ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid action." ); -return -rte_errno; - } - -if (rss->queue_num <=1 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Queue region size can't be 0 or 1." ); -return -rte_errno; - } - -/* check if queue index for queue region is continuous */ -for (i =0 ; i < rss->queue_num -1 ; i++) { -if (rss->queue[i +1 ] != rss->queue[i] +1 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Discontinuous queue region" ); -return -rte_errno; - } - } - -if (rss->queue[rss->queue_num -1 ] >= ad->dev_data->nb_rx_queues) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid queue region indexes." ); -return -rte_errno; - } - -if (!(rte_is_power_of_2 (rss->queue_num) && - rss->queue_num <=IAVF_FDIR_MAX_QREGION_SIZE )) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"The region size should be any of the following values:" -"1, 2, 4, 8, 16, 32, 64, 128 as long as the total number " -"of queues do not exceed the VSI allocation." ); -return -rte_errno; - } - -if (rss->queue_num > vf->max_rss_qregion) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"The region size cannot be large than the supported max RSS queue region" ); -return -rte_errno; - } - - filter_action->act_conf.queue.index = rss->queue[0 ]; - filter_action->act_conf.queue.region =rte_fls_u32 (rss->queue_num) -1 ; - -return 0 ; -} - -static int -iavf_fdir_parse_action (struct iavf_adapter *ad, -const struct rte_flow_action actions[], -struct rte_flow_error *error, -struct iavf_fdir_conf *filter) -{ -const struct rte_flow_action_queue *act_q; -const struct rte_flow_action_mark *mark_spec =NULL ; -uint32_t dest_num =0 ; -uint32_t mark_num =0 ; -int ret; - -int number =0 ; -struct virtchnl_filter_action *filter_action; - -for (; actions->type !=RTE_FLOW_ACTION_TYPE_END ; actions++) { -switch (actions->type) { -case RTE_FLOW_ACTION_TYPE_VOID : -break ; - -case RTE_FLOW_ACTION_TYPE_PASSTHRU : - dest_num++; - - filter_action = &filter->add_fltr.rule_cfg.action_set.actions[number]; - - filter_action->type =VIRTCHNL_ACTION_PASSTHRU ; - - filter->add_fltr.rule_cfg.action_set.count = ++number; -break ; - -case RTE_FLOW_ACTION_TYPE_DROP : - dest_num++; - - filter_action = &filter->add_fltr.rule_cfg.action_set.actions[number]; - - filter_action->type =VIRTCHNL_ACTION_DROP ; - - filter->add_fltr.rule_cfg.action_set.count = ++number; -break ; - -case RTE_FLOW_ACTION_TYPE_QUEUE : - dest_num++; - - act_q = actions->conf; - filter_action = &filter->add_fltr.rule_cfg.action_set.actions[number]; - - filter_action->type =VIRTCHNL_ACTION_QUEUE ; - filter_action->act_conf.queue.index = act_q->index; - -if (filter_action->act_conf.queue.index >= - ad->dev_data->nb_rx_queues) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - actions,"Invalid queue for FDIR." ); -return -rte_errno; - } - - filter->add_fltr.rule_cfg.action_set.count = ++number; -break ; - -case RTE_FLOW_ACTION_TYPE_RSS : - dest_num++; - - filter_action = &filter->add_fltr.rule_cfg.action_set.actions[number]; - - filter_action->type =VIRTCHNL_ACTION_Q_REGION ; - - ret =iavf_fdir_parse_action_qregion (ad, - error, actions, filter_action); -if (ret) -return ret; - - filter->add_fltr.rule_cfg.action_set.count = ++number; -break ; - -case RTE_FLOW_ACTION_TYPE_MARK : - mark_num++; - - filter->mark_flag =1 ; - mark_spec = actions->conf; - filter_action = &filter->add_fltr.rule_cfg.action_set.actions[number]; - - filter_action->type =VIRTCHNL_ACTION_MARK ; - filter_action->act_conf.mark_id = mark_spec->id; - - filter->add_fltr.rule_cfg.action_set.count = ++number; -break ; - -default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Invalid action." ); -return -rte_errno; - } - } - -if (number >VIRTCHNL_MAX_NUM_ACTIONS ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Action numbers exceed the maximum value" ); -return -rte_errno; - } - -if (dest_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Unsupported action combination" ); -return -rte_errno; - } - -if (mark_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Too many mark actions" ); -return -rte_errno; - } - -if (dest_num + mark_num ==0 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Empty action" ); -return -rte_errno; - } - -/* Mark only is equal to mark + passthru. */ -if (dest_num ==0 ) { - filter_action = &filter->add_fltr.rule_cfg.action_set.actions[number]; - filter_action->type =VIRTCHNL_ACTION_PASSTHRU ; - filter->add_fltr.rule_cfg.action_set.count = ++number; - } - -return 0 ; -} - static bool iavf_fdir_refine_input_set(const uint64_t input_set, const uint64_t input_set_mask,
@@ -1589,6 +1391,145 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,return 0 ; } +static int +iavf_fdir_action_check_qregion (struct iavf_adapter *ad, +const struct rte_flow_action_rss *rss, +struct rte_flow_error *error) +{ +struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (ad); + +if (rss->queue_num <=1 ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"Queue region size can't be 0 or 1." ); + } + +if (rss->queue[rss->queue_num -1 ] >= ad->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"Invalid queue region indexes." ); + } + +if (!(rte_is_power_of_2 (rss->queue_num) && + rss->queue_num <=IAVF_FDIR_MAX_QREGION_SIZE )) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"The region size should be any of the following values:" +"1, 2, 4, 8, 16, 32, 64, 128 as long as the total number " +"of queues do not exceed the VSI allocation." ); + } + +if (rss->queue_num > vf->max_rss_qregion) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"The region size cannot be large than the supported max RSS queue region" ); + } + +return 0 ; +} + +static int +iavf_fdir_parse_action_check (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +struct iavf_adapter *ad = param->driver_ctx; +struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (ad); +struct iavf_fdir_conf *filter = &vf->fdir.conf; +uint32_t dest_num =0 , mark_num =0 ; +size_t i, number =0 ; +bool has_drop = false; +int ret; + +for (i =0 ; i < actions->count; i++) { +const struct rte_flow_action *act = actions->actions[i]; +struct virtchnl_filter_action *filter_action = + &filter->add_fltr.rule_cfg.action_set.actions[number]; + +switch (act->type) { +case RTE_FLOW_ACTION_TYPE_PASSTHRU : + dest_num++; + + filter_action->type =VIRTCHNL_ACTION_PASSTHRU ; +break ; +case RTE_FLOW_ACTION_TYPE_DROP : + dest_num++; + has_drop = true; + + filter_action->type =VIRTCHNL_ACTION_DROP ; +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *act_q; + dest_num++; + + act_q = act->conf; + + filter_action->type =VIRTCHNL_ACTION_QUEUE ; + +if (act_q->index >= ad->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , actions, +"Invalid queue index." ); + } + filter_action->act_conf.queue.index = act_q->index; + +break ; + } +case RTE_FLOW_ACTION_TYPE_RSS : + { +const struct rte_flow_action_rss *rss = act->conf; + dest_num++; + + filter_action->type =VIRTCHNL_ACTION_Q_REGION ; + + ret =iavf_fdir_action_check_qregion (ad, rss, error); +if (ret) +return ret; + + filter_action->act_conf.queue.index = rss->queue[0 ]; + filter_action->act_conf.queue.region =rte_fls_u32 (rss->queue_num) -1 ; +break ; + } +case RTE_FLOW_ACTION_TYPE_MARK : + { +const struct rte_flow_action_mark *mark_spec; + mark_num++; + + filter->mark_flag =1 ; + mark_spec = act->conf; + + filter_action->type =VIRTCHNL_ACTION_MARK ; + filter_action->act_conf.mark_id = mark_spec->id; + +break ; + } +default : +/* cannot happen */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , actions, +"Invalid action." ); + } + filter->add_fltr.rule_cfg.action_set.count = ++number; + } + +if (dest_num >1 || mark_num >1 || (has_drop && mark_num >1 )) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , actions, +"Unsupported action combination" ); + } + +/* Mark only is equal to mark + passthru. */ +if (dest_num ==0 ) { +struct virtchnl_filter_action *filter_action = + &filter->add_fltr.rule_cfg.action_set.actions[number]; + filter_action->type =VIRTCHNL_ACTION_PASSTHRU ; + filter->add_fltr.rule_cfg.action_set.count = ++number; + } + +return 0 ; +} + static int iavf_fdir_parse(struct iavf_adapter *ad, struct iavf_pattern_match_item *array,
@@ -1599,6 +1540,21 @@ iavf_fdir_parse(struct iavf_adapter *ad,void **meta, struct rte_flow_error *error) { + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_PASSTHRU , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_MARK , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =2 , + .check = iavf_fdir_parse_action_check, + .driver_ctx = ad, + .rss_queues_contig = true, + };struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (ad);struct iavf_fdir_conf *filter = &vf->fdir.conf;struct iavf_pattern_match_item *item =NULL ;
@@ -1610,6 +1566,10 @@ iavf_fdir_parse(struct iavf_adapter *ad,if (ret)return ret; + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret) +return ret; + item =iavf_search_pattern_match_item (pattern, array, array_len, error);if (!item)return -rte_errno;
@@ -1619,10 +1579,6 @@ iavf_fdir_parse(struct iavf_adapter *ad,if (ret) goto error; - ret =iavf_fdir_parse_action (ad, actions, error, filter); -if (ret) - goto error; -if (meta) *meta = filter;
Signature · 1 line
2.47.3
PATCH v6 21/27 net/iavf: use common action checks for fsub
In reply to Anatoly BurakovUse the common flow action checking parsing infrastructure for checking flow actions for flow subscription filter.
Existing implementation had a couple issues that do not rise to the level of being bugs, but are still questionable design choices.
For one, DROP action is supported in actions check (single actions are allowed as long as it isn't RSS or QUEUE) but is later disallowed in action parse (because not having port representor action is treated as an error). This is fixed by removing DROP action support from the check stage.
For another, PORT_REPRESENTOR action was incrementing action counter but not writing anything into action array, which, given that action list is zero-initialized, meant that the default action (drop) was kept in the action list. However, because the actual PF treats drop as a no-op, nothing bad happened when a DROP action was added to the list of actions.
However, nothing bad also happens if we just didn't have an action to begin with, so we remedy these unorthodox semantics by accordingly treating PORT_REPRESENTOR action as a noop, and not adding anything to the action list.
As a final note, now that all filter parsing code paths use the common action check infrastructure, we can remove the NULL check for actions from the beginning of the parsing path, as this is now handled by each engine.
--- drivers/net/intel/iavf/iavf_fsub.c | 244 +++++++++------------ drivers/net/intel/iavf/iavf_generic_flow.c | 7 - 2 files changed, 101 insertions(+), 150 deletions(-)
drivers/net/intel/iavf/iavf_fsub.c +101 -143
@@ -465,89 +465,46 @@ iavf_fsub_parse_pattern(const struct rte_flow_item pattern[], }static int -iavf_fsub_parse_action (struct iavf_adapter *ad, -const struct rte_flow_action *actions, +iavf_fsub_parse_action (const struct ci_flow_actions *actions,uint32_t priority,struct rte_flow_error *error,struct iavf_fsub_conf *filter) { -const struct rte_flow_action *action; -const struct rte_flow_action_ethdev *act_ethdev; -const struct rte_flow_action_queue *act_q; -const struct rte_flow_action_rss *act_qgrop; -struct virtchnl_filter_action *filter_action; -uint16_t valid_qgrop_number[MAX_QGRP_NUM_TYPE ] = { -2 ,4 ,8 ,16 ,32 ,64 ,128 }; -uint16_t i, num =0 , dest_num =0 , vf_num =0 ; -uint16_t rule_port_id; +uint16_t num_actions =0 ; +size_t i; + +for (i =0 ; i < actions->count; i++) { +const struct rte_flow_action *action = actions->actions[i]; +struct virtchnl_filter_action *filter_action = + &filter->sub_fltr.actions.actions[num_actions]; -for (action = actions; action->type != -RTE_FLOW_ACTION_TYPE_END ; action++) {switch (action->type) { -case RTE_FLOW_ACTION_TYPE_VOID : -break ; -case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR : - vf_num++; - filter_action = &filter->sub_fltr.actions.actions[num]; - - act_ethdev = action->conf; - rule_port_id = ad->dev_data->port_id; -if (rule_port_id != act_ethdev->port_id) - goto error1; - - filter->sub_fltr.actions.count = ++num; -break ; +/* nothing to be done, but skip the action */ +continue ;case RTE_FLOW_ACTION_TYPE_QUEUE : - dest_num++; - filter_action = &filter->sub_fltr.actions.actions[num]; - - act_q = action->conf; -if (act_q->index >= ad->dev_data->nb_rx_queues) - goto error2; - + { +const struct rte_flow_action_queue *act_q = action->conf; filter_action->type =VIRTCHNL_ACTION_QUEUE ; filter_action->act_conf.queue.index = act_q->index; - filter->sub_fltr.actions.count = ++num;break ; + }case RTE_FLOW_ACTION_TYPE_RSS : - dest_num++; - filter_action = &filter->sub_fltr.actions.actions[num]; - - act_qgrop = action->conf; -if (act_qgrop->queue_num <=1 ) - goto error2; + { +const struct rte_flow_action_rss *act_qgrp = action->conf; filter_action->type =VIRTCHNL_ACTION_Q_REGION ; - filter_action->act_conf.queue.index = - act_qgrop->queue[0 ]; -for (i =0 ; i <MAX_QGRP_NUM_TYPE ; i++) { -if (act_qgrop->queue_num == - valid_qgrop_number[i]) -break ; - } - -if (i ==MAX_QGRP_NUM_TYPE ) - goto error2; - -if ((act_qgrop->queue[0 ] + act_qgrop->queue_num) > - ad->dev_data->nb_rx_queues) - goto error3; - -for (i =0 ; i < act_qgrop->queue_num -1 ; i++) -if (act_qgrop->queue[i +1 ] != - act_qgrop->queue[i] +1 ) - goto error4; - - filter_action->act_conf.queue.region = act_qgrop->queue_num; - filter->sub_fltr.actions.count = ++num; + filter_action->act_conf.queue.index = act_qgrp->queue[0 ]; + filter_action->act_conf.queue.region = act_qgrp->queue_num;break ; + }default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - actions,"Invalid action type" ); -return -rte_errno; +/* cannot happen */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid action type." ); } + filter->sub_fltr.actions.count = ++num_actions; }/* 0 denotes lowest priority of recipe and highest priority
@@ -555,91 +512,81 @@ iavf_fsub_parse_action(struct iavf_adapter *ad,*/ filter->sub_fltr.priority = priority; -if (num >VIRTCHNL_MAX_NUM_ACTIONS ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Action numbers exceed the maximum value" ); -return -rte_errno; - } - -if (vf_num ==0 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Invalid action, vf action must be added" ); -return -rte_errno; - } - -if (dest_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Unsupported action combination" ); -return -rte_errno; - } -return 0 ; - -error1: -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Invalid port id" ); -return -rte_errno; - -error2: -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Invalid action type or queue number" ); -return -rte_errno; - -error3: -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Invalid queue region indexes" ); -return -rte_errno; - -error4: -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Discontinuous queue region" ); -return -rte_errno; }static int -iavf_fsub_check_action (const struct rte_flow_action *actions, +iavf_fsub_action_check (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param,struct rte_flow_error *error) { -const struct rte_flow_action *action; -enum rte_flow_action_type action_type; -uint16_t actions_num =0 ; -bool vf_valid = false; -bool queue_valid = false; +const struct iavf_adapter *ad = param->driver_ctx; +bool vf = false; +size_t i; -for (action = actions; action->type != -RTE_FLOW_ACTION_TYPE_END ; action++) { - action_type = action->type; -switch (action_type) { +/* +* allowed action types: +* 1. PORT_REPRESENTOR only +* 2. PORT_REPRESENTOR + QUEUE/RSS +*/ + +for (i =0 ; i < actions->count; i++) { +const struct rte_flow_action *action = actions->actions[i]; +switch (action->type) {case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR : - vf_valid = true; - actions_num++; + { +const struct rte_flow_action_ethdev *act_ethdev = action->conf; + +if (act_ethdev->port_id != ad->dev_data->port_id) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , act_ethdev, +"Invalid port id" ); + } + vf = true;break ; + }case RTE_FLOW_ACTION_TYPE_RSS : + { +const struct rte_flow_action_rss *act_qgrp = action->conf; + +/* must be between 2 and 128 and be a power of 2 */ +if (act_qgrp->queue_num <2 || act_qgrp->queue_num >128 || + !rte_is_power_of_2 (act_qgrp->queue_num)) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , act_qgrp, +"Invalid number of queues in RSS queue group" ); + } +/* last queue must not exceed total number of queues */ +if (act_qgrp->queue[0 ] + act_qgrp->queue_num > ad->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , act_qgrp, +"Invalid queue index in RSS queue group" ); + } +break ; + }case RTE_FLOW_ACTION_TYPE_QUEUE : - queue_valid = true; - actions_num++; + { +const struct rte_flow_action_queue *act_q = action->conf; + +if (act_q->index >= ad->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , act_q, +"Invalid queue index" ); + }break ; -case RTE_FLOW_ACTION_TYPE_DROP : - actions_num++; -break ; -case RTE_FLOW_ACTION_TYPE_VOID : -continue ; + }default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - actions,"Invalid action type" ); -return -rte_errno; +/* shouldn't happen */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid action type" ); } } - -if (!((actions_num ==1 && !queue_valid) || - (actions_num ==2 && vf_valid && queue_valid))) { -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions,"Invalid action number" ); -return -rte_errno; +/* QUEUE/RSS must be accompanied by PORT_REPRESENTOR */ +if (!vf) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , actions, +"Invalid action combination" ); }return 0 ;
@@ -655,6 +602,19 @@ iavf_fsub_parse(struct iavf_adapter *ad,void **meta, struct rte_flow_error *error) { + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR , +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =2 , + .check = iavf_fsub_action_check, + .driver_ctx = ad, + .rss_queues_contig = true, + };struct iavf_fsub_conf *filter;struct iavf_pattern_match_item *pattern_match_item =NULL ; struct ci_flow_attr_check_param attr_param = {
@@ -674,6 +634,10 @@ iavf_fsub_parse(struct iavf_adapter *ad,if (ret) goto error; + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret) + goto error; +if (attr->priority >1 ) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
@@ -697,14 +661,8 @@ iavf_fsub_parse(struct iavf_adapter *ad,if (ret) goto error; -/* check flow subscribe pattern action */ - ret =iavf_fsub_check_action (actions, error); -if (ret) - goto error; -/* parse flow subscribe pattern action */ - ret =iavf_fsub_parse_action ((void *)ad, actions, attr->priority, - error, filter); + ret =iavf_fsub_parse_action (&parsed_actions, attr->priority, error, filter); error:if (!ret && meta)
drivers/net/intel/iavf/iavf_generic_flow.c +0 -7
@@ -2159,13 +2159,6 @@ iavf_flow_process_filter(struct rte_eth_dev *dev,return -rte_errno; } -if (!actions) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION_NUM , -NULL ,"NULL action." ); -return -rte_errno; - } - *engine =iavf_parse_engine (ad, flow, &vf->rss_parser_list, attr, pattern, actions, error);if (*engine)
Signature · 1 line
2.47.3
PATCH v6 22/27 net/iavf: use common action checks for flow query
In reply to Anatoly BurakovUse the common flow parsing infrastructure to validate query actions.
--- drivers/net/intel/iavf/iavf_generic_flow.c | 33 +++++++++++----------- 1 file changed, 16 insertions(+), 17 deletions(-)
drivers/net/intel/iavf/iavf_generic_flow.c +16 -17
@@ -14,10 +14,11 @@#include <ethdev_driver.h> #include <rte_malloc.h> #include <rte_tailq.h> +#include <rte_hexdump.h> #include "iavf.h" #include "iavf_generic_flow.h" -#include <rte_hexdump.h> +#include "../common/flow_check.h" static struct iavf_engine_list engine_list =TAILQ_HEAD_INITIALIZER (engine_list);
@@ -2338,10 +2339,18 @@ iavf_flow_query(struct rte_eth_dev *dev,void *data, struct rte_flow_error *error) { - int ret = -EINVAL; + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []) { +RTE_FLOW_ACTION_TYPE_COUNT , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =1 + };struct iavf_adapter *ad =IAVF_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private);struct rte_flow_query_count *count = data; +int ret;if (!iavf_flow_is_valid (flow) || !flow->engine->query_count) { rte_flow_error_set(error, EINVAL,
@@ -2350,21 +2359,11 @@ iavf_flow_query(struct rte_eth_dev *dev,return -rte_errno; } -for (; actions->type !=RTE_FLOW_ACTION_TYPE_END ; actions++) { -switch (actions->type) { -case RTE_FLOW_ACTION_TYPE_VOID : -break ; -case RTE_FLOW_ACTION_TYPE_COUNT : - ret = flow->engine->query_count (ad, flow, count, error); -break ; -default : -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"action not supported" ); - } - } -return ret; + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret <0 ) +return ret; + +return flow->engine->query_count (ad, flow, count, error); }#define IAVF_FLOW_DUMP_CHUNK_BYTES 32
Signature · 1 line
2.47.3
PATCH v6 23/27 net/ice: use common flow attribute checks
In reply to Anatoly BurakovFrom: Vladimir Medvedkin <[email protected]>
Replace custom attr checks with a call to common checks. Switch engine supports priority (0 or 1) but other engines don't, so we move the attribute checks into the engines.
--- drivers/net/intel/ice/ice_acl_filter.c | 9 ++-- drivers/net/intel/ice/ice_fdir_filter.c | 8 ++- drivers/net/intel/ice/ice_generic_flow.c | 59 +++-------------------- drivers/net/intel/ice/ice_generic_flow.h | 2 +- drivers/net/intel/ice/ice_hash.c | 11 +++-- drivers/net/intel/ice/ice_switch_filter.c | 22 +++++++-- 6 files changed, 48 insertions(+), 63 deletions(-)
drivers/net/intel/ice/ice_acl_filter.c +6 -3
@@ -27,6 +27,8 @@#include "ice_generic_flow.h" #include "base/ice_flow.h" +#include "../common/flow_check.h" +#define MAX_ACL_SLOTS_ID 2048#define ICE_ACL_INSET_ETH_IPV4 ( \
@@ -970,7 +972,7 @@ ice_acl_parse(struct ice_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error) {
@@ -980,8 +982,9 @@ ice_acl_parse(struct ice_adapter *ad,uint64_t input_set;int ret; -if (priority >=1 ) -return -rte_errno; + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret;memset (filter,0 ,sizeof (*filter)); item = ice_search_pattern_match_item(ad, pattern, array, array_len,
drivers/net/intel/ice/ice_fdir_filter.c +7 -1
@@ -15,6 +15,8 @@#include "ice_rxtx.h" #include "ice_generic_flow.h" +#include "../common/flow_check.h" +#define ICE_FDIR_IPV6_TC_OFFSET 20#define ICE_IPV6_TC_MASK (0xFF << ICE_FDIR_IPV6_TC_OFFSET)
@@ -2808,7 +2810,7 @@ ice_fdir_parse(struct ice_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority __rte_unused, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error) {
@@ -2819,6 +2821,10 @@ ice_fdir_parse(struct ice_adapter *ad,bool raw = false;int ret; + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; +memset (filter,0 ,sizeof (*filter)); item =ice_search_pattern_match_item (ad, pattern, array, array_len, error);
drivers/net/intel/ice/ice_generic_flow.c +8 -51
122 lines not on this page · raw message
drivers/net/intel/ice/ice_generic_flow.h +1 -1
@@ -525,7 +525,7 @@ typedef int (*parse_pattern_action_t)(struct ice_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error);
drivers/net/intel/ice/ice_hash.c +7 -4
@@ -26,6 +26,8 @@#include "ice_ethdev.h" #include "ice_generic_flow.h" +#include "../common/flow_check.h" +#define ICE_PHINT_NONE 0#define ICE_PHINT_VLAN BIT_ULL(0)#define ICE_PHINT_PPPOE BIT_ULL(1)
@@ -107,7 +109,7 @@ ice_hash_parse_pattern_action(struct ice_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error);
@@ -1187,7 +1189,7 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error) {
@@ -1196,8 +1198,9 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,struct ice_rss_meta *rss_meta_ptr;uint64_t phint =ICE_PHINT_NONE ; -if (priority >=1 ) -return -rte_errno; + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; rss_meta_ptr =rte_zmalloc (NULL ,sizeof (*rss_meta_ptr),0 );if (!rss_meta_ptr) {
drivers/net/intel/ice/ice_switch_filter.c +19 -3
@@ -26,6 +26,7 @@#include "ice_generic_flow.h" #include "ice_dcf_ethdev.h" +#include "../common/flow_check.h" #define MAX_QGRP_NUM_TYPE 7#define MAX_INPUT_SET_BYTE 32
@@ -1768,7 +1769,7 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error) {
@@ -1784,6 +1785,21 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,enum ice_sw_tunnel_type tun_type =ICE_NON_TUN ;struct ice_pattern_match_item *pattern_match_item =NULL ; +struct ci_flow_attr_check_param attr_param = { + .allow_priority = true, + }; + + ret =ci_flow_check_attr (attr, &attr_param, error); +if (ret) +return ret; + +/* Allow only two priority values - 0 or 1 */ +if (attr->priority >1 ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY ,NULL , +"Invalid priority for switch filter" ); +return -rte_errno; + }for (; item->type !=RTE_FLOW_ITEM_TYPE_END ; item++) { item_num++;
@@ -1859,10 +1875,10 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad, goto error;if (ad->hw.dcf_enabled) - ret =ice_switch_parse_dcf_action ((void *)ad, actions, priority, + ret =ice_switch_parse_dcf_action ((void *)ad, actions, attr->priority, error, &rule_info);else - ret =ice_switch_parse_action (pf, actions, priority, error, + ret =ice_switch_parse_action (pf, actions, attr->priority, error, &rule_info);if (ret)
Signature · 1 line
2.47.3
PATCH v6 24/27 net/ice: use common action checks for hash
In reply to Anatoly BurakovFrom: Vladimir Medvedkin <[email protected]>
Use the common flow action checking parsing infrastructure for checking flow actions for hash filter.
--- drivers/net/intel/ice/ice_hash.c | 178 +++++++++++++++++-------------- 1 file changed, 95 insertions(+), 83 deletions(-)
drivers/net/intel/ice/ice_hash.c +95 -83
@@ -1092,94 +1092,92 @@ ice_any_invalid_rss_type(enum rte_eth_hash_function rss_func, }static int -ice_hash_parse_action (struct ice_pattern_match_item *pattern_match_item, -const struct rte_flow_action actions[], +ice_hash_parse_action_check (const struct ci_flow_actions *actions, + const struct ci_flow_actions_check_param *param __rte_unused, +struct rte_flow_error *error) +{ +const struct rte_flow_action_rss *rss; + + rss = actions->actions[0 ]->conf; + +switch (rss->func) { +case RTE_ETH_HASH_FUNCTION_DEFAULT : +case RTE_ETH_HASH_FUNCTION_TOEPLITZ : +case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR : +case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ : +break ; +default : +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"Selected RSS hash function not supported" ); + } + +if (rss->level) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"a nonzero RSS encapsulation level is not supported" ); + +if (rss->key_len) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"a nonzero RSS key_len is not supported" ); + +if (rss->queue) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"a non-NULL RSS queue is not supported" ); + +return 0 ; +} + +static int +ice_hash_parse_rss_action (struct ice_pattern_match_item *pattern_match_item, +const struct rte_flow_action_rss *rss,uint64_t pattern_hint,struct ice_rss_meta *rss_meta,struct rte_flow_error *error) {struct ice_rss_hash_cfg *cfg = pattern_match_item->meta; -enum rte_flow_action_type action_type; -const struct rte_flow_action_rss *rss; -const struct rte_flow_action *action;uint64_t rss_type; +bool symm = false; -/* Supported action is RSS. */ -for (action = actions; action->type != -RTE_FLOW_ACTION_TYPE_END ; action++) { - action_type = action->type; -switch (action_type) { -case RTE_FLOW_ACTION_TYPE_RSS : - rss = action->conf; - rss_type = rss->types; - -/* Check hash function and save it to rss_meta. */ -if (pattern_match_item->pattern_list != - pattern_empty && rss->func == -RTE_ETH_HASH_FUNCTION_SIMPLE_XOR ) { -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"Not supported flow" ); - }else if (rss->func == -RTE_ETH_HASH_FUNCTION_SIMPLE_XOR ){ - rss_meta->hash_function = -RTE_ETH_HASH_FUNCTION_SIMPLE_XOR ; -return 0 ; - }else if (rss->func == -RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ ) { - rss_meta->hash_function = -RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ ; -if (pattern_hint ==ICE_PHINT_RAW ) - rss_meta->raw.symm = true; -else - cfg->symm = true; - } - -if (rss->level) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"a nonzero RSS encapsulation level is not supported" ); - -if (rss->key_len) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"a nonzero RSS key_len is not supported" ); - -if (rss->queue) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"a non-NULL RSS queue is not supported" ); - -/* If pattern type is raw, no need to refine rss type */ -if (pattern_hint ==ICE_PHINT_RAW ) -break ; - -/** -* Check simultaneous use of SRC_ONLY and DST_ONLY -* of the same level. -*/ - rss_type =rte_eth_rss_hf_refine (rss_type); - -if (ice_any_invalid_rss_type (rss->func, rss_type, - pattern_match_item->input_set_mask_o)) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , - action,"RSS type not supported" ); - - rss_meta->cfg = *cfg; -ice_refine_hash_cfg (&rss_meta->cfg, - rss_type, pattern_hint); -break ; -case RTE_FLOW_ACTION_TYPE_END : -break ; - -default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"Invalid action." ); -return -rte_errno; +if (rss->func ==RTE_ETH_HASH_FUNCTION_SIMPLE_XOR ) { +if (pattern_match_item->pattern_list != pattern_empty) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"XOR hash function is only supported for empty pattern" ); } + rss_meta->hash_function =RTE_ETH_HASH_FUNCTION_SIMPLE_XOR ; +return 0 ; } +if (rss->func ==RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ ) { + rss_meta->hash_function =RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ ; + symm = true; + } + +/* If pattern type is raw, no need to refine rss type */ +if (pattern_hint ==ICE_PHINT_RAW ) { + rss_meta->raw.symm = symm; +return 0 ; + } + cfg->symm = symm; + +/** +* Check simultaneous use of SRC_ONLY and DST_ONLY +* of the same level. +*/ + rss_type =rte_eth_rss_hf_refine (rss->types); + +if (ice_any_invalid_rss_type (rss->func, rss_type, + pattern_match_item->input_set_mask_o)) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , + rss,"RSS type not supported" ); + + rss_meta->cfg = *cfg; +ice_refine_hash_cfg (&rss_meta->cfg, + rss_type, pattern_hint); +return 0 ; }
@@ -1193,15 +1191,29 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,void **meta, struct rte_flow_error *error) { - int ret = 0; + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =1 , + .check = ice_hash_parse_action_check, + }; +const struct rte_flow_action_rss *rss;struct ice_pattern_match_item *pattern_match_item;struct ice_rss_meta *rss_meta_ptr;uint64_t phint =ICE_PHINT_NONE ; +int ret =0 ; ret =ci_flow_check_attr (attr,NULL , error);if (ret)return ret; + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret) +return ret; + rss_meta_ptr =rte_zmalloc (NULL ,sizeof (*rss_meta_ptr),0 );if (!rss_meta_ptr) { rte_flow_error_set(error, EINVAL,
@@ -1233,9 +1245,9 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad, } } -/* Check rss action. */ - ret =ice_hash_parse_action (pattern_match_item, actions, phint, - rss_meta_ptr, error); + rss = parsed_actions.actions[0 ]->conf; + ret =ice_hash_parse_rss_action (pattern_match_item, rss, phint, + rss_meta_ptr, error); error:if (!ret && meta)
Signature · 1 line
2.47.3
PATCH v6 25/27 net/ice: use common action checks for FDIR
In reply to Anatoly BurakovFrom: Vladimir Medvedkin <[email protected]>
Use the common flow action checking parsing infrastructure for checking flow actions for FDIR filter.
--- drivers/net/intel/ice/ice_fdir_filter.c | 376 +++++++++++++----------- 1 file changed, 204 insertions(+), 172 deletions(-)
drivers/net/intel/ice/ice_fdir_filter.c +204 -172
@@ -1695,177 +1695,6 @@ static struct ice_flow_engine ice_fdir_engine = { .rule_size = sizeof(struct ice_fdir_filter_conf), }; -static int -ice_fdir_parse_action_qregion (struct ice_pf *pf, -struct rte_flow_error *error, -const struct rte_flow_action *act, -struct ice_fdir_filter_conf *filter) -{ -const struct rte_flow_action_rss *rss = act->conf; -uint32_t i; - -if (act->type !=RTE_FLOW_ACTION_TYPE_RSS ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid action." ); -return -rte_errno; - } - -if (rss->queue_num <=1 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Queue region size can't be 0 or 1." ); -return -rte_errno; - } - -/* check if queue index for queue region is continuous */ -for (i =0 ; i < rss->queue_num -1 ; i++) { -if (rss->queue[i +1 ] != rss->queue[i] +1 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Discontinuous queue region" ); -return -rte_errno; - } - } - -if (rss->queue[rss->queue_num -1 ] >= pf->dev_data->nb_rx_queues) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid queue region indexes." ); -return -rte_errno; - } - -if (!(rte_is_power_of_2 (rss->queue_num) && - (rss->queue_num <=ICE_FDIR_MAX_QREGION_SIZE ))) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"The region size should be any of the following values:" -"1, 2, 4, 8, 16, 32, 64, 128 as long as the total number " -"of queues do not exceed the VSI allocation." ); -return -rte_errno; - } - - filter->input.q_index = rss->queue[0 ]; - filter->input.q_region =rte_fls_u32 (rss->queue_num) -1 ; - filter->input.dest_ctl =ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QGROUP ; - -return 0 ; -} - -static int -ice_fdir_parse_action (struct ice_adapter *ad, -const struct rte_flow_action actions[], -struct rte_flow_error *error, -struct ice_fdir_filter_conf *filter) -{ -struct ice_pf *pf = &ad->pf; -const struct rte_flow_action_queue *act_q; -const struct rte_flow_action_mark *mark_spec =NULL ; -const struct rte_flow_action_count *act_count; -uint32_t dest_num =0 ; -uint32_t mark_num =0 ; -uint32_t counter_num =0 ; -int ret; - -for (; actions->type !=RTE_FLOW_ACTION_TYPE_END ; actions++) { -switch (actions->type) { -case RTE_FLOW_ACTION_TYPE_VOID : -break ; -case RTE_FLOW_ACTION_TYPE_QUEUE : - dest_num++; - - act_q = actions->conf; - filter->input.q_index = act_q->index; -if (filter->input.q_index >= - pf->dev_data->nb_rx_queues) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid queue for FDIR." ); -return -rte_errno; - } - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX ; -break ; -case RTE_FLOW_ACTION_TYPE_DROP : - dest_num++; - - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DROP_PKT ; -break ; -case RTE_FLOW_ACTION_TYPE_PASSTHRU : - dest_num++; - - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER ; -break ; -case RTE_FLOW_ACTION_TYPE_RSS : - dest_num++; - - ret =ice_fdir_parse_action_qregion (pf, - error, actions, filter); -if (ret) -return ret; -break ; -case RTE_FLOW_ACTION_TYPE_MARK : - mark_num++; - filter->mark_flag =1 ; - mark_spec = actions->conf; - filter->input.fltr_id = mark_spec->id; - filter->input.fdid_prio =ICE_FXD_FLTR_QW1_FDID_PRI_ONE ; -break ; -case RTE_FLOW_ACTION_TYPE_COUNT : - counter_num++; - - act_count = actions->conf; - filter->input.cnt_ena =ICE_FXD_FLTR_QW0_STAT_ENA_PKTS ; -memcpy (&filter->act_count, act_count, -sizeof (filter->act_count)); - -break ; -default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Invalid action." ); -return -rte_errno; - } - } - -if (dest_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Unsupported action combination" ); -return -rte_errno; - } - -if (mark_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Too many mark actions" ); -return -rte_errno; - } - -if (counter_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Too many count actions" ); -return -rte_errno; - } - -if (dest_num + mark_num + counter_num ==0 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Empty action" ); -return -rte_errno; - } - -/* set default action to PASSTHRU mode, in "mark/count only" case. */ -if (dest_num ==0 ) - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER ; - -return 0 ; -} static int ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
@@ -2804,6 +2633,188 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,return 0 ; } +static int +ice_fdir_parse_action (struct ice_adapter *ad, +const struct ci_flow_actions *actions, +struct rte_flow_error *error) +{ +struct ice_pf *pf = &ad->pf; +struct ice_fdir_filter_conf *filter = &pf->fdir.conf; +bool dest_set = false; +size_t i; + +for (i =0 ; i < actions->count; i++) { +const struct rte_flow_action *act = actions->actions[i]; + +switch (act->type) { +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *act_q = act->conf; + dest_set = true; + + filter->input.q_index = act_q->index; + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX ; +break ; + } +case RTE_FLOW_ACTION_TYPE_DROP : + dest_set = true; + + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DROP_PKT ; +break ; +case RTE_FLOW_ACTION_TYPE_PASSTHRU : + dest_set = true; + + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER ; +break ; +case RTE_FLOW_ACTION_TYPE_RSS : + { +const struct rte_flow_action_rss *rss = act->conf; + dest_set = true; + + filter->input.q_index = rss->queue[0 ]; + filter->input.q_region =rte_fls_u32 (rss->queue_num) -1 ; + filter->input.dest_ctl =ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QGROUP ; + +break ; + } +case RTE_FLOW_ACTION_TYPE_MARK : + { +const struct rte_flow_action_mark *mark_spec = act->conf; + filter->mark_flag =1 ; + filter->input.fltr_id = mark_spec->id; + filter->input.fdid_prio =ICE_FXD_FLTR_QW1_FDID_PRI_ONE ; +break ; + } +case RTE_FLOW_ACTION_TYPE_COUNT : + { +const struct rte_flow_action_count *act_count = act->conf; + + filter->input.cnt_ena =ICE_FXD_FLTR_QW0_STAT_ENA_PKTS ; +rte_memcpy (&filter->act_count, act_count, +sizeof (filter->act_count)); +break ; + } +default : +/* Should not happen */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"Invalid action." ); + } + } + +/* set default action to PASSTHRU mode, in "mark/count only" case. */ +if (!dest_set) { + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER ; + } + +return 0 ; +} + +static int +ice_fdir_check_action_qregion (struct ice_pf *pf, +struct rte_flow_error *error, +const struct rte_flow_action_rss *rss) +{ +if (rss->queue_num <=1 ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"Queue region size can't be 0 or 1." ); + } + +if (rss->queue[rss->queue_num -1 ] >= pf->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"Invalid queue region indexes." ); + } + +if (!(rte_is_power_of_2 (rss->queue_num) && + (rss->queue_num <=ICE_FDIR_MAX_QREGION_SIZE ))) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"The region size should be any of the following values:" +"2, 4, 8, 16, 32, 64, 128 as long as the total number " +"of queues do not exceed the VSI allocation." ); + +return 0 ; +} + +static int +ice_fdir_check_action (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +struct ice_adapter *ad = param->driver_ctx; +struct ice_pf *pf = &ad->pf; +uint32_t dest_num =0 ; +uint32_t mark_num =0 ; +uint32_t counter_num =0 ; +size_t i; +int ret; + +for (i =0 ; i < actions->count; i++) { +const struct rte_flow_action *act = actions->actions[i]; + +switch (act->type) { +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *act_q = act->conf; + dest_num++; + +if (act_q->index >= pf->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act, +"Invalid queue for FDIR." ); + } +break ; + } +case RTE_FLOW_ACTION_TYPE_DROP : + dest_num++; +break ; +case RTE_FLOW_ACTION_TYPE_PASSTHRU : + dest_num++; +break ; +case RTE_FLOW_ACTION_TYPE_RSS : + { +const struct rte_flow_action_rss *rss = act->conf; + + dest_num++; + ret =ice_fdir_check_action_qregion (pf, error, rss); +if (ret) +return ret; +break ; + } +case RTE_FLOW_ACTION_TYPE_MARK : + { + mark_num++; +break ; + } +case RTE_FLOW_ACTION_TYPE_COUNT : + { + counter_num++; +break ; + } +default : +/* Should not happen */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"Invalid action." ); + } + } + +if (dest_num >1 || mark_num >1 || counter_num >1 ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Unsupported action combination" ); + } + +return 0 ; +} + static int ice_fdir_parse(struct ice_adapter *ad, struct ice_pattern_match_item *array,
@@ -2814,6 +2825,22 @@ ice_fdir_parse(struct ice_adapter *ad,void **meta, struct rte_flow_error *error) { + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_PASSTHRU , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_MARK , +RTE_FLOW_ACTION_TYPE_COUNT , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =3 , + .check = ice_fdir_check_action, + .driver_ctx = ad, + .rss_queues_contig = true, + };struct ice_pf *pf = &ad->pf;struct ice_fdir_filter_conf *filter = &pf->fdir.conf;struct ice_pattern_match_item *item =NULL ;
@@ -2826,6 +2853,11 @@ ice_fdir_parse(struct ice_adapter *ad,return ret;memset (filter,0 ,sizeof (*filter)); + + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret) +return ret; + item =ice_search_pattern_match_item (ad, pattern, array, array_len, error);
@@ -2854,7 +2886,7 @@ ice_fdir_parse(struct ice_adapter *ad, goto error; } - ret =ice_fdir_parse_action (ad, actions, error, filter); + ret =ice_fdir_parse_action (ad, &parsed_actions, error);if (ret) goto error;
Signature · 1 line
2.47.3
PATCH v6 26/27 net/ice: use common action checks for switch
In reply to Anatoly BurakovFrom: Vladimir Medvedkin <[email protected]>
Use the common flow action checking parsing infrastructure for checking flow actions for switch filter.
--- drivers/net/intel/ice/ice_switch_filter.c | 371 +++++++++++----------- 1 file changed, 185 insertions(+), 186 deletions(-)
drivers/net/intel/ice/ice_switch_filter.c +185 -186
@@ -35,6 +35,8 @@#define ICE_IPV4_PROTO_NVGRE 0x002F#define ICE_SW_PRI_BASE 6 +#define ICE_SW_MAX_QUEUES 128 +#define ICE_SW_INSET_ETHER ( \ ICE_INSET_DMAC | ICE_INSET_SMAC | ICE_INSET_ETHERTYPE)#define ICE_SW_INSET_MAC_VLAN ( \
@@ -1527,85 +1529,38 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[], }static int -ice_switch_parse_dcf_action (struct ice_dcf_adapter *ad, -const struct rte_flow_action *actions, +ice_switch_parse_dcf_action (const struct rte_flow_action *action,uint32_t priority,struct rte_flow_error *error,struct ice_adv_rule_info *rule_info) {const struct rte_flow_action_ethdev *act_ethdev; -const struct rte_flow_action *action;const struct rte_eth_dev *repr_dev;enum rte_flow_action_type action_type; -uint16_t rule_port_id, backer_port_id; -for (action = actions; action->type != -RTE_FLOW_ACTION_TYPE_END ; action++) { - action_type = action->type; -switch (action_type) { -case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR : - rule_info->sw_act.fltr_act =ICE_FWD_TO_VSI ; - act_ethdev = action->conf; - -if (!rte_eth_dev_is_valid_port (act_ethdev->port_id)) - goto invalid_port_id; - -/* For traffic to original DCF port */ - rule_port_id = ad->parent.pf.dev_data->port_id; - -if (rule_port_id != act_ethdev->port_id) - goto invalid_port_id; - - rule_info->sw_act.vsi_handle =0 ; - -break ; - -invalid_port_id: -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid port_id" ); -return -rte_errno; - -case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT : - rule_info->sw_act.fltr_act =ICE_FWD_TO_VSI ; - act_ethdev = action->conf; - -if (!rte_eth_dev_is_valid_port (act_ethdev->port_id)) - goto invalid; - - repr_dev = &rte_eth_devices[act_ethdev->port_id]; - -if (!repr_dev->data) - goto invalid; - - rule_port_id = ad->parent.pf.dev_data->port_id; - backer_port_id = repr_dev->data->backer_port_id; - -if (backer_port_id != rule_port_id) - goto invalid; - - rule_info->sw_act.vsi_handle = repr_dev->data->representor_id; -break ; - -invalid: -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid ethdev_port_id" ); -return -rte_errno; - -case RTE_FLOW_ACTION_TYPE_DROP : - rule_info->sw_act.fltr_act =ICE_DROP_PACKET ; -break ; - -default : -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid action type" ); -return -rte_errno; - } + action_type = action->type; +switch (action_type) { +case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR : + rule_info->sw_act.fltr_act =ICE_FWD_TO_VSI ; + rule_info->sw_act.vsi_handle =0 ; +break ; + +case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT : + rule_info->sw_act.fltr_act =ICE_FWD_TO_VSI ; + act_ethdev = action->conf; + repr_dev = &rte_eth_devices[act_ethdev->port_id]; + rule_info->sw_act.vsi_handle = repr_dev->data->representor_id; +break ; + +case RTE_FLOW_ACTION_TYPE_DROP : + rule_info->sw_act.fltr_act =ICE_DROP_PACKET ; +break ; + +default : +/* Should never reach */ +rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Invalid action type" ); +return -rte_errno; } rule_info->sw_act.src = rule_info->sw_act.vsi_handle;
@@ -1621,73 +1576,38 @@ ice_switch_parse_dcf_action(struct ice_dcf_adapter *ad,static int ice_switch_parse_action (struct ice_pf *pf, -const struct rte_flow_action *actions, +const struct rte_flow_action *action,uint32_t priority,struct rte_flow_error *error,struct ice_adv_rule_info *rule_info) {struct ice_vsi *vsi = pf->main_vsi; -struct rte_eth_dev_data *dev_data = pf->adapter->pf.dev_data;const struct rte_flow_action_queue *act_q;const struct rte_flow_action_rss *act_qgrop; -uint16_t base_queue, i; -const struct rte_flow_action *action; +uint16_t base_queue;enum rte_flow_action_type action_type; -uint16_t valid_qgrop_number[MAX_QGRP_NUM_TYPE ] = { -2 ,4 ,8 ,16 ,32 ,64 ,128 }; base_queue = pf->base_queue + vsi->base_queue; -for (action = actions; action->type != -RTE_FLOW_ACTION_TYPE_END ; action++) { - action_type = action->type; -switch (action_type) { -case RTE_FLOW_ACTION_TYPE_RSS : - act_qgrop = action->conf; -if (act_qgrop->queue_num <=1 ) - goto error; - rule_info->sw_act.fltr_act = -ICE_FWD_TO_QGRP ; - rule_info->sw_act.fwd_id.q_id = - base_queue + act_qgrop->queue[0 ]; -for (i =0 ; i <MAX_QGRP_NUM_TYPE ; i++) { -if (act_qgrop->queue_num == - valid_qgrop_number[i]) -break ; - } -if (i ==MAX_QGRP_NUM_TYPE ) - goto error; -if ((act_qgrop->queue[0 ] + - act_qgrop->queue_num) > - dev_data->nb_rx_queues) - goto error1; -for (i =0 ; i < act_qgrop->queue_num -1 ; i++) -if (act_qgrop->queue[i +1 ] != - act_qgrop->queue[i] +1 ) - goto error2; - rule_info->sw_act.qgrp_size = - act_qgrop->queue_num; -break ; -case RTE_FLOW_ACTION_TYPE_QUEUE : - act_q = action->conf; -if (act_q->index >= dev_data->nb_rx_queues) - goto error; - rule_info->sw_act.fltr_act = -ICE_FWD_TO_Q ; - rule_info->sw_act.fwd_id.q_id = - base_queue + act_q->index; -break ; - -case RTE_FLOW_ACTION_TYPE_DROP : - rule_info->sw_act.fltr_act = -ICE_DROP_PACKET ; -break ; - -case RTE_FLOW_ACTION_TYPE_VOID : -break ; - -default : - goto error; - } + action_type = action->type; +switch (action_type) { +case RTE_FLOW_ACTION_TYPE_RSS : + act_qgrop = action->conf; + rule_info->sw_act.fltr_act =ICE_FWD_TO_QGRP ; + rule_info->sw_act.fwd_id.q_id = base_queue + act_qgrop->queue[0 ]; + rule_info->sw_act.qgrp_size = act_qgrop->queue_num; +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : + act_q = action->conf; + rule_info->sw_act.fltr_act =ICE_FWD_TO_Q ; + rule_info->sw_act.fwd_id.q_id = base_queue + act_q->index; +break ; +case RTE_FLOW_ACTION_TYPE_DROP : + rule_info->sw_act.fltr_act =ICE_DROP_PACKET ; +break ; +default : +rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Invalid action type or queue number" ); +return -rte_errno; } rule_info->sw_act.vsi_handle = vsi->idx;
@@ -1699,65 +1619,120 @@ ice_switch_parse_action(struct ice_pf *pf, rule_info->priority =ICE_SW_PRI_BASE - priority;return 0 ; - -error: -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid action type or queue number" ); -return -rte_errno; - -error1: -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid queue region indexes" ); -return -rte_errno; - -error2: -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Discontinuous queue region" ); -return -rte_errno; }static int -ice_switch_check_action (const struct rte_flow_action *actions, -struct rte_flow_error *error) +ice_switch_dcf_action_check (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) { +struct ice_dcf_adapter *ad = param->driver_ctx;const struct rte_flow_action *action;enum rte_flow_action_type action_type; -uint16_t actions_num =0 ; - -for (action = actions; action->type != -RTE_FLOW_ACTION_TYPE_END ; action++) { - action_type = action->type; -switch (action_type) { -case RTE_FLOW_ACTION_TYPE_RSS : -case RTE_FLOW_ACTION_TYPE_QUEUE : -case RTE_FLOW_ACTION_TYPE_DROP : -case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT : -case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR : - actions_num++; -break ; -case RTE_FLOW_ACTION_TYPE_VOID : -continue ; -default : -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid action type" ); -return -rte_errno; +const struct rte_flow_action_ethdev *act_ethdev; +const struct rte_eth_dev *repr_dev; + + action = actions->actions[0 ]; + action_type = action->type; + +switch (action_type) { +case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR : +case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT : + { +uint16_t expected_port_id, backer_port_id; + act_ethdev = action->conf; + +if (!rte_eth_dev_is_valid_port (act_ethdev->port_id)) + goto invalid_port_id; + + expected_port_id = ad->parent.pf.dev_data->port_id; + +if (action_type ==RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR ) { +if (expected_port_id != act_ethdev->port_id) + goto invalid_port_id; + }else { + repr_dev = &rte_eth_devices[act_ethdev->port_id]; + +if (!repr_dev->data) + goto invalid_port_id; + + backer_port_id = repr_dev->data->backer_port_id; + +if (backer_port_id != expected_port_id) + goto invalid_port_id; } + +break ; +invalid_port_id: +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid port ID" ); + } +case RTE_FLOW_ACTION_TYPE_DROP : +break ; +default : +/* Should never reach */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid action type" ); } -if (actions_num !=1 ) { -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid action number" ); -return -rte_errno; +return 0 ; +} + +static int +ice_switch_action_check (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +struct ice_adapter *ad = param->driver_ctx; +struct ice_pf *pf = &ad->pf; +struct rte_eth_dev_data *dev_data = pf->dev_data; +const struct rte_flow_action *action = actions->actions[0 ]; + +switch (action->type) { +case RTE_FLOW_ACTION_TYPE_RSS : + { +const struct rte_flow_action_rss *act_qgrop; + act_qgrop = action->conf; + +/* Check bounds on number of queues */ +if (act_qgrop->queue_num <2 || act_qgrop->queue_num >ICE_SW_MAX_QUEUES ) + goto err_rss; + +/* must be power of 2 */ +if (!rte_is_power_of_2 (act_qgrop->queue_num)) + goto err_rss; + +/* queues are monotonous and contiguous so check last queue */ +if ((act_qgrop->queue[0 ] + act_qgrop->queue_num) > dev_data->nb_rx_queues) + goto err_rss; + +break ; +err_rss: +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid queue region" ); + } +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *act_q; + act_q = action->conf; +if (act_q->index >= dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid queue" ); + } + +break ; + } +case RTE_FLOW_ACTION_TYPE_DROP : +break ; +default : +/* Should never reach */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid action type" ); }return 0 ;
@@ -1788,11 +1763,39 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,struct ci_flow_attr_check_param attr_param = { .allow_priority = true, }; +struct ci_flow_actions parsed_actions = {0 }; +struct ci_flow_actions_check_param dcf_param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT , +RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =1 , + .check = ice_switch_dcf_action_check, + }; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =1 , + .check = ice_switch_action_check, + .driver_ctx = ad, + .rss_queues_contig = true, + }; ret =ci_flow_check_attr (attr, &attr_param, error);if (ret)return ret; + ret =ci_flow_check_actions (actions, (ad->hw.dcf_enabled) ? &dcf_param : ¶m, + &parsed_actions, error); +if (ret) + goto error; +/* Allow only two priority values - 0 or 1 */ if (attr->priority >1 ) { rte_flow_error_set(error, EINVAL,
@@ -1870,16 +1873,12 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,memset (&rule_info,0 ,sizeof (rule_info)); rule_info.tun_type = tun_type; - ret =ice_switch_check_action (actions, error); -if (ret) - goto error; -if (ad->hw.dcf_enabled) - ret =ice_switch_parse_dcf_action ((void *)ad, actions, attr->priority, - error, &rule_info); + ret =ice_switch_parse_dcf_action (parsed_actions.actions[0 ], + attr->priority, error, &rule_info);else - ret =ice_switch_parse_action (pf, actions, attr->priority, error, - &rule_info); + ret =ice_switch_parse_action (pf, parsed_actions.actions[0 ], + attr->priority, error, &rule_info);if (ret) goto error;
Signature · 1 line
2.47.3
PATCH v6 27/27 net/ice: use common action checks for ACL
In reply to Anatoly BurakovFrom: Vladimir Medvedkin <[email protected]>
Use the common flow action checking parsing infrastructure for checking flow actions for ACL filter.
--- drivers/net/intel/ice/ice_acl_filter.c | 143 +++++++++++++++---------- 1 file changed, 84 insertions(+), 59 deletions(-)
drivers/net/intel/ice/ice_acl_filter.c +84 -59
@@ -645,60 +645,6 @@ ice_acl_filter_free(struct rte_flow *flow) flow->rule =NULL ; } -static int -ice_acl_parse_action(__rte_unused struct ice_adapter *ad, -const struct rte_flow_action actions[], -struct rte_flow_error *error, -struct ice_acl_conf *filter) -{ -struct ice_pf *pf = &ad->pf; -const struct rte_flow_action_queue *act_q; -uint32_t dest_num =0 ; - -for (; actions->type !=RTE_FLOW_ACTION_TYPE_END ; actions++) { -switch (actions->type) { -case RTE_FLOW_ACTION_TYPE_VOID : -break ; -case RTE_FLOW_ACTION_TYPE_DROP : - dest_num++; - - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DROP_PKT ; -break ; -case RTE_FLOW_ACTION_TYPE_QUEUE : - dest_num++; - - act_q = actions->conf; - filter->input.q_index = act_q->index; -if (filter->input.q_index >= - pf->dev_data->nb_rx_queues) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid queue for FDIR." ); -return -rte_errno; - } - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX ; -break ; -default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Invalid action." ); -return -rte_errno; - } - } - -if (dest_num ==0 || dest_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Unsupported action combination" ); -return -rte_errno; - } - -return 0 ; -} - static int ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad, const struct rte_flow_item pattern[],
@@ -966,6 +912,69 @@ ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad,return 0 ; } +static int +ice_acl_parse_action (const struct ci_flow_actions *actions, +struct ice_acl_conf *filter, +struct rte_flow_error *error) +{ +const struct rte_flow_action *act = actions->actions[0 ]; + +switch (act->type) { +case RTE_FLOW_ACTION_TYPE_DROP : + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DROP_PKT ; +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *act_q = act->conf; + + filter->input.q_index = act_q->index; + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX ; +break ; + } +default : +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"Invalid action." ); + } + +return 0 ; +} + +static int +ice_acl_parse_action_check (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +struct ice_adapter *ad = param->driver_ctx; +struct ice_pf *pf = &ad->pf; +const struct rte_flow_action *act = actions->actions[0 ]; + +switch (act->type) { +case RTE_FLOW_ACTION_TYPE_DROP : +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *act_q = act->conf; + +if (act_q->index >= pf->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"Invalid queue for ACL." ); + } +break ; + } +default : +/* shouldn't happen */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"Invalid action." ); + } + +return 0 ; +} + static int ice_acl_parse(struct ice_adapter *ad, struct ice_pattern_match_item *array,
@@ -976,17 +985,33 @@ ice_acl_parse(struct ice_adapter *ad,void **meta, struct rte_flow_error *error) { + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =1 , + .check = ice_acl_parse_action_check, + .driver_ctx = ad, + };struct ice_pf *pf = &ad->pf;struct ice_acl_conf *filter = &pf->acl.conf;struct ice_pattern_match_item *item =NULL ;uint64_t input_set;int ret; - ret =ci_flow_check_attr (attr,NULL , error); -if (ret) -return ret; -memset (filter,0 ,sizeof (*filter)); + + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; + + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret) +return ret; + item =ice_search_pattern_match_item (ad, pattern, array, array_len, error);if (!item)
@@ -1005,7 +1030,7 @@ ice_acl_parse(struct ice_adapter *ad, goto error; } - ret =ice_acl_parse_action (ad, actions, error, filter); + ret =ice_acl_parse_action (&parsed_actions, filter, error);if (ret) goto error;
Signature · 1 line
2.47.3
v7 cover Add common flow attr/action parsing infrastructure to Intel PMD's
In reply to Anatoly BurakovThis patchset introduces common flow attr/action checking infrastructure to some Intel PMD's (IXGBE, I40E, IAVF, and ICE). The aim is to reduce code duplication, simplify implementation of new parsers/verification of existing ones, and make action/attr handling more consistent across drivers.
v7:
- Fail on empty action list before calling into user callbacks
- Remove empty code
v6:
- Increase max number of actions to 32
- Add missing flow item types from list of types needing conf
- Improved egress/ingress handling
- ixgbe: allow mark and drop combination of actions
- ixgbe: fix set-then-reset when initializing rules for fdir engine
v5:
- Add missing patch for component/class name compile time constant
- Fixed missing RSS queue contiguousness checks
v4:
- First few commits were integrated as part of a different patchset
- Added more logging to common infrastructure
- RSS validation now allows discontiguous queue lists by default
- Fixed some checks being too stringent and failing common validation
v3:
- Rebase on latest next-net-intel
- Added 4 new commits that have to do with not using rte_eth_dev in rte_flow
- Converted the remaining commits to use adapter structures everywhere
- Minor fixes in how return values are handled
- Fixed incorrect check in i40e RSS validation
v2:
- Rebase on latest main
- Now depends on series 37585 [1]
[1] https://patches.dpdk.org/project/dpdk/list/?series=37585
Anatoly Burakov (21):
eal/common: add token concatenation macro net/intel/common: add common flow action parsing net/intel/common: add common flow attr validation net/ixgbe: use common checks in ethertype filter net/ixgbe: use common checks in syn filter net/ixgbe: use common checks in L2 tunnel filter net/ixgbe: use common checks in ntuple filter net/ixgbe: use common checks in security filter net/ixgbe: use common checks in FDIR filters net/ixgbe: use common checks in RSS filter net/i40e: use common flow attribute checks net/i40e: refactor RSS flow parameter checks net/i40e: use common action checks for ethertype net/i40e: use common action checks for FDIR net/i40e: use common action checks for tunnel net/iavf: use common flow attribute checks net/iavf: use common action checks for IPsec net/iavf: use common action checks for hash net/iavf: use common action checks for FDIR net/iavf: use common action checks for fsub net/iavf: use common action checks for flow query
Bruce Richardson (1):
build: add build defines for component name and class
Vladimir Medvedkin (5):
net/ice: use common flow attribute checks
net/ice: use common action checks for hash
net/ice: use common action checks for FDIR
net/ice: use common action checks for switch
net/ice: use common action checks for ACL
drivers/meson.build | 2 + drivers/net/intel/common/flow_check.h | 354 ++++++ drivers/net/intel/common/log.h | 40 + drivers/net/intel/i40e/i40e_ethdev.h | 1 - drivers/net/intel/i40e/i40e_flow.c | 433 +++----- drivers/net/intel/i40e/i40e_hash.c | 438 +++++--- drivers/net/intel/i40e/i40e_hash.h | 2 +- drivers/net/intel/iavf/iavf_fdir.c | 368 +++---- drivers/net/intel/iavf/iavf_fsub.c | 262 ++--- drivers/net/intel/iavf/iavf_generic_flow.c | 107 +- drivers/net/intel/iavf/iavf_generic_flow.h | 2 +- drivers/net/intel/iavf/iavf_hash.c | 153 +-- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 43 +- drivers/net/intel/ice/ice_acl_filter.c | 146 ++- drivers/net/intel/ice/ice_fdir_filter.c | 384 ++++--- drivers/net/intel/ice/ice_generic_flow.c | 59 +- drivers/net/intel/ice/ice_generic_flow.h | 2 +- drivers/net/intel/ice/ice_hash.c | 189 ++-- drivers/net/intel/ice/ice_switch_filter.c | 389 +++---- drivers/net/intel/ixgbe/ixgbe_flow.c | 1161 +++++++------------- lib/eal/include/rte_common.h | 4 + lib/meson.build | 2 + 22 files changed, 2269 insertions(+), 2272 deletions(-) create mode 100644 drivers/net/intel/common/flow_check.h create mode 100644 drivers/net/intel/common/log.h
Signature · 1 line
2.47.3
PATCH v7 1/27 build: add build defines for component name and class
From: Bruce Richardson <[email protected]>
When building each component, pass in -D flags to define for it the component class and name. This allows any files which may be used multiple times to identify what component is including them.
--- drivers/meson.build | 2 ++ lib/meson.build | 2 ++ 2 files changed, 4 insertions(+)
drivers/meson.build +2 -0
@@ -264,6 +264,8 @@ foreach subpath:subdirs enabled_drivers += name lib_name = '_'.join(['rte', class, name]) + cflags += '-DRTE_COMPONENT_CLASS=pmd_' + class + cflags += '-DRTE_COMPONENT_NAME=' + name cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=' + '.'.join([log_prefix, name]) if annotate_locks and cc.get_id() == 'clang' cflags += '-DRTE_ANNOTATE_LOCKS'
lib/meson.build +2 -0
@@ -237,6 +237,8 @@ foreach l:libraries cflags += '-DRTE_USE_FUNCTION_VERSIONING' endif cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=lib.' + l + cflags += '-DRTE_COMPONENT_CLASS=lib' + cflags += '-DRTE_COMPONENT_NAME=' + name if annotate_locks and cc.get_id() == 'clang' cflags += '-DRTE_ANNOTATE_LOCKS' cflags += '-Wthread-safety'
Signature · 1 line
2.47.3
PATCH v7 2/27 eal/common: add token concatenation macro
In reply to Anatoly BurakovAdd RTE_CONCAT() macro to enable token concatenation with proper macro expansion.
--- lib/eal/include/rte_common.h | 4 ++++ 1 file changed, 4 insertions(+)
lib/eal/include/rte_common.h +4 -0
@@ -918,6 +918,10 @@ __extension__ typedef uint64_t RTE_MARKER64[0];/** Take a macro value and get a string version of it */ #define RTE_STR (x) _RTE_STR(x) +/** Concatenate two tokens after expanding macros in both. */ +#define _RTE_CONCAT2 (a, b) a ## b +#define RTE_CONCAT (a, b) _RTE_CONCAT2(a, b) +/** * ISO C helpers to modify format strings using variadic macros. * This is a replacement for the ", ## __VA_ARGS__" GNU extension.
Signature · 1 line
2.47.3
PATCH v7 3/27 net/intel/common: add common flow action parsing
In reply to Anatoly BurakovCurrently, each driver has their own code for action parsing, which results in a lot of duplication and subtle mismatches in behavior between drivers.
Add common infrastructure, based on the following assumptions:
- All drivers support at most 32 actions at once, but usually far less
- Not every action is supported by all drivers
- We can check a few common things to filter out obviously wrong actions
- Driver performs semantic checks on all valid actions
So, the intention is to reject everything we can reasonably reject at the outset without knowing anything about the drivers, parametrize what is trivial to parametrize, and leave the rest for the driver to implement.
While we're at it, also add logging infrastructure for Intel common code, using the new component name defines that are automatically passed to each DPDK driver as it is being built.
--- drivers/net/intel/common/flow_check.h | 284 ++++++++++++++++++++++++++ drivers/net/intel/common/log.h | 40 ++++ 2 files changed, 324 insertions(+) create mode 100644 drivers/net/intel/common/flow_check.h create mode 100644 drivers/net/intel/common/log.h
drivers/net/intel/common/flow_check.h new file +284 -0
@@ -0,0 +1,284 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2025 Intel Corporation +*/ + +#ifndef _COMMON_INTEL_FLOW_CHECK_H_ +#define _COMMON_INTEL_FLOW_CHECK_H_ + +#include <bus_pci_driver.h> +#include <ethdev_driver.h> + +#include "log.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* +* Common attr and action validation code for Intel drivers. +*/ + +/** +* Maximum number of actions that can be stored in a parsed action list. +*/ +#define CI_FLOW_PARSED_ACTIONS_MAX 32 + +/* Actions that are reasonably expected to have a conf structure */ +static const enum rte_flow_action_type need_conf[] = { +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_VF , +RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR , +RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT , +RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP , +RTE_FLOW_ACTION_TYPE_PROG , +RTE_FLOW_ACTION_TYPE_COUNT , +RTE_FLOW_ACTION_TYPE_MARK , +RTE_FLOW_ACTION_TYPE_SECURITY , +RTE_FLOW_ACTION_TYPE_END +}; + +/** +* Is action type in this list of action types? +*/ +static inline bool +ci_flow_action_type_in_list (const enum rte_flow_action_type type, +const enum rte_flow_action_type list[]) +{ +size_t i =0 ; +while (list[i] !=RTE_FLOW_ACTION_TYPE_END ) { +if (type == list[i]) +return true; + i++; + } +return false; +} + +/* Forward declarations */ +struct ci_flow_actions ; +struct ci_flow_actions_check_param ; + +static inline const char * +ci_flow_action_type_to_str (enum rte_flow_action_type type) +{ +const char *name =NULL ; +int ret; + + ret =rte_flow_conv (RTE_FLOW_CONV_OP_ACTION_NAME_PTR , + &name,sizeof (name), (const void *)(uintptr_t )type,NULL ); +if (ret <0 || name ==NULL ) +return "UNKNOWN" ; + +return name; +} + +/** +* Driver-specific action list validation callback. +* +* Performs driver-specific validation of action parameter list. +* Called after all actions have been parsed and added to the list, +* allowing validation based on the complete action set. +* +* @param actions +* The complete list of parsed actions (for context-dependent validation). +* @param driver_ctx +* Opaque driver context (e.g., adapter/queue configuration). +* @param error +* Pointer to rte_flow_error for reporting failures. +* @return +* 0 on success, negative errno on failure. +*/ +typedef int (*ci_flow_actions_check_fn )(const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error); + +/** +* List of actions that we know we've validated. +*/ +struct ci_flow_actions { +/* Number of actions in the list. */ +uint8_t count; +/* Parsed actions array. */ +struct rte_flow_action const *actions[CI_FLOW_PARSED_ACTIONS_MAX ]; +}; + +/** +* Parameters for action list validation. Any element can be NULL/0 as checks are only performed +* against constraints specified. +*/ +struct ci_flow_actions_check_param { +/** +* Driver-specific context pointer (e.g., adapter/queue configuration). Can be NULL. +*/ +void *driver_ctx; +/** +* Driver-specific action list validation callback. Can be NULL. +*/ +ci_flow_actions_check_fn check; +/** +* Allowed action types for this parse parameter. Must be terminated with +* RTE_FLOW_ACTION_TYPE_END. Can be NULL. +*/ +const enum rte_flow_action_type *allowed_types; +size_t max_actions;/**< Maximum number of actions allowed. */ +bool rss_queues_contig;/**< If true, RSS queues must be contiguous. */ +}; + +static inline int +__flow_action_check_rss (const struct rte_flow_action_rss *rss, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +uint32_t qnum, q; + + qnum = rss->queue_num; + +/* either we have both queues and queue number, or we have neither */ +if ((qnum ==0 ) != (rss->queue ==NULL )) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"If queue number is specified, queue array must also be specified" ); + } +/* check if queues are monotonic */ +for (q =1 ; q < qnum; q++) { +if (rss->queue[q] < rss->queue[q -1 ]) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"RSS queues must be in ascending order" ); + } +/* if user has requested contiguousness, check that as well */ +if (param ==NULL || !param->rss_queues_contig) +continue ; +if (rss->queue[q] != rss->queue[0 ] + q) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"RSS queues must be contiguous" ); + } + } + +/* either we have both key and key length, or we have neither */ +if ((rss->key_len ==0 ) != (rss->key ==NULL )) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"If RSS key is specified, key length must also be specified" ); + } +return 0 ; +} + +static inline int +__flow_action_check_generic (const struct rte_flow_action *action, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +/* is this action in our allowed list? */ +if (param !=NULL && param->allowed_types !=NULL && + !ci_flow_action_type_in_list (action->type, param->allowed_types)) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Unsupported action" ); + } +/* do we need to validate presence of conf? */ +if (ci_flow_action_type_in_list (action->type, need_conf)) { +if (action->conf ==NULL ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , action, +"Action requires configuration" ); + } + } + +/* type-specific validation */ +switch (action->type) { +case RTE_FLOW_ACTION_TYPE_RSS : + { +const struct rte_flow_action_rss *rss = + (const struct rte_flow_action_rss *)action->conf; +int ret; + + ret =__flow_action_check_rss (rss, param, error); +if (ret <0 ) +return ret; +break ; + } +default : +/* no specific validation */ +break ; + } + +return 0 ; +} + +/** +* Validate and parse a list of rte_flow_action into a parsed action list. +* +* @param actions pointer to array of rte_flow_action, terminated by RTE_FLOW_ACTION_TYPE_END +* @param param pointer to ci_flow_actions_check_param structure (can be NULL) +* @param parsed_actions pointer to ci_flow_actions structure to store parsed actions +* @param error pointer to rte_flow_error structure for error reporting +* +* @return 0 on success, negative errno on failure. +*/ +static inline int +ci_flow_check_actions (const struct rte_flow_action *actions, +const struct ci_flow_actions_check_param *param, +struct ci_flow_actions *parsed_actions, +struct rte_flow_error *error) +{ +size_t i =0 ; +int ret; + +if (actions ==NULL ) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , +NULL ,"Missing actions" ); + } + +/* reset the list */ + *parsed_actions = (struct ci_flow_actions ){0 }; + +while (actions[i].type !=RTE_FLOW_ACTION_TYPE_END ) { +const struct rte_flow_action *action = &actions[i++]; + +/* skip VOID actions */ +if (action->type ==RTE_FLOW_ACTION_TYPE_VOID ) +continue ; + +/* generic validation for actions - this will check against param as well */ + ret =__flow_action_check_generic (action, param, error); +if (ret <0 ) +return ret; + +/* check against global maximum number of actions */ +if (parsed_actions->count >=RTE_DIM (parsed_actions->actions)) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Too many actions" ); + } +/* user may have specified a maximum number of actions */ +if (param !=NULL && param->max_actions !=0 && + parsed_actions->count >= param->max_actions) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Too many actions" ); + } +/* add action to the list */ +CI_DRV_LOG (DEBUG ,"Parsed action %u: type=%s" , parsed_actions->count, +ci_flow_action_type_to_str (action->type)); + parsed_actions->actions[parsed_actions->count++] = action; + } + +/* if we didn't parse anything, valid action list is empty */ +if (parsed_actions->count ==0 ) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , +NULL ,"No valid actions specified" ); + } + +/* now, call into user validation if specified */ +if (param !=NULL && param->check !=NULL ) { + ret = param->check (parsed_actions, param, error); +if (ret <0 ) +return ret; + } +return 0 ; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _COMMON_INTEL_FLOW_CHECK_H_ */
drivers/net/intel/common/log.h new file +40 -0
@@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2026 Intel Corporation +*/ + +#ifndef _COMMON_INTEL_LOG_H_ +#define _COMMON_INTEL_LOG_H_ + +#include <rte_log.h> + +/* +* Common logging for shared Intel driver code. +* +* This header must only be included from driver translation units, where the +* build system has already defined RTE_COMPONENT_NAME (e.g. "iavf"). It uses +* that token to reference the per-driver logtype variable that every Intel +* driver registers (e.g. iavf_logtype_driver), so no additional setup is +* needed beyond what each driver already provides. +* +* Usage: CI_DRV_LOG(DEBUG, "format %s", arg); +*/ + +#ifndef RTE_COMPONENT_NAME +/* CI_DRV_LOG is a no-op when included outside a driver build context. */ +#define CI_DRV_LOG (level, fmt, ...) do { } while (0) +#else /* RTE_COMPONENT_NAME */ + +/* Resolves to the per-driver logtype variable, e.g. iavf_logtype_driver. */ +#define CI_DRV_LOGTYPE RTE_CONCAT(RTE_COMPONENT_NAME, _logtype_driver) + +/* Forward-declare the logtype so shared headers need not include driver headers. */ +extern int CI_DRV_LOGTYPE ; + +#define CI_DRV_LOG (level, fmt, ...) \ + rte_log(RTE_LOG_##level, CI_DRV_LOGTYPE, \ + "PMD_INTEL_COMMON: %s(): " fmt "\n", \ + __func__, ##__VA_ARGS__) + +#endif /* RTE_COMPONENT_NAME */ + +#endif /* _COMMON_INTEL_LOG_H_ */
Signature · 1 line
2.47.3
PATCH v7 4/27 net/intel/common: add common flow attr validation
In reply to Anatoly BurakovThere are a lot of commonalities between what kinds of flow attr each Intel driver supports. Add a helper function that will validate attr based on common requirements and (optional) parameter checks.
Things we check for:
- Rejecting NULL attr (obviously)
- Ingress/egress according to requested params
- Transfer, group, and priority are not allowed unless requested
--- drivers/net/intel/common/flow_check.h | 70 +++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)
drivers/net/intel/common/flow_check.h +70 -0
@@ -57,6 +57,7 @@ ci_flow_action_type_in_list(const enum rte_flow_action_type type,/* Forward declarations */ struct ci_flow_actions ;struct ci_flow_actions_check_param ; +struct ci_flow_attr_check_param ;static inline const char *ci_flow_action_type_to_str (enum rte_flow_action_type type)
@@ -277,6 +278,75 @@ ci_flow_check_actions(const struct rte_flow_action *actions,return 0 ; } +/** +* Parameter structure for attr check. +*/ +struct ci_flow_attr_check_param { +bool allow_priority;/**< True if priority attribute is allowed. */ +bool allow_transfer;/**< True if transfer attribute is allowed. */ +bool allow_group;/**< True if group attribute is allowed. */ +bool require_egress;/**< True if egress attribute is required. */ +}; + +/** +* Validate rte_flow_attr structure against specified constraints. +* +* @param attr Pointer to rte_flow_attr structure to validate. +* @param attr_param Pointer to ci_flow_attr_check_param structure specifying constraints. +* @param error Pointer to rte_flow_error structure for error reporting. +* +* @return 0 on success, negative errno on failure. +*/ +static inline int +ci_flow_check_attr (const struct rte_flow_attr *attr, +const struct ci_flow_attr_check_param *attr_param, +struct rte_flow_error *error) +{ +if (attr ==NULL ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR , attr, +"NULL attribute" ); + } + +/* a rule can only be ingress or egress, never both or neither. */ +if (attr_param !=NULL && attr_param->require_egress) { +if (attr->egress !=1 || attr->ingress !=0 ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_EGRESS , attr, +"Egress attribute is required" ); + } + }else { +if (attr->ingress !=1 || attr->egress !=0 ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_INGRESS , attr, +"Ingress attribute is required" ); + } + } + +/* May not be supported */ +if (attr->transfer && (attr_param ==NULL || !attr_param->allow_transfer)) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER , attr, +"Transfer not supported" ); + } + +/* May not be supported */ +if (attr->group && (attr_param ==NULL || !attr_param->allow_group)) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_GROUP , attr, +"Group not supported" ); + } + +/* May not be supported */ +if (attr->priority && (attr_param ==NULL || !attr_param->allow_priority)) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , attr, +"Priority not supported" ); + } + +return 0 ; +} + #ifdef __cplusplus }#endif
Signature · 1 line
2.47.3
PATCH v7 5/27 net/ixgbe: use common checks in ethertype filter
In reply to Anatoly BurakovUse the common attr and action parsing infrastructure in ethertype. This allows us to remove some checks as they are no longer necessary (such as whether DROP flag was set - if we do not accept DROP actions, we do not set the DROP flag), as well as make some checks more stringent (such as rejecting more than one action).
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 190 ++++++++++----------------- 1 file changed, 73 insertions(+), 117 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +73 -117
@@ -46,6 +46,8 @@#include "base/ixgbe_phy.h" #include "rte_pmd_ixgbe.h" +#include "../common/flow_check.h" +#define IXGBE_MIN_N_TUPLE_PRIO 1#define IXGBE_MAX_N_TUPLE_PRIO 7
@@ -124,6 +126,41 @@ const struct rte_flow_action *next_no_void_action( } } +/* +* All ixgbe engines mostly check the same stuff, so use a common check. +*/ +static int +ixgbe_flow_actions_check (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +const struct rte_flow_action *action; +struct rte_eth_dev_data *dev_data = param->driver_ctx; +size_t idx; + +for (idx =0 ; idx < actions->count; idx++) { + action = actions->actions[idx]; + +switch (action->type) { +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *queue = action->conf; +if (queue->index >= dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + action, +"queue index out of range" ); + } +break ; + } +default : +/* no specific validation */ +break ; + } + } +return 0 ; +} +/** * Please be aware there's an assumption for all the parsers. * rte_flow_item is using big endian, rte_flow_attr and
@@ -725,38 +762,14 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,* item->last should be NULL. */ static int -cons_parse_ethertype_filter (const struct rte_flow_attr *attr, -const struct rte_flow_item *pattern, -const struct rte_flow_action *actions, -struct rte_eth_ethertype_filter *filter, -struct rte_flow_error *error) +cons_parse_ethertype_filter (const struct rte_flow_item *pattern, +const struct rte_flow_action *action, +struct rte_eth_ethertype_filter *filter, +struct rte_flow_error *error) {const struct rte_flow_item *item; -const struct rte_flow_action *act;const struct rte_flow_item_eth *eth_spec;const struct rte_flow_item_eth *eth_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; - } item =next_no_void_pattern (pattern,NULL );/* The first non-void item should be MAC. */
@@ -826,87 +839,30 @@ cons_parse_ethertype_filter(const struct rte_flow_attr *attr,return -rte_errno; } -/* Parse action */ - - act =next_no_void_action (actions,NULL ); -if (act->type !=RTE_FLOW_ACTION_TYPE_QUEUE && - act->type !=RTE_FLOW_ACTION_TYPE_DROP ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - -if (act->type ==RTE_FLOW_ACTION_TYPE_QUEUE ) { - act_q = (const struct rte_flow_action_queue *)act->conf; - filter->queue = act_q->index; - }else { - filter->flags |=RTE_ETHTYPE_FLAGS_DROP ; - } - -/* Check if the next non-void item is END */ - act =next_no_void_action (actions, act); -if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -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) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_INGRESS , - attr,"Only support ingress." ); -return -rte_errno; - } - -/* Not supported */ -if (attr->egress) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_EGRESS , - attr,"Not support egress." ); -return -rte_errno; - } - -/* Not supported */ -if (attr->transfer) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER , - attr,"No support for transfer." ); -return -rte_errno; - } - -/* Not supported */ -if (attr->priority) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , - attr,"Not support priority." ); -return -rte_errno; - } - -/* Not supported */ -if (attr->group) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_GROUP , - attr,"Not support group." ); -return -rte_errno; - } + filter->queue = ((const struct rte_flow_action_queue *)action->conf)->index;return 0 ; }static int -ixgbe_parse_ethertype_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_ethertype_filter *filter, -struct rte_flow_error *error) +ixgbe_parse_ethertype_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_ethertype_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 + }, + .max_actions =1 , + .driver_ctx = dev->data, + .check = ixgbe_flow_actions_check + }; +const struct rte_flow_action *action; if (hw->mac.type != ixgbe_mac_82599EB && hw->mac.type != ixgbe_mac_X540 &&
@@ -916,19 +872,27 @@ ixgbe_parse_ethertype_filter(struct rte_eth_dev *dev, hw->mac.type != ixgbe_mac_E610)return -ENOTSUP ; - ret =cons_parse_ethertype_filter (attr, pattern, - actions, filter, error); +/* validate attributes */ + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; +/* parse requested actions */ + ret =ci_flow_check_actions (actions, &ap_param, &parsed_actions, error);if (ret)return ret; -if (filter->queue >= dev->data->nb_rx_queues) { -memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , -NULL ,"queue index much too big" ); -return -rte_errno; +/* only one action is supported */ +if (parsed_actions.count >1 ) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + parsed_actions.actions[1 ], +"Only one action can be specified at a time" ); } + action = parsed_actions.actions[0 ]; + + ret =cons_parse_ethertype_filter (pattern, action, filter, error); +if (ret) +return ret;if (filter->ether_type ==RTE_ETHER_TYPE_IPV4 || filter->ether_type ==RTE_ETHER_TYPE_IPV6 ) {
@@ -947,14 +911,6 @@ ixgbe_parse_ethertype_filter(struct rte_eth_dev *dev,return -rte_errno; } -if (filter->flags &RTE_ETHTYPE_FLAGS_DROP ) { -memset (filter,0 ,sizeof (struct rte_eth_ethertype_filter )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , -NULL ,"drop option is unsupported" ); -return -rte_errno; - } -return 0 ; }
Signature · 1 line
2.47.3
PATCH v7 6/27 net/ixgbe: use common checks in syn filter
In reply to Anatoly BurakovUse 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.
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 130 +++++++-------------------- 1 file changed, 32 insertions(+), 98 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +32 -98
@@ -935,38 +935,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 */
@@ -1074,63 +1049,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) {
@@ -1141,7 +1060,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; }
@@ -1149,15 +1068,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->data, + .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 &&
@@ -1167,16 +1098,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); }/**
Signature · 1 line
2.47.3
PATCH v7 7/27 net/ixgbe: use common checks in L2 tunnel filter
In reply to Anatoly BurakovUse the common attr and action parsing infrastructure in L2 tunnel filter. Some checks have become more stringent as a result, in particular, group attribute is now explicitly rejected instead of being ignored.
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 149 +++++++++------------------ 1 file changed, 48 insertions(+), 101 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +48 -101
@@ -136,6 +136,7 @@ ixgbe_flow_actions_check(const struct ci_flow_actions *actions, {const struct rte_flow_action *action;struct rte_eth_dev_data *dev_data = param->driver_ctx; +struct ixgbe_adapter *ad =IXGBE_DEV_PRIVATE_TO_ADAPTER (dev_data->dev_private);size_t idx;for (idx =0 ; idx < actions->count; idx++) {
@@ -153,6 +154,17 @@ ixgbe_flow_actions_check(const struct ci_flow_actions *actions, }break ; } +case RTE_FLOW_ACTION_TYPE_VF : + { +const struct rte_flow_action_vf *vf = action->conf; +if (vf->id >= ad->max_vfs) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + action, +"VF id out of range" ); + } +break ; + }default :/* no specific validation */ break ;
@@ -882,12 +894,6 @@ ixgbe_parse_ethertype_filter(struct rte_eth_dev *dev, const struct rte_flow_attrif (ret)return ret; -/* only one action is supported */ -if (parsed_actions.count >1 ) { -return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - parsed_actions.actions[1 ], -"Only one action can be specified at a time" ); - } action = parsed_actions.actions[0 ]; ret =cons_parse_ethertype_filter (pattern, action, filter, error);
@@ -1133,40 +1139,16 @@ ixgbe_parse_syn_filter(struct rte_eth_dev *dev, const struct rte_flow_attr *attr*/ static int cons_parse_l2_tn_filter (struct rte_eth_dev *dev, -const struct rte_flow_attr *attr,const struct rte_flow_item pattern[], -const struct rte_flow_action actions[], +const struct rte_flow_action *action,struct ixgbe_l2_tunnel_conf *filter,struct rte_flow_error *error) {const struct rte_flow_item *item;const struct rte_flow_item_e_tag *e_tag_spec;const struct rte_flow_item_e_tag *e_tag_mask; -const struct rte_flow_action *act; -const struct rte_flow_action_vf *act_vf;struct ixgbe_adapter *ad =IXGBE_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); -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 e-tag. */ item =next_no_void_pattern (pattern,NULL );if (item->type !=RTE_FLOW_ITEM_TYPE_E_TAG ) {
@@ -1224,71 +1206,13 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev,return -rte_errno; } -/* parse attr */ -/* must be input direction */ -if (!attr->ingress) { -memset (filter,0 ,sizeof (struct ixgbe_l2_tunnel_conf )); -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 ixgbe_l2_tunnel_conf )); -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 ixgbe_l2_tunnel_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER , - attr,"No support for transfer." ); -return -rte_errno; - } - -/* not supported */ -if (attr->priority) { -memset (filter,0 ,sizeof (struct ixgbe_l2_tunnel_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , - attr,"Not support priority." ); -return -rte_errno; - } - -/* check if the first not void action is VF or PF. */ - act =next_no_void_action (actions,NULL ); -if (act->type !=RTE_FLOW_ACTION_TYPE_VF && - act->type !=RTE_FLOW_ACTION_TYPE_PF ) { -memset (filter,0 ,sizeof (struct ixgbe_l2_tunnel_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - -if (act->type ==RTE_FLOW_ACTION_TYPE_VF ) { - act_vf = (const struct rte_flow_action_vf *)act->conf; +if (action->type ==RTE_FLOW_ACTION_TYPE_VF ) { +const struct rte_flow_action_vf *act_vf = action->conf; filter->pool = act_vf->id; }else { filter->pool = ad->max_vfs; } -/* 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 ixgbe_l2_tunnel_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } -return 0 ; }
@@ -1300,29 +1224,52 @@ ixgbe_parse_l2_tn_filter(struct rte_eth_dev *dev,struct ixgbe_l2_tunnel_conf *l2_tn_filter, struct rte_flow_error *error) { + struct rte_eth_dev_data *dev_data = dev->data; +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 vf/pf is allowed here */ +RTE_FLOW_ACTION_TYPE_VF , +RTE_FLOW_ACTION_TYPE_PF , +RTE_FLOW_ACTION_TYPE_END + }, + .driver_ctx = dev_data, + .check = ixgbe_flow_actions_check, + .max_actions =1 , + };int ret =0 ; -struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct ixgbe_adapter *ad =IXGBE_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); -uint16_t vf_num; - - ret =cons_parse_l2_tn_filter (dev, attr, pattern, - actions, l2_tn_filter, error); +const struct rte_flow_action *action;if (hw->mac.type != ixgbe_mac_X550 && hw->mac.type != ixgbe_mac_X550EM_x && hw->mac.type != ixgbe_mac_X550EM_a && hw->mac.type != ixgbe_mac_E610) { -memset (l2_tn_filter,0 ,sizeof (struct ixgbe_l2_tunnel_conf ));rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM ,NULL ,"Not supported by L2 tunnel filter" );return -rte_errno; } - vf_num = ad->max_vfs; +/* validate attributes */ + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; -if (l2_tn_filter->pool > vf_num) -return -rte_errno; +/* parse requested actions */ + ret =ci_flow_check_actions (actions, &ap_param, &parsed_actions, error); +if (ret) +return ret; + +/* only one action is supported */ +if (parsed_actions.count >1 ) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + parsed_actions.actions[1 ], +"Only one action can be specified at a time" ); + } + action = parsed_actions.actions[0 ]; + + ret =cons_parse_l2_tn_filter (dev, pattern, action, l2_tn_filter, error);return ret; }
Signature · 1 line
2.47.3
PATCH v7 8/27 net/ixgbe: use common checks in ntuple filter
In reply to Anatoly BurakovUse the common attr and action parsing infrastructure in ntuple filter. As a result, some checks have become more stringent, in particular the group attribute is now explicitly rejected instead of being ignored.
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 133 ++++++++------------------- 1 file changed, 36 insertions(+), 97 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +36 -97
@@ -210,12 +210,11 @@ ixgbe_flow_actions_check(const struct ci_flow_actions *actions,static int cons_parse_ntuple_filter (const struct rte_flow_attr *attr,const struct rte_flow_item pattern[], -const struct rte_flow_action actions[], +const struct rte_flow_action_queue *q_act,struct rte_eth_ntuple_filter *filter,struct rte_flow_error *error) {const struct rte_flow_item *item; -const struct rte_flow_action *act;const struct rte_flow_item_ipv4 *ipv4_spec;const struct rte_flow_item_ipv4 *ipv4_mask;const struct rte_flow_item_tcp *tcp_spec;
@@ -231,24 +230,11 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,struct rte_flow_item_eth eth_null;struct rte_flow_item_vlan vlan_null; -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; +/* Priority must be 16-bit */ +if (attr->priority >UINT16_MAX ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , attr, +"Priority must be 16-bit" ); }memset (ð_null,0 ,sizeof (struct rte_flow_item_eth ));
@@ -535,70 +521,11 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, action: -/** -* n-tuple only supports forwarding, -* 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_ntuple_filter )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - item,"Not supported action." ); -return -rte_errno; - } - filter->queue = - ((const struct rte_flow_action_queue *)act->conf)->index; + filter->queue = q_act->index; -/* 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_ntuple_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_ntuple_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_ntuple_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_ntuple_filter )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER , - attr,"No support for transfer." ); -return -rte_errno; - } - -if (attr->priority >0xFFFF ) { -memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , - attr,"Error priority." ); -return -rte_errno; - } filter->priority = (uint16_t )attr->priority; -if (attr->priority <IXGBE_MIN_N_TUPLE_PRIO || - attr->priority >IXGBE_MAX_N_TUPLE_PRIO ) - filter->priority =1 ; +if (attr->priority <IXGBE_MIN_N_TUPLE_PRIO || attr->priority >IXGBE_MAX_N_TUPLE_PRIO ) + filter->priority =1 ;return 0 ; }
@@ -718,15 +645,40 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,struct rte_eth_ntuple_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_attr_check_param attr_param = { + .allow_priority = true, + }; +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->data, + .check = ixgbe_flow_actions_check, + .max_actions =1 , + }; +const struct rte_flow_action *action; +int ret;if (hw->mac.type != ixgbe_mac_82599EB && hw->mac.type != ixgbe_mac_X540)return -ENOTSUP ; - ret =cons_parse_ntuple_filter (attr, pattern, actions, filter, error); +/* 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; + action = parsed_actions.actions[0 ]; + + ret =cons_parse_ntuple_filter (attr, pattern, action->conf, filter, error);if (ret)return ret;
@@ -739,19 +691,6 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,return -rte_errno; } -/* Ixgbe doesn't support many priorities. */ -if (filter->priority <IXGBE_MIN_N_TUPLE_PRIO || - filter->priority >IXGBE_MAX_N_TUPLE_PRIO ) { -memset (filter,0 ,sizeof (struct rte_eth_ntuple_filter )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , -NULL ,"Priority not supported by ntuple filter" ); -return -rte_errno; - } - -if (filter->queue >= dev->data->nb_rx_queues) -return -rte_errno; -/* fixed value for ixgbe */ filter->flags =RTE_5TUPLE_FLAGS ;return 0 ;
Signature · 1 line
2.47.3
PATCH v7 9/27 net/ixgbe: use common checks in security filter
In reply to Anatoly BurakovUse the common attr and action parsing infrastructure in security filter. As a result, some checks have become more stringent. In particular, group attribute is now explicitly rejected instead of being ignored.
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 62 ++++++++++------------------ 1 file changed, 22 insertions(+), 40 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +22 -40
@@ -539,7 +539,16 @@ ixgbe_parse_security_filter(struct rte_eth_dev *dev, const struct rte_flow_attrconst struct rte_flow_action_security *security;struct rte_security_session *session;const struct rte_flow_item *item; -const struct rte_flow_action *act; +struct ci_flow_actions parsed_actions; +struct ci_flow_actions_check_param ap_param = { + .allowed_types = (const enum rte_flow_action_type []){ +/* only security is allowed here */ +RTE_FLOW_ACTION_TYPE_SECURITY , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =1 , + }; +const struct rte_flow_action *action;struct ip_spec spec;int ret;
@@ -551,45 +560,18 @@ ixgbe_parse_security_filter(struct rte_eth_dev *dev, const struct rte_flow_attr hw->mac.type != ixgbe_mac_E610)return -ENOTSUP ; -if (pattern ==NULL ) { -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM_NUM , -NULL ,"NULL pattern." ); -return -rte_errno; - } -if (actions ==NULL ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION_NUM , -NULL ,"NULL action." ); -return -rte_errno; - } -if (attr ==NULL ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR , -NULL ,"NULL attribute." ); -return -rte_errno; - } +/* validate attributes */ + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; -/* check if next non-void action is security */ - act =next_no_void_action (actions,NULL ); -if (act->type !=RTE_FLOW_ACTION_TYPE_SECURITY ) { -return rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); - } - security = act->conf; -if (security ==NULL ) { -return rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"NULL security action config." ); - } -/* check if the next not void item is END */ - act =next_no_void_action (actions, act); -if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -return rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); - } +/* parse requested actions */ + ret =ci_flow_check_actions (actions, &ap_param, &parsed_actions, error); +if (ret) +return ret; + + action = parsed_actions.actions[0 ]; + security = action->conf;/* get the IP pattern*/ item =next_no_void_pattern (pattern,NULL );
@@ -629,7 +611,7 @@ ixgbe_parse_security_filter(struct rte_eth_dev *dev, const struct rte_flow_attr ret =ixgbe_crypto_add_ingress_sa_from_flow (session, &spec);if (ret) {rte_flow_error_set (error, -ret, -RTE_FLOW_ERROR_TYPE_ACTION , act, +RTE_FLOW_ERROR_TYPE_ACTION , action,"Failed to add security session." );return -rte_errno; }
Signature · 1 line
2.47.3
PATCH v7 10/27 net/ixgbe: use common checks in FDIR filters
In reply to Anatoly BurakovUse the common attr and action parsing infrastructure in flow director filters (both tunnel and normal). As a result, some checks have become more stringent, in particular group attribute is now explicitly rejected instead of being ignored.
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 319 ++++++++++++--------------- 1 file changed, 138 insertions(+), 181 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +138 -181
@@ -1195,111 +1195,6 @@ ixgbe_parse_l2_tn_filter(struct rte_eth_dev *dev,return ret; } -/* Parse to get the attr and action info of flow director rule. */ -static int -ixgbe_parse_fdir_act_attr (const struct rte_flow_attr *attr, -const struct rte_flow_action actions[], -struct ixgbe_fdir_rule *rule, -struct rte_flow_error *error) -{ -const struct rte_flow_action *act; -const struct rte_flow_action_queue *act_q; -const struct rte_flow_action_mark *mark; - -/* parse attr */ -/* must be input direction */ -if (!attr->ingress) { -memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -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 (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -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 (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER , - attr,"No support for transfer." ); -return -rte_errno; - } - -/* not supported */ -if (attr->priority) { -memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , - attr,"Not support priority." ); -return -rte_errno; - } - -/* check if the first not void action is QUEUE or DROP. */ - act =next_no_void_action (actions,NULL ); -if (act->type !=RTE_FLOW_ACTION_TYPE_QUEUE && - act->type !=RTE_FLOW_ACTION_TYPE_DROP ) { -memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - -if (act->type ==RTE_FLOW_ACTION_TYPE_QUEUE ) { - act_q = (const struct rte_flow_action_queue *)act->conf; - rule->queue = act_q->index; - }else {/* drop */ -/* signature mode does not support drop action. */ -if (rule->mode ==RTE_FDIR_MODE_SIGNATURE ) { -memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - rule->fdirflags =IXGBE_FDIRCMD_DROP ; - } - -/* check if the next not void item is MARK */ - act =next_no_void_action (actions, act); -if ((act->type !=RTE_FLOW_ACTION_TYPE_MARK ) && - (act->type !=RTE_FLOW_ACTION_TYPE_END )) { -memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - - rule->soft_id =0 ; - -if (act->type ==RTE_FLOW_ACTION_TYPE_MARK ) { - mark = (const struct rte_flow_action_mark *)act->conf; - rule->soft_id = mark->id; - act =next_no_void_action (actions, act); - } - -/* check if the next not void item is END */ -if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - -return 0 ; -} -/* search next no void pattern and skip fuzzy */ static inline const struct rte_flow_item *next_no_fuzzy_pattern(
@@ -1406,9 +1301,8 @@ static inline uint8_t signature_match(const struct rte_flow_item pattern[])*/ static int ixgbe_parse_fdir_filter_normal (struct rte_eth_dev *dev, -const struct rte_flow_attr *attr,const struct rte_flow_item pattern[], -const struct rte_flow_action actions[], +const struct ci_flow_actions *parsed_actions,struct ixgbe_fdir_rule *rule,struct rte_flow_error *error) {
@@ -1429,30 +1323,13 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev,const struct rte_flow_item_vlan *vlan_mask;const struct rte_flow_item_raw *raw_mask;const struct rte_flow_item_raw *raw_spec; +const struct rte_flow_action *fwd_action, *aux_action; +struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private);uint8_t j; -struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); - -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; - } + fwd_action = parsed_actions->actions[0 ]; +/* can be NULL */ + aux_action = parsed_actions->actions[1 ];/** * Some fields may not be provided. Set spec to 0 and mask to default
@@ -1466,29 +1343,51 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev, rule->mask.dst_port_mask =0 ; rule->mask.src_port_mask =0 ; -/** -* The first not void item should be -* MAC or IPv4 or TCP or UDP or SCTP. -*/ - item =next_no_fuzzy_pattern (pattern,NULL ); -if (item->type !=RTE_FLOW_ITEM_TYPE_ETH && - item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && - item->type !=RTE_FLOW_ITEM_TYPE_IPV6 && - item->type !=RTE_FLOW_ITEM_TYPE_TCP && - item->type !=RTE_FLOW_ITEM_TYPE_UDP && - item->type !=RTE_FLOW_ITEM_TYPE_SCTP ) { -memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , - item,"Not supported by fdir filter" ); -return -rte_errno; - } - +/* check if this is a signature match */ if (signature_match (pattern)) rule->mode =RTE_FDIR_MODE_SIGNATURE ;else rule->mode =RTE_FDIR_MODE_PERFECT ; +/* set up action */ +if (fwd_action->type ==RTE_FLOW_ACTION_TYPE_QUEUE ) { +const struct rte_flow_action_queue *q_act = fwd_action->conf; + rule->queue = q_act->index; + }else { +/* signature mode does not support drop action. */ +if (rule->mode ==RTE_FDIR_MODE_SIGNATURE ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , fwd_action, +"Signature mode does not support drop action." ); +return -rte_errno; + } + rule->fdirflags =IXGBE_FDIRCMD_DROP ; + } + +/* set up mark action */ +if (aux_action !=NULL && aux_action->type ==RTE_FLOW_ACTION_TYPE_MARK ) { +const struct rte_flow_action_mark *m_act = aux_action->conf; + rule->soft_id = m_act->id; + } + +/** +* The first not void item should be +* MAC or IPv4 or TCP or UDP or SCTP. +*/ + item =next_no_fuzzy_pattern (pattern,NULL ); +if (item->type !=RTE_FLOW_ITEM_TYPE_ETH && + item->type !=RTE_FLOW_ITEM_TYPE_IPV4 && + item->type !=RTE_FLOW_ITEM_TYPE_IPV6 && + item->type !=RTE_FLOW_ITEM_TYPE_TCP && + item->type !=RTE_FLOW_ITEM_TYPE_UDP && + item->type !=RTE_FLOW_ITEM_TYPE_SCTP ) { +memset (rule,0 ,sizeof (struct ixgbe_fdir_rule )); +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item,"Not supported by fdir filter" ); +return -rte_errno; + } +/*Not supported last point for range*/ if (item->last) { rte_flow_error_set(error, EINVAL,
@@ -2083,7 +1982,7 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev, rule->mask.l4_proto_match = (rule->ixgbe_fdir.formatted.flow_type &IXGBE_ATR_L4TYPE_MASK ) !=0 ; -return ixgbe_parse_fdir_act_attr (attr, actions, rule, error); +return 0 ; }#define NVGRE_PROTOCOL 0x6558
@@ -2126,9 +2025,8 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev,* item->last should be NULL. */ static int -ixgbe_parse_fdir_filter_tunnel (const struct rte_flow_attr *attr, -const struct rte_flow_item pattern[], -const struct rte_flow_action actions[], +ixgbe_parse_fdir_filter_tunnel (const struct rte_flow_item pattern[], +const struct ci_flow_actions *parsed_actions,struct ixgbe_fdir_rule *rule,struct rte_flow_error *error) {
@@ -2141,28 +2039,12 @@ ixgbe_parse_fdir_filter_tunnel(const struct rte_flow_attr *attr,const struct rte_flow_item_eth *eth_mask;const struct rte_flow_item_vlan *vlan_spec;const struct rte_flow_item_vlan *vlan_mask; +const struct rte_flow_action *fwd_action, *aux_action;uint32_t j; -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; - } + fwd_action = parsed_actions->actions[0 ]; +/* can be NULL */ + aux_action = parsed_actions->actions[1 ];/** * Some fields may not be provided. Set spec to 0 and mask to default
@@ -2172,6 +2054,20 @@ ixgbe_parse_fdir_filter_tunnel(const struct rte_flow_attr *attr,memset (&rule->mask,0xFF ,sizeof (struct ixgbe_hw_fdir_mask )); rule->mask.vlan_tci_mask =0 ; +/* set up queue/drop action */ +if (fwd_action->type ==RTE_FLOW_ACTION_TYPE_QUEUE ) { +const struct rte_flow_action_queue *q_act = fwd_action->conf; + rule->queue = q_act->index; + }else { + rule->fdirflags =IXGBE_FDIRCMD_DROP ; + } + +/* set up mark action */ +if (aux_action !=NULL && aux_action->type ==RTE_FLOW_ACTION_TYPE_MARK ) { +const struct rte_flow_action_mark *mark = aux_action->conf; + rule->soft_id = mark->id; + } +/** * The first not void item should be * MAC or IPv4 or IPv6 or UDP or VxLAN.
@@ -2572,7 +2468,43 @@ ixgbe_parse_fdir_filter_tunnel(const struct rte_flow_attr *attr,* Do nothing. */ -return ixgbe_parse_fdir_act_attr (attr, actions, rule, error); +return 0 ; +} + +/* +* Check flow director actions +*/ +static int +ixgbe_fdir_actions_check (const struct ci_flow_actions *parsed_actions, + const struct ci_flow_actions_check_param *param __rte_unused, +struct rte_flow_error *error) +{ +const enum rte_flow_action_type fwd_actions[] = { +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_END + }; +const struct rte_flow_action *action; + +/* do the generic checks first */ +int ret =ixgbe_flow_actions_check (parsed_actions, param, error); +if (ret) +return ret; + +/* first action must be a forwarding action */ + action = parsed_actions->actions[0 ]; +if (!ci_flow_action_type_in_list (action->type, fwd_actions)) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"First action must be QUEUE or DROP" ); + } + +/* second action, if specified, must not be a forwarding action */ + action = parsed_actions->actions[1 ]; +if (action !=NULL &&ci_flow_action_type_in_list (action->type, fwd_actions)) { +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Conflicting actions" ); + } +return 0 ; } static int
@@ -2585,22 +2517,47 @@ ixgbe_parse_fdir_filter(struct rte_eth_dev *dev, {int ret;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_adapter *adapter =IXGBE_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); +struct rte_eth_fdir_conf *fdir_conf =IXGBE_DEV_PRIVATE_TO_FDIR_CONF (adapter); +struct ci_flow_actions parsed_actions; +struct ci_flow_actions_check_param ap_param = { + .allowed_types = (const enum rte_flow_action_type []){ +/* queue/mark/drop allowed here */ +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_MARK , +RTE_FLOW_ACTION_TYPE_END + }, + .driver_ctx = dev->data, + .check = ixgbe_fdir_actions_check + };if (hw->mac.type != ixgbe_mac_82599EB && - hw->mac.type != ixgbe_mac_X540 && - hw->mac.type != ixgbe_mac_X550 && - hw->mac.type != ixgbe_mac_X550EM_x && - hw->mac.type != ixgbe_mac_X550EM_a && - hw->mac.type != ixgbe_mac_E610) + hw->mac.type != ixgbe_mac_X540 && + hw->mac.type != ixgbe_mac_X550 && + hw->mac.type != ixgbe_mac_X550EM_x && + hw->mac.type != ixgbe_mac_X550EM_a && + hw->mac.type != ixgbe_mac_E610)return -ENOTSUP ; - ret =ixgbe_parse_fdir_filter_normal (dev, attr, pattern, - actions, rule, error); +/* validate attributes */ + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; + +/* parse requested actions */ + ret =ci_flow_check_actions (actions, &ap_param, &parsed_actions, error); +if (ret) +return ret; + + fdir_conf->drop_queue =IXGBE_FDIR_DROP_QUEUE ; + + ret =ixgbe_parse_fdir_filter_normal (dev, pattern, &parsed_actions, rule, error);if (!ret)return 0 ; -return ixgbe_parse_fdir_filter_tunnel (attr, pattern, - actions, rule, error); +return ixgbe_parse_fdir_filter_tunnel (pattern, &parsed_actions, + rule, error); } static int
Signature · 1 line
2.47.3
PATCH v7 11/27 net/ixgbe: use common checks in RSS filter
In reply to Anatoly BurakovUse the common attr and action parsing infrastructure in RSS filter. As a result, some checks have become more stringent, in particular:
- the group attribute is now explicitly rejected instead of being ignored
- the priority attribute was previously allowed but rejected values bigger than 0xFFFF despite not using priority anywhere - it is now rejected
--- drivers/net/intel/ixgbe/ixgbe_flow.c | 196 +++++++++++---------------- 1 file changed, 79 insertions(+), 117 deletions(-)
drivers/net/intel/ixgbe/ixgbe_flow.c +79 -117
@@ -112,20 +112,6 @@ const struct rte_flow_item *next_no_void_pattern( } } -static inline -const struct rte_flow_action *next_no_void_action ( -const struct rte_flow_action actions[], -const struct rte_flow_action *cur) -{ -const struct rte_flow_action *next = - cur ? cur +1 : &actions[0 ]; -while (1 ) { -if (next->type !=RTE_FLOW_ACTION_TYPE_VOID ) -return next; - next++; - } -} -/* * All ixgbe engines mostly check the same stuff, so use a common check. */
@@ -2680,6 +2666,56 @@ ixgbe_fdir_flow_program(struct rte_eth_dev *dev,return 0 ; } +/* Flow actions check specific to RSS filter */ +static int +ixgbe_flow_actions_check_rss (const struct ci_flow_actions *parsed_actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +const struct rte_flow_action *action = parsed_actions->actions[0 ]; +const struct rte_flow_action_rss *rss_act = action->conf; +struct rte_eth_dev_data *dev_data = param->driver_ctx; +const size_t rss_key_len =sizeof (((struct ixgbe_rte_flow_rss_conf *)0 )->key); +size_t q_idx, q; + +/* check if queue list is not empty */ +if (rss_act->queue_num ==0 ) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss_act, +"RSS queue list is empty" ); + } + +/* check if each RSS queue is valid */ +for (q_idx =0 ; q_idx < rss_act->queue_num; q_idx++) { + q = rss_act->queue[q_idx]; +if (q >= dev_data->nb_rx_queues) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss_act, +"Invalid RSS queue specified" ); + } + } + +/* only support default hash function */ +if (rss_act->func !=RTE_ETH_HASH_FUNCTION_DEFAULT ) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss_act, +"Non-default RSS hash functions are not supported" ); + } +/* levels aren't supported */ +if (rss_act->level) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss_act, +"A nonzero RSS encapsulation level is not supported" ); + } +/* check key length */ +if (rss_act->key_len !=0 && rss_act->key_len != rss_key_len) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss_act, +"RSS key must be exactly 40 bytes long" ); + } +return 0 ; +} + static int ixgbe_parse_rss_filter(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
@@ -2687,109 +2723,35 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev,struct ixgbe_rte_flow_rss_conf *rss_conf, struct rte_flow_error *error) { - const struct rte_flow_action *act; -const struct rte_flow_action_rss *rss; -uint16_t n; - -/** -* rss only supports forwarding, -* check if the first not void action is RSS. -*/ - act =next_no_void_action (actions,NULL ); -if (act->type !=RTE_FLOW_ACTION_TYPE_RSS ) { -memset (rss_conf,0 ,sizeof (struct ixgbe_rte_flow_rss_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } - - rss = (const struct rte_flow_action_rss *)act->conf; - -if (!rss || !rss->queue_num) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act, -"no valid queues" ); -return -rte_errno; - } - -for (n =0 ; n < rss->queue_num; n++) { -if (rss->queue[n] >= dev->data->nb_rx_queues) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act, -"queue id > max number of queues" ); -return -rte_errno; - } - } - -if (rss->func !=RTE_ETH_HASH_FUNCTION_DEFAULT ) -return rte_flow_error_set - (error,ENOTSUP ,RTE_FLOW_ERROR_TYPE_ACTION , act, -"non-default RSS hash functions are not supported" ); -if (rss->level) -return rte_flow_error_set - (error,ENOTSUP ,RTE_FLOW_ERROR_TYPE_ACTION , act, -"a nonzero RSS encapsulation level is not supported" ); -if (rss->key_len && rss->key_len !=RTE_DIM (rss_conf->key)) -return rte_flow_error_set - (error,ENOTSUP ,RTE_FLOW_ERROR_TYPE_ACTION , act, -"RSS hash key must be exactly 40 bytes" ); -if (rss->queue_num >RTE_DIM (rss_conf->queue)) -return rte_flow_error_set - (error,ENOTSUP ,RTE_FLOW_ERROR_TYPE_ACTION , act, -"too many queues for RSS context" ); -if (ixgbe_rss_conf_init (rss_conf, rss)) -return rte_flow_error_set - (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , act, -"RSS context initialization failure" ); - -/* 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 (rss_conf,0 ,sizeof (struct ixgbe_rte_flow_rss_conf )); -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 (rss_conf,0 ,sizeof (struct ixgbe_rte_flow_rss_conf )); -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 (rss_conf,0 ,sizeof (struct ixgbe_rte_flow_rss_conf )); -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 (rss_conf,0 ,sizeof (struct ixgbe_rte_flow_rss_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER , - attr,"No support for transfer." ); -return -rte_errno; - } - -if (attr->priority >0xFFFF ) { -memset (rss_conf,0 ,sizeof (struct ixgbe_rte_flow_rss_conf )); -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , - attr,"Error priority." ); -return -rte_errno; - } + struct ci_flow_actions parsed_actions; +struct ci_flow_actions_check_param ap_param = { + .allowed_types = (const enum rte_flow_action_type []){ +/* only rss allowed here */ +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_END + }, + .driver_ctx = dev->data, + .check = ixgbe_flow_actions_check_rss, + .max_actions =1 , + }; +int ret; +const struct rte_flow_action *action; + +/* validate attributes */ + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; + +/* parse requested actions */ + ret =ci_flow_check_actions (actions, &ap_param, &parsed_actions, error); +if (ret) +return ret; + action = parsed_actions.actions[0 ]; + +if (ixgbe_rss_conf_init (rss_conf, action->conf)) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"RSS context initialization failure" );return 0 ; }
Signature · 1 line
2.47.3
PATCH v7 12/27 net/i40e: use common flow attribute checks
In reply to Anatoly BurakovThere is no need to call the same attribute checks in multiple places when there are no cases where we do otherwise. Therefore, remove all the attribute check calls from all filter call paths and instead check the attributes once at the very beginning of flow validation, and use common flow attribute checks instead of driver-local ones.
--- drivers/net/intel/i40e/i40e_ethdev.h | 1 - drivers/net/intel/i40e/i40e_flow.c | 121 +++------------------------ 2 files changed, 10 insertions(+), 112 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.h +0 -1
@@ -1315,7 +1315,6 @@ struct i40e_filter_ctx { }; typedef int (*parse_filter_t)(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_flow_error *error,
drivers/net/intel/i40e/i40e_flow.c +10 -111
302 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH v7 13/27 net/i40e: refactor RSS flow parameter checks
In reply to Anatoly BurakovCurrently, the hash parser parameter checks are somewhat confusing as they have multiple mutually exclusive code paths and requirements, and it's difficult to reason about them because RSS flow parsing is interspersed with validation checks.
To address that, refactor hash engine error checking to perform almost all validation at the beginning, with only happy paths being implemented in actual parsing functions.
Some parameter combinations that were previously ignored (and perhaps produced a warning) are now explicitly rejected:
- if no pattern is specified, RSS types are rejected
- for queue lists and regions, RSS key is rejected
--- drivers/net/intel/i40e/i40e_flow.c | 13 +- drivers/net/intel/i40e/i40e_hash.c | 438 ++++++++++++++++++----------- drivers/net/intel/i40e/i40e_hash.h | 2 +- 3 files changed, 275 insertions(+), 178 deletions(-)
drivers/net/intel/i40e/i40e_flow.c +6 -7
@@ -3816,6 +3816,7 @@ i40e_flow_check(struct rte_eth_dev *dev,if (ret) {return ret; } +/* action and pattern validation will happen in each respective engine */ if (!pattern) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
@@ -3830,13 +3831,11 @@ i40e_flow_check(struct rte_eth_dev *dev,return -rte_errno; } -/* Get the non-void item of action */ -while ((actions + i)->type ==RTE_FLOW_ACTION_TYPE_VOID ) - i++; - -if ((actions + i)->type ==RTE_FLOW_ACTION_TYPE_RSS ) { - filter_ctx->type =RTE_ETH_FILTER_HASH ; -return i40e_hash_parse (dev, pattern, actions + i, &filter_ctx->rss_conf, error); +/* try parsing as RSS */ + filter_ctx->type =RTE_ETH_FILTER_HASH ; + ret =i40e_hash_parse (dev, pattern, actions, &filter_ctx->rss_conf, error); +if (!ret) { +return ret; } i =0 ;
drivers/net/intel/i40e/i40e_hash.c +268 -170
527 lines not on this page · raw message
drivers/net/intel/i40e/i40e_hash.h +1 -1
@@ -13,7 +13,7 @@extern "C" {#endif -int i40e_hash_parse(const struct rte_eth_dev *dev, +int i40e_hash_parse(struct rte_eth_dev *dev, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], struct i40e_rte_flow_rss_conf *rss_conf,
Signature · 1 line
2.47.3
PATCH v7 14/27 net/i40e: use common action checks for ethertype
In reply to Anatoly BurakovUse the common flow action checking parsing infrastructure for checking flow actions for ethertype filter.
--- drivers/net/intel/i40e/i40e_flow.c | 56 +++++++++++++----------------- 1 file changed, 24 insertions(+), 32 deletions(-)
drivers/net/intel/i40e/i40e_flow.c +24 -32
@@ -1448,43 +1448,35 @@ i40e_flow_parse_ethertype_action(struct rte_eth_dev *dev,struct rte_flow_error *error, struct rte_eth_ethertype_filter *filter) { - struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); -const struct rte_flow_action *act; -const struct rte_flow_action_queue *act_q; -uint32_t index =0 ; + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param ac_param = { + .allowed_types = (enum rte_flow_action_type []) { +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_END , + }, + .max_actions =1 , + }; +const struct rte_flow_action *action; +int ret; -/* Check if the first non-void action is QUEUE or DROP. */ -NEXT_ITEM_OF_ACTION (act, actions, index); -if (act->type !=RTE_FLOW_ACTION_TYPE_QUEUE && - act->type !=RTE_FLOW_ACTION_TYPE_DROP ) { -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } + ret =ci_flow_check_actions (actions, &ac_param, &parsed_actions, error); +if (ret) +return ret; + action = parsed_actions.actions[0 ]; -if (act->type ==RTE_FLOW_ACTION_TYPE_QUEUE ) { - act_q = act->conf; +if (action->type ==RTE_FLOW_ACTION_TYPE_QUEUE ) { +const struct rte_flow_action_queue *act_q = action->conf; +/* check queue index */ +if (act_q->index >= dev->data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid queue index" ); + } filter->queue = act_q->index; -if (filter->queue >= pf->dev_data->nb_rx_queues) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Invalid queue ID for" -" ethertype_filter." ); -return -rte_errno; - } - }else { + }else if (action->type ==RTE_FLOW_ACTION_TYPE_DROP ) { filter->flags |=RTE_ETHTYPE_FLAGS_DROP ; } - -/* Check if the next non-void item is END */ - index++; -NEXT_ITEM_OF_ACTION (act, actions, index); -if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } -return 0 ; }
Signature · 1 line
2.47.3
PATCH v7 15/27 net/i40e: use common action checks for FDIR
In reply to Anatoly BurakovUse the common flow action checking parsing infrastructure for checking flow actions for flow director filter.
--- drivers/net/intel/i40e/i40e_flow.c | 139 ++++++++++++++++------------- 1 file changed, 76 insertions(+), 63 deletions(-)
drivers/net/intel/i40e/i40e_flow.c +76 -63
@@ -2486,28 +2486,49 @@ i40e_flow_parse_fdir_action(struct rte_eth_dev *dev, struct i40e_fdir_filter_conf *filter) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); -const struct rte_flow_action *act; -const struct rte_flow_action_queue *act_q; -const struct rte_flow_action_mark *mark_spec =NULL ; -uint32_t index =0 ; +struct ci_flow_actions parsed_actions = {0 }; +struct ci_flow_actions_check_param ac_param = { + .allowed_types = (enum rte_flow_action_type []) { +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_PASSTHRU , +RTE_FLOW_ACTION_TYPE_MARK , +RTE_FLOW_ACTION_TYPE_FLAG , +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =2 , + }; +const struct rte_flow_action *first, *second; +int ret; -/* Check if the first non-void action is QUEUE or DROP or PASSTHRU. */ -NEXT_ITEM_OF_ACTION (act, actions, index); -switch (act->type) { + ret =ci_flow_check_actions (actions, &ac_param, &parsed_actions, error); +if (ret) +return ret; + first = parsed_actions.actions[0 ]; +/* can be NULL */ + second = parsed_actions.actions[1 ]; + +switch (first->type) {case RTE_FLOW_ACTION_TYPE_QUEUE : - act_q = act->conf; + { +const struct rte_flow_action_queue *act_q = first->conf; +/* check against PF constraints */ +if (!filter->input.flow_ext.is_vf && act_q->index >= pf->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , first, +"Invalid queue ID for FDIR" ); + } +/* check against VF constraints */ +if (filter->input.flow_ext.is_vf && act_q->index >= pf->vf_nb_qps) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , first, +"Invalid queue ID for FDIR" ); + } filter->action.rx_queue = act_q->index; -if ((!filter->input.flow_ext.is_vf && - filter->action.rx_queue >= pf->dev_data->nb_rx_queues) || - (filter->input.flow_ext.is_vf && - filter->action.rx_queue >= pf->vf_nb_qps)) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid queue ID for FDIR." ); -return -rte_errno; - } filter->action.behavior =I40E_FDIR_ACCEPT ;break ; + }case RTE_FLOW_ACTION_TYPE_DROP : filter->action.behavior =I40E_FDIR_REJECT ;break ;
@@ -2515,69 +2536,61 @@ i40e_flow_parse_fdir_action(struct rte_eth_dev *dev, filter->action.behavior =I40E_FDIR_PASSTHRU ;break ;case RTE_FLOW_ACTION_TYPE_MARK : + { +const struct rte_flow_action_mark *act_m = first->conf; filter->action.behavior =I40E_FDIR_PASSTHRU ; - mark_spec = act->conf; filter->action.report_status =I40E_FDIR_REPORT_ID ; - filter->soft_id = mark_spec->id; -break ; + filter->soft_id = act_m->id; +break ; + }default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid action." ); -return -rte_errno; +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , first, +"Invalid first action for FDIR" ); } -/* Check if the next non-void item is MARK or FLAG or END. */ - index++; -NEXT_ITEM_OF_ACTION (act, actions, index); -switch (act->type) { +/* do we have another? */ +if (second ==NULL ) +return 0 ; + +switch (second->type) {case RTE_FLOW_ACTION_TYPE_MARK : -if (mark_spec) { -/* Double MARK actions requested */ -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid action." ); -return -rte_errno; + { +const struct rte_flow_action_mark *act_m = second->conf; +/* only one mark action can be specified */ +if (first->type ==RTE_FLOW_ACTION_TYPE_MARK ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , second, +"Invalid second action for FDIR" ); } - mark_spec = act->conf; filter->action.report_status =I40E_FDIR_REPORT_ID ; - filter->soft_id = mark_spec->id; + filter->soft_id = act_m->id;break ; + }case RTE_FLOW_ACTION_TYPE_FLAG : -if (mark_spec) { -/* MARK + FLAG not supported */ -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid action." ); -return -rte_errno; + { +/* mark + flag is unsupported */ +if (first->type ==RTE_FLOW_ACTION_TYPE_MARK ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , second, +"Invalid second action for FDIR" ); } filter->action.report_status =I40E_FDIR_NO_REPORT_STATUS ;break ; + }case RTE_FLOW_ACTION_TYPE_RSS : -if (filter->action.behavior !=I40E_FDIR_PASSTHRU ) { -/* RSS filter won't be next if FDIR did not pass thru */ -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid action." ); -return -rte_errno; +/* RSS filter only can be after passthru or mark */ +if (first->type !=RTE_FLOW_ACTION_TYPE_PASSTHRU && + first->type !=RTE_FLOW_ACTION_TYPE_MARK ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , second, +"Invalid second action for FDIR" ); }break ; -case RTE_FLOW_ACTION_TYPE_END : -return 0 ;default : -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - act,"Invalid action." ); -return -rte_errno; - } - -/* Check if the next non-void item is END */ - index++; -NEXT_ITEM_OF_ACTION (act, actions, index); -if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Invalid action." ); -return -rte_errno; +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , second, +"Invalid second action for FDIR" ); }return 0 ;
Signature · 1 line
2.47.3
PATCH v7 16/27 net/i40e: use common action checks for tunnel
In reply to Anatoly BurakovUse the common flow action checking parsing infrastructure for checking flow actions for flow director tunnel filter. As a result, more stringent checks are performed against parametersm specifically the following:
- reject NULL conf for VF action (instead of attempt at NULL dereference)
- second action was expected to be QUEUE but if it wasn't it was ignored
--- drivers/net/intel/i40e/i40e_flow.c | 104 +++++++++++++---------------- 1 file changed, 48 insertions(+), 56 deletions(-)
drivers/net/intel/i40e/i40e_flow.c +48 -56
@@ -1107,15 +1107,6 @@ static struct i40e_valid_pattern i40e_supported_patterns[] = { { pattern_fdir_ipv6_sctp, i40e_flow_parse_l4_cloud_filter }, }; -#define NEXT_ITEM_OF_ACTION (act, actions, index) \ - do { \ - act = actions + index; \ - while (act->type == RTE_FLOW_ACTION_TYPE_VOID) { \ - index++; \ - act = actions + index; \ - } \ - } while (0) -/* Find the first VOID or non-VOID item pointer */ static const struct rte_flow_item *i40e_find_first_item (const struct rte_flow_item *item,bool is_void)
@@ -2629,61 +2620,62 @@ i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev, struct i40e_tunnel_filter_conf *filter) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); -const struct rte_flow_action *act;const struct rte_flow_action_queue *act_q; -const struct rte_flow_action_vf *act_vf; -uint32_t index =0 ; +struct ci_flow_actions parsed_actions = {0 }; +struct ci_flow_actions_check_param ac_param = { + .allowed_types = (enum rte_flow_action_type []) { +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_PF , +RTE_FLOW_ACTION_TYPE_VF , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =2 , + }; +const struct rte_flow_action *first, *second; +int ret; -/* Check if the first non-void action is PF or VF. */ -NEXT_ITEM_OF_ACTION (act, actions, index); -if (act->type !=RTE_FLOW_ACTION_TYPE_PF && - act->type !=RTE_FLOW_ACTION_TYPE_VF ) { -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; - } + ret =ci_flow_check_actions (actions, &ac_param, &parsed_actions, error); +if (ret) +return ret; + first = parsed_actions.actions[0 ]; +/* can be NULL */ + second = parsed_actions.actions[1 ]; -if (act->type ==RTE_FLOW_ACTION_TYPE_VF ) { - act_vf = act->conf; - filter->vf_id = act_vf->id; +/* first action must be PF or VF */ +if (first->type ==RTE_FLOW_ACTION_TYPE_VF ) { +const struct rte_flow_action_vf *vf = first->conf; +if (vf->id >= pf->vf_num) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , first, +"Invalid VF ID for tunnel filter" ); +return -rte_errno; + } + filter->vf_id = vf->id; filter->is_to_vf =1 ; -if (filter->vf_id >= pf->vf_num) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Invalid VF ID for tunnel filter" ); -return -rte_errno; - } + }else if (first->type !=RTE_FLOW_ACTION_TYPE_PF ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , first, +"Unsupported action" ); } -/* Check if the next non-void item is QUEUE */ - index++; -NEXT_ITEM_OF_ACTION (act, actions, index); -if (act->type ==RTE_FLOW_ACTION_TYPE_QUEUE ) { - act_q = act->conf; - filter->queue_id = act_q->index; -if ((!filter->is_to_vf) && - (filter->queue_id >= pf->dev_data->nb_rx_queues)) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Invalid queue ID for tunnel filter" ); -return -rte_errno; - }else if (filter->is_to_vf && - (filter->queue_id >= pf->vf_nb_qps)) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - act,"Invalid queue ID for tunnel filter" ); -return -rte_errno; - } - } +/* check if second action is QUEUE */ +if (second ==NULL ) +return 0 ; -/* Check if the next non-void item is END */ - index++; -NEXT_ITEM_OF_ACTION (act, actions, index); -if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - act,"Not supported action." ); -return -rte_errno; + act_q = second->conf; +/* check queue ID for PF flow */ +if (!filter->is_to_vf && act_q->index >= pf->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , act_q, +"Invalid queue ID for tunnel filter" ); + } +/* check queue ID for VF flow */ +if (filter->is_to_vf && act_q->index >= pf->vf_nb_qps) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , act_q, +"Invalid queue ID for tunnel filter" ); } + filter->queue_id = act_q->index;return 0 ; }
Signature · 1 line
2.47.3
PATCH v7 17/27 net/iavf: use common flow attribute checks
In reply to Anatoly BurakovReplace custom attr checks with a call to common checks. Flow subscription engine supports priority but other engines don't, so we move the attribute checks into the engines.
--- drivers/net/intel/iavf/iavf_fdir.c | 8 ++- drivers/net/intel/iavf/iavf_fsub.c | 20 ++++++- drivers/net/intel/iavf/iavf_generic_flow.c | 67 +++------------------- drivers/net/intel/iavf/iavf_generic_flow.h | 2 +- drivers/net/intel/iavf/iavf_hash.c | 10 ++-- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 8 ++- 6 files changed, 43 insertions(+), 72 deletions(-)
drivers/net/intel/iavf/iavf_fdir.c +5 -3
@@ -17,6 +17,7 @@#include "iavf.h" #include "iavf_generic_flow.h" +#include "../common/flow_check.h" #include "virtchnl.h" #include "iavf_rxtx.h"
@@ -1594,7 +1595,7 @@ iavf_fdir_parse(struct iavf_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error) {
@@ -1605,8 +1606,9 @@ iavf_fdir_parse(struct iavf_adapter *ad,memset (filter,0 ,sizeof (*filter)); -if (priority >=1 ) -return -rte_errno; + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; item =iavf_search_pattern_match_item (pattern, array, array_len, error);if (!item)
drivers/net/intel/iavf/iavf_fsub.c +18 -2
@@ -20,6 +20,7 @@#include <rte_flow.h> #include <iavf.h> #include "iavf_generic_flow.h" +#include "../common/flow_check.h" #define MAX_QGRP_NUM_TYPE 7#define IAVF_IPV6_ADDR_LENGTH 16
@@ -650,12 +651,15 @@ iavf_fsub_parse(struct iavf_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error) { struct iavf_fsub_conf *filter;struct iavf_pattern_match_item *pattern_match_item =NULL ; +struct ci_flow_attr_check_param attr_param = { + .allow_priority = true, + };int ret =0 ; filter =rte_zmalloc (NULL ,sizeof (*filter),0 );
@@ -666,6 +670,18 @@ iavf_fsub_parse(struct iavf_adapter *ad,return -ENOMEM ; } + ret =ci_flow_check_attr (attr, &attr_param, error); +if (ret) + goto error; + +if (attr->priority >1 ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , + attr,"Only support priority 0 and 1." ); + ret = -rte_errno; + goto error; + } +/* search flow subscribe pattern */ pattern_match_item =iavf_search_pattern_match_item (pattern, array, array_len, error);
@@ -687,7 +703,7 @@ iavf_fsub_parse(struct iavf_adapter *ad, goto error;/* parse flow subscribe pattern action */ - ret =iavf_fsub_parse_action ((void *)ad, actions, priority, + ret =iavf_fsub_parse_action ((void *)ad, actions, attr->priority, error, filter); error:
drivers/net/intel/iavf/iavf_generic_flow.c +8 -59
124 lines not on this page · raw message
drivers/net/intel/iavf/iavf_generic_flow.h +1 -1
@@ -471,7 +471,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error);
drivers/net/intel/iavf/iavf_hash.c +6 -4
@@ -22,6 +22,7 @@#include "iavf_log.h" #include "iavf.h" #include "iavf_generic_flow.h" +#include "../common/flow_check.h" #define IAVF_PHINT_NONE 0#define IAVF_PHINT_GTPU BIT_ULL(0)
@@ -86,7 +87,7 @@ iavf_hash_parse_pattern_action(struct iavf_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error);
@@ -1521,7 +1522,7 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error) {
@@ -1530,8 +1531,9 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,uint64_t phint =IAVF_PHINT_NONE ;int ret =0 ; -if (priority >=1 ) -return -rte_errno; + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; rss_meta_ptr =rte_zmalloc (NULL ,sizeof (*rss_meta_ptr),0 );if (!rss_meta_ptr) {
drivers/net/intel/iavf/iavf_ipsec_crypto.c +5 -3
@@ -14,6 +14,7 @@#include "iavf_rxtx.h" #include "iavf_log.h" #include "iavf_generic_flow.h" +#include "../common/flow_check.h" #include "iavf_ipsec_crypto.h" #include "iavf_ipsec_crypto_capabilities.h"
@@ -1953,15 +1954,16 @@ iavf_ipsec_flow_parse(struct iavf_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error) { struct iavf_pattern_match_item *item = NULL;int ret =-1 ; -if (priority >=1 ) -return -rte_errno; + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; item =iavf_search_pattern_match_item (pattern, array, array_len, error);if (item && item->meta) {
Signature · 1 line
2.47.3
PATCH v7 18/27 net/iavf: use common action checks for IPsec
In reply to Anatoly BurakovUse the common flow action checking parsing infrastructure for checking flow actions for IPsec filter.
--- drivers/net/intel/iavf/iavf_ipsec_crypto.c | 35 ++++++++++------------ 1 file changed, 15 insertions(+), 20 deletions(-)
drivers/net/intel/iavf/iavf_ipsec_crypto.c +15 -20
@@ -1745,26 +1745,12 @@ parse_udp_item(const struct rte_flow_item_udp *item, struct rte_udp_hdr *udp) udp->src_port = item->hdr.src_port; } -static int -has_security_action (const struct rte_flow_action actions[], -const void **session) -{ -/* only {SECURITY; END} supported */ -if (actions[0 ].type ==RTE_FLOW_ACTION_TYPE_SECURITY && - actions[1 ].type ==RTE_FLOW_ACTION_TYPE_END ) { - *session = actions[0 ].conf; -return true; - } -return false; -} -static struct iavf_ipsec_flow_item *iavf_ipsec_flow_item_parse (struct rte_eth_dev *ethdev,const struct rte_flow_item pattern[], -const struct rte_flow_action actions[], +const struct rte_security_session *session,uint32_t type) { -const void *session;struct iavf_ipsec_flow_item *ipsec_flow =rte_malloc ("security-flow-rule" ,sizeof (struct iavf_ipsec_flow_item ),0 );
@@ -1831,9 +1817,6 @@ iavf_ipsec_flow_item_parse(struct rte_eth_dev *ethdev, goto flow_cleanup; } -if (!has_security_action (actions, &session)) - goto flow_cleanup; -if (!iavf_ipsec_crypto_action_valid (ethdev, session, ipsec_flow->spi)) goto flow_cleanup;
@@ -1958,6 +1941,14 @@ iavf_ipsec_flow_parse(struct iavf_adapter *ad,void **meta, struct rte_flow_error *error) { + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_SECURITY , +RTE_FLOW_ACTION_TYPE_END , + }, + .max_actions =1 , + };struct iavf_pattern_match_item *item =NULL ;int ret =-1 ;
@@ -1965,12 +1956,16 @@ iavf_ipsec_flow_parse(struct iavf_adapter *ad,if (ret)return ret; + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret <0 ) +return ret; + item =iavf_search_pattern_match_item (pattern, array, array_len, error);if (item && item->meta) { +const struct rte_security_session *session = parsed_actions.actions[0 ]->conf;uint32_t type = (uint64_t )(item->meta);struct iavf_ipsec_flow_item *fi = -iavf_ipsec_flow_item_parse (ad->vf.eth_dev, - pattern, actions, type); +iavf_ipsec_flow_item_parse (ad->vf.eth_dev, pattern, session, type);if (fi && meta) { *meta = fi; ret =0 ;
Signature · 1 line
2.47.3
PATCH v7 19/27 net/iavf: use common action checks for hash
In reply to Anatoly BurakovUse the common flow action checking parsing infrastructure for checking flow actions for hash filter.
--- drivers/net/intel/iavf/iavf_hash.c | 143 +++++++++++++++-------------- 1 file changed, 72 insertions(+), 71 deletions(-)
drivers/net/intel/iavf/iavf_hash.c +72 -71
@@ -1429,95 +1429,81 @@ iavf_any_invalid_rss_type(enum rte_eth_hash_function rss_func, }static int -iavf_hash_parse_action (struct iavf_pattern_match_item *match_item, -const struct rte_flow_action actions[], -uint64_t pattern_hint,struct iavf_rss_meta *rss_meta, -struct rte_flow_error *error) +iavf_hash_parse_rss_type (struct iavf_pattern_match_item *match_item, +const struct rte_flow_action_rss *rss, +uint64_t pattern_hint,struct iavf_rss_meta *rss_meta, +struct rte_flow_error *error) { -enum rte_flow_action_type action_type; -const struct rte_flow_action_rss *rss; -const struct rte_flow_action *action;uint64_t rss_type; -/* Supported action is RSS. */ -for (action = actions; action->type != -RTE_FLOW_ACTION_TYPE_END ; action++) { - action_type = action->type; -switch (action_type) { -case RTE_FLOW_ACTION_TYPE_RSS : - rss = action->conf; - rss_type = rss->types; + rss_meta->rss_algorithm = rss->func ==RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ ? +VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC : +VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC ; -if (rss->func == -RTE_ETH_HASH_FUNCTION_SIMPLE_XOR ){ - rss_meta->rss_algorithm = -VIRTCHNL_RSS_ALG_XOR_ASYMMETRIC ; -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"function simple_xor is not supported" ); - }else if (rss->func == -RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ ) { - rss_meta->rss_algorithm = -VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC ; - }else { - rss_meta->rss_algorithm = -VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC ; - } +/* If pattern type is raw, no need to refine rss type */ +if (pattern_hint ==IAVF_PHINT_RAW ) +return 0 ; -if (rss->level) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"a nonzero RSS encapsulation level is not supported" ); +/** +* Check simultaneous use of SRC_ONLY and DST_ONLY +* of the same level. +*/ + rss_type =rte_eth_rss_hf_refine (rss->types); -if (rss->key_len) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"a nonzero RSS key_len is not supported" ); +if (iavf_any_invalid_rss_type (rss->func, rss_type, match_item->input_set_mask)) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"RSS type not supported" ); + } -if (rss->queue_num) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"a non-NULL RSS queue is not supported" ); +memcpy (&rss_meta->proto_hdrs, match_item->meta,sizeof (struct virtchnl_proto_hdrs )); -/* If pattern type is raw, no need to refine rss type */ -if (pattern_hint ==IAVF_PHINT_RAW ) -break ; +iavf_refine_proto_hdrs (&rss_meta->proto_hdrs, rss_type, pattern_hint); -/** -* Check simultaneous use of SRC_ONLY and DST_ONLY -* of the same level. -*/ - rss_type =rte_eth_rss_hf_refine (rss_type); +return 0 ; +} -if (iavf_any_invalid_rss_type (rss->func, rss_type, - match_item->input_set_mask)) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , - action,"RSS type not supported" ); +static int +iavf_hash_parse_action_check (const struct ci_flow_actions *actions, + const struct ci_flow_actions_check_param *param __rte_unused, +struct rte_flow_error *error) +{ +const struct rte_flow_action_rss *rss = actions->actions[0 ]->conf; -memcpy (&rss_meta->proto_hdrs, match_item->meta, -sizeof (struct virtchnl_proto_hdrs )); +/* filter out unsupported RSS functions */ +switch (rss->func) { +case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR : +case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT : +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"Selected RSS hash function not supported" ); +default : +break ; + } -iavf_refine_proto_hdrs (&rss_meta->proto_hdrs, - rss_type, pattern_hint); -break ; +if (rss->level !=0 ) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"Nonzero RSS encapsulation level is not supported" ); + } -case RTE_FLOW_ACTION_TYPE_END : -break ; +if (rss->key_len !=0 ) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"RSS key is not supported" ); + } -default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"Invalid action." ); -return -rte_errno; - } +if (rss->queue_num !=0 ) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"RSS queue region is not supported" ); }return 0 ; } static int -iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad, +iavf_hash_parse_pattern_action(struct iavf_adapter *ad, struct iavf_pattern_match_item *array, uint32_t array_len, const struct rte_flow_item pattern[],
@@ -1526,6 +1512,17 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,void **meta, struct rte_flow_error *error) { + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =1 , + .driver_ctx = ad, + .check = iavf_hash_parse_action_check, + }; +const struct rte_flow_action_rss *rss;struct iavf_pattern_match_item *pattern_match_item;struct iavf_rss_meta *rss_meta_ptr;uint64_t phint =IAVF_PHINT_NONE ;
@@ -1535,6 +1532,10 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,if (ret)return ret; + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret) +return ret; + rss_meta_ptr =rte_zmalloc (NULL ,sizeof (*rss_meta_ptr),0 );if (!rss_meta_ptr) { rte_flow_error_set(error, EINVAL,
@@ -1567,8 +1568,8 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad, } } - ret =iavf_hash_parse_action (pattern_match_item, actions, phint, - rss_meta_ptr, error); + rss = parsed_actions.actions[0 ]->conf; + ret =iavf_hash_parse_rss_type (pattern_match_item, rss, phint, rss_meta_ptr, error); error:if (!ret && meta)
Signature · 1 line
2.47.3
PATCH v7 20/27 net/iavf: use common action checks for FDIR
In reply to Anatoly BurakovUse the common flow action checking parsing infrastructure for checking flow actions for FDIR filter.
--- drivers/net/intel/iavf/iavf_fdir.c | 360 +++++++++++++---------------- 1 file changed, 158 insertions(+), 202 deletions(-)
drivers/net/intel/iavf/iavf_fdir.c +158 -202
@@ -443,204 +443,6 @@ static struct iavf_flow_engine iavf_fdir_engine = { .rule_size = sizeof(struct iavf_fdir_conf), }; -static int -iavf_fdir_parse_action_qregion (struct iavf_adapter *ad, -struct rte_flow_error *error, -const struct rte_flow_action *act, -struct virtchnl_filter_action *filter_action) -{ -struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (ad); -const struct rte_flow_action_rss *rss = act->conf; -uint32_t i; - -if (act->type !=RTE_FLOW_ACTION_TYPE_RSS ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid action." ); -return -rte_errno; - } - -if (rss->queue_num <=1 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Queue region size can't be 0 or 1." ); -return -rte_errno; - } - -/* check if queue index for queue region is continuous */ -for (i =0 ; i < rss->queue_num -1 ; i++) { -if (rss->queue[i +1 ] != rss->queue[i] +1 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Discontinuous queue region" ); -return -rte_errno; - } - } - -if (rss->queue[rss->queue_num -1 ] >= ad->dev_data->nb_rx_queues) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid queue region indexes." ); -return -rte_errno; - } - -if (!(rte_is_power_of_2 (rss->queue_num) && - rss->queue_num <=IAVF_FDIR_MAX_QREGION_SIZE )) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"The region size should be any of the following values:" -"1, 2, 4, 8, 16, 32, 64, 128 as long as the total number " -"of queues do not exceed the VSI allocation." ); -return -rte_errno; - } - -if (rss->queue_num > vf->max_rss_qregion) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"The region size cannot be large than the supported max RSS queue region" ); -return -rte_errno; - } - - filter_action->act_conf.queue.index = rss->queue[0 ]; - filter_action->act_conf.queue.region =rte_fls_u32 (rss->queue_num) -1 ; - -return 0 ; -} - -static int -iavf_fdir_parse_action (struct iavf_adapter *ad, -const struct rte_flow_action actions[], -struct rte_flow_error *error, -struct iavf_fdir_conf *filter) -{ -const struct rte_flow_action_queue *act_q; -const struct rte_flow_action_mark *mark_spec =NULL ; -uint32_t dest_num =0 ; -uint32_t mark_num =0 ; -int ret; - -int number =0 ; -struct virtchnl_filter_action *filter_action; - -for (; actions->type !=RTE_FLOW_ACTION_TYPE_END ; actions++) { -switch (actions->type) { -case RTE_FLOW_ACTION_TYPE_VOID : -break ; - -case RTE_FLOW_ACTION_TYPE_PASSTHRU : - dest_num++; - - filter_action = &filter->add_fltr.rule_cfg.action_set.actions[number]; - - filter_action->type =VIRTCHNL_ACTION_PASSTHRU ; - - filter->add_fltr.rule_cfg.action_set.count = ++number; -break ; - -case RTE_FLOW_ACTION_TYPE_DROP : - dest_num++; - - filter_action = &filter->add_fltr.rule_cfg.action_set.actions[number]; - - filter_action->type =VIRTCHNL_ACTION_DROP ; - - filter->add_fltr.rule_cfg.action_set.count = ++number; -break ; - -case RTE_FLOW_ACTION_TYPE_QUEUE : - dest_num++; - - act_q = actions->conf; - filter_action = &filter->add_fltr.rule_cfg.action_set.actions[number]; - - filter_action->type =VIRTCHNL_ACTION_QUEUE ; - filter_action->act_conf.queue.index = act_q->index; - -if (filter_action->act_conf.queue.index >= - ad->dev_data->nb_rx_queues) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - actions,"Invalid queue for FDIR." ); -return -rte_errno; - } - - filter->add_fltr.rule_cfg.action_set.count = ++number; -break ; - -case RTE_FLOW_ACTION_TYPE_RSS : - dest_num++; - - filter_action = &filter->add_fltr.rule_cfg.action_set.actions[number]; - - filter_action->type =VIRTCHNL_ACTION_Q_REGION ; - - ret =iavf_fdir_parse_action_qregion (ad, - error, actions, filter_action); -if (ret) -return ret; - - filter->add_fltr.rule_cfg.action_set.count = ++number; -break ; - -case RTE_FLOW_ACTION_TYPE_MARK : - mark_num++; - - filter->mark_flag =1 ; - mark_spec = actions->conf; - filter_action = &filter->add_fltr.rule_cfg.action_set.actions[number]; - - filter_action->type =VIRTCHNL_ACTION_MARK ; - filter_action->act_conf.mark_id = mark_spec->id; - - filter->add_fltr.rule_cfg.action_set.count = ++number; -break ; - -default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Invalid action." ); -return -rte_errno; - } - } - -if (number >VIRTCHNL_MAX_NUM_ACTIONS ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Action numbers exceed the maximum value" ); -return -rte_errno; - } - -if (dest_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Unsupported action combination" ); -return -rte_errno; - } - -if (mark_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Too many mark actions" ); -return -rte_errno; - } - -if (dest_num + mark_num ==0 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Empty action" ); -return -rte_errno; - } - -/* Mark only is equal to mark + passthru. */ -if (dest_num ==0 ) { - filter_action = &filter->add_fltr.rule_cfg.action_set.actions[number]; - filter_action->type =VIRTCHNL_ACTION_PASSTHRU ; - filter->add_fltr.rule_cfg.action_set.count = ++number; - } - -return 0 ; -} - static bool iavf_fdir_refine_input_set(const uint64_t input_set, const uint64_t input_set_mask,
@@ -1589,6 +1391,145 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,return 0 ; } +static int +iavf_fdir_action_check_qregion (struct iavf_adapter *ad, +const struct rte_flow_action_rss *rss, +struct rte_flow_error *error) +{ +struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (ad); + +if (rss->queue_num <=1 ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"Queue region size can't be 0 or 1." ); + } + +if (rss->queue[rss->queue_num -1 ] >= ad->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"Invalid queue region indexes." ); + } + +if (!(rte_is_power_of_2 (rss->queue_num) && + rss->queue_num <=IAVF_FDIR_MAX_QREGION_SIZE )) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"The region size should be any of the following values:" +"1, 2, 4, 8, 16, 32, 64, 128 as long as the total number " +"of queues do not exceed the VSI allocation." ); + } + +if (rss->queue_num > vf->max_rss_qregion) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"The region size cannot be large than the supported max RSS queue region" ); + } + +return 0 ; +} + +static int +iavf_fdir_parse_action_check (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +struct iavf_adapter *ad = param->driver_ctx; +struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (ad); +struct iavf_fdir_conf *filter = &vf->fdir.conf; +uint32_t dest_num =0 , mark_num =0 ; +size_t i, number =0 ; +bool has_drop = false; +int ret; + +for (i =0 ; i < actions->count; i++) { +const struct rte_flow_action *act = actions->actions[i]; +struct virtchnl_filter_action *filter_action = + &filter->add_fltr.rule_cfg.action_set.actions[number]; + +switch (act->type) { +case RTE_FLOW_ACTION_TYPE_PASSTHRU : + dest_num++; + + filter_action->type =VIRTCHNL_ACTION_PASSTHRU ; +break ; +case RTE_FLOW_ACTION_TYPE_DROP : + dest_num++; + has_drop = true; + + filter_action->type =VIRTCHNL_ACTION_DROP ; +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *act_q; + dest_num++; + + act_q = act->conf; + + filter_action->type =VIRTCHNL_ACTION_QUEUE ; + +if (act_q->index >= ad->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , actions, +"Invalid queue index." ); + } + filter_action->act_conf.queue.index = act_q->index; + +break ; + } +case RTE_FLOW_ACTION_TYPE_RSS : + { +const struct rte_flow_action_rss *rss = act->conf; + dest_num++; + + filter_action->type =VIRTCHNL_ACTION_Q_REGION ; + + ret =iavf_fdir_action_check_qregion (ad, rss, error); +if (ret) +return ret; + + filter_action->act_conf.queue.index = rss->queue[0 ]; + filter_action->act_conf.queue.region =rte_fls_u32 (rss->queue_num) -1 ; +break ; + } +case RTE_FLOW_ACTION_TYPE_MARK : + { +const struct rte_flow_action_mark *mark_spec; + mark_num++; + + filter->mark_flag =1 ; + mark_spec = act->conf; + + filter_action->type =VIRTCHNL_ACTION_MARK ; + filter_action->act_conf.mark_id = mark_spec->id; + +break ; + } +default : +/* cannot happen */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , actions, +"Invalid action." ); + } + filter->add_fltr.rule_cfg.action_set.count = ++number; + } + +if (dest_num >1 || mark_num >1 || (has_drop && mark_num >1 )) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , actions, +"Unsupported action combination" ); + } + +/* Mark only is equal to mark + passthru. */ +if (dest_num ==0 ) { +struct virtchnl_filter_action *filter_action = + &filter->add_fltr.rule_cfg.action_set.actions[number]; + filter_action->type =VIRTCHNL_ACTION_PASSTHRU ; + filter->add_fltr.rule_cfg.action_set.count = ++number; + } + +return 0 ; +} + static int iavf_fdir_parse(struct iavf_adapter *ad, struct iavf_pattern_match_item *array,
@@ -1599,6 +1540,21 @@ iavf_fdir_parse(struct iavf_adapter *ad,void **meta, struct rte_flow_error *error) { + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_PASSTHRU , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_MARK , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =2 , + .check = iavf_fdir_parse_action_check, + .driver_ctx = ad, + .rss_queues_contig = true, + };struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (ad);struct iavf_fdir_conf *filter = &vf->fdir.conf;struct iavf_pattern_match_item *item =NULL ;
@@ -1610,6 +1566,10 @@ iavf_fdir_parse(struct iavf_adapter *ad,if (ret)return ret; + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret) +return ret; + item =iavf_search_pattern_match_item (pattern, array, array_len, error);if (!item)return -rte_errno;
@@ -1619,10 +1579,6 @@ iavf_fdir_parse(struct iavf_adapter *ad,if (ret) goto error; - ret =iavf_fdir_parse_action (ad, actions, error, filter); -if (ret) - goto error; -if (meta) *meta = filter;
Signature · 1 line
2.47.3
PATCH v7 21/27 net/iavf: use common action checks for fsub
In reply to Anatoly BurakovUse the common flow action checking parsing infrastructure for checking flow actions for flow subscription filter.
Existing implementation had a couple issues that do not rise to the level of being bugs, but are still questionable design choices.
For one, DROP action is supported in actions check (single actions are allowed as long as it isn't RSS or QUEUE) but is later disallowed in action parse (because not having port representor action is treated as an error). This is fixed by removing DROP action support from the check stage.
For another, PORT_REPRESENTOR action was incrementing action counter but not writing anything into action array, which, given that action list is zero-initialized, meant that the default action (drop) was kept in the action list. However, because the actual PF treats drop as a no-op, nothing bad happened when a DROP action was added to the list of actions.
However, nothing bad also happens if we just didn't have an action to begin with, so we remedy these unorthodox semantics by accordingly treating PORT_REPRESENTOR action as a noop, and not adding anything to the action list.
As a final note, now that all filter parsing code paths use the common action check infrastructure, we can remove the NULL check for actions from the beginning of the parsing path, as this is now handled by each engine.
--- drivers/net/intel/iavf/iavf_fsub.c | 244 +++++++++------------ drivers/net/intel/iavf/iavf_generic_flow.c | 7 - 2 files changed, 101 insertions(+), 150 deletions(-)
drivers/net/intel/iavf/iavf_fsub.c +101 -143
@@ -465,89 +465,46 @@ iavf_fsub_parse_pattern(const struct rte_flow_item pattern[], }static int -iavf_fsub_parse_action (struct iavf_adapter *ad, -const struct rte_flow_action *actions, +iavf_fsub_parse_action (const struct ci_flow_actions *actions,uint32_t priority,struct rte_flow_error *error,struct iavf_fsub_conf *filter) { -const struct rte_flow_action *action; -const struct rte_flow_action_ethdev *act_ethdev; -const struct rte_flow_action_queue *act_q; -const struct rte_flow_action_rss *act_qgrop; -struct virtchnl_filter_action *filter_action; -uint16_t valid_qgrop_number[MAX_QGRP_NUM_TYPE ] = { -2 ,4 ,8 ,16 ,32 ,64 ,128 }; -uint16_t i, num =0 , dest_num =0 , vf_num =0 ; -uint16_t rule_port_id; +uint16_t num_actions =0 ; +size_t i; + +for (i =0 ; i < actions->count; i++) { +const struct rte_flow_action *action = actions->actions[i]; +struct virtchnl_filter_action *filter_action = + &filter->sub_fltr.actions.actions[num_actions]; -for (action = actions; action->type != -RTE_FLOW_ACTION_TYPE_END ; action++) {switch (action->type) { -case RTE_FLOW_ACTION_TYPE_VOID : -break ; -case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR : - vf_num++; - filter_action = &filter->sub_fltr.actions.actions[num]; - - act_ethdev = action->conf; - rule_port_id = ad->dev_data->port_id; -if (rule_port_id != act_ethdev->port_id) - goto error1; - - filter->sub_fltr.actions.count = ++num; -break ; +/* nothing to be done, but skip the action */ +continue ;case RTE_FLOW_ACTION_TYPE_QUEUE : - dest_num++; - filter_action = &filter->sub_fltr.actions.actions[num]; - - act_q = action->conf; -if (act_q->index >= ad->dev_data->nb_rx_queues) - goto error2; - + { +const struct rte_flow_action_queue *act_q = action->conf; filter_action->type =VIRTCHNL_ACTION_QUEUE ; filter_action->act_conf.queue.index = act_q->index; - filter->sub_fltr.actions.count = ++num;break ; + }case RTE_FLOW_ACTION_TYPE_RSS : - dest_num++; - filter_action = &filter->sub_fltr.actions.actions[num]; - - act_qgrop = action->conf; -if (act_qgrop->queue_num <=1 ) - goto error2; + { +const struct rte_flow_action_rss *act_qgrp = action->conf; filter_action->type =VIRTCHNL_ACTION_Q_REGION ; - filter_action->act_conf.queue.index = - act_qgrop->queue[0 ]; -for (i =0 ; i <MAX_QGRP_NUM_TYPE ; i++) { -if (act_qgrop->queue_num == - valid_qgrop_number[i]) -break ; - } - -if (i ==MAX_QGRP_NUM_TYPE ) - goto error2; - -if ((act_qgrop->queue[0 ] + act_qgrop->queue_num) > - ad->dev_data->nb_rx_queues) - goto error3; - -for (i =0 ; i < act_qgrop->queue_num -1 ; i++) -if (act_qgrop->queue[i +1 ] != - act_qgrop->queue[i] +1 ) - goto error4; - - filter_action->act_conf.queue.region = act_qgrop->queue_num; - filter->sub_fltr.actions.count = ++num; + filter_action->act_conf.queue.index = act_qgrp->queue[0 ]; + filter_action->act_conf.queue.region = act_qgrp->queue_num;break ; + }default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - actions,"Invalid action type" ); -return -rte_errno; +/* cannot happen */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid action type." ); } + filter->sub_fltr.actions.count = ++num_actions; }/* 0 denotes lowest priority of recipe and highest priority
@@ -555,91 +512,81 @@ iavf_fsub_parse_action(struct iavf_adapter *ad,*/ filter->sub_fltr.priority = priority; -if (num >VIRTCHNL_MAX_NUM_ACTIONS ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Action numbers exceed the maximum value" ); -return -rte_errno; - } - -if (vf_num ==0 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Invalid action, vf action must be added" ); -return -rte_errno; - } - -if (dest_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Unsupported action combination" ); -return -rte_errno; - } -return 0 ; - -error1: -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Invalid port id" ); -return -rte_errno; - -error2: -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Invalid action type or queue number" ); -return -rte_errno; - -error3: -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Invalid queue region indexes" ); -return -rte_errno; - -error4: -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Discontinuous queue region" ); -return -rte_errno; }static int -iavf_fsub_check_action (const struct rte_flow_action *actions, +iavf_fsub_action_check (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param,struct rte_flow_error *error) { -const struct rte_flow_action *action; -enum rte_flow_action_type action_type; -uint16_t actions_num =0 ; -bool vf_valid = false; -bool queue_valid = false; +const struct iavf_adapter *ad = param->driver_ctx; +bool vf = false; +size_t i; -for (action = actions; action->type != -RTE_FLOW_ACTION_TYPE_END ; action++) { - action_type = action->type; -switch (action_type) { +/* +* allowed action types: +* 1. PORT_REPRESENTOR only +* 2. PORT_REPRESENTOR + QUEUE/RSS +*/ + +for (i =0 ; i < actions->count; i++) { +const struct rte_flow_action *action = actions->actions[i]; +switch (action->type) {case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR : - vf_valid = true; - actions_num++; + { +const struct rte_flow_action_ethdev *act_ethdev = action->conf; + +if (act_ethdev->port_id != ad->dev_data->port_id) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , act_ethdev, +"Invalid port id" ); + } + vf = true;break ; + }case RTE_FLOW_ACTION_TYPE_RSS : + { +const struct rte_flow_action_rss *act_qgrp = action->conf; + +/* must be between 2 and 128 and be a power of 2 */ +if (act_qgrp->queue_num <2 || act_qgrp->queue_num >128 || + !rte_is_power_of_2 (act_qgrp->queue_num)) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , act_qgrp, +"Invalid number of queues in RSS queue group" ); + } +/* last queue must not exceed total number of queues */ +if (act_qgrp->queue[0 ] + act_qgrp->queue_num > ad->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , act_qgrp, +"Invalid queue index in RSS queue group" ); + } +break ; + }case RTE_FLOW_ACTION_TYPE_QUEUE : - queue_valid = true; - actions_num++; + { +const struct rte_flow_action_queue *act_q = action->conf; + +if (act_q->index >= ad->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , act_q, +"Invalid queue index" ); + }break ; -case RTE_FLOW_ACTION_TYPE_DROP : - actions_num++; -break ; -case RTE_FLOW_ACTION_TYPE_VOID : -continue ; + }default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - actions,"Invalid action type" ); -return -rte_errno; +/* shouldn't happen */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid action type" ); } } - -if (!((actions_num ==1 && !queue_valid) || - (actions_num ==2 && vf_valid && queue_valid))) { -rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions,"Invalid action number" ); -return -rte_errno; +/* QUEUE/RSS must be accompanied by PORT_REPRESENTOR */ +if (!vf) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , actions, +"Invalid action combination" ); }return 0 ;
@@ -655,6 +602,19 @@ iavf_fsub_parse(struct iavf_adapter *ad,void **meta, struct rte_flow_error *error) { + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR , +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =2 , + .check = iavf_fsub_action_check, + .driver_ctx = ad, + .rss_queues_contig = true, + };struct iavf_fsub_conf *filter;struct iavf_pattern_match_item *pattern_match_item =NULL ; struct ci_flow_attr_check_param attr_param = {
@@ -674,6 +634,10 @@ iavf_fsub_parse(struct iavf_adapter *ad,if (ret) goto error; + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret) + goto error; +if (attr->priority >1 ) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
@@ -697,14 +661,8 @@ iavf_fsub_parse(struct iavf_adapter *ad,if (ret) goto error; -/* check flow subscribe pattern action */ - ret =iavf_fsub_check_action (actions, error); -if (ret) - goto error; -/* parse flow subscribe pattern action */ - ret =iavf_fsub_parse_action ((void *)ad, actions, attr->priority, - error, filter); + ret =iavf_fsub_parse_action (&parsed_actions, attr->priority, error, filter); error:if (!ret && meta)
drivers/net/intel/iavf/iavf_generic_flow.c +0 -7
@@ -2159,13 +2159,6 @@ iavf_flow_process_filter(struct rte_eth_dev *dev,return -rte_errno; } -if (!actions) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION_NUM , -NULL ,"NULL action." ); -return -rte_errno; - } - *engine =iavf_parse_engine (ad, flow, &vf->rss_parser_list, attr, pattern, actions, error);if (*engine)
Signature · 1 line
2.47.3
PATCH v7 22/27 net/iavf: use common action checks for flow query
In reply to Anatoly BurakovUse the common flow parsing infrastructure to validate query actions.
--- drivers/net/intel/iavf/iavf_generic_flow.c | 33 +++++++++++----------- 1 file changed, 16 insertions(+), 17 deletions(-)
drivers/net/intel/iavf/iavf_generic_flow.c +16 -17
@@ -14,10 +14,11 @@#include <ethdev_driver.h> #include <rte_malloc.h> #include <rte_tailq.h> +#include <rte_hexdump.h> #include "iavf.h" #include "iavf_generic_flow.h" -#include <rte_hexdump.h> +#include "../common/flow_check.h" static struct iavf_engine_list engine_list =TAILQ_HEAD_INITIALIZER (engine_list);
@@ -2338,10 +2339,18 @@ iavf_flow_query(struct rte_eth_dev *dev,void *data, struct rte_flow_error *error) { - int ret = -EINVAL; + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []) { +RTE_FLOW_ACTION_TYPE_COUNT , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =1 + };struct iavf_adapter *ad =IAVF_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private);struct rte_flow_query_count *count = data; +int ret;if (!iavf_flow_is_valid (flow) || !flow->engine->query_count) { rte_flow_error_set(error, EINVAL,
@@ -2350,21 +2359,11 @@ iavf_flow_query(struct rte_eth_dev *dev,return -rte_errno; } -for (; actions->type !=RTE_FLOW_ACTION_TYPE_END ; actions++) { -switch (actions->type) { -case RTE_FLOW_ACTION_TYPE_VOID : -break ; -case RTE_FLOW_ACTION_TYPE_COUNT : - ret = flow->engine->query_count (ad, flow, count, error); -break ; -default : -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"action not supported" ); - } - } -return ret; + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret <0 ) +return ret; + +return flow->engine->query_count (ad, flow, count, error); }#define IAVF_FLOW_DUMP_CHUNK_BYTES 32
Signature · 1 line
2.47.3
PATCH v7 23/27 net/ice: use common flow attribute checks
In reply to Anatoly BurakovFrom: Vladimir Medvedkin <[email protected]>
Replace custom attr checks with a call to common checks. Switch engine supports priority (0 or 1) but other engines don't, so we move the attribute checks into the engines.
--- drivers/net/intel/ice/ice_acl_filter.c | 9 ++-- drivers/net/intel/ice/ice_fdir_filter.c | 8 ++- drivers/net/intel/ice/ice_generic_flow.c | 59 +++-------------------- drivers/net/intel/ice/ice_generic_flow.h | 2 +- drivers/net/intel/ice/ice_hash.c | 11 +++-- drivers/net/intel/ice/ice_switch_filter.c | 22 +++++++-- 6 files changed, 48 insertions(+), 63 deletions(-)
drivers/net/intel/ice/ice_acl_filter.c +6 -3
@@ -27,6 +27,8 @@#include "ice_generic_flow.h" #include "base/ice_flow.h" +#include "../common/flow_check.h" +#define MAX_ACL_SLOTS_ID 2048#define ICE_ACL_INSET_ETH_IPV4 ( \
@@ -970,7 +972,7 @@ ice_acl_parse(struct ice_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error) {
@@ -980,8 +982,9 @@ ice_acl_parse(struct ice_adapter *ad,uint64_t input_set;int ret; -if (priority >=1 ) -return -rte_errno; + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret;memset (filter,0 ,sizeof (*filter)); item = ice_search_pattern_match_item(ad, pattern, array, array_len,
drivers/net/intel/ice/ice_fdir_filter.c +7 -1
@@ -15,6 +15,8 @@#include "ice_rxtx.h" #include "ice_generic_flow.h" +#include "../common/flow_check.h" +#define ICE_FDIR_IPV6_TC_OFFSET 20#define ICE_IPV6_TC_MASK (0xFF << ICE_FDIR_IPV6_TC_OFFSET)
@@ -2808,7 +2810,7 @@ ice_fdir_parse(struct ice_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority __rte_unused, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error) {
@@ -2819,6 +2821,10 @@ ice_fdir_parse(struct ice_adapter *ad,bool raw = false;int ret; + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; +memset (filter,0 ,sizeof (*filter)); item =ice_search_pattern_match_item (ad, pattern, array, array_len, error);
drivers/net/intel/ice/ice_generic_flow.c +8 -51
122 lines not on this page · raw message
drivers/net/intel/ice/ice_generic_flow.h +1 -1
@@ -525,7 +525,7 @@ typedef int (*parse_pattern_action_t)(struct ice_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error);
drivers/net/intel/ice/ice_hash.c +7 -4
@@ -26,6 +26,8 @@#include "ice_ethdev.h" #include "ice_generic_flow.h" +#include "../common/flow_check.h" +#define ICE_PHINT_NONE 0#define ICE_PHINT_VLAN BIT_ULL(0)#define ICE_PHINT_PPPOE BIT_ULL(1)
@@ -107,7 +109,7 @@ ice_hash_parse_pattern_action(struct ice_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error);
@@ -1187,7 +1189,7 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error) {
@@ -1196,8 +1198,9 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,struct ice_rss_meta *rss_meta_ptr;uint64_t phint =ICE_PHINT_NONE ; -if (priority >=1 ) -return -rte_errno; + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; rss_meta_ptr =rte_zmalloc (NULL ,sizeof (*rss_meta_ptr),0 );if (!rss_meta_ptr) {
drivers/net/intel/ice/ice_switch_filter.c +19 -3
@@ -26,6 +26,7 @@#include "ice_generic_flow.h" #include "ice_dcf_ethdev.h" +#include "../common/flow_check.h" #define MAX_QGRP_NUM_TYPE 7#define MAX_INPUT_SET_BYTE 32
@@ -1768,7 +1769,7 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,uint32_t array_len, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - uint32_t priority, + const struct rte_flow_attr *attr, void **meta, struct rte_flow_error *error) {
@@ -1784,6 +1785,21 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,enum ice_sw_tunnel_type tun_type =ICE_NON_TUN ;struct ice_pattern_match_item *pattern_match_item =NULL ; +struct ci_flow_attr_check_param attr_param = { + .allow_priority = true, + }; + + ret =ci_flow_check_attr (attr, &attr_param, error); +if (ret) +return ret; + +/* Allow only two priority values - 0 or 1 */ +if (attr->priority >1 ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY ,NULL , +"Invalid priority for switch filter" ); +return -rte_errno; + }for (; item->type !=RTE_FLOW_ITEM_TYPE_END ; item++) { item_num++;
@@ -1859,10 +1875,10 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad, goto error;if (ad->hw.dcf_enabled) - ret =ice_switch_parse_dcf_action ((void *)ad, actions, priority, + ret =ice_switch_parse_dcf_action ((void *)ad, actions, attr->priority, error, &rule_info);else - ret =ice_switch_parse_action (pf, actions, priority, error, + ret =ice_switch_parse_action (pf, actions, attr->priority, error, &rule_info);if (ret)
Signature · 1 line
2.47.3
PATCH v7 24/27 net/ice: use common action checks for hash
In reply to Anatoly BurakovFrom: Vladimir Medvedkin <[email protected]>
Use the common flow action checking parsing infrastructure for checking flow actions for hash filter.
--- drivers/net/intel/ice/ice_hash.c | 178 +++++++++++++++++-------------- 1 file changed, 95 insertions(+), 83 deletions(-)
drivers/net/intel/ice/ice_hash.c +95 -83
@@ -1092,94 +1092,92 @@ ice_any_invalid_rss_type(enum rte_eth_hash_function rss_func, }static int -ice_hash_parse_action (struct ice_pattern_match_item *pattern_match_item, -const struct rte_flow_action actions[], +ice_hash_parse_action_check (const struct ci_flow_actions *actions, + const struct ci_flow_actions_check_param *param __rte_unused, +struct rte_flow_error *error) +{ +const struct rte_flow_action_rss *rss; + + rss = actions->actions[0 ]->conf; + +switch (rss->func) { +case RTE_ETH_HASH_FUNCTION_DEFAULT : +case RTE_ETH_HASH_FUNCTION_TOEPLITZ : +case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR : +case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ : +break ; +default : +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"Selected RSS hash function not supported" ); + } + +if (rss->level) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"a nonzero RSS encapsulation level is not supported" ); + +if (rss->key_len) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"a nonzero RSS key_len is not supported" ); + +if (rss->queue) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"a non-NULL RSS queue is not supported" ); + +return 0 ; +} + +static int +ice_hash_parse_rss_action (struct ice_pattern_match_item *pattern_match_item, +const struct rte_flow_action_rss *rss,uint64_t pattern_hint,struct ice_rss_meta *rss_meta,struct rte_flow_error *error) {struct ice_rss_hash_cfg *cfg = pattern_match_item->meta; -enum rte_flow_action_type action_type; -const struct rte_flow_action_rss *rss; -const struct rte_flow_action *action;uint64_t rss_type; +bool symm = false; -/* Supported action is RSS. */ -for (action = actions; action->type != -RTE_FLOW_ACTION_TYPE_END ; action++) { - action_type = action->type; -switch (action_type) { -case RTE_FLOW_ACTION_TYPE_RSS : - rss = action->conf; - rss_type = rss->types; - -/* Check hash function and save it to rss_meta. */ -if (pattern_match_item->pattern_list != - pattern_empty && rss->func == -RTE_ETH_HASH_FUNCTION_SIMPLE_XOR ) { -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"Not supported flow" ); - }else if (rss->func == -RTE_ETH_HASH_FUNCTION_SIMPLE_XOR ){ - rss_meta->hash_function = -RTE_ETH_HASH_FUNCTION_SIMPLE_XOR ; -return 0 ; - }else if (rss->func == -RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ ) { - rss_meta->hash_function = -RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ ; -if (pattern_hint ==ICE_PHINT_RAW ) - rss_meta->raw.symm = true; -else - cfg->symm = true; - } - -if (rss->level) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"a nonzero RSS encapsulation level is not supported" ); - -if (rss->key_len) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"a nonzero RSS key_len is not supported" ); - -if (rss->queue) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"a non-NULL RSS queue is not supported" ); - -/* If pattern type is raw, no need to refine rss type */ -if (pattern_hint ==ICE_PHINT_RAW ) -break ; - -/** -* Check simultaneous use of SRC_ONLY and DST_ONLY -* of the same level. -*/ - rss_type =rte_eth_rss_hf_refine (rss_type); - -if (ice_any_invalid_rss_type (rss->func, rss_type, - pattern_match_item->input_set_mask_o)) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , - action,"RSS type not supported" ); - - rss_meta->cfg = *cfg; -ice_refine_hash_cfg (&rss_meta->cfg, - rss_type, pattern_hint); -break ; -case RTE_FLOW_ACTION_TYPE_END : -break ; - -default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , action, -"Invalid action." ); -return -rte_errno; +if (rss->func ==RTE_ETH_HASH_FUNCTION_SIMPLE_XOR ) { +if (pattern_match_item->pattern_list != pattern_empty) { +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"XOR hash function is only supported for empty pattern" ); } + rss_meta->hash_function =RTE_ETH_HASH_FUNCTION_SIMPLE_XOR ; +return 0 ; } +if (rss->func ==RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ ) { + rss_meta->hash_function =RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ ; + symm = true; + } + +/* If pattern type is raw, no need to refine rss type */ +if (pattern_hint ==ICE_PHINT_RAW ) { + rss_meta->raw.symm = symm; +return 0 ; + } + cfg->symm = symm; + +/** +* Check simultaneous use of SRC_ONLY and DST_ONLY +* of the same level. +*/ + rss_type =rte_eth_rss_hf_refine (rss->types); + +if (ice_any_invalid_rss_type (rss->func, rss_type, + pattern_match_item->input_set_mask_o)) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , + rss,"RSS type not supported" ); + + rss_meta->cfg = *cfg; +ice_refine_hash_cfg (&rss_meta->cfg, + rss_type, pattern_hint); +return 0 ; }
@@ -1193,15 +1191,29 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,void **meta, struct rte_flow_error *error) { - int ret = 0; + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =1 , + .check = ice_hash_parse_action_check, + }; +const struct rte_flow_action_rss *rss;struct ice_pattern_match_item *pattern_match_item;struct ice_rss_meta *rss_meta_ptr;uint64_t phint =ICE_PHINT_NONE ; +int ret =0 ; ret =ci_flow_check_attr (attr,NULL , error);if (ret)return ret; + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret) +return ret; + rss_meta_ptr =rte_zmalloc (NULL ,sizeof (*rss_meta_ptr),0 );if (!rss_meta_ptr) { rte_flow_error_set(error, EINVAL,
@@ -1233,9 +1245,9 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad, } } -/* Check rss action. */ - ret =ice_hash_parse_action (pattern_match_item, actions, phint, - rss_meta_ptr, error); + rss = parsed_actions.actions[0 ]->conf; + ret =ice_hash_parse_rss_action (pattern_match_item, rss, phint, + rss_meta_ptr, error); error:if (!ret && meta)
Signature · 1 line
2.47.3
PATCH v7 25/27 net/ice: use common action checks for FDIR
In reply to Anatoly BurakovFrom: Vladimir Medvedkin <[email protected]>
Use the common flow action checking parsing infrastructure for checking flow actions for FDIR filter.
--- drivers/net/intel/ice/ice_fdir_filter.c | 376 +++++++++++++----------- 1 file changed, 204 insertions(+), 172 deletions(-)
drivers/net/intel/ice/ice_fdir_filter.c +204 -172
@@ -1695,177 +1695,6 @@ static struct ice_flow_engine ice_fdir_engine = { .rule_size = sizeof(struct ice_fdir_filter_conf), }; -static int -ice_fdir_parse_action_qregion (struct ice_pf *pf, -struct rte_flow_error *error, -const struct rte_flow_action *act, -struct ice_fdir_filter_conf *filter) -{ -const struct rte_flow_action_rss *rss = act->conf; -uint32_t i; - -if (act->type !=RTE_FLOW_ACTION_TYPE_RSS ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid action." ); -return -rte_errno; - } - -if (rss->queue_num <=1 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Queue region size can't be 0 or 1." ); -return -rte_errno; - } - -/* check if queue index for queue region is continuous */ -for (i =0 ; i < rss->queue_num -1 ; i++) { -if (rss->queue[i +1 ] != rss->queue[i] +1 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Discontinuous queue region" ); -return -rte_errno; - } - } - -if (rss->queue[rss->queue_num -1 ] >= pf->dev_data->nb_rx_queues) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"Invalid queue region indexes." ); -return -rte_errno; - } - -if (!(rte_is_power_of_2 (rss->queue_num) && - (rss->queue_num <=ICE_FDIR_MAX_QREGION_SIZE ))) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , act, -"The region size should be any of the following values:" -"1, 2, 4, 8, 16, 32, 64, 128 as long as the total number " -"of queues do not exceed the VSI allocation." ); -return -rte_errno; - } - - filter->input.q_index = rss->queue[0 ]; - filter->input.q_region =rte_fls_u32 (rss->queue_num) -1 ; - filter->input.dest_ctl =ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QGROUP ; - -return 0 ; -} - -static int -ice_fdir_parse_action (struct ice_adapter *ad, -const struct rte_flow_action actions[], -struct rte_flow_error *error, -struct ice_fdir_filter_conf *filter) -{ -struct ice_pf *pf = &ad->pf; -const struct rte_flow_action_queue *act_q; -const struct rte_flow_action_mark *mark_spec =NULL ; -const struct rte_flow_action_count *act_count; -uint32_t dest_num =0 ; -uint32_t mark_num =0 ; -uint32_t counter_num =0 ; -int ret; - -for (; actions->type !=RTE_FLOW_ACTION_TYPE_END ; actions++) { -switch (actions->type) { -case RTE_FLOW_ACTION_TYPE_VOID : -break ; -case RTE_FLOW_ACTION_TYPE_QUEUE : - dest_num++; - - act_q = actions->conf; - filter->input.q_index = act_q->index; -if (filter->input.q_index >= - pf->dev_data->nb_rx_queues) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid queue for FDIR." ); -return -rte_errno; - } - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX ; -break ; -case RTE_FLOW_ACTION_TYPE_DROP : - dest_num++; - - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DROP_PKT ; -break ; -case RTE_FLOW_ACTION_TYPE_PASSTHRU : - dest_num++; - - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER ; -break ; -case RTE_FLOW_ACTION_TYPE_RSS : - dest_num++; - - ret =ice_fdir_parse_action_qregion (pf, - error, actions, filter); -if (ret) -return ret; -break ; -case RTE_FLOW_ACTION_TYPE_MARK : - mark_num++; - filter->mark_flag =1 ; - mark_spec = actions->conf; - filter->input.fltr_id = mark_spec->id; - filter->input.fdid_prio =ICE_FXD_FLTR_QW1_FDID_PRI_ONE ; -break ; -case RTE_FLOW_ACTION_TYPE_COUNT : - counter_num++; - - act_count = actions->conf; - filter->input.cnt_ena =ICE_FXD_FLTR_QW0_STAT_ENA_PKTS ; -memcpy (&filter->act_count, act_count, -sizeof (filter->act_count)); - -break ; -default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Invalid action." ); -return -rte_errno; - } - } - -if (dest_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Unsupported action combination" ); -return -rte_errno; - } - -if (mark_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Too many mark actions" ); -return -rte_errno; - } - -if (counter_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Too many count actions" ); -return -rte_errno; - } - -if (dest_num + mark_num + counter_num ==0 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Empty action" ); -return -rte_errno; - } - -/* set default action to PASSTHRU mode, in "mark/count only" case. */ -if (dest_num ==0 ) - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER ; - -return 0 ; -} static int ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
@@ -2804,6 +2633,188 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,return 0 ; } +static int +ice_fdir_parse_action (struct ice_adapter *ad, +const struct ci_flow_actions *actions, +struct rte_flow_error *error) +{ +struct ice_pf *pf = &ad->pf; +struct ice_fdir_filter_conf *filter = &pf->fdir.conf; +bool dest_set = false; +size_t i; + +for (i =0 ; i < actions->count; i++) { +const struct rte_flow_action *act = actions->actions[i]; + +switch (act->type) { +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *act_q = act->conf; + dest_set = true; + + filter->input.q_index = act_q->index; + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX ; +break ; + } +case RTE_FLOW_ACTION_TYPE_DROP : + dest_set = true; + + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DROP_PKT ; +break ; +case RTE_FLOW_ACTION_TYPE_PASSTHRU : + dest_set = true; + + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER ; +break ; +case RTE_FLOW_ACTION_TYPE_RSS : + { +const struct rte_flow_action_rss *rss = act->conf; + dest_set = true; + + filter->input.q_index = rss->queue[0 ]; + filter->input.q_region =rte_fls_u32 (rss->queue_num) -1 ; + filter->input.dest_ctl =ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QGROUP ; + +break ; + } +case RTE_FLOW_ACTION_TYPE_MARK : + { +const struct rte_flow_action_mark *mark_spec = act->conf; + filter->mark_flag =1 ; + filter->input.fltr_id = mark_spec->id; + filter->input.fdid_prio =ICE_FXD_FLTR_QW1_FDID_PRI_ONE ; +break ; + } +case RTE_FLOW_ACTION_TYPE_COUNT : + { +const struct rte_flow_action_count *act_count = act->conf; + + filter->input.cnt_ena =ICE_FXD_FLTR_QW0_STAT_ENA_PKTS ; +rte_memcpy (&filter->act_count, act_count, +sizeof (filter->act_count)); +break ; + } +default : +/* Should not happen */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"Invalid action." ); + } + } + +/* set default action to PASSTHRU mode, in "mark/count only" case. */ +if (!dest_set) { + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER ; + } + +return 0 ; +} + +static int +ice_fdir_check_action_qregion (struct ice_pf *pf, +struct rte_flow_error *error, +const struct rte_flow_action_rss *rss) +{ +if (rss->queue_num <=1 ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"Queue region size can't be 0 or 1." ); + } + +if (rss->queue[rss->queue_num -1 ] >= pf->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"Invalid queue region indexes." ); + } + +if (!(rte_is_power_of_2 (rss->queue_num) && + (rss->queue_num <=ICE_FDIR_MAX_QREGION_SIZE ))) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION_CONF , rss, +"The region size should be any of the following values:" +"2, 4, 8, 16, 32, 64, 128 as long as the total number " +"of queues do not exceed the VSI allocation." ); + +return 0 ; +} + +static int +ice_fdir_check_action (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +struct ice_adapter *ad = param->driver_ctx; +struct ice_pf *pf = &ad->pf; +uint32_t dest_num =0 ; +uint32_t mark_num =0 ; +uint32_t counter_num =0 ; +size_t i; +int ret; + +for (i =0 ; i < actions->count; i++) { +const struct rte_flow_action *act = actions->actions[i]; + +switch (act->type) { +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *act_q = act->conf; + dest_num++; + +if (act_q->index >= pf->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act, +"Invalid queue for FDIR." ); + } +break ; + } +case RTE_FLOW_ACTION_TYPE_DROP : + dest_num++; +break ; +case RTE_FLOW_ACTION_TYPE_PASSTHRU : + dest_num++; +break ; +case RTE_FLOW_ACTION_TYPE_RSS : + { +const struct rte_flow_action_rss *rss = act->conf; + + dest_num++; + ret =ice_fdir_check_action_qregion (pf, error, rss); +if (ret) +return ret; +break ; + } +case RTE_FLOW_ACTION_TYPE_MARK : + { + mark_num++; +break ; + } +case RTE_FLOW_ACTION_TYPE_COUNT : + { + counter_num++; +break ; + } +default : +/* Should not happen */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"Invalid action." ); + } + } + +if (dest_num >1 || mark_num >1 || counter_num >1 ) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Unsupported action combination" ); + } + +return 0 ; +} + static int ice_fdir_parse(struct ice_adapter *ad, struct ice_pattern_match_item *array,
@@ -2814,6 +2825,22 @@ ice_fdir_parse(struct ice_adapter *ad,void **meta, struct rte_flow_error *error) { + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_PASSTHRU , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_MARK , +RTE_FLOW_ACTION_TYPE_COUNT , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =3 , + .check = ice_fdir_check_action, + .driver_ctx = ad, + .rss_queues_contig = true, + };struct ice_pf *pf = &ad->pf;struct ice_fdir_filter_conf *filter = &pf->fdir.conf;struct ice_pattern_match_item *item =NULL ;
@@ -2826,6 +2853,11 @@ ice_fdir_parse(struct ice_adapter *ad,return ret;memset (filter,0 ,sizeof (*filter)); + + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret) +return ret; + item =ice_search_pattern_match_item (ad, pattern, array, array_len, error);
@@ -2854,7 +2886,7 @@ ice_fdir_parse(struct ice_adapter *ad, goto error; } - ret =ice_fdir_parse_action (ad, actions, error, filter); + ret =ice_fdir_parse_action (ad, &parsed_actions, error);if (ret) goto error;
Signature · 1 line
2.47.3
PATCH v7 26/27 net/ice: use common action checks for switch
In reply to Anatoly BurakovFrom: Vladimir Medvedkin <[email protected]>
Use the common flow action checking parsing infrastructure for checking flow actions for switch filter.
--- drivers/net/intel/ice/ice_switch_filter.c | 371 +++++++++++----------- 1 file changed, 185 insertions(+), 186 deletions(-)
drivers/net/intel/ice/ice_switch_filter.c +185 -186
@@ -35,6 +35,8 @@#define ICE_IPV4_PROTO_NVGRE 0x002F#define ICE_SW_PRI_BASE 6 +#define ICE_SW_MAX_QUEUES 128 +#define ICE_SW_INSET_ETHER ( \ ICE_INSET_DMAC | ICE_INSET_SMAC | ICE_INSET_ETHERTYPE)#define ICE_SW_INSET_MAC_VLAN ( \
@@ -1527,85 +1529,38 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[], }static int -ice_switch_parse_dcf_action (struct ice_dcf_adapter *ad, -const struct rte_flow_action *actions, +ice_switch_parse_dcf_action (const struct rte_flow_action *action,uint32_t priority,struct rte_flow_error *error,struct ice_adv_rule_info *rule_info) {const struct rte_flow_action_ethdev *act_ethdev; -const struct rte_flow_action *action;const struct rte_eth_dev *repr_dev;enum rte_flow_action_type action_type; -uint16_t rule_port_id, backer_port_id; -for (action = actions; action->type != -RTE_FLOW_ACTION_TYPE_END ; action++) { - action_type = action->type; -switch (action_type) { -case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR : - rule_info->sw_act.fltr_act =ICE_FWD_TO_VSI ; - act_ethdev = action->conf; - -if (!rte_eth_dev_is_valid_port (act_ethdev->port_id)) - goto invalid_port_id; - -/* For traffic to original DCF port */ - rule_port_id = ad->parent.pf.dev_data->port_id; - -if (rule_port_id != act_ethdev->port_id) - goto invalid_port_id; - - rule_info->sw_act.vsi_handle =0 ; - -break ; - -invalid_port_id: -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid port_id" ); -return -rte_errno; - -case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT : - rule_info->sw_act.fltr_act =ICE_FWD_TO_VSI ; - act_ethdev = action->conf; - -if (!rte_eth_dev_is_valid_port (act_ethdev->port_id)) - goto invalid; - - repr_dev = &rte_eth_devices[act_ethdev->port_id]; - -if (!repr_dev->data) - goto invalid; - - rule_port_id = ad->parent.pf.dev_data->port_id; - backer_port_id = repr_dev->data->backer_port_id; - -if (backer_port_id != rule_port_id) - goto invalid; - - rule_info->sw_act.vsi_handle = repr_dev->data->representor_id; -break ; - -invalid: -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid ethdev_port_id" ); -return -rte_errno; - -case RTE_FLOW_ACTION_TYPE_DROP : - rule_info->sw_act.fltr_act =ICE_DROP_PACKET ; -break ; - -default : -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid action type" ); -return -rte_errno; - } + action_type = action->type; +switch (action_type) { +case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR : + rule_info->sw_act.fltr_act =ICE_FWD_TO_VSI ; + rule_info->sw_act.vsi_handle =0 ; +break ; + +case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT : + rule_info->sw_act.fltr_act =ICE_FWD_TO_VSI ; + act_ethdev = action->conf; + repr_dev = &rte_eth_devices[act_ethdev->port_id]; + rule_info->sw_act.vsi_handle = repr_dev->data->representor_id; +break ; + +case RTE_FLOW_ACTION_TYPE_DROP : + rule_info->sw_act.fltr_act =ICE_DROP_PACKET ; +break ; + +default : +/* Should never reach */ +rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Invalid action type" ); +return -rte_errno; } rule_info->sw_act.src = rule_info->sw_act.vsi_handle;
@@ -1621,73 +1576,38 @@ ice_switch_parse_dcf_action(struct ice_dcf_adapter *ad,static int ice_switch_parse_action (struct ice_pf *pf, -const struct rte_flow_action *actions, +const struct rte_flow_action *action,uint32_t priority,struct rte_flow_error *error,struct ice_adv_rule_info *rule_info) {struct ice_vsi *vsi = pf->main_vsi; -struct rte_eth_dev_data *dev_data = pf->adapter->pf.dev_data;const struct rte_flow_action_queue *act_q;const struct rte_flow_action_rss *act_qgrop; -uint16_t base_queue, i; -const struct rte_flow_action *action; +uint16_t base_queue;enum rte_flow_action_type action_type; -uint16_t valid_qgrop_number[MAX_QGRP_NUM_TYPE ] = { -2 ,4 ,8 ,16 ,32 ,64 ,128 }; base_queue = pf->base_queue + vsi->base_queue; -for (action = actions; action->type != -RTE_FLOW_ACTION_TYPE_END ; action++) { - action_type = action->type; -switch (action_type) { -case RTE_FLOW_ACTION_TYPE_RSS : - act_qgrop = action->conf; -if (act_qgrop->queue_num <=1 ) - goto error; - rule_info->sw_act.fltr_act = -ICE_FWD_TO_QGRP ; - rule_info->sw_act.fwd_id.q_id = - base_queue + act_qgrop->queue[0 ]; -for (i =0 ; i <MAX_QGRP_NUM_TYPE ; i++) { -if (act_qgrop->queue_num == - valid_qgrop_number[i]) -break ; - } -if (i ==MAX_QGRP_NUM_TYPE ) - goto error; -if ((act_qgrop->queue[0 ] + - act_qgrop->queue_num) > - dev_data->nb_rx_queues) - goto error1; -for (i =0 ; i < act_qgrop->queue_num -1 ; i++) -if (act_qgrop->queue[i +1 ] != - act_qgrop->queue[i] +1 ) - goto error2; - rule_info->sw_act.qgrp_size = - act_qgrop->queue_num; -break ; -case RTE_FLOW_ACTION_TYPE_QUEUE : - act_q = action->conf; -if (act_q->index >= dev_data->nb_rx_queues) - goto error; - rule_info->sw_act.fltr_act = -ICE_FWD_TO_Q ; - rule_info->sw_act.fwd_id.q_id = - base_queue + act_q->index; -break ; - -case RTE_FLOW_ACTION_TYPE_DROP : - rule_info->sw_act.fltr_act = -ICE_DROP_PACKET ; -break ; - -case RTE_FLOW_ACTION_TYPE_VOID : -break ; - -default : - goto error; - } + action_type = action->type; +switch (action_type) { +case RTE_FLOW_ACTION_TYPE_RSS : + act_qgrop = action->conf; + rule_info->sw_act.fltr_act =ICE_FWD_TO_QGRP ; + rule_info->sw_act.fwd_id.q_id = base_queue + act_qgrop->queue[0 ]; + rule_info->sw_act.qgrp_size = act_qgrop->queue_num; +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : + act_q = action->conf; + rule_info->sw_act.fltr_act =ICE_FWD_TO_Q ; + rule_info->sw_act.fwd_id.q_id = base_queue + act_q->index; +break ; +case RTE_FLOW_ACTION_TYPE_DROP : + rule_info->sw_act.fltr_act =ICE_DROP_PACKET ; +break ; +default : +rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , + action,"Invalid action type or queue number" ); +return -rte_errno; } rule_info->sw_act.vsi_handle = vsi->idx;
@@ -1699,65 +1619,120 @@ ice_switch_parse_action(struct ice_pf *pf, rule_info->priority =ICE_SW_PRI_BASE - priority;return 0 ; - -error: -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid action type or queue number" ); -return -rte_errno; - -error1: -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid queue region indexes" ); -return -rte_errno; - -error2: -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Discontinuous queue region" ); -return -rte_errno; }static int -ice_switch_check_action (const struct rte_flow_action *actions, -struct rte_flow_error *error) +ice_switch_dcf_action_check (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) { +struct ice_dcf_adapter *ad = param->driver_ctx;const struct rte_flow_action *action;enum rte_flow_action_type action_type; -uint16_t actions_num =0 ; - -for (action = actions; action->type != -RTE_FLOW_ACTION_TYPE_END ; action++) { - action_type = action->type; -switch (action_type) { -case RTE_FLOW_ACTION_TYPE_RSS : -case RTE_FLOW_ACTION_TYPE_QUEUE : -case RTE_FLOW_ACTION_TYPE_DROP : -case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT : -case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR : - actions_num++; -break ; -case RTE_FLOW_ACTION_TYPE_VOID : -continue ; -default : -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid action type" ); -return -rte_errno; +const struct rte_flow_action_ethdev *act_ethdev; +const struct rte_eth_dev *repr_dev; + + action = actions->actions[0 ]; + action_type = action->type; + +switch (action_type) { +case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR : +case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT : + { +uint16_t expected_port_id, backer_port_id; + act_ethdev = action->conf; + +if (!rte_eth_dev_is_valid_port (act_ethdev->port_id)) + goto invalid_port_id; + + expected_port_id = ad->parent.pf.dev_data->port_id; + +if (action_type ==RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR ) { +if (expected_port_id != act_ethdev->port_id) + goto invalid_port_id; + }else { + repr_dev = &rte_eth_devices[act_ethdev->port_id]; + +if (!repr_dev->data) + goto invalid_port_id; + + backer_port_id = repr_dev->data->backer_port_id; + +if (backer_port_id != expected_port_id) + goto invalid_port_id; } + +break ; +invalid_port_id: +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid port ID" ); + } +case RTE_FLOW_ACTION_TYPE_DROP : +break ; +default : +/* Should never reach */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid action type" ); } -if (actions_num !=1 ) { -rte_flow_error_set (error, -EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid action number" ); -return -rte_errno; +return 0 ; +} + +static int +ice_switch_action_check (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +struct ice_adapter *ad = param->driver_ctx; +struct ice_pf *pf = &ad->pf; +struct rte_eth_dev_data *dev_data = pf->dev_data; +const struct rte_flow_action *action = actions->actions[0 ]; + +switch (action->type) { +case RTE_FLOW_ACTION_TYPE_RSS : + { +const struct rte_flow_action_rss *act_qgrop; + act_qgrop = action->conf; + +/* Check bounds on number of queues */ +if (act_qgrop->queue_num <2 || act_qgrop->queue_num >ICE_SW_MAX_QUEUES ) + goto err_rss; + +/* must be power of 2 */ +if (!rte_is_power_of_2 (act_qgrop->queue_num)) + goto err_rss; + +/* queues are monotonous and contiguous so check last queue */ +if ((act_qgrop->queue[0 ] + act_qgrop->queue_num) > dev_data->nb_rx_queues) + goto err_rss; + +break ; +err_rss: +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid queue region" ); + } +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *act_q; + act_q = action->conf; +if (act_q->index >= dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid queue" ); + } + +break ; + } +case RTE_FLOW_ACTION_TYPE_DROP : +break ; +default : +/* Should never reach */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"Invalid action type" ); }return 0 ;
@@ -1788,11 +1763,39 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,struct ci_flow_attr_check_param attr_param = { .allow_priority = true, }; +struct ci_flow_actions parsed_actions = {0 }; +struct ci_flow_actions_check_param dcf_param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT , +RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =1 , + .check = ice_switch_dcf_action_check, + }; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_RSS , +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =1 , + .check = ice_switch_action_check, + .driver_ctx = ad, + .rss_queues_contig = true, + }; ret =ci_flow_check_attr (attr, &attr_param, error);if (ret)return ret; + ret =ci_flow_check_actions (actions, (ad->hw.dcf_enabled) ? &dcf_param : ¶m, + &parsed_actions, error); +if (ret) + goto error; +/* Allow only two priority values - 0 or 1 */ if (attr->priority >1 ) { rte_flow_error_set(error, EINVAL,
@@ -1870,16 +1873,12 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,memset (&rule_info,0 ,sizeof (rule_info)); rule_info.tun_type = tun_type; - ret =ice_switch_check_action (actions, error); -if (ret) - goto error; -if (ad->hw.dcf_enabled) - ret =ice_switch_parse_dcf_action ((void *)ad, actions, attr->priority, - error, &rule_info); + ret =ice_switch_parse_dcf_action (parsed_actions.actions[0 ], + attr->priority, error, &rule_info);else - ret =ice_switch_parse_action (pf, actions, attr->priority, error, - &rule_info); + ret =ice_switch_parse_action (pf, parsed_actions.actions[0 ], + attr->priority, error, &rule_info);if (ret) goto error;
Signature · 1 line
2.47.3
PATCH v7 27/27 net/ice: use common action checks for ACL
In reply to Anatoly BurakovFrom: Vladimir Medvedkin <[email protected]>
Use the common flow action checking parsing infrastructure for checking flow actions for ACL filter.
--- drivers/net/intel/ice/ice_acl_filter.c | 143 +++++++++++++++---------- 1 file changed, 84 insertions(+), 59 deletions(-)
drivers/net/intel/ice/ice_acl_filter.c +84 -59
@@ -645,60 +645,6 @@ ice_acl_filter_free(struct rte_flow *flow) flow->rule =NULL ; } -static int -ice_acl_parse_action(__rte_unused struct ice_adapter *ad, -const struct rte_flow_action actions[], -struct rte_flow_error *error, -struct ice_acl_conf *filter) -{ -struct ice_pf *pf = &ad->pf; -const struct rte_flow_action_queue *act_q; -uint32_t dest_num =0 ; - -for (; actions->type !=RTE_FLOW_ACTION_TYPE_END ; actions++) { -switch (actions->type) { -case RTE_FLOW_ACTION_TYPE_VOID : -break ; -case RTE_FLOW_ACTION_TYPE_DROP : - dest_num++; - - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DROP_PKT ; -break ; -case RTE_FLOW_ACTION_TYPE_QUEUE : - dest_num++; - - act_q = actions->conf; - filter->input.q_index = act_q->index; -if (filter->input.q_index >= - pf->dev_data->nb_rx_queues) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , - actions, -"Invalid queue for FDIR." ); -return -rte_errno; - } - filter->input.dest_ctl = -ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX ; -break ; -default : -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Invalid action." ); -return -rte_errno; - } - } - -if (dest_num ==0 || dest_num >=2 ) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , actions, -"Unsupported action combination" ); -return -rte_errno; - } - -return 0 ; -} - static int ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad, const struct rte_flow_item pattern[],
@@ -966,6 +912,69 @@ ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad,return 0 ; } +static int +ice_acl_parse_action (const struct ci_flow_actions *actions, +struct ice_acl_conf *filter, +struct rte_flow_error *error) +{ +const struct rte_flow_action *act = actions->actions[0 ]; + +switch (act->type) { +case RTE_FLOW_ACTION_TYPE_DROP : + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DROP_PKT ; +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *act_q = act->conf; + + filter->input.q_index = act_q->index; + filter->input.dest_ctl = +ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX ; +break ; + } +default : +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"Invalid action." ); + } + +return 0 ; +} + +static int +ice_acl_parse_action_check (const struct ci_flow_actions *actions, +const struct ci_flow_actions_check_param *param, +struct rte_flow_error *error) +{ +struct ice_adapter *ad = param->driver_ctx; +struct ice_pf *pf = &ad->pf; +const struct rte_flow_action *act = actions->actions[0 ]; + +switch (act->type) { +case RTE_FLOW_ACTION_TYPE_DROP : +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : + { +const struct rte_flow_action_queue *act_q = act->conf; + +if (act_q->index >= pf->dev_data->nb_rx_queues) { +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"Invalid queue for ACL." ); + } +break ; + } +default : +/* shouldn't happen */ +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , act, +"Invalid action." ); + } + +return 0 ; +} + static int ice_acl_parse(struct ice_adapter *ad, struct ice_pattern_match_item *array,
@@ -976,17 +985,33 @@ ice_acl_parse(struct ice_adapter *ad,void **meta, struct rte_flow_error *error) { + struct ci_flow_actions parsed_actions = {0}; +struct ci_flow_actions_check_param param = { + .allowed_types = (enum rte_flow_action_type []){ +RTE_FLOW_ACTION_TYPE_DROP , +RTE_FLOW_ACTION_TYPE_QUEUE , +RTE_FLOW_ACTION_TYPE_END + }, + .max_actions =1 , + .check = ice_acl_parse_action_check, + .driver_ctx = ad, + };struct ice_pf *pf = &ad->pf;struct ice_acl_conf *filter = &pf->acl.conf;struct ice_pattern_match_item *item =NULL ;uint64_t input_set;int ret; - ret =ci_flow_check_attr (attr,NULL , error); -if (ret) -return ret; -memset (filter,0 ,sizeof (*filter)); + + ret =ci_flow_check_attr (attr,NULL , error); +if (ret) +return ret; + + ret =ci_flow_check_actions (actions, ¶m, &parsed_actions, error); +if (ret) +return ret; + item =ice_search_pattern_match_item (ad, pattern, array, array_len, error);if (!item)
@@ -1005,7 +1030,7 @@ ice_acl_parse(struct ice_adapter *ad, goto error; } - ret =ice_acl_parse_action (ad, actions, error, filter); + ret =ice_acl_parse_action (&parsed_actions, filter, error);if (ret) goto error;
Signature · 1 line
2.47.3
Quoted 9 lines · Anatoly Burakov
This patchset introduces common flow attr/action checking infrastructure to some Intel PMD's (IXGBE, I40E, IAVF, and ICE). The aim is to reduce code duplication, simplify implementation of new parsers/verification of existing ones, and make action/attr handling more consistent across drivers.
v7:
- Fail on empty action list before calling into user callbacks
- Remove empty code
Series applied to dpdk-next-net-intel.
Thanks,
/Bruce