patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/cnxk: fix port ID default action
@ 2025-10-30  3:44 psatheesh
  0 siblings, 0 replies; only message in thread
From: psatheesh @ 2025-10-30  3:44 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
	Harman Kalra, Jerin Jacob, Satheesh Paul
  Cc: dev, stable

From: Satheesh Paul <psatheesh@marvell.com>

The default action for port_id is set incorrectly.
Fixing this by introducing a new kernel mbox to read
the action set for the port's default rule and using
the same action for the rule being created.

Fixes: 15f0b8a5b9e1 ("common/cnxk: support port ID action")
Cc: stable@dpdk.org

Signed-off-by: Satheesh Paul <psatheesh@marvell.com>
Reviewed-by: Kiran Kumar K <kirankumark@marvell.com>
---
 drivers/common/cnxk/roc_mbox.h                |  2 +
 drivers/common/cnxk/roc_npc.c                 | 52 ++++++++++++++-----
 drivers/common/cnxk/roc_npc.h                 |  4 +-
 drivers/common/cnxk/roc_npc_priv.h            |  1 +
 .../common/cnxk/roc_platform_base_symbols.c   |  1 +
 drivers/net/cnxk/cnxk_flow.c                  | 36 ++++++++-----
 6 files changed, 69 insertions(+), 27 deletions(-)

diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h
index cbafa9555d..e1bed7858f 100644
--- a/drivers/common/cnxk/roc_mbox.h
+++ b/drivers/common/cnxk/roc_mbox.h
@@ -268,6 +268,8 @@ struct mbox_msghdr {
 	M(NPC_CN20K_MCAM_READ_BASE_RULE, 0x601c,                               \
 	  npc_cn20k_read_base_steer_rule, msg_req,                             \
 	  npc_cn20k_mcam_read_base_rule_rsp)                                   \
+	M(NPC_MCAM_READ_DEFAULT_RULE, 0x6023, npc_read_default_rule,           \
+	  msg_req, npc_mcam_read_base_rule_rsp)                                \
 	/* NIX mbox IDs (range 0x8000 - 0xFFFF) */                             \
 	M(NIX_LF_ALLOC, 0x8000, nix_lf_alloc, nix_lf_alloc_req,                \
 	  nix_lf_alloc_rsp)                                                    \
diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c
index 50106b8773..56e0e05b63 100644
--- a/drivers/common/cnxk/roc_npc.c
+++ b/drivers/common/cnxk/roc_npc.c
@@ -599,8 +599,9 @@ roc_npc_process_sample_action(struct roc_npc *roc_npc,
 static int
 npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 		  const struct roc_npc_action actions[], struct roc_npc_flow *flow,
-		  uint16_t dst_pf_func)
+		  uint16_t dst_pf_func, uint64_t npc_default_action)
 {
+	bool vlan_insert_action = false, npc_action_set = false;
 	struct npc *npc = roc_npc_to_npc_priv(roc_npc);
 	const struct roc_npc_action *sec_action = NULL;
 	const struct roc_npc_action_sample *act_sample;
@@ -609,7 +610,6 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 	const struct roc_npc_action_meter *act_mtr;
 	const struct roc_npc_action_queue *act_q;
 	const struct roc_npc_action_vf *vf_act;
-	bool vlan_insert_action = false;
 	uint8_t has_spi_to_sa_act = 0;
 	int sel_act, req_act = 0;
 	uint16_t pf_func, vf_id;
@@ -907,7 +907,8 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 	} else if (req_act & (ROC_NPC_ACTION_TYPE_PF | ROC_NPC_ACTION_TYPE_VF)) {
 		/* Check if any other action is set */
 		if ((req_act == ROC_NPC_ACTION_TYPE_PF) || (req_act == ROC_NPC_ACTION_TYPE_VF)) {
-			flow->npc_action = NIX_RX_ACTIONOP_DEFAULT;
+			flow->npc_action = npc_default_action;
+			npc_action_set = true;
 		} else {
 			flow->npc_action = NIX_RX_ACTIONOP_UCAST;
 			if (req_act & ROC_NPC_ACTION_TYPE_QUEUE)
@@ -944,15 +945,16 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 		goto err_exit;
 	}
 
-	if (req_act & ROC_NPC_ACTION_TYPE_SAMPLE)
-		flow->npc_action = NIX_RX_ACTIONOP_MCAST;
+	if (!npc_action_set) {
+		if (req_act & ROC_NPC_ACTION_TYPE_SAMPLE)
+			flow->npc_action = NIX_RX_ACTIONOP_MCAST;
 
-	if (mark)
-		flow->npc_action |= (uint64_t)mark << 40;
-
-	/* Ideally AF must ensure that correct pf_func is set */
-	flow->npc_action |= (uint64_t)pf_func << 4;
+		if (mark)
+			flow->npc_action |= (uint64_t)mark << 40;
 
+		/* Ideally AF must ensure that correct pf_func is set */
+		flow->npc_action |= (uint64_t)pf_func << 4;
+	}
 done:
 	return 0;
 
@@ -1072,7 +1074,8 @@ npc_parse_rule(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 		return err;
 
 	/* Check action */
-	err = npc_parse_actions(roc_npc, attr, actions, flow, pst->dst_pf_func);
+	err = npc_parse_actions(roc_npc, attr, actions, flow, pst->dst_pf_func,
+				pst->npc_default_action);
 	if (err)
 		return err;
 	return 0;
@@ -1643,7 +1646,7 @@ roc_npc_sdp_channel_get(struct roc_npc *roc_npc, uint16_t *chan_base, uint16_t *
 struct roc_npc_flow *
 roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 		    const struct roc_npc_item_info pattern[], const struct roc_npc_action actions[],
-		    uint16_t dst_pf_func, int *errcode)
+		    uint16_t dst_pf_func, uint64_t npc_default_action, int *errcode)
 {
 	struct npc *npc = roc_npc_to_npc_priv(roc_npc);
 	uint16_t sdp_chan_base = 0, sdp_chan_mask = 0;
@@ -1693,6 +1696,7 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 	}
 
 	parse_state.dst_pf_func = dst_pf_func;
+	parse_state.npc_default_action = npc_default_action;
 
 	rc = npc_parse_rule(roc_npc, attr, pattern, actions, flow, &parse_state);
 	if (rc != 0) {
@@ -1959,3 +1963,27 @@ roc_npc_mcam_merge_base_steering_rule(struct roc_npc *roc_npc, struct roc_npc_fl
 	mbox_put(mbox);
 	return rc;
 }
+
+int
+roc_npc_mcam_default_rule_action_get(struct roc_npc *roc_npc, uint64_t *action)
+{
+	struct npc *npc = roc_npc_to_npc_priv(roc_npc);
+	struct mbox *mbox = mbox_get(npc->mbox);
+	int rc;
+
+	struct npc_mcam_read_base_rule_rsp *base_rule_rsp;
+	struct mcam_entry *base_entry;
+
+	(void)mbox_alloc_msg_npc_read_default_rule(mbox);
+	rc = mbox_process_msg(mbox, (void *)&base_rule_rsp);
+	if (rc) {
+		plt_err("Failed to fetch default MCAM entry");
+		goto exit;
+	}
+	base_entry = &base_rule_rsp->entry_data;
+
+	*action = base_entry->action;
+exit:
+	mbox_put(mbox);
+	return rc;
+}
diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h
index 91c84d7d97..b7565806c0 100644
--- a/drivers/common/cnxk/roc_npc.h
+++ b/drivers/common/cnxk/roc_npc.h
@@ -449,7 +449,8 @@ struct roc_npc_flow *__roc_api roc_npc_flow_create(struct roc_npc *roc_npc,
 						   const struct roc_npc_attr *attr,
 						   const struct roc_npc_item_info pattern[],
 						   const struct roc_npc_action actions[],
-						   uint16_t dst_pf_func, int *errcode);
+						   uint16_t dst_pf_funct,
+						   uint64_t npc_default_action, int *errcode);
 int __roc_api roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow);
 int __roc_api roc_npc_mcam_free(struct roc_npc *roc_npc, struct roc_npc_flow *mcam);
 int __roc_api roc_npc_mcam_free_entry(struct roc_npc *roc_npc, uint32_t entry);
@@ -486,6 +487,7 @@ int __roc_api roc_npc_vtag_actions_get(struct roc_npc *roc_npc);
 int __roc_api roc_npc_vtag_actions_sub_return(struct roc_npc *roc_npc, uint32_t count);
 int __roc_api roc_npc_mcam_merge_base_steering_rule(struct roc_npc *roc_npc,
 						    struct roc_npc_flow *flow);
