Skip to contentSkip to conversation

net/ice: support ddp dump switch rule binary

PATCH Superseded Steve Yang 2 participants 3 messages Oct 18, 2022 Network drivers

lore
Share & tools
lore

Steve Yang

author
#0 lore raw

PATCH 1/1 net/ice: support ddp dump switch rule binary

Dump ICE ddp runtime switch rule binary via following command:
testpmd> ddp dump switch <port_id> <output_file>

You can covert the binary file to readable texture via dpdt tool.

---
 drivers/net/ice/ice_ddp_package.c | 93 +++++++++++++++++++++++++++++++
 drivers/net/ice/ice_testpmd.c     | 80 +++++++++++++++++++++++++-
 drivers/net/ice/rte_pmd_ice.h     |  3 +
 drivers/net/ice/version.map       |  1 +
 4 files changed, 175 insertions(+), 2 deletions(-)
drivers/net/ice/ice_ddp_package.c +93 -0
index c7b5dc7ee7..db6e6e955a 100644
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2022 Intel Corporation
  */
+#include <unistd.h>
+#include <sys/stat.h>
 
 #include <rte_string_fns.h>
 #include <rte_malloc.h>
@@ -9,6 +11,7 @@
 #include "ice_ethdev.h"
 #include "rte_pmd_ice.h"
 
+#define ICE_BLK_MAX_COUNT          512
 #define ICE_BUFF_SEG_HEADER_FLAG   0x1
 #define ICE_PKG_HDR_HEADR_PART1    1
 #define ICE_PKG_HDR_HEADR_PART2    2
@@ -416,3 +419,93 @@ int rte_pmd_ice_dump_package(uint16_t port, uint8_t **buff, uint32_t *size)
 
 	return ice_dump_pkg(dev, buff, size);
 }
+
+static uint16_t
+covert_byte_to_hex(uint8_t **outbuf, const uint8_t *inbuf, uint32_t inbuf_size)
+{
+	uint32_t i;
+	uint8_t *buffer = *outbuf;
+	for (i = 0; i < inbuf_size; ++i)
+		sprintf((char *)(buffer + i * 2), "%02X", inbuf[i]);
+
+	return inbuf_size * 2;
+}
+
+static int
+ice_dump_switch(struct rte_eth_dev *dev, uint8_t **buff2, uint32_t *size)
+{
+	struct ice_hw *hw;
+	int i = 0;
+	uint16_t tbl_id = 0;
+	uint32_t tbl_idx = 0;
+	int tbl_cnt = 0;
+	uint8_t *buffer = *buff2;
+
+	hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	/* table index string format: "0000:" */
+	#define TBL_IDX_STR_SIZE  6
+	for (i = 0; i < ICE_BLK_MAX_COUNT; i++) {
+		int res;
+		uint16_t buff_size;
+		uint8_t *buff;
+		uint32_t offset = 0;
+
+		buff = malloc(ICE_PKG_BUF_SIZE);
+		if (!buff)
+			return ICE_ERR_NO_MEMORY;
+
+		if (tbl_idx == 0) {
+			char tbl_idx_str[TBL_IDX_STR_SIZE];
+			memset(tbl_idx_str, 0, sizeof(tbl_idx_str));
+			sprintf(tbl_idx_str, "%d:", tbl_id);
+			memcpy(buffer, tbl_idx_str, strlen(tbl_idx_str));
+			offset = strlen(tbl_idx_str);
+			buffer += offset;
+		}
+
+		res = ice_aq_get_internal_data(hw,
+			ICE_AQC_DBG_DUMP_CLUSTER_ID_SW,
+			tbl_id, tbl_idx, buff,
+			ICE_PKG_BUF_SIZE,
+			&buff_size, &tbl_id, &tbl_idx, NULL);
+
+		if (res) {
+			free(buff);
+			return res;
+		}
+
+		offset = covert_byte_to_hex(&buffer, buff, buff_size);
+		buffer += offset;
+
+		free(buff);
+
+		tbl_cnt++;
+		if (tbl_idx == 0xffffffff) {
+			tbl_idx = 0;
+			tbl_cnt = 0;
+			memset(buffer, '\n', sizeof(char));
+			buffer++;
+			offset = 0;
+		}
+
+		if (tbl_id == 0xff)
+			break;
+	}
+
+	*size = buffer - *buff2;
+	return 0;
+}
+
+int rte_pmd_ice_dump_switch(uint16_t port, uint8_t **buff, uint32_t *size)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+	if (!is_ice_supported(dev))
+		return -ENOTSUP;
+
+	return ice_dump_switch(dev, buff, size);
+}
drivers/net/ice/ice_testpmd.c +78 -2

108 lines not on this page · raw message

drivers/net/ice/rte_pmd_ice.h +3 -0
index 53c81ccf4e..6a7efc6ce4 100644
@@ -240,6 +240,9 @@ rte_net_ice_dump_proto_xtr_metadata(struct rte_mbuf *m)
 __rte_experimental
 int rte_pmd_ice_dump_package(uint16_t port, uint8_t **buff, uint32_t *size);
 
+__rte_experimental
+int rte_pmd_ice_dump_switch(uint16_t port, uint8_t **buff, uint32_t *size);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/ice/version.map +1 -0
index 60a3f17393..e77e27c95f 100644
@@ -14,4 +14,5 @@ EXPERIMENTAL {
 	rte_net_ice_dynflag_proto_xtr_tcp_mask;
 	rte_net_ice_dynflag_proto_xtr_ip_offset_mask;
 	rte_pmd_ice_dump_package;
+	rte_pmd_ice_dump_switch;
 };
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v2 1/1 net/ice: support ddp dump switch rule binary

