net/cnxk: fix incorrect queue index validation

Message ID 20230620110137.1416830-1-psatheesh@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series net/cnxk: fix incorrect queue index validation |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-aarch-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS

Commit Message

Satheesh Paul Antonysamy June 20, 2023, 11:01 a.m. UTC
  From: Satheesh Paul <psatheesh@marvell.com>

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: 8c009b4505e ("net/cnxk: support flow API")
Cc: stable@dpdk.org

Signed-off-by: Satheesh Paul <psatheesh@marvell.com>
Reviewed-by: Kiran Kumar K <kirankumark@marvell.com>
---
 drivers/net/cnxk/cnxk_flow.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
  

Comments

Jerin Jacob June 21, 2023, 4:33 a.m. UTC | #1
On Tue, Jun 20, 2023 at 4:32 PM <psatheesh@marvell.com> wrote:
>
> From: Satheesh Paul <psatheesh@marvell.com>
>
> 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: 8c009b4505e ("net/cnxk: support flow API")
> Cc: stable@dpdk.org
>
> Signed-off-by: Satheesh Paul <psatheesh@marvell.com>
> Reviewed-by: Kiran Kumar K <kirankumark@marvell.com>

Applied to dpdk-next-net-mrvl/for-next-net. Thanks
  

Patch

diff --git a/drivers/net/cnxk/cnxk_flow.c b/drivers/net/cnxk/cnxk_flow.c
index 1b88542dcb..3b8348ae9c 100644
--- a/drivers/net/cnxk/cnxk_flow.c
+++ b/drivers/net/cnxk/cnxk_flow.c
@@ -117,13 +117,14 @@  cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
 		 uint32_t *flowkey_cfg, uint16_t *dst_pf_func)
 {
 	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_ethdev *act_ethdev;
 	const struct rte_flow_action_port_id *port_act;
-	const struct rte_flow_action_queue *act_q;
 	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;
 
@@ -157,6 +158,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_REPRESENTED_PORT:
@@ -189,13 +191,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;
@@ -241,6 +237,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;