DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 1/8] common/cnxk: common mbox for representor events
@ 2024-10-23 15:01 Harman Kalra
  2024-10-23 15:01 ` [PATCH 2/8] net/cnxk: " Harman Kalra
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Harman Kalra @ 2024-10-23 15:01 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
	Harman Kalra
  Cc: dev, Ankur Dwivedi

From: Ankur Dwivedi <adwivedi@marvell.com>

Adding a common mbox which can process multiple representor events
under one mbox ID. Different types of events like, representee state
change, MTU change all can be sent as different events but via same
mbox.

Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
Signed-off-by: Harman Kalra <hkalra@marvell.com>
---
 drivers/common/cnxk/roc_dev.c     | 68 +++++++++++++------------------
 drivers/common/cnxk/roc_eswitch.h |  7 ++++
 drivers/common/cnxk/roc_mbox.h    | 28 ++++++++-----
 3 files changed, 53 insertions(+), 50 deletions(-)

diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c
index c905d35ea6..45f007325e 100644
--- a/drivers/common/cnxk/roc_dev.c
+++ b/drivers/common/cnxk/roc_dev.c
@@ -543,16 +543,16 @@ pf_vf_mbox_send_up_msg(struct dev *dev, void *rec_msg)
 }
 
 static int
-mbox_up_handler_rep_repte_notify(struct dev *dev, struct rep_repte_req *req, struct msg_rsp *rsp)
+mbox_up_handler_rep_event_up_notify(struct dev *dev, struct rep_event *req, struct msg_rsp *rsp)
 {
 	struct roc_eswitch_repte_notify_msg *notify_msg;
 	int rc = 0;
 
+	plt_base_dbg("mbox_up_handler_rep_event_up_notify");
 	plt_base_dbg("pf:%d/vf:%d msg id 0x%x (%s) from: pf:%d/vf:%d", dev_get_pf(dev->pf_func),
 		     dev_get_vf(dev->pf_func), req->hdr.id, mbox_id2name(req->hdr.id),
 		     dev_get_pf(req->hdr.pcifunc), dev_get_vf(req->hdr.pcifunc));
 
-	plt_base_dbg("repte pcifunc %x, enable %d", req->repte_pcifunc, req->enable);
 	if (dev->ops && dev->ops->repte_notify) {
 		notify_msg = plt_zmalloc(sizeof(struct roc_eswitch_repte_notify_msg), 0);
 		if (!notify_msg) {
@@ -560,49 +560,39 @@ mbox_up_handler_rep_repte_notify(struct dev *dev, struct rep_repte_req *req, str
 			rc = -ENOMEM;
 			goto fail;
 		}
-		notify_msg->type = ROC_ESWITCH_REPTE_STATE;
-		notify_msg->state.hw_func = req->repte_pcifunc;
-		notify_msg->state.enable = req->enable;
 
-		rc = dev->ops->repte_notify(dev->roc_nix, (void *)notify_msg);
-		if (rc < 0)
-			plt_err("Failed to sent new representee %x notification to %s",
-				req->repte_pcifunc, (req->enable == true) ? "enable" : "disable");
-
-		plt_free(notify_msg);
-	}
-fail:
-	rsp->hdr.rc = rc;
-	return rc;
-}
-
-static int
-mbox_up_handler_rep_set_mtu(struct dev *dev, struct rep_mtu *req, struct msg_rsp *rsp)
-{
-	struct roc_eswitch_repte_notify_msg *notify_msg;
-	int rc = 0;
-
-	plt_base_dbg("pf:%d/vf:%d msg id 0x%x (%s) from: pf:%d/vf:%d", dev_get_pf(dev->pf_func),
-		     dev_get_vf(dev->pf_func), req->hdr.id, mbox_id2name(req->hdr.id),
-		     dev_get_pf(req->hdr.pcifunc), dev_get_vf(req->hdr.pcifunc));
-
-	plt_base_dbg("rep pcifunc %x, rep id %d mtu %d", req->rep_pcifunc, req->rep_id, req->mtu);
-	if (dev->ops && dev->ops->repte_notify) {
-		notify_msg = plt_zmalloc(sizeof(struct roc_eswitch_repte_notify_msg), 0);
-		if (!notify_msg) {
-			plt_err("Failed to allocate memory");
-			rc = -ENOMEM;
+		switch (req->event) {
+		case RVU_EVENT_PORT_STATE:
+			plt_base_dbg("pcifunc %x, port_state %d", req->pcifunc,
+				     req->evt_data.port_state);
+			notify_msg->type = ROC_ESWITCH_LINK_STATE;
+			notify_msg->link.hw_func = req->pcifunc;
+			notify_msg->link.enable = req->evt_data.port_state;
+			break;
+		case RVU_EVENT_PFVF_STATE:
+			plt_base_dbg("pcifunc %x, repte_state %d", req->pcifunc,
+				     req->evt_data.vf_state);
+			notify_msg->type = ROC_ESWITCH_REPTE_STATE;
+			notify_msg->state.hw_func = req->pcifunc;
+			notify_msg->state.enable = req->evt_data.vf_state;
+			break;
+		case RVU_EVENT_MTU_CHANGE:
+			plt_base_dbg("pcifunc %x, mtu val %d", req->pcifunc, req->evt_data.mtu);
+			notify_msg->type = ROC_ESWITCH_REPTE_MTU;
+			notify_msg->mtu.hw_func = req->pcifunc;
+			notify_msg->mtu.mtu = req->evt_data.mtu;
+			break;
+		default:
+			plt_err("Unknown event type %u", req->event);
+			plt_free(notify_msg);
+			rc = -EINVAL;
 			goto fail;
 		}
-		notify_msg->type = ROC_ESWITCH_REPTE_MTU;
-		notify_msg->mtu.hw_func = req->rep_pcifunc;
-		notify_msg->mtu.rep_id = req->rep_id;
-		notify_msg->mtu.mtu = req->mtu;
 
 		rc = dev->ops->repte_notify(dev->roc_nix, (void *)notify_msg);
 		if (rc < 0)
-			plt_err("Failed to send new mtu notification for representee %x ",
-				req->rep_pcifunc);
+			plt_err("Failed to send notification type %x for representee %x",
+				notify_msg->type, notify_msg->state.hw_func);
 
 		plt_free(notify_msg);
 	}
diff --git a/drivers/common/cnxk/roc_eswitch.h b/drivers/common/cnxk/roc_eswitch.h
index b701ea69ee..45400ae77a 100644
--- a/drivers/common/cnxk/roc_eswitch.h
+++ b/drivers/common/cnxk/roc_eswitch.h
@@ -10,6 +10,7 @@
 
 typedef enum roc_eswitch_repte_notify_msg_type {
 	ROC_ESWITCH_REPTE_STATE = 0,
+	ROC_ESWITCH_LINK_STATE,
 	ROC_ESWITCH_REPTE_MTU,
 } roc_eswitch_repte_notify_msg_type_t;
 
@@ -18,6 +19,11 @@ struct roc_eswitch_repte_state {
 	uint16_t hw_func;
 };
 
+struct roc_eswitch_link_state {
+	bool enable;
+	uint16_t hw_func;
+};
+
 struct roc_eswitch_repte_mtu {
 	uint16_t mtu;
 	uint16_t rep_id;
@@ -28,6 +34,7 @@ struct roc_eswitch_repte_notify_msg {
 	roc_eswitch_repte_notify_msg_type_t type;
 	union {
 		struct roc_eswitch_repte_state state;
+		struct roc_eswitch_link_state link;
 		struct roc_eswitch_repte_mtu mtu;
 	};
 };
diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h
index dd65946e9e..0864c0e8c0 100644
--- a/drivers/common/cnxk/roc_mbox.h
+++ b/drivers/common/cnxk/roc_mbox.h
@@ -361,9 +361,7 @@ struct mbox_msghdr {
 
 #define MBOX_UP_MCS_MESSAGES M(MCS_INTR_NOTIFY, 0xE00, mcs_intr_notify, mcs_intr_info, msg_rsp)
 
-#define MBOX_UP_REP_MESSAGES						       \
-M(REP_REPTE_NOTIFY, 0xEF1, rep_repte_notify, rep_repte_req, msg_rsp)           \
-M(REP_SET_MTU, 0xEF2, rep_set_mtu, rep_mtu, msg_rsp)
+#define MBOX_UP_REP_MESSAGES M(REP_EVENT_UP_NOTIFY, 0xEF0, rep_event_up_notify, rep_event, msg_rsp)
 
 enum {
 #define M(_name, _id, _1, _2, _3) MBOX_MSG_##_name = _id,
@@ -2919,16 +2917,24 @@ struct nix_spi_to_sa_delete_req {
 	uint8_t __io way;
 };
 
-struct rep_repte_req {
-	struct mbox_msghdr hdr;
-	uint16_t __io repte_pcifunc;
-	bool __io enable;
+struct rep_evt_data {
+	uint8_t __io port_state;
+	uint8_t __io vf_state;
+	uint16_t __io rx_mode;
+	uint16_t __io rx_flags;
+	uint16_t __io mtu;
+	uint64_t __io rsvd[5];
 };
 
-struct rep_mtu {
+struct rep_event {
 	struct mbox_msghdr hdr;
-	uint16_t __io rep_pcifunc;
-	uint16_t __io rep_id;
-	uint16_t __io mtu;
+	uint16_t __io pcifunc;
+#define RVU_EVENT_PORT_STATE	 BIT_ULL(0)
+#define RVU_EVENT_PFVF_STATE	 BIT_ULL(1)
+#define RVU_EVENT_MTU_CHANGE	 BIT_ULL(2)
+#define RVU_EVENT_RX_MODE_CHANGE BIT_ULL(3)
+	uint16_t __io event;
+	struct rep_evt_data evt_data;
 };
+
 #endif /* __ROC_MBOX_H__ */
-- 
2.46.0.469.g4590f2e941


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/8] net/cnxk: common mbox for representor events
  2024-10-23 15:01 [PATCH 1/8] common/cnxk: common mbox for representor events Harman Kalra
@ 2024-10-23 15:01 ` Harman Kalra
  2024-10-23 15:01 ` [PATCH 3/8] common/cnxk: fix double free of flow aging resources Harman Kalra
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Harman Kalra @ 2024-10-23 15:01 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
	Harman Kalra
  Cc: dev, Ankur Dwivedi

From: Ankur Dwivedi <adwivedi@marvell.com>

Under a common mbox, multiple events can be received. These events are
processed by net driver based on event IDs.

Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
---
 drivers/net/cnxk/cnxk_rep.c | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/drivers/net/cnxk/cnxk_rep.c b/drivers/net/cnxk/cnxk_rep.c
index 652d419ad8..ddc688fdc2 100644
--- a/drivers/net/cnxk/cnxk_rep.c
+++ b/drivers/net/cnxk/cnxk_rep.c
@@ -253,12 +253,30 @@ cnxk_representee_state_msg_process(struct cnxk_eswitch_dev *eswitch_dev, uint16_
 
 static int
 cnxk_representee_mtu_msg_process(struct cnxk_eswitch_dev *eswitch_dev, uint16_t hw_func,
-				 uint16_t rep_id, uint16_t mtu)
+				 uint16_t mtu)
 {
+	struct cnxk_eswitch_devargs *esw_da;
 	struct cnxk_rep_dev *rep_dev = NULL;
 	struct rte_eth_dev *rep_eth_dev;
+	uint16_t rep_id = UINT16_MAX;
 	int rc = 0;
-	int i;
+	int i, j;
+
+	/* Traversing the initialized represented list */
+	for (i = 0; i < eswitch_dev->nb_esw_da; i++) {
+		esw_da = &eswitch_dev->esw_da[i];
+		for (j = 0; j < esw_da->nb_repr_ports; j++) {
+			if (esw_da->repr_hw_info[j].hw_func == hw_func) {
+				rep_id = esw_da->repr_hw_info[j].rep_id;
+				break;
+			}
+		}
+		if (rep_id != UINT16_MAX)
+			break;
+	}
+	/* No action on PF func for which representor has not been created */
+	if (rep_id == UINT16_MAX)
+		goto done;
 
 	for (i = 0; i < eswitch_dev->repr_cnt.nb_repr_probed; i++) {
 		rep_eth_dev = eswitch_dev->rep_info[i].rep_eth_dev;
@@ -289,17 +307,20 @@ cnxk_representee_msg_process(struct cnxk_eswitch_dev *eswitch_dev,
 
 	switch (notify_msg->type) {
 	case ROC_ESWITCH_REPTE_STATE:
-		plt_rep_dbg("	   type %d: hw_func %x action %s", notify_msg->type,
-			    notify_msg->state.hw_func,
+		plt_rep_dbg("	  REPTE STATE: hw_func %x action %s", notify_msg->state.hw_func,
 			    notify_msg->state.enable ? "enable" : "disable");
 		rc = cnxk_representee_state_msg_process(eswitch_dev, notify_msg->state.hw_func,
 							notify_msg->state.enable);
 		break;
+	case ROC_ESWITCH_LINK_STATE:
+		plt_rep_dbg("	  LINK STATE: hw_func %x action %s", notify_msg->link.hw_func,
+			    notify_msg->link.enable ? "enable" : "disable");
+		break;
 	case ROC_ESWITCH_REPTE_MTU:
-		plt_rep_dbg("	   type %d: hw_func %x rep_id %d mtu %d", notify_msg->type,
-			    notify_msg->mtu.hw_func, notify_msg->mtu.rep_id, notify_msg->mtu.mtu);
+		plt_rep_dbg("	   REPTE MTU: hw_func %x rep_id %d mtu %d", notify_msg->mtu.hw_func,
+			    notify_msg->mtu.rep_id, notify_msg->mtu.mtu);
 		rc = cnxk_representee_mtu_msg_process(eswitch_dev, notify_msg->mtu.hw_func,
-						      notify_msg->mtu.rep_id, notify_msg->mtu.mtu);
+						      notify_msg->mtu.mtu);
 		break;
 	default:
 		plt_err("Invalid notification msg received %d", notify_msg->type);
-- 
2.46.0.469.g4590f2e941


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/8] common/cnxk: fix double free of flow aging resources
  2024-10-23 15:01 [PATCH 1/8] common/cnxk: common mbox for representor events Harman Kalra
  2024-10-23 15:01 ` [PATCH 2/8] net/cnxk: " Harman Kalra