Dump ICE ddp runtime switch rule binary via following command:
testpmd> ddp dump switch <port_id> <output_file>

You can covert the binary file to readable texture via dpdt tool.

---
 drivers/net/ice/ice_ddp_package.c | 93 +++++++++++++++++++++++++++++++
 drivers/net/ice/ice_ethdev.h      |  2 +
 drivers/net/ice/ice_testpmd.c     | 80 +++++++++++++++++++++++++-
 drivers/net/ice/version.map       |  1 +
 4 files changed, 174 insertions(+), 2 deletions(-)
drivers/net/ice/ice_ddp_package.c +93 -0
index a5b42c57d9..b881fa3ded 100644
@@ -3,6 +3,8 @@
  */
 
 #include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
 
 #include <rte_string_fns.h>
 #include <rte_malloc.h>
@@ -10,6 +12,7 @@
 
 #include "ice_ethdev.h"
 
+#define ICE_BLK_MAX_COUNT          512
 #define ICE_BUFF_SEG_HEADER_FLAG   0x1
 #define ICE_PKG_HDR_HEADR_PART1    1
 #define ICE_PKG_HDR_HEADR_PART2    2
@@ -417,3 +420,93 @@ int rte_pmd_ice_dump_package(uint16_t port, uint8_t **buff, uint32_t *size)
 
 	return ice_dump_pkg(dev, buff, size);
 }
+
+static uint16_t
+covert_byte_to_hex(uint8_t **outbuf, const uint8_t *inbuf, uint32_t inbuf_size)
+{
+	uint32_t i;
+	uint8_t *buffer = *outbuf;
+	for (i = 0; i < inbuf_size; ++i)
+		sprintf((char *)(buffer + i * 2), "%02X", inbuf[i]);
+
+	return inbuf_size * 2;
+}
+
+static int
+ice_dump_switch(struct rte_eth_dev *dev, uint8_t **buff2, uint32_t *size)
+{
+	struct ice_hw *hw;
+	int i = 0;
+	uint16_t tbl_id = 0;
+	uint32_t tbl_idx = 0;
+	int tbl_cnt = 0;
+	uint8_t *buffer = *buff2;
+
+	hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	/* table index string format: "0000:" */
+	#define TBL_IDX_STR_SIZE  6
+	for (i = 0; i < ICE_BLK_MAX_COUNT; i++) {
+		int res;
+		uint16_t buff_size;
+		uint8_t *buff;
+		uint32_t offset = 0;
+
+		buff = malloc(ICE_PKG_BUF_SIZE);
+		if (!buff)
+			return ICE_ERR_NO_MEMORY;
+
+		if (tbl_idx == 0) {
+			char tbl_idx_str[TBL_IDX_STR_SIZE];
+			memset(tbl_idx_str, 0, sizeof(tbl_idx_str));
+			sprintf(tbl_idx_str, "%d:", tbl_id);
+			memcpy(buffer, tbl_idx_str, strlen(tbl_idx_str));
+			offset = strlen(tbl_idx_str);
+			buffer += offset;
+		}
+
+		res = ice_aq_get_internal_data(hw,
+			ICE_AQC_DBG_DUMP_CLUSTER_ID_SW,
+			tbl_id, tbl_idx, buff,
+			ICE_PKG_BUF_SIZE,
+			&buff_size, &tbl_id, &tbl_idx, NULL);
+
+		if (res) {
+			free(buff);
+			return res;
+		}
+
+		offset = covert_byte_to_hex(&buffer, buff, buff_size);
+		buffer += offset;
+
+		free(buff);
+
+		tbl_cnt++;
+		if (tbl_idx == 0xffffffff) {
+			tbl_idx = 0;
+			tbl_cnt = 0;
+			memset(buffer, '\n', sizeof(char));
+			buffer++;
+			offset = 0;
+		}
+
+		if (tbl_id == 0xff)
+			break;
+	}
+
+	*size = buffer - *buff2;
+	return 0;
+}
+
+int rte_pmd_ice_dump_switch(uint16_t port, uint8_t **buff, uint32_t *size)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+	if (!is_ice_supported(dev))
+		return -ENOTSUP;
+
+	return ice_dump_switch(dev, buff, size);
+}
drivers/net/ice/ice_ethdev.h +2 -0
index a4b8ce2956..487a331117 100644
@@ -734,4 +734,6 @@ ice_align_floor(int n)
 __rte_experimental
 int rte_pmd_ice_dump_package(uint16_t port, uint8_t **buff, uint32_t *size);
 
+__rte_experimental
+int rte_pmd_ice_dump_switch(uint16_t port, uint8_t **buff, uint32_t *size);
 #endif /* _ICE_ETHDEV_H_ */
drivers/net/ice/ice_testpmd.c +78 -2

108 lines not on this page · raw message

drivers/net/ice/version.map +1 -0
index 67b7ec6e80..d70c250e9a 100644
@@ -7,4 +7,5 @@ EXPERIMENTAL {
 
 	# added in 19.11
 	rte_pmd_ice_dump_package;
+	rte_pmd_ice_dump_switch;
 };
Signature · 1 line
2.25.1
Acked-by on v2 1/1 Applied
#2 lore raw
Quoted 10 lines

-----Original Message-----
From: Yang, SteveX <[email protected]>
Sent: Tuesday, October 18, 2022 2:48 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, SteveX <[email protected]>
Subject: [PATCH v2] net/ice: support ddp dump switch rule binary

Quoted 6 lines

Dump ICE ddp runtime switch rule binary via following command:
testpmd> ddp dump switch <port_id> <output_file>

You can covert the binary file to readable texture via dpdt tool.

Applied to dpdk-next-net-intel.

Thanks
Qi