Skip to content

Commit

Permalink
net/cnxk: fix flow queue index validation
Browse files Browse the repository at this point in the history
[ upstream commit 47f4051664c3235586c08095a2b328d5c86b87e2 ]

When creating a flow rule directing traffic from PF
to VF, current validation is incorrectly checking the
RQ index in flow action with the PF's maximum
configured RQs. This validation is applicable only
when action target is an RQ of the PF. The validation
has been modified accordingly.

Fixes: 8c009b4 ("net/cnxk: support flow API")

Signed-off-by: Satheesh Paul <psatheesh@marvell.com>
Reviewed-by: Kiran Kumar K <kirankumark@marvell.com>
  • Loading branch information
satheeshpaul authored and kevintraynor committed Jul 12, 2023
1 parent 988a65a commit 14945c0
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions drivers/net/cnxk/cnxk_rte_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,14 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
struct roc_npc_action in_actions[], uint32_t *flowkey_cfg)
{
struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
const struct rte_flow_action_queue *act_q = NULL;
const struct rte_flow_action_port_id *port_act;
const struct rte_flow_action_queue *act_q;
struct roc_npc *roc_npc_src = &dev->npc;
struct rte_eth_dev *portid_eth_dev;
char if_name[RTE_ETH_NAME_MAX_LEN];
struct cnxk_eth_dev *hw_dst;
struct roc_npc *roc_npc_dst;
bool is_vf_action = false;
int i = 0, rc = 0;
int rq;

Expand Down Expand Up @@ -150,6 +151,7 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
case RTE_FLOW_ACTION_TYPE_VF:
in_actions[i].type = ROC_NPC_ACTION_TYPE_VF;
in_actions[i].conf = actions->conf;
is_vf_action = true;
break;

case RTE_FLOW_ACTION_TYPE_PORT_ID:
Expand Down Expand Up @@ -183,13 +185,7 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
break;

case RTE_FLOW_ACTION_TYPE_QUEUE:
act_q = (const struct rte_flow_action_queue *)
actions->conf;
rq = act_q->index;
if (rq >= eth_dev->data->nb_rx_queues) {
plt_npc_dbg("Invalid queue index");
goto err_exit;
}
act_q = (const struct rte_flow_action_queue *)actions->conf;
in_actions[i].type = ROC_NPC_ACTION_TYPE_QUEUE;
in_actions[i].conf = actions->conf;
break;
Expand Down Expand Up @@ -234,6 +230,14 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
}
i++;
}

if (!is_vf_action && act_q) {
rq = act_q->index;
if (rq >= eth_dev->data->nb_rx_queues) {
plt_npc_dbg("Invalid queue index");
goto err_exit;
}
}
in_actions[i].type = ROC_NPC_ACTION_TYPE_END;
return 0;

Expand Down

0 comments on commit 14945c0

Please sign in to comment.