@ 2024-10-23 15:01 ` Harman Kalra
  2024-10-23 15:01 ` [PATCH 4/8] net/cnxk: fix eswitch multiseg Harman Kalra
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Harman Kalra @ 2024-10-23 15:01 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
	Harman Kalra
  Cc: dev

As part of npc tear down sequence flow aging resources are
cleaned up while they were already cleaned up when last flow
with aging action was removed. This leads to double free of
some resources.

Fixes: 85e9542d4700 ("common/cnxk: fix flow aging cleanup")

Signed-off-by: Harman Kalra <hkalra@marvell.com>
---
 drivers/common/cnxk/roc_npc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c
index 8a951b6360..2b3c90683c 100644
--- a/drivers/common/cnxk/roc_npc.c
+++ b/drivers/common/cnxk/roc_npc.c
@@ -389,7 +389,8 @@ roc_npc_fini(struct roc_npc *roc_npc)
 	struct npc *npc = roc_npc_to_npc_priv(roc_npc);
 	int rc;
 
-	npc_aging_ctrl_thread_destroy(roc_npc);
+	if (!roc_npc->flow_age.aged_flows_get_thread_exit)
+		npc_aging_ctrl_thread_destroy(roc_npc);
 
 	rc = npc_flow_free_all_resources(npc);
 	if (rc) {
-- 
2.46.0.469.g4590f2e941


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 4/8] net/cnxk: fix eswitch multiseg
  2024-10-23 15:01 [PATCH 1/8] common/cnxk: common mbox for representor events Harman Kalra
  2024-10-23 15:01 ` [PATCH 2/8] net/cnxk: " Harman Kalra
  2024-10-23 15:01 ` [PATCH 3/8] common/cnxk: fix double free of flow aging resources Harman Kalra
