[v3,50/62] net/cnxk: add flow ops get operation

Message ID 20210618103741.26526-51-ndabilpuram@marvell.com (mailing list archive)
State Changes Requested, archived
Delegated to: Jerin Jacob
Headers
Series Marvell CNXK Ethdev Driver |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Nithin Dabilpuram June 18, 2021, 10:37 a.m. UTC
  From: Satheesh Paul <psatheesh@marvell.com>

This patch adds flow ops get operation to enable rte_flow_ops.A

This patch also add support for flow dev dump API.
Every flow rule added will be dumped in the below format.

MCAM Index:1881
Interface :NIX-RX (0)
Priority  :1
NPC RX Action:0X00000000404001
	ActionOp:NIX_RX_ACTIONOP_UCAST (1)
	PF_FUNC: 0X400
	RQ Index:0X004
	Match Id:0000
	Flow Key Alg:0
NPC RX VTAG Action:0X00000000008100
	VTAG0:relptr:0
	lid:0X1
	type:0
Patterns:
	NPC_PARSE_NIBBLE_CHAN:000
	NPC_PARSE_NIBBLE_LA_LTYPE:LA_ETHER
	NPC_PARSE_NIBBLE_LB_LTYPE:NONE
	NPC_PARSE_NIBBLE_LC_LTYPE:LC_IP
	NPC_PARSE_NIBBLE_LD_LTYPE:LD_TCP
	NPC_PARSE_NIBBLE_LE_LTYPE:NONE
	LA_ETHER, hdr offset:0, len:0X6, key offset:0X8,\
		Data:0X4AE124FC7FFF, Mask:0XFFFFFFFFFFFF
	LA_ETHER, hdr offset:0XC, len:0X2, key offset:0X4, Data:0XCA5A,\
		Mask:0XFFFF
	LC_IP, hdr offset:0XC, len:0X8, key offset:0X10,\
		Data:0X0A01010300000000, Mask:0XFFFFFFFF00000000
	LD_TCP, hdr offset:0, len:0X4, key offset:0X18, Data:0X03450000,\
		Mask:0XFFFF0000
MCAM Raw Data :
	DW0     :0000CA5A01202000
	DW0_Mask:0000FFFF0FF0F000
	DW1     :00004AE124FC7FFF
	DW1_Mask:0000FFFFFFFFFFFF
	DW2     :0A01010300000000
	DW2_Mask:FFFFFFFF00000000
	DW3     :0000000003450000
	DW3_Mask:00000000FFFF0000
	DW4     :0000000000000000
	DW4_Mask:0000000000000000
	DW5     :0000000000000000
	DW5_Mask:0000000000000000
	DW6     :0000000000000000
	DW6_Mask:0000000000000000

Signed-off-by: Satheesh Paul <psatheesh@marvell.com>
---
 drivers/common/cnxk/roc_npc.c      |  2 ++
 drivers/net/cnxk/cnxk_ethdev.c     |  3 +++
 drivers/net/cnxk/cnxk_ethdev.h     |  3 ++-
 drivers/net/cnxk/cnxk_ethdev_ops.c | 10 ++++++++++
 drivers/net/cnxk/cnxk_rte_flow.c   | 28 ++++++++++++++++++++++++++++
 5 files changed, 45 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c
index 8a76823..aff4eef 100644
--- a/drivers/common/cnxk/roc_npc.c
+++ b/drivers/common/cnxk/roc_npc.c
@@ -1009,6 +1009,8 @@  roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 	struct npc_flow_list *list;
 	int rc;
 
+	npc->channel = roc_npc->channel;
+
 	flow = plt_zmalloc(sizeof(*flow), 0);
 	if (flow == NULL) {
 		*errcode = NPC_ERR_NO_MEM;
diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
index d1a7f2e..a330875 100644
--- a/drivers/net/cnxk/cnxk_ethdev.c
+++ b/drivers/net/cnxk/cnxk_ethdev.c
@@ -807,6 +807,8 @@  cnxk_nix_configure(struct rte_eth_dev *eth_dev)
 		goto fail_configure;
 	}
 
