Skip to contentSkip to conversation

common/cnxk: support NPC flow on cn20k

PATCH Superseded [email protected] 4 participants 16 messages Oct 21, 2024 – Feb 6, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 common/cnxk: support NPC flow on cn20k

From: Satheesh Paul <[email protected]>

ROC changes to support NPC flow on cn20k.

---
 drivers/common/cnxk/roc_mbox.h          | 144 +++++-
 drivers/common/cnxk/roc_nix.h           |  18 +-
 drivers/common/cnxk/roc_nix_mcast.c     |  40 +-
 drivers/common/cnxk/roc_nix_vlan.c      |  66 ++-
 drivers/common/cnxk/roc_npc.c           |  58 ++-
 drivers/common/cnxk/roc_npc.h           |  59 ++-
 drivers/common/cnxk/roc_npc_mcam.c      | 602 +++++++++++++++++++-----
 drivers/common/cnxk/roc_npc_mcam_dump.c | 279 +++++++++--
 drivers/common/cnxk/roc_npc_priv.h      |  86 +++-
 drivers/common/cnxk/roc_npc_utils.c     | 340 ++++++++++---
 drivers/common/cnxk/version.map         |   1 +
 11 files changed, 1321 insertions(+), 372 deletions(-)
drivers/common/cnxk/roc_mbox.h +123 -21
index dd65946e9e..451589e7e5 100644
@@ -234,6 +234,22 @@ struct mbox_msghdr {
 	  npc_get_field_hash_info_req, npc_get_field_hash_info_rsp)            \
 	M(NPC_MCAM_GET_HIT_STATUS, 0x6015, npc_mcam_get_hit_status,            \
 	  npc_mcam_get_hit_status_req, npc_mcam_get_hit_status_rsp)            \