@ 2024-10-23 15:01 ` Harman Kalra
  2024-10-23 15:01 ` [PATCH 5/8] net/cnxk: append mark ID action Harman Kalra
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Harman Kalra @ 2024-10-23 15:01 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
	Harman Kalra
  Cc: dev

Data corruption is observed in case of VxLAN packets as the segment
data was not handled properly

Fixes: 6ad061cd74ad ("net/cnxk: support multi-segment in eswitch")

Signed-off-by: Harman Kalra <hkalra@marvell.com>
---
 drivers/net/cnxk/cnxk_eswitch_rxtx.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/net/cnxk/cnxk_eswitch_rxtx.c b/drivers/net/cnxk/cnxk_eswitch_rxtx.c
index 6df4ecd762..832c4e5d5c 100644
--- a/drivers/net/cnxk/cnxk_eswitch_rxtx.c
+++ b/drivers/net/cnxk/cnxk_eswitch_rxtx.c
@@ -120,6 +120,7 @@ cnxk_eswitch_dev_tx_burst(struct cnxk_eswitch_dev *eswitch_dev, uint16_t qid,
 {
 	struct roc_nix_sq *sq = &eswitch_dev->txq[qid].sqs;
 	struct roc_nix_rq *rq = &eswitch_dev->rxq[qid].rqs;
+	uint64_t cmd[6 + CNXK_NIX_TX_MSEG_SG_DWORDS - 2];
 	uint16_t lmt_id, pkt = 0, nb_tx = 0;
 	struct nix_send_ext_s *send_hdr_ext;
 	struct nix_send_hdr_s *send_hdr;
@@ -128,11 +129,9 @@ cnxk_eswitch_dev_tx_burst(struct cnxk_eswitch_dev *eswitch_dev, uint16_t qid,
 	union nix_send_sg_s *sg;
 	uintptr_t lmt_base, pa;
 	int64_t fc_pkts, dw_m1;
-	uint64_t cmd_cn9k[16];
 	struct rte_mbuf *m;
 	rte_iova_t io_addr;
 	uint16_t segdw;
-	uint64_t *cmd;
 	uint64_t len;
 	uint8_t off;
 
@@ -149,12 +148,7 @@ cnxk_eswitch_dev_tx_burst(struct cnxk_eswitch_dev *eswitch_dev, uint16_t qid,
 	/* 2(HDR) + 2(EXT_HDR) + 1(SG) + 1(IOVA) = 6/2 - 1 = 2 */
 	dw_m1 = cn10k_nix_tx_ext_subs(flags) + 1;
 
-	if (roc_model_is_cn9k()) {
-		memset(cmd_cn9k, 0, sizeof(cmd_cn9k));
-		cmd = &cmd_cn9k[0];
-	} else {
-		cmd = (uint64_t *)lmt_base;
-	}
+	memset(cmd, 0, sizeof(cmd));
 
 	send_hdr = (struct nix_send_hdr_s *)&cmd[0];
 	send_hdr->w0.sq = sq->qid;
@@ -204,6 +198,7 @@ cnxk_eswitch_dev_tx_burst(struct cnxk_eswitch_dev *eswitch_dev, uint16_t qid,
 		if (roc_model_is_cn9k()) {
 			nix_cn9k_xmit_one(cmd, sq->lmt_addr, sq->io_addr, segdw);
 		} else {
+			cn10k_nix_xmit_mv_lmt_base(lmt_base, cmd, flags);
 			/* PA<6:4> = LMTST size-1 in units of 128 bits. Size of the first LMTST in
 			 * burst.
 			 */
-- 
2.46.0.469.g4590f2e941


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 5/8] net/cnxk: append mark ID action
  2024-10-23 15:01 [PATCH 1/8] common/cnxk: common mbox for representor events Harman Kalra
                   ` (2 preceding siblings ...)
  2024-10-23 15:01 ` [PATCH 4/8] net/cnxk: fix eswitch multiseg Harman Kalra
@ 2024-10-23 15:01 ` Harman Kalra
  2024-10-23 15:01 ` [PATCH 6/8] net/cnxk: support single flow dump Harman Kalra
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Harman Kalra @ 2024-10-23 15:01 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
	Harman Kalra
  Cc: dev

In case of represented port action corresponding to a representee,
a mark ID is appended to identify the flow.

Signed-off-by: Harman Kalra <hkalra@marvell.com>
---
 drivers/net/cnxk/cnxk_flow.c | 73 ++++++++++++++++++++++++------------
 1 file changed, 50 insertions(+), 23 deletions(-)

diff --git a/drivers/net/cnxk/cnxk_flow.c b/drivers/net/cnxk/cnxk_flow.c
index d3c20e8315..7c60e5200b 100644
--- a/drivers/net/cnxk/cnxk_flow.c
+++ b/drivers/net/cnxk/cnxk_flow.c
@@ -5,6 +5,9 @@
 #include <cnxk_rep.h>
 
 #define IS_REP_BIT 7
+
+#define TNL_DCP_MATCH_ID 5
+#define NRML_MATCH_ID	 1
 const struct cnxk_rte_flow_term_info term[] = {
 	[RTE_FLOW_ITEM_TYPE_ETH] = {ROC_NPC_ITEM_TYPE_ETH, sizeof(struct rte_flow_item_eth)},
 	[RTE_FLOW_ITEM_TYPE_VLAN] = {ROC_NPC_ITEM_TYPE_VLAN, sizeof(struct rte_flow_item_vlan)},
@@ -187,12 +190,43 @@ roc_npc_parse_sample_subaction(struct rte_eth_dev *eth_dev, const struct rte_flo
 	return 0;
 }
 
+static int
+append_mark_action(struct roc_npc_action *in_actions, uint8_t has_tunnel_pattern,
+		   uint64_t *free_allocs, int *act_cnt)
+{
+	struct rte_flow_action_mark *act_mark;
+	int i = *act_cnt, j = 0;
+
+	/* Add Mark action */
+	i++;
+	act_mark = plt_zmalloc(sizeof(struct rte_flow_action_mark), 0);
+	if (!act_mark) {
+		plt_err("Error allocation memory");
+		return -ENOMEM;
+	}
+
+	while (free_allocs[j] != 0)
+		j++;
+	free_allocs[j] = (uint64_t)act_mark;
+	/* Mark ID format: (tunnel type - VxLAN, Geneve << 6) | Tunnel decap */
+	act_mark->id =
+		has_tunnel_pattern ? ((has_tunnel_pattern << 6) | TNL_DCP_MATCH_ID) : NRML_MATCH_ID;
+	in_actions[i].type = ROC_NPC_ACTION_TYPE_MARK;
+	in_actions[i].conf = (struct rte_flow_action_mark *)act_mark;
+
+	plt_rep_dbg("Assigned mark ID %x", act_mark->id);
+
+	*act_cnt = i;
+
+	return 0;
+}
+
 static int
 representor_rep_portid_action(struct roc_npc_action *in_actions, struct rte_eth_dev *eth_dev,
 			      struct rte_eth_dev *portid_eth_dev,
 			      enum rte_flow_action_type act_type, uint8_t rep_pattern,
-			      uint16_t *dst_pf_func, bool is_rep, uint64_t *free_allocs,
-			      int *act_cnt)
+			      uint16_t *dst_pf_func, bool is_rep, uint8_t has_tunnel_pattern,
+			      uint64_t *free_allocs, int *act_cnt)
 {
 	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
 	struct rte_eth_dev *rep_eth_dev = portid_eth_dev;
@@ -203,7 +237,7 @@ representor_rep_portid_action(struct roc_npc_action *in_actions, struct rte_eth_
 	struct cnxk_rep_dev *rep_dev;
 	struct roc_npc *npc;
 	uint16_t vlan_tci;
-	int j = 0;
+	int j = 0, rc;
 
 	/* For inserting an action in the list */
 	int i = *act_cnt;
@@ -322,6 +356,11 @@ representor_rep_portid_action(struct roc_npc_action *in_actions, struct rte_eth_
 			in_actions[i].type = ROC_NPC_ACTION_TYPE_PORT_ID;
 			npc->rep_act_pf_func = rep_dev->hw_func;
 			*dst_pf_func = rep_dev->hw_func;
+
+			/* Append a mark action - needed to identify the flow */
+			rc = append_mark_action(in_actions, has_tunnel_pattern, free_allocs, &i);
+			if (rc)
+				return rc;
 		}
 	}
 done:
@@ -336,34 +375,21 @@ representor_portid_action(struct roc_npc_action *in_actions, struct rte_eth_dev
 			  int *act_cnt)
 {
 	struct rte_eth_dev *rep_eth_dev = portid_eth_dev;
-	struct rte_flow_action_mark *act_mark;
 	struct cnxk_rep_dev *rep_dev;
 	/* For inserting an action in the list */
-	int i = *act_cnt, j = 0;
+	int i = *act_cnt, rc;
 
 	rep_dev = cnxk_rep_pmd_priv(rep_eth_dev);
 
 	*dst_pf_func = rep_dev->hw_func;
 
-	/* Add Mark action */
-	i++;
-	act_mark = plt_zmalloc(sizeof(struct rte_flow_action_mark), 0);
-	if (!act_mark) {
-		plt_err("Error allocation memory");
-		return -ENOMEM;
-	}
-
-	while (free_allocs[j] != 0)
-		j++;
-	free_allocs[j] = (uint64_t)act_mark;
-	/* Mark ID format: (tunnel type - VxLAN, Geneve << 6) | Tunnel decap */
-	act_mark->id = has_tunnel_pattern ? ((has_tunnel_pattern << 6) | 5) : 1;
-	in_actions[i].type = ROC_NPC_ACTION_TYPE_MARK;
-	in_actions[i].conf = (struct rte_flow_action_mark *)act_mark;
+	rc = append_mark_action(in_actions, has_tunnel_pattern, free_allocs, &i);
+	if (rc)
+		return rc;
 
 	*act_cnt = i;
-	plt_rep_dbg("Rep port %d ID %d mark ID is %d rep_dev->hw_func 0x%x", rep_dev->port_id,
-		    rep_dev->rep_id, act_mark->id, rep_dev->hw_func);
+	plt_rep_dbg("Rep port %d ID %d rep_dev->hw_func 0x%x", rep_dev->port_id, rep_dev->rep_id,
+		    rep_dev->hw_func);
 
 	return 0;
 }
@@ -441,7 +467,8 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
 				if (representor_rep_portid_action(in_actions, eth_dev,
 								  portid_eth_dev, actions->type,
 								  rep_pattern, dst_pf_func, is_rep,
-								  free_allocs, &i)) {
+								  has_tunnel_pattern, free_allocs,
+								  &i)) {
 					plt_err("Representor port action set failed");
 					goto err_exit;
 				}
-- 
2.46.0.469.g4590f2e941


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 6/8] net/cnxk: support single flow dump
  2024-10-23 15:01 [PATCH 1/8] common/cnxk: common mbox for representor events Harman Kalra
                   ` (3 preceding siblings ...)
  2024-10-23 15:01 ` [PATCH 5/8] net/cnxk: append mark ID action Harman Kalra
@ 2024-10-23 15:01 ` Harman Kalra
  2024-10-23 15:01 ` [PATCH 7/8] common/cnxk: update representee RSS rule via PF Harman Kalra
  2024-10-23 15:01 ` [PATCH 8/8] net/cnxk: handle RSS action for representees Harman Kalra
  6 siblings, 0 replies; 8+ messages in thread
From: Harman Kalra @ 2024-10-23 15:01 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
	Harman Kalra
  Cc: dev

Adding support for single flow dump, as the user may want to
dump details for a single flow.

Signed-off-by: Harman Kalra <hkalra@marvell.com>
---
 drivers/net/cnxk/cnxk_flow.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/cnxk/cnxk_flow.c b/drivers/net/cnxk/cnxk_flow.c
index 7c60e5200b..75a10371b3 100644
--- a/drivers/net/cnxk/cnxk_flow.c
+++ b/drivers/net/cnxk/cnxk_flow.c
@@ -1094,11 +1094,8 @@ cnxk_flow_dev_dump_common(struct rte_eth_dev *eth_dev, struct rte_flow *flow, FI
 	}
 
 	if (flow != NULL) {
-		rte_flow_error_set(error, EINVAL,
-				   RTE_FLOW_ERROR_TYPE_HANDLE,
-				   NULL,
-				   "Invalid argument");
-		return -EINVAL;
+		roc_npc_flow_mcam_dump(file, npc, (struct roc_npc_flow *)flow);
+		return 0;
 	}
 
 	roc_npc_flow_dump(file, npc, -1);
-- 
2.46.0.469.g4590f2e941


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 7/8] common/cnxk: update representee RSS rule via PF
  2024-10-23 15:01 [PATCH 1/8] common/cnxk: common mbox for representor events Harman Kalra
                   ` (4 preceding siblings ...)
  2024-10-23 15:01 ` [PATCH 6/8] net/cnxk: support single flow dump Harman Kalra
@ 2024-10-23 15:01 ` Harman Kalra
  2024-10-23 15:01 ` [PATCH 8/8] net/cnxk: handle RSS action for representees Harman Kalra
  6 siblings, 0 replies; 8+ messages in thread
From: Harman Kalra @ 2024-10-23 15:01 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
	Harman Kalra
  Cc: dev

Adding support to update representee's RSS rule via PF ports.
Before updating the rule strict validation to check if requested
representee is part of PF port.

Signed-off-by: Harman Kalra <hkalra@marvell.com>
---
 drivers/common/cnxk/roc_eswitch.c  | 11 ++++++++
 drivers/common/cnxk/roc_eswitch.h  |  3 ++
 drivers/common/cnxk/roc_nix_priv.h |  8 ++++++
 drivers/common/cnxk/roc_nix_rss.c  | 45 ++++++++++++++++++++++--------
 drivers/common/cnxk/roc_npc.c      | 23 ++++++++-------
 drivers/common/cnxk/roc_npc.h      |  1 +
 drivers/common/cnxk/roc_npc_priv.h |  3 +-
 drivers/common/cnxk/version.map    |  1 +
 8 files changed, 72 insertions(+), 23 deletions(-)

diff --git a/drivers/common/cnxk/roc_eswitch.c b/drivers/common/cnxk/roc_eswitch.c
index c67b4090a5..6cae459065 100644
--- a/drivers/common/cnxk/roc_eswitch.c
+++ b/drivers/common/cnxk/roc_eswitch.c
@@ -387,3 +387,14 @@ roc_eswitch_nix_repte_stats(struct roc_nix *roc_nix, uint16_t pf_func, struct ro
 	mbox_put(mbox);
 	return rc;
 }
+
+int
+roc_eswitch_is_repte_pfs_vf(uint16_t rep_pffunc, uint16_t pf_pffunc)
+{
+	uint16_t rep_pf = dev_get_pf(rep_pffunc);
+
+	if (roc_model_is_cn20k())
+		return ((rep_pf << RVU_PFVF_PF_SHIFT_CN20K) == pf_pffunc);
+	else
+		return ((rep_pf << RVU_PFVF_PF_SHIFT) == pf_pffunc);
+}
diff --git a/drivers/common/cnxk/roc_eswitch.h b/drivers/common/cnxk/roc_eswitch.h
index 45400ae77a..5e4ba5d72a 100644
--- a/drivers/common/cnxk/roc_eswitch.h
+++ b/drivers/common/cnxk/roc_eswitch.h
@@ -43,6 +43,9 @@ struct roc_eswitch_repte_notify_msg {
 typedef int (*process_repte_notify_t)(void *roc_nix,
 				      struct roc_eswitch_repte_notify_msg *notify_msg);
 
+/* Generic */
+int __roc_api roc_eswitch_is_repte_pfs_vf(uint16_t rep_pffunc, uint16_t pf_pffunc);
+
 /* NPC */
 int __roc_api roc_eswitch_npc_mcam_rx_rule(struct roc_npc *roc_npc, struct roc_npc_flow *flow,
 					   uint16_t pcifunc, uint16_t vlan_tci,
diff --git a/drivers/common/cnxk/roc_nix_priv.h b/drivers/common/cnxk/roc_nix_priv.h
index 3fd6fcbe9f..eb64608885 100644
--- a/drivers/common/cnxk/roc_nix_priv.h
+++ b/drivers/common/cnxk/roc_nix_priv.h
@@ -488,4 +488,12 @@ int nix_tel_node_add_rq(struct roc_nix_rq *rq);
 int nix_tel_node_add_cq(struct roc_nix_cq *cq);
 int nix_tel_node_add_sq(struct roc_nix_sq *sq);
 
+/*
+ * RSS
+ */
+int nix_rss_reta_pffunc_set(struct roc_nix *roc_nix, uint8_t group,
+			    uint16_t reta[ROC_NIX_RSS_RETA_MAX], uint16_t pf_func);
+int nix_rss_flowkey_pffunc_set(struct roc_nix *roc_nix, uint8_t *alg_idx, uint32_t flowkey,
+			       uint8_t group, int mcam_index, uint16_t pf_func);
+
 #endif /* _ROC_NIX_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_nix_rss.c b/drivers/common/cnxk/roc_nix_rss.c
index fd1472e9b9..ac5df654ff 100644
--- a/drivers/common/cnxk/roc_nix_rss.c
+++ b/drivers/common/cnxk/roc_nix_rss.c
@@ -116,7 +116,7 @@ nix_cn9k_rss_reta_set(struct nix *nix, uint8_t group,
 
 static int
 nix_cn10k_rss_reta_set(struct nix *nix, uint8_t group, uint16_t reta[ROC_NIX_RSS_RETA_MAX],
-		       uint8_t lock_rx_ctx)
+		       uint8_t lock_rx_ctx, uint16_t pf_func)
 {
 	struct mbox *mbox = mbox_get((&nix->dev)->mbox);
 	struct nix_cn10k_aq_enq_req *req;
@@ -138,6 +138,9 @@ nix_cn10k_rss_reta_set(struct nix *nix, uint8_t group, uint16_t reta[ROC_NIX_RSS
 				goto exit;
 			}
 		}
+		if (pf_func)
+			req->hdr.pcifunc = pf_func;
+
 		req->rss.rq = reta[idx];
 		/* Fill AQ info */
 		req->qidx = (group * nix->reta_sz) + idx;
@@ -161,6 +164,8 @@ nix_cn10k_rss_reta_set(struct nix *nix, uint8_t group, uint16_t reta[ROC_NIX_RSS
 				goto exit;
 			}
 		}
+		if (pf_func)
+			req->hdr.pcifunc = pf_func;
 		req->rss.rq = reta[idx];
 		/* Fill AQ info */
 		req->qidx = (group * nix->reta_sz) + idx;
@@ -180,7 +185,7 @@ nix_cn10k_rss_reta_set(struct nix *nix, uint8_t group, uint16_t reta[ROC_NIX_RSS
 
 static int
 nix_rss_reta_set(struct nix *nix, uint8_t group, uint16_t reta[ROC_NIX_RSS_RETA_MAX],
-		 uint8_t lock_rx_ctx)
+		 uint8_t lock_rx_ctx, uint16_t pf_func)
 {
 	struct mbox *mbox = mbox_get((&nix->dev)->mbox);
 	struct nix_cn20k_aq_enq_req *req;
@@ -225,6 +230,8 @@ nix_rss_reta_set(struct nix *nix, uint8_t group, uint16_t reta[ROC_NIX_RSS_RETA_
 				goto exit;
 			}
 		}
+		if (pf_func)
+			req->hdr.pcifunc = pf_func;
 		req->rss.rq = reta[idx];
 		/* Fill AQ info */
 		req->qidx = (group * nix->reta_sz) + idx;
@@ -243,8 +250,8 @@ nix_rss_reta_set(struct nix *nix, uint8_t group, uint16_t reta[ROC_NIX_RSS_RETA_
 }
 
 int
-roc_nix_rss_reta_set(struct roc_nix *roc_nix, uint8_t group,
-		     uint16_t reta[ROC_NIX_RSS_RETA_MAX])
+nix_rss_reta_pffunc_set(struct roc_nix *roc_nix, uint8_t group, uint16_t reta[ROC_NIX_RSS_RETA_MAX],
+			uint16_t pf_func)
 {
 	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
 	int rc;
@@ -253,12 +260,11 @@ roc_nix_rss_reta_set(struct roc_nix *roc_nix, uint8_t group,
 		return NIX_ERR_PARAM;
 
 	if (roc_model_is_cn9k())
-		rc = nix_cn9k_rss_reta_set(nix, group, reta,
-					   roc_nix->lock_rx_ctx);
+		rc = nix_cn9k_rss_reta_set(nix, group, reta, roc_nix->lock_rx_ctx);
 	else if (roc_model_is_cn10k())
-		rc = nix_cn10k_rss_reta_set(nix, group, reta, roc_nix->lock_rx_ctx);
+		rc = nix_cn10k_rss_reta_set(nix, group, reta, roc_nix->lock_rx_ctx, pf_func);
 	else
-		rc = nix_rss_reta_set(nix, group, reta, roc_nix->lock_rx_ctx);
+		rc = nix_rss_reta_set(nix, group, reta, roc_nix->lock_rx_ctx, pf_func);
 	if (rc)
 		return rc;
 
@@ -267,8 +273,13 @@ roc_nix_rss_reta_set(struct roc_nix *roc_nix, uint8_t group,
 }
 
 int
-roc_nix_rss_reta_get(struct roc_nix *roc_nix, uint8_t group,
-		     uint16_t reta[ROC_NIX_RSS_RETA_MAX])
+roc_nix_rss_reta_set(struct roc_nix *roc_nix, uint8_t group, uint16_t reta[ROC_NIX_RSS_RETA_MAX])
+{
+	return nix_rss_reta_pffunc_set(roc_nix, group, reta, 0);
+}
+
+int
+roc_nix_rss_reta_get(struct roc_nix *roc_nix, uint8_t group, uint16_t reta[ROC_NIX_RSS_RETA_MAX])
 {
 	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
 
@@ -280,8 +291,8 @@ roc_nix_rss_reta_get(struct roc_nix *roc_nix, uint8_t group,
 }
 
 int
-roc_nix_rss_flowkey_set(struct roc_nix *roc_nix, uint8_t *alg_idx,
-			uint32_t flowkey, uint8_t group, int mcam_index)
+nix_rss_flowkey_pffunc_set(struct roc_nix *roc_nix, uint8_t *alg_idx, uint32_t flowkey,
+			   uint8_t group, int mcam_index, uint16_t pf_func)
 {
 	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
 	struct nix_rss_flowkey_cfg_rsp *rss_rsp;
@@ -297,6 +308,9 @@ roc_nix_rss_flowkey_set(struct roc_nix *roc_nix, uint8_t *alg_idx,
 	cfg = mbox_alloc_msg_nix_rss_flowkey_cfg(mbox);
 	if (cfg == NULL)
 		goto exit;
+	if (pf_func)
+		cfg->hdr.pcifunc = pf_func;
+
 	cfg->flowkey_cfg = flowkey;
 	cfg->mcam_index = mcam_index; /* -1 indicates default group */
 	cfg->group = group;	      /* 0 is default group */
@@ -311,6 +325,13 @@ roc_nix_rss_flowkey_set(struct roc_nix *roc_nix, uint8_t *alg_idx,
 	return rc;
 }
 
+int
+roc_nix_rss_flowkey_set(struct roc_nix *roc_nix, uint8_t *alg_idx, uint32_t flowkey, uint8_t group,
+			int mcam_index)
+{
+	return nix_rss_flowkey_pffunc_set(roc_nix, alg_idx, flowkey, group, mcam_index, 0);
+}
+
 int
 roc_nix_rss_default_setup(struct roc_nix *roc_nix, uint32_t flowkey)
 {
diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c
index 2b3c90683c..53f278c764 100644
--- a/drivers/common/cnxk/roc_npc.c
+++ b/drivers/common/cnxk/roc_npc.c
@@ -1053,9 +1053,9 @@ npc_rss_free_grp_get(struct npc *npc, uint32_t *pos)
 }
 
 int
-npc_rss_action_configure(struct roc_npc *roc_npc,
-			 const struct roc_npc_action_rss *rss, uint8_t *alg_idx,
-			 uint32_t *rss_grp, uint32_t mcam_id)
+npc_rss_action_configure(struct roc_npc *roc_npc, const struct roc_npc_action_rss *rss,
+			 uint8_t *alg_idx, uint32_t *rss_grp, uint32_t mcam_id,
+			 uint16_t rss_repte_pf_func)
 {
 	struct npc *npc = roc_npc_to_npc_priv(roc_npc);
 	struct roc_nix *roc_nix = roc_npc->roc_nix;
@@ -1098,7 +1098,7 @@ npc_rss_action_configure(struct roc_npc *roc_npc,
 	if (rc < 0 || rss_grp_idx == 0)
 		return -ENOSPC;
 
-	for (i = 0; i < rss->queue_num; i++) {
+	for (i = 0; (i < rss->queue_num) && !rss_repte_pf_func; i++) {
 		if (rss->queue[i] >= nix->nb_rx_queues) {
 			plt_err("queue id > max number of queues");
 			return -EINVAL;
@@ -1126,10 +1126,9 @@ npc_rss_action_configure(struct roc_npc *roc_npc,
 
 	rem = nix->reta_sz % rss->queue_num;
 	if (rem)
-		memcpy(&reta[i * rss->queue_num], rss->queue,
-		       rem * sizeof(uint16_t));
+		memcpy(&reta[i * rss->queue_num], rss->queue, rem * sizeof(uint16_t));
 
-	rc = roc_nix_rss_reta_set(roc_nix, *rss_grp, reta);
+	rc = nix_rss_reta_pffunc_set(roc_nix, *rss_grp, reta, rss_repte_pf_func);
 	if (rc) {
 		plt_err("Failed to init rss table rc = %d", rc);
 		return rc;
@@ -1137,8 +1136,8 @@ npc_rss_action_configure(struct roc_npc *roc_npc,
 
 	flowkey_cfg = roc_npc->flowkey_cfg_state;
 
-	rc = roc_nix_rss_flowkey_set(roc_nix, &flowkey_algx, flowkey_cfg,
-				     *rss_grp, mcam_id);
+	rc = nix_rss_flowkey_pffunc_set(roc_nix, &flowkey_algx, flowkey_cfg, *rss_grp, mcam_id,
+					rss_repte_pf_func);
 	if (rc) {
 		plt_err("Failed to set rss hash function rc = %d", rc);
 		return rc;
@@ -1170,7 +1169,8 @@ npc_rss_action_program(struct roc_npc *roc_npc,
 	for (; actions->type != ROC_NPC_ACTION_TYPE_END; actions++) {
 		if (actions->type == ROC_NPC_ACTION_TYPE_RSS) {
 			rss = (const struct roc_npc_action_rss *)actions->conf;
-			rc = npc_rss_action_configure(npc, rss, &alg_idx, &rss_grp, flow->mcam_id);
+			rc = npc_rss_action_configure(npc, rss, &alg_idx, &rss_grp, flow->mcam_id,
+						      actions->rss_repte_pf_func);
 			if (rc)
 				return rc;
 
@@ -1678,6 +1678,7 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 		goto set_rss_failed;
 	}
 	roc_npc->rep_npc = NULL;
+	roc_npc->rep_act_pf_func = 0;
 
 	if (flow->has_age_action)
 		npc_age_flow_list_entry_add(roc_npc, flow);
@@ -1700,6 +1701,7 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 
 set_rss_failed:
 	roc_npc->rep_npc = NULL;
+	roc_npc->rep_act_pf_func = 0;
 	if (flow->use_pre_alloc == 0) {
 		rc = roc_npc_mcam_free_entry(roc_npc, flow->mcam_id);
 		if (rc != 0) {
@@ -1712,6 +1714,7 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 	}
 err_exit:
 	roc_npc->rep_npc = NULL;
+	roc_npc->rep_act_pf_func = 0;
 	plt_free(flow);
 	return NULL;
 }
diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h
index 72aada84a1..bf8c65aa9c 100644
--- a/drivers/common/cnxk/roc_npc.h
+++ b/drivers/common/cnxk/roc_npc.h
@@ -203,6 +203,7 @@ enum roc_npc_action_type {
 struct roc_npc_action {
 	enum roc_npc_action_type type; /**< Action type. */
 	const void *conf;	       /**< Pointer to action configuration object. */
+	uint16_t rss_repte_pf_func;    /**< Per flow tmp var for rss representee pffunc */
 };
 
 struct roc_npc_action_sample {
diff --git a/drivers/common/cnxk/roc_npc_priv.h b/drivers/common/cnxk/roc_npc_priv.h
index 069c625911..e08a34d146 100644
--- a/drivers/common/cnxk/roc_npc_priv.h
+++ b/drivers/common/cnxk/roc_npc_priv.h
@@ -484,7 +484,8 @@ int npc_process_ipv6_field_hash(const struct roc_npc_flow_item_ipv6 *ipv6_spec,
 				const struct roc_npc_flow_item_ipv6 *ipv6_mask,
 				struct npc_parse_state *pst, uint8_t type);
 int npc_rss_action_configure(struct roc_npc *roc_npc, const struct roc_npc_action_rss *rss,
-			     uint8_t *alg_idx, uint32_t *rss_grp, uint32_t mcam_id);
+			     uint8_t *alg_idx, uint32_t *rss_grp, uint32_t mcam_id,
+			     uint16_t rss_repte_pf_func);
 int npc_rss_action_program(struct roc_npc *roc_npc, const struct roc_npc_action actions[],
 			   struct roc_npc_flow *flow);
 int npc_rss_group_free(struct npc *npc, struct roc_npc_flow *flow);
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 877333b80c..935be3584c 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -90,6 +90,7 @@ INTERNAL {
 	roc_dpi_enable;
 	roc_dpi_wait_queue_idle;
 	roc_error_msg_get;
+	roc_eswitch_is_repte_pfs_vf;
 	roc_eswitch_nix_process_repte_notify_cb_register;
 	roc_eswitch_nix_process_repte_notify_cb_unregister;
 	roc_eswitch_nix_repte_stats;
-- 
2.46.0.469.g4590f2e941


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 8/8] net/cnxk: handle RSS action for representees
  2024-10-23 15:01 [PATCH 1/8] common/cnxk: common mbox for representor events Harman Kalra
                   ` (5 preceding siblings ...)
  2024-10-23 15:01 ` [PATCH 7/8] common/cnxk: update representee RSS rule via PF Harman Kalra
@ 2024-10-23 15:01 ` Harman Kalra
  6 siblings, 0 replies; 8+ messages in thread
From: Harman Kalra @ 2024-10-23 15:01 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
	Harman Kalra
  Cc: dev

Flows installed via single queue'd port representors on behalf of
multiple queue'd gets installed as unicast flows, causing representee
application to loose RSS advantage. Handling the scenario by
appending a RSS action to flow action list if representee is configured
with multiple queues support.

Signed-off-by: Harman Kalra <hkalra@marvell.com>
---
 drivers/net/cnxk/cnxk_flow.c    | 80 ++++++++++++++++++++++++++++++---
 drivers/net/cnxk/cnxk_rep.c     |  9 +++-
 drivers/net/cnxk/cnxk_rep.h     |  5 ++-
 drivers/net/cnxk/cnxk_rep_msg.h |  2 +-
 4 files changed, 85 insertions(+), 11 deletions(-)

diff --git a/drivers/net/cnxk/cnxk_flow.c b/drivers/net/cnxk/cnxk_flow.c
index 75a10371b3..e42e2f8deb 100644
--- a/drivers/net/cnxk/cnxk_flow.c
+++ b/drivers/net/cnxk/cnxk_flow.c
@@ -221,12 +221,65 @@ append_mark_action(struct roc_npc_action *in_actions, uint8_t has_tunnel_pattern
 	return 0;
 }
 
+static int
+append_rss_action(struct cnxk_eth_dev *dev, struct roc_npc_action *in_actions, uint16_t nb_rxq,
+		  uint32_t *flowkey_cfg, uint64_t *free_allocs, uint16_t rss_repte_pf_func,
+		  int *act_cnt)
+{
+	struct roc_npc_action_rss *rss_conf;
+	int i = *act_cnt, j = 0, l, rc = 0;
+	uint16_t *queue_arr;
+
+	rss_conf = plt_zmalloc(sizeof(struct roc_npc_action_rss), 0);
+	if (!rss_conf) {
+		plt_err("Failed to allocate memory for rss conf");
+		rc = -ENOMEM;
+		goto fail;
+	}
+
+	/* Add RSS action */
+	rss_conf->queue_num = nb_rxq;
+	queue_arr = calloc(1, rss_conf->queue_num * sizeof(uint16_t));
+	if (!queue_arr) {
+		plt_err("Failed to allocate memory for rss queue");
+		rc = -ENOMEM;
+		goto free_rss;
+	}
+
+	for (l = 0; l < nb_rxq; l++)
+		queue_arr[l] = l;
+	rss_conf->queue = queue_arr;
+	rss_conf->key = NULL;
+	rss_conf->types = RTE_ETH_RSS_IP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_TCP;
+
+	i++;
+
+	in_actions[i].type = ROC_NPC_ACTION_TYPE_RSS;
+	in_actions[i].conf = (struct roc_npc_action_rss *)rss_conf;
+	in_actions[i].rss_repte_pf_func = rss_repte_pf_func;
+
+	npc_rss_flowkey_get(dev, &in_actions[i], flowkey_cfg,
+			    RTE_ETH_RSS_IP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_TCP);
+
+	*act_cnt = i;
+
+	while (free_allocs[j] != 0)
+		j++;
+	free_allocs[j] = (uint64_t)rss_conf;
+
+	return 0;
+free_rss:
+	rte_free(rss_conf);
+fail:
+	return rc;
+}
+
 static int
 representor_rep_portid_action(struct roc_npc_action *in_actions, struct rte_eth_dev *eth_dev,
 			      struct rte_eth_dev *portid_eth_dev,
 			      enum rte_flow_action_type act_type, uint8_t rep_pattern,
 			      uint16_t *dst_pf_func, bool is_rep, uint8_t has_tunnel_pattern,
-			      uint64_t *free_allocs, int *act_cnt)
+			      uint64_t *free_allocs, int *act_cnt, uint32_t *flowkey_cfg)
 {
 	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
 	struct rte_eth_dev *rep_eth_dev = portid_eth_dev;
@@ -361,6 +414,19 @@ representor_rep_portid_action(struct roc_npc_action *in_actions, struct rte_eth_
 			rc = append_mark_action(in_actions, has_tunnel_pattern, free_allocs, &i);
 			if (rc)
 				return rc;
+			/* Append RSS action if representee has RSS enabled */
+			if (rep_dev->nb_rxq > 1) {
+				/* PF can install rule for only its VF acting as representee */
+				if (rep_dev->hw_func &&
+				    roc_eswitch_is_repte_pfs_vf(rep_dev->hw_func,
+							roc_nix_get_pf_func(npc->roc_nix))) {
+					rc = append_rss_action(dev, in_actions, rep_dev->nb_rxq,
+							       flowkey_cfg, free_allocs,
+							       rep_dev->hw_func, &i);
+					if (rc)
+						return rc;
+				}
+			}
 		}
 	}
 done:
@@ -465,10 +531,9 @@ 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)) {
+					    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;
 				}
@@ -536,6 +601,7 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
 			rc = npc_rss_action_validate(eth_dev, attr, actions);
 			if (rc)
 				goto err_exit;
+
 			in_actions[i].type = ROC_NPC_ACTION_TYPE_RSS;
 			in_actions[i].conf = actions->conf;
 			npc_rss_flowkey_get(dev, &in_actions[i], flowkey_cfg,
@@ -856,8 +922,8 @@ cnxk_flow_create_common(struct rte_eth_dev *eth_dev, const struct rte_flow_attr
 			const struct rte_flow_action actions[], struct rte_flow_error *error,
 			bool is_rep)
 {
-	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_item_info in_pattern[ROC_NPC_ITEM_TYPE_END + 1] = {0};
+	struct roc_npc_action in_actions[ROC_NPC_MAX_ACTION_COUNT] = {0};
 	struct roc_npc_action_sample in_sample_action;
 	struct cnxk_rep_dev *rep_dev = NULL;
 	struct roc_npc_flow *flow = NULL;
diff --git a/drivers/net/cnxk/cnxk_rep.c b/drivers/net/cnxk/cnxk_rep.c
index ddc688fdc2..e536898d3a 100644
--- a/drivers/net/cnxk/cnxk_rep.c
+++ b/drivers/net/cnxk/cnxk_rep.c
@@ -29,12 +29,15 @@ switch_domain_id_allocate(struct cnxk_eswitch_dev *eswitch_dev, uint16_t pf)
 }
 
 int
-cnxk_rep_state_update(struct cnxk_eswitch_dev *eswitch_dev, uint16_t hw_func, uint16_t *rep_id)
+cnxk_rep_state_update(struct cnxk_eswitch_dev *eswitch_dev, uint32_t state, uint16_t *rep_id)
 {
 	struct cnxk_rep_dev *rep_dev = NULL;
 	struct rte_eth_dev *rep_eth_dev;
+	uint16_t hw_func, nb_rxq;
 	int i, rc = 0;
 
+	nb_rxq = state & 0xFFFF;
+	hw_func = (state >> 16) & 0xFFFF;
 	/* Delete the individual PFVF flows as common eswitch VF rule will be used. */
 	rc = cnxk_eswitch_flow_rules_delete(eswitch_dev, hw_func);
 	if (rc) {
@@ -61,8 +64,10 @@ cnxk_rep_state_update(struct cnxk_eswitch_dev *eswitch_dev, uint16_t hw_func, ui
 		}
 
 		rep_dev = cnxk_rep_pmd_priv(rep_eth_dev);
-		if (rep_dev->hw_func == hw_func && rep_dev->is_vf_active)
+		if (rep_dev->hw_func == hw_func && rep_dev->is_vf_active) {
 			rep_dev->native_repte = false;
+			rep_dev->nb_rxq = nb_rxq;
+		}
 	}
 
 	return 0;
diff --git a/drivers/net/cnxk/cnxk_rep.h b/drivers/net/cnxk/cnxk_rep.h
index aaae2d4e8f..b9601854ce 100644
--- a/drivers/net/cnxk/cnxk_rep.h
+++ b/drivers/net/cnxk/cnxk_rep.h
@@ -62,7 +62,10 @@ struct cnxk_rep_dev {
 	uint16_t rep_id;
 	uint16_t switch_domain_id;
 	struct cnxk_eswitch_dev *parent_dev;
+	/* Representee HW func */
 	uint16_t hw_func;
+	/* No of queues configured at representee */
+	uint16_t nb_rxq;
 	bool is_vf_active;
 	bool native_repte;
 	struct cnxk_rep_rxq *rxq;
@@ -130,7 +133,7 @@ int cnxk_rep_dev_close(struct rte_eth_dev *eth_dev);
 int cnxk_rep_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *stats);
 int cnxk_rep_stats_reset(struct rte_eth_dev *eth_dev);
 int cnxk_rep_flow_ops_get(struct rte_eth_dev *ethdev, const struct rte_flow_ops **ops);
-int cnxk_rep_state_update(struct cnxk_eswitch_dev *eswitch_dev, uint16_t hw_func, uint16_t *rep_id);
+int cnxk_rep_state_update(struct cnxk_eswitch_dev *eswitch_dev, uint32_t state, uint16_t *rep_id);
 int cnxk_rep_promiscuous_enable(struct rte_eth_dev *ethdev);
 int cnxk_rep_promiscuous_disable(struct rte_eth_dev *ethdev);
 int cnxk_rep_mac_addr_set(struct rte_eth_dev *eth_dev, struct rte_ether_addr *addr);
diff --git a/drivers/net/cnxk/cnxk_rep_msg.h b/drivers/net/cnxk/cnxk_rep_msg.h
index bfd9ce9c7b..f5cb636c6c 100644
--- a/drivers/net/cnxk/cnxk_rep_msg.h
+++ b/drivers/net/cnxk/cnxk_rep_msg.h
@@ -86,7 +86,7 @@ typedef struct cnxk_rep_msg_ack_data1 {
 typedef struct cnxk_rep_msg_ready_data {
 	uint8_t val;
 	uint16_t nb_ports;
-	uint16_t data[];
+	uint32_t data[];
 } __rte_packed cnxk_rep_msg_ready_data_t;
 
 /* Exit msg */
-- 
2.46.0.469.g4590f2e941


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-10-23 15:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-23 15:01 [PATCH 1/8] common/cnxk: common mbox for representor events Harman Kalra
2024-10-23 15:01 ` [PATCH 2/8] net/cnxk: " Harman Kalra
2024-10-23 15:01 ` [PATCH 3/8] common/cnxk: fix double free of flow aging resources Harman Kalra
2024-10-23 15:01 ` [PATCH 4/8] net/cnxk: fix eswitch multiseg Harman Kalra
2024-10-23 15:01 ` [PATCH 5/8] net/cnxk: append mark ID action Harman Kalra
2024-10-23 15:01 ` [PATCH 6/8] net/cnxk: support single flow dump Harman Kalra
2024-10-23 15:01 ` [PATCH 7/8] common/cnxk: update representee RSS rule via PF Harman Kalra
2024-10-23 15:01 ` [PATCH 8/8] net/cnxk: handle RSS action for representees Harman Kalra

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).