+	dev->npc.channel = roc_nix_get_base_chan(nix);
+
 	nb_rxq = data->nb_rx_queues;
 	nb_txq = data->nb_tx_queues;
 	rc = -ENOMEM;
@@ -1211,6 +1213,7 @@  struct eth_dev_ops cnxk_eth_dev_ops = {
 	.rxq_info_get = cnxk_nix_rxq_info_get,
 	.txq_info_get = cnxk_nix_txq_info_get,
 	.tx_done_cleanup = cnxk_nix_tx_done_cleanup,
+	.flow_ops_get = cnxk_nix_flow_ops_get,
 };
 
 static int
diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h
index b7869b4..07c87ea 100644
--- a/drivers/net/cnxk/cnxk_ethdev.h
+++ b/drivers/net/cnxk/cnxk_ethdev.h
@@ -273,7 +273,8 @@  int cnxk_nix_rx_queue_intr_disable(struct rte_eth_dev *eth_dev,
 				   uint16_t rx_queue_id);
 int cnxk_nix_pool_ops_supported(struct rte_eth_dev *eth_dev, const char *pool);
 int cnxk_nix_tx_done_cleanup(void *txq, uint32_t free_cnt);
-
+int cnxk_nix_flow_ops_get(struct rte_eth_dev *eth_dev,
+			  const struct rte_flow_ops **ops);
 int cnxk_nix_configure(struct rte_eth_dev *eth_dev);
 int cnxk_nix_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t qid,
 			    uint16_t nb_desc, uint16_t fp_tx_q_sz,
diff --git a/drivers/net/cnxk/cnxk_ethdev_ops.c b/drivers/net/cnxk/cnxk_ethdev_ops.c
index ce94eb6..0b62911 100644
--- a/drivers/net/cnxk/cnxk_ethdev_ops.c
+++ b/drivers/net/cnxk/cnxk_ethdev_ops.c
@@ -300,6 +300,16 @@  cnxk_nix_flow_ctrl_set(struct rte_eth_dev *eth_dev,
 }
 
 int
+cnxk_nix_flow_ops_get(struct rte_eth_dev *eth_dev,
+		      const struct rte_flow_ops **ops)
+{
+	RTE_SET_USED(eth_dev);
+
+	*ops = &cnxk_flow_ops;
+	return 0;
+}
+
+int
 cnxk_nix_mac_addr_set(struct rte_eth_dev *eth_dev, struct rte_ether_addr *addr)
 {
 	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
diff --git a/drivers/net/cnxk/cnxk_rte_flow.c b/drivers/net/cnxk/cnxk_rte_flow.c
index 1695d4f..2dee19e 100644
--- a/drivers/net/cnxk/cnxk_rte_flow.c
+++ b/drivers/net/cnxk/cnxk_rte_flow.c
@@ -322,9 +322,37 @@  cnxk_flow_isolate(struct rte_eth_dev *eth_dev __rte_unused,
 	return -rte_errno;
 }
 
+static int
+cnxk_flow_dev_dump(struct rte_eth_dev *eth_dev, struct rte_flow *flow,
+		   FILE *file, struct rte_flow_error *error)
+{
+	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+	struct roc_npc *npc = &dev->npc;
+
+	if (file == NULL) {
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+				   "Invalid file");
+		return -rte_errno;
+	}
+
+	if (flow != NULL) {
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_HANDLE,
+				   NULL,
+				   "Invalid argument");
+		return -EINVAL;
+	}
+
+	roc_npc_flow_dump(file, npc);
+
+	return 0;
+}
+
 struct rte_flow_ops cnxk_flow_ops = {
 	.validate = cnxk_flow_validate,
 	.flush = cnxk_flow_flush,
 	.query = cnxk_flow_query,
 	.isolate = cnxk_flow_isolate,
+	.dev_dump = cnxk_flow_dev_dump,
 };