+	M(NPC_MCAM_DEFRAG, 0x6016, npc_defrag, msg_req,	msg_rsp)               \
+	M(NPC_CN20K_GET_KEX_CFG, 0x6017, npc_cn20k_get_kex_cfg, msg_req,       \
+	  npc_cn20k_get_kex_cfg_rsp)                                           \
+	M(NPC_CN20K_MCAM_GET_FREE_COUNT, 0x6018, npc_cn20k_get_free_count,     \
+	  msg_req, npc_cn20k_get_free_count_rsp)                               \
+	M(NPC_CN20K_MCAM_WRITE_ENTRY,	0x6019, npc_cn20k_mcam_write_entry,    \
+	  npc_cn20k_mcam_write_entry_req, msg_rsp)	                       \
+	M(NPC_CN20K_MCAM_ALLOC_AND_WRITE_ENTRY, 0x601a,			       \
+	  npc_cn20k_mcam_alloc_and_write_entry,				       \
+	  npc_cn20k_mcam_alloc_and_write_entry_req,			       \
+	  npc_mcam_alloc_and_write_entry_rsp)				       \
+	M(NPC_CN20K_MCAM_READ_ENTRY,	0x601b, npc_cn20k_mcam_read_entry,     \
+	  npc_mcam_read_entry_req, npc_cn20k_mcam_read_entry_rsp)	       \
+	M(NPC_CN20K_MCAM_READ_BASE_RULE, 0x601c,                               \
+	  npc_cn20k_read_base_steer_rule, msg_req,                             \
+	  npc_cn20k_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)                                                    \
@@ -637,7 +653,7 @@ struct cgx_mac_addr_add_req {
  */
 struct cgx_mac_addr_add_rsp {
 	struct mbox_msghdr hdr;
-	uint8_t __io index;
+	uint32_t __io index;
 };
 
 /* Structure for requesting the operation to
@@ -645,7 +661,7 @@ struct cgx_mac_addr_add_rsp {
  */
 struct cgx_mac_addr_del_req {
 	struct mbox_msghdr hdr;
-	uint8_t __io index;
+	uint32_t __io index;
 };
 
 /* Structure for response against the operation to
@@ -653,7 +669,7 @@ struct cgx_mac_addr_del_req {
  */
 struct cgx_max_dmac_entries_get_rsp {
 	struct mbox_msghdr hdr;
-	uint8_t __io max_dmac_filters;
+	uint32_t __io max_dmac_filters;
 };
 
 struct cgx_link_user_info {
@@ -2433,6 +2449,14 @@ enum npc_af_status {
 	NPC_MCAM_ALLOC_FAILED = -703,
 	NPC_MCAM_PERM_DENIED = -704,
 	NPC_AF_ERR_HIGIG_CONFIG_FAIL = -705,
+	NPC_AF_ERR_HIGIG_NOT_SUPPORTED = -706,
+	NPC_FLOW_INTF_INVALID = -707,
+	NPC_FLOW_CHAN_INVALID = -708,
+	NPC_FLOW_NO_NIXLF = -709,
+	NPC_FLOW_NOT_SUPPORTED = -710,
+	NPC_FLOW_VF_PERM_DENIED = -711,
+	NPC_FLOW_VF_NOT_INIT = -712,
+	NPC_FLOW_VF_OVERLAP = -713,
 };
 
 struct npc_mcam_alloc_entry_req {
@@ -2442,9 +2466,12 @@ struct npc_mcam_alloc_entry_req {
 #define NPC_MCAM_ANY_PRIO    0
 #define NPC_MCAM_LOWER_PRIO  1
 #define NPC_MCAM_HIGHER_PRIO 2
-	uint8_t __io priority; /* Lower or higher w.r.t ref_entry */
+	uint8_t __io ref_priority; /* Lower or higher w.r.t ref_entry */
 	uint16_t __io ref_entry;
 	uint16_t __io count; /* Number of entries requested */
+	uint8_t __io kw_type; /* Key type */
+	uint8_t __io virt;    /* Request virtual index */
+	uint16_t __io rsvd[16];	/* Reserved */
 };
 
 struct npc_mcam_alloc_entry_rsp {
@@ -2456,6 +2483,7 @@ struct npc_mcam_alloc_entry_rsp {
 	uint16_t __io count;	  /* Number of entries allocated */
 	uint16_t __io free_count; /* Number of entries available */
 	uint16_t __io entry_list[NPC_MAX_NONCONTIG_ENTRIES];
+	uint16_t __io rsvd[16];	/* Reserved */
 };
 
 struct npc_mcam_free_entry_req {
@@ -2482,6 +2510,26 @@ struct npc_mcam_write_entry_req {
 	uint8_t __io set_cntr;	   /* Set counter for this entry ? */
 };
 
+struct cn20k_mcam_entry {
+#define NPC_CN20K_MAX_KWS_IN_KEY 8 /* Number of keywords in max keywidth */
+	uint64_t __io kw[NPC_CN20K_MAX_KWS_IN_KEY];
+	uint64_t __io kw_mask[NPC_CN20K_MAX_KWS_IN_KEY];
+	uint64_t __io action;
+	uint64_t __io vtag_action;
+};
+
+struct npc_cn20k_mcam_write_entry_req {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry_data;
+	uint16_t __io entry;	   /* MCAM entry to write this match key */
+	uint16_t __io cntr;	   /* Counter for this MCAM entry */
+	uint8_t __io intf;	   /* Rx or Tx interface */
+	uint8_t __io enable_entry; /* Enable this MCAM entry ? */
+	uint8_t __io hw_prio;	   /* hardware priority, valid for cn20k */
+	uint8_t __io req_kw_type;  /* Type of kw which should be written */
+	uint64_t __io reserved;	   /* reserved for future use */
+};
+
 /* Enable/Disable a given entry */
 struct npc_mcam_ena_dis_entry_req {
 	struct mbox_msghdr hdr;
@@ -2541,12 +2589,25 @@ struct npc_mcam_alloc_and_write_entry_req {
 	struct mbox_msghdr hdr;
 	struct mcam_entry entry_data;
 	uint16_t __io ref_entry;
-	uint8_t __io priority;	   /* Lower or higher w.r.t ref_entry */
+	uint8_t __io ref_priority; /* Lower or higher w.r.t ref_entry */
 	uint8_t __io intf;	   /* Rx or Tx interface */
 	uint8_t __io enable_entry; /* Enable this MCAM entry ? */
 	uint8_t __io alloc_cntr;   /* Allocate counter and map ? */
 };
 
+struct npc_cn20k_mcam_alloc_and_write_entry_req {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry_data;
+	uint16_t __io ref_entry;
+	uint8_t __io ref_prio;	   /* Lower or higher w.r.t ref_entry */
+	uint8_t __io intf;	   /* Rx or Tx interface */
+	uint8_t __io enable_entry; /* Enable this MCAM entry ? */
+	uint8_t __io hw_prio;	   /* hardware priority, valid for cn20k */
+	uint8_t __io virt;	   /* Allocate virtual index */
+	uint8_t __io req_kw_type;  /* Key type to be written */
+	uint16_t __io reserved[4]; /* reserved for future use */
+};
+
 struct npc_mcam_alloc_and_write_entry_rsp {
 	struct mbox_msghdr hdr;
 	uint16_t __io entry;
@@ -2573,6 +2634,48 @@ struct npc_get_kex_cfg_rsp {
 	uint8_t __io mkex_pfl_name[MKEX_NAME_LEN];
 };
 
+struct npc_delete_flow_rsp {
+	struct mbox_msghdr hdr;
+	uint16_t __io cntr_val;
+};
+
+/* Available entries to use */
+struct npc_cn20k_get_free_count_rsp {
+	struct mbox_msghdr hdr;
+	int __io free_x2;
+	int __io free_x4;
+	int __io free_subbanks;
+};
+
+struct npc_cn20k_get_kex_cfg_rsp {
+	struct mbox_msghdr hdr;
+	uint64_t __io rx_keyx_cfg; /* NPC_AF_INTF(0)_KEX_CFG */
+	uint64_t __io tx_keyx_cfg; /* NPC_AF_INTF(1)_KEX_CFG */
+#define NPC_MAX_EXTRACTOR 24
+	/* MKEX Extractor data */
+	uint64_t __io intf_extr[NPC_MAX_INTF][NPC_MAX_EXTRACTOR];
+	/* KEX configuration per extractor */
+	uint64_t __io intf_extr_lt[NPC_MAX_INTF][NPC_MAX_EXTRACTOR][NPC_MAX_LT];
+#define MKEX_NAME_LEN 128
+	uint8_t __io mkex_pfl_name[MKEX_NAME_LEN];
+};
+
+struct npc_get_field_hash_info_req {
+	struct mbox_msghdr hdr;
+	uint8_t intf;
+};
+
+struct npc_get_field_hash_info_rsp {
+	struct mbox_msghdr hdr;
+	uint64_t __io secret_key[3];
+#define NPC_MAX_HASH	  2
+#define NPC_MAX_HASH_MASK 2
+	/* NPC_AF_INTF(0..1)_HASH(0..1)_MASK(0..1) */
+	uint64_t __io hash_mask[NPC_MAX_INTF][NPC_MAX_HASH][NPC_MAX_HASH_MASK];
+	/* NPC_AF_INTF(0..1)_HASH(0..1)_RESULT_CTRL */
+	uint64_t __io hash_ctrl[NPC_MAX_INTF][NPC_MAX_HASH];
+};
+
 enum header_fields {
 	NPC_DMAC,
 	NPC_SMAC,
@@ -2662,6 +2765,8 @@ struct npc_install_flow_req {
 	uint8_t __io vtag1_op;
 	/* old counter value */
 	uint16_t __io cntr_val;
+	/* hardware priority, supported for cn20k */
+	uint8_t __io hw_prio;
 };
 
 struct npc_install_flow_rsp {
@@ -2692,11 +2797,24 @@ struct npc_mcam_read_entry_rsp {
 	uint8_t __io enable;
 };
 
+struct npc_cn20k_mcam_read_entry_rsp {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry_data;
+	uint8_t __io intf;
+	uint8_t __io enable;
+	uint8_t __io hw_prio; /* valid for cn20k */
+};
+
 struct npc_mcam_read_base_rule_rsp {
 	struct mbox_msghdr hdr;
 	struct mcam_entry entry_data;
 };
 
+struct npc_cn20k_mcam_read_base_rule_rsp {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry;
+};
+
 struct npc_mcam_get_stats_req {
 	struct mbox_msghdr hdr;
 	uint16_t __io entry; /* mcam entry */
@@ -2776,22 +2894,6 @@ enum tim_gpio_edge {
 	TIM_GPIO_INVALID,
 };
 
-struct npc_get_field_hash_info_req {
-	struct mbox_msghdr hdr;
-	uint8_t intf;
-};
-
-struct npc_get_field_hash_info_rsp {
-	struct mbox_msghdr hdr;
-	uint64_t __io secret_key[3];
-#define NPC_MAX_HASH	  2
-#define NPC_MAX_HASH_MASK 2
-	/* NPC_AF_INTF(0..1)_HASH(0..1)_MASK(0..1) */
-	uint64_t __io hash_mask[NPC_MAX_INTF][NPC_MAX_HASH][NPC_MAX_HASH_MASK];
-	/* NPC_AF_INTF(0..1)_HASH(0..1)_RESULT_CTRL */
-	uint64_t __io hash_ctrl[NPC_MAX_INTF][NPC_MAX_HASH];
-};
-
 enum ptp_op {
 	PTP_OP_ADJFINE = 0,   /* adjfine(req.scaled_ppm); */
 	PTP_OP_GET_CLOCK = 1, /* rsp.clk = get_clock() */
drivers/common/cnxk/roc_nix.h +6 -12
index f213823b9b..15823ab16c 100644
@@ -983,15 +983,11 @@ bool __roc_api roc_nix_ptp_is_enable(struct roc_nix *roc_nix);
 /* VLAN */
 int __roc_api
 roc_nix_vlan_mcam_entry_read(struct roc_nix *roc_nix, uint32_t index,
-			     struct npc_mcam_read_entry_rsp **rsp);
-int __roc_api roc_nix_vlan_mcam_entry_write(struct roc_nix *roc_nix,
-					    uint32_t index,
-					    struct mcam_entry *entry,
+			     void **rsp);
+int __roc_api roc_nix_vlan_mcam_entry_write(struct roc_nix *roc_nix, uint32_t index, void *entry,
 					    uint8_t intf, uint8_t enable);
-int __roc_api roc_nix_vlan_mcam_entry_alloc_and_write(struct roc_nix *roc_nix,
-						      struct mcam_entry *entry,
-						      uint8_t intf,
-						      uint8_t priority,
+int __roc_api roc_nix_vlan_mcam_entry_alloc_and_write(struct roc_nix *roc_nix, void *entry,
+						      uint8_t intf, uint8_t priority,
 						      uint8_t ref_entry);
 int __roc_api roc_nix_vlan_mcam_entry_free(struct roc_nix *roc_nix,
 					   uint32_t index);
@@ -1012,10 +1008,8 @@ int __roc_api roc_nix_mcast_mcam_entry_alloc(struct roc_nix *roc_nix,
 					     uint16_t index[]);
 int __roc_api roc_nix_mcast_mcam_entry_free(struct roc_nix *roc_nix,
 					    uint32_t index);
-int __roc_api roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix,
-					     struct mcam_entry *entry,
-					     uint32_t index, uint8_t intf,
-					     uint64_t action);
+int __roc_api roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix, void *entry, uint32_t index,
+					     uint8_t intf, uint64_t action);
 int __roc_api roc_nix_mcast_mcam_entry_ena_dis(struct roc_nix *roc_nix, uint32_t index,
 					       bool enable);
 int __roc_api roc_nix_mcast_list_setup(struct mbox *mbox, uint8_t intf, int nb_entries,
drivers/common/cnxk/roc_nix_mcast.c +27 -13
index 615014e820..eab4bde743 100644
@@ -19,7 +19,7 @@ roc_nix_mcast_mcam_entry_alloc(struct roc_nix *roc_nix, uint16_t nb_entries,
 	req = mbox_alloc_msg_npc_mcam_alloc_entry(mbox);
 	if (req == NULL)
 		goto exit;
-	req->priority = priority;
+	req->ref_priority = priority;
 	req->count = nb_entries;
 
 	rc = mbox_process_msg(mbox, (void *)&rsp);
@@ -56,24 +56,38 @@ roc_nix_mcast_mcam_entry_free(struct roc_nix *roc_nix, uint32_t index)
 }
 
 int
-roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix,
-			       struct mcam_entry *entry, uint32_t index,
-			       uint8_t intf, uint64_t action)
+roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix, void *entry, uint32_t index, uint8_t intf,
+			       uint64_t action)
 {
 	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
 	struct dev *dev = &nix->dev;
 	struct mbox *mbox = mbox_get(dev->mbox);
-	struct npc_mcam_write_entry_req *req;
 	int rc = -ENOSPC;
 
-	req = mbox_alloc_msg_npc_mcam_write_entry(mbox);
-	if (req == NULL)
-		goto exit;
-	req->entry = index;
-	req->intf = intf;
-	req->enable_entry = true;
-	mbox_memcpy(&req->entry_data, entry, sizeof(struct mcam_entry));
-	req->entry_data.action = action;
+	if (roc_model_is_cn20k()) {
+		struct npc_cn20k_mcam_write_entry_req *req;
+
+		req = mbox_alloc_msg_npc_cn20k_mcam_write_entry(mbox);
+		if (req == NULL)
+			goto exit;
+		req->entry = index;
+		req->intf = intf;
+		req->enable_entry = true;
+		mbox_memcpy(&req->entry_data, entry, sizeof(struct cn20k_mcam_entry));
+		req->entry_data.action = action;
+
+	} else {
+		struct npc_mcam_write_entry_req *req;
+
+		req = mbox_alloc_msg_npc_mcam_write_entry(mbox);
+		if (req == NULL)
+			goto exit;
+		req->entry = index;
+		req->intf = intf;
+		req->enable_entry = true;
+		mbox_memcpy(&req->entry_data, entry, sizeof(struct mcam_entry));
+		req->entry_data.action = action;
+	}
 
 	rc = mbox_process(mbox);
 exit:
drivers/common/cnxk/roc_nix_vlan.c +45 -21

101 lines not on this page · raw message

drivers/common/cnxk/roc_npc.c +44 -14

96 lines not on this page · raw message

drivers/common/cnxk/roc_npc.h +34 -25

123 lines not on this page · raw message

drivers/common/cnxk/roc_npc_mcam.c +473 -129

861 lines not on this page · raw message

drivers/common/cnxk/roc_npc_mcam_dump.c +232 -47

380 lines not on this page · raw message

drivers/common/cnxk/roc_npc_priv.h +60 -26

169 lines not on this page · raw message

drivers/common/cnxk/roc_npc_utils.c +276 -64

445 lines not on this page · raw message

drivers/common/cnxk/version.map +1 -0
index 6f8a2e02da..a5a7b1f70f 100644
@@ -480,6 +480,7 @@ INTERNAL {
 	roc_npc_mcam_free_counter;
 	roc_npc_mcam_free;
 	roc_npc_mcam_free_entry;
+	roc_npc_mcam_get_stats;
 	roc_npc_mcam_init;
 	roc_npc_mcam_move;
 	roc_npc_mcam_merge_base_steering_rule;
Signature · 1 line
2.39.2
#1 lore raw

PATCH 2/2 net/cnxk: support rte flow on cn20k

From: Satheesh Paul <[email protected]>

Support for rte flow in cn20k.

---
 drivers/net/cnxk/cn10k_ethdev.c        |   8 +-
 drivers/net/cnxk/cn10k_flow.h          |  21 --
 drivers/net/cnxk/cn20k_ethdev.c        |   4 +
 drivers/net/cnxk/cnxk_ethdev_devargs.c |  10 +-
 drivers/net/cnxk/cnxk_flow.c           |  10 +-
 drivers/net/cnxk/cnxk_flow_wrapper.c   | 303 +++++++++++++++++++++++++
 drivers/net/cnxk/cnxk_flow_wrapper.h   |  21 ++
 drivers/net/cnxk/meson.build           |  10 +-
 8 files changed, 355 insertions(+), 32 deletions(-)
 delete mode 100644 drivers/net/cnxk/cn10k_flow.h
 create mode 100644 drivers/net/cnxk/cnxk_flow_wrapper.c
 create mode 100644 drivers/net/cnxk/cnxk_flow_wrapper.h
drivers/net/cnxk/cn10k_ethdev.c +4 -4
index fbb9b09062..a4b3d56c61 100644
@@ -2,9 +2,9 @@
  * Copyright(C) 2021 Marvell.
  */
 #include "cn10k_ethdev.h"
-#include "cn10k_flow.h"
 #include "cn10k_rx.h"
 #include "cn10k_tx.h"
+#include "cnxk_flow_wrapper.h"
 
 static uint16_t
 nix_rx_offload_flags(struct rte_eth_dev *eth_dev)
@@ -913,9 +913,9 @@ npc_flow_ops_override(void)
 	init_once = 1;
 
 	/* Update platform specific ops */
-	cnxk_flow_ops.create = cn10k_flow_create;
-	cnxk_flow_ops.destroy = cn10k_flow_destroy;
-	cnxk_flow_ops.info_get = cn10k_flow_info_get;
+	cnxk_flow_ops.create = cnxk_flow_create_wrapper;
+	cnxk_flow_ops.destroy = cnxk_flow_destroy_wrapper;
+	cnxk_flow_ops.info_get = cnxk_flow_info_get_wrapper;
 }
 
 static int
drivers/net/cnxk/cn10k_flow.h deleted +0 -21
deleted file mode 100644
index 316b74e6a6..0000000000
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(C) 2020 Marvell.
- */
-#ifndef __CN10K_RTE_FLOW_H__
-#define __CN10K_RTE_FLOW_H__
-
-#include <rte_flow_driver.h>
-
-struct rte_flow *cn10k_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
-				   const struct rte_flow_item pattern[],
-				   const struct rte_flow_action actions[],
-				   struct rte_flow_error *error);
-int cn10k_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
-		       struct rte_flow_error *error);
-
-int cn10k_flow_info_get(struct rte_eth_dev *dev, struct rte_flow_port_info *port_info,
-			struct rte_flow_queue_info *queue_info, struct rte_flow_error *err);
-
-#define CN10K_NPC_COUNTERS_MAX 512
-
-#endif /* __CN10K_RTE_FLOW_H__ */
drivers/net/cnxk/cn20k_ethdev.c +4 -0
index 37c372d80f..e74dd88172 100644
@@ -4,6 +4,7 @@
 #include "cn20k_ethdev.h"
 #include "cn20k_rx.h"
 #include "cn20k_tx.h"
+#include "cnxk_flow_wrapper.h"
 
 static uint16_t
 nix_rx_offload_flags(struct rte_eth_dev *eth_dev)
@@ -867,6 +868,9 @@ npc_flow_ops_override(void)
 	init_once = 1;
 
 	/* Update platform specific ops */
+	cnxk_flow_ops.create = cnxk_flow_create_wrapper;
+	cnxk_flow_ops.destroy = cnxk_flow_destroy_wrapper;
+	cnxk_flow_ops.info_get = cnxk_flow_info_get_wrapper;
 }
 
 static int
drivers/net/cnxk/cnxk_ethdev_devargs.c +7 -3
index 5bd50bb9a1..bdf5d88b92 100644
@@ -88,8 +88,7 @@ parse_flow_max_priority(const char *key, const char *value, void *extra_args)
 
 	val = atoi(value);
 
-	/* Limit the max priority to 32 */
-	if (val < 1 || val > 32)
+	if (val < 1 || val > ROC_NPC_MAX_MCAM_PRIORITY)
 		return -EINVAL;
 
 	*(uint16_t *)extra_args = val;
@@ -390,7 +389,12 @@ cnxk_ethdev_parse_devargs(struct rte_devargs *devargs, struct cnxk_eth_dev *dev)
 		dev->nix.meta_buf_sz = meta_buf_sz;
 
 	dev->npc.flow_prealloc_size = flow_prealloc_size;
-	dev->npc.flow_max_priority = flow_max_priority;
+
+	if (roc_model_is_cn20k())
+		dev->npc.flow_max_priority = ROC_NPC_MAX_MCAM_PRIORITY;
+	else
+		dev->npc.flow_max_priority = flow_max_priority;
+
 	dev->npc.switch_header_type = switch_header_type;
 	dev->npc.sdp_channel = sdp_chan.channel;
 	dev->npc.sdp_channel_mask = sdp_chan.mask;
drivers/net/cnxk/cnxk_flow.c +7 -3
index d3c20e8315..887dd8f911 100644
@@ -990,10 +990,14 @@ cnxk_flow_query_common(struct rte_eth_dev *eth_dev, struct rte_flow *flow,
 		npc = &rep_dev->parent_dev->npc;
 	}
 
-	if (in_flow->use_pre_alloc)
+	if (in_flow->use_pre_alloc) {
 		rc = roc_npc_inl_mcam_read_counter(in_flow->ctr_id, &query->hits);
-	else
-		rc = roc_npc_mcam_read_counter(npc, in_flow->ctr_id, &query->hits);
+	} else {
+		if (roc_model_is_cn20k())
+			rc = roc_npc_mcam_get_stats(npc, in_flow, &query->hits);
+		else
+			rc = roc_npc_mcam_read_counter(npc, in_flow->ctr_id, &query->hits);
+	}
 	if (rc != 0) {
 		errcode = EIO;
 		errmsg = "Error reading flow counter";
drivers/net/cnxk/cnxk_flow_wrapper.c new file +303 -0

303 lines not on this page · raw message

drivers/net/cnxk/cnxk_flow_wrapper.h new file +21 -0
new file mode 100644
index 0000000000..506293dd51
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell.
+ */
+#ifndef __CNXK_FLOW_WRAPPER_H__
+#define __CNXK_FLOW_WRAPPER_H__
+
+#include <rte_flow_driver.h>
+
+struct rte_flow *cnxk_flow_create_wrapper(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
+					  const struct rte_flow_item pattern[],
+					  const struct rte_flow_action actions[],
+					  struct rte_flow_error *error);
+int cnxk_flow_destroy_wrapper(struct rte_eth_dev *dev, struct rte_flow *flow,
+			      struct rte_flow_error *error);
+
+int cnxk_flow_info_get_wrapper(struct rte_eth_dev *dev, struct rte_flow_port_info *port_info,
+			       struct rte_flow_queue_info *queue_info, struct rte_flow_error *err);
+
+#define CNXK_NPC_COUNTERS_MAX 512
+
+#endif /* __CNXK_FLOW_WRAPPER_H__ */
drivers/net/cnxk/meson.build +9 -1
index fcf48f600a..5b9e06e535 100644
@@ -18,6 +18,13 @@ if soc_type != 'cn9k' and soc_type != 'cn10k' and soc_type != 'cn20k'
         soc_type = 'all'
 endif
 
+if soc_type == 'cn10k' or soc_type == 'all'
+    dpdk_conf.set('CNXK_PLATFORM_CN10K', 1)
+elif soc_type == 'cn20k'
+    dpdk_conf.set('CNXK_PLATFORM_CN20K', 1)
+endif
+
+
 sources = files(
         'cnxk_ethdev.c',
         'cnxk_ethdev_cman.c',
@@ -146,9 +153,9 @@ if soc_type == 'cn10k' or soc_type == 'all'
 sources += files(
         'cn10k_ethdev.c',
         'cn10k_ethdev_sec.c',
-        'cn10k_flow.c',
         'cn10k_rx_select.c',
         'cn10k_tx_select.c',
+        'cnxk_flow_wrapper.c',
 )
 
 if host_machine.cpu_family().startswith('aarch') and not disable_template
@@ -238,6 +245,7 @@ sources += files(
         'cn20k_ethdev.c',
         'cn20k_rx_select.c',
         'cn20k_tx_select.c',
+        'cnxk_flow_wrapper.c',
 )
 
 if host_machine.cpu_family().startswith('aarch') and not disable_template
Signature · 1 line
2.39.2
#2 lore raw

Re: [dpdk-dev] [PATCH 2/2] net/cnxk: support rte flow on cn20k

Quoted 6 lines · On Mon, 21 Oct 2024 09:31:44 +0530 <[email protected]> wrote:

From: Satheesh Paul <[email protected]>

Support for rte flow in cn20k.

Quoted 13 lines
---
 drivers/net/cnxk/cn10k_ethdev.c        |   8 +-
 drivers/net/cnxk/cn10k_flow.h          |  21 --
 drivers/net/cnxk/cn20k_ethdev.c        |   4 +
 drivers/net/cnxk/cnxk_ethdev_devargs.c |  10 +-
 drivers/net/cnxk/cnxk_flow.c           |  10 +-
 drivers/net/cnxk/cnxk_flow_wrapper.c   | 303 +++++++++++++++++++++++++
 drivers/net/cnxk/cnxk_flow_wrapper.h   |  21 ++
 drivers/net/cnxk/meson.build           |  10 +-
 8 files changed, 355 insertions(+), 32 deletions(-)
 delete mode 100644 drivers/net/cnxk/cn10k_flow.h
 create mode 100644 drivers/net/cnxk/cnxk_flow_wrapper.c
 create mode 100644 drivers/net/cnxk/cnxk_flow_wrapper.h

Compiler erorrs.

*Build Failed #2:
OS: RHEL94-64
Target: x86_64-native-linuxapp-gcc
FAILED: drivers/libtmp_rte_common_cnxk.a.p/common_cnxk_roc_npc_mcam.c.o
gcc -Idrivers/libtmp_rte_common_cnxk.a.p -Idrivers -I../drivers -Idrivers/common/cnxk -I../drivers/common/cnxk -Idrivers/bus/pci -I../drivers/bus/pci -Ilib/net -I../lib/net -Ilib/ethdev -I../lib/ethdev -Ilib/meter -I../lib/meter -I. -I.. -Iconfig -I../config -Ilib/eal/include -I../lib/eal/include -Ilib/eal/linux/include -I../lib/eal/linux/include -Ilib/eal/x86/include -I../lib/eal/x86/include -Ilib/eal/common -I../lib/eal/common -Ilib/eal -I../lib/eal -Ilib/kvargs -I../lib/kvargs -Ilib/log -I../lib/log -Ilib/metrics -I../lib/metrics -Ilib/telemetry -I../lib/telemetry -Ilib/pci -I../lib/pci -I../drivers/bus/pci/linux -Ilib/mbuf -I../lib/mbuf -Ilib/mempool -I../lib/mempool -Ilib/ring -I../lib/ring -Ilib/security -I../lib/security -Ilib/cryptodev -I../lib/cryptodev -Ilib/rcu -I../lib/rcu -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -O3 -include rte_config.h -Wcast-qual -Wdeprecated -Wformat -Wformat-nonliteral -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wsign-compare -Wstrict-prototypes -Wundef -Wwrite-strings -Wno-address-of-packed-member -Wno-packed-not-aligned -Wno-missing-field-initializers -Wno-zero-length-bounds -D_GNU_SOURCE -fPIC -march=native -mrtm -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -Wno-format-truncation -DRTE_LOG_DEFAULT_LOGTYPE=pmd.common.cnxk -MD -MQ drivers/libtmp_rte_common_cnxk.a.p/common_cnxk_roc_npc_mcam.c.o -MF drivers/libtmp_rte_common_cnxk.a.p/common_cnxk_roc_npc_mcam.c.o.d -o drivers/libtmp_rte_common_cnxk.a.p/common_cnxk_roc_npc_mcam.c.o -c ../drivers/common/cnxk/roc_npc_mcam.c ../drivers/common/cnxk/roc_npc_mcam.c: In function ‘npc_mcam_write_entry’:
../drivers/common/cnxk/roc_npc_mcam.c:520:70: error: iteration 7 invokes undefined behavior [-Werror=aggressive-loop-optimizations]

  520 |                         cn20k_req->entry_data.kw[i] = mcam->mcam_data[i];
      |                                                       ~~~~~~~~~~~~~~~^~~

../drivers/common/cnxk/roc_npc_mcam.c:519:31: note: within this loop
519 | for (i = 0; i < NPC_CN20K_MCAM_KEY_X4_WORDS; i++) {
cc1: all warnings being treated as errors
[794/3044] Compiling C object drivers/libtmp_rte_common_cnxk.a.p/common_cnxk_roc_tim.c.o [795/3044] Compiling C object drivers/libtmp_rte_common_cnxk.a.p/common_cnxk_roc_utils.c.o [796/3044] Compiling C object drivers/libtmp_rte_common_cnxk.a.p/common_cnxk_roc_tim_irq.c.o [797/3044] Compiling C object drivers/libtmp_rte_common_cnxk.a.p/common_cnxk_cnxk_telemetry_bphy.c.o [798/3044] Compiling C object drivers/libtmp_rte_common_cnxk.a.p/common_cnxk_cnxk_telemetry_npa.c.o [799/3044] Compiling C object drivers/libtmp_rte_common_cnxk.a.p/common_cnxk_roc_ree.c.o [800/3044] Compiling C object drivers/libtmp_rte_common_cnxk.a.p/common_cnxk_cnxk_utils.c.o [801/3044] Compiling C object drivers/libtmp_rte_common_cnxk.a.p/common_cnxk_cnxk_security.c.o [802/3044] Compiling C object drivers/libtmp_rte_common_cnxk.a.p/common_cnxk_cnxk_telemetry_nix.c.o
ninja: build stopped

#3 lore raw

PATCH v2 1/2 common/cnxk: support NPC flow on cn20k

In reply to [email protected]

From: Satheesh Paul <[email protected]>

ROC changes to support NPC flow on cn20k.

---
v2:
* Fixed generic platform compiler error.

 drivers/common/cnxk/roc_mbox.h          | 144 +++++-
 drivers/common/cnxk/roc_nix.h           |  18 +-
 drivers/common/cnxk/roc_nix_mcast.c     |  40 +-
 drivers/common/cnxk/roc_nix_vlan.c      |  66 ++-
 drivers/common/cnxk/roc_npc.c           |  58 ++-
 drivers/common/cnxk/roc_npc.h           |  59 ++-
 drivers/common/cnxk/roc_npc_mcam.c      | 602 +++++++++++++++++++-----
 drivers/common/cnxk/roc_npc_mcam_dump.c | 279 +++++++++--
 drivers/common/cnxk/roc_npc_priv.h      |  91 ++--
 drivers/common/cnxk/roc_npc_utils.c     | 340 ++++++++++---
 drivers/common/cnxk/version.map         |   1 +
 11 files changed, 1325 insertions(+), 373 deletions(-)
drivers/common/cnxk/roc_mbox.h +123 -21
index 0864c0e8c0..cc96ca76a1 100644
@@ -234,6 +234,22 @@ struct mbox_msghdr {
 	  npc_get_field_hash_info_req, npc_get_field_hash_info_rsp)            \
 	M(NPC_MCAM_GET_HIT_STATUS, 0x6015, npc_mcam_get_hit_status,            \
 	  npc_mcam_get_hit_status_req, npc_mcam_get_hit_status_rsp)            \
+	M(NPC_MCAM_DEFRAG, 0x6016, npc_defrag, msg_req,	msg_rsp)               \
+	M(NPC_CN20K_GET_KEX_CFG, 0x6017, npc_cn20k_get_kex_cfg, msg_req,       \
+	  npc_cn20k_get_kex_cfg_rsp)                                           \
+	M(NPC_CN20K_MCAM_GET_FREE_COUNT, 0x6018, npc_cn20k_get_free_count,     \
+	  msg_req, npc_cn20k_get_free_count_rsp)                               \
+	M(NPC_CN20K_MCAM_WRITE_ENTRY,	0x6019, npc_cn20k_mcam_write_entry,    \
+	  npc_cn20k_mcam_write_entry_req, msg_rsp)	                       \
+	M(NPC_CN20K_MCAM_ALLOC_AND_WRITE_ENTRY, 0x601a,			       \
+	  npc_cn20k_mcam_alloc_and_write_entry,				       \
+	  npc_cn20k_mcam_alloc_and_write_entry_req,			       \
+	  npc_mcam_alloc_and_write_entry_rsp)				       \
+	M(NPC_CN20K_MCAM_READ_ENTRY,	0x601b, npc_cn20k_mcam_read_entry,     \
+	  npc_mcam_read_entry_req, npc_cn20k_mcam_read_entry_rsp)	       \
+	M(NPC_CN20K_MCAM_READ_BASE_RULE, 0x601c,                               \
+	  npc_cn20k_read_base_steer_rule, msg_req,                             \
+	  npc_cn20k_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)                                                    \
@@ -635,7 +651,7 @@ struct cgx_mac_addr_add_req {
  */
 struct cgx_mac_addr_add_rsp {
 	struct mbox_msghdr hdr;
-	uint8_t __io index;
+	uint32_t __io index;
 };
 
 /* Structure for requesting the operation to
@@ -643,7 +659,7 @@ struct cgx_mac_addr_add_rsp {
  */
 struct cgx_mac_addr_del_req {
 	struct mbox_msghdr hdr;
-	uint8_t __io index;
+	uint32_t __io index;
 };
 
 /* Structure for response against the operation to
@@ -651,7 +667,7 @@ struct cgx_mac_addr_del_req {
  */
 struct cgx_max_dmac_entries_get_rsp {
 	struct mbox_msghdr hdr;
-	uint8_t __io max_dmac_filters;
+	uint32_t __io max_dmac_filters;
 };
 
 struct cgx_link_user_info {
@@ -2431,6 +2447,14 @@ enum npc_af_status {
 	NPC_MCAM_ALLOC_FAILED = -703,
 	NPC_MCAM_PERM_DENIED = -704,
 	NPC_AF_ERR_HIGIG_CONFIG_FAIL = -705,
+	NPC_AF_ERR_HIGIG_NOT_SUPPORTED = -706,
+	NPC_FLOW_INTF_INVALID = -707,
+	NPC_FLOW_CHAN_INVALID = -708,
+	NPC_FLOW_NO_NIXLF = -709,
+	NPC_FLOW_NOT_SUPPORTED = -710,
+	NPC_FLOW_VF_PERM_DENIED = -711,
+	NPC_FLOW_VF_NOT_INIT = -712,
+	NPC_FLOW_VF_OVERLAP = -713,
 };
 
 struct npc_mcam_alloc_entry_req {
@@ -2440,9 +2464,12 @@ struct npc_mcam_alloc_entry_req {
 #define NPC_MCAM_ANY_PRIO    0
 #define NPC_MCAM_LOWER_PRIO  1
 #define NPC_MCAM_HIGHER_PRIO 2
-	uint8_t __io priority; /* Lower or higher w.r.t ref_entry */
+	uint8_t __io ref_priority; /* Lower or higher w.r.t ref_entry */
 	uint16_t __io ref_entry;
 	uint16_t __io count; /* Number of entries requested */
+	uint8_t __io kw_type; /* Key type */
+	uint8_t __io virt;    /* Request virtual index */
+	uint16_t __io rsvd[16];	/* Reserved */
 };
 
 struct npc_mcam_alloc_entry_rsp {
@@ -2454,6 +2481,7 @@ struct npc_mcam_alloc_entry_rsp {
 	uint16_t __io count;	  /* Number of entries allocated */
 	uint16_t __io free_count; /* Number of entries available */
 	uint16_t __io entry_list[NPC_MAX_NONCONTIG_ENTRIES];
+	uint16_t __io rsvd[16];	/* Reserved */
 };
 
 struct npc_mcam_free_entry_req {
@@ -2480,6 +2508,26 @@ struct npc_mcam_write_entry_req {
 	uint8_t __io set_cntr;	   /* Set counter for this entry ? */
 };
 
+struct cn20k_mcam_entry {
+#define NPC_CN20K_MAX_KWS_IN_KEY 8 /* Number of keywords in max keywidth */
+	uint64_t __io kw[NPC_CN20K_MAX_KWS_IN_KEY];
+	uint64_t __io kw_mask[NPC_CN20K_MAX_KWS_IN_KEY];
+	uint64_t __io action;
+	uint64_t __io vtag_action;
+};
+
+struct npc_cn20k_mcam_write_entry_req {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry_data;
+	uint16_t __io entry;	   /* MCAM entry to write this match key */
+	uint16_t __io cntr;	   /* Counter for this MCAM entry */
+	uint8_t __io intf;	   /* Rx or Tx interface */
+	uint8_t __io enable_entry; /* Enable this MCAM entry ? */
+	uint8_t __io hw_prio;	   /* hardware priority, valid for cn20k */
+	uint8_t __io req_kw_type;  /* Type of kw which should be written */
+	uint64_t __io reserved;	   /* reserved for future use */
+};
+
 /* Enable/Disable a given entry */
 struct npc_mcam_ena_dis_entry_req {
 	struct mbox_msghdr hdr;
@@ -2539,12 +2587,25 @@ struct npc_mcam_alloc_and_write_entry_req {
 	struct mbox_msghdr hdr;
 	struct mcam_entry entry_data;
 	uint16_t __io ref_entry;
-	uint8_t __io priority;	   /* Lower or higher w.r.t ref_entry */
+	uint8_t __io ref_priority; /* Lower or higher w.r.t ref_entry */
 	uint8_t __io intf;	   /* Rx or Tx interface */
 	uint8_t __io enable_entry; /* Enable this MCAM entry ? */
 	uint8_t __io alloc_cntr;   /* Allocate counter and map ? */
 };
 
+struct npc_cn20k_mcam_alloc_and_write_entry_req {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry_data;
+	uint16_t __io ref_entry;
+	uint8_t __io ref_prio;	   /* Lower or higher w.r.t ref_entry */
+	uint8_t __io intf;	   /* Rx or Tx interface */
+	uint8_t __io enable_entry; /* Enable this MCAM entry ? */
+	uint8_t __io hw_prio;	   /* hardware priority, valid for cn20k */
+	uint8_t __io virt;	   /* Allocate virtual index */
+	uint8_t __io req_kw_type;  /* Key type to be written */
+	uint16_t __io reserved[4]; /* reserved for future use */
+};
+
 struct npc_mcam_alloc_and_write_entry_rsp {
 	struct mbox_msghdr hdr;
 	uint16_t __io entry;
@@ -2571,6 +2632,48 @@ struct npc_get_kex_cfg_rsp {
 	uint8_t __io mkex_pfl_name[MKEX_NAME_LEN];
 };
 
+struct npc_delete_flow_rsp {
+	struct mbox_msghdr hdr;
+	uint16_t __io cntr_val;
+};
+
+/* Available entries to use */
+struct npc_cn20k_get_free_count_rsp {
+	struct mbox_msghdr hdr;
+	int __io free_x2;
+	int __io free_x4;
+	int __io free_subbanks;
+};
+
+struct npc_cn20k_get_kex_cfg_rsp {
+	struct mbox_msghdr hdr;
+	uint64_t __io rx_keyx_cfg; /* NPC_AF_INTF(0)_KEX_CFG */
+	uint64_t __io tx_keyx_cfg; /* NPC_AF_INTF(1)_KEX_CFG */
+#define NPC_MAX_EXTRACTOR 24
+	/* MKEX Extractor data */
+	uint64_t __io intf_extr[NPC_MAX_INTF][NPC_MAX_EXTRACTOR];
+	/* KEX configuration per extractor */
+	uint64_t __io intf_extr_lt[NPC_MAX_INTF][NPC_MAX_EXTRACTOR][NPC_MAX_LT];
+#define MKEX_NAME_LEN 128
+	uint8_t __io mkex_pfl_name[MKEX_NAME_LEN];
+};
+
+struct npc_get_field_hash_info_req {
+	struct mbox_msghdr hdr;
+	uint8_t intf;
+};
+
+struct npc_get_field_hash_info_rsp {
+	struct mbox_msghdr hdr;
+	uint64_t __io secret_key[3];
+#define NPC_MAX_HASH	  2
+#define NPC_MAX_HASH_MASK 2
+	/* NPC_AF_INTF(0..1)_HASH(0..1)_MASK(0..1) */
+	uint64_t __io hash_mask[NPC_MAX_INTF][NPC_MAX_HASH][NPC_MAX_HASH_MASK];
+	/* NPC_AF_INTF(0..1)_HASH(0..1)_RESULT_CTRL */
+	uint64_t __io hash_ctrl[NPC_MAX_INTF][NPC_MAX_HASH];
+};
+
 enum header_fields {
 	NPC_DMAC,
 	NPC_SMAC,
@@ -2660,6 +2763,8 @@ struct npc_install_flow_req {
 	uint8_t __io vtag1_op;
 	/* old counter value */
 	uint16_t __io cntr_val;
+	/* hardware priority, supported for cn20k */
+	uint8_t __io hw_prio;
 };
 
 struct npc_install_flow_rsp {
@@ -2690,11 +2795,24 @@ struct npc_mcam_read_entry_rsp {
 	uint8_t __io enable;
 };
 
+struct npc_cn20k_mcam_read_entry_rsp {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry_data;
+	uint8_t __io intf;
+	uint8_t __io enable;
+	uint8_t __io hw_prio; /* valid for cn20k */
+};
+
 struct npc_mcam_read_base_rule_rsp {
 	struct mbox_msghdr hdr;
 	struct mcam_entry entry_data;
 };
 
+struct npc_cn20k_mcam_read_base_rule_rsp {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry;
+};
+
 struct npc_mcam_get_stats_req {
 	struct mbox_msghdr hdr;
 	uint16_t __io entry; /* mcam entry */
@@ -2774,22 +2892,6 @@ enum tim_gpio_edge {
 	TIM_GPIO_INVALID,
 };
 
-struct npc_get_field_hash_info_req {
-	struct mbox_msghdr hdr;
-	uint8_t intf;
-};
-
-struct npc_get_field_hash_info_rsp {
-	struct mbox_msghdr hdr;
-	uint64_t __io secret_key[3];
-#define NPC_MAX_HASH	  2
-#define NPC_MAX_HASH_MASK 2
-	/* NPC_AF_INTF(0..1)_HASH(0..1)_MASK(0..1) */
-	uint64_t __io hash_mask[NPC_MAX_INTF][NPC_MAX_HASH][NPC_MAX_HASH_MASK];
-	/* NPC_AF_INTF(0..1)_HASH(0..1)_RESULT_CTRL */
-	uint64_t __io hash_ctrl[NPC_MAX_INTF][NPC_MAX_HASH];
-};
-
 enum ptp_op {
 	PTP_OP_ADJFINE = 0,   /* adjfine(req.scaled_ppm); */
 	PTP_OP_GET_CLOCK = 1, /* rsp.clk = get_clock() */
drivers/common/cnxk/roc_nix.h +6 -12
index f213823b9b..15823ab16c 100644
@@ -983,15 +983,11 @@ bool __roc_api roc_nix_ptp_is_enable(struct roc_nix *roc_nix);
 /* VLAN */
 int __roc_api
 roc_nix_vlan_mcam_entry_read(struct roc_nix *roc_nix, uint32_t index,
-			     struct npc_mcam_read_entry_rsp **rsp);
-int __roc_api roc_nix_vlan_mcam_entry_write(struct roc_nix *roc_nix,
-					    uint32_t index,
-					    struct mcam_entry *entry,
+			     void **rsp);
+int __roc_api roc_nix_vlan_mcam_entry_write(struct roc_nix *roc_nix, uint32_t index, void *entry,
 					    uint8_t intf, uint8_t enable);
-int __roc_api roc_nix_vlan_mcam_entry_alloc_and_write(struct roc_nix *roc_nix,
-						      struct mcam_entry *entry,
-						      uint8_t intf,
-						      uint8_t priority,
+int __roc_api roc_nix_vlan_mcam_entry_alloc_and_write(struct roc_nix *roc_nix, void *entry,
+						      uint8_t intf, uint8_t priority,
 						      uint8_t ref_entry);
 int __roc_api roc_nix_vlan_mcam_entry_free(struct roc_nix *roc_nix,
 					   uint32_t index);
@@ -1012,10 +1008,8 @@ int __roc_api roc_nix_mcast_mcam_entry_alloc(struct roc_nix *roc_nix,
 					     uint16_t index[]);
 int __roc_api roc_nix_mcast_mcam_entry_free(struct roc_nix *roc_nix,
 					    uint32_t index);
-int __roc_api roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix,
-					     struct mcam_entry *entry,
-					     uint32_t index, uint8_t intf,
-					     uint64_t action);
+int __roc_api roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix, void *entry, uint32_t index,
+					     uint8_t intf, uint64_t action);
 int __roc_api roc_nix_mcast_mcam_entry_ena_dis(struct roc_nix *roc_nix, uint32_t index,
 					       bool enable);
 int __roc_api roc_nix_mcast_list_setup(struct mbox *mbox, uint8_t intf, int nb_entries,
drivers/common/cnxk/roc_nix_mcast.c +27 -13
index 615014e820..eab4bde743 100644
@@ -19,7 +19,7 @@ roc_nix_mcast_mcam_entry_alloc(struct roc_nix *roc_nix, uint16_t nb_entries,
 	req = mbox_alloc_msg_npc_mcam_alloc_entry(mbox);
 	if (req == NULL)
 		goto exit;
-	req->priority = priority;
+	req->ref_priority = priority;
 	req->count = nb_entries;
 
 	rc = mbox_process_msg(mbox, (void *)&rsp);
@@ -56,24 +56,38 @@ roc_nix_mcast_mcam_entry_free(struct roc_nix *roc_nix, uint32_t index)
 }
 
 int
-roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix,
-			       struct mcam_entry *entry, uint32_t index,
-			       uint8_t intf, uint64_t action)
+roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix, void *entry, uint32_t index, uint8_t intf,
+			       uint64_t action)
 {
 	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
 	struct dev *dev = &nix->dev;
 	struct mbox *mbox = mbox_get(dev->mbox);
-	struct npc_mcam_write_entry_req *req;
 	int rc = -ENOSPC;
 
-	req = mbox_alloc_msg_npc_mcam_write_entry(mbox);
-	if (req == NULL)
-		goto exit;
-	req->entry = index;
-	req->intf = intf;
-	req->enable_entry = true;
-	mbox_memcpy(&req->entry_data, entry, sizeof(struct mcam_entry));
-	req->entry_data.action = action;
+	if (roc_model_is_cn20k()) {
+		struct npc_cn20k_mcam_write_entry_req *req;
+
+		req = mbox_alloc_msg_npc_cn20k_mcam_write_entry(mbox);
+		if (req == NULL)
+			goto exit;
+		req->entry = index;
+		req->intf = intf;
+		req->enable_entry = true;
+		mbox_memcpy(&req->entry_data, entry, sizeof(struct cn20k_mcam_entry));
+		req->entry_data.action = action;
+
+	} else {
+		struct npc_mcam_write_entry_req *req;
+
+		req = mbox_alloc_msg_npc_mcam_write_entry(mbox);
+		if (req == NULL)
+			goto exit;
+		req->entry = index;
+		req->intf = intf;
+		req->enable_entry = true;
+		mbox_memcpy(&req->entry_data, entry, sizeof(struct mcam_entry));
+		req->entry_data.action = action;
+	}
 
 	rc = mbox_process(mbox);
 exit:
drivers/common/cnxk/roc_nix_vlan.c +45 -21

101 lines not on this page · raw message

drivers/common/cnxk/roc_npc.c +44 -14

96 lines not on this page · raw message

drivers/common/cnxk/roc_npc.h +34 -25

123 lines not on this page · raw message

drivers/common/cnxk/roc_npc_mcam.c +473 -129

861 lines not on this page · raw message

drivers/common/cnxk/roc_npc_mcam_dump.c +232 -47

380 lines not on this page · raw message

drivers/common/cnxk/roc_npc_priv.h +64 -27

174 lines not on this page · raw message

drivers/common/cnxk/roc_npc_utils.c +276 -64

445 lines not on this page · raw message

drivers/common/cnxk/version.map +1 -0
index 935be3584c..27c6e8ed0e 100644
@@ -482,6 +482,7 @@ INTERNAL {
 	roc_npc_mcam_free_counter;
 	roc_npc_mcam_free;
 	roc_npc_mcam_free_entry;
+	roc_npc_mcam_get_stats;
 	roc_npc_mcam_init;
 	roc_npc_mcam_move;
 	roc_npc_mcam_merge_base_steering_rule;
Signature · 1 line
2.39.2
#4 lore raw

PATCH v2 2/2 net/cnxk: support rte flow on cn20k

From: Satheesh Paul <[email protected]>

Support for rte flow in cn20k.

---
 drivers/net/cnxk/cn10k_ethdev.c        |   8 +-
 drivers/net/cnxk/cn10k_flow.h          |  21 --
 drivers/net/cnxk/cn20k_ethdev.c        |   4 +
 drivers/net/cnxk/cnxk_ethdev_devargs.c |  10 +-
 drivers/net/cnxk/cnxk_flow.c           |  10 +-
 drivers/net/cnxk/cnxk_flow_wrapper.c   | 303 +++++++++++++++++++++++++
 drivers/net/cnxk/cnxk_flow_wrapper.h   |  21 ++
 drivers/net/cnxk/meson.build           |  10 +-
 8 files changed, 355 insertions(+), 32 deletions(-)
 delete mode 100644 drivers/net/cnxk/cn10k_flow.h
 create mode 100644 drivers/net/cnxk/cnxk_flow_wrapper.c
 create mode 100644 drivers/net/cnxk/cnxk_flow_wrapper.h
drivers/net/cnxk/cn10k_ethdev.c +4 -4
index fbb9b09062..a4b3d56c61 100644
@@ -2,9 +2,9 @@
  * Copyright(C) 2021 Marvell.
  */
 #include "cn10k_ethdev.h"
-#include "cn10k_flow.h"
 #include "cn10k_rx.h"
 #include "cn10k_tx.h"
+#include "cnxk_flow_wrapper.h"
 
 static uint16_t
 nix_rx_offload_flags(struct rte_eth_dev *eth_dev)
@@ -913,9 +913,9 @@ npc_flow_ops_override(void)
 	init_once = 1;
 
 	/* Update platform specific ops */
-	cnxk_flow_ops.create = cn10k_flow_create;
-	cnxk_flow_ops.destroy = cn10k_flow_destroy;
-	cnxk_flow_ops.info_get = cn10k_flow_info_get;
+	cnxk_flow_ops.create = cnxk_flow_create_wrapper;
+	cnxk_flow_ops.destroy = cnxk_flow_destroy_wrapper;
+	cnxk_flow_ops.info_get = cnxk_flow_info_get_wrapper;
 }
 
 static int
drivers/net/cnxk/cn10k_flow.h deleted +0 -21
deleted file mode 100644
index 316b74e6a6..0000000000
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(C) 2020 Marvell.
- */
-#ifndef __CN10K_RTE_FLOW_H__
-#define __CN10K_RTE_FLOW_H__
-
-#include <rte_flow_driver.h>
-
-struct rte_flow *cn10k_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
-				   const struct rte_flow_item pattern[],
-				   const struct rte_flow_action actions[],
-				   struct rte_flow_error *error);
-int cn10k_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
-		       struct rte_flow_error *error);
-
-int cn10k_flow_info_get(struct rte_eth_dev *dev, struct rte_flow_port_info *port_info,
-			struct rte_flow_queue_info *queue_info, struct rte_flow_error *err);
-
-#define CN10K_NPC_COUNTERS_MAX 512
-
-#endif /* __CN10K_RTE_FLOW_H__ */
drivers/net/cnxk/cn20k_ethdev.c +4 -0
index 37c372d80f..e74dd88172 100644
@@ -4,6 +4,7 @@
 #include "cn20k_ethdev.h"
 #include "cn20k_rx.h"
 #include "cn20k_tx.h"
+#include "cnxk_flow_wrapper.h"
 
 static uint16_t
 nix_rx_offload_flags(struct rte_eth_dev *eth_dev)
@@ -867,6 +868,9 @@ npc_flow_ops_override(void)
 	init_once = 1;
 
 	/* Update platform specific ops */
+	cnxk_flow_ops.create = cnxk_flow_create_wrapper;
+	cnxk_flow_ops.destroy = cnxk_flow_destroy_wrapper;
+	cnxk_flow_ops.info_get = cnxk_flow_info_get_wrapper;
 }
 
 static int
drivers/net/cnxk/cnxk_ethdev_devargs.c +7 -3
index 5bd50bb9a1..bdf5d88b92 100644
@@ -88,8 +88,7 @@ parse_flow_max_priority(const char *key, const char *value, void *extra_args)
 
 	val = atoi(value);
 
-	/* Limit the max priority to 32 */
-	if (val < 1 || val > 32)
+	if (val < 1 || val > ROC_NPC_MAX_MCAM_PRIORITY)
 		return -EINVAL;
 
 	*(uint16_t *)extra_args = val;
@@ -390,7 +389,12 @@ cnxk_ethdev_parse_devargs(struct rte_devargs *devargs, struct cnxk_eth_dev *dev)
 		dev->nix.meta_buf_sz = meta_buf_sz;
 
 	dev->npc.flow_prealloc_size = flow_prealloc_size;
-	dev->npc.flow_max_priority = flow_max_priority;
+
+	if (roc_model_is_cn20k())
+		dev->npc.flow_max_priority = ROC_NPC_MAX_MCAM_PRIORITY;
+	else
+		dev->npc.flow_max_priority = flow_max_priority;
+
 	dev->npc.switch_header_type = switch_header_type;
 	dev->npc.sdp_channel = sdp_chan.channel;
 	dev->npc.sdp_channel_mask = sdp_chan.mask;
drivers/net/cnxk/cnxk_flow.c +7 -3
index e42e2f8deb..4a32c11765 100644
@@ -1083,10 +1083,14 @@ cnxk_flow_query_common(struct rte_eth_dev *eth_dev, struct rte_flow *flow,
 		npc = &rep_dev->parent_dev->npc;
 	}
 
-	if (in_flow->use_pre_alloc)
+	if (in_flow->use_pre_alloc) {
 		rc = roc_npc_inl_mcam_read_counter(in_flow->ctr_id, &query->hits);
-	else
-		rc = roc_npc_mcam_read_counter(npc, in_flow->ctr_id, &query->hits);
+	} else {
+		if (roc_model_is_cn20k())
+			rc = roc_npc_mcam_get_stats(npc, in_flow, &query->hits);
+		else
+			rc = roc_npc_mcam_read_counter(npc, in_flow->ctr_id, &query->hits);
+	}
 	if (rc != 0) {
 		errcode = EIO;
 		errmsg = "Error reading flow counter";
drivers/net/cnxk/cnxk_flow_wrapper.c new file +303 -0

303 lines not on this page · raw message

drivers/net/cnxk/cnxk_flow_wrapper.h new file +21 -0
new file mode 100644
index 0000000000..506293dd51
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell.
+ */
+#ifndef __CNXK_FLOW_WRAPPER_H__
+#define __CNXK_FLOW_WRAPPER_H__
+
+#include <rte_flow_driver.h>
+
+struct rte_flow *cnxk_flow_create_wrapper(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
+					  const struct rte_flow_item pattern[],
+					  const struct rte_flow_action actions[],
+					  struct rte_flow_error *error);
+int cnxk_flow_destroy_wrapper(struct rte_eth_dev *dev, struct rte_flow *flow,
+			      struct rte_flow_error *error);
+
+int cnxk_flow_info_get_wrapper(struct rte_eth_dev *dev, struct rte_flow_port_info *port_info,
+			       struct rte_flow_queue_info *queue_info, struct rte_flow_error *err);
+
+#define CNXK_NPC_COUNTERS_MAX 512
+
+#endif /* __CNXK_FLOW_WRAPPER_H__ */
drivers/net/cnxk/meson.build +9 -1
index 32ff8aadc0..e77ceb8efc 100644
@@ -18,6 +18,13 @@ if soc_type != 'cn9k' and soc_type != 'cn10k' and soc_type != 'cn20k'
         soc_type = 'all'
 endif
 
+if soc_type == 'cn10k' or soc_type == 'all'
+    dpdk_conf.set('CNXK_PLATFORM_CN10K', 1)
+elif soc_type == 'cn20k'
+    dpdk_conf.set('CNXK_PLATFORM_CN20K', 1)
+endif
+
+
 sources = files(
         'cnxk_ethdev.c',
         'cnxk_ethdev_cman.c',
@@ -146,9 +153,9 @@ if soc_type == 'cn10k' or soc_type == 'all'
 sources += files(
         'cn10k_ethdev.c',
         'cn10k_ethdev_sec.c',
-        'cn10k_flow.c',
         'cn10k_rx_select.c',
         'cn10k_tx_select.c',
+        'cnxk_flow_wrapper.c',
 )
 
 if host_machine.cpu_family().startswith('aarch') and not disable_template
@@ -238,6 +245,7 @@ sources += files(
         'cn20k_ethdev.c',
         'cn20k_rx_select.c',
         'cn20k_tx_select.c',
+        'cnxk_flow_wrapper.c',
 )
 
 if host_machine.cpu_family().startswith('aarch') and not disable_template
Signature · 1 line
2.39.2
#5 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] net/cnxk: support rte flow on cn20k

Quoted 28 lines · On Tue, Oct 29, 2024 at 1:01 PM <[email protected]> wrote:

From: Satheesh Paul <[email protected]>

Support for rte flow in cn20k.

index 0000000000..af2eee7266

drivers/net/cnxk/cnxk_flow_wrapper.c new file +16 -0
@@ -0,0 +1,303 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifdef CNXK_PLATFORM_CN10K
+#include "cn10k_ethdev.h"
+#include "cn10k_rx.h"
+#endif
+#ifdef CNXK_PLATFORM_CN20K
+#include "cn20k_ethdev.h"
+#include "cn20k_rx.h"
+#endif
+#include "cnxk_ethdev_mcs.h"
+#include "cnxk_flow_wrapper.h"
+#include <cnxk_flow.h>
+

drivers/net/cnxk/cnxk_flow_wrapper.c line 26

Quoted 10 lines
drivers/net/cnxk/cnxk_flow_wrapper.c new file +10 -0
+static void
+cnxk_eth_set_rx_function(struct rte_eth_dev *eth_dev)
+{
+       RTE_SET_USED(eth_dev);
+#ifdef CNXK_PLATFORM_CN10K
+       cn10k_eth_set_rx_function(eth_dev);
+#endif
+#ifdef CNXK_PLATFORM_CN20K
+       cn20k_eth_set_rx_function(eth_dev);
+#endif

Please work to remove compile time macros

#6 lore raw

PATCH v3 1/2 common/cnxk: support NPC flow on cn20k

In reply to [email protected]

From: Satheesh Paul <[email protected]>

ROC changes to support NPC flow on cn20k.

---
v2:
* Fixed generic platform compiler error.
v3:
* Removed compile time macros.

 drivers/common/cnxk/roc_mbox.h          | 144 +++++-
 drivers/common/cnxk/roc_nix.h           |  18 +-
 drivers/common/cnxk/roc_nix_mcast.c     |  40 +-
 drivers/common/cnxk/roc_nix_vlan.c      |  66 ++-
 drivers/common/cnxk/roc_npc.c           |  58 ++-
 drivers/common/cnxk/roc_npc.h           |  59 ++-
 drivers/common/cnxk/roc_npc_mcam.c      | 602 +++++++++++++++++++-----
 drivers/common/cnxk/roc_npc_mcam_dump.c | 279 +++++++++--
 drivers/common/cnxk/roc_npc_priv.h      |  91 ++--
 drivers/common/cnxk/roc_npc_utils.c     | 340 ++++++++++---
 drivers/common/cnxk/version.map         |   1 +
 11 files changed, 1325 insertions(+), 373 deletions(-)
drivers/common/cnxk/roc_mbox.h +123 -21
index e7a916d61c..5328fd768e 100644
@@ -236,6 +236,22 @@ struct mbox_msghdr {
 	  npc_get_field_hash_info_req, npc_get_field_hash_info_rsp)            \
 	M(NPC_MCAM_GET_HIT_STATUS, 0x6015, npc_mcam_get_hit_status,            \
 	  npc_mcam_get_hit_status_req, npc_mcam_get_hit_status_rsp)            \
+	M(NPC_MCAM_DEFRAG, 0x6016, npc_defrag, msg_req,	msg_rsp)               \
+	M(NPC_CN20K_GET_KEX_CFG, 0x6017, npc_cn20k_get_kex_cfg, msg_req,       \
+	  npc_cn20k_get_kex_cfg_rsp)                                           \
+	M(NPC_CN20K_MCAM_GET_FREE_COUNT, 0x6018, npc_cn20k_get_free_count,     \
+	  msg_req, npc_cn20k_get_free_count_rsp)                               \
+	M(NPC_CN20K_MCAM_WRITE_ENTRY,	0x6019, npc_cn20k_mcam_write_entry,    \
+	  npc_cn20k_mcam_write_entry_req, msg_rsp)	                       \
+	M(NPC_CN20K_MCAM_ALLOC_AND_WRITE_ENTRY, 0x601a,			       \
+	  npc_cn20k_mcam_alloc_and_write_entry,				       \
+	  npc_cn20k_mcam_alloc_and_write_entry_req,			       \
+	  npc_mcam_alloc_and_write_entry_rsp)				       \
+	M(NPC_CN20K_MCAM_READ_ENTRY,	0x601b, npc_cn20k_mcam_read_entry,     \
+	  npc_mcam_read_entry_req, npc_cn20k_mcam_read_entry_rsp)	       \
+	M(NPC_CN20K_MCAM_READ_BASE_RULE, 0x601c,                               \
+	  npc_cn20k_read_base_steer_rule, msg_req,                             \
+	  npc_cn20k_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)                                                    \
@@ -637,7 +653,7 @@ struct cgx_mac_addr_add_req {
  */
 struct cgx_mac_addr_add_rsp {
 	struct mbox_msghdr hdr;
-	uint8_t __io index;
+	uint32_t __io index;
 };
 
 /* Structure for requesting the operation to
@@ -645,7 +661,7 @@ struct cgx_mac_addr_add_rsp {
  */
 struct cgx_mac_addr_del_req {
 	struct mbox_msghdr hdr;
-	uint8_t __io index;
+	uint32_t __io index;
 };
 
 /* Structure for response against the operation to
@@ -653,7 +669,7 @@ struct cgx_mac_addr_del_req {
  */
 struct cgx_max_dmac_entries_get_rsp {
 	struct mbox_msghdr hdr;
-	uint8_t __io max_dmac_filters;
+	uint32_t __io max_dmac_filters;
 };
 
 struct cgx_link_user_info {
@@ -2433,6 +2449,14 @@ enum npc_af_status {
 	NPC_MCAM_ALLOC_FAILED = -703,
 	NPC_MCAM_PERM_DENIED = -704,
 	NPC_AF_ERR_HIGIG_CONFIG_FAIL = -705,
+	NPC_AF_ERR_HIGIG_NOT_SUPPORTED = -706,
+	NPC_FLOW_INTF_INVALID = -707,
+	NPC_FLOW_CHAN_INVALID = -708,
+	NPC_FLOW_NO_NIXLF = -709,
+	NPC_FLOW_NOT_SUPPORTED = -710,
+	NPC_FLOW_VF_PERM_DENIED = -711,
+	NPC_FLOW_VF_NOT_INIT = -712,
+	NPC_FLOW_VF_OVERLAP = -713,
 };
 
 struct npc_mcam_alloc_entry_req {
@@ -2442,9 +2466,12 @@ struct npc_mcam_alloc_entry_req {
 #define NPC_MCAM_ANY_PRIO    0
 #define NPC_MCAM_LOWER_PRIO  1
 #define NPC_MCAM_HIGHER_PRIO 2
-	uint8_t __io priority; /* Lower or higher w.r.t ref_entry */
+	uint8_t __io ref_priority; /* Lower or higher w.r.t ref_entry */
 	uint16_t __io ref_entry;
 	uint16_t __io count; /* Number of entries requested */
+	uint8_t __io kw_type; /* Key type */
+	uint8_t __io virt;    /* Request virtual index */
+	uint16_t __io rsvd[16];	/* Reserved */
 };
 
 struct npc_mcam_alloc_entry_rsp {
@@ -2456,6 +2483,7 @@ struct npc_mcam_alloc_entry_rsp {
 	uint16_t __io count;	  /* Number of entries allocated */
 	uint16_t __io free_count; /* Number of entries available */
 	uint16_t __io entry_list[NPC_MAX_NONCONTIG_ENTRIES];
+	uint16_t __io rsvd[16];	/* Reserved */
 };
 
 struct npc_mcam_free_entry_req {
@@ -2482,6 +2510,26 @@ struct npc_mcam_write_entry_req {
 	uint8_t __io set_cntr;	   /* Set counter for this entry ? */
 };
 
+struct cn20k_mcam_entry {
+#define NPC_CN20K_MAX_KWS_IN_KEY 8 /* Number of keywords in max keywidth */
+	uint64_t __io kw[NPC_CN20K_MAX_KWS_IN_KEY];
+	uint64_t __io kw_mask[NPC_CN20K_MAX_KWS_IN_KEY];
+	uint64_t __io action;
+	uint64_t __io vtag_action;
+};
+
+struct npc_cn20k_mcam_write_entry_req {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry_data;
+	uint16_t __io entry;	   /* MCAM entry to write this match key */
+	uint16_t __io cntr;	   /* Counter for this MCAM entry */
+	uint8_t __io intf;	   /* Rx or Tx interface */
+	uint8_t __io enable_entry; /* Enable this MCAM entry ? */
+	uint8_t __io hw_prio;	   /* hardware priority, valid for cn20k */
+	uint8_t __io req_kw_type;  /* Type of kw which should be written */
+	uint64_t __io reserved;	   /* reserved for future use */
+};
+
 /* Enable/Disable a given entry */
 struct npc_mcam_ena_dis_entry_req {
 	struct mbox_msghdr hdr;
@@ -2541,12 +2589,25 @@ struct npc_mcam_alloc_and_write_entry_req {
 	struct mbox_msghdr hdr;
 	struct mcam_entry entry_data;
 	uint16_t __io ref_entry;
-	uint8_t __io priority;	   /* Lower or higher w.r.t ref_entry */
+	uint8_t __io ref_priority; /* Lower or higher w.r.t ref_entry */
 	uint8_t __io intf;	   /* Rx or Tx interface */
 	uint8_t __io enable_entry; /* Enable this MCAM entry ? */
 	uint8_t __io alloc_cntr;   /* Allocate counter and map ? */
 };
 
+struct npc_cn20k_mcam_alloc_and_write_entry_req {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry_data;
+	uint16_t __io ref_entry;
+	uint8_t __io ref_prio;	   /* Lower or higher w.r.t ref_entry */
+	uint8_t __io intf;	   /* Rx or Tx interface */
+	uint8_t __io enable_entry; /* Enable this MCAM entry ? */
+	uint8_t __io hw_prio;	   /* hardware priority, valid for cn20k */
+	uint8_t __io virt;	   /* Allocate virtual index */
+	uint8_t __io req_kw_type;  /* Key type to be written */
+	uint16_t __io reserved[4]; /* reserved for future use */
+};
+
 struct npc_mcam_alloc_and_write_entry_rsp {
 	struct mbox_msghdr hdr;
 	uint16_t __io entry;
@@ -2573,6 +2634,48 @@ struct npc_get_kex_cfg_rsp {
 	uint8_t __io mkex_pfl_name[MKEX_NAME_LEN];
 };
 
+struct npc_delete_flow_rsp {
+	struct mbox_msghdr hdr;
+	uint16_t __io cntr_val;
+};
+
+/* Available entries to use */
+struct npc_cn20k_get_free_count_rsp {
+	struct mbox_msghdr hdr;
+	int __io free_x2;
+	int __io free_x4;
+	int __io free_subbanks;
+};
+
+struct npc_cn20k_get_kex_cfg_rsp {
+	struct mbox_msghdr hdr;
+	uint64_t __io rx_keyx_cfg; /* NPC_AF_INTF(0)_KEX_CFG */
+	uint64_t __io tx_keyx_cfg; /* NPC_AF_INTF(1)_KEX_CFG */
+#define NPC_MAX_EXTRACTOR 24
+	/* MKEX Extractor data */
+	uint64_t __io intf_extr[NPC_MAX_INTF][NPC_MAX_EXTRACTOR];
+	/* KEX configuration per extractor */
+	uint64_t __io intf_extr_lt[NPC_MAX_INTF][NPC_MAX_EXTRACTOR][NPC_MAX_LT];
+#define MKEX_NAME_LEN 128
+	uint8_t __io mkex_pfl_name[MKEX_NAME_LEN];
+};
+
+struct npc_get_field_hash_info_req {
+	struct mbox_msghdr hdr;
+	uint8_t intf;
+};
+
+struct npc_get_field_hash_info_rsp {
+	struct mbox_msghdr hdr;
+	uint64_t __io secret_key[3];
+#define NPC_MAX_HASH	  2
+#define NPC_MAX_HASH_MASK 2
+	/* NPC_AF_INTF(0..1)_HASH(0..1)_MASK(0..1) */
+	uint64_t __io hash_mask[NPC_MAX_INTF][NPC_MAX_HASH][NPC_MAX_HASH_MASK];
+	/* NPC_AF_INTF(0..1)_HASH(0..1)_RESULT_CTRL */
+	uint64_t __io hash_ctrl[NPC_MAX_INTF][NPC_MAX_HASH];
+};
+
 enum header_fields {
 	NPC_DMAC,
 	NPC_SMAC,
@@ -2662,6 +2765,8 @@ struct npc_install_flow_req {
 	uint8_t __io vtag1_op;
 	/* old counter value */
 	uint16_t __io cntr_val;
+	/* hardware priority, supported for cn20k */
+	uint8_t __io hw_prio;
 };
 
 struct npc_install_flow_rsp {
@@ -2692,11 +2797,24 @@ struct npc_mcam_read_entry_rsp {
 	uint8_t __io enable;
 };
 
+struct npc_cn20k_mcam_read_entry_rsp {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry_data;
+	uint8_t __io intf;
+	uint8_t __io enable;
+	uint8_t __io hw_prio; /* valid for cn20k */
+};
+
 struct npc_mcam_read_base_rule_rsp {
 	struct mbox_msghdr hdr;
 	struct mcam_entry entry_data;
 };
 
+struct npc_cn20k_mcam_read_base_rule_rsp {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry;
+};
+
 struct npc_mcam_get_stats_req {
 	struct mbox_msghdr hdr;
 	uint16_t __io entry; /* mcam entry */
@@ -2776,22 +2894,6 @@ enum tim_gpio_edge {
 	TIM_GPIO_INVALID,
 };
 
-struct npc_get_field_hash_info_req {
-	struct mbox_msghdr hdr;
-	uint8_t intf;
-};
-
-struct npc_get_field_hash_info_rsp {
-	struct mbox_msghdr hdr;
-	uint64_t __io secret_key[3];
-#define NPC_MAX_HASH	  2
-#define NPC_MAX_HASH_MASK 2
-	/* NPC_AF_INTF(0..1)_HASH(0..1)_MASK(0..1) */
-	uint64_t __io hash_mask[NPC_MAX_INTF][NPC_MAX_HASH][NPC_MAX_HASH_MASK];
-	/* NPC_AF_INTF(0..1)_HASH(0..1)_RESULT_CTRL */
-	uint64_t __io hash_ctrl[NPC_MAX_INTF][NPC_MAX_HASH];
-};
-
 enum ptp_op {
 	PTP_OP_ADJFINE = 0,   /* adjfine(req.scaled_ppm); */
 	PTP_OP_GET_CLOCK = 1, /* rsp.clk = get_clock() */
drivers/common/cnxk/roc_nix.h +6 -12
index f213823b9b..15823ab16c 100644
@@ -983,15 +983,11 @@ bool __roc_api roc_nix_ptp_is_enable(struct roc_nix *roc_nix);
 /* VLAN */
 int __roc_api
 roc_nix_vlan_mcam_entry_read(struct roc_nix *roc_nix, uint32_t index,
-			     struct npc_mcam_read_entry_rsp **rsp);
-int __roc_api roc_nix_vlan_mcam_entry_write(struct roc_nix *roc_nix,
-					    uint32_t index,
-					    struct mcam_entry *entry,
+			     void **rsp);
+int __roc_api roc_nix_vlan_mcam_entry_write(struct roc_nix *roc_nix, uint32_t index, void *entry,
 					    uint8_t intf, uint8_t enable);
-int __roc_api roc_nix_vlan_mcam_entry_alloc_and_write(struct roc_nix *roc_nix,
-						      struct mcam_entry *entry,
-						      uint8_t intf,
-						      uint8_t priority,
+int __roc_api roc_nix_vlan_mcam_entry_alloc_and_write(struct roc_nix *roc_nix, void *entry,
+						      uint8_t intf, uint8_t priority,
 						      uint8_t ref_entry);
 int __roc_api roc_nix_vlan_mcam_entry_free(struct roc_nix *roc_nix,
 					   uint32_t index);
@@ -1012,10 +1008,8 @@ int __roc_api roc_nix_mcast_mcam_entry_alloc(struct roc_nix *roc_nix,
 					     uint16_t index[]);
 int __roc_api roc_nix_mcast_mcam_entry_free(struct roc_nix *roc_nix,
 					    uint32_t index);
-int __roc_api roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix,
-					     struct mcam_entry *entry,
-					     uint32_t index, uint8_t intf,
-					     uint64_t action);
+int __roc_api roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix, void *entry, uint32_t index,
+					     uint8_t intf, uint64_t action);
 int __roc_api roc_nix_mcast_mcam_entry_ena_dis(struct roc_nix *roc_nix, uint32_t index,
 					       bool enable);
 int __roc_api roc_nix_mcast_list_setup(struct mbox *mbox, uint8_t intf, int nb_entries,
drivers/common/cnxk/roc_nix_mcast.c +27 -13
index 615014e820..eab4bde743 100644
@@ -19,7 +19,7 @@ roc_nix_mcast_mcam_entry_alloc(struct roc_nix *roc_nix, uint16_t nb_entries,
 	req = mbox_alloc_msg_npc_mcam_alloc_entry(mbox);
 	if (req == NULL)
 		goto exit;
-	req->priority = priority;
+	req->ref_priority = priority;
 	req->count = nb_entries;
 
 	rc = mbox_process_msg(mbox, (void *)&rsp);
@@ -56,24 +56,38 @@ roc_nix_mcast_mcam_entry_free(struct roc_nix *roc_nix, uint32_t index)
 }
 
 int
-roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix,
-			       struct mcam_entry *entry, uint32_t index,
-			       uint8_t intf, uint64_t action)
+roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix, void *entry, uint32_t index, uint8_t intf,
+			       uint64_t action)
 {
 	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
 	struct dev *dev = &nix->dev;
 	struct mbox *mbox = mbox_get(dev->mbox);
-	struct npc_mcam_write_entry_req *req;
 	int rc = -ENOSPC;
 
-	req = mbox_alloc_msg_npc_mcam_write_entry(mbox);
-	if (req == NULL)
-		goto exit;
-	req->entry = index;
-	req->intf = intf;
-	req->enable_entry = true;
-	mbox_memcpy(&req->entry_data, entry, sizeof(struct mcam_entry));
-	req->entry_data.action = action;
+	if (roc_model_is_cn20k()) {
+		struct npc_cn20k_mcam_write_entry_req *req;
+
+		req = mbox_alloc_msg_npc_cn20k_mcam_write_entry(mbox);
+		if (req == NULL)
+			goto exit;
+		req->entry = index;
+		req->intf = intf;
+		req->enable_entry = true;
+		mbox_memcpy(&req->entry_data, entry, sizeof(struct cn20k_mcam_entry));
+		req->entry_data.action = action;
+
+	} else {
+		struct npc_mcam_write_entry_req *req;
+
+		req = mbox_alloc_msg_npc_mcam_write_entry(mbox);
+		if (req == NULL)
+			goto exit;
+		req->entry = index;
+		req->intf = intf;
+		req->enable_entry = true;
+		mbox_memcpy(&req->entry_data, entry, sizeof(struct mcam_entry));
+		req->entry_data.action = action;
+	}
 
 	rc = mbox_process(mbox);
 exit:
drivers/common/cnxk/roc_nix_vlan.c +45 -21

101 lines not on this page · raw message

drivers/common/cnxk/roc_npc.c +44 -14

96 lines not on this page · raw message

drivers/common/cnxk/roc_npc.h +34 -25

123 lines not on this page · raw message

drivers/common/cnxk/roc_npc_mcam.c +473 -129

861 lines not on this page · raw message

drivers/common/cnxk/roc_npc_mcam_dump.c +232 -47

380 lines not on this page · raw message

drivers/common/cnxk/roc_npc_priv.h +64 -27

174 lines not on this page · raw message

drivers/common/cnxk/roc_npc_utils.c +276 -64

445 lines not on this page · raw message

drivers/common/cnxk/version.map +1 -0
index 42e9375706..4f8da55da5 100644
@@ -486,6 +486,7 @@ INTERNAL {
 	roc_npc_mcam_free_counter;
 	roc_npc_mcam_free;
 	roc_npc_mcam_free_entry;
+	roc_npc_mcam_get_stats;
 	roc_npc_mcam_init;
 	roc_npc_mcam_move;
 	roc_npc_mcam_merge_base_steering_rule;
Signature · 1 line
2.39.2
#7 lore raw

PATCH v3 2/2 net/cnxk: support rte flow on cn20k

From: Satheesh Paul <[email protected]>

Support for rte flow in cn20k.

---
 drivers/net/cnxk/cn10k_flow.c          | 227 ++-----------------------
 drivers/net/cnxk/cn10k_flow.h          |  10 +-
 drivers/net/cnxk/cn20k_ethdev.c        |   4 +
 drivers/net/cnxk/cn20k_flow.c          | 101 +++++++++++
 drivers/net/cnxk/cn20k_flow.h          |  21 +++
 drivers/net/cnxk/cn9k_flow.c           |   2 +-
 drivers/net/cnxk/cnxk_ethdev_devargs.c |  10 +-
 drivers/net/cnxk/cnxk_flow.c           |  18 +-
 drivers/net/cnxk/cnxk_flow.h           |   5 +-
 drivers/net/cnxk/cnxk_flow_common.c    | 214 +++++++++++++++++++++++
 drivers/net/cnxk/cnxk_flow_common.h    |  19 +++
 drivers/net/cnxk/meson.build           |   2 +
 12 files changed, 396 insertions(+), 237 deletions(-)
 create mode 100644 drivers/net/cnxk/cn20k_flow.c
 create mode 100644 drivers/net/cnxk/cn20k_flow.h
 create mode 100644 drivers/net/cnxk/cnxk_flow_common.c
 create mode 100644 drivers/net/cnxk/cnxk_flow_common.h
drivers/net/cnxk/cn10k_flow.c +14 -213
index db5e427362..b95fb83f08 100644
@@ -1,215 +1,29 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(C) 2020 Marvell.
  */
-#include "cn10k_flow.h"
+
 #include "cn10k_ethdev.h"
 #include "cn10k_rx.h"
 #include "cnxk_ethdev_mcs.h"
+#include "cnxk_flow_common.h"
+#include <cn10k_flow.h>
 #include <cnxk_flow.h>
 
-static int
-cn10k_mtr_connect(struct rte_eth_dev *eth_dev, uint32_t mtr_id)
-{
-	return nix_mtr_connect(eth_dev, mtr_id);
-}
-
-static int
-cn10k_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t mtr_id)
-{
-	struct rte_mtr_error mtr_error;
-
-	return nix_mtr_destroy(eth_dev, mtr_id, &mtr_error);
-}
-
-static int
-cn10k_mtr_configure(struct rte_eth_dev *eth_dev,
-		    const struct rte_flow_action actions[])
-{
-	uint32_t mtr_id = 0xffff, prev_mtr_id = 0xffff, next_mtr_id = 0xffff;
-	const struct rte_flow_action_meter *mtr_conf;
-	const struct rte_flow_action_queue *q_conf;
-	const struct rte_flow_action_rss *rss_conf;
-	struct cnxk_mtr_policy_node *policy;
-	bool is_mtr_act = false;
-	int tree_level = 0;
-	int rc = -EINVAL, i;
-
-	for (i = 0; actions[i].type != RTE_FLOW_ACTION_TYPE_END; i++) {
-		if (actions[i].type == RTE_FLOW_ACTION_TYPE_METER) {
-			mtr_conf = (const struct rte_flow_action_meter
-					    *)(actions[i].conf);
-			mtr_id = mtr_conf->mtr_id;
-			is_mtr_act = true;
-		}
-		if (actions[i].type == RTE_FLOW_ACTION_TYPE_QUEUE) {
-			q_conf = (const struct rte_flow_action_queue
-					  *)(actions[i].conf);
-			if (is_mtr_act)
-				nix_mtr_rq_update(eth_dev, mtr_id, 1,
-						  &q_conf->index);
-		}
-		if (actions[i].type == RTE_FLOW_ACTION_TYPE_RSS) {
-			rss_conf = (const struct rte_flow_action_rss
-					    *)(actions[i].conf);
-			if (is_mtr_act)
-				nix_mtr_rq_update(eth_dev, mtr_id,
-						  rss_conf->queue_num,
-						  rss_conf->queue);
-		}
-	}
-
-	if (!is_mtr_act)
-		return rc;
-
-	prev_mtr_id = mtr_id;
-	next_mtr_id = mtr_id;
-	while (next_mtr_id != 0xffff) {
-		rc = nix_mtr_validate(eth_dev, next_mtr_id);
-		if (rc)
-			return rc;
-
-		rc = nix_mtr_policy_act_get(eth_dev, next_mtr_id, &policy);
-		if (rc)
-			return rc;
-
-		rc = nix_mtr_color_action_validate(eth_dev, mtr_id,
-						   &prev_mtr_id, &next_mtr_id,
-						   policy, &tree_level);
-		if (rc)
-			return rc;
-	}
-
-	return nix_mtr_configure(eth_dev, mtr_id);
-}
-
-static int
-cn10k_rss_action_validate(struct rte_eth_dev *eth_dev,
-			  const struct rte_flow_attr *attr,
-			  const struct rte_flow_action *act)
-{
-	const struct rte_flow_action_rss *rss;
-
-	if (act == NULL)
-		return -EINVAL;
-
-	rss = (const struct rte_flow_action_rss *)act->conf;
-
-	if (attr->egress) {
-		plt_err("No support of RSS in egress");
-		return -EINVAL;
-	}
-
-	if (eth_dev->data->dev_conf.rxmode.mq_mode != RTE_ETH_MQ_RX_RSS) {
-		plt_err("multi-queue mode is disabled");
-		return -ENOTSUP;
-	}
-
-	if (!rss || !rss->queue_num) {
-		plt_err("no valid queues");
-		return -EINVAL;
-	}
-
-	if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) {
-		plt_err("non-default RSS hash functions are not supported");
-		return -ENOTSUP;
-	}
-
-	if (rss->key_len && rss->key_len > ROC_NIX_RSS_KEY_LEN) {
-		plt_err("RSS hash key too large");
-		return -ENOTSUP;
-	}
-
-	return 0;
-}
-
 struct rte_flow *
 cn10k_flow_create(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
-		  const struct rte_flow_item pattern[],
-		  const struct rte_flow_action actions[],
+		  const struct rte_flow_item pattern[], const struct rte_flow_action actions[],
 		  struct rte_flow_error *error)
 {
 	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
-	const struct rte_flow_action *action_rss = NULL;
-	const struct rte_flow_action_meter *mtr = NULL;
-	const struct rte_flow_action *act_q = NULL;
 	struct roc_npc *npc = &dev->npc;
 	struct roc_npc_flow *flow;
-	void *mcs_flow = NULL;
 	int vtag_actions = 0;
-	uint32_t req_act = 0;
 	int mark_actions;
-	int i, rc;
-
-	for (i = 0; actions[i].type != RTE_FLOW_ACTION_TYPE_END; i++) {
-		if (actions[i].type == RTE_FLOW_ACTION_TYPE_METER)
-			req_act |= ROC_NPC_ACTION_TYPE_METER;
-
-		if (actions[i].type == RTE_FLOW_ACTION_TYPE_QUEUE) {
-			req_act |= ROC_NPC_ACTION_TYPE_QUEUE;
-			act_q = &actions[i];
-		}
-		if (actions[i].type == RTE_FLOW_ACTION_TYPE_RSS) {
-			req_act |= ROC_NPC_ACTION_TYPE_RSS;
-			action_rss = &actions[i];
-		}
-	}
-
-	if (req_act & ROC_NPC_ACTION_TYPE_METER) {
-		if ((req_act & ROC_NPC_ACTION_TYPE_RSS) &&
-		    ((req_act & ROC_NPC_ACTION_TYPE_QUEUE))) {
-			return NULL;
-		}
-		if (req_act & ROC_NPC_ACTION_TYPE_RSS) {
-			rc = cn10k_rss_action_validate(eth_dev, attr,
-						       action_rss);
-			if (rc)
-				return NULL;
-		} else if (req_act & ROC_NPC_ACTION_TYPE_QUEUE) {
-			const struct rte_flow_action_queue *act_queue;
-			act_queue = (const struct rte_flow_action_queue *)
-					    act_q->conf;
-			if (act_queue->index > eth_dev->data->nb_rx_queues)
-				return NULL;
-		} else {
-			return NULL;
-		}
-	}
-	for (i = 0; actions[i].type != RTE_FLOW_ACTION_TYPE_END; i++) {
-		if (actions[i].type == RTE_FLOW_ACTION_TYPE_METER) {
-			mtr = (const struct rte_flow_action_meter *)actions[i]
-				      .conf;
-			rc = cn10k_mtr_configure(eth_dev, actions);
-			if (rc) {
-				rte_flow_error_set(error, rc,
-					RTE_FLOW_ERROR_TYPE_ACTION, NULL,
-					"Failed to configure mtr ");
-				return NULL;
-			}
-			break;
-		}
-	}
-
-	if (actions[0].type == RTE_FLOW_ACTION_TYPE_SECURITY &&
-	    cnxk_eth_macsec_sess_get_by_sess(dev, actions[0].conf) != NULL) {
-		rc = cnxk_mcs_flow_configure(eth_dev, attr, pattern, actions, error, &mcs_flow);
-		if (rc) {
-			rte_flow_error_set(error, rc, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
-					   "Failed to configure mcs flow");
-			return NULL;
-		}
-		return (struct rte_flow *)mcs_flow;
-	}
 
 	flow = cnxk_flow_create(eth_dev, attr, pattern, actions, error);
-	if (!flow) {
-		if (mtr)
-			nix_mtr_chain_reset(eth_dev, mtr->mtr_id);
 
+	if (!flow)
 		return NULL;
-	} else {
-		if (mtr)
-			cn10k_mtr_connect(eth_dev, mtr->mtr_id);
-	}
 
 	mark_actions = roc_npc_mark_actions_get(npc);
 	if (mark_actions) {
@@ -231,16 +45,7 @@ int
 cn10k_flow_info_get(struct rte_eth_dev *dev, struct rte_flow_port_info *port_info,
 		    struct rte_flow_queue_info *queue_info, struct rte_flow_error *err)
 {
-	RTE_SET_USED(dev);
-	RTE_SET_USED(err);
-
-	memset(port_info, 0, sizeof(*port_info));
-	memset(queue_info, 0, sizeof(*queue_info));
-
-	port_info->max_nb_counters = CN10K_NPC_COUNTERS_MAX;
-	port_info->max_nb_meters = CNXK_NIX_MTR_COUNT_MAX;
-
-	return 0;
+	return cnxk_flow_info_get_common(dev, port_info, queue_info, err);
 }
 
 int
@@ -250,14 +55,12 @@ cn10k_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *rte_flow,
 	struct roc_npc_flow *flow = (struct roc_npc_flow *)rte_flow;
 	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
 	struct roc_npc *npc = &dev->npc;
-	int vtag_actions = 0;
+	int vtag_actions = 0, rc = 0;
 	int mark_actions;
 	uint16_t match_id;
 	uint32_t mtr_id;
-	int rc;
 
-	match_id = (flow->npc_action >> NPC_RX_ACT_MATCH_OFFSET) &
-		   NPC_RX_ACT_MATCH_MASK;
+	match_id = (flow->npc_action >> NPC_RX_ACT_MATCH_OFFSET) & NPC_RX_ACT_MATCH_MASK;
 	if (match_id) {
 		mark_actions = roc_npc_mark_actions_sub_return(npc, 1);
 		if (mark_actions == 0) {
@@ -271,8 +74,7 @@ cn10k_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *rte_flow,
 		if (flow->nix_intf == ROC_NPC_INTF_RX) {
 			vtag_actions = roc_npc_vtag_actions_sub_return(npc, 1);
 			if (vtag_actions == 0) {
-				dev->rx_offload_flags &=
-					~NIX_RX_OFFLOAD_VLAN_STRIP_F;
+				dev->rx_offload_flags &= ~NIX_RX_OFFLOAD_VLAN_STRIP_F;
 				cn10k_eth_set_rx_function(eth_dev);
 			}
 		}
@@ -281,19 +83,18 @@ cn10k_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *rte_flow,
 	if (cnxk_eth_macsec_sess_get_by_sess(dev, (void *)flow) != NULL) {
 		rc = cnxk_mcs_flow_destroy(dev, (void *)flow);
 		if (rc < 0)
-			rte_flow_error_set(error, rc, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-					NULL, "Failed to free mcs flow");
+			rte_flow_error_set(error, rc, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+					   "Failed to free mcs flow");
 		return rc;
 	}
 
 	mtr_id = flow->mtr_id;
 	rc = cnxk_flow_destroy(eth_dev, flow, error);
 	if (!rc && mtr_id != ROC_NIX_MTR_ID_INVALID) {
-		rc = cn10k_mtr_destroy(eth_dev, mtr_id);
+		rc = cnxk_mtr_destroy(eth_dev, mtr_id);
 		if (rc) {
-			rte_flow_error_set(error, ENXIO,
-				RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
-				"Meter attached to this flow does not exist");
+			rte_flow_error_set(error, ENXIO, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+					   "Meter attached to this flow does not exist");
 		}
 	}
 	return rc;
drivers/net/cnxk/cn10k_flow.h +5 -5
index 316b74e6a6..c9e8c86e96 100644
@@ -1,8 +1,8 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(C) 2020 Marvell.
+ * Copyright(C) 2024 Marvell.
  */
-#ifndef __CN10K_RTE_FLOW_H__
-#define __CN10K_RTE_FLOW_H__
+#ifndef __CN10K_FLOW_H__
+#define __CN10K_FLOW_H__
 
 #include <rte_flow_driver.h>
 
@@ -16,6 +16,6 @@ int cn10k_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
 int cn10k_flow_info_get(struct rte_eth_dev *dev, struct rte_flow_port_info *port_info,
 			struct rte_flow_queue_info *queue_info, struct rte_flow_error *err);
 
-#define CN10K_NPC_COUNTERS_MAX 512
+#define CNXK_NPC_COUNTERS_MAX 512
 
-#endif /* __CN10K_RTE_FLOW_H__ */
+#endif /* __CN10K_FLOW_H__ */
drivers/net/cnxk/cn20k_ethdev.c +4 -0
index 37c372d80f..4e4337a6e5 100644
@@ -2,6 +2,7 @@
  * Copyright(C) 2024 Marvell.
  */
 #include "cn20k_ethdev.h"
+#include "cn20k_flow.h"
 #include "cn20k_rx.h"
 #include "cn20k_tx.h"
 
@@ -867,6 +868,9 @@ npc_flow_ops_override(void)
 	init_once = 1;
 
 	/* Update platform specific ops */
+	cnxk_flow_ops.create = cn20k_flow_create;
+	cnxk_flow_ops.destroy = cn20k_flow_destroy;
+	cnxk_flow_ops.info_get = cn20k_flow_info_get;
 }
 
 static int
drivers/net/cnxk/cn20k_flow.c new file +101 -0

101 lines not on this page · raw message

drivers/net/cnxk/cn20k_flow.h new file +21 -0
new file mode 100644
index 0000000000..1e4bd6214a
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+#ifndef __CN20K_FLOW_H__
+#define __CN20K_FLOW_H__
+
+#include <rte_flow_driver.h>
+
+struct rte_flow *cn20k_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
+				   const struct rte_flow_item pattern[],
+				   const struct rte_flow_action actions[],
+				   struct rte_flow_error *error);
+int cn20k_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
+		       struct rte_flow_error *error);
+
+int cn20k_flow_info_get(struct rte_eth_dev *dev, struct rte_flow_port_info *port_info,
+			struct rte_flow_queue_info *queue_info, struct rte_flow_error *err);
+
+#define CNXK_NPC_COUNTERS_MAX 512
+
+#endif /* __CN20K_FLOW_H__ */
drivers/net/cnxk/cn9k_flow.c +1 -1
index dc5476a189..ae4629ea69 100644
@@ -18,7 +18,7 @@ cn9k_flow_create(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
 	int vtag_actions = 0;
 	int mark_actions;
 
-	flow = cnxk_flow_create(eth_dev, attr, pattern, actions, error);
+	flow = cnxk_flow_create_common(eth_dev, attr, pattern, actions, error, false);
 	if (!flow)
 		return NULL;
 
drivers/net/cnxk/cnxk_ethdev_devargs.c +7 -3
index 5bd50bb9a1..bdf5d88b92 100644
@@ -88,8 +88,7 @@ parse_flow_max_priority(const char *key, const char *value, void *extra_args)
 
 	val = atoi(value);
 
-	/* Limit the max priority to 32 */
-	if (val < 1 || val > 32)
+	if (val < 1 || val > ROC_NPC_MAX_MCAM_PRIORITY)
 		return -EINVAL;
 
 	*(uint16_t *)extra_args = val;
@@ -390,7 +389,12 @@ cnxk_ethdev_parse_devargs(struct rte_devargs *devargs, struct cnxk_eth_dev *dev)
 		dev->nix.meta_buf_sz = meta_buf_sz;
 
 	dev->npc.flow_prealloc_size = flow_prealloc_size;
-	dev->npc.flow_max_priority = flow_max_priority;
+
+	if (roc_model_is_cn20k())
+		dev->npc.flow_max_priority = ROC_NPC_MAX_MCAM_PRIORITY;
+	else
+		dev->npc.flow_max_priority = flow_max_priority;
+
 	dev->npc.switch_header_type = switch_header_type;
 	dev->npc.sdp_channel = sdp_chan.channel;
 	dev->npc.sdp_channel_mask = sdp_chan.mask;
drivers/net/cnxk/cnxk_flow.c +7 -11
index e42e2f8deb..fcc60cd4f0 100644
@@ -977,14 +977,6 @@ cnxk_flow_create_common(struct rte_eth_dev *eth_dev, const struct rte_flow_attr
 	return flow;
 }
 
-struct roc_npc_flow *
-cnxk_flow_create(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
-		 const struct rte_flow_item pattern[], const struct rte_flow_action actions[],
-		 struct rte_flow_error *error)
-{
-	return cnxk_flow_create_common(eth_dev, attr, pattern, actions, error, false);
-}
-
 int
 cnxk_flow_destroy_common(struct rte_eth_dev *eth_dev, struct roc_npc_flow *flow,
 			 struct rte_flow_error *error, bool is_rep)
@@ -1083,10 +1075,14 @@ cnxk_flow_query_common(struct rte_eth_dev *eth_dev, struct rte_flow *flow,
 		npc = &rep_dev->parent_dev->npc;
 	}
 
-	if (in_flow->use_pre_alloc)
+	if (in_flow->use_pre_alloc) {
 		rc = roc_npc_inl_mcam_read_counter(in_flow->ctr_id, &query->hits);
-	else
-		rc = roc_npc_mcam_read_counter(npc, in_flow->ctr_id, &query->hits);
+	} else {
+		if (roc_model_is_cn20k())
+			rc = roc_npc_mcam_get_stats(npc, in_flow, &query->hits);
+		else
+			rc = roc_npc_mcam_read_counter(npc, in_flow->ctr_id, &query->hits);
+	}
 	if (rc != 0) {
 		errcode = EIO;
 		errmsg = "Error reading flow counter";
drivers/net/cnxk/cnxk_flow.h +1 -4
index e51d04b2c9..80b8d2c36a 100644
@@ -22,10 +22,6 @@ struct cnxk_rte_flow_action_info {
 
 extern const struct cnxk_rte_flow_term_info term[];
 
-struct roc_npc_flow *cnxk_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
-				      const struct rte_flow_item pattern[],
-				      const struct rte_flow_action actions[],
-				      struct rte_flow_error *error);
 int cnxk_flow_destroy(struct rte_eth_dev *dev, struct roc_npc_flow *flow,
 		      struct rte_flow_error *error);
 
@@ -46,5 +42,6 @@ int cnxk_flow_query_common(struct rte_eth_dev *eth_dev, struct rte_flow *flow,
 			   struct rte_flow_error *error, bool is_rep);
 int cnxk_flow_dev_dump_common(struct rte_eth_dev *eth_dev, struct rte_flow *flow, FILE *file,
 			      struct rte_flow_error *error, bool is_rep);
+int cnxk_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t mtr_id);
 
 #endif /* __CNXK_RTE_FLOW_H__ */
drivers/net/cnxk/cnxk_flow_common.c new file +214 -0

214 lines not on this page · raw message

drivers/net/cnxk/cnxk_flow_common.h new file +19 -0
new file mode 100644
index 0000000000..21289d9daf
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+#ifndef __CNXK_FLOW_COMMON_H__
+#define __CNXK_FLOW_COMMON_H__
+
+#include <rte_flow_driver.h>
+
+struct roc_npc_flow *cnxk_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
+				      const struct rte_flow_item pattern[],
+				      const struct rte_flow_action actions[],
+				      struct rte_flow_error *error);
+
+int cnxk_flow_info_get_common(struct rte_eth_dev *dev, struct rte_flow_port_info *port_info,
+			      struct rte_flow_queue_info *queue_info, struct rte_flow_error *err);
+
+#define CNXK_NPC_COUNTERS_MAX 512
+
+#endif /* __CNXK_FLOW_COMMON_H__ */
drivers/net/cnxk/meson.build +2 -0
index 32ff8aadc0..733ee61c0a 100644
@@ -32,6 +32,7 @@ sources = files(
         'cnxk_eswitch_devargs.c',
         'cnxk_eswitch_flow.c',
         'cnxk_eswitch_rxtx.c',
+        'cnxk_flow_common.c',
         'cnxk_link.c',
         'cnxk_lookup.c',
         'cnxk_ptp.c',
@@ -236,6 +237,7 @@ if soc_type == 'cn20k' or soc_type == 'all'
 # CN20K
 sources += files(
         'cn20k_ethdev.c',
+        'cn20k_flow.c',
         'cn20k_rx_select.c',
         'cn20k_tx_select.c',
 )
Signature · 1 line
2.39.2
#8 lore raw

RE: [EXTERNAL] [dpdk-dev] [PATCH v3 2/2] net/cnxk: support rte flow on cn20k

Quoted 15 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Tuesday, November 12, 2024 3:29 PM
To: Nithin Kumar Dabilpuram <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>; Harman Kalra <[email protected]>
Cc: [email protected]; Satheesh Paul Antonysamy <[email protected]>
Subject: [EXTERNAL] [dpdk-dev] [PATCH v3 2/2] net/cnxk: support rte flow on cn20k

From: Satheesh Paul <psatheesh@ marvell. com> Support for rte flow in cn20k.

Signed-off-by Satheesh Paul <psatheesh@ marvell. com> Reviewed-by: Kiran
Quoted 8 lines

Kumar K <kirankumark@ marvell. com> --- drivers/net/cnxk/cn10k_flow. c | 227
++-----------------------
From: Satheesh Paul <[email protected]>

Support for rte flow in cn20k.

1)Fix https://mails.dpdk.org/archives/test-report/2024-November/823929.html
2) Please rebase t

[for-main]dell[dpdk-next-net-mrvl] $ git pw series apply 33903 Failed to apply patch:
Applying: common/cnxk: support NPC flow on cn20k Using index info to reconstruct a base tree...

M       drivers/common/cnxk/roc_mbox.h
M       drivers/common/cnxk/roc_npc.h
M       drivers/common/cnxk/roc_npc_mcam_dump.c
M       drivers/common/cnxk/version.map

Falling back to patching base and 3-way merge...
Auto-merging drivers/common/cnxk/version.map
Auto-merging drivers/common/cnxk/roc_npc_mcam_dump.c
CONFLICT (content): Merge conflict in drivers/common/cnxk/roc_npc_mcam_dump.c Auto-merging drivers/common/cnxk/roc_npc.h
Auto-merging drivers/common/cnxk/roc_mbox.h
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false" Patch failed at 0001 common/cnxk: support NPC flow on cn20k

#9 lore raw

RE: [EXTERNAL] [dpdk-dev] [PATCH v3 2/2] net/cnxk: support rte flow on cn20k

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Wednesday, January 22, 2025 6:04 PM
To: Satheesh Paul Antonysamy <[email protected]>; Nithin Kumar Dabilpuram <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>; Harman Kalra <[email protected]>
Cc: [email protected]; Satheesh Paul Antonysamy <[email protected]>
Subject: RE: [EXTERNAL] [dpdk-dev] [PATCH v3 2/2] net/cnxk: support rte flow on cn20k

Quoted 18 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Tuesday, November 12, 2024 3:29 PM
To: Nithin Kumar Dabilpuram <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>; Harman Kalra <[email protected]>
Cc: [email protected]; Satheesh Paul Antonysamy <[email protected]>
Subject: [EXTERNAL] [dpdk-dev] [PATCH v3 2/2] net/cnxk: support rte flow on cn20k

From: Satheesh Paul <psatheesh@ marvell. com> Support for rte flow in cn20k.

Signed-off-by Satheesh Paul <psatheesh@ marvell. com> Reviewed-by:

Kiran Kumar K <kirankumark@ marvell. com> ---
drivers/net/cnxk/cn10k_flow. c | 227
++-----------------------
From: Satheesh Paul <[email protected]>

Quoted 4 lines

Support for rte flow in cn20k.

1)Fix https://mails.dpdk.org/archives/test-report/2024-November/823929.html

This checkpatch warning is a false alarm.

2) Please rebase t
Ack.

[for-main]dell[dpdk-next-net-mrvl] $ git pw series apply 33903
Failed to apply patch:
Applying: common/cnxk: support NPC flow on cn20k Using index info to reconstruct a base tree...

M       drivers/common/cnxk/roc_mbox.h
M       drivers/common/cnxk/roc_npc.h
M       drivers/common/cnxk/roc_npc_mcam_dump.c
M       drivers/common/cnxk/version.map

Falling back to patching base and 3-way merge...
Auto-merging drivers/common/cnxk/version.map Auto-merging drivers/common/cnxk/roc_npc_mcam_dump.c CONFLICT (content): Merge conflict in drivers/common/cnxk/roc_npc_mcam_dump.c Auto-merging drivers/common/cnxk/roc_npc.h Auto-merging drivers/common/cnxk/roc_mbox.h
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 common/cnxk: support NPC flow on cn20k

#10 lore raw

PATCH v4 1/2 common/cnxk: support NPC flow on cn20k

In reply to [email protected]

From: Satheesh Paul <[email protected]>

ROC changes to support NPC flow on cn20k.

---
v2:
* Fixed generic platform compiler error.
v3:
* Removed compile time macros.
v4:
* Rebased the patches.

 drivers/common/cnxk/roc_mbox.h          | 144 +++++-
 drivers/common/cnxk/roc_nix.h           |  18 +-
 drivers/common/cnxk/roc_nix_mcast.c     |  40 +-
 drivers/common/cnxk/roc_nix_vlan.c      |  66 ++-
 drivers/common/cnxk/roc_npc.c           |  58 ++-
 drivers/common/cnxk/roc_npc.h           |  59 ++-
 drivers/common/cnxk/roc_npc_mcam.c      | 602 +++++++++++++++++++-----
 drivers/common/cnxk/roc_npc_mcam_dump.c | 279 +++++++++--
 drivers/common/cnxk/roc_npc_priv.h      |  91 ++--
 drivers/common/cnxk/roc_npc_utils.c     | 340 ++++++++++---
 drivers/common/cnxk/version.map         |   1 +
 11 files changed, 1325 insertions(+), 373 deletions(-)
drivers/common/cnxk/roc_mbox.h +123 -21
index f362d55bc2..ab19387330 100644
@@ -244,6 +244,22 @@ struct mbox_msghdr {
 	  npc_get_field_hash_info_req, npc_get_field_hash_info_rsp)            \
 	M(NPC_MCAM_GET_HIT_STATUS, 0x6015, npc_mcam_get_hit_status,            \
 	  npc_mcam_get_hit_status_req, npc_mcam_get_hit_status_rsp)            \
+	M(NPC_MCAM_DEFRAG, 0x6016, npc_defrag, msg_req,	msg_rsp)               \
+	M(NPC_CN20K_GET_KEX_CFG, 0x6017, npc_cn20k_get_kex_cfg, msg_req,       \
+	  npc_cn20k_get_kex_cfg_rsp)                                           \
+	M(NPC_CN20K_MCAM_GET_FREE_COUNT, 0x6018, npc_cn20k_get_free_count,     \
+	  msg_req, npc_cn20k_get_free_count_rsp)                               \
+	M(NPC_CN20K_MCAM_WRITE_ENTRY,	0x6019, npc_cn20k_mcam_write_entry,    \
+	  npc_cn20k_mcam_write_entry_req, msg_rsp)	                       \
+	M(NPC_CN20K_MCAM_ALLOC_AND_WRITE_ENTRY, 0x601a,			       \
+	  npc_cn20k_mcam_alloc_and_write_entry,				       \
+	  npc_cn20k_mcam_alloc_and_write_entry_req,			       \
+	  npc_mcam_alloc_and_write_entry_rsp)				       \
+	M(NPC_CN20K_MCAM_READ_ENTRY,	0x601b, npc_cn20k_mcam_read_entry,     \
+	  npc_mcam_read_entry_req, npc_cn20k_mcam_read_entry_rsp)	       \
+	M(NPC_CN20K_MCAM_READ_BASE_RULE, 0x601c,                               \
+	  npc_cn20k_read_base_steer_rule, msg_req,                             \
+	  npc_cn20k_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)                                                    \
@@ -645,7 +661,7 @@ struct cgx_mac_addr_add_req {
  */
 struct cgx_mac_addr_add_rsp {
 	struct mbox_msghdr hdr;
-	uint8_t __io index;
+	uint32_t __io index;
 };
 
 /* Structure for requesting the operation to
@@ -653,7 +669,7 @@ struct cgx_mac_addr_add_rsp {
  */
 struct cgx_mac_addr_del_req {
 	struct mbox_msghdr hdr;
-	uint8_t __io index;
+	uint32_t __io index;
 };
 
 /* Structure for response against the operation to
@@ -661,7 +677,7 @@ struct cgx_mac_addr_del_req {
  */
 struct cgx_max_dmac_entries_get_rsp {
 	struct mbox_msghdr hdr;
-	uint8_t __io max_dmac_filters;
+	uint32_t __io max_dmac_filters;
 };
 
 struct cgx_link_user_info {
@@ -2485,6 +2501,14 @@ enum npc_af_status {
 	NPC_MCAM_ALLOC_FAILED = -703,
 	NPC_MCAM_PERM_DENIED = -704,
 	NPC_AF_ERR_HIGIG_CONFIG_FAIL = -705,
+	NPC_AF_ERR_HIGIG_NOT_SUPPORTED = -706,
+	NPC_FLOW_INTF_INVALID = -707,
+	NPC_FLOW_CHAN_INVALID = -708,
+	NPC_FLOW_NO_NIXLF = -709,
+	NPC_FLOW_NOT_SUPPORTED = -710,
+	NPC_FLOW_VF_PERM_DENIED = -711,
+	NPC_FLOW_VF_NOT_INIT = -712,
+	NPC_FLOW_VF_OVERLAP = -713,
 };
 
 struct npc_mcam_alloc_entry_req {
@@ -2494,9 +2518,12 @@ struct npc_mcam_alloc_entry_req {
 #define NPC_MCAM_ANY_PRIO    0
 #define NPC_MCAM_LOWER_PRIO  1
 #define NPC_MCAM_HIGHER_PRIO 2
-	uint8_t __io priority; /* Lower or higher w.r.t ref_entry */
+	uint8_t __io ref_priority; /* Lower or higher w.r.t ref_entry */
 	uint16_t __io ref_entry;
 	uint16_t __io count; /* Number of entries requested */
+	uint8_t __io kw_type; /* Key type */
+	uint8_t __io virt;    /* Request virtual index */
+	uint16_t __io rsvd[16];	/* Reserved */
 };
 
 struct npc_mcam_alloc_entry_rsp {
@@ -2508,6 +2535,7 @@ struct npc_mcam_alloc_entry_rsp {
 	uint16_t __io count;	  /* Number of entries allocated */
 	uint16_t __io free_count; /* Number of entries available */
 	uint16_t __io entry_list[NPC_MAX_NONCONTIG_ENTRIES];
+	uint16_t __io rsvd[16];	/* Reserved */
 };
 
 struct npc_mcam_free_entry_req {
@@ -2534,6 +2562,26 @@ struct npc_mcam_write_entry_req {
 	uint8_t __io set_cntr;	   /* Set counter for this entry ? */
 };
 
+struct cn20k_mcam_entry {
+#define NPC_CN20K_MAX_KWS_IN_KEY 8 /* Number of keywords in max keywidth */
+	uint64_t __io kw[NPC_CN20K_MAX_KWS_IN_KEY];
+	uint64_t __io kw_mask[NPC_CN20K_MAX_KWS_IN_KEY];
+	uint64_t __io action;
+	uint64_t __io vtag_action;
+};
+
+struct npc_cn20k_mcam_write_entry_req {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry_data;
+	uint16_t __io entry;	   /* MCAM entry to write this match key */
+	uint16_t __io cntr;	   /* Counter for this MCAM entry */
+	uint8_t __io intf;	   /* Rx or Tx interface */
+	uint8_t __io enable_entry; /* Enable this MCAM entry ? */
+	uint8_t __io hw_prio;	   /* hardware priority, valid for cn20k */
+	uint8_t __io req_kw_type;  /* Type of kw which should be written */
+	uint64_t __io reserved;	   /* reserved for future use */
+};
+
 /* Enable/Disable a given entry */
 struct npc_mcam_ena_dis_entry_req {
 	struct mbox_msghdr hdr;
@@ -2593,12 +2641,25 @@ struct npc_mcam_alloc_and_write_entry_req {
 	struct mbox_msghdr hdr;
 	struct mcam_entry entry_data;
 	uint16_t __io ref_entry;
-	uint8_t __io priority;	   /* Lower or higher w.r.t ref_entry */
+	uint8_t __io ref_priority; /* Lower or higher w.r.t ref_entry */
 	uint8_t __io intf;	   /* Rx or Tx interface */
 	uint8_t __io enable_entry; /* Enable this MCAM entry ? */
 	uint8_t __io alloc_cntr;   /* Allocate counter and map ? */
 };
 
+struct npc_cn20k_mcam_alloc_and_write_entry_req {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry_data;
+	uint16_t __io ref_entry;
+	uint8_t __io ref_prio;	   /* Lower or higher w.r.t ref_entry */
+	uint8_t __io intf;	   /* Rx or Tx interface */
+	uint8_t __io enable_entry; /* Enable this MCAM entry ? */
+	uint8_t __io hw_prio;	   /* hardware priority, valid for cn20k */
+	uint8_t __io virt;	   /* Allocate virtual index */
+	uint8_t __io req_kw_type;  /* Key type to be written */
+	uint16_t __io reserved[4]; /* reserved for future use */
+};
+
 struct npc_mcam_alloc_and_write_entry_rsp {
 	struct mbox_msghdr hdr;
 	uint16_t __io entry;
@@ -2625,6 +2686,48 @@ struct npc_get_kex_cfg_rsp {
 	uint8_t __io mkex_pfl_name[MKEX_NAME_LEN];
 };
 
+struct npc_delete_flow_rsp {
+	struct mbox_msghdr hdr;
+	uint16_t __io cntr_val;
+};
+
+/* Available entries to use */
+struct npc_cn20k_get_free_count_rsp {
+	struct mbox_msghdr hdr;
+	int __io free_x2;
+	int __io free_x4;
+	int __io free_subbanks;
+};
+
+struct npc_cn20k_get_kex_cfg_rsp {
+	struct mbox_msghdr hdr;
+	uint64_t __io rx_keyx_cfg; /* NPC_AF_INTF(0)_KEX_CFG */
+	uint64_t __io tx_keyx_cfg; /* NPC_AF_INTF(1)_KEX_CFG */
+#define NPC_MAX_EXTRACTOR 24
+	/* MKEX Extractor data */
+	uint64_t __io intf_extr[NPC_MAX_INTF][NPC_MAX_EXTRACTOR];
+	/* KEX configuration per extractor */
+	uint64_t __io intf_extr_lt[NPC_MAX_INTF][NPC_MAX_EXTRACTOR][NPC_MAX_LT];
+#define MKEX_NAME_LEN 128
+	uint8_t __io mkex_pfl_name[MKEX_NAME_LEN];
+};
+
+struct npc_get_field_hash_info_req {
+	struct mbox_msghdr hdr;
+	uint8_t intf;
+};
+
+struct npc_get_field_hash_info_rsp {
+	struct mbox_msghdr hdr;
+	uint64_t __io secret_key[3];
+#define NPC_MAX_HASH	  2
+#define NPC_MAX_HASH_MASK 2
+	/* NPC_AF_INTF(0..1)_HASH(0..1)_MASK(0..1) */
+	uint64_t __io hash_mask[NPC_MAX_INTF][NPC_MAX_HASH][NPC_MAX_HASH_MASK];
+	/* NPC_AF_INTF(0..1)_HASH(0..1)_RESULT_CTRL */
+	uint64_t __io hash_ctrl[NPC_MAX_INTF][NPC_MAX_HASH];
+};
+
 enum header_fields {
 	NPC_DMAC,
 	NPC_SMAC,
@@ -2714,6 +2817,8 @@ struct npc_install_flow_req {
 	uint8_t __io vtag1_op;
 	/* old counter value */
 	uint16_t __io cntr_val;
+	/* hardware priority, supported for cn20k */
+	uint8_t __io hw_prio;
 };
 
 struct npc_install_flow_rsp {
@@ -2744,11 +2849,24 @@ struct npc_mcam_read_entry_rsp {
 	uint8_t __io enable;
 };
 
+struct npc_cn20k_mcam_read_entry_rsp {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry_data;
+	uint8_t __io intf;
+	uint8_t __io enable;
+	uint8_t __io hw_prio; /* valid for cn20k */
+};
+
 struct npc_mcam_read_base_rule_rsp {
 	struct mbox_msghdr hdr;
 	struct mcam_entry entry_data;
 };
 
+struct npc_cn20k_mcam_read_base_rule_rsp {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry;
+};
+
 struct npc_mcam_get_stats_req {
 	struct mbox_msghdr hdr;
 	uint16_t __io entry; /* mcam entry */
@@ -2829,22 +2947,6 @@ enum tim_gpio_edge {
 	TIM_GPIO_INVALID,
 };
 
-struct npc_get_field_hash_info_req {
-	struct mbox_msghdr hdr;
-	uint8_t intf;
-};
-
-struct npc_get_field_hash_info_rsp {
-	struct mbox_msghdr hdr;
-	uint64_t __io secret_key[3];
-#define NPC_MAX_HASH	  2
-#define NPC_MAX_HASH_MASK 2
-	/* NPC_AF_INTF(0..1)_HASH(0..1)_MASK(0..1) */
-	uint64_t __io hash_mask[NPC_MAX_INTF][NPC_MAX_HASH][NPC_MAX_HASH_MASK];
-	/* NPC_AF_INTF(0..1)_HASH(0..1)_RESULT_CTRL */
-	uint64_t __io hash_ctrl[NPC_MAX_INTF][NPC_MAX_HASH];
-};
-
 enum ptp_op {
 	PTP_OP_ADJFINE = 0,   /* adjfine(req.scaled_ppm); */
 	PTP_OP_GET_CLOCK = 1, /* rsp.clk = get_clock() */
drivers/common/cnxk/roc_nix.h +6 -12
index f213823b9b..15823ab16c 100644
@@ -983,15 +983,11 @@ bool __roc_api roc_nix_ptp_is_enable(struct roc_nix *roc_nix);
 /* VLAN */
 int __roc_api
 roc_nix_vlan_mcam_entry_read(struct roc_nix *roc_nix, uint32_t index,
-			     struct npc_mcam_read_entry_rsp **rsp);
-int __roc_api roc_nix_vlan_mcam_entry_write(struct roc_nix *roc_nix,
-					    uint32_t index,
-					    struct mcam_entry *entry,
+			     void **rsp);
+int __roc_api roc_nix_vlan_mcam_entry_write(struct roc_nix *roc_nix, uint32_t index, void *entry,
 					    uint8_t intf, uint8_t enable);
-int __roc_api roc_nix_vlan_mcam_entry_alloc_and_write(struct roc_nix *roc_nix,
-						      struct mcam_entry *entry,
-						      uint8_t intf,
-						      uint8_t priority,
+int __roc_api roc_nix_vlan_mcam_entry_alloc_and_write(struct roc_nix *roc_nix, void *entry,
+						      uint8_t intf, uint8_t priority,
 						      uint8_t ref_entry);
 int __roc_api roc_nix_vlan_mcam_entry_free(struct roc_nix *roc_nix,
 					   uint32_t index);
@@ -1012,10 +1008,8 @@ int __roc_api roc_nix_mcast_mcam_entry_alloc(struct roc_nix *roc_nix,
 					     uint16_t index[]);
 int __roc_api roc_nix_mcast_mcam_entry_free(struct roc_nix *roc_nix,
 					    uint32_t index);
-int __roc_api roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix,
-					     struct mcam_entry *entry,
-					     uint32_t index, uint8_t intf,
-					     uint64_t action);
+int __roc_api roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix, void *entry, uint32_t index,
+					     uint8_t intf, uint64_t action);
 int __roc_api roc_nix_mcast_mcam_entry_ena_dis(struct roc_nix *roc_nix, uint32_t index,
 					       bool enable);
 int __roc_api roc_nix_mcast_list_setup(struct mbox *mbox, uint8_t intf, int nb_entries,
drivers/common/cnxk/roc_nix_mcast.c +27 -13
index 615014e820..eab4bde743 100644
@@ -19,7 +19,7 @@ roc_nix_mcast_mcam_entry_alloc(struct roc_nix *roc_nix, uint16_t nb_entries,
 	req = mbox_alloc_msg_npc_mcam_alloc_entry(mbox);
 	if (req == NULL)
 		goto exit;
-	req->priority = priority;
+	req->ref_priority = priority;
 	req->count = nb_entries;
 
 	rc = mbox_process_msg(mbox, (void *)&rsp);
@@ -56,24 +56,38 @@ roc_nix_mcast_mcam_entry_free(struct roc_nix *roc_nix, uint32_t index)
 }
 
 int
-roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix,
-			       struct mcam_entry *entry, uint32_t index,
-			       uint8_t intf, uint64_t action)
+roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix, void *entry, uint32_t index, uint8_t intf,
+			       uint64_t action)
 {
 	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
 	struct dev *dev = &nix->dev;
 	struct mbox *mbox = mbox_get(dev->mbox);
-	struct npc_mcam_write_entry_req *req;
 	int rc = -ENOSPC;
 
-	req = mbox_alloc_msg_npc_mcam_write_entry(mbox);
-	if (req == NULL)
-		goto exit;
-	req->entry = index;
-	req->intf = intf;
-	req->enable_entry = true;
-	mbox_memcpy(&req->entry_data, entry, sizeof(struct mcam_entry));
-	req->entry_data.action = action;
+	if (roc_model_is_cn20k()) {
+		struct npc_cn20k_mcam_write_entry_req *req;
+
+		req = mbox_alloc_msg_npc_cn20k_mcam_write_entry(mbox);
+		if (req == NULL)
+			goto exit;
+		req->entry = index;
+		req->intf = intf;
+		req->enable_entry = true;
+		mbox_memcpy(&req->entry_data, entry, sizeof(struct cn20k_mcam_entry));
+		req->entry_data.action = action;
+
+	} else {
+		struct npc_mcam_write_entry_req *req;
+
+		req = mbox_alloc_msg_npc_mcam_write_entry(mbox);
+		if (req == NULL)
+			goto exit;
+		req->entry = index;
+		req->intf = intf;
+		req->enable_entry = true;
+		mbox_memcpy(&req->entry_data, entry, sizeof(struct mcam_entry));
+		req->entry_data.action = action;
+	}
 
 	rc = mbox_process(mbox);
 exit:
drivers/common/cnxk/roc_nix_vlan.c +45 -21

101 lines not on this page · raw message

drivers/common/cnxk/roc_npc.c +44 -14

96 lines not on this page · raw message

drivers/common/cnxk/roc_npc.h +34 -25

123 lines not on this page · raw message

drivers/common/cnxk/roc_npc_mcam.c +473 -129

861 lines not on this page · raw message

drivers/common/cnxk/roc_npc_mcam_dump.c +232 -47

380 lines not on this page · raw message

drivers/common/cnxk/roc_npc_priv.h +64 -27

174 lines not on this page · raw message

drivers/common/cnxk/roc_npc_utils.c +276 -64

445 lines not on this page · raw message

drivers/common/cnxk/version.map +1 -0
index 37b76c020e..d622848f21 100644
@@ -486,6 +486,7 @@ INTERNAL {
 	roc_npc_mcam_free_counter;
 	roc_npc_mcam_free;
 	roc_npc_mcam_free_entry;
+	roc_npc_mcam_get_stats;
 	roc_npc_mcam_init;
 	roc_npc_mcam_move;
 	roc_npc_mcam_merge_base_steering_rule;
Signature · 1 line
2.39.2
#11 lore raw

PATCH v4 2/2 net/cnxk: support rte flow on cn20k

From: Satheesh Paul <[email protected]>

Support for rte flow in cn20k.

---
 drivers/net/cnxk/cn10k_flow.c          | 227 ++-----------------------
 drivers/net/cnxk/cn10k_flow.h          |  10 +-
 drivers/net/cnxk/cn20k_ethdev.c        |   4 +
 drivers/net/cnxk/cn20k_flow.c          | 101 +++++++++++
 drivers/net/cnxk/cn20k_flow.h          |  21 +++
 drivers/net/cnxk/cn9k_flow.c           |   2 +-
 drivers/net/cnxk/cnxk_ethdev_devargs.c |  10 +-
 drivers/net/cnxk/cnxk_flow.c           |  18 +-
 drivers/net/cnxk/cnxk_flow.h           |   5 +-
 drivers/net/cnxk/cnxk_flow_common.c    | 214 +++++++++++++++++++++++
 drivers/net/cnxk/cnxk_flow_common.h    |  19 +++
 drivers/net/cnxk/meson.build           |   2 +
 12 files changed, 396 insertions(+), 237 deletions(-)
 create mode 100644 drivers/net/cnxk/cn20k_flow.c
 create mode 100644 drivers/net/cnxk/cn20k_flow.h
 create mode 100644 drivers/net/cnxk/cnxk_flow_common.c
 create mode 100644 drivers/net/cnxk/cnxk_flow_common.h
drivers/net/cnxk/cn10k_flow.c +14 -213
index db5e427362..b95fb83f08 100644
@@ -1,215 +1,29 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(C) 2020 Marvell.
  */
-#include "cn10k_flow.h"
+
 #include "cn10k_ethdev.h"
 #include "cn10k_rx.h"
 #include "cnxk_ethdev_mcs.h"
+#include "cnxk_flow_common.h"
+#include <cn10k_flow.h>
 #include <cnxk_flow.h>
 
-static int
-cn10k_mtr_connect(struct rte_eth_dev *eth_dev, uint32_t mtr_id)
-{
-	return nix_mtr_connect(eth_dev, mtr_id);
-}
-
-static int
-cn10k_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t mtr_id)
-{
-	struct rte_mtr_error mtr_error;
-
-	return nix_mtr_destroy(eth_dev, mtr_id, &mtr_error);
-}
-
-static int
-cn10k_mtr_configure(struct rte_eth_dev *eth_dev,
-		    const struct rte_flow_action actions[])
-{
-	uint32_t mtr_id = 0xffff, prev_mtr_id = 0xffff, next_mtr_id = 0xffff;
-	const struct rte_flow_action_meter *mtr_conf;
-	const struct rte_flow_action_queue *q_conf;
-	const struct rte_flow_action_rss *rss_conf;
-	struct cnxk_mtr_policy_node *policy;
-	bool is_mtr_act = false;
-	int tree_level = 0;
-	int rc = -EINVAL, i;
-
-	for (i = 0; actions[i].type != RTE_FLOW_ACTION_TYPE_END; i++) {
-		if (actions[i].type == RTE_FLOW_ACTION_TYPE_METER) {
-			mtr_conf = (const struct rte_flow_action_meter
-					    *)(actions[i].conf);
-			mtr_id = mtr_conf->mtr_id;
-			is_mtr_act = true;
-		}
-		if (actions[i].type == RTE_FLOW_ACTION_TYPE_QUEUE) {
-			q_conf = (const struct rte_flow_action_queue
-					  *)(actions[i].conf);
-			if (is_mtr_act)
-				nix_mtr_rq_update(eth_dev, mtr_id, 1,
-						  &q_conf->index);
-		}
-		if (actions[i].type == RTE_FLOW_ACTION_TYPE_RSS) {
-			rss_conf = (const struct rte_flow_action_rss
-					    *)(actions[i].conf);
-			if (is_mtr_act)
-				nix_mtr_rq_update(eth_dev, mtr_id,
-						  rss_conf->queue_num,
-						  rss_conf->queue);
-		}
-	}
-
-	if (!is_mtr_act)
-		return rc;
-
-	prev_mtr_id = mtr_id;
-	next_mtr_id = mtr_id;
-	while (next_mtr_id != 0xffff) {
-		rc = nix_mtr_validate(eth_dev, next_mtr_id);
-		if (rc)
-			return rc;
-
-		rc = nix_mtr_policy_act_get(eth_dev, next_mtr_id, &policy);
-		if (rc)
-			return rc;
-
-		rc = nix_mtr_color_action_validate(eth_dev, mtr_id,
-						   &prev_mtr_id, &next_mtr_id,
-						   policy, &tree_level);
-		if (rc)
-			return rc;
-	}
-
-	return nix_mtr_configure(eth_dev, mtr_id);
-}
-
-static int
-cn10k_rss_action_validate(struct rte_eth_dev *eth_dev,
-			  const struct rte_flow_attr *attr,
-			  const struct rte_flow_action *act)
-{
-	const struct rte_flow_action_rss *rss;
-
-	if (act == NULL)
-		return -EINVAL;
-
-	rss = (const struct rte_flow_action_rss *)act->conf;
-
-	if (attr->egress) {
-		plt_err("No support of RSS in egress");
-		return -EINVAL;
-	}
-
-	if (eth_dev->data->dev_conf.rxmode.mq_mode != RTE_ETH_MQ_RX_RSS) {
-		plt_err("multi-queue mode is disabled");
-		return -ENOTSUP;
-	}
-
-	if (!rss || !rss->queue_num) {
-		plt_err("no valid queues");
-		return -EINVAL;
-	}
-
-	if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT) {
-		plt_err("non-default RSS hash functions are not supported");
-		return -ENOTSUP;
-	}
-
-	if (rss->key_len && rss->key_len > ROC_NIX_RSS_KEY_LEN) {
-		plt_err("RSS hash key too large");
-		return -ENOTSUP;
-	}
-
-	return 0;
-}
-
 struct rte_flow *
 cn10k_flow_create(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
-		  const struct rte_flow_item pattern[],
-		  const struct rte_flow_action actions[],
+		  const struct rte_flow_item pattern[], const struct rte_flow_action actions[],
 		  struct rte_flow_error *error)
 {
 	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
-	const struct rte_flow_action *action_rss = NULL;
-	const struct rte_flow_action_meter *mtr = NULL;
-	const struct rte_flow_action *act_q = NULL;
 	struct roc_npc *npc = &dev->npc;
 	struct roc_npc_flow *flow;
-	void *mcs_flow = NULL;
 	int vtag_actions = 0;
-	uint32_t req_act = 0;
 	int mark_actions;
-	int i, rc;
-
-	for (i = 0; actions[i].type != RTE_FLOW_ACTION_TYPE_END; i++) {
-		if (actions[i].type == RTE_FLOW_ACTION_TYPE_METER)
-			req_act |= ROC_NPC_ACTION_TYPE_METER;
-
-		if (actions[i].type == RTE_FLOW_ACTION_TYPE_QUEUE) {
-			req_act |= ROC_NPC_ACTION_TYPE_QUEUE;
-			act_q = &actions[i];
-		}
-		if (actions[i].type == RTE_FLOW_ACTION_TYPE_RSS) {
-			req_act |= ROC_NPC_ACTION_TYPE_RSS;
-			action_rss = &actions[i];
-		}
-	}
-
-	if (req_act & ROC_NPC_ACTION_TYPE_METER) {
-		if ((req_act & ROC_NPC_ACTION_TYPE_RSS) &&
-		    ((req_act & ROC_NPC_ACTION_TYPE_QUEUE))) {
-			return NULL;
-		}
-		if (req_act & ROC_NPC_ACTION_TYPE_RSS) {
-			rc = cn10k_rss_action_validate(eth_dev, attr,
-						       action_rss);
-			if (rc)
-				return NULL;
-		} else if (req_act & ROC_NPC_ACTION_TYPE_QUEUE) {
-			const struct rte_flow_action_queue *act_queue;
-			act_queue = (const struct rte_flow_action_queue *)
-					    act_q->conf;
-			if (act_queue->index > eth_dev->data->nb_rx_queues)
-				return NULL;
-		} else {
-			return NULL;
-		}
-	}
-	for (i = 0; actions[i].type != RTE_FLOW_ACTION_TYPE_END; i++) {
-		if (actions[i].type == RTE_FLOW_ACTION_TYPE_METER) {
-			mtr = (const struct rte_flow_action_meter *)actions[i]
-				      .conf;
-			rc = cn10k_mtr_configure(eth_dev, actions);
-			if (rc) {
-				rte_flow_error_set(error, rc,
-					RTE_FLOW_ERROR_TYPE_ACTION, NULL,
-					"Failed to configure mtr ");
-				return NULL;
-			}
-			break;
-		}
-	}
-
-	if (actions[0].type == RTE_FLOW_ACTION_TYPE_SECURITY &&
-	    cnxk_eth_macsec_sess_get_by_sess(dev, actions[0].conf) != NULL) {
-		rc = cnxk_mcs_flow_configure(eth_dev, attr, pattern, actions, error, &mcs_flow);
-		if (rc) {
-			rte_flow_error_set(error, rc, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
-					   "Failed to configure mcs flow");
-			return NULL;
-		}
-		return (struct rte_flow *)mcs_flow;
-	}
 
 	flow = cnxk_flow_create(eth_dev, attr, pattern, actions, error);
-	if (!flow) {
-		if (mtr)
-			nix_mtr_chain_reset(eth_dev, mtr->mtr_id);
 
+	if (!flow)
 		return NULL;
-	} else {
-		if (mtr)
-			cn10k_mtr_connect(eth_dev, mtr->mtr_id);
-	}
 
 	mark_actions = roc_npc_mark_actions_get(npc);
 	if (mark_actions) {
@@ -231,16 +45,7 @@ int
 cn10k_flow_info_get(struct rte_eth_dev *dev, struct rte_flow_port_info *port_info,
 		    struct rte_flow_queue_info *queue_info, struct rte_flow_error *err)
 {
-	RTE_SET_USED(dev);
-	RTE_SET_USED(err);
-
-	memset(port_info, 0, sizeof(*port_info));
-	memset(queue_info, 0, sizeof(*queue_info));
-
-	port_info->max_nb_counters = CN10K_NPC_COUNTERS_MAX;
-	port_info->max_nb_meters = CNXK_NIX_MTR_COUNT_MAX;
-
-	return 0;
+	return cnxk_flow_info_get_common(dev, port_info, queue_info, err);
 }
 
 int
@@ -250,14 +55,12 @@ cn10k_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *rte_flow,
 	struct roc_npc_flow *flow = (struct roc_npc_flow *)rte_flow;
 	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
 	struct roc_npc *npc = &dev->npc;
-	int vtag_actions = 0;
+	int vtag_actions = 0, rc = 0;
 	int mark_actions;
 	uint16_t match_id;
 	uint32_t mtr_id;
-	int rc;
 
-	match_id = (flow->npc_action >> NPC_RX_ACT_MATCH_OFFSET) &
-		   NPC_RX_ACT_MATCH_MASK;
+	match_id = (flow->npc_action >> NPC_RX_ACT_MATCH_OFFSET) & NPC_RX_ACT_MATCH_MASK;
 	if (match_id) {
 		mark_actions = roc_npc_mark_actions_sub_return(npc, 1);
 		if (mark_actions == 0) {
@@ -271,8 +74,7 @@ cn10k_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *rte_flow,
 		if (flow->nix_intf == ROC_NPC_INTF_RX) {
 			vtag_actions = roc_npc_vtag_actions_sub_return(npc, 1);
 			if (vtag_actions == 0) {
-				dev->rx_offload_flags &=
-					~NIX_RX_OFFLOAD_VLAN_STRIP_F;
+				dev->rx_offload_flags &= ~NIX_RX_OFFLOAD_VLAN_STRIP_F;
 				cn10k_eth_set_rx_function(eth_dev);
 			}
 		}
@@ -281,19 +83,18 @@ cn10k_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *rte_flow,
 	if (cnxk_eth_macsec_sess_get_by_sess(dev, (void *)flow) != NULL) {
 		rc = cnxk_mcs_flow_destroy(dev, (void *)flow);
 		if (rc < 0)
-			rte_flow_error_set(error, rc, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-					NULL, "Failed to free mcs flow");
+			rte_flow_error_set(error, rc, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+					   "Failed to free mcs flow");
 		return rc;
 	}
 
 	mtr_id = flow->mtr_id;
 	rc = cnxk_flow_destroy(eth_dev, flow, error);
 	if (!rc && mtr_id != ROC_NIX_MTR_ID_INVALID) {
-		rc = cn10k_mtr_destroy(eth_dev, mtr_id);
+		rc = cnxk_mtr_destroy(eth_dev, mtr_id);
 		if (rc) {
-			rte_flow_error_set(error, ENXIO,
-				RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
-				"Meter attached to this flow does not exist");
+			rte_flow_error_set(error, ENXIO, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+					   "Meter attached to this flow does not exist");
 		}
 	}
 	return rc;
drivers/net/cnxk/cn10k_flow.h +5 -5
index 316b74e6a6..c9e8c86e96 100644
@@ -1,8 +1,8 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(C) 2020 Marvell.
+ * Copyright(C) 2024 Marvell.
  */
-#ifndef __CN10K_RTE_FLOW_H__
-#define __CN10K_RTE_FLOW_H__
+#ifndef __CN10K_FLOW_H__
+#define __CN10K_FLOW_H__
 
 #include <rte_flow_driver.h>
 
@@ -16,6 +16,6 @@ int cn10k_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
 int cn10k_flow_info_get(struct rte_eth_dev *dev, struct rte_flow_port_info *port_info,
 			struct rte_flow_queue_info *queue_info, struct rte_flow_error *err);
 
-#define CN10K_NPC_COUNTERS_MAX 512
+#define CNXK_NPC_COUNTERS_MAX 512
 
-#endif /* __CN10K_RTE_FLOW_H__ */
+#endif /* __CN10K_FLOW_H__ */
drivers/net/cnxk/cn20k_ethdev.c +4 -0
index 37c372d80f..4e4337a6e5 100644
@@ -2,6 +2,7 @@
  * Copyright(C) 2024 Marvell.
  */
 #include "cn20k_ethdev.h"
+#include "cn20k_flow.h"
 #include "cn20k_rx.h"
 #include "cn20k_tx.h"
 
@@ -867,6 +868,9 @@ npc_flow_ops_override(void)
 	init_once = 1;
 
 	/* Update platform specific ops */
+	cnxk_flow_ops.create = cn20k_flow_create;
+	cnxk_flow_ops.destroy = cn20k_flow_destroy;
+	cnxk_flow_ops.info_get = cn20k_flow_info_get;
 }
 
 static int
drivers/net/cnxk/cn20k_flow.c new file +101 -0

101 lines not on this page · raw message

drivers/net/cnxk/cn20k_flow.h new file +21 -0
new file mode 100644
index 0000000000..1e4bd6214a
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+#ifndef __CN20K_FLOW_H__
+#define __CN20K_FLOW_H__
+
+#include <rte_flow_driver.h>
+
+struct rte_flow *cn20k_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
+				   const struct rte_flow_item pattern[],
+				   const struct rte_flow_action actions[],
+				   struct rte_flow_error *error);
+int cn20k_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
+		       struct rte_flow_error *error);
+
+int cn20k_flow_info_get(struct rte_eth_dev *dev, struct rte_flow_port_info *port_info,
+			struct rte_flow_queue_info *queue_info, struct rte_flow_error *err);
+
+#define CNXK_NPC_COUNTERS_MAX 512
+
+#endif /* __CN20K_FLOW_H__ */
drivers/net/cnxk/cn9k_flow.c +1 -1
index dc5476a189..ae4629ea69 100644
@@ -18,7 +18,7 @@ cn9k_flow_create(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
 	int vtag_actions = 0;
 	int mark_actions;
 
-	flow = cnxk_flow_create(eth_dev, attr, pattern, actions, error);
+	flow = cnxk_flow_create_common(eth_dev, attr, pattern, actions, error, false);
 	if (!flow)
 		return NULL;
 
drivers/net/cnxk/cnxk_ethdev_devargs.c +7 -3
index ecc2ea8b77..aa2fe7dfe1 100644
@@ -88,8 +88,7 @@ parse_flow_max_priority(const char *key, const char *value, void *extra_args)
 
 	val = atoi(value);
 
-	/* Limit the max priority to 32 */
-	if (val < 1 || val > 32)
+	if (val < 1 || val > ROC_NPC_MAX_MCAM_PRIORITY)
 		return -EINVAL;
 
 	*(uint16_t *)extra_args = val;
@@ -390,7 +389,12 @@ cnxk_ethdev_parse_devargs(struct rte_devargs *devargs, struct cnxk_eth_dev *dev)
 		dev->nix.meta_buf_sz = meta_buf_sz;
 
 	dev->npc.flow_prealloc_size = flow_prealloc_size;
-	dev->npc.flow_max_priority = flow_max_priority;
+
+	if (roc_model_is_cn20k())
+		dev->npc.flow_max_priority = ROC_NPC_MAX_MCAM_PRIORITY;
+	else
+		dev->npc.flow_max_priority = flow_max_priority;
+
 	dev->npc.switch_header_type = switch_header_type;
 	dev->npc.sdp_channel = sdp_chan.channel;
 	dev->npc.sdp_channel_mask = sdp_chan.mask;
drivers/net/cnxk/cnxk_flow.c +7 -11
index e42e2f8deb..fcc60cd4f0 100644
@@ -977,14 +977,6 @@ cnxk_flow_create_common(struct rte_eth_dev *eth_dev, const struct rte_flow_attr
 	return flow;
 }
 
-struct roc_npc_flow *
-cnxk_flow_create(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
-		 const struct rte_flow_item pattern[], const struct rte_flow_action actions[],
-		 struct rte_flow_error *error)
-{
-	return cnxk_flow_create_common(eth_dev, attr, pattern, actions, error, false);
-}
-
 int
 cnxk_flow_destroy_common(struct rte_eth_dev *eth_dev, struct roc_npc_flow *flow,
 			 struct rte_flow_error *error, bool is_rep)
@@ -1083,10 +1075,14 @@ cnxk_flow_query_common(struct rte_eth_dev *eth_dev, struct rte_flow *flow,
 		npc = &rep_dev->parent_dev->npc;
 	}
 
-	if (in_flow->use_pre_alloc)
+	if (in_flow->use_pre_alloc) {
 		rc = roc_npc_inl_mcam_read_counter(in_flow->ctr_id, &query->hits);
-	else
-		rc = roc_npc_mcam_read_counter(npc, in_flow->ctr_id, &query->hits);
+	} else {
+		if (roc_model_is_cn20k())
+			rc = roc_npc_mcam_get_stats(npc, in_flow, &query->hits);
+		else
+			rc = roc_npc_mcam_read_counter(npc, in_flow->ctr_id, &query->hits);
+	}
 	if (rc != 0) {
 		errcode = EIO;
 		errmsg = "Error reading flow counter";
drivers/net/cnxk/cnxk_flow.h +1 -4
index e51d04b2c9..80b8d2c36a 100644
@@ -22,10 +22,6 @@ struct cnxk_rte_flow_action_info {
 
 extern const struct cnxk_rte_flow_term_info term[];
 
-struct roc_npc_flow *cnxk_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
-				      const struct rte_flow_item pattern[],
-				      const struct rte_flow_action actions[],
-				      struct rte_flow_error *error);
 int cnxk_flow_destroy(struct rte_eth_dev *dev, struct roc_npc_flow *flow,
 		      struct rte_flow_error *error);
 
@@ -46,5 +42,6 @@ int cnxk_flow_query_common(struct rte_eth_dev *eth_dev, struct rte_flow *flow,
 			   struct rte_flow_error *error, bool is_rep);
 int cnxk_flow_dev_dump_common(struct rte_eth_dev *eth_dev, struct rte_flow *flow, FILE *file,
 			      struct rte_flow_error *error, bool is_rep);
+int cnxk_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t mtr_id);
 
 #endif /* __CNXK_RTE_FLOW_H__ */
drivers/net/cnxk/cnxk_flow_common.c new file +214 -0

214 lines not on this page · raw message

drivers/net/cnxk/cnxk_flow_common.h new file +19 -0
new file mode 100644
index 0000000000..21289d9daf
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+#ifndef __CNXK_FLOW_COMMON_H__
+#define __CNXK_FLOW_COMMON_H__
+
+#include <rte_flow_driver.h>
+
+struct roc_npc_flow *cnxk_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
+				      const struct rte_flow_item pattern[],
+				      const struct rte_flow_action actions[],
+				      struct rte_flow_error *error);
+
+int cnxk_flow_info_get_common(struct rte_eth_dev *dev, struct rte_flow_port_info *port_info,
+			      struct rte_flow_queue_info *queue_info, struct rte_flow_error *err);
+
+#define CNXK_NPC_COUNTERS_MAX 512
+
+#endif /* __CNXK_FLOW_COMMON_H__ */
drivers/net/cnxk/meson.build +2 -0
index 32ff8aadc0..733ee61c0a 100644
@@ -32,6 +32,7 @@ sources = files(
         'cnxk_eswitch_devargs.c',
         'cnxk_eswitch_flow.c',
         'cnxk_eswitch_rxtx.c',
+        'cnxk_flow_common.c',
         'cnxk_link.c',
         'cnxk_lookup.c',
         'cnxk_ptp.c',
@@ -236,6 +237,7 @@ if soc_type == 'cn20k' or soc_type == 'all'
 # CN20K
 sources += files(
         'cn20k_ethdev.c',
+        'cn20k_flow.c',
         'cn20k_rx_select.c',
         'cn20k_tx_select.c',
 )
Signature · 1 line
2.39.2
#12 lore raw
In reply to [email protected]
Quoted 18 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Thursday, January 23, 2025 11:23 AM
To: Nithin Kumar Dabilpuram <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>; Harman Kalra <[email protected]>
Cc: [email protected]; Satheesh Paul Antonysamy <[email protected]>
Subject: [EXTERNAL] [dpdk-dev] [PATCH v4 1/2] common/cnxk: support NPC flow on cn20k

From: Satheesh Paul <psatheesh@ marvell. com> ROC changes to support NPC flow on cn20k. Signed-off-by: Satheesh Paul <psatheesh@ marvell. com>

Reviewed-by Kiran Kumar K <kirankumark@ marvell. com> --- v2: * Fixed

generic platform

Quoted 7 lines

From: Satheesh Paul <[email protected]>

ROC changes to support NPC flow on cn20k.

---

_LEN];

drivers/common/cnxk/roc_mbox.h struct npc_get_kex_cfg_rsp { · line 2717

Quoted 5 lines
drivers/common/cnxk/roc_mbox.h +5 -0
+};
+
+struct npc_get_field_hash_info_req {
+	struct mbox_msghdr hdr;
+	uint8_t intf;

1)Looks like __io tag is missing
2)Please update the release note for this feature(rte_flow support for cn20k)

Quoted 3 lines
(quoted diff) +2 -0
+};
+
#13 lore raw

PATCH v5 1/2 common/cnxk: support NPC flow on cn20k

In reply to [email protected]

From: Satheesh Paul <[email protected]>

ROC changes to support NPC flow on cn20k.

---
v2:
* Fixed generic platform compiler error.
v3:
* Removed compile time macros.
v4:
* Rebased the patches.
v5:
* Updated release notes.
* Fixed '__io' label for mbox field.

 drivers/common/cnxk/roc_mbox.h          | 144 +++++-
 drivers/common/cnxk/roc_nix.h           |  18 +-
 drivers/common/cnxk/roc_nix_mcast.c     |  40 +-
 drivers/common/cnxk/roc_nix_vlan.c      |  66 ++-
 drivers/common/cnxk/roc_npc.c           |  58 ++-
 drivers/common/cnxk/roc_npc.h           |  59 ++-
 drivers/common/cnxk/roc_npc_mcam.c      | 602 +++++++++++++++++++-----
 drivers/common/cnxk/roc_npc_mcam_dump.c | 279 +++++++++--
 drivers/common/cnxk/roc_npc_priv.h      |  91 ++--
 drivers/common/cnxk/roc_npc_utils.c     | 340 ++++++++++---
 drivers/common/cnxk/version.map         |   1 +
 11 files changed, 1325 insertions(+), 373 deletions(-)
drivers/common/cnxk/roc_mbox.h +123 -21
index 989f33b0d2..f3024057b5 100644
@@ -244,6 +244,22 @@ struct mbox_msghdr {
 	  npc_get_field_hash_info_req, npc_get_field_hash_info_rsp)            \
 	M(NPC_MCAM_GET_HIT_STATUS, 0x6015, npc_mcam_get_hit_status,            \
 	  npc_mcam_get_hit_status_req, npc_mcam_get_hit_status_rsp)            \
+	M(NPC_MCAM_DEFRAG, 0x6016, npc_defrag, msg_req,	msg_rsp)               \
+	M(NPC_CN20K_GET_KEX_CFG, 0x6017, npc_cn20k_get_kex_cfg, msg_req,       \
+	  npc_cn20k_get_kex_cfg_rsp)                                           \
+	M(NPC_CN20K_MCAM_GET_FREE_COUNT, 0x6018, npc_cn20k_get_free_count,     \
+	  msg_req, npc_cn20k_get_free_count_rsp)                               \
+	M(NPC_CN20K_MCAM_WRITE_ENTRY,	0x6019, npc_cn20k_mcam_write_entry,    \
+	  npc_cn20k_mcam_write_entry_req, msg_rsp)	                       \
+	M(NPC_CN20K_MCAM_ALLOC_AND_WRITE_ENTRY, 0x601a,			       \
+	  npc_cn20k_mcam_alloc_and_write_entry,				       \
+	  npc_cn20k_mcam_alloc_and_write_entry_req,			       \
+	  npc_mcam_alloc_and_write_entry_rsp)				       \
+	M(NPC_CN20K_MCAM_READ_ENTRY,	0x601b, npc_cn20k_mcam_read_entry,     \
+	  npc_mcam_read_entry_req, npc_cn20k_mcam_read_entry_rsp)	       \
+	M(NPC_CN20K_MCAM_READ_BASE_RULE, 0x601c,                               \
+	  npc_cn20k_read_base_steer_rule, msg_req,                             \
+	  npc_cn20k_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)                                                    \
@@ -645,7 +661,7 @@ struct cgx_mac_addr_add_req {
  */
 struct cgx_mac_addr_add_rsp {
 	struct mbox_msghdr hdr;
-	uint8_t __io index;
+	uint32_t __io index;
 };
 
 /* Structure for requesting the operation to
@@ -653,7 +669,7 @@ struct cgx_mac_addr_add_rsp {
  */
 struct cgx_mac_addr_del_req {
 	struct mbox_msghdr hdr;
-	uint8_t __io index;
+	uint32_t __io index;
 };
 
 /* Structure for response against the operation to
@@ -661,7 +677,7 @@ struct cgx_mac_addr_del_req {
  */
 struct cgx_max_dmac_entries_get_rsp {
 	struct mbox_msghdr hdr;
-	uint8_t __io max_dmac_filters;
+	uint32_t __io max_dmac_filters;
 };
 
 struct cgx_link_user_info {
@@ -2485,6 +2501,14 @@ enum npc_af_status {
 	NPC_MCAM_ALLOC_FAILED = -703,
 	NPC_MCAM_PERM_DENIED = -704,
 	NPC_AF_ERR_HIGIG_CONFIG_FAIL = -705,
+	NPC_AF_ERR_HIGIG_NOT_SUPPORTED = -706,
+	NPC_FLOW_INTF_INVALID = -707,
+	NPC_FLOW_CHAN_INVALID = -708,
+	NPC_FLOW_NO_NIXLF = -709,
+	NPC_FLOW_NOT_SUPPORTED = -710,
+	NPC_FLOW_VF_PERM_DENIED = -711,
+	NPC_FLOW_VF_NOT_INIT = -712,
+	NPC_FLOW_VF_OVERLAP = -713,
 };
 
 struct npc_mcam_alloc_entry_req {
@@ -2494,9 +2518,12 @@ struct npc_mcam_alloc_entry_req {
 #define NPC_MCAM_ANY_PRIO    0
 #define NPC_MCAM_LOWER_PRIO  1
 #define NPC_MCAM_HIGHER_PRIO 2
-	uint8_t __io priority; /* Lower or higher w.r.t ref_entry */
+	uint8_t __io ref_priority; /* Lower or higher w.r.t ref_entry */
 	uint16_t __io ref_entry;
 	uint16_t __io count; /* Number of entries requested */
+	uint8_t __io kw_type; /* Key type */
+	uint8_t __io virt;    /* Request virtual index */
+	uint16_t __io rsvd[16];	/* Reserved */
 };
 
 struct npc_mcam_alloc_entry_rsp {
@@ -2508,6 +2535,7 @@ struct npc_mcam_alloc_entry_rsp {
 	uint16_t __io count;	  /* Number of entries allocated */
 	uint16_t __io free_count; /* Number of entries available */
 	uint16_t __io entry_list[NPC_MAX_NONCONTIG_ENTRIES];
+	uint16_t __io rsvd[16];	/* Reserved */
 };
 
 struct npc_mcam_free_entry_req {
@@ -2534,6 +2562,26 @@ struct npc_mcam_write_entry_req {
 	uint8_t __io set_cntr;	   /* Set counter for this entry ? */
 };
 
+struct cn20k_mcam_entry {
+#define NPC_CN20K_MAX_KWS_IN_KEY 8 /* Number of keywords in max keywidth */
+	uint64_t __io kw[NPC_CN20K_MAX_KWS_IN_KEY];
+	uint64_t __io kw_mask[NPC_CN20K_MAX_KWS_IN_KEY];
+	uint64_t __io action;
+	uint64_t __io vtag_action;
+};
+
+struct npc_cn20k_mcam_write_entry_req {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry_data;
+	uint16_t __io entry;	   /* MCAM entry to write this match key */
+	uint16_t __io cntr;	   /* Counter for this MCAM entry */
+	uint8_t __io intf;	   /* Rx or Tx interface */
+	uint8_t __io enable_entry; /* Enable this MCAM entry ? */
+	uint8_t __io hw_prio;	   /* hardware priority, valid for cn20k */
+	uint8_t __io req_kw_type;  /* Type of kw which should be written */
+	uint64_t __io reserved;	   /* reserved for future use */
+};
+
 /* Enable/Disable a given entry */
 struct npc_mcam_ena_dis_entry_req {
 	struct mbox_msghdr hdr;
@@ -2593,12 +2641,25 @@ struct npc_mcam_alloc_and_write_entry_req {
 	struct mbox_msghdr hdr;
 	struct mcam_entry entry_data;
 	uint16_t __io ref_entry;
-	uint8_t __io priority;	   /* Lower or higher w.r.t ref_entry */
+	uint8_t __io ref_priority; /* Lower or higher w.r.t ref_entry */
 	uint8_t __io intf;	   /* Rx or Tx interface */
 	uint8_t __io enable_entry; /* Enable this MCAM entry ? */
 	uint8_t __io alloc_cntr;   /* Allocate counter and map ? */
 };
 
+struct npc_cn20k_mcam_alloc_and_write_entry_req {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry_data;
+	uint16_t __io ref_entry;
+	uint8_t __io ref_prio;	   /* Lower or higher w.r.t ref_entry */
+	uint8_t __io intf;	   /* Rx or Tx interface */
+	uint8_t __io enable_entry; /* Enable this MCAM entry ? */
+	uint8_t __io hw_prio;	   /* hardware priority, valid for cn20k */
+	uint8_t __io virt;	   /* Allocate virtual index */
+	uint8_t __io req_kw_type;  /* Key type to be written */
+	uint16_t __io reserved[4]; /* reserved for future use */
+};
+
 struct npc_mcam_alloc_and_write_entry_rsp {
 	struct mbox_msghdr hdr;
 	uint16_t __io entry;
@@ -2625,6 +2686,48 @@ struct npc_get_kex_cfg_rsp {
 	uint8_t __io mkex_pfl_name[MKEX_NAME_LEN];
 };
 
+struct npc_delete_flow_rsp {
+	struct mbox_msghdr hdr;
+	uint16_t __io cntr_val;
+};
+
+/* Available entries to use */
+struct npc_cn20k_get_free_count_rsp {
+	struct mbox_msghdr hdr;
+	int __io free_x2;
+	int __io free_x4;
+	int __io free_subbanks;
+};
+
+struct npc_cn20k_get_kex_cfg_rsp {
+	struct mbox_msghdr hdr;
+	uint64_t __io rx_keyx_cfg; /* NPC_AF_INTF(0)_KEX_CFG */
+	uint64_t __io tx_keyx_cfg; /* NPC_AF_INTF(1)_KEX_CFG */
+#define NPC_MAX_EXTRACTOR 24
+	/* MKEX Extractor data */
+	uint64_t __io intf_extr[NPC_MAX_INTF][NPC_MAX_EXTRACTOR];
+	/* KEX configuration per extractor */
+	uint64_t __io intf_extr_lt[NPC_MAX_INTF][NPC_MAX_EXTRACTOR][NPC_MAX_LT];
+#define MKEX_NAME_LEN 128
+	uint8_t __io mkex_pfl_name[MKEX_NAME_LEN];
+};
+
+struct npc_get_field_hash_info_req {
+	struct mbox_msghdr hdr;
+	uint8_t __io intf;
+};
+
+struct npc_get_field_hash_info_rsp {
+	struct mbox_msghdr hdr;
+	uint64_t __io secret_key[3];
+#define NPC_MAX_HASH	  2
+#define NPC_MAX_HASH_MASK 2
+	/* NPC_AF_INTF(0..1)_HASH(0..1)_MASK(0..1) */
+	uint64_t __io hash_mask[NPC_MAX_INTF][NPC_MAX_HASH][NPC_MAX_HASH_MASK];
+	/* NPC_AF_INTF(0..1)_HASH(0..1)_RESULT_CTRL */
+	uint64_t __io hash_ctrl[NPC_MAX_INTF][NPC_MAX_HASH];
+};
+
 enum header_fields {
 	NPC_DMAC,
 	NPC_SMAC,
@@ -2714,6 +2817,8 @@ struct npc_install_flow_req {
 	uint8_t __io vtag1_op;
 	/* old counter value */
 	uint16_t __io cntr_val;
+	/* hardware priority, supported for cn20k */
+	uint8_t __io hw_prio;
 };
 
 struct npc_install_flow_rsp {
@@ -2744,11 +2849,24 @@ struct npc_mcam_read_entry_rsp {
 	uint8_t __io enable;
 };
 
+struct npc_cn20k_mcam_read_entry_rsp {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry_data;
+	uint8_t __io intf;
+	uint8_t __io enable;
+	uint8_t __io hw_prio; /* valid for cn20k */
+};
+
 struct npc_mcam_read_base_rule_rsp {
 	struct mbox_msghdr hdr;
 	struct mcam_entry entry_data;
 };
 
+struct npc_cn20k_mcam_read_base_rule_rsp {
+	struct mbox_msghdr hdr;
+	struct cn20k_mcam_entry entry;
+};
+
 struct npc_mcam_get_stats_req {
 	struct mbox_msghdr hdr;
 	uint16_t __io entry; /* mcam entry */
@@ -2829,22 +2947,6 @@ enum tim_gpio_edge {
 	TIM_GPIO_INVALID,
 };
 
-struct npc_get_field_hash_info_req {
-	struct mbox_msghdr hdr;
-	uint8_t intf;
-};
-
-struct npc_get_field_hash_info_rsp {
-	struct mbox_msghdr hdr;
-	uint64_t __io secret_key[3];
-#define NPC_MAX_HASH	  2
-#define NPC_MAX_HASH_MASK 2
-	/* NPC_AF_INTF(0..1)_HASH(0..1)_MASK(0..1) */
-	uint64_t __io hash_mask[NPC_MAX_INTF][NPC_MAX_HASH][NPC_MAX_HASH_MASK];
-	/* NPC_AF_INTF(0..1)_HASH(0..1)_RESULT_CTRL */
-	uint64_t __io hash_ctrl[NPC_MAX_INTF][NPC_MAX_HASH];
-};
-
 enum ptp_op {
 	PTP_OP_ADJFINE = 0,   /* adjfine(req.scaled_ppm); */
 	PTP_OP_GET_CLOCK = 1, /* rsp.clk = get_clock() */
drivers/common/cnxk/roc_nix.h +6 -12
index f213823b9b..15823ab16c 100644
@@ -983,15 +983,11 @@ bool __roc_api roc_nix_ptp_is_enable(struct roc_nix *roc_nix);
 /* VLAN */
 int __roc_api
 roc_nix_vlan_mcam_entry_read(struct roc_nix *roc_nix, uint32_t index,
-			     struct npc_mcam_read_entry_rsp **rsp);
-int __roc_api roc_nix_vlan_mcam_entry_write(struct roc_nix *roc_nix,
-					    uint32_t index,
-					    struct mcam_entry *entry,
+			     void **rsp);
+int __roc_api roc_nix_vlan_mcam_entry_write(struct roc_nix *roc_nix, uint32_t index, void *entry,
 					    uint8_t intf, uint8_t enable);
-int __roc_api roc_nix_vlan_mcam_entry_alloc_and_write(struct roc_nix *roc_nix,
-						      struct mcam_entry *entry,
-						      uint8_t intf,
-						      uint8_t priority,
+int __roc_api roc_nix_vlan_mcam_entry_alloc_and_write(struct roc_nix *roc_nix, void *entry,
+						      uint8_t intf, uint8_t priority,
 						      uint8_t ref_entry);
 int __roc_api roc_nix_vlan_mcam_entry_free(struct roc_nix *roc_nix,
 					   uint32_t index);
@@ -1012,10 +1008,8 @@ int __roc_api roc_nix_mcast_mcam_entry_alloc(struct roc_nix *roc_nix,
 					     uint16_t index[]);
 int __roc_api roc_nix_mcast_mcam_entry_free(struct roc_nix *roc_nix,
 					    uint32_t index);
-int __roc_api roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix,
-					     struct mcam_entry *entry,
-					     uint32_t index, uint8_t intf,
-					     uint64_t action);
+int __roc_api roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix, void *entry, uint32_t index,
+					     uint8_t intf, uint64_t action);
 int __roc_api roc_nix_mcast_mcam_entry_ena_dis(struct roc_nix *roc_nix, uint32_t index,
 					       bool enable);
 int __roc_api roc_nix_mcast_list_setup(struct mbox *mbox, uint8_t intf, int nb_entries,
drivers/common/cnxk/roc_nix_mcast.c +27 -13
index 615014e820..eab4bde743 100644
@@ -19,7 +19,7 @@ roc_nix_mcast_mcam_entry_alloc(struct roc_nix *roc_nix, uint16_t nb_entries,
 	req = mbox_alloc_msg_npc_mcam_alloc_entry(mbox);
 	if (req == NULL)
 		goto exit;
-	req->priority = priority;
+	req->ref_priority = priority;
 	req->count = nb_entries;
 
 	rc = mbox_process_msg(mbox, (void *)&rsp);
@@ -56,24 +56,38 @@ roc_nix_mcast_mcam_entry_free(struct roc_nix *roc_nix, uint32_t index)
 }
 
 int
-roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix,
-			       struct mcam_entry *entry, uint32_t index,
-			       uint8_t intf, uint64_t action)
+roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix, void *entry, uint32_t index, uint8_t intf,
+			       uint64_t action)
 {
 	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
 	struct dev *dev = &nix->dev;
 	struct mbox *mbox = mbox_get(dev->mbox);
-	struct npc_mcam_write_entry_req *req;
 	int rc = -ENOSPC;
 
-	req = mbox_alloc_msg_npc_mcam_write_entry(mbox);
-	if (req == NULL)
-		goto exit;
-	req->entry = index;
-	req->intf = intf;
-	req->enable_entry = true;
-	mbox_memcpy(&req->entry_data, entry, sizeof(struct mcam_entry));
-	req->entry_data.action = action;
+	if (roc_model_is_cn20k()) {
+		struct npc_cn20k_mcam_write_entry_req *req;
+
+		req = mbox_alloc_msg_npc_cn20k_mcam_write_entry(mbox);
+		if (req == NULL)
+			goto exit;
+		req->entry = index;
+		req->intf = intf;
+		req->enable_entry = true;
+		mbox_memcpy(&req->entry_data, entry, sizeof(struct cn20k_mcam_entry));
+		req->entry_data.action = action;
+
+	} else {
+		struct npc_mcam_write_entry_req *req;
+
+		req = mbox_alloc_msg_npc_mcam_write_entry(mbox);
+		if (req == NULL)
+			goto exit;
+		req->entry = index;
+		req->intf = intf;
+		req->enable_entry = true;
+		mbox_memcpy(&req->entry_data, entry, sizeof(struct mcam_entry));
+		req->entry_data.action = action;
+	}
 
 	rc = mbox_process(mbox);
 exit:
drivers/common/cnxk/roc_nix_vlan.c +45 -21

101 lines not on this page · raw message

drivers/common/cnxk/roc_npc.c +44 -14

96 lines not on this page · raw message

drivers/common/cnxk/roc_npc.h +34 -25

123 lines not on this page · raw message

drivers/common/cnxk/roc_npc_mcam.c +473 -129

861 lines not on this page · raw message

drivers/common/cnxk/roc_npc_mcam_dump.c +232 -47

380 lines not on this page · raw message

drivers/common/cnxk/roc_npc_priv.h +64 -27

174 lines not on this page · raw message

drivers/common/cnxk/roc_npc_utils.c +276 -64

445 lines not on this page · raw message

drivers/common/cnxk/version.map +1 -0
index 97562b1663..dc8fb1b29f 100644
@@ -487,6 +487,7 @@ INTERNAL {
 	roc_npc_mcam_free_counter;
 	roc_npc_mcam_free;
 	roc_npc_mcam_free_entry;
+	roc_npc_mcam_get_stats;
 	roc_npc_mcam_init;
 	roc_npc_mcam_move;
 	roc_npc_mcam_merge_base_steering_rule;
Signature · 1 line
2.39.2
#14 lore raw

PATCH v5 2/2 net/cnxk: support rte flow on cn20k

From: Satheesh Paul <[email protected]>

Support for rte flow in cn20k.

---
 doc/guides/rel_notes/release_25_03.rst |   4 +
 drivers/net/cnxk/cn10k_flow.c          | 227 ++-----------------------
 drivers/net/cnxk/cn10k_flow.h          |  10 +-
 drivers/net/cnxk/cn20k_ethdev.c        |   4 +
 drivers/net/cnxk/cn20k_flow.c          | 101 +++++++++++
 drivers/net/cnxk/cn20k_flow.h          |  21 +++
 drivers/net/cnxk/cn9k_flow.c           |   2 +-
 drivers/net/cnxk/cnxk_ethdev_devargs.c |  10 +-
 drivers/net/cnxk/cnxk_flow.c           |  18 +-
 drivers/net/cnxk/cnxk_flow.h           |   5 +-
 drivers/net/cnxk/cnxk_flow_common.c    | 213 +++++++++++++++++++++++
 drivers/net/cnxk/cnxk_flow_common.h    |  19 +++
 drivers/net/cnxk/meson.build           |   2 +
 13 files changed, 399 insertions(+), 237 deletions(-)
 create mode 100644 drivers/net/cnxk/cn20k_flow.c
 create mode 100644 drivers/net/cnxk/cn20k_flow.h
 create mode 100644 drivers/net/cnxk/cnxk_flow_common.c
 create mode 100644 drivers/net/cnxk/cnxk_flow_common.h
doc/guides/rel_notes/release_25_03.rst +4 -0
index 85986ffa61..18a675a6ef 100644
@@ -63,6 +63,10 @@ New Features
   and even substantial part of its code.
   It can be viewed as an extension of rte_ring functionality.
 
+* **Updated Marvell cnxk net driver.**
+
+  * Added rte_flow support for CN20K SoC.
+
 
 Removed Items
 -------------
drivers/net/cnxk/cn10k_flow.c +14 -213

286 lines not on this page · raw message

drivers/net/cnxk/cn10k_flow.h +5 -5
index 316b74e6a6..c9e8c86e96 100644
@@ -1,8 +1,8 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(C) 2020 Marvell.
+ * Copyright(C) 2024 Marvell.
  */
-#ifndef __CN10K_RTE_FLOW_H__
-#define __CN10K_RTE_FLOW_H__
+#ifndef __CN10K_FLOW_H__
+#define __CN10K_FLOW_H__
 
 #include <rte_flow_driver.h>
 
@@ -16,6 +16,6 @@ int cn10k_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
 int cn10k_flow_info_get(struct rte_eth_dev *dev, struct rte_flow_port_info *port_info,
 			struct rte_flow_queue_info *queue_info, struct rte_flow_error *err);
 
-#define CN10K_NPC_COUNTERS_MAX 512
+#define CNXK_NPC_COUNTERS_MAX 512
 
-#endif /* __CN10K_RTE_FLOW_H__ */
+#endif /* __CN10K_FLOW_H__ */
drivers/net/cnxk/cn20k_ethdev.c +4 -0
index 37c372d80f..4e4337a6e5 100644
@@ -2,6 +2,7 @@
  * Copyright(C) 2024 Marvell.
  */
 #include "cn20k_ethdev.h"
+#include "cn20k_flow.h"
 #include "cn20k_rx.h"
 #include "cn20k_tx.h"
 
@@ -867,6 +868,9 @@ npc_flow_ops_override(void)
 	init_once = 1;
 
 	/* Update platform specific ops */
+	cnxk_flow_ops.create = cn20k_flow_create;
+	cnxk_flow_ops.destroy = cn20k_flow_destroy;
+	cnxk_flow_ops.info_get = cn20k_flow_info_get;
 }
 
 static int
drivers/net/cnxk/cn20k_flow.c new file +101 -0

101 lines not on this page · raw message

drivers/net/cnxk/cn20k_flow.h new file +21 -0
new file mode 100644
index 0000000000..1e4bd6214a
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+#ifndef __CN20K_FLOW_H__
+#define __CN20K_FLOW_H__
+
+#include <rte_flow_driver.h>
+
+struct rte_flow *cn20k_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
+				   const struct rte_flow_item pattern[],
+				   const struct rte_flow_action actions[],
+				   struct rte_flow_error *error);
+int cn20k_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
+		       struct rte_flow_error *error);
+
+int cn20k_flow_info_get(struct rte_eth_dev *dev, struct rte_flow_port_info *port_info,
+			struct rte_flow_queue_info *queue_info, struct rte_flow_error *err);
+
+#define CNXK_NPC_COUNTERS_MAX 512
+
+#endif /* __CN20K_FLOW_H__ */
drivers/net/cnxk/cn9k_flow.c +1 -1
index dc5476a189..ae4629ea69 100644
@@ -18,7 +18,7 @@ cn9k_flow_create(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
 	int vtag_actions = 0;
 	int mark_actions;
 
-	flow = cnxk_flow_create(eth_dev, attr, pattern, actions, error);
+	flow = cnxk_flow_create_common(eth_dev, attr, pattern, actions, error, false);
 	if (!flow)
 		return NULL;
 
drivers/net/cnxk/cnxk_ethdev_devargs.c +7 -3
index ecc2ea8b77..aa2fe7dfe1 100644
@@ -88,8 +88,7 @@ parse_flow_max_priority(const char *key, const char *value, void *extra_args)
 
 	val = atoi(value);
 
-	/* Limit the max priority to 32 */
-	if (val < 1 || val > 32)
+	if (val < 1 || val > ROC_NPC_MAX_MCAM_PRIORITY)
 		return -EINVAL;
 
 	*(uint16_t *)extra_args = val;
@@ -390,7 +389,12 @@ cnxk_ethdev_parse_devargs(struct rte_devargs *devargs, struct cnxk_eth_dev *dev)
 		dev->nix.meta_buf_sz = meta_buf_sz;
 
 	dev->npc.flow_prealloc_size = flow_prealloc_size;
-	dev->npc.flow_max_priority = flow_max_priority;
+
+	if (roc_model_is_cn20k())
+		dev->npc.flow_max_priority = ROC_NPC_MAX_MCAM_PRIORITY;
+	else
+		dev->npc.flow_max_priority = flow_max_priority;
+
 	dev->npc.switch_header_type = switch_header_type;
 	dev->npc.sdp_channel = sdp_chan.channel;
 	dev->npc.sdp_channel_mask = sdp_chan.mask;
drivers/net/cnxk/cnxk_flow.c +7 -11
index e42e2f8deb..fcc60cd4f0 100644
@@ -977,14 +977,6 @@ cnxk_flow_create_common(struct rte_eth_dev *eth_dev, const struct rte_flow_attr
 	return flow;
 }
 
-struct roc_npc_flow *
-cnxk_flow_create(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
-		 const struct rte_flow_item pattern[], const struct rte_flow_action actions[],
-		 struct rte_flow_error *error)
-{
-	return cnxk_flow_create_common(eth_dev, attr, pattern, actions, error, false);
-}
-
 int
 cnxk_flow_destroy_common(struct rte_eth_dev *eth_dev, struct roc_npc_flow *flow,
 			 struct rte_flow_error *error, bool is_rep)
@@ -1083,10 +1075,14 @@ cnxk_flow_query_common(struct rte_eth_dev *eth_dev, struct rte_flow *flow,
 		npc = &rep_dev->parent_dev->npc;
 	}
 
-	if (in_flow->use_pre_alloc)
+	if (in_flow->use_pre_alloc) {
 		rc = roc_npc_inl_mcam_read_counter(in_flow->ctr_id, &query->hits);
-	else
-		rc = roc_npc_mcam_read_counter(npc, in_flow->ctr_id, &query->hits);
+	} else {
+		if (roc_model_is_cn20k())
+			rc = roc_npc_mcam_get_stats(npc, in_flow, &query->hits);
+		else
+			rc = roc_npc_mcam_read_counter(npc, in_flow->ctr_id, &query->hits);
+	}
 	if (rc != 0) {
 		errcode = EIO;
 		errmsg = "Error reading flow counter";
drivers/net/cnxk/cnxk_flow.h +1 -4
index e51d04b2c9..80b8d2c36a 100644
@@ -22,10 +22,6 @@ struct cnxk_rte_flow_action_info {
 
 extern const struct cnxk_rte_flow_term_info term[];
 
-struct roc_npc_flow *cnxk_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
-				      const struct rte_flow_item pattern[],
-				      const struct rte_flow_action actions[],
-				      struct rte_flow_error *error);
 int cnxk_flow_destroy(struct rte_eth_dev *dev, struct roc_npc_flow *flow,
 		      struct rte_flow_error *error);
 
@@ -46,5 +42,6 @@ int cnxk_flow_query_common(struct rte_eth_dev *eth_dev, struct rte_flow *flow,
 			   struct rte_flow_error *error, bool is_rep);
 int cnxk_flow_dev_dump_common(struct rte_eth_dev *eth_dev, struct rte_flow *flow, FILE *file,
 			      struct rte_flow_error *error, bool is_rep);
+int cnxk_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t mtr_id);
 
 #endif /* __CNXK_RTE_FLOW_H__ */
drivers/net/cnxk/cnxk_flow_common.c new file +213 -0

213 lines not on this page · raw message

drivers/net/cnxk/cnxk_flow_common.h new file +19 -0
new file mode 100644
index 0000000000..21289d9daf
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+#ifndef __CNXK_FLOW_COMMON_H__
+#define __CNXK_FLOW_COMMON_H__
+
+#include <rte_flow_driver.h>
+
+struct roc_npc_flow *cnxk_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
+				      const struct rte_flow_item pattern[],
+				      const struct rte_flow_action actions[],
+				      struct rte_flow_error *error);
+
+int cnxk_flow_info_get_common(struct rte_eth_dev *dev, struct rte_flow_port_info *port_info,
+			      struct rte_flow_queue_info *queue_info, struct rte_flow_error *err);
+
+#define CNXK_NPC_COUNTERS_MAX 512
+
+#endif /* __CNXK_FLOW_COMMON_H__ */
drivers/net/cnxk/meson.build +2 -0
index 32ff8aadc0..733ee61c0a 100644
@@ -32,6 +32,7 @@ sources = files(
         'cnxk_eswitch_devargs.c',
         'cnxk_eswitch_flow.c',
         'cnxk_eswitch_rxtx.c',
+        'cnxk_flow_common.c',
         'cnxk_link.c',
         'cnxk_lookup.c',
         'cnxk_ptp.c',
@@ -236,6 +237,7 @@ if soc_type == 'cn20k' or soc_type == 'all'
 # CN20K
 sources += files(
         'cn20k_ethdev.c',
+        'cn20k_flow.c',
         'cn20k_rx_select.c',
         'cn20k_tx_select.c',
 )
Signature · 1 line
2.39.2
#15 lore raw
In reply to [email protected]
Quoted 16 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Wednesday, February 5, 2025 11:13 AM
To: Nithin Kumar Dabilpuram <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>; Harman Kalra <[email protected]>
Cc: [email protected]; Satheesh Paul Antonysamy <[email protected]>
Subject: [EXTERNAL] [dpdk-dev] [PATCH v5 1/2] common/cnxk: support NPC flow on cn20k

From: Satheesh Paul <psatheesh@ marvell. com> ROC changes to support NPC flow on cn20k. Signed-off-by: Satheesh Paul <psatheesh@ marvell. com>

Reviewed-by Kiran Kumar K <kirankumark@ marvell. com> --- v2: * Fixed
Quoted 8 lines

generic platform

From: Satheesh Paul <[email protected]>

ROC changes to support NPC flow on cn20k.

Series applied to dpdk-next-net-mrvl/for-main. Thanks