Use the common flow action checking parsing infrastructure for checking
flow actions for ethertype filter.

Signed-off-by: Anatoly Burakov <[email protected]>
---
 drivers/net/intel/i40e/i40e_flow.c | 56 +++++++++++++-----------------
 1 file changed, 24 insertions(+), 32 deletions(-)

diff --git a/drivers/net/intel/i40e/i40e_flow.c 
b/drivers/net/intel/i40e/i40e_flow.c
index ad80883f13..0e9880e9ce 100644
--- a/drivers/net/intel/i40e/i40e_flow.c
+++ b/drivers/net/intel/i40e/i40e_flow.c
@@ -1347,43 +1347,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;
 }
 
-- 
2.47.3

Reply via email to