Skip to contentSkip to conversation

common/cnxk: support mirror flow action

PATCH Superseded [email protected] 3 participants 8 messages Dec 14, 2023 – Dec 15, 2023 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 common/cnxk: support mirror flow action

From: Satheesh Paul <[email protected]>

Add ROC API to support mirror flow action.

---
 drivers/common/cnxk/roc_mbox.h      | 56 +++++++++++++++++
 drivers/common/cnxk/roc_nix.h       |  8 ++-
 drivers/common/cnxk/roc_nix_mcast.c | 86 ++++++++++++++++++++++++++
 drivers/common/cnxk/roc_npc.c       | 94 +++++++++++++++++++++++++----
 drivers/common/cnxk/roc_npc.h       | 19 +++++-
 drivers/common/cnxk/roc_npc_mcam.c  | 56 +++++++++++++----
 drivers/common/cnxk/roc_npc_priv.h  |  3 +-
 drivers/common/cnxk/version.map     |  2 +
 8 files changed, 295 insertions(+), 29 deletions(-)
drivers/common/cnxk/roc_mbox.h +56 -0
index 05434aec5a..3257a370bc 100644
@@ -298,6 +298,11 @@ struct mbox_msghdr {
 	M(NIX_FREE_BPIDS, 0x8029, nix_free_bpids, nix_bpids, msg_rsp)          \
 	M(NIX_RX_CHAN_CFG, 0x802a, nix_rx_chan_cfg, nix_rx_chan_cfg,           \
 	  nix_rx_chan_cfg)                                                     \
+	M(NIX_MCAST_GRP_CREATE, 0x802b, nix_mcast_grp_create, nix_mcast_grp_create_req,            \
+	  nix_mcast_grp_create_rsp)                                                                \
+	M(NIX_MCAST_GRP_DESTROY, 0x802c, nix_mcast_grp_destroy, nix_mcast_grp_destroy_req, msg_rsp)\
+	M(NIX_MCAST_GRP_UPDATE, 0x802d, nix_mcast_grp_update, nix_mcast_grp_update_req,            \
+	  nix_mcast_grp_update_rsp)                                                                \
 	/* MCS mbox IDs (range 0xa000 - 0xbFFF) */                                                 \
 	M(MCS_ALLOC_RESOURCES, 0xa000, mcs_alloc_resources, mcs_alloc_rsrc_req,                    \
 	  mcs_alloc_rsrc_rsp)                                                                      \
@@ -1768,6 +1773,57 @@ struct nix_rx_chan_cfg {
 	uint64_t __io rsvd;
 };
 
+struct nix_mcast_grp_create_req {
+	struct mbox_msghdr hdr;
+#define NIX_MCAST_INGRESS 0
+#define NIX_MCAST_EGRESS  1
+	uint8_t __io dir;
+	uint8_t __io reserved[11];
+	/* Reserving few bytes for future requirement */
+};
+
+struct nix_mcast_grp_create_rsp {
+	struct mbox_msghdr hdr;
+	/* This mcast_grp_idx should be passed during MCAM
+	 * write entry for multicast. AF will identify the
+	 * corresponding multicast table index associated
+	 * with the group id and program the same to MCAM entry.
+	 * This group id is also needed during group delete
+	 * and update request.
+	 */
+	uint32_t __io mcast_grp_idx;
+};
+struct nix_mcast_grp_destroy_req {
+	struct mbox_msghdr hdr;
+	/* Group id returned by nix_mcast_grp_create_rsp */
+	uint32_t __io mcast_grp_idx;
+};
+
+struct nix_mcast_grp_update_req {
+	struct mbox_msghdr hdr;
+	/* Group id returned by nix_mcast_grp_create_rsp */
+	uint32_t __io mcast_grp_idx;
+	/* Number of multicast/mirror entries requested */
+	uint32_t __io num_mce_entry;
+#define NIX_MCE_ENTRY_MAX 64
+#define NIX_RX_RQ	  0
+#define NIX_RX_RSS	  1
+	/* Receive queue or RSS index within pf_func */
+	uint32_t __io rq_rss_index[NIX_MCE_ENTRY_MAX];
+	uint16_t __io pcifunc[NIX_MCE_ENTRY_MAX];
+	uint16_t __io channel[NIX_MCE_ENTRY_MAX];
+#define NIX_MCAST_OP_ADD_ENTRY 0
+#define NIX_MCAST_OP_DEL_ENTRY 1
+	/* Destination type. 0:Receive queue, 1:RSS*/
+	uint8_t __io dest_type[NIX_MCE_ENTRY_MAX];
+	uint8_t __io op;
+};
+
+struct nix_mcast_grp_update_rsp {
+	struct mbox_msghdr hdr;
+	uint32_t __io mce_start_index;
+};
+
 /* Global NIX inline IPSec configuration */
 struct nix_inline_ipsec_cfg {
 	struct mbox_msghdr hdr;
drivers/common/cnxk/roc_nix.h +6 -2
index 82997c38ce..c1ebf971f7 100644
@@ -1005,6 +1005,10 @@ 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_ena_dis(struct roc_nix *roc_nix,
-					       uint32_t index, bool enable);
+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,
+				       uint16_t *pf_funcs, uint16_t *channels, uint32_t *rqs,
+				       uint32_t *grp_index, uint32_t *start_index);
+int __roc_api roc_nix_mcast_list_free(struct mbox *mbox, uint32_t mcast_grp_index);
 #endif /* _ROC_NIX_H_ */
drivers/common/cnxk/roc_nix_mcast.c +86 -0

89 lines not on this page · raw message

drivers/common/cnxk/roc_npc.c +82 -12

165 lines not on this page · raw message

drivers/common/cnxk/roc_npc.h +18 -1
index cb59db2220..e880a7fa67 100644
@@ -196,11 +196,19 @@ enum roc_npc_action_type {
 	ROC_NPC_ACTION_TYPE_PORT_ID = (1 << 16),
 	ROC_NPC_ACTION_TYPE_METER = (1 << 17),
 	ROC_NPC_ACTION_TYPE_AGE = (1 << 18),
+	ROC_NPC_ACTION_TYPE_SAMPLE = (1 << 19),
 };
 
 struct roc_npc_action {
 	enum roc_npc_action_type type; /**< Action type. */
-	const void *conf; /**< Pointer to action configuration object. */
+	const void *conf;	       /**< Pointer to action configuration object. */
+};
+
+struct roc_npc_action_sample {
+	uint32_t ratio;	      /**< packets sampled equals to '1/ratio'. */
+	uint32_t action_type; /* PF or VF or PORT_ID target. */
+	uint16_t pf_func;
+	uint16_t channel;
 };
 
 struct roc_npc_action_mark {
@@ -294,6 +302,8 @@ struct roc_npc_spi_to_sa_action_info {
 	bool has_action;
 };
 
+struct mbox;
+
 struct roc_npc_flow {
 	uint8_t nix_intf;
 	uint8_t enable;
@@ -322,6 +332,13 @@ struct roc_npc_flow {
 	void *age_context;
 	uint32_t timeout;
 	bool has_age_action;
+	bool is_sampling_rule;
+	uint32_t recv_queue;
+	uint32_t mcast_grp_index;
+	uint32_t mce_start_index;
+#define ROC_NPC_MIRROR_LIST_SIZE 2
+	uint16_t mcast_pf_funcs[ROC_NPC_MIRROR_LIST_SIZE];
+	uint16_t mcast_channels[ROC_NPC_MIRROR_LIST_SIZE];
 
 	TAILQ_ENTRY(roc_npc_flow) next;
 };
drivers/common/cnxk/roc_npc_mcam.c +44 -12

100 lines not on this page · raw message

drivers/common/cnxk/roc_npc_priv.h +1 -2
index 424f8e207a..c0809407a6 100644
@@ -493,8 +493,7 @@ void npc_age_flow_list_entry_delete(struct roc_npc *npc, struct roc_npc_flow *fl
 uint32_t npc_aged_flows_get(void *args);
 int npc_aged_flows_bitmap_alloc(struct roc_npc *roc_npc);
 void npc_aged_flows_bitmap_free(struct roc_npc *roc_npc);
-int npc_aging_ctrl_thread_create(struct roc_npc *roc_npc,
-				 const struct roc_npc_action_age *age,
+int npc_aging_ctrl_thread_create(struct roc_npc *roc_npc, const struct roc_npc_action_age *age,
 				 struct roc_npc_flow *flow);
 void npc_aging_ctrl_thread_destroy(struct roc_npc *roc_npc);
 #endif /* _ROC_NPC_PRIV_H_ */
drivers/common/cnxk/version.map +2 -0
index 52faf676ba..1b531da36d 100644
@@ -294,6 +294,8 @@ INTERNAL {
 	roc_nix_mac_promisc_mode_enable;
 	roc_nix_mac_rxtx_start_stop;
 	roc_nix_max_pkt_len;
+	roc_nix_mcast_list_free;
+	roc_nix_mcast_list_setup;
 	roc_nix_mcast_mcam_entry_alloc;
 	roc_nix_mcast_mcam_entry_ena_dis;
 	roc_nix_mcast_mcam_entry_free;
Signature · 1 line
2.39.2
#1 lore raw

PATCH 2/3 net/cnxk: support mirror flow action

From: Satheesh Paul <[email protected]>

Added RTE_FLOW_ACTION_TYPE_SAMPLE action type for cnxk device.

---
 doc/guides/nics/features/cnxk.ini |   1 +
 drivers/net/cnxk/cnxk_flow.c      | 121 ++++++++++++++++++++++++++++--
 2 files changed, 115 insertions(+), 7 deletions(-)
doc/guides/nics/features/cnxk.ini +1 -0
index cc7deaeaa9..94e7a6ab8d 100644
@@ -97,6 +97,7 @@ port_id              = Y
 queue                = Y
 represented_port     = Y
 rss                  = Y
+sample               = Y
 security             = Y
 skip_cman            = Y
 vf                   = Y
drivers/net/cnxk/cnxk_flow.c +114 -7

181 lines not on this page · raw message

Signature · 1 line
2.39.2
#2 lore raw

RE: [EXT] [dpdk-dev] [PATCH 2/3] net/cnxk: support mirror flow action

Quoted 14 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Thursday, December 14, 2023 4:28 PM
To: Nithin Kumar Dabilpuram <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>
Cc: [email protected]; Satheesh Paul Antonysamy <[email protected]>
Subject: [EXT] [dpdk-dev] [PATCH 2/3] net/cnxk: support mirror flow action

External Email

Quoted 7 lines

----------------------------------------------------------------------
From: Satheesh Paul <[email protected]>

Added RTE_FLOW_ACTION_TYPE_SAMPLE action type for cnxk device.

Please update the release notes for this new feature.

#3 lore raw

PATCH 3/3 common/cnxk: add egress mirror support

In reply to [email protected]

From: Satha Rao <[email protected]>

Added ROC api to send packets on multiple links when egress mirror enabled.

---
 drivers/common/cnxk/roc_nix.h        |  2 +
 drivers/common/cnxk/roc_nix_tm_ops.c | 70 ++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_npc.c        | 26 +++++++++++
 drivers/common/cnxk/version.map      |  1 +
 4 files changed, 99 insertions(+)
drivers/common/cnxk/roc_nix.h +2 -0
index c1ebf971f7..84e6fc3df5 100644
@@ -755,6 +755,8 @@ int __roc_api roc_nix_tm_mark_config(struct roc_nix *roc_nix,
 				     int mark_red);
 uint64_t __roc_api roc_nix_tm_mark_format_get(struct roc_nix *roc_nix,
 					      uint64_t *flags);
+int __roc_api roc_nix_tm_egress_link_cfg_set(struct roc_nix *roc_nix, uint64_t dst_pf_func,
+					     bool enable);
 
 /* Ingress Policer API */
 int __roc_api roc_nix_bpf_timeunit_get(struct roc_nix *roc_nix,
drivers/common/cnxk/roc_nix_tm_ops.c +70 -0

73 lines not on this page · raw message

drivers/common/cnxk/roc_npc.c +26 -0
index 65f99549c9..9a0fe5f4e2 100644
@@ -1595,6 +1595,21 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 		goto err_exit;
 	}
 
+	/* If Egress mirror requested then enable TL3_TL2_LINK_CFG */
+	if (flow->is_sampling_rule && (flow->nix_intf == NIX_INTF_TX)) {
+		if (flow->mcast_pf_funcs[0] == npc->pf_func)
+			rc = roc_nix_tm_egress_link_cfg_set(roc_npc->roc_nix,
+							    flow->mcast_pf_funcs[1], true);
+		else
+			rc = roc_nix_tm_egress_link_cfg_set(roc_npc->roc_nix,
+							    flow->mcast_pf_funcs[0], true);
+		if (rc) {
+			plt_err("Adding egress mirror failed");
+			*errcode = rc;
+			goto err_exit;
+		}
+	}
+
 	rc = npc_rss_action_program(roc_npc, actions, flow);
 	if (rc != 0) {
 		*errcode = rc;
@@ -1706,6 +1721,17 @@ roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow)
 			return rc;
 	}
 
+	/* Disable egress mirror rule */
+	if (flow->is_sampling_rule && (flow->nix_intf == NIX_INTF_TX)) {
+		if (flow->mcast_pf_funcs[0] == npc->pf_func)
+			rc = roc_nix_tm_egress_link_cfg_set(roc_npc->roc_nix,
+							    flow->mcast_pf_funcs[1], false);
+		else
+			rc = roc_nix_tm_egress_link_cfg_set(roc_npc->roc_nix,
+							    flow->mcast_pf_funcs[0], false);
+		if (rc)
+			plt_err("Failed to remove egress mirror rule");
+	}
 	if (flow->is_sampling_rule)
 		roc_nix_mcast_list_free(npc->mbox, flow->mcast_grp_index);
 
drivers/common/cnxk/version.map +1 -0
index 1b531da36d..7b6afa63a9 100644
@@ -355,6 +355,7 @@ INTERNAL {
 	roc_nix_switch_hdr_set;
 	roc_nix_eeprom_info_get;
 	roc_nix_smq_flush;
+	roc_nix_tm_egress_link_cfg_set;
 	roc_nix_tm_dump;
 	roc_nix_tm_err_to_rte_err;
 	roc_nix_tm_fini;
Signature · 1 line
2.39.2
#4 lore raw

PATCH v2 1/3 common/cnxk: support mirror flow action

In reply to [email protected]

From: Satheesh Paul <[email protected]>

Add ROC API to support mirror flow action.

---
v2:
* Updated release notes.

Depends-on: series-30556 ("common/cnxk: support PPPoE flow item type in ROC API")

 drivers/common/cnxk/roc_mbox.h      | 56 +++++++++++++++++
 drivers/common/cnxk/roc_nix.h       |  8 ++-
 drivers/common/cnxk/roc_nix_mcast.c | 86 ++++++++++++++++++++++++++
 drivers/common/cnxk/roc_npc.c       | 94 +++++++++++++++++++++++++----
 drivers/common/cnxk/roc_npc.h       | 19 +++++-
 drivers/common/cnxk/roc_npc_mcam.c  | 56 +++++++++++++----
 drivers/common/cnxk/roc_npc_priv.h  |  3 +-
 drivers/common/cnxk/version.map     |  2 +
 8 files changed, 295 insertions(+), 29 deletions(-)
drivers/common/cnxk/roc_mbox.h +56 -0
index 05434aec5a..3257a370bc 100644
@@ -298,6 +298,11 @@ struct mbox_msghdr {
 	M(NIX_FREE_BPIDS, 0x8029, nix_free_bpids, nix_bpids, msg_rsp)          \
 	M(NIX_RX_CHAN_CFG, 0x802a, nix_rx_chan_cfg, nix_rx_chan_cfg,           \
 	  nix_rx_chan_cfg)                                                     \
+	M(NIX_MCAST_GRP_CREATE, 0x802b, nix_mcast_grp_create, nix_mcast_grp_create_req,            \
+	  nix_mcast_grp_create_rsp)                                                                \
+	M(NIX_MCAST_GRP_DESTROY, 0x802c, nix_mcast_grp_destroy, nix_mcast_grp_destroy_req, msg_rsp)\
+	M(NIX_MCAST_GRP_UPDATE, 0x802d, nix_mcast_grp_update, nix_mcast_grp_update_req,            \
+	  nix_mcast_grp_update_rsp)                                                                \
 	/* MCS mbox IDs (range 0xa000 - 0xbFFF) */                                                 \
 	M(MCS_ALLOC_RESOURCES, 0xa000, mcs_alloc_resources, mcs_alloc_rsrc_req,                    \
 	  mcs_alloc_rsrc_rsp)                                                                      \
@@ -1768,6 +1773,57 @@ struct nix_rx_chan_cfg {
 	uint64_t __io rsvd;
 };
 
+struct nix_mcast_grp_create_req {
+	struct mbox_msghdr hdr;
+#define NIX_MCAST_INGRESS 0
+#define NIX_MCAST_EGRESS  1
+	uint8_t __io dir;
+	uint8_t __io reserved[11];
+	/* Reserving few bytes for future requirement */
+};
+
+struct nix_mcast_grp_create_rsp {
+	struct mbox_msghdr hdr;
+	/* This mcast_grp_idx should be passed during MCAM
+	 * write entry for multicast. AF will identify the
+	 * corresponding multicast table index associated
+	 * with the group id and program the same to MCAM entry.
+	 * This group id is also needed during group delete
+	 * and update request.
+	 */
+	uint32_t __io mcast_grp_idx;
+};
+struct nix_mcast_grp_destroy_req {
+	struct mbox_msghdr hdr;
+	/* Group id returned by nix_mcast_grp_create_rsp */
+	uint32_t __io mcast_grp_idx;
+};
+
+struct nix_mcast_grp_update_req {
+	struct mbox_msghdr hdr;
+	/* Group id returned by nix_mcast_grp_create_rsp */
+	uint32_t __io mcast_grp_idx;
+	/* Number of multicast/mirror entries requested */
+	uint32_t __io num_mce_entry;
+#define NIX_MCE_ENTRY_MAX 64
+#define NIX_RX_RQ	  0
+#define NIX_RX_RSS	  1
+	/* Receive queue or RSS index within pf_func */
+	uint32_t __io rq_rss_index[NIX_MCE_ENTRY_MAX];
+	uint16_t __io pcifunc[NIX_MCE_ENTRY_MAX];
+	uint16_t __io channel[NIX_MCE_ENTRY_MAX];
+#define NIX_MCAST_OP_ADD_ENTRY 0
+#define NIX_MCAST_OP_DEL_ENTRY 1
+	/* Destination type. 0:Receive queue, 1:RSS*/
+	uint8_t __io dest_type[NIX_MCE_ENTRY_MAX];
+	uint8_t __io op;
+};
+
+struct nix_mcast_grp_update_rsp {
+	struct mbox_msghdr hdr;
+	uint32_t __io mce_start_index;
+};
+
 /* Global NIX inline IPSec configuration */
 struct nix_inline_ipsec_cfg {
 	struct mbox_msghdr hdr;
drivers/common/cnxk/roc_nix.h +6 -2
index 82997c38ce..c1ebf971f7 100644
@@ -1005,6 +1005,10 @@ 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_ena_dis(struct roc_nix *roc_nix,
-					       uint32_t index, bool enable);
+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,
+				       uint16_t *pf_funcs, uint16_t *channels, uint32_t *rqs,
+				       uint32_t *grp_index, uint32_t *start_index);
+int __roc_api roc_nix_mcast_list_free(struct mbox *mbox, uint32_t mcast_grp_index);
 #endif /* _ROC_NIX_H_ */
drivers/common/cnxk/roc_nix_mcast.c +86 -0

89 lines not on this page · raw message

drivers/common/cnxk/roc_npc.c +82 -12

165 lines not on this page · raw message

drivers/common/cnxk/roc_npc.h +18 -1
index cb59db2220..e880a7fa67 100644
@@ -196,11 +196,19 @@ enum roc_npc_action_type {
 	ROC_NPC_ACTION_TYPE_PORT_ID = (1 << 16),
 	ROC_NPC_ACTION_TYPE_METER = (1 << 17),
 	ROC_NPC_ACTION_TYPE_AGE = (1 << 18),
+	ROC_NPC_ACTION_TYPE_SAMPLE = (1 << 19),
 };
 
 struct roc_npc_action {
 	enum roc_npc_action_type type; /**< Action type. */
-	const void *conf; /**< Pointer to action configuration object. */
+	const void *conf;	       /**< Pointer to action configuration object. */
+};
+
+struct roc_npc_action_sample {
+	uint32_t ratio;	      /**< packets sampled equals to '1/ratio'. */
+	uint32_t action_type; /* PF or VF or PORT_ID target. */
+	uint16_t pf_func;
+	uint16_t channel;
 };
 
 struct roc_npc_action_mark {
@@ -294,6 +302,8 @@ struct roc_npc_spi_to_sa_action_info {
 	bool has_action;
 };
 
+struct mbox;
+
 struct roc_npc_flow {
 	uint8_t nix_intf;
 	uint8_t enable;
@@ -322,6 +332,13 @@ struct roc_npc_flow {
 	void *age_context;
 	uint32_t timeout;
 	bool has_age_action;
+	bool is_sampling_rule;
+	uint32_t recv_queue;
+	uint32_t mcast_grp_index;
+	uint32_t mce_start_index;
+#define ROC_NPC_MIRROR_LIST_SIZE 2
+	uint16_t mcast_pf_funcs[ROC_NPC_MIRROR_LIST_SIZE];
+	uint16_t mcast_channels[ROC_NPC_MIRROR_LIST_SIZE];
 
 	TAILQ_ENTRY(roc_npc_flow) next;
 };
drivers/common/cnxk/roc_npc_mcam.c +44 -12

100 lines not on this page · raw message

drivers/common/cnxk/roc_npc_priv.h +1 -2
index 424f8e207a..c0809407a6 100644
@@ -493,8 +493,7 @@ void npc_age_flow_list_entry_delete(struct roc_npc *npc, struct roc_npc_flow *fl
 uint32_t npc_aged_flows_get(void *args);
 int npc_aged_flows_bitmap_alloc(struct roc_npc *roc_npc);
 void npc_aged_flows_bitmap_free(struct roc_npc *roc_npc);
-int npc_aging_ctrl_thread_create(struct roc_npc *roc_npc,
-				 const struct roc_npc_action_age *age,
+int npc_aging_ctrl_thread_create(struct roc_npc *roc_npc, const struct roc_npc_action_age *age,
 				 struct roc_npc_flow *flow);
 void npc_aging_ctrl_thread_destroy(struct roc_npc *roc_npc);
 #endif /* _ROC_NPC_PRIV_H_ */
drivers/common/cnxk/version.map +2 -0
index 52faf676ba..1b531da36d 100644
@@ -294,6 +294,8 @@ INTERNAL {
 	roc_nix_mac_promisc_mode_enable;
 	roc_nix_mac_rxtx_start_stop;
 	roc_nix_max_pkt_len;
+	roc_nix_mcast_list_free;
+	roc_nix_mcast_list_setup;
 	roc_nix_mcast_mcam_entry_alloc;
 	roc_nix_mcast_mcam_entry_ena_dis;
 	roc_nix_mcast_mcam_entry_free;
Signature · 1 line
2.39.2
#5 lore raw

PATCH v2 2/3 net/cnxk: support mirror flow action

From: Satheesh Paul <[email protected]>

Added RTE_FLOW_ACTION_TYPE_SAMPLE action type for cnxk device.

---
 doc/guides/nics/features/cnxk.ini      |   1 +
 doc/guides/rel_notes/release_24_03.rst |   1 +
 drivers/net/cnxk/cnxk_flow.c           | 121 +++++++++++++++++++++++--
 3 files changed, 116 insertions(+), 7 deletions(-)
doc/guides/nics/features/cnxk.ini +1 -0
index cc7deaeaa9..94e7a6ab8d 100644
@@ -97,6 +97,7 @@ port_id              = Y
 queue                = Y
 represented_port     = Y
 rss                  = Y
+sample               = Y
 security             = Y
 skip_cman            = Y
 vf                   = Y
doc/guides/rel_notes/release_24_03.rst +1 -0
index 866dd60fbf..282a3f9c8c 100644
@@ -65,6 +65,7 @@ New Features
 * **Updated Marvell cnxk net driver.**
 
   * Added support for ``RTE_FLOW_ITEM_TYPE_PPPOES`` flow item.
+  * Added support for ``RTE_FLOW_ACTION_TYPE_SAMPLE`` flow item.
 
 Removed Items
 -------------
drivers/net/cnxk/cnxk_flow.c +114 -7

181 lines not on this page · raw message

Signature · 1 line
2.39.2
#7 lore raw

PATCH v2 3/3 common/cnxk: add egress mirror support

In reply to [email protected]

From: Satha Rao <[email protected]>

Added ROC api to send packets on multiple links when egress mirror enabled.

---
 drivers/common/cnxk/roc_nix.h        |  2 +
 drivers/common/cnxk/roc_nix_tm_ops.c | 70 ++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_npc.c        | 26 +++++++++++
 drivers/common/cnxk/version.map      |  1 +
 4 files changed, 99 insertions(+)
drivers/common/cnxk/roc_nix.h +2 -0
index c1ebf971f7..84e6fc3df5 100644
@@ -755,6 +755,8 @@ int __roc_api roc_nix_tm_mark_config(struct roc_nix *roc_nix,
 				     int mark_red);
 uint64_t __roc_api roc_nix_tm_mark_format_get(struct roc_nix *roc_nix,
 					      uint64_t *flags);
+int __roc_api roc_nix_tm_egress_link_cfg_set(struct roc_nix *roc_nix, uint64_t dst_pf_func,
+					     bool enable);
 
 /* Ingress Policer API */
 int __roc_api roc_nix_bpf_timeunit_get(struct roc_nix *roc_nix,
drivers/common/cnxk/roc_nix_tm_ops.c +70 -0

73 lines not on this page · raw message

drivers/common/cnxk/roc_npc.c +26 -0
index 65f99549c9..9a0fe5f4e2 100644
@@ -1595,6 +1595,21 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 		goto err_exit;
 	}
 
+	/* If Egress mirror requested then enable TL3_TL2_LINK_CFG */
+	if (flow->is_sampling_rule && (flow->nix_intf == NIX_INTF_TX)) {
+		if (flow->mcast_pf_funcs[0] == npc->pf_func)
+			rc = roc_nix_tm_egress_link_cfg_set(roc_npc->roc_nix,
+							    flow->mcast_pf_funcs[1], true);
+		else
+			rc = roc_nix_tm_egress_link_cfg_set(roc_npc->roc_nix,
+							    flow->mcast_pf_funcs[0], true);
+		if (rc) {
+			plt_err("Adding egress mirror failed");
+			*errcode = rc;
+			goto err_exit;
+		}
+	}
+
 	rc = npc_rss_action_program(roc_npc, actions, flow);
 	if (rc != 0) {
 		*errcode = rc;
@@ -1706,6 +1721,17 @@ roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow)
 			return rc;
 	}
 
+	/* Disable egress mirror rule */
+	if (flow->is_sampling_rule && (flow->nix_intf == NIX_INTF_TX)) {
+		if (flow->mcast_pf_funcs[0] == npc->pf_func)
+			rc = roc_nix_tm_egress_link_cfg_set(roc_npc->roc_nix,
+							    flow->mcast_pf_funcs[1], false);
+		else
+			rc = roc_nix_tm_egress_link_cfg_set(roc_npc->roc_nix,
+							    flow->mcast_pf_funcs[0], false);
+		if (rc)
+			plt_err("Failed to remove egress mirror rule");
+	}
 	if (flow->is_sampling_rule)
 		roc_nix_mcast_list_free(npc->mbox, flow->mcast_grp_index);
 
drivers/common/cnxk/version.map +1 -0
index 1b531da36d..7b6afa63a9 100644
@@ -355,6 +355,7 @@ INTERNAL {
 	roc_nix_switch_hdr_set;
 	roc_nix_eeprom_info_get;
 	roc_nix_smq_flush;
+	roc_nix_tm_egress_link_cfg_set;
 	roc_nix_tm_dump;
 	roc_nix_tm_err_to_rte_err;
 	roc_nix_tm_fini;
Signature · 1 line
2.39.2