Hi Wei, > -----Original Message----- > From: Zhao1, Wei > Sent: Monday, June 17, 2019 4:52 PM > To: Xing, Beilei <beilei.x...@intel.com>; Yang, Qiming > <qiming.y...@intel.com>; dev@dpdk.org > Subject: RE: [dpdk-dev] [PATCH v2 1/3] net/ice: enable switch filter > > Hi , Beilei > > > > -----Original Message----- > > From: Xing, Beilei > > Sent: Monday, June 17, 2019 1:27 PM > > To: Yang, Qiming <qiming.y...@intel.com>; dev@dpdk.org > > Cc: Zhao1, Wei <wei.zh...@intel.com> > > Subject: RE: [dpdk-dev] [PATCH v2 1/3] net/ice: enable switch filter > > > > > > > > ... > > > > > + > > > +/* By now ice switch filter action code implement only > > > +* supports QUEUE or DROP. > > > +*/ > > > +static int > > > +ice_parse_switch_action(struct ice_pf *pf, > > > + const struct rte_flow_action *actions, > > > + struct rte_flow_error *error, > > > + struct ice_adv_rule_info *rule_info) { > > > + struct ice_hw *hw = ICE_PF_TO_HW(pf); > > > + struct ice_vsi *vsi = pf->main_vsi; > > > + const struct rte_flow_action *act; > > > + const struct rte_flow_action_queue *act_q; > > > + uint16_t base_queue, index = 0; > > > + uint32_t reg; > > > + > > > + /* 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; > > > + } > > > + reg = ICE_READ_REG(hw, PFLAN_RX_QALLOC); > > > + if (reg & PFLAN_RX_QALLOC_VALID_M) { > > > + base_queue = reg & PFLAN_RX_QALLOC_FIRSTQ_M; > > > + } else { > > > + rte_flow_error_set(error, EINVAL, > > > + RTE_FLOW_ERROR_TYPE_ACTION, > > > + act, "Invalid queue register"); > > > + return -rte_errno; > > > + } > > > + if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) { > > > + act_q = act->conf; > > > + rule_info->sw_act.fltr_act = ICE_FWD_TO_Q; > > > + rule_info->sw_act.fwd_id.q_id = base_queue + act_q->index; > > > + if (act_q->index >= pf->dev_data->nb_rx_queues) { > > > + rte_flow_error_set(error, EINVAL, > > > + RTE_FLOW_ERROR_TYPE_ACTION, > > > + act, "Invalid queue ID for" > > > + " switch filter."); > > > + return -rte_errno; > > > + } > > > + } else { > > > + rule_info->sw_act.fltr_act = ICE_DROP_PACKET; > > > + } > > > + > > > + rule_info->sw_act.vsi_handle = vsi->idx; > > > + rule_info->rx = 1; > > > + rule_info->sw_act.src = vsi->idx; > > > + > > > + /* 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; > > > +} > > > > > > How about use supported array to replace NEXT_ITEM_OF_ACTION? Just > > like pattern. > > This seems no need to change, i40e also implement in this way.
Code in I40e is not perfect, we can try to improve our PMD in new driver. I think supported array is more clear and friendly, what do you think?