+int __roc_api roc_npc_mcam_default_rule_action_get(struct roc_npc *roc_npc, uint64_t *action);
 int __roc_api roc_npc_validate_portid_action(struct roc_npc *roc_npc_src,
 					     struct roc_npc *roc_npc_dst);
 int __roc_api roc_npc_mcam_init(struct roc_npc *roc_npc, struct roc_npc_flow *flow, int mcam_id);
diff --git a/drivers/common/cnxk/roc_npc_priv.h b/drivers/common/cnxk/roc_npc_priv.h
index 5812cf0f8d..f8f4489f06 100644
--- a/drivers/common/cnxk/roc_npc_priv.h
+++ b/drivers/common/cnxk/roc_npc_priv.h
@@ -219,6 +219,7 @@ struct npc_parse_state {
 	uint8_t *mcam_mask; /* point to flow->mcam_mask + key_len */
 	bool is_vf;
 	uint16_t dst_pf_func;
+	uint64_t npc_default_action;
 	uint16_t nb_tx_queues;
 };
 
diff --git a/drivers/common/cnxk/roc_platform_base_symbols.c b/drivers/common/cnxk/roc_platform_base_symbols.c
index 7f0fe601ad..14f0b3ad5e 100644
--- a/drivers/common/cnxk/roc_platform_base_symbols.c
+++ b/drivers/common/cnxk/roc_platform_base_symbols.c
@@ -450,6 +450,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_inl_mcam_clear_counter)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_mcam_alloc_counter)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_get_free_mcam_entry)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_mcam_read_counter)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_mcam_default_rule_action_get)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_mcam_get_stats)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_mcam_clear_counter)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_mcam_free_entry)
diff --git a/drivers/net/cnxk/cnxk_flow.c b/drivers/net/cnxk/cnxk_flow.c
index fcc60cd4f0..33501310e0 100644
--- a/drivers/net/cnxk/cnxk_flow.c
+++ b/drivers/net/cnxk/cnxk_flow.c
@@ -464,8 +464,8 @@ static int
 cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
 		 const struct rte_flow_action actions[], struct roc_npc_action in_actions[],
 		 struct roc_npc_action_sample *in_sample_actions, uint32_t *flowkey_cfg,
-		 uint16_t *dst_pf_func, uint8_t has_tunnel_pattern, bool is_rep,
-		 uint8_t rep_pattern, uint64_t *free_allocs)
+		 uint16_t *dst_pf_func, uint64_t *npc_default_action, uint8_t has_tunnel_pattern,
+		 bool is_rep, uint8_t rep_pattern, uint64_t *free_allocs)
 {
 	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
 	const struct rte_flow_action_queue *act_q = NULL;
@@ -531,9 +531,10 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
 				    eth_dev->data->port_id, if_name, act_ethdev->port_id);
 			if (cnxk_ethdev_is_representor(if_name)) {
 				if (representor_rep_portid_action(in_actions, eth_dev,
-					    portid_eth_dev, actions->type, rep_pattern,
-					    dst_pf_func, is_rep, has_tunnel_pattern,
-					    free_allocs, &i, flowkey_cfg)) {
+								  portid_eth_dev, actions->type,
+								  rep_pattern, dst_pf_func,
+								  is_rep, has_tunnel_pattern,
+								  free_allocs, &i, flowkey_cfg)) {
 					plt_err("Representor port action set failed");
 					goto err_exit;
 				}
@@ -583,6 +584,8 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
 				}
 
 				hw_dst = portid_eth_dev->data->dev_private;
+				roc_npc_mcam_default_rule_action_get(&hw_dst->npc,
+								     npc_default_action);
 				roc_npc_dst = &hw_dst->npc;
 				*dst_pf_func = roc_npc_dst->pf_func;
 			}
@@ -800,7 +803,7 @@ cnxk_map_flow_data(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr
 		   struct roc_npc_attr *in_attr, struct roc_npc_item_info in_pattern[],
 		   struct roc_npc_action in_actions[],
 		   struct roc_npc_action_sample *in_sample_actions, uint32_t *flowkey_cfg,
-		   uint16_t *dst_pf_func, bool is_rep, uint64_t *free_allocs)
+		   uint16_t *dst_pf_func, uint64_t *def_action, bool is_rep, uint64_t *free_allocs)
 {
 	uint8_t has_tunnel_pattern = 0, rep_pattern = 0;
 	int rc;
@@ -838,7 +841,8 @@ cnxk_map_flow_data(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr
 	}
 
 	return cnxk_map_actions(eth_dev, attr, actions, in_actions, in_sample_actions, flowkey_cfg,
-				dst_pf_func, has_tunnel_pattern, is_rep, rep_pattern, free_allocs);
+				dst_pf_func, def_action, has_tunnel_pattern, is_rep, rep_pattern,
+				free_allocs);
 }
 
 int
@@ -850,14 +854,15 @@ cnxk_flow_validate_common(struct rte_eth_dev *eth_dev, const struct rte_flow_att
 	struct roc_npc_item_info in_pattern[ROC_NPC_ITEM_TYPE_END + 1];
 	struct roc_npc_action in_actions[ROC_NPC_MAX_ACTION_COUNT];
 	struct roc_npc_action_sample in_sample_action;
+	uint64_t npc_default_action = 0;
 	struct cnxk_rep_dev *rep_dev;
 	struct roc_npc_attr in_attr;
 	uint64_t *free_allocs, sz;
 	struct cnxk_eth_dev *dev;
 	struct roc_npc_flow flow;
-	uint32_t flowkey_cfg = 0;
 	uint16_t dst_pf_func = 0;
-	struct roc_npc *npc;
+	uint32_t flowkey_cfg = 0;
+	struct roc_npc *npc = 0;
 	int rc, j;
 
 	/* is_rep set for operation performed via representor ports */
@@ -885,7 +890,8 @@ cnxk_flow_validate_common(struct rte_eth_dev *eth_dev, const struct rte_flow_att
 		return -ENOMEM;
 	}
 	rc = cnxk_map_flow_data(eth_dev, attr, pattern, actions, &in_attr, in_pattern, in_actions,
-				&in_sample_action, &flowkey_cfg, &dst_pf_func, is_rep, free_allocs);
+				&in_sample_action, &flowkey_cfg, &dst_pf_func, &npc_default_action,
+				is_rep, free_allocs);
 	if (rc) {
 		rte_flow_error_set(error, 0, RTE_FLOW_ERROR_TYPE_ACTION_NUM, NULL,
 				   "Failed to map flow data");
@@ -928,10 +934,11 @@ cnxk_flow_create_common(struct rte_eth_dev *eth_dev, const struct rte_flow_attr
 	struct cnxk_rep_dev *rep_dev = NULL;
 	struct roc_npc_flow *flow = NULL;
 	struct cnxk_eth_dev *dev = NULL;
+	uint64_t npc_default_action = 0;
 	struct roc_npc_attr in_attr;
+	struct roc_npc *npc = NULL;
 	uint64_t *free_allocs, sz;
 	uint16_t dst_pf_func = 0;
-	struct roc_npc *npc;
 	int errcode = 0;
 	int rc, j;
 
@@ -954,15 +961,16 @@ cnxk_flow_create_common(struct rte_eth_dev *eth_dev, const struct rte_flow_attr
 	memset(&in_sample_action, 0, sizeof(in_sample_action));
 	memset(&in_attr, 0, sizeof(struct roc_npc_attr));
 	rc = cnxk_map_flow_data(eth_dev, attr, pattern, actions, &in_attr, in_pattern, in_actions,
-				&in_sample_action, &npc->flowkey_cfg_state, &dst_pf_func, is_rep,
-				free_allocs);
+				&in_sample_action, &npc->flowkey_cfg_state, &dst_pf_func,
+				&npc_default_action, is_rep, free_allocs);
 	if (rc) {
 		rte_flow_error_set(error, rc, RTE_FLOW_ERROR_TYPE_ACTION_NUM, NULL,
 				   "Failed to map flow data");
 		goto clean;
 	}
 
-	flow = roc_npc_flow_create(npc, &in_attr, in_pattern, in_actions, dst_pf_func, &errcode);
+	flow = roc_npc_flow_create(npc, &in_attr, in_pattern, in_actions, dst_pf_func,
+				   npc_default_action, &errcode);
 	if (errcode != 0) {
 		rte_flow_error_set(error, errcode, errcode, NULL, roc_error_msg_get(errcode));
 		goto clean;
-- 
2.51.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-10-30  3:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-30  3:44 [dpdk-dev] [PATCH] net/cnxk: fix port ID default action psatheesh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).