DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v1 0/2] ICE ddp download tool
@ 2022-05-11  8:02 Steve Yang
  2022-05-11  8:02 ` [PATCH v1 1/2] net/ice: support dump ice ddp package Steve Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Steve Yang @ 2022-05-11  8:02 UTC (permalink / raw)
  To: dev; +Cc: yuying.zhang, qiming.yang, qi.z.zhang, mdr, Steve Yang

Support dump ice PF ddp package via testpmd command line.

Add command line:
    ddp dump <port_id> <profile_path>

Parameters:
    <port_id>       the PF Port ID
    <profile_path>  dumped package profile file, if not a absolute path,
                    it will be dumped to testpmd running directory.

For example:
testpmd> ddp dump 0 current.pkg

If you want to dump ice VF ddp package, you need bind other unused PF port
of the NIC first, and then dump the PF ddp package as target output.

Steve Yang (2):
  net/ice: support dump ice ddp package
  app/testpmd: support dump_pkg command for ice

 app/test-pmd/cmdline.c            |  74 ++++++
 drivers/net/ice/ice_ddp_package.c | 418 ++++++++++++++++++++++++++++++
 drivers/net/ice/ice_ethdev.c      |   5 +
 drivers/net/ice/ice_ethdev.h      |   1 +
 drivers/net/ice/meson.build       |   1 +
 drivers/net/ice/rte_pmd_ice.h     |   3 +
 drivers/net/ice/version.map       |   1 +
 7 files changed, 503 insertions(+)
 create mode 100644 drivers/net/ice/ice_ddp_package.c

-- 
2.27.0


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

* [PATCH v1 1/2] net/ice: support dump ice ddp package
  2022-05-11  8:02 [PATCH v1 0/2] ICE ddp download tool Steve Yang
@ 2022-05-11  8:02 ` Steve Yang
  2022-05-18  4:22   ` Zhang, Qi Z
  2022-05-18 15:21   ` Stephen Hemminger
  2022-05-11  8:02 ` [PATCH v1 2/2] app/testpmd: support dump_pkg command for ice Steve Yang
  2022-05-12  2:06 ` [PATCH v2 0/2] ICE ddp download tool Steve Yang
  2 siblings, 2 replies; 24+ messages in thread
From: Steve Yang @ 2022-05-11  8:02 UTC (permalink / raw)
  To: dev; +Cc: yuying.zhang, qiming.yang, qi.z.zhang, mdr, Steve Yang

Send the AQ command to acquire ice ddp package, and dump the binary to
output file.

Export rte dump package API (rte_pmd_ice_dump_package) for application.

Signed-off-by: Steve Yang <stevex.yang@intel.com>
---
 drivers/net/ice/ice_ddp_package.c | 418 ++++++++++++++++++++++++++++++
 drivers/net/ice/ice_ethdev.c      |   5 +
 drivers/net/ice/ice_ethdev.h      |   1 +
 drivers/net/ice/meson.build       |   1 +
 drivers/net/ice/rte_pmd_ice.h     |   3 +
 drivers/net/ice/version.map       |   1 +
 6 files changed, 429 insertions(+)
 create mode 100644 drivers/net/ice/ice_ddp_package.c

diff --git a/drivers/net/ice/ice_ddp_package.c b/drivers/net/ice/ice_ddp_package.c
new file mode 100644
index 0000000000..c1a1ca8aba
--- /dev/null
+++ b/drivers/net/ice/ice_ddp_package.c
@@ -0,0 +1,418 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#include <rte_string_fns.h>
+#include <rte_malloc.h>
+#include <rte_tailq.h>
+
+#include "ice_ethdev.h"
+#include "rte_pmd_ice.h"
+
+#define ICE_BUFF_SEG_HEADER_FLAG   0x1
+#define ICE_PKG_HDR_HEADR_PART1    1
+#define ICE_PKG_HDR_HEADR_PART2    2
+#define ICE_PKG_HDR_GM_SEG_OFFSET  16
+#define ICE_PKG_HDR_ICE_SEG_OFFSET 100
+#define ICE_PKG_GM_SEG_TYPE        1
+#define ICE_PKG_MAJOR_VERSION      1
+#define ICE_PKG_GM_SEG_SIZE        84
+#define SPACE_CHAR                 0x20
+#define ICE_PKG_ICE_SEG_TYPE       0x10
+#define ICE_PKG_ICE_SEG_SIZE_BASE  56
+
+#define ICE_PKG_COPY_STRING(dst, src)	\
+	do {\
+		char *_dst = (dst); \
+		const char *_src = (src); \
+		memset(_dst, SPACE_CHAR, ICE_PKG_NAME_SIZE); \
+		strncpy(_dst, _src, strlen(_src) + 1); \
+	} while (0)
+
+/* Package header */
+struct ice_package_header {
+	struct __hdr {
+		uint32_t h1; /* header part 1 */
+		uint32_t h2; /* header part 2 */
+	} header;
+	uint32_t gm_seg_offset;	 /* Global Metadata segment: 16 */
+	uint32_t ice_seg_offset; /* ICE segment: 100 */
+	struct ice_global_metadata_seg gm_seg;
+	struct __ice_seg {
+		struct ice_generic_seg_hdr hdr;
+		uint32_t devid_count;
+		struct ice_pkg_ver nvm_ver;
+	} ice_seg;
+
+	uint32_t buff_count;
+};
+
+struct ice_buff_seg_header {
+	__le16 flag;
+	__le16 length;
+	__le16 type;
+	__le16 reserve;		/* 0 */
+	__le16 header_len;	/* 0x0C */
+	__le16 data_size;	/* length - header_len */
+};
+
+struct ice_buff_seg_simple {
+	struct ice_buff_seg_header header;
+	__le16 seg_end;
+};
+
+struct ice_buff_seg_simple_data {
+	__le16 type;
+	__le32 addr;
+	__le16 len;
+	__le16 seg_end;
+};
+
+struct ice_buff_seg_series {
+	struct ice_buff_seg_header header;
+	uint16_t offset_delta;
+	uint16_t offset[2];
+};
+
+struct ice_buff_seg_series_data {
+	__le16 type;
+	__le32 begin_addr;
+	__le16 len;
+	__le32 end_addr;
+	__le16 last_len;
+	__le16 offset_delta;
+	__le16 seg_end;
+	uint8_t padding;
+};
+
+struct ice_buff_seg_series_with_sub {
+	struct ice_buff_seg_header header;
+	uint16_t sub_block_num;
+};
+
+struct ice_buff_seg_series_with_sub_data {
+	__le16 type;
+	__le32 begin_addr;
+	__le16 len;
+	__le32 end_addr;
+	__le16 last_len;
+	__le16 sblk_size;
+};
+
+
+static const
+uint16_t ice_buff_seg_header_size = sizeof(struct ice_buff_seg_header);
+
+static void
+write_buffer_simple(uint8_t **buff)
+{
+	uint16_t i;
+	/* ICE ddp package simple segment template */
+	const struct ice_buff_seg_simple_data buff_data[] = {
+	    {0x0001, 0x00000, 0x0030, 0x0000},
+	    {0x000a, 0x01000, 0x0810, 0x0800},
+	    {0x000b, 0x02000, 0x00d8, 0x0000},
+	    {0x000d, 0x06000, 0x0810, 0x0400},
+	    {0x000f, 0x09000, 0x0110, 0x0100},
+	    {0x0011, 0x17000, 0x001d, 0x0000},
+	    {0x0012, 0x18000, 0x0014, 0x0000},
+	    {0x0014, 0x19000, 0x0810, 0x0800},
+	    {0x0015, 0x1a000, 0x00d8, 0x0000},
+	    {0x0017, 0x1e000, 0x0810, 0x0400},
+	    {0x0019, 0x21000, 0x0090, 0x0080},
+	    {0x001b, 0x27000, 0x001d, 0x0000},
+	    {0x001c, 0x28000, 0x0014, 0x0000},
+	    {0x001e, 0x29000, 0x0810, 0x0800},
+	    {0x001f, 0x2a000, 0x00d8, 0x0000},
+	    {0x0021, 0x2e000, 0x0810, 0x0400},
+	    {0x0023, 0x31000, 0x0090, 0x0080},
+	    {0x0025, 0x36000, 0x001d, 0x0000},
+	    {0x0026, 0x37000, 0x0014, 0x0000},
+	    {0x0028, 0x38000, 0x0810, 0x0800},
+	    {0x0029, 0x39000, 0x00d8, 0x0000},
+	    {0x002b, 0x3d000, 0x0810, 0x0400},
+	    {0x002d, 0x40000, 0x0090, 0x0080},
+	    {0x002f, 0x45000, 0x001d, 0x0000},
+	    {0x0030, 0x46000, 0x0014, 0x0000},
+	    {0x0035, 0x57000, 0x0010, 0x0000},
+	    {0x003a, 0x67000, 0x0190, 0x0010},
+	    {0x003b, 0x68000, 0x0810, 0x0800},
+	    {0x003f, 0x79000, 0x0010, 0x0000},
+	    {0x0044, 0x89000, 0x0190, 0x0010},
+	    {0x0045, 0x8a000, 0x0810, 0x0800},
+	    {0x0046, 0x8b000, 0x001c, 0x0000},
+	    {0x0047, 0x8c000, 0x001c, 0x0000},
+	    {0x0048, 0x8d000, 0x0410, 0x0080},
+	    {0x0049, 0x8e000, 0x0410, 0x0080},
+	    {0x004a, 0x8f000, 0x0028, 0x0006},
+	    {0x004b, 0x90000, 0x0028, 0x0006},
+	    {0x004c, 0x91000, 0x0890, 0x0080},
+	    {0x004d, 0x92000, 0x0890, 0x0080},
+	    {0x004e, 0x93000, 0x0350, 0x0040},
+	    {0x004f, 0x94000, 0x0350, 0x0040},
+	    {0x0050, 0x95000, 0x0810, 0x0800},
+	    {0x0051, 0x96000, 0x00d8, 0x0000},
+	    {0x0053, 0x9a000, 0x0810, 0x0400},
+	    {0x0055, 0x9c000, 0x0030, 0x0020},
+	    {0x0057, 0x9f000, 0x001d, 0x0000},
+	    {0x0058, 0xa0000, 0x0014, 0x0000},
+	    {0x005a, 0xa1000, 0x0024, 0x0000},
+	    {0x005b, 0xa2000, 0x0024, 0x0000},
+	    {0x005d, 0xa4000, 0x0810, 0x0100},
+	    {0x020d, 0xa8000, 0x0414, 0x0400},
+	    {0x020e, 0xa9000, 0x0214, 0x0200},
+	    {0x020f, 0xaa000, 0x0114, 0x0100},
+	    {0x0210, 0xab000, 0x0114, 0x0100},
+	    {0x0217, 0xaf000, 0x0414, 0x0400},
+	    {0x0218, 0xb0000, 0x0214, 0x0200},
+	    {0x0219, 0xb1000, 0x0094, 0x0080},
+	    {0x021a, 0xb2000, 0x0094, 0x0080},
+	    {0x0221, 0xb6000, 0x0414, 0x0400},
+	    {0x0222, 0xb7000, 0x0214, 0x0200},
+	    {0x0223, 0xb8000, 0x0094, 0x0080},
+	    {0x0224, 0xb9000, 0x0094, 0x0080},
+	    {0x022b, 0xbd000, 0x0414, 0x0400},
+	    {0x022c, 0xbe000, 0x0214, 0x0200},
+	    {0x022d, 0xbf000, 0x0094, 0x0080},
+	    {0x022e, 0xc0000, 0x0094, 0x0080},
+	    {0x0238, 0xc1000, 0x0114, 0x0100},
+	    {0x0253, 0xc5000, 0x0414, 0x0400},
+	    {0x0254, 0xc6000, 0x0054, 0x0040},
+	    {0x0255, 0xc7000, 0x0034, 0x0020},
+	    {0x0256, 0xc8000, 0x0034, 0x0020},
+	};
+
+	for (i = 0; i < ARRAY_SIZE(buff_data); i++) {
+		const struct ice_buff_seg_simple_data *seg = &buff_data[i];
+		struct ice_buff_seg_simple buff_seg;
+		uint8_t *buffer = &(*buff)[seg->addr];
+
+		memset(buffer, 0xFF, ICE_PKG_BUF_SIZE);
+		buff_seg.header.flag = ICE_BUFF_SEG_HEADER_FLAG;
+		buff_seg.header.length = seg->len;
+		buff_seg.header.type = seg->type;
+		buff_seg.header.reserve = 0x0;
+		buff_seg.header.header_len =
+			sizeof(struct ice_buff_seg_header);
+		buff_seg.header.data_size =
+			buff_seg.header.length - buff_seg.header.header_len;
+		buff_seg.seg_end = seg->seg_end;
+
+		memset(buffer, 0x00, buff_seg.header.length);
+		memcpy(buffer, &buff_seg, sizeof(struct ice_buff_seg_simple));
+	}
+}
+
+static void
+write_buffer_block(uint8_t **buff)
+{
+	uint16_t i;
+	/* ICE ddp package multiple segments template 1 */
+	const struct ice_buff_seg_series_data buff_data[] = {
+		{0x000c, 0x03000, 0x1000, 0x05000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x0010, 0x0a000, 0x0fd0, 0x16000, 0x0310, 0x0015, 0x0004, 0},
+		{0x0016, 0x1b000, 0x1000, 0x1d000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x001a, 0x22000, 0x0f90, 0x26000, 0x0210, 0x001f, 0x0004, 0},
+		{0x0020, 0x2b000, 0x1000, 0x2d000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x0024, 0x32000, 0x0fd0, 0x35000, 0x00d0, 0x002a, 0x0002, 0},
+		{0x002a, 0x3a000, 0x1000, 0x3c000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x002e, 0x41000, 0x0fd0, 0x44000, 0x00d0, 0x002a, 0x0002, 0},
+		{0x0032, 0x47000, 0x1000, 0x4f000, 0x0090, 0x00ff, 0x0008, 0},
+		{0x0033, 0x50000, 0x1000, 0x53000, 0x0040, 0x0154, 0x0004, 0},
+		{0x0034, 0x54000, 0x1000, 0x56000, 0x0430, 0x0055, 0x0016, 0},
+		{0x0039, 0x65000, 0x1000, 0x66000, 0x0220, 0x00aa, 0x0016, 0},
+		{0x003c, 0x69000, 0x1000, 0x71000, 0x0090, 0x00ff, 0x0008, 0},
+		{0x003d, 0x72000, 0x1000, 0x75000, 0x0040, 0x0154, 0x0004, 0},
+		{0x003e, 0x76000, 0x1000, 0x78000, 0x0430, 0x0055, 0x0016, 0},
+		{0x0043, 0x87000, 0x1000, 0x88000, 0x0220, 0x00aa, 0x0016, 0},
+		{0x0052, 0x97000, 0x1000, 0x99000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x0056, 0x9d000, 0x0f90, 0x9e000, 0x0090, 0x001f, 0x0001, 0},
+		{0x020c, 0xa5000, 0x1000, 0xa7000, 0x003c, 0x0fec, 0x0028, 1},
+		{0x0216, 0xac000, 0x1000, 0xae000, 0x003c, 0x0fec, 0x0028, 1},
+		{0x0220, 0xb3000, 0x1000, 0xb5000, 0x003c, 0x0fec, 0x0028, 1},
+		{0x022a, 0xba000, 0x1000, 0xbc000, 0x003c, 0x0fec, 0x0028, 1},
+		{0x0252, 0xc2000, 0x1000, 0xc4000, 0x003c, 0x0fec, 0x0028, 1},
+	};
+
+	for (i = 0; i < ARRAY_SIZE(buff_data); i++) {
+		const struct ice_buff_seg_series_data *seg = &buff_data[i];
+		struct ice_buff_seg_series buff_seg;
+		const uint16_t buff_seg_size =
+			sizeof(struct ice_buff_seg_series);
+		uint32_t addr = seg->begin_addr;
+		__le16 last_offset = 0;
+
+		for (; addr <= seg->end_addr; addr += ICE_PKG_BUF_SIZE) {
+			uint8_t *buffer = &(*buff)[addr];
+
+			memset(buffer, 0xFF, ICE_PKG_BUF_SIZE);
+			buff_seg.header.flag = ICE_BUFF_SEG_HEADER_FLAG;
+			buff_seg.header.length = addr == seg->end_addr ?
+						seg->last_len : seg->len;
+			buff_seg.header.type = seg->type;
+			buff_seg.header.reserve = 0x0;
+			buff_seg.header.header_len = ice_buff_seg_header_size;
+			buff_seg.header.data_size = buff_seg.header.length -
+						buff_seg.header.header_len;
+			buff_seg.offset_delta =  addr < seg->end_addr ?
+				seg->offset_delta : seg->seg_end;
+			buff_seg.offset[!seg->padding] = 0x0;
+			buff_seg.offset[seg->padding] = last_offset;
+
+			memset(buffer, 0x00, buff_seg.header.length);
+			memcpy(buffer, &buff_seg, buff_seg_size);
+
+			last_offset += seg->offset_delta;
+		}
+	}
+}
+
+static void
+write_buffer_block2(uint8_t **buff)
+{
+	uint16_t i;
+	/* ICE ddp package multiple segments template 2 */
+	struct ice_buff_seg_series_with_sub_data buff_data[] = {
+		{0x000e, 0x07000, 0x1000, 0x08000, 0x0a1c, 13},
+		{0x0018, 0x1f000, 0x1000, 0x20000, 0x0a1c, 13},
+		{0x0022, 0x2f000, 0x1000, 0x30000, 0x0a1c, 13},
+		{0x002c, 0x3e000, 0x1000, 0x3f000, 0x0a1c, 13},
+		{0x0037, 0x58000, 0x1000, 0x5e000, 0x0070, 24},
+		{0x0038, 0x5f000, 0x0fe0, 0x64000, 0x0900, 88},
+		{0x0041, 0x7a000, 0x1000, 0x80000, 0x0070, 24},
+		{0x0042, 0x81000, 0x0fe0, 0x86000, 0x0900, 88},
+		{0x0054, 0x9b000, 0x034e, 0x9b000, 0x034e, 13},
+		{0x005c, 0xa3000, 0x0a10, 0xa3000, 0x0a10, 40},
+	};
+
+	for (i = 0; i < ARRAY_SIZE(buff_data); i++) {
+		struct ice_buff_seg_series_with_sub_data *seg = &buff_data[i];
+		struct ice_buff_seg_series_with_sub buff_seg;
+		const uint16_t buff_seg_size =
+			sizeof(struct ice_buff_seg_series_with_sub);
+		uint32_t addr;
+		uint16_t last_idx = 0;
+
+		for (addr = seg->begin_addr;
+		     addr <= seg->end_addr; addr += ICE_PKG_BUF_SIZE) {
+			uint8_t *buffer = &(*buff)[addr];
+			uint16_t total_sblk_size;
+			uint16_t idx = 0;
+			uint32_t pos = buff_seg_size;
+
+			memset(buffer, 0xFF, ICE_PKG_BUF_SIZE);
+			buff_seg.header.flag = ICE_BUFF_SEG_HEADER_FLAG;
+			buff_seg.header.length =
+				addr == seg->end_addr ?
+					seg->last_len : seg->len;
+			buff_seg.header.type = seg->type;
+			buff_seg.header.reserve = 0x0;
+			buff_seg.header.header_len = ice_buff_seg_header_size;
+			buff_seg.header.data_size = buff_seg.header.length -
+					buff_seg.header.header_len;
+
+			total_sblk_size = buff_seg.header.data_size
+					  - sizeof(buff_seg.sub_block_num);
+			buff_seg.sub_block_num =
+					total_sblk_size / seg->sblk_size;
+
+			memset(buffer, 0x00, buff_seg.header.length);
+			memcpy(buffer, &buff_seg, buff_seg_size);
+
+			/* padding if needed */
+			if (total_sblk_size % seg->sblk_size)
+				pos += sizeof(uint16_t);
+
+			for (idx = last_idx;
+			     idx < last_idx + buff_seg.sub_block_num; idx++) {
+				memcpy(buffer + pos, &idx, sizeof(uint16_t));
+				pos += seg->sblk_size;
+			}
+
+			last_idx = idx;
+		}
+	}
+}
+
+static int
+ice_dump_pkg(struct rte_eth_dev *dev, uint8_t **buff, uint32_t *size)
+{
+	struct ice_hw *hw;
+	struct ice_buf pkg_buff;
+	uint8_t *next_buff;
+	uint16_t i = 0;
+	uint16_t count;
+	struct ice_package_header *cache;
+	uint32_t cache_size;
+
+	write_buffer_simple(buff);
+	write_buffer_block(buff);
+	write_buffer_block2(buff);
+
+	hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	if (*size % ICE_PKG_BUF_SIZE)
+		return -EINVAL;
+
+	count = *size / ICE_PKG_BUF_SIZE;
+	for (i = 0; i < count; i++) {
+		next_buff = (uint8_t *)(*buff) + i * ICE_PKG_BUF_SIZE;
+		rte_memcpy(pkg_buff.buf, next_buff, ICE_PKG_BUF_SIZE);
+		if (ice_aq_upload_section(hw,
+					  (struct ice_buf_hdr *)&pkg_buff.buf[0],
+					  ICE_PKG_BUF_SIZE,
+					  NULL))
+			return -EINVAL;
+		rte_memcpy(next_buff, pkg_buff.buf, ICE_PKG_BUF_SIZE);
+	}
+
+	cache_size = sizeof(struct ice_package_header) + *size;
+	cache = (struct ice_package_header *)malloc(cache_size);
+	if (!cache)
+		return -ENOSPC;
+
+	cache->header.h1 = ICE_PKG_HDR_HEADR_PART1;
+	cache->header.h2 = ICE_PKG_HDR_HEADR_PART2;
+	cache->gm_seg_offset = ICE_PKG_HDR_GM_SEG_OFFSET;
+	cache->ice_seg_offset = ICE_PKG_HDR_ICE_SEG_OFFSET;
+	cache->gm_seg.hdr.seg_type = ICE_PKG_GM_SEG_TYPE;
+	cache->gm_seg.hdr.seg_format_ver.major = ICE_PKG_MAJOR_VERSION;
+	cache->gm_seg.hdr.seg_size = ICE_PKG_GM_SEG_SIZE;
+	ICE_PKG_COPY_STRING(cache->gm_seg.hdr.seg_id, "Global Metadata\0");
+
+	cache->gm_seg.pkg_ver.major = ICE_PKG_MAJOR_VERSION;
+	cache->gm_seg.rsvd = 1;
+	ICE_PKG_COPY_STRING(cache->gm_seg.pkg_name, "DEFAULT\0");
+
+	cache->ice_seg.hdr.seg_type = ICE_PKG_ICE_SEG_TYPE;
+	cache->ice_seg.hdr.seg_format_ver.major = ICE_PKG_MAJOR_VERSION;
+	cache->ice_seg.hdr.seg_size = ICE_PKG_ICE_SEG_SIZE_BASE + *size;
+	cache->ice_seg.devid_count = 0;
+	cache->ice_seg.nvm_ver.major = 0;
+	ICE_PKG_COPY_STRING(cache->ice_seg.hdr.seg_id, "CPK Configuration Data\0");
+
+	cache->buff_count = count;
+
+	next_buff = (uint8_t *)cache;
+	next_buff += sizeof(struct ice_package_header);
+	memcpy(next_buff, *buff, *size);
+
+	free(*buff);
+	*buff = (uint8_t *)cache;
+	*size = cache_size;
+
+	return 0;
+}
+
+int rte_pmd_ice_dump_package(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_pkg(dev, buff, size);
+}
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 00ac2bb191..373e2f7f2c 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -5911,3 +5911,8 @@ RTE_LOG_REGISTER_SUFFIX(ice_logtype_rx, rx, DEBUG);
 #ifdef RTE_ETHDEV_DEBUG_TX
 RTE_LOG_REGISTER_SUFFIX(ice_logtype_tx, tx, DEBUG);
 #endif
+
+bool is_ice_supported(struct rte_eth_dev *dev)
+{
+	return !strcmp(dev->device->driver->name, rte_ice_pmd.driver.name);
+}
diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index 3d8427225f..2ef663e38e 100644
--- a/drivers/net/ice/ice_ethdev.h
+++ b/drivers/net/ice/ice_ethdev.h
@@ -611,6 +611,7 @@ struct ice_vsi_vlan_pvid_info {
 #define ICE_PF_TO_ETH_DEV(pf) \
 	(((struct ice_pf *)pf)->adapter->eth_dev)
 
+bool is_ice_supported(struct rte_eth_dev *dev);
 int
 ice_load_pkg(struct ice_adapter *adapter, bool use_dsn, uint64_t dsn);
 struct ice_vsi *
diff --git a/drivers/net/ice/meson.build b/drivers/net/ice/meson.build
index d608da7765..2dbe4448ad 100644
--- a/drivers/net/ice/meson.build
+++ b/drivers/net/ice/meson.build
@@ -12,6 +12,7 @@ sources = files(
         'ice_hash.c',
         'ice_rxtx.c',
         'ice_switch_filter.c',
+        'ice_ddp_package.c',
 )
 
 deps += ['hash', 'net', 'common_iavf']
diff --git a/drivers/net/ice/rte_pmd_ice.h b/drivers/net/ice/rte_pmd_ice.h
index 9a436a140b..53c81ccf4e 100644
--- a/drivers/net/ice/rte_pmd_ice.h
+++ b/drivers/net/ice/rte_pmd_ice.h
@@ -237,6 +237,9 @@ rte_net_ice_dump_proto_xtr_metadata(struct rte_mbuf *m)
 		       data.ip_ofs);
 }
 
+__rte_experimental
+int rte_pmd_ice_dump_package(uint16_t port, uint8_t **buff, uint32_t *size);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/drivers/net/ice/version.map b/drivers/net/ice/version.map
index cc837f1c00..60a3f17393 100644
--- a/drivers/net/ice/version.map
+++ b/drivers/net/ice/version.map
@@ -13,4 +13,5 @@ EXPERIMENTAL {
 	rte_net_ice_dynflag_proto_xtr_ipv6_flow_mask;
 	rte_net_ice_dynflag_proto_xtr_tcp_mask;
 	rte_net_ice_dynflag_proto_xtr_ip_offset_mask;
+	rte_pmd_ice_dump_package;
 };
-- 
2.27.0


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

* [PATCH v1 2/2] app/testpmd: support dump_pkg command for ice
  2022-05-11  8:02 [PATCH v1 0/2] ICE ddp download tool Steve Yang
  2022-05-11  8:02 ` [PATCH v1 1/2] net/ice: support dump ice ddp package Steve Yang
@ 2022-05-11  8:02 ` Steve Yang
  2022-05-18  4:32   ` Zhang, Qi Z
  2022-05-12  2:06 ` [PATCH v2 0/2] ICE ddp download tool Steve Yang
  2 siblings, 1 reply; 24+ messages in thread
From: Steve Yang @ 2022-05-11  8:02 UTC (permalink / raw)
  To: dev; +Cc: yuying.zhang, qiming.yang, qi.z.zhang, mdr, Steve Yang

Support dump ice PF ddp package via testpmd command line.

Add command line:
    ddp dump <port_id> <profile_path>

Parameters:
    <port_id>       the PF Port ID
    <profile_path>  dumped package profile file, if not a absolute path,
                    it will be dumped to testpmd running directory.

For example:
testpmd> ddp dump 0 current.pkg

If you want to dump ice VF ddp package, you need bind other unused PF port
of the NIC first, and then dump the PF ddp package as target output.

Signed-off-by: Steve Yang <stevex.yang@intel.com>
---
 app/test-pmd/cmdline.c | 74 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 6ffea8e21a..f13773cd6c 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -60,6 +60,9 @@
 #ifdef RTE_NET_I40E
 #include <rte_pmd_i40e.h>
 #endif
+#ifdef RTE_NET_ICE
+#include <rte_pmd_ice.h>
+#endif
 #ifdef RTE_NET_BNXT
 #include <rte_pmd_bnxt.h>
 #endif
@@ -654,6 +657,9 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"set link-down port (port_id)\n"
 			"	Set link down for a port.\n\n"
 
+			"ddp dump (port_id) (profile_path)\n"
+			"    Dump a profile package on a port\n\n"
+
 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
 			"    Load a profile package on a port\n\n"
 
@@ -14471,6 +14477,73 @@ cmdline_parse_inst_t cmd_strict_link_prio = {
 	},
 };
 
+/* Dump device ddp package, only for ice PF */
+struct cmd_ddp_dump_result {
+	cmdline_fixed_string_t ddp;
+	cmdline_fixed_string_t add;
+	portid_t port_id;
+	char filepath[];
+};
+
+cmdline_parse_token_string_t cmd_ddp_dump_ddp =
+	TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, ddp, "ddp");
+cmdline_parse_token_string_t cmd_ddp_dump_dump =
+	TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, add, "dump");
+cmdline_parse_token_num_t cmd_ddp_dump_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_ddp_dump_result, port_id, RTE_UINT16);
+cmdline_parse_token_string_t cmd_ddp_dump_filepath =
+	TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, filepath, NULL);
+
+static void
+cmd_ddp_dump_parsed(
+	void *parsed_result,
+	__rte_unused struct cmdline *cl,
+	__rte_unused void *data)
+{
+	struct cmd_ddp_dump_result *res = parsed_result;
+	uint8_t *buff;
+	uint32_t size;
+	int ret = 0;
+
+#ifdef RTE_NET_ICE
+#define ICE_BUFF_SIZE	0x000c9000
+	size = ICE_BUFF_SIZE;
+	buff = (uint8_t *)malloc(ICE_BUFF_SIZE);
+	if (buff) {
+		ret = rte_pmd_ice_dump_package(res->port_id, &buff, &size);
+
+		switch (ret) {
+		case 0:
+			save_file(res->filepath, buff, size);
+			break;
+		case -EINVAL:
+			fprintf(stderr, "Invalid buffer size\n");
+			break;
+		case -ENOTSUP:
+			fprintf(stderr, "Device doesn't support dump package.\n");
+			break;
+		default:
+			fprintf(stderr, "Failed to dump package file,"
+				" error: (%s)\n", strerror(-ret));
+		}
+	}
+	free(buff);
+#endif
+}
+
+cmdline_parse_inst_t cmd_ddp_dump = {
+	.f = cmd_ddp_dump_parsed,
+	.data = NULL,
+	.help_str = "ddp dump <port_id> <profile_path>",
+	.tokens = {
+		(void *)&cmd_ddp_dump_ddp,
+		(void *)&cmd_ddp_dump_dump,
+		(void *)&cmd_ddp_dump_port_id,
+		(void *)&cmd_ddp_dump_filepath,
+		NULL,
+	},
+};
+
 /* Load dynamic device personalization*/
 struct cmd_ddp_add_result {
 	cmdline_fixed_string_t ddp;
@@ -18025,6 +18098,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_ddp_del,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
+	(cmdline_parse_inst_t *)&cmd_ddp_dump,
 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
-- 
2.27.0


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

* [PATCH v2 0/2] ICE ddp download tool
  2022-05-11  8:02 [PATCH v1 0/2] ICE ddp download tool Steve Yang
  2022-05-11  8:02 ` [PATCH v1 1/2] net/ice: support dump ice ddp package Steve Yang
  2022-05-11  8:02 ` [PATCH v1 2/2] app/testpmd: support dump_pkg command for ice Steve Yang
@ 2022-05-12  2:06 ` Steve Yang
  2022-05-12  2:06   ` [PATCH v2 1/2] net/ice: support dump ice ddp package Steve Yang
                     ` (2 more replies)
  2 siblings, 3 replies; 24+ messages in thread
From: Steve Yang @ 2022-05-12  2:06 UTC (permalink / raw)
  To: dev; +Cc: yuying.zhang, qiming.yang, qi.z.zhang, mdr, Steve Yang

Support dump ice PF ddp package via testpmd command line.

Add command line:
    ddp dump <port_id> <profile_path>

Parameters:
    <port_id>       the PF Port ID
    <profile_path>  dumped package profile file, if not a absolute path,
                    it will be dumped to testpmd running directory.

For example:
testpmd> ddp dump 0 current.pkg

If you want to dump ice VF ddp package, you need bind other unused PF port
of the NIC first, and then dump the PF ddp package as target output.

---
v2:
- fixed compiling issue
- fixed unused variables warning

Steve Yang (2):
  net/ice: support dump ice ddp package
  app/testpmd: support dump_pkg command for ice

 app/test-pmd/cmdline.c            |  74 ++++++
 app/test-pmd/meson.build          |   3 +
 drivers/net/ice/ice_ddp_package.c | 418 ++++++++++++++++++++++++++++++
 drivers/net/ice/ice_ethdev.c      |   5 +
 drivers/net/ice/ice_ethdev.h      |   1 +
 drivers/net/ice/meson.build       |   1 +
 drivers/net/ice/rte_pmd_ice.h     |   3 +
 drivers/net/ice/version.map       |   1 +
 8 files changed, 506 insertions(+)
 create mode 100644 drivers/net/ice/ice_ddp_package.c

-- 
2.27.0


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

* [PATCH v2 1/2] net/ice: support dump ice ddp package
  2022-05-12  2:06 ` [PATCH v2 0/2] ICE ddp download tool Steve Yang
@ 2022-05-12  2:06   ` Steve Yang
  2022-05-12  2:06   ` [PATCH v2 2/2] app/testpmd: support dump_pkg command for ice Steve Yang
  2022-05-18  6:58   ` [PATCH v3] app/testpmd: support ddp dump " Steve Yang
  2 siblings, 0 replies; 24+ messages in thread
From: Steve Yang @ 2022-05-12  2:06 UTC (permalink / raw)
  To: dev; +Cc: yuying.zhang, qiming.yang, qi.z.zhang, mdr, Steve Yang

Send the AQ command to acquire ice ddp package, and dump the binary to
output file.

Export rte dump package API (rte_pmd_ice_dump_package) for application.

Signed-off-by: Steve Yang <stevex.yang@intel.com>
---
 drivers/net/ice/ice_ddp_package.c | 418 ++++++++++++++++++++++++++++++
 drivers/net/ice/ice_ethdev.c      |   5 +
 drivers/net/ice/ice_ethdev.h      |   1 +
 drivers/net/ice/meson.build       |   1 +
 drivers/net/ice/rte_pmd_ice.h     |   3 +
 drivers/net/ice/version.map       |   1 +
 6 files changed, 429 insertions(+)
 create mode 100644 drivers/net/ice/ice_ddp_package.c

diff --git a/drivers/net/ice/ice_ddp_package.c b/drivers/net/ice/ice_ddp_package.c
new file mode 100644
index 0000000000..c1a1ca8aba
--- /dev/null
+++ b/drivers/net/ice/ice_ddp_package.c
@@ -0,0 +1,418 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#include <rte_string_fns.h>
+#include <rte_malloc.h>
+#include <rte_tailq.h>
+
+#include "ice_ethdev.h"
+#include "rte_pmd_ice.h"
+
+#define ICE_BUFF_SEG_HEADER_FLAG   0x1
+#define ICE_PKG_HDR_HEADR_PART1    1
+#define ICE_PKG_HDR_HEADR_PART2    2
+#define ICE_PKG_HDR_GM_SEG_OFFSET  16
+#define ICE_PKG_HDR_ICE_SEG_OFFSET 100
+#define ICE_PKG_GM_SEG_TYPE        1
+#define ICE_PKG_MAJOR_VERSION      1
+#define ICE_PKG_GM_SEG_SIZE        84
+#define SPACE_CHAR                 0x20
+#define ICE_PKG_ICE_SEG_TYPE       0x10
+#define ICE_PKG_ICE_SEG_SIZE_BASE  56
+
+#define ICE_PKG_COPY_STRING(dst, src)	\
+	do {\
+		char *_dst = (dst); \
+		const char *_src = (src); \
+		memset(_dst, SPACE_CHAR, ICE_PKG_NAME_SIZE); \
+		strncpy(_dst, _src, strlen(_src) + 1); \
+	} while (0)
+
+/* Package header */
+struct ice_package_header {
+	struct __hdr {
+		uint32_t h1; /* header part 1 */
+		uint32_t h2; /* header part 2 */
+	} header;
+	uint32_t gm_seg_offset;	 /* Global Metadata segment: 16 */
+	uint32_t ice_seg_offset; /* ICE segment: 100 */
+	struct ice_global_metadata_seg gm_seg;
+	struct __ice_seg {
+		struct ice_generic_seg_hdr hdr;
+		uint32_t devid_count;
+		struct ice_pkg_ver nvm_ver;
+	} ice_seg;
+
+	uint32_t buff_count;
+};
+
+struct ice_buff_seg_header {
+	__le16 flag;
+	__le16 length;
+	__le16 type;
+	__le16 reserve;		/* 0 */
+	__le16 header_len;	/* 0x0C */
+	__le16 data_size;	/* length - header_len */
+};
+
+struct ice_buff_seg_simple {
+	struct ice_buff_seg_header header;
+	__le16 seg_end;
+};
+
+struct ice_buff_seg_simple_data {
+	__le16 type;
+	__le32 addr;
+	__le16 len;
+	__le16 seg_end;
+};
+
+struct ice_buff_seg_series {
+	struct ice_buff_seg_header header;
+	uint16_t offset_delta;
+	uint16_t offset[2];
+};
+
+struct ice_buff_seg_series_data {
+	__le16 type;
+	__le32 begin_addr;
+	__le16 len;
+	__le32 end_addr;
+	__le16 last_len;
+	__le16 offset_delta;
+	__le16 seg_end;
+	uint8_t padding;
+};
+
+struct ice_buff_seg_series_with_sub {
+	struct ice_buff_seg_header header;
+	uint16_t sub_block_num;
+};
+
+struct ice_buff_seg_series_with_sub_data {
+	__le16 type;
+	__le32 begin_addr;
+	__le16 len;
+	__le32 end_addr;
+	__le16 last_len;
+	__le16 sblk_size;
+};
+
+
+static const
+uint16_t ice_buff_seg_header_size = sizeof(struct ice_buff_seg_header);
+
+static void
+write_buffer_simple(uint8_t **buff)
+{
+	uint16_t i;
+	/* ICE ddp package simple segment template */
+	const struct ice_buff_seg_simple_data buff_data[] = {
+	    {0x0001, 0x00000, 0x0030, 0x0000},
+	    {0x000a, 0x01000, 0x0810, 0x0800},
+	    {0x000b, 0x02000, 0x00d8, 0x0000},
+	    {0x000d, 0x06000, 0x0810, 0x0400},
+	    {0x000f, 0x09000, 0x0110, 0x0100},
+	    {0x0011, 0x17000, 0x001d, 0x0000},
+	    {0x0012, 0x18000, 0x0014, 0x0000},
+	    {0x0014, 0x19000, 0x0810, 0x0800},
+	    {0x0015, 0x1a000, 0x00d8, 0x0000},
+	    {0x0017, 0x1e000, 0x0810, 0x0400},
+	    {0x0019, 0x21000, 0x0090, 0x0080},
+	    {0x001b, 0x27000, 0x001d, 0x0000},
+	    {0x001c, 0x28000, 0x0014, 0x0000},
+	    {0x001e, 0x29000, 0x0810, 0x0800},
+	    {0x001f, 0x2a000, 0x00d8, 0x0000},
+	    {0x0021, 0x2e000, 0x0810, 0x0400},
+	    {0x0023, 0x31000, 0x0090, 0x0080},
+	    {0x0025, 0x36000, 0x001d, 0x0000},
+	    {0x0026, 0x37000, 0x0014, 0x0000},
+	    {0x0028, 0x38000, 0x0810, 0x0800},
+	    {0x0029, 0x39000, 0x00d8, 0x0000},
+	    {0x002b, 0x3d000, 0x0810, 0x0400},
+	    {0x002d, 0x40000, 0x0090, 0x0080},
+	    {0x002f, 0x45000, 0x001d, 0x0000},
+	    {0x0030, 0x46000, 0x0014, 0x0000},
+	    {0x0035, 0x57000, 0x0010, 0x0000},
+	    {0x003a, 0x67000, 0x0190, 0x0010},
+	    {0x003b, 0x68000, 0x0810, 0x0800},
+	    {0x003f, 0x79000, 0x0010, 0x0000},
+	    {0x0044, 0x89000, 0x0190, 0x0010},
+	    {0x0045, 0x8a000, 0x0810, 0x0800},
+	    {0x0046, 0x8b000, 0x001c, 0x0000},
+	    {0x0047, 0x8c000, 0x001c, 0x0000},
+	    {0x0048, 0x8d000, 0x0410, 0x0080},
+	    {0x0049, 0x8e000, 0x0410, 0x0080},
+	    {0x004a, 0x8f000, 0x0028, 0x0006},
+	    {0x004b, 0x90000, 0x0028, 0x0006},
+	    {0x004c, 0x91000, 0x0890, 0x0080},
+	    {0x004d, 0x92000, 0x0890, 0x0080},
+	    {0x004e, 0x93000, 0x0350, 0x0040},
+	    {0x004f, 0x94000, 0x0350, 0x0040},
+	    {0x0050, 0x95000, 0x0810, 0x0800},
+	    {0x0051, 0x96000, 0x00d8, 0x0000},
+	    {0x0053, 0x9a000, 0x0810, 0x0400},
+	    {0x0055, 0x9c000, 0x0030, 0x0020},
+	    {0x0057, 0x9f000, 0x001d, 0x0000},
+	    {0x0058, 0xa0000, 0x0014, 0x0000},
+	    {0x005a, 0xa1000, 0x0024, 0x0000},
+	    {0x005b, 0xa2000, 0x0024, 0x0000},
+	    {0x005d, 0xa4000, 0x0810, 0x0100},
+	    {0x020d, 0xa8000, 0x0414, 0x0400},
+	    {0x020e, 0xa9000, 0x0214, 0x0200},
+	    {0x020f, 0xaa000, 0x0114, 0x0100},
+	    {0x0210, 0xab000, 0x0114, 0x0100},
+	    {0x0217, 0xaf000, 0x0414, 0x0400},
+	    {0x0218, 0xb0000, 0x0214, 0x0200},
+	    {0x0219, 0xb1000, 0x0094, 0x0080},
+	    {0x021a, 0xb2000, 0x0094, 0x0080},
+	    {0x0221, 0xb6000, 0x0414, 0x0400},
+	    {0x0222, 0xb7000, 0x0214, 0x0200},
+	    {0x0223, 0xb8000, 0x0094, 0x0080},
+	    {0x0224, 0xb9000, 0x0094, 0x0080},
+	    {0x022b, 0xbd000, 0x0414, 0x0400},
+	    {0x022c, 0xbe000, 0x0214, 0x0200},
+	    {0x022d, 0xbf000, 0x0094, 0x0080},
+	    {0x022e, 0xc0000, 0x0094, 0x0080},
+	    {0x0238, 0xc1000, 0x0114, 0x0100},
+	    {0x0253, 0xc5000, 0x0414, 0x0400},
+	    {0x0254, 0xc6000, 0x0054, 0x0040},
+	    {0x0255, 0xc7000, 0x0034, 0x0020},
+	    {0x0256, 0xc8000, 0x0034, 0x0020},
+	};
+
+	for (i = 0; i < ARRAY_SIZE(buff_data); i++) {
+		const struct ice_buff_seg_simple_data *seg = &buff_data[i];
+		struct ice_buff_seg_simple buff_seg;
+		uint8_t *buffer = &(*buff)[seg->addr];
+
+		memset(buffer, 0xFF, ICE_PKG_BUF_SIZE);
+		buff_seg.header.flag = ICE_BUFF_SEG_HEADER_FLAG;
+		buff_seg.header.length = seg->len;
+		buff_seg.header.type = seg->type;
+		buff_seg.header.reserve = 0x0;
+		buff_seg.header.header_len =
+			sizeof(struct ice_buff_seg_header);
+		buff_seg.header.data_size =
+			buff_seg.header.length - buff_seg.header.header_len;
+		buff_seg.seg_end = seg->seg_end;
+
+		memset(buffer, 0x00, buff_seg.header.length);
+		memcpy(buffer, &buff_seg, sizeof(struct ice_buff_seg_simple));
+	}
+}
+
+static void
+write_buffer_block(uint8_t **buff)
+{
+	uint16_t i;
+	/* ICE ddp package multiple segments template 1 */
+	const struct ice_buff_seg_series_data buff_data[] = {
+		{0x000c, 0x03000, 0x1000, 0x05000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x0010, 0x0a000, 0x0fd0, 0x16000, 0x0310, 0x0015, 0x0004, 0},
+		{0x0016, 0x1b000, 0x1000, 0x1d000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x001a, 0x22000, 0x0f90, 0x26000, 0x0210, 0x001f, 0x0004, 0},
+		{0x0020, 0x2b000, 0x1000, 0x2d000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x0024, 0x32000, 0x0fd0, 0x35000, 0x00d0, 0x002a, 0x0002, 0},
+		{0x002a, 0x3a000, 0x1000, 0x3c000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x002e, 0x41000, 0x0fd0, 0x44000, 0x00d0, 0x002a, 0x0002, 0},
+		{0x0032, 0x47000, 0x1000, 0x4f000, 0x0090, 0x00ff, 0x0008, 0},
+		{0x0033, 0x50000, 0x1000, 0x53000, 0x0040, 0x0154, 0x0004, 0},
+		{0x0034, 0x54000, 0x1000, 0x56000, 0x0430, 0x0055, 0x0016, 0},
+		{0x0039, 0x65000, 0x1000, 0x66000, 0x0220, 0x00aa, 0x0016, 0},
+		{0x003c, 0x69000, 0x1000, 0x71000, 0x0090, 0x00ff, 0x0008, 0},
+		{0x003d, 0x72000, 0x1000, 0x75000, 0x0040, 0x0154, 0x0004, 0},
+		{0x003e, 0x76000, 0x1000, 0x78000, 0x0430, 0x0055, 0x0016, 0},
+		{0x0043, 0x87000, 0x1000, 0x88000, 0x0220, 0x00aa, 0x0016, 0},
+		{0x0052, 0x97000, 0x1000, 0x99000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x0056, 0x9d000, 0x0f90, 0x9e000, 0x0090, 0x001f, 0x0001, 0},
+		{0x020c, 0xa5000, 0x1000, 0xa7000, 0x003c, 0x0fec, 0x0028, 1},
+		{0x0216, 0xac000, 0x1000, 0xae000, 0x003c, 0x0fec, 0x0028, 1},
+		{0x0220, 0xb3000, 0x1000, 0xb5000, 0x003c, 0x0fec, 0x0028, 1},
+		{0x022a, 0xba000, 0x1000, 0xbc000, 0x003c, 0x0fec, 0x0028, 1},
+		{0x0252, 0xc2000, 0x1000, 0xc4000, 0x003c, 0x0fec, 0x0028, 1},
+	};
+
+	for (i = 0; i < ARRAY_SIZE(buff_data); i++) {
+		const struct ice_buff_seg_series_data *seg = &buff_data[i];
+		struct ice_buff_seg_series buff_seg;
+		const uint16_t buff_seg_size =
+			sizeof(struct ice_buff_seg_series);
+		uint32_t addr = seg->begin_addr;
+		__le16 last_offset = 0;
+
+		for (; addr <= seg->end_addr; addr += ICE_PKG_BUF_SIZE) {
+			uint8_t *buffer = &(*buff)[addr];
+
+			memset(buffer, 0xFF, ICE_PKG_BUF_SIZE);
+			buff_seg.header.flag = ICE_BUFF_SEG_HEADER_FLAG;
+			buff_seg.header.length = addr == seg->end_addr ?
+						seg->last_len : seg->len;
+			buff_seg.header.type = seg->type;
+			buff_seg.header.reserve = 0x0;
+			buff_seg.header.header_len = ice_buff_seg_header_size;
+			buff_seg.header.data_size = buff_seg.header.length -
+						buff_seg.header.header_len;
+			buff_seg.offset_delta =  addr < seg->end_addr ?
+				seg->offset_delta : seg->seg_end;
+			buff_seg.offset[!seg->padding] = 0x0;
+			buff_seg.offset[seg->padding] = last_offset;
+
+			memset(buffer, 0x00, buff_seg.header.length);
+			memcpy(buffer, &buff_seg, buff_seg_size);
+
+			last_offset += seg->offset_delta;
+		}
+	}
+}
+
+static void
+write_buffer_block2(uint8_t **buff)
+{
+	uint16_t i;
+	/* ICE ddp package multiple segments template 2 */
+	struct ice_buff_seg_series_with_sub_data buff_data[] = {
+		{0x000e, 0x07000, 0x1000, 0x08000, 0x0a1c, 13},
+		{0x0018, 0x1f000, 0x1000, 0x20000, 0x0a1c, 13},
+		{0x0022, 0x2f000, 0x1000, 0x30000, 0x0a1c, 13},
+		{0x002c, 0x3e000, 0x1000, 0x3f000, 0x0a1c, 13},
+		{0x0037, 0x58000, 0x1000, 0x5e000, 0x0070, 24},
+		{0x0038, 0x5f000, 0x0fe0, 0x64000, 0x0900, 88},
+		{0x0041, 0x7a000, 0x1000, 0x80000, 0x0070, 24},
+		{0x0042, 0x81000, 0x0fe0, 0x86000, 0x0900, 88},
+		{0x0054, 0x9b000, 0x034e, 0x9b000, 0x034e, 13},
+		{0x005c, 0xa3000, 0x0a10, 0xa3000, 0x0a10, 40},
+	};
+
+	for (i = 0; i < ARRAY_SIZE(buff_data); i++) {
+		struct ice_buff_seg_series_with_sub_data *seg = &buff_data[i];
+		struct ice_buff_seg_series_with_sub buff_seg;
+		const uint16_t buff_seg_size =
+			sizeof(struct ice_buff_seg_series_with_sub);
+		uint32_t addr;
+		uint16_t last_idx = 0;
+
+		for (addr = seg->begin_addr;
+		     addr <= seg->end_addr; addr += ICE_PKG_BUF_SIZE) {
+			uint8_t *buffer = &(*buff)[addr];
+			uint16_t total_sblk_size;
+			uint16_t idx = 0;
+			uint32_t pos = buff_seg_size;
+
+			memset(buffer, 0xFF, ICE_PKG_BUF_SIZE);
+			buff_seg.header.flag = ICE_BUFF_SEG_HEADER_FLAG;
+			buff_seg.header.length =
+				addr == seg->end_addr ?
+					seg->last_len : seg->len;
+			buff_seg.header.type = seg->type;
+			buff_seg.header.reserve = 0x0;
+			buff_seg.header.header_len = ice_buff_seg_header_size;
+			buff_seg.header.data_size = buff_seg.header.length -
+					buff_seg.header.header_len;
+
+			total_sblk_size = buff_seg.header.data_size
+					  - sizeof(buff_seg.sub_block_num);
+			buff_seg.sub_block_num =
+					total_sblk_size / seg->sblk_size;
+
+			memset(buffer, 0x00, buff_seg.header.length);
+			memcpy(buffer, &buff_seg, buff_seg_size);
+
+			/* padding if needed */
+			if (total_sblk_size % seg->sblk_size)
+				pos += sizeof(uint16_t);
+
+			for (idx = last_idx;
+			     idx < last_idx + buff_seg.sub_block_num; idx++) {
+				memcpy(buffer + pos, &idx, sizeof(uint16_t));
+				pos += seg->sblk_size;
+			}
+
+			last_idx = idx;
+		}
+	}
+}
+
+static int
+ice_dump_pkg(struct rte_eth_dev *dev, uint8_t **buff, uint32_t *size)
+{
+	struct ice_hw *hw;
+	struct ice_buf pkg_buff;
+	uint8_t *next_buff;
+	uint16_t i = 0;
+	uint16_t count;
+	struct ice_package_header *cache;
+	uint32_t cache_size;
+
+	write_buffer_simple(buff);
+	write_buffer_block(buff);
+	write_buffer_block2(buff);
+
+	hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	if (*size % ICE_PKG_BUF_SIZE)
+		return -EINVAL;
+
+	count = *size / ICE_PKG_BUF_SIZE;
+	for (i = 0; i < count; i++) {
+		next_buff = (uint8_t *)(*buff) + i * ICE_PKG_BUF_SIZE;
+		rte_memcpy(pkg_buff.buf, next_buff, ICE_PKG_BUF_SIZE);
+		if (ice_aq_upload_section(hw,
+					  (struct ice_buf_hdr *)&pkg_buff.buf[0],
+					  ICE_PKG_BUF_SIZE,
+					  NULL))
+			return -EINVAL;
+		rte_memcpy(next_buff, pkg_buff.buf, ICE_PKG_BUF_SIZE);
+	}
+
+	cache_size = sizeof(struct ice_package_header) + *size;
+	cache = (struct ice_package_header *)malloc(cache_size);
+	if (!cache)
+		return -ENOSPC;
+
+	cache->header.h1 = ICE_PKG_HDR_HEADR_PART1;
+	cache->header.h2 = ICE_PKG_HDR_HEADR_PART2;
+	cache->gm_seg_offset = ICE_PKG_HDR_GM_SEG_OFFSET;
+	cache->ice_seg_offset = ICE_PKG_HDR_ICE_SEG_OFFSET;
+	cache->gm_seg.hdr.seg_type = ICE_PKG_GM_SEG_TYPE;
+	cache->gm_seg.hdr.seg_format_ver.major = ICE_PKG_MAJOR_VERSION;
+	cache->gm_seg.hdr.seg_size = ICE_PKG_GM_SEG_SIZE;
+	ICE_PKG_COPY_STRING(cache->gm_seg.hdr.seg_id, "Global Metadata\0");
+
+	cache->gm_seg.pkg_ver.major = ICE_PKG_MAJOR_VERSION;
+	cache->gm_seg.rsvd = 1;
+	ICE_PKG_COPY_STRING(cache->gm_seg.pkg_name, "DEFAULT\0");
+
+	cache->ice_seg.hdr.seg_type = ICE_PKG_ICE_SEG_TYPE;
+	cache->ice_seg.hdr.seg_format_ver.major = ICE_PKG_MAJOR_VERSION;
+	cache->ice_seg.hdr.seg_size = ICE_PKG_ICE_SEG_SIZE_BASE + *size;
+	cache->ice_seg.devid_count = 0;
+	cache->ice_seg.nvm_ver.major = 0;
+	ICE_PKG_COPY_STRING(cache->ice_seg.hdr.seg_id, "CPK Configuration Data\0");
+
+	cache->buff_count = count;
+
+	next_buff = (uint8_t *)cache;
+	next_buff += sizeof(struct ice_package_header);
+	memcpy(next_buff, *buff, *size);
+
+	free(*buff);
+	*buff = (uint8_t *)cache;
+	*size = cache_size;
+
+	return 0;
+}
+
+int rte_pmd_ice_dump_package(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_pkg(dev, buff, size);
+}
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 00ac2bb191..373e2f7f2c 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -5911,3 +5911,8 @@ RTE_LOG_REGISTER_SUFFIX(ice_logtype_rx, rx, DEBUG);
 #ifdef RTE_ETHDEV_DEBUG_TX
 RTE_LOG_REGISTER_SUFFIX(ice_logtype_tx, tx, DEBUG);
 #endif
+
+bool is_ice_supported(struct rte_eth_dev *dev)
+{
+	return !strcmp(dev->device->driver->name, rte_ice_pmd.driver.name);
+}
diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index 3d8427225f..2ef663e38e 100644
--- a/drivers/net/ice/ice_ethdev.h
+++ b/drivers/net/ice/ice_ethdev.h
@@ -611,6 +611,7 @@ struct ice_vsi_vlan_pvid_info {
 #define ICE_PF_TO_ETH_DEV(pf) \
 	(((struct ice_pf *)pf)->adapter->eth_dev)
 
+bool is_ice_supported(struct rte_eth_dev *dev);
 int
 ice_load_pkg(struct ice_adapter *adapter, bool use_dsn, uint64_t dsn);
 struct ice_vsi *
diff --git a/drivers/net/ice/meson.build b/drivers/net/ice/meson.build
index d608da7765..2dbe4448ad 100644
--- a/drivers/net/ice/meson.build
+++ b/drivers/net/ice/meson.build
@@ -12,6 +12,7 @@ sources = files(
         'ice_hash.c',
         'ice_rxtx.c',
         'ice_switch_filter.c',
+        'ice_ddp_package.c',
 )
 
 deps += ['hash', 'net', 'common_iavf']
diff --git a/drivers/net/ice/rte_pmd_ice.h b/drivers/net/ice/rte_pmd_ice.h
index 9a436a140b..53c81ccf4e 100644
--- a/drivers/net/ice/rte_pmd_ice.h
+++ b/drivers/net/ice/rte_pmd_ice.h
@@ -237,6 +237,9 @@ rte_net_ice_dump_proto_xtr_metadata(struct rte_mbuf *m)
 		       data.ip_ofs);
 }
 
+__rte_experimental
+int rte_pmd_ice_dump_package(uint16_t port, uint8_t **buff, uint32_t *size);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/drivers/net/ice/version.map b/drivers/net/ice/version.map
index cc837f1c00..60a3f17393 100644
--- a/drivers/net/ice/version.map
+++ b/drivers/net/ice/version.map
@@ -13,4 +13,5 @@ EXPERIMENTAL {
 	rte_net_ice_dynflag_proto_xtr_ipv6_flow_mask;
 	rte_net_ice_dynflag_proto_xtr_tcp_mask;
 	rte_net_ice_dynflag_proto_xtr_ip_offset_mask;
+	rte_pmd_ice_dump_package;
 };
-- 
2.27.0


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

* [PATCH v2 2/2] app/testpmd: support dump_pkg command for ice
  2022-05-12  2:06 ` [PATCH v2 0/2] ICE ddp download tool Steve Yang
  2022-05-12  2:06   ` [PATCH v2 1/2] net/ice: support dump ice ddp package Steve Yang
@ 2022-05-12  2:06   ` Steve Yang
  2022-05-18  6:58   ` [PATCH v3] app/testpmd: support ddp dump " Steve Yang
  2 siblings, 0 replies; 24+ messages in thread
From: Steve Yang @ 2022-05-12  2:06 UTC (permalink / raw)
  To: dev; +Cc: yuying.zhang, qiming.yang, qi.z.zhang, mdr, Steve Yang

Support dump ice PF ddp package via testpmd command line.

Add command line:
    ddp dump <port_id> <profile_path>

Parameters:
    <port_id>       the PF Port ID
    <profile_path>  dumped package profile file, if not a absolute path,
                    it will be dumped to testpmd running directory.

For example:
testpmd> ddp dump 0 current.pkg

If you want to dump ice VF ddp package, you need bind other unused PF port
of the NIC first, and then dump the PF ddp package as target output.

Signed-off-by: Steve Yang <stevex.yang@intel.com>
---
 app/test-pmd/cmdline.c   | 74 ++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/meson.build |  3 ++
 2 files changed, 77 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 6ffea8e21a..e55532223b 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -60,6 +60,9 @@
 #ifdef RTE_NET_I40E
 #include <rte_pmd_i40e.h>
 #endif
+#ifdef RTE_NET_ICE
+#include <rte_pmd_ice.h>
+#endif
 #ifdef RTE_NET_BNXT
 #include <rte_pmd_bnxt.h>
 #endif
@@ -654,6 +657,9 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"set link-down port (port_id)\n"
 			"	Set link down for a port.\n\n"
 
+			"ddp dump (port_id) (profile_path)\n"
+			"    Dump a profile package on a port\n\n"
+
 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
 			"    Load a profile package on a port\n\n"
 
@@ -14471,6 +14477,73 @@ cmdline_parse_inst_t cmd_strict_link_prio = {
 	},
 };
 
+/* Dump device ddp package, only for ice PF */
+struct cmd_ddp_dump_result {
+	cmdline_fixed_string_t ddp;
+	cmdline_fixed_string_t add;
+	portid_t port_id;
+	char filepath[];
+};
+
+cmdline_parse_token_string_t cmd_ddp_dump_ddp =
+	TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, ddp, "ddp");
+cmdline_parse_token_string_t cmd_ddp_dump_dump =
+	TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, add, "dump");
+cmdline_parse_token_num_t cmd_ddp_dump_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_ddp_dump_result, port_id, RTE_UINT16);
+cmdline_parse_token_string_t cmd_ddp_dump_filepath =
+	TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, filepath, NULL);
+
+static void
+cmd_ddp_dump_parsed(
+	void *parsed_result,
+	__rte_unused struct cmdline *cl,
+	__rte_unused void *data)
+{
+	struct cmd_ddp_dump_result *res = parsed_result;
+	uint8_t *buff;
+	uint32_t size;
+	int ret = -ENOTSUP;
+
+#define ICE_BUFF_SIZE	0x000c9000
+	size = ICE_BUFF_SIZE;
+	buff = (uint8_t *)malloc(ICE_BUFF_SIZE);
+	if (buff) {
+#ifdef RTE_NET_ICE
+		ret = rte_pmd_ice_dump_package(res->port_id, &buff, &size);
+#endif
+		switch (ret) {
+		case 0:
+			save_file(res->filepath, buff, size);
+			break;
+		case -EINVAL:
+			fprintf(stderr, "Invalid buffer size\n");
+			break;
+		case -ENOTSUP:
+			fprintf(stderr,
+				"Device doesn't support dump package.\n");
+			break;
+		default:
+			fprintf(stderr, "Failed to dump package file,"
+				" error: (%s)\n", strerror(-ret));
+		}
+	}
+	free(buff);
+}
+
+cmdline_parse_inst_t cmd_ddp_dump = {
+	.f = cmd_ddp_dump_parsed,
+	.data = NULL,
+	.help_str = "ddp dump <port_id> <profile_path>",
+	.tokens = {
+		(void *)&cmd_ddp_dump_ddp,
+		(void *)&cmd_ddp_dump_dump,
+		(void *)&cmd_ddp_dump_port_id,
+		(void *)&cmd_ddp_dump_filepath,
+		NULL,
+	},
+};
+
 /* Load dynamic device personalization*/
 struct cmd_ddp_add_result {
 	cmdline_fixed_string_t ddp;
@@ -18025,6 +18098,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_ddp_del,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
+	(cmdline_parse_inst_t *)&cmd_ddp_dump,
 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build
index 43130c8856..569e039bf7 100644
--- a/app/test-pmd/meson.build
+++ b/app/test-pmd/meson.build
@@ -67,6 +67,9 @@ endif
 if dpdk_conf.has('RTE_NET_I40E')
     deps += 'net_i40e'
 endif
+if dpdk_conf.has('RTE_NET_ICE')
+    deps += 'net_ice'
+endif
 if dpdk_conf.has('RTE_NET_IXGBE')
     deps += 'net_ixgbe'
 endif
-- 
2.27.0


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

* RE: [PATCH v1 1/2] net/ice: support dump ice ddp package
  2022-05-11  8:02 ` [PATCH v1 1/2] net/ice: support dump ice ddp package Steve Yang
@ 2022-05-18  4:22   ` Zhang, Qi Z
  2022-05-24  2:49     ` Zhang, Qi Z
  2022-05-18 15:21   ` Stephen Hemminger
  1 sibling, 1 reply; 24+ messages in thread
From: Zhang, Qi Z @ 2022-05-18  4:22 UTC (permalink / raw)
  To: Yang, SteveX, dev; +Cc: Zhang, Yuying, Yang, Qiming, mdr



> -----Original Message-----
> From: Yang, SteveX <stevex.yang@intel.com>
> Sent: Wednesday, May 11, 2022 4:03 PM
> To: dev@dpdk.org
> Cc: Zhang, Yuying <yuying.zhang@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>;
> mdr@ashroe.eu; Yang, SteveX <stevex.yang@intel.com>
> Subject: [PATCH v1 1/2] net/ice: support dump ice ddp package
> 
> Send the AQ command to acquire ice ddp package, and dump the binary to
> output file.

The ddp package is a static file be loaded during driver init.
So,  replace "package" with "runtime configure" which is more accurate.  

> 
> Export rte dump package API (rte_pmd_ice_dump_package) for application.
> 
> Signed-off-by: Steve Yang <stevex.yang@intel.com>

Acked-by: Qi Zhang <qi.z.zhang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi


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

* RE: [PATCH v1 2/2] app/testpmd: support dump_pkg command for ice
  2022-05-11  8:02 ` [PATCH v1 2/2] app/testpmd: support dump_pkg command for ice Steve Yang
@ 2022-05-18  4:32   ` Zhang, Qi Z
  0 siblings, 0 replies; 24+ messages in thread
From: Zhang, Qi Z @ 2022-05-18  4:32 UTC (permalink / raw)
  To: Yang, SteveX, dev; +Cc: Zhang, Yuying, Yang, Qiming, mdr



> -----Original Message-----
> From: Yang, SteveX <stevex.yang@intel.com>
> Sent: Wednesday, May 11, 2022 4:03 PM
> To: dev@dpdk.org
> Cc: Zhang, Yuying <yuying.zhang@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>;
> mdr@ashroe.eu; Yang, SteveX <stevex.yang@intel.com>
> Subject: [PATCH v1 2/2] app/testpmd: support dump_pkg command for ice
> 
> Support dump ice PF ddp package via testpmd command line.

Dump DDP configure into a binary(package) file from ice PF port.

> 
> Add command line:
>     ddp dump <port_id> <profile_path>
> 
> Parameters:
>     <port_id>       the PF Port ID
>     <profile_path>  dumped package profile file, if not a absolute path,
>                     it will be dumped to testpmd running directory.
> 
> For example:
> testpmd> ddp dump 0 current.pkg
> 
> If you want to dump ice VF ddp package, you need bind other unused PF port of
> the NIC first, and then dump the PF ddp package as target output.
> 
> Signed-off-by: Steve Yang <stevex.yang@intel.com>


Same comment to previous patch, 
"dump DDP package" is different concept with "dump DDP runtime configure into a package file" 

Please reword.


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

* [PATCH v3] app/testpmd: support ddp dump command for ice
  2022-05-12  2:06 ` [PATCH v2 0/2] ICE ddp download tool Steve Yang
  2022-05-12  2:06   ` [PATCH v2 1/2] net/ice: support dump ice ddp package Steve Yang
  2022-05-12  2:06   ` [PATCH v2 2/2] app/testpmd: support dump_pkg command for ice Steve Yang
@ 2022-05-18  6:58   ` Steve Yang
  2022-05-18 15:24     ` Stephen Hemminger
                       ` (2 more replies)
  2 siblings, 3 replies; 24+ messages in thread
From: Steve Yang @ 2022-05-18  6:58 UTC (permalink / raw)
  To: dev; +Cc: yuying.zhang, qi.z.zhang, Steve Yang

Dump DDP runtime configure into a binary(package) file from ice PF port.

Add command line:
    ddp dump <port_id> <config_path>

Parameters:
    <port_id>       the PF Port ID
    <config_path>   dumped runtime configure file, if not a absolute path,
                    it will be dumped to testpmd running directory.

For example:
testpmd> ddp dump 0 current.pkg

If you want to dump ice VF DDP runtime configure, you need bind other
unused PF port of the NIC first, and then dump the PF's runtime configure
as target output.

Signed-off-by: Steve Yang <stevex.yang@intel.com>

---
v3: change git commit log
---
 app/test-pmd/cmdline.c   | 76 ++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/meson.build |  3 ++
 2 files changed, 79 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 6ffea8e21a..6282981ee9 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -60,6 +60,9 @@
 #ifdef RTE_NET_I40E
 #include <rte_pmd_i40e.h>
 #endif
+#ifdef RTE_NET_ICE
+#include <rte_pmd_ice.h>
+#endif
 #ifdef RTE_NET_BNXT
 #include <rte_pmd_bnxt.h>
 #endif
@@ -654,6 +657,9 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"set link-down port (port_id)\n"
 			"	Set link down for a port.\n\n"
 
+			"ddp dump (port_id) (config_path)\n"
+			"    Dump a runtime configure on a port\n\n"
+
 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
 			"    Load a profile package on a port\n\n"
 
@@ -14471,6 +14477,75 @@ cmdline_parse_inst_t cmd_strict_link_prio = {
 	},
 };
 
+/* Dump device ddp package, only for ice PF */
+struct cmd_ddp_dump_result {
+	cmdline_fixed_string_t ddp;
+	cmdline_fixed_string_t add;
+	portid_t port_id;
+	char filepath[];
+};
+
+cmdline_parse_token_string_t cmd_ddp_dump_ddp =
+	TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, ddp, "ddp");
+cmdline_parse_token_string_t cmd_ddp_dump_dump =
+	TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, add, "dump");
+cmdline_parse_token_num_t cmd_ddp_dump_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_ddp_dump_result, port_id, RTE_UINT16);
+cmdline_parse_token_string_t cmd_ddp_dump_filepath =
+	TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, filepath, NULL);
+
+static void
+cmd_ddp_dump_parsed(
+	void *parsed_result,
+	__rte_unused struct cmdline *cl,
+	__rte_unused void *data)
+{
+	struct cmd_ddp_dump_result *res = parsed_result;
+	uint8_t *buff;
+	uint32_t size;
+	int ret = -ENOTSUP;
+
+#define ICE_BUFF_SIZE	0x000c9000
+	size = ICE_BUFF_SIZE;
+	buff = (uint8_t *)malloc(ICE_BUFF_SIZE);
+	if (buff) {
+#ifdef RTE_NET_ICE
+		ret = rte_pmd_ice_dump_package(res->port_id, &buff, &size);
+#endif
+		switch (ret) {
+		case 0:
+			save_file(res->filepath, buff, size);
+			break;
+		case -EINVAL:
+			fprintf(stderr, "Invalid buffer size\n");
+			break;
+		case -ENOTSUP:
+			fprintf(stderr,
+				"Device doesn't support "
+				"dump DDP runtime configure.\n");
+			break;
+		default:
+			fprintf(stderr,
+				"Failed to dump DDP runtime configure,"
+				" error: (%s)\n", strerror(-ret));
+		}
+	}
+	free(buff);
+}
+
+cmdline_parse_inst_t cmd_ddp_dump = {
+	.f = cmd_ddp_dump_parsed,
+	.data = NULL,
+	.help_str = "ddp dump <port_id> <config_path>",
+	.tokens = {
+		(void *)&cmd_ddp_dump_ddp,
+		(void *)&cmd_ddp_dump_dump,
+		(void *)&cmd_ddp_dump_port_id,
+		(void *)&cmd_ddp_dump_filepath,
+		NULL,
+	},
+};
+
 /* Load dynamic device personalization*/
 struct cmd_ddp_add_result {
 	cmdline_fixed_string_t ddp;
@@ -18025,6 +18100,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_ddp_del,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
+	(cmdline_parse_inst_t *)&cmd_ddp_dump,
 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build
index 43130c8856..569e039bf7 100644
--- a/app/test-pmd/meson.build
+++ b/app/test-pmd/meson.build
@@ -67,6 +67,9 @@ endif
 if dpdk_conf.has('RTE_NET_I40E')
     deps += 'net_i40e'
 endif
+if dpdk_conf.has('RTE_NET_ICE')
+    deps += 'net_ice'
+endif
 if dpdk_conf.has('RTE_NET_IXGBE')
     deps += 'net_ixgbe'
 endif
-- 
2.27.0


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

* Re: [PATCH v1 1/2] net/ice: support dump ice ddp package
  2022-05-11  8:02 ` [PATCH v1 1/2] net/ice: support dump ice ddp package Steve Yang
  2022-05-18  4:22   ` Zhang, Qi Z
@ 2022-05-18 15:21   ` Stephen Hemminger
  1 sibling, 0 replies; 24+ messages in thread
From: Stephen Hemminger @ 2022-05-18 15:21 UTC (permalink / raw)
  To: Steve Yang; +Cc: dev, yuying.zhang, qiming.yang, qi.z.zhang, mdr

On Wed, 11 May 2022 08:02:46 +0000
Steve Yang <stevex.yang@intel.com> wrote:

> +#define ICE_PKG_COPY_STRING(dst, src)	\
> +	do {\
> +		char *_dst = (dst); \
> +		const char *_src = (src); \
> +		memset(_dst, SPACE_CHAR, ICE_PKG_NAME_SIZE); \
> +		strncpy(_dst, _src, strlen(_src) + 1); \
> +	} while (0)

Reinventing strlcpy why?

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

* Re: [PATCH v3] app/testpmd: support ddp dump command for ice
  2022-05-18  6:58   ` [PATCH v3] app/testpmd: support ddp dump " Steve Yang
@ 2022-05-18 15:24     ` Stephen Hemminger
  2022-05-19  8:14       ` Andrew Rybchenko
  2022-05-19 12:12     ` David Marchand
  2022-06-09  7:39     ` [PATCH v4] net/ice: support dump DDP runtime configure Steve Yang
  2 siblings, 1 reply; 24+ messages in thread
From: Stephen Hemminger @ 2022-05-18 15:24 UTC (permalink / raw)
  To: Steve Yang; +Cc: dev, yuying.zhang, qi.z.zhang

On Wed, 18 May 2022 06:58:06 +0000
Steve Yang <stevex.yang@intel.com> wrote:

> +#define ICE_BUFF_SIZE	0x000c9000
Having magic size hard coded in testpmd is bad idea.
If there is driver specific size it should be exposed by API

> +	size = ICE_BUFF_SIZE;
> +	buff = (uint8_t *)malloc(ICE_BUFF_SIZE);

Cast of void * is not necessary in C (only C++)

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

* Re: [PATCH v3] app/testpmd: support ddp dump command for ice
  2022-05-18 15:24     ` Stephen Hemminger
@ 2022-05-19  8:14       ` Andrew Rybchenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Rybchenko @ 2022-05-19  8:14 UTC (permalink / raw)
  To: Stephen Hemminger, Steve Yang; +Cc: dev, yuying.zhang, qi.z.zhang

On 5/18/22 18:24, Stephen Hemminger wrote:
> On Wed, 18 May 2022 06:58:06 +0000
> Steve Yang <stevex.yang@intel.com> wrote:
> 
>> +#define ICE_BUFF_SIZE	0x000c9000
> Having magic size hard coded in testpmd is bad idea.
> If there is driver specific size it should be exposed by API
> 
>> +	size = ICE_BUFF_SIZE;
>> +	buff = (uint8_t *)malloc(ICE_BUFF_SIZE);
> 
> Cast of void * is not necessary in C (only C++)

Also the patch breaks build as reported by CI [1]:

[1] 
https://patches.dpdk.org/project/dpdk/patch/20220518065806.1005694-1-stevex.yang@intel.com/


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

* Re: [PATCH v3] app/testpmd: support ddp dump command for ice
  2022-05-18  6:58   ` [PATCH v3] app/testpmd: support ddp dump " Steve Yang
  2022-05-18 15:24     ` Stephen Hemminger
@ 2022-05-19 12:12     ` David Marchand
  2022-05-20  3:07       ` Zhang, Qi Z
  2022-06-09  7:39     ` [PATCH v4] net/ice: support dump DDP runtime configure Steve Yang
  2 siblings, 1 reply; 24+ messages in thread
From: David Marchand @ 2022-05-19 12:12 UTC (permalink / raw)
  To: Steve Yang
  Cc: dev, Yuying Zhang, Qi Zhang, Ferruh Yigit, Andrew Rybchenko,
	Thomas Monjalon

On Wed, May 18, 2022 at 9:07 AM Steve Yang <stevex.yang@intel.com> wrote:
>
> Dump DDP runtime configure into a binary(package) file from ice PF port.
>
> Add command line:
>     ddp dump <port_id> <config_path>
>
> Parameters:
>     <port_id>       the PF Port ID
>     <config_path>   dumped runtime configure file, if not a absolute path,
>                     it will be dumped to testpmd running directory.
>
> For example:
> testpmd> ddp dump 0 current.pkg
>
> If you want to dump ice VF DDP runtime configure, you need bind other
> unused PF port of the NIC first, and then dump the PF's runtime configure
> as target output.
>
> Signed-off-by: Steve Yang <stevex.yang@intel.com>

I proposed a way to move such code in drivers, please have a look
at/give feedback to:
https://patchwork.dpdk.org/project/dpdk/list/?series=23000&state=*


-- 
David Marchand


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

* RE: [PATCH v3] app/testpmd: support ddp dump command for ice
  2022-05-19 12:12     ` David Marchand
@ 2022-05-20  3:07       ` Zhang, Qi Z
  2022-05-21  1:19         ` Zhang, Qi Z
  0 siblings, 1 reply; 24+ messages in thread
From: Zhang, Qi Z @ 2022-05-20  3:07 UTC (permalink / raw)
  To: David Marchand, Yang, SteveX
  Cc: dev, Zhang, Yuying, Ferruh Yigit, Andrew Rybchenko, Thomas Monjalon



> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Thursday, May 19, 2022 8:13 PM
> To: Yang, SteveX <stevex.yang@intel.com>
> Cc: dev <dev@dpdk.org>; Zhang, Yuying <yuying.zhang@intel.com>; Zhang, Qi
> Z <qi.z.zhang@intel.com>; Ferruh Yigit <ferruh.yigit@xilinx.com>; Andrew
> Rybchenko <andrew.rybchenko@oktetlabs.ru>; Thomas Monjalon
> <thomas@monjalon.net>
> Subject: Re: [PATCH v3] app/testpmd: support ddp dump command for ice
> 
> On Wed, May 18, 2022 at 9:07 AM Steve Yang <stevex.yang@intel.com> wrote:
> >
> > Dump DDP runtime configure into a binary(package) file from ice PF port.
> >
> > Add command line:
> >     ddp dump <port_id> <config_path>
> >
> > Parameters:
> >     <port_id>       the PF Port ID
> >     <config_path>   dumped runtime configure file, if not a absolute path,
> >                     it will be dumped to testpmd running directory.
> >
> > For example:
> > testpmd> ddp dump 0 current.pkg
> >
> > If you want to dump ice VF DDP runtime configure, you need bind other
> > unused PF port of the NIC first, and then dump the PF's runtime
> > configure as target output.
> >
> > Signed-off-by: Steve Yang <stevex.yang@intel.com>
> 
> I proposed a way to move such code in drivers, please have a look at/give
> feedback to:
> https://patchwork.dpdk.org/project/dpdk/list/?series=23000&state=*

This looks like a good idea, we will review and thanks for the heads-up

> 
> 
> --
> David Marchand


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

* RE: [PATCH v3] app/testpmd: support ddp dump command for ice
  2022-05-20  3:07       ` Zhang, Qi Z
@ 2022-05-21  1:19         ` Zhang, Qi Z
  2022-05-23  7:14           ` David Marchand
  0 siblings, 1 reply; 24+ messages in thread
From: Zhang, Qi Z @ 2022-05-21  1:19 UTC (permalink / raw)
  To: David Marchand, Yang, SteveX
  Cc: dev, Zhang, Yuying, Ferruh Yigit, Andrew Rybchenko, Thomas Monjalon



> -----Original Message-----
> From: Zhang, Qi Z
> Sent: Friday, May 20, 2022 11:07 AM
> To: David Marchand <david.marchand@redhat.com>; Yang, SteveX
> <stevex.yang@intel.com>
> Cc: dev <dev@dpdk.org>; Zhang, Yuying <Yuying.Zhang@intel.com>; Ferruh
> Yigit <ferruh.yigit@xilinx.com>; Andrew Rybchenko
> <andrew.rybchenko@oktetlabs.ru>; Thomas Monjalon <thomas@monjalon.net>
> Subject: RE: [PATCH v3] app/testpmd: support ddp dump command for ice
> 
> 
> 
> > -----Original Message-----
> > From: David Marchand <david.marchand@redhat.com>
> > Sent: Thursday, May 19, 2022 8:13 PM
> > To: Yang, SteveX <stevex.yang@intel.com>
> > Cc: dev <dev@dpdk.org>; Zhang, Yuying <yuying.zhang@intel.com>; Zhang,
> > Qi Z <qi.z.zhang@intel.com>; Ferruh Yigit <ferruh.yigit@xilinx.com>;
> > Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>; Thomas Monjalon
> > <thomas@monjalon.net>
> > Subject: Re: [PATCH v3] app/testpmd: support ddp dump command for ice
> >
> > On Wed, May 18, 2022 at 9:07 AM Steve Yang <stevex.yang@intel.com>
> wrote:
> > >
> > > Dump DDP runtime configure into a binary(package) file from ice PF port.
> > >
> > > Add command line:
> > >     ddp dump <port_id> <config_path>
> > >
> > > Parameters:
> > >     <port_id>       the PF Port ID
> > >     <config_path>   dumped runtime configure file, if not a absolute path,
> > >                     it will be dumped to testpmd running directory.
> > >
> > > For example:
> > > testpmd> ddp dump 0 current.pkg
> > >
> > > If you want to dump ice VF DDP runtime configure, you need bind
> > > other unused PF port of the NIC first, and then dump the PF's
> > > runtime configure as target output.
> > >
> > > Signed-off-by: Steve Yang <stevex.yang@intel.com>
> >
> > I proposed a way to move such code in drivers, please have a look
> > at/give feedback to:
> > https://patchwork.dpdk.org/project/dpdk/list/?series=23000&state=*
> 
> This looks like a good idea, we will review and thanks for the heads-up
> 

David
	Are these RFC patches target to DPDK 22.07?
	If not, is below proposal acceptable?
	1. merge this patch in DPDK 22.07.
	2. meanwhile we will also contribute the ice refactor patch based on your RFC, so it can be  captured in next release.
Thanks
Qi

> >
> >
> > --
> > David Marchand


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

* Re: [PATCH v3] app/testpmd: support ddp dump command for ice
  2022-05-21  1:19         ` Zhang, Qi Z
@ 2022-05-23  7:14           ` David Marchand
  0 siblings, 0 replies; 24+ messages in thread
From: David Marchand @ 2022-05-23  7:14 UTC (permalink / raw)
  To: Zhang, Qi Z
  Cc: Yang, SteveX, dev, Zhang, Yuying, Ferruh Yigit, Andrew Rybchenko,
	Thomas Monjalon

On Sat, May 21, 2022 at 3:20 AM Zhang, Qi Z <qi.z.zhang@intel.com> wrote:
> > > > Dump DDP runtime configure into a binary(package) file from ice PF port.
> > > >
> > > > Add command line:
> > > >     ddp dump <port_id> <config_path>
> > > >
> > > > Parameters:
> > > >     <port_id>       the PF Port ID
> > > >     <config_path>   dumped runtime configure file, if not a absolute path,
> > > >                     it will be dumped to testpmd running directory.
> > > >
> > > > For example:
> > > > testpmd> ddp dump 0 current.pkg
> > > >
> > > > If you want to dump ice VF DDP runtime configure, you need bind
> > > > other unused PF port of the NIC first, and then dump the PF's
> > > > runtime configure as target output.
> > > >
> > > > Signed-off-by: Steve Yang <stevex.yang@intel.com>
> > >
> > > I proposed a way to move such code in drivers, please have a look
> > > at/give feedback to:
> > > https://patchwork.dpdk.org/project/dpdk/list/?series=23000&state=*
> >
> > This looks like a good idea, we will review and thanks for the heads-up
> >
>
> David
>         Are these RFC patches target to DPDK 22.07?
>         If not, is below proposal acceptable?
>         1. merge this patch in DPDK 22.07.
>         2. meanwhile we will also contribute the ice refactor patch based on your RFC, so it can be  captured in next release.

My intention is to get them in 22.07, if other maintainers are happy with it.
I just posted a non-RFC series.


-- 
David Marchand


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

* RE: [PATCH v1 1/2] net/ice: support dump ice ddp package
  2022-05-18  4:22   ` Zhang, Qi Z
@ 2022-05-24  2:49     ` Zhang, Qi Z
  0 siblings, 0 replies; 24+ messages in thread
From: Zhang, Qi Z @ 2022-05-24  2:49 UTC (permalink / raw)
  To: Yang, SteveX, dev; +Cc: Zhang, Yuying, Yang, Qiming, mdr



> -----Original Message-----
> From: Zhang, Qi Z
> Sent: Wednesday, May 18, 2022 12:22 PM
> To: Yang, SteveX <stevex.yang@intel.com>; dev@dpdk.org
> Cc: Zhang, Yuying <Yuying.Zhang@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; mdr@ashroe.eu
> Subject: RE: [PATCH v1 1/2] net/ice: support dump ice ddp package
> 
> 
> 
> > -----Original Message-----
> > From: Yang, SteveX <stevex.yang@intel.com>
> > Sent: Wednesday, May 11, 2022 4:03 PM
> > To: dev@dpdk.org
> > Cc: Zhang, Yuying <yuying.zhang@intel.com>; Yang, Qiming
> > <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>;
> > mdr@ashroe.eu; Yang, SteveX <stevex.yang@intel.com>
> > Subject: [PATCH v1 1/2] net/ice: support dump ice ddp package
> >
> > Send the AQ command to acquire ice ddp package, and dump the binary to
> > output file.
> 
> The ddp package is a static file be loaded during driver init.
> So,  replace "package" with "runtime configure" which is more accurate.
> 
> >
> > Export rte dump package API (rte_pmd_ice_dump_package) for application.
> >
> > Signed-off-by: Steve Yang <stevex.yang@intel.com>
> 
> Acked-by: Qi Zhang <qi.z.zhang@intel.com>
> 
> Applied to dpdk-next-net-intel.

The patch was dropped from dpdk-next-net-intel as new version is required to follow testpmd refactor
https://patchwork.dpdk.org/project/dpdk/list/?series=23086

> 
> Thanks
> Qi


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

* [PATCH v4] net/ice: support dump DDP runtime configure
  2022-05-18  6:58   ` [PATCH v3] app/testpmd: support ddp dump " Steve Yang
  2022-05-18 15:24     ` Stephen Hemminger
  2022-05-19 12:12     ` David Marchand
@ 2022-06-09  7:39     ` Steve Yang
  2022-06-09  8:40       ` Zhang, Qi Z
  2022-06-10  1:14       ` [PATCH v5] " Steve Yang
  2 siblings, 2 replies; 24+ messages in thread
From: Steve Yang @ 2022-06-09  7:39 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, qi.z.zhang, Steve Yang

Dump DDP runtime configure into a binary(package) file from ice PF port.

Add command line:
    ddp dump <port_id> <config_path>

Parameters:
    <port_id>       the PF Port ID
    <config_path>   dumped runtime configure file, if not a absolute path,
                    it will be dumped to testpmd running directory.

For example:
testpmd> ddp dump 0 current.pkg

If you want to dump ice VF DDP runtime configure, you need bind other
unused PF port of the NIC first, and then dump the PF's runtime configure
as target output.

Signed-off-by: Steve Yang <stevex.yang@intel.com>
---
 drivers/net/ice/ice_ddp_package.c | 418 ++++++++++++++++++++++++++++++
 drivers/net/ice/ice_ethdev.c      |   5 +
 drivers/net/ice/ice_ethdev.h      |   1 +
 drivers/net/ice/ice_testpmd.c     |  90 +++++++
 drivers/net/ice/meson.build       |   3 +
 drivers/net/ice/rte_pmd_ice.h     |   3 +
 drivers/net/ice/version.map       |   1 +
 7 files changed, 521 insertions(+)
 create mode 100644 drivers/net/ice/ice_ddp_package.c
 create mode 100644 drivers/net/ice/ice_testpmd.c

diff --git a/drivers/net/ice/ice_ddp_package.c b/drivers/net/ice/ice_ddp_package.c
new file mode 100644
index 0000000000..c7b5dc7ee7
--- /dev/null
+++ b/drivers/net/ice/ice_ddp_package.c
@@ -0,0 +1,418 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#include <rte_string_fns.h>
+#include <rte_malloc.h>
+#include <rte_tailq.h>
+
+#include "ice_ethdev.h"
+#include "rte_pmd_ice.h"
+
+#define ICE_BUFF_SEG_HEADER_FLAG   0x1
+#define ICE_PKG_HDR_HEADR_PART1    1
+#define ICE_PKG_HDR_HEADR_PART2    2
+#define ICE_PKG_HDR_GM_SEG_OFFSET  16
+#define ICE_PKG_HDR_ICE_SEG_OFFSET 100
+#define ICE_PKG_GM_SEG_TYPE        1
+#define ICE_PKG_MAJOR_VERSION      1
+#define ICE_PKG_GM_SEG_SIZE        84
+#define ICE_PKG_ICE_SEG_TYPE       0x10
+#define ICE_PKG_ICE_SEG_SIZE_BASE  56
+#define SPACE_CHAR                 0x20
+
+#define ICE_PKG_COPY_STRING(dst, src)	\
+	do {\
+		char *_dst = (dst); \
+		const char *_src = (src); \
+		memset(_dst, SPACE_CHAR, ICE_PKG_NAME_SIZE); \
+		strlcpy(_dst, _src, strlen(_dst)); \
+	} while (0)
+
+/* Package header */
+struct ice_package_header {
+	struct __hdr {
+		uint32_t h1; /* header part 1 */
+		uint32_t h2; /* header part 2 */
+	} header;
+	uint32_t gm_seg_offset;	 /* Global Metadata segment: 16 */
+	uint32_t ice_seg_offset; /* ICE segment: 100 */
+	struct ice_global_metadata_seg gm_seg;
+	struct __ice_seg {
+		struct ice_generic_seg_hdr hdr;
+		uint32_t devid_count;
+		struct ice_pkg_ver nvm_ver;
+	} ice_seg;
+
+	uint32_t buff_count;
+};
+
+struct ice_buff_seg_header {
+	__le16 flag;
+	__le16 length;
+	__le16 type;
+	__le16 reserve;		/* 0 */
+	__le16 header_len;	/* 0x0C */
+	__le16 data_size;	/* length - header_len */
+};
+
+struct ice_buff_seg_simple {
+	struct ice_buff_seg_header header;
+	__le16 seg_end;
+};
+
+struct ice_buff_seg_simple_data {
+	__le16 type;
+	__le32 addr;
+	__le16 len;
+	__le16 seg_end;
+};
+
+struct ice_buff_seg_series {
+	struct ice_buff_seg_header header;
+	uint16_t offset_delta;
+	uint16_t offset[2];
+};
+
+struct ice_buff_seg_series_data {
+	__le16 type;
+	__le32 begin_addr;
+	__le16 len;
+	__le32 end_addr;
+	__le16 last_len;
+	__le16 offset_delta;
+	__le16 seg_end;
+	uint8_t padding;
+};
+
+struct ice_buff_seg_series_with_sub {
+	struct ice_buff_seg_header header;
+	uint16_t sub_block_num;
+};
+
+struct ice_buff_seg_series_with_sub_data {
+	__le16 type;
+	__le32 begin_addr;
+	__le16 len;
+	__le32 end_addr;
+	__le16 last_len;
+	__le16 sblk_size;
+};
+
+
+static const
+uint16_t ice_buff_seg_header_size = sizeof(struct ice_buff_seg_header);
+
+static void
+write_buffer_simple(uint8_t **buff)
+{
+	uint16_t i;
+	/* ICE ddp package simple segment template */
+	const struct ice_buff_seg_simple_data buff_data[] = {
+	    {0x0001, 0x00000, 0x0030, 0x0000},
+	    {0x000a, 0x01000, 0x0810, 0x0800},
+	    {0x000b, 0x02000, 0x00d8, 0x0000},
+	    {0x000d, 0x06000, 0x0810, 0x0400},
+	    {0x000f, 0x09000, 0x0110, 0x0100},
+	    {0x0011, 0x17000, 0x001d, 0x0000},
+	    {0x0012, 0x18000, 0x0014, 0x0000},
+	    {0x0014, 0x19000, 0x0810, 0x0800},
+	    {0x0015, 0x1a000, 0x00d8, 0x0000},
+	    {0x0017, 0x1e000, 0x0810, 0x0400},
+	    {0x0019, 0x21000, 0x0090, 0x0080},
+	    {0x001b, 0x27000, 0x001d, 0x0000},
+	    {0x001c, 0x28000, 0x0014, 0x0000},
+	    {0x001e, 0x29000, 0x0810, 0x0800},
+	    {0x001f, 0x2a000, 0x00d8, 0x0000},
+	    {0x0021, 0x2e000, 0x0810, 0x0400},
+	    {0x0023, 0x31000, 0x0090, 0x0080},
+	    {0x0025, 0x36000, 0x001d, 0x0000},
+	    {0x0026, 0x37000, 0x0014, 0x0000},
+	    {0x0028, 0x38000, 0x0810, 0x0800},
+	    {0x0029, 0x39000, 0x00d8, 0x0000},
+	    {0x002b, 0x3d000, 0x0810, 0x0400},
+	    {0x002d, 0x40000, 0x0090, 0x0080},
+	    {0x002f, 0x45000, 0x001d, 0x0000},
+	    {0x0030, 0x46000, 0x0014, 0x0000},
+	    {0x0035, 0x57000, 0x0010, 0x0000},
+	    {0x003a, 0x67000, 0x0190, 0x0010},
+	    {0x003b, 0x68000, 0x0810, 0x0800},
+	    {0x003f, 0x79000, 0x0010, 0x0000},
+	    {0x0044, 0x89000, 0x0190, 0x0010},
+	    {0x0045, 0x8a000, 0x0810, 0x0800},
+	    {0x0046, 0x8b000, 0x001c, 0x0000},
+	    {0x0047, 0x8c000, 0x001c, 0x0000},
+	    {0x0048, 0x8d000, 0x0410, 0x0080},
+	    {0x0049, 0x8e000, 0x0410, 0x0080},
+	    {0x004a, 0x8f000, 0x0028, 0x0006},
+	    {0x004b, 0x90000, 0x0028, 0x0006},
+	    {0x004c, 0x91000, 0x0890, 0x0080},
+	    {0x004d, 0x92000, 0x0890, 0x0080},
+	    {0x004e, 0x93000, 0x0350, 0x0040},
+	    {0x004f, 0x94000, 0x0350, 0x0040},
+	    {0x0050, 0x95000, 0x0810, 0x0800},
+	    {0x0051, 0x96000, 0x00d8, 0x0000},
+	    {0x0053, 0x9a000, 0x0810, 0x0400},
+	    {0x0055, 0x9c000, 0x0030, 0x0020},
+	    {0x0057, 0x9f000, 0x001d, 0x0000},
+	    {0x0058, 0xa0000, 0x0014, 0x0000},
+	    {0x005a, 0xa1000, 0x0024, 0x0000},
+	    {0x005b, 0xa2000, 0x0024, 0x0000},
+	    {0x005d, 0xa4000, 0x0810, 0x0100},
+	    {0x020d, 0xa8000, 0x0414, 0x0400},
+	    {0x020e, 0xa9000, 0x0214, 0x0200},
+	    {0x020f, 0xaa000, 0x0114, 0x0100},
+	    {0x0210, 0xab000, 0x0114, 0x0100},
+	    {0x0217, 0xaf000, 0x0414, 0x0400},
+	    {0x0218, 0xb0000, 0x0214, 0x0200},
+	    {0x0219, 0xb1000, 0x0094, 0x0080},
+	    {0x021a, 0xb2000, 0x0094, 0x0080},
+	    {0x0221, 0xb6000, 0x0414, 0x0400},
+	    {0x0222, 0xb7000, 0x0214, 0x0200},
+	    {0x0223, 0xb8000, 0x0094, 0x0080},
+	    {0x0224, 0xb9000, 0x0094, 0x0080},
+	    {0x022b, 0xbd000, 0x0414, 0x0400},
+	    {0x022c, 0xbe000, 0x0214, 0x0200},
+	    {0x022d, 0xbf000, 0x0094, 0x0080},
+	    {0x022e, 0xc0000, 0x0094, 0x0080},
+	    {0x0238, 0xc1000, 0x0114, 0x0100},
+	    {0x0253, 0xc5000, 0x0414, 0x0400},
+	    {0x0254, 0xc6000, 0x0054, 0x0040},
+	    {0x0255, 0xc7000, 0x0034, 0x0020},
+	    {0x0256, 0xc8000, 0x0034, 0x0020},
+	};
+
+	for (i = 0; i < ARRAY_SIZE(buff_data); i++) {
+		const struct ice_buff_seg_simple_data *seg = &buff_data[i];
+		struct ice_buff_seg_simple buff_seg;
+		uint8_t *buffer = &(*buff)[seg->addr];
+
+		memset(buffer, 0xFF, ICE_PKG_BUF_SIZE);
+		buff_seg.header.flag = ICE_BUFF_SEG_HEADER_FLAG;
+		buff_seg.header.length = seg->len;
+		buff_seg.header.type = seg->type;
+		buff_seg.header.reserve = 0x0;
+		buff_seg.header.header_len =
+			sizeof(struct ice_buff_seg_header);
+		buff_seg.header.data_size =
+			buff_seg.header.length - buff_seg.header.header_len;
+		buff_seg.seg_end = seg->seg_end;
+
+		memset(buffer, 0x00, buff_seg.header.length);
+		memcpy(buffer, &buff_seg, sizeof(struct ice_buff_seg_simple));
+	}
+}
+
+static void
+write_buffer_block(uint8_t **buff)
+{
+	uint16_t i;
+	/* ICE ddp package multiple segments template 1 */
+	const struct ice_buff_seg_series_data buff_data[] = {
+		{0x000c, 0x03000, 0x1000, 0x05000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x0010, 0x0a000, 0x0fd0, 0x16000, 0x0310, 0x0015, 0x0004, 0},
+		{0x0016, 0x1b000, 0x1000, 0x1d000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x001a, 0x22000, 0x0f90, 0x26000, 0x0210, 0x001f, 0x0004, 0},
+		{0x0020, 0x2b000, 0x1000, 0x2d000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x0024, 0x32000, 0x0fd0, 0x35000, 0x00d0, 0x002a, 0x0002, 0},
+		{0x002a, 0x3a000, 0x1000, 0x3c000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x002e, 0x41000, 0x0fd0, 0x44000, 0x00d0, 0x002a, 0x0002, 0},
+		{0x0032, 0x47000, 0x1000, 0x4f000, 0x0090, 0x00ff, 0x0008, 0},
+		{0x0033, 0x50000, 0x1000, 0x53000, 0x0040, 0x0154, 0x0004, 0},
+		{0x0034, 0x54000, 0x1000, 0x56000, 0x0430, 0x0055, 0x0016, 0},
+		{0x0039, 0x65000, 0x1000, 0x66000, 0x0220, 0x00aa, 0x0016, 0},
+		{0x003c, 0x69000, 0x1000, 0x71000, 0x0090, 0x00ff, 0x0008, 0},
+		{0x003d, 0x72000, 0x1000, 0x75000, 0x0040, 0x0154, 0x0004, 0},
+		{0x003e, 0x76000, 0x1000, 0x78000, 0x0430, 0x0055, 0x0016, 0},
+		{0x0043, 0x87000, 0x1000, 0x88000, 0x0220, 0x00aa, 0x0016, 0},
+		{0x0052, 0x97000, 0x1000, 0x99000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x0056, 0x9d000, 0x0f90, 0x9e000, 0x0090, 0x001f, 0x0001, 0},
+		{0x020c, 0xa5000, 0x1000, 0xa7000, 0x003c, 0x0fec, 0x0028, 1},
+		{0x0216, 0xac000, 0x1000, 0xae000, 0x003c, 0x0fec, 0x0028, 1},
+		{0x0220, 0xb3000, 0x1000, 0xb5000, 0x003c, 0x0fec, 0x0028, 1},
+		{0x022a, 0xba000, 0x1000, 0xbc000, 0x003c, 0x0fec, 0x0028, 1},
+		{0x0252, 0xc2000, 0x1000, 0xc4000, 0x003c, 0x0fec, 0x0028, 1},
+	};
+
+	for (i = 0; i < ARRAY_SIZE(buff_data); i++) {
+		const struct ice_buff_seg_series_data *seg = &buff_data[i];
+		struct ice_buff_seg_series buff_seg;
+		const uint16_t buff_seg_size =
+			sizeof(struct ice_buff_seg_series);
+		uint32_t addr = seg->begin_addr;
+		__le16 last_offset = 0;
+
+		for (; addr <= seg->end_addr; addr += ICE_PKG_BUF_SIZE) {
+			uint8_t *buffer = &(*buff)[addr];
+
+			memset(buffer, 0xFF, ICE_PKG_BUF_SIZE);
+			buff_seg.header.flag = ICE_BUFF_SEG_HEADER_FLAG;
+			buff_seg.header.length = addr == seg->end_addr ?
+						seg->last_len : seg->len;
+			buff_seg.header.type = seg->type;
+			buff_seg.header.reserve = 0x0;
+			buff_seg.header.header_len = ice_buff_seg_header_size;
+			buff_seg.header.data_size = buff_seg.header.length -
+						buff_seg.header.header_len;
+			buff_seg.offset_delta =  addr < seg->end_addr ?
+				seg->offset_delta : seg->seg_end;
+			buff_seg.offset[!seg->padding] = 0x0;
+			buff_seg.offset[seg->padding] = last_offset;
+
+			memset(buffer, 0x00, buff_seg.header.length);
+			memcpy(buffer, &buff_seg, buff_seg_size);
+
+			last_offset += seg->offset_delta;
+		}
+	}
+}
+
+static void
+write_buffer_block2(uint8_t **buff)
+{
+	uint16_t i;
+	/* ICE ddp package multiple segments template 2 */
+	struct ice_buff_seg_series_with_sub_data buff_data[] = {
+		{0x000e, 0x07000, 0x1000, 0x08000, 0x0a1c, 13},
+		{0x0018, 0x1f000, 0x1000, 0x20000, 0x0a1c, 13},
+		{0x0022, 0x2f000, 0x1000, 0x30000, 0x0a1c, 13},
+		{0x002c, 0x3e000, 0x1000, 0x3f000, 0x0a1c, 13},
+		{0x0037, 0x58000, 0x1000, 0x5e000, 0x0070, 24},
+		{0x0038, 0x5f000, 0x0fe0, 0x64000, 0x0900, 88},
+		{0x0041, 0x7a000, 0x1000, 0x80000, 0x0070, 24},
+		{0x0042, 0x81000, 0x0fe0, 0x86000, 0x0900, 88},
+		{0x0054, 0x9b000, 0x034e, 0x9b000, 0x034e, 13},
+		{0x005c, 0xa3000, 0x0a10, 0xa3000, 0x0a10, 40},
+	};
+
+	for (i = 0; i < ARRAY_SIZE(buff_data); i++) {
+		struct ice_buff_seg_series_with_sub_data *seg = &buff_data[i];
+		struct ice_buff_seg_series_with_sub buff_seg;
+		const uint16_t buff_seg_size =
+			sizeof(struct ice_buff_seg_series_with_sub);
+		uint32_t addr;
+		uint16_t last_idx = 0;
+
+		for (addr = seg->begin_addr;
+		     addr <= seg->end_addr; addr += ICE_PKG_BUF_SIZE) {
+			uint8_t *buffer = &(*buff)[addr];
+			uint16_t total_sblk_size;
+			uint16_t idx = 0;
+			uint32_t pos = buff_seg_size;
+
+			memset(buffer, 0xFF, ICE_PKG_BUF_SIZE);
+			buff_seg.header.flag = ICE_BUFF_SEG_HEADER_FLAG;
+			buff_seg.header.length =
+				addr == seg->end_addr ?
+					seg->last_len : seg->len;
+			buff_seg.header.type = seg->type;
+			buff_seg.header.reserve = 0x0;
+			buff_seg.header.header_len = ice_buff_seg_header_size;
+			buff_seg.header.data_size = buff_seg.header.length -
+					buff_seg.header.header_len;
+
+			total_sblk_size = buff_seg.header.data_size
+					  - sizeof(buff_seg.sub_block_num);
+			buff_seg.sub_block_num =
+					total_sblk_size / seg->sblk_size;
+
+			memset(buffer, 0x00, buff_seg.header.length);
+			memcpy(buffer, &buff_seg, buff_seg_size);
+
+			/* padding if needed */
+			if (total_sblk_size % seg->sblk_size)
+				pos += sizeof(uint16_t);
+
+			for (idx = last_idx;
+			     idx < last_idx + buff_seg.sub_block_num; idx++) {
+				memcpy(buffer + pos, &idx, sizeof(uint16_t));
+				pos += seg->sblk_size;
+			}
+
+			last_idx = idx;
+		}
+	}
+}
+
+static int
+ice_dump_pkg(struct rte_eth_dev *dev, uint8_t **buff, uint32_t *size)
+{
+	struct ice_hw *hw;
+	struct ice_buf pkg_buff;
+	uint8_t *next_buff;
+	uint16_t i = 0;
+	uint16_t count;
+	struct ice_package_header *cache;
+	uint32_t cache_size;
+
+	write_buffer_simple(buff);
+	write_buffer_block(buff);
+	write_buffer_block2(buff);
+
+	hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	if (*size % ICE_PKG_BUF_SIZE)
+		return -EINVAL;
+
+	count = *size / ICE_PKG_BUF_SIZE;
+	for (i = 0; i < count; i++) {
+		next_buff = (uint8_t *)(*buff) + i * ICE_PKG_BUF_SIZE;
+		rte_memcpy(pkg_buff.buf, next_buff, ICE_PKG_BUF_SIZE);
+		if (ice_aq_upload_section(hw,
+					  (struct ice_buf_hdr *)&pkg_buff.buf[0],
+					  ICE_PKG_BUF_SIZE,
+					  NULL))
+			return -EINVAL;
+		rte_memcpy(next_buff, pkg_buff.buf, ICE_PKG_BUF_SIZE);
+	}
+
+	cache_size = sizeof(struct ice_package_header) + *size;
+	cache = (struct ice_package_header *)malloc(cache_size);
+	if (!cache)
+		return -ENOSPC;
+
+	cache->header.h1 = ICE_PKG_HDR_HEADR_PART1;
+	cache->header.h2 = ICE_PKG_HDR_HEADR_PART2;
+	cache->gm_seg_offset = ICE_PKG_HDR_GM_SEG_OFFSET;
+	cache->ice_seg_offset = ICE_PKG_HDR_ICE_SEG_OFFSET;
+	cache->gm_seg.hdr.seg_type = ICE_PKG_GM_SEG_TYPE;
+	cache->gm_seg.hdr.seg_format_ver.major = ICE_PKG_MAJOR_VERSION;
+	cache->gm_seg.hdr.seg_size = ICE_PKG_GM_SEG_SIZE;
+	ICE_PKG_COPY_STRING(cache->gm_seg.hdr.seg_id, "Global Metadata");
+
+	cache->gm_seg.pkg_ver.major = ICE_PKG_MAJOR_VERSION;
+	cache->gm_seg.rsvd = 1;
+	ICE_PKG_COPY_STRING(cache->gm_seg.pkg_name, "DEFAULT");
+
+	cache->ice_seg.hdr.seg_type = ICE_PKG_ICE_SEG_TYPE;
+	cache->ice_seg.hdr.seg_format_ver.major = ICE_PKG_MAJOR_VERSION;
+	cache->ice_seg.hdr.seg_size = ICE_PKG_ICE_SEG_SIZE_BASE + *size;
+	cache->ice_seg.devid_count = 0;
+	cache->ice_seg.nvm_ver.major = 0;
+	ICE_PKG_COPY_STRING(cache->ice_seg.hdr.seg_id, "CPK Configuration Data");
+
+	cache->buff_count = count;
+
+	next_buff = (uint8_t *)cache;
+	next_buff += sizeof(struct ice_package_header);
+	memcpy(next_buff, *buff, *size);
+
+	free(*buff);
+	*buff = (uint8_t *)cache;
+	*size = cache_size;
+
+	return 0;
+}
+
+int rte_pmd_ice_dump_package(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_pkg(dev, buff, size);
+}
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 35ab542e61..20079d038e 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -5930,3 +5930,8 @@ RTE_LOG_REGISTER_SUFFIX(ice_logtype_rx, rx, DEBUG);
 #ifdef RTE_ETHDEV_DEBUG_TX
 RTE_LOG_REGISTER_SUFFIX(ice_logtype_tx, tx, DEBUG);
 #endif
+
+bool is_ice_supported(struct rte_eth_dev *dev)
+{
+	return !strcmp(dev->device->driver->name, rte_ice_pmd.driver.name);
+}
diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index f9f4a1c71b..3345356d9f 100644
--- a/drivers/net/ice/ice_ethdev.h
+++ b/drivers/net/ice/ice_ethdev.h
@@ -663,6 +663,7 @@ struct ice_vsi_vlan_pvid_info {
 #define ICE_PF_TO_ETH_DEV(pf) \
 	(((struct ice_pf *)pf)->adapter->eth_dev)
 
+bool is_ice_supported(struct rte_eth_dev *dev);
 int
 ice_load_pkg(struct ice_adapter *adapter, bool use_dsn, uint64_t dsn);
 struct ice_vsi *
diff --git a/drivers/net/ice/ice_testpmd.c b/drivers/net/ice/ice_testpmd.c
new file mode 100644
index 0000000000..6198f405bc
--- /dev/null
+++ b/drivers/net/ice/ice_testpmd.c
@@ -0,0 +1,90 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation.
+ */
+#include <rte_pmd_ice.h>
+
+#include <cmdline_parse_num.h>
+#include <cmdline_parse_string.h>
+
+#include "testpmd.h"
+
+/* Fixed size for ICE ddp runtime configure */
+#define ICE_BUFF_SIZE	0x000c9000
+
+/* Dump device ddp package, only for ice PF */
+struct cmd_ddp_dump_result {
+	cmdline_fixed_string_t ddp;
+	cmdline_fixed_string_t add;
+	portid_t port_id;
+	char filepath[];
+};
+
+cmdline_parse_token_string_t cmd_ddp_dump_ddp =
+	TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, ddp, "ddp");
+cmdline_parse_token_string_t cmd_ddp_dump_dump =
+	TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, add, "dump");
+cmdline_parse_token_num_t cmd_ddp_dump_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_ddp_dump_result, port_id, RTE_UINT16);
+cmdline_parse_token_string_t cmd_ddp_dump_filepath =
+	TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, filepath, NULL);
+
+static void
+cmd_ddp_dump_parsed(void *parsed_result,
+		    __rte_unused struct cmdline *cl,
+		    __rte_unused void *data)
+{
+	struct cmd_ddp_dump_result *res = parsed_result;
+	uint8_t *buff;
+	uint32_t size;
+	int ret = -ENOTSUP;
+
+	size = ICE_BUFF_SIZE;
+	buff = (uint8_t *)malloc(ICE_BUFF_SIZE);
+	if (buff) {
+		ret = rte_pmd_ice_dump_package(res->port_id, &buff, &size);
+		switch (ret) {
+		case 0:
+			save_file(res->filepath, buff, size);
+			break;
+		case -EINVAL:
+			fprintf(stderr, "Invalid buffer size\n");
+			break;
+		case -ENOTSUP:
+			fprintf(stderr,
+				"Device doesn't support "
+				"dump DDP runtime configure.\n");
+			break;
+		default:
+			fprintf(stderr,
+				"Failed to dump DDP runtime configure,"
+				" error: (%s)\n", strerror(-ret));
+		}
+	}
+	free(buff);
+}
+
+cmdline_parse_inst_t cmd_ddp_dump = {
+	.f = cmd_ddp_dump_parsed,
+	.data = NULL,
+	.help_str = "ddp dump <port_id> <config_path>",
+	.tokens = {
+		(void *)&cmd_ddp_dump_ddp,
+		(void *)&cmd_ddp_dump_dump,
+		(void *)&cmd_ddp_dump_port_id,
+		(void *)&cmd_ddp_dump_filepath,
+		NULL,
+	},
+};
+
+static struct testpmd_commands ice_cmds = {
+	.commands = {
+	{
+		&cmd_ddp_dump,
+		"ddp dump (port_id) (config_path)\n"
+		"    Dump a runtime configure on a port\n\n",
+
+	},
+	{ NULL, NULL },
+	},
+};
+TESTPMD_ADD_DRIVER_COMMANDS(ice_cmds)
diff --git a/drivers/net/ice/meson.build b/drivers/net/ice/meson.build
index de307c9e71..89f9abaaa7 100644
--- a/drivers/net/ice/meson.build
+++ b/drivers/net/ice/meson.build
@@ -13,8 +13,11 @@ sources = files(
         'ice_rxtx.c',
         'ice_switch_filter.c',
         'ice_tm.c',
+        'ice_ddp_package.c'
 )
 
+testpmd_sources = files('ice_testpmd.c')
+
 deps += ['hash', 'net', 'common_iavf']
 includes += include_directories('base', '../../common/iavf')
 
diff --git a/drivers/net/ice/rte_pmd_ice.h b/drivers/net/ice/rte_pmd_ice.h
index 9a436a140b..53c81ccf4e 100644
--- a/drivers/net/ice/rte_pmd_ice.h
+++ b/drivers/net/ice/rte_pmd_ice.h
@@ -237,6 +237,9 @@ rte_net_ice_dump_proto_xtr_metadata(struct rte_mbuf *m)
 		       data.ip_ofs);
 }
 
+__rte_experimental
+int rte_pmd_ice_dump_package(uint16_t port, uint8_t **buff, uint32_t *size);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/drivers/net/ice/version.map b/drivers/net/ice/version.map
index cc837f1c00..60a3f17393 100644
--- a/drivers/net/ice/version.map
+++ b/drivers/net/ice/version.map
@@ -13,4 +13,5 @@ EXPERIMENTAL {
 	rte_net_ice_dynflag_proto_xtr_ipv6_flow_mask;
 	rte_net_ice_dynflag_proto_xtr_tcp_mask;
 	rte_net_ice_dynflag_proto_xtr_ip_offset_mask;
+	rte_pmd_ice_dump_package;
 };
-- 
2.34.1


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

* RE: [PATCH v4] net/ice: support dump DDP runtime configure
  2022-06-09  7:39     ` [PATCH v4] net/ice: support dump DDP runtime configure Steve Yang
@ 2022-06-09  8:40       ` Zhang, Qi Z
  2022-06-10  1:16         ` Zhang, Qi Z
  2022-06-10  1:14       ` [PATCH v5] " Steve Yang
  1 sibling, 1 reply; 24+ messages in thread
From: Zhang, Qi Z @ 2022-06-09  8:40 UTC (permalink / raw)
  To: Yang, SteveX, dev; +Cc: Yang, Qiming



> -----Original Message-----
> From: Yang, SteveX <stevex.yang@intel.com>
> Sent: Thursday, June 9, 2022 3:40 PM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; Yang, SteveX <stevex.yang@intel.com>
> Subject: [PATCH v4] net/ice: support dump DDP runtime configure
> 
> Dump DDP runtime configure into a binary(package) file from ice PF port.
> 
> Add command line:
>     ddp dump <port_id> <config_path>
> 
> Parameters:
>     <port_id>       the PF Port ID
>     <config_path>   dumped runtime configure file, if not a absolute path,
>                     it will be dumped to testpmd running directory.
> 
> For example:
> testpmd> ddp dump 0 current.pkg
> 
> If you want to dump ice VF DDP runtime configure, you need bind other
> unused PF port of the NIC first, and then dump the PF's runtime configure as
> target output.
> 
> Signed-off-by: Steve Yang <stevex.yang@intel.com>

Acked-by: Qi Zhang <qi.z.zhang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi

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

* [PATCH v5] net/ice: support dump DDP runtime configure
  2022-06-09  7:39     ` [PATCH v4] net/ice: support dump DDP runtime configure Steve Yang
  2022-06-09  8:40       ` Zhang, Qi Z
@ 2022-06-10  1:14       ` Steve Yang
  2022-06-10  2:25         ` Zhang, Qi Z
  1 sibling, 1 reply; 24+ messages in thread
From: Steve Yang @ 2022-06-10  1:14 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, qi.z.zhang, Steve Yang

Dump DDP runtime configure into a binary(package) file from ice PF port.

Add command line:
    ddp dump <port_id> <config_path>

Parameters:
    <port_id>       the PF Port ID
    <config_path>   dumped runtime configure file, if not a absolute path,
                    it will be dumped to testpmd running directory.

For example:
testpmd> ddp dump 0 current.pkg

If you want to dump ice VF DDP runtime configure, you need bind other
unused PF port of the NIC first, and then dump the PF's runtime configure
as target output.

Signed-off-by: Steve Yang <stevex.yang@intel.com>
---
 drivers/net/ice/ice_ddp_package.c | 418 ++++++++++++++++++++++++++++++
 drivers/net/ice/ice_ethdev.c      |   5 +
 drivers/net/ice/ice_ethdev.h      |   1 +
 drivers/net/ice/ice_testpmd.c     |  90 +++++++
 drivers/net/ice/meson.build       |   3 +
 drivers/net/ice/rte_pmd_ice.h     |   3 +
 drivers/net/ice/version.map       |   1 +
 7 files changed, 521 insertions(+)
 create mode 100644 drivers/net/ice/ice_ddp_package.c
 create mode 100644 drivers/net/ice/ice_testpmd.c

diff --git a/drivers/net/ice/ice_ddp_package.c b/drivers/net/ice/ice_ddp_package.c
new file mode 100644
index 0000000000..c7b5dc7ee7
--- /dev/null
+++ b/drivers/net/ice/ice_ddp_package.c
@@ -0,0 +1,418 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#include <rte_string_fns.h>
+#include <rte_malloc.h>
+#include <rte_tailq.h>
+
+#include "ice_ethdev.h"
+#include "rte_pmd_ice.h"
+
+#define ICE_BUFF_SEG_HEADER_FLAG   0x1
+#define ICE_PKG_HDR_HEADR_PART1    1
+#define ICE_PKG_HDR_HEADR_PART2    2
+#define ICE_PKG_HDR_GM_SEG_OFFSET  16
+#define ICE_PKG_HDR_ICE_SEG_OFFSET 100
+#define ICE_PKG_GM_SEG_TYPE        1
+#define ICE_PKG_MAJOR_VERSION      1
+#define ICE_PKG_GM_SEG_SIZE        84
+#define ICE_PKG_ICE_SEG_TYPE       0x10
+#define ICE_PKG_ICE_SEG_SIZE_BASE  56
+#define SPACE_CHAR                 0x20
+
+#define ICE_PKG_COPY_STRING(dst, src)	\
+	do {\
+		char *_dst = (dst); \
+		const char *_src = (src); \
+		memset(_dst, SPACE_CHAR, ICE_PKG_NAME_SIZE); \
+		strlcpy(_dst, _src, strlen(_dst)); \
+	} while (0)
+
+/* Package header */
+struct ice_package_header {
+	struct __hdr {
+		uint32_t h1; /* header part 1 */
+		uint32_t h2; /* header part 2 */
+	} header;
+	uint32_t gm_seg_offset;	 /* Global Metadata segment: 16 */
+	uint32_t ice_seg_offset; /* ICE segment: 100 */
+	struct ice_global_metadata_seg gm_seg;
+	struct __ice_seg {
+		struct ice_generic_seg_hdr hdr;
+		uint32_t devid_count;
+		struct ice_pkg_ver nvm_ver;
+	} ice_seg;
+
+	uint32_t buff_count;
+};
+
+struct ice_buff_seg_header {
+	__le16 flag;
+	__le16 length;
+	__le16 type;
+	__le16 reserve;		/* 0 */
+	__le16 header_len;	/* 0x0C */
+	__le16 data_size;	/* length - header_len */
+};
+
+struct ice_buff_seg_simple {
+	struct ice_buff_seg_header header;
+	__le16 seg_end;
+};
+
+struct ice_buff_seg_simple_data {
+	__le16 type;
+	__le32 addr;
+	__le16 len;
+	__le16 seg_end;
+};
+
+struct ice_buff_seg_series {
+	struct ice_buff_seg_header header;
+	uint16_t offset_delta;
+	uint16_t offset[2];
+};
+
+struct ice_buff_seg_series_data {
+	__le16 type;
+	__le32 begin_addr;
+	__le16 len;
+	__le32 end_addr;
+	__le16 last_len;
+	__le16 offset_delta;
+	__le16 seg_end;
+	uint8_t padding;
+};
+
+struct ice_buff_seg_series_with_sub {
+	struct ice_buff_seg_header header;
+	uint16_t sub_block_num;
+};
+
+struct ice_buff_seg_series_with_sub_data {
+	__le16 type;
+	__le32 begin_addr;
+	__le16 len;
+	__le32 end_addr;
+	__le16 last_len;
+	__le16 sblk_size;
+};
+
+
+static const
+uint16_t ice_buff_seg_header_size = sizeof(struct ice_buff_seg_header);
+
+static void
+write_buffer_simple(uint8_t **buff)
+{
+	uint16_t i;
+	/* ICE ddp package simple segment template */
+	const struct ice_buff_seg_simple_data buff_data[] = {
+	    {0x0001, 0x00000, 0x0030, 0x0000},
+	    {0x000a, 0x01000, 0x0810, 0x0800},
+	    {0x000b, 0x02000, 0x00d8, 0x0000},
+	    {0x000d, 0x06000, 0x0810, 0x0400},
+	    {0x000f, 0x09000, 0x0110, 0x0100},
+	    {0x0011, 0x17000, 0x001d, 0x0000},
+	    {0x0012, 0x18000, 0x0014, 0x0000},
+	    {0x0014, 0x19000, 0x0810, 0x0800},
+	    {0x0015, 0x1a000, 0x00d8, 0x0000},
+	    {0x0017, 0x1e000, 0x0810, 0x0400},
+	    {0x0019, 0x21000, 0x0090, 0x0080},
+	    {0x001b, 0x27000, 0x001d, 0x0000},
+	    {0x001c, 0x28000, 0x0014, 0x0000},
+	    {0x001e, 0x29000, 0x0810, 0x0800},
+	    {0x001f, 0x2a000, 0x00d8, 0x0000},
+	    {0x0021, 0x2e000, 0x0810, 0x0400},
+	    {0x0023, 0x31000, 0x0090, 0x0080},
+	    {0x0025, 0x36000, 0x001d, 0x0000},
+	    {0x0026, 0x37000, 0x0014, 0x0000},
+	    {0x0028, 0x38000, 0x0810, 0x0800},
+	    {0x0029, 0x39000, 0x00d8, 0x0000},
+	    {0x002b, 0x3d000, 0x0810, 0x0400},
+	    {0x002d, 0x40000, 0x0090, 0x0080},
+	    {0x002f, 0x45000, 0x001d, 0x0000},
+	    {0x0030, 0x46000, 0x0014, 0x0000},
+	    {0x0035, 0x57000, 0x0010, 0x0000},
+	    {0x003a, 0x67000, 0x0190, 0x0010},
+	    {0x003b, 0x68000, 0x0810, 0x0800},
+	    {0x003f, 0x79000, 0x0010, 0x0000},
+	    {0x0044, 0x89000, 0x0190, 0x0010},
+	    {0x0045, 0x8a000, 0x0810, 0x0800},
+	    {0x0046, 0x8b000, 0x001c, 0x0000},
+	    {0x0047, 0x8c000, 0x001c, 0x0000},
+	    {0x0048, 0x8d000, 0x0410, 0x0080},
+	    {0x0049, 0x8e000, 0x0410, 0x0080},
+	    {0x004a, 0x8f000, 0x0028, 0x0006},
+	    {0x004b, 0x90000, 0x0028, 0x0006},
+	    {0x004c, 0x91000, 0x0890, 0x0080},
+	    {0x004d, 0x92000, 0x0890, 0x0080},
+	    {0x004e, 0x93000, 0x0350, 0x0040},
+	    {0x004f, 0x94000, 0x0350, 0x0040},
+	    {0x0050, 0x95000, 0x0810, 0x0800},
+	    {0x0051, 0x96000, 0x00d8, 0x0000},
+	    {0x0053, 0x9a000, 0x0810, 0x0400},
+	    {0x0055, 0x9c000, 0x0030, 0x0020},
+	    {0x0057, 0x9f000, 0x001d, 0x0000},
+	    {0x0058, 0xa0000, 0x0014, 0x0000},
+	    {0x005a, 0xa1000, 0x0024, 0x0000},
+	    {0x005b, 0xa2000, 0x0024, 0x0000},
+	    {0x005d, 0xa4000, 0x0810, 0x0100},
+	    {0x020d, 0xa8000, 0x0414, 0x0400},
+	    {0x020e, 0xa9000, 0x0214, 0x0200},
+	    {0x020f, 0xaa000, 0x0114, 0x0100},
+	    {0x0210, 0xab000, 0x0114, 0x0100},
+	    {0x0217, 0xaf000, 0x0414, 0x0400},
+	    {0x0218, 0xb0000, 0x0214, 0x0200},
+	    {0x0219, 0xb1000, 0x0094, 0x0080},
+	    {0x021a, 0xb2000, 0x0094, 0x0080},
+	    {0x0221, 0xb6000, 0x0414, 0x0400},
+	    {0x0222, 0xb7000, 0x0214, 0x0200},
+	    {0x0223, 0xb8000, 0x0094, 0x0080},
+	    {0x0224, 0xb9000, 0x0094, 0x0080},
+	    {0x022b, 0xbd000, 0x0414, 0x0400},
+	    {0x022c, 0xbe000, 0x0214, 0x0200},
+	    {0x022d, 0xbf000, 0x0094, 0x0080},
+	    {0x022e, 0xc0000, 0x0094, 0x0080},
+	    {0x0238, 0xc1000, 0x0114, 0x0100},
+	    {0x0253, 0xc5000, 0x0414, 0x0400},
+	    {0x0254, 0xc6000, 0x0054, 0x0040},
+	    {0x0255, 0xc7000, 0x0034, 0x0020},
+	    {0x0256, 0xc8000, 0x0034, 0x0020},
+	};
+
+	for (i = 0; i < ARRAY_SIZE(buff_data); i++) {
+		const struct ice_buff_seg_simple_data *seg = &buff_data[i];
+		struct ice_buff_seg_simple buff_seg;
+		uint8_t *buffer = &(*buff)[seg->addr];
+
+		memset(buffer, 0xFF, ICE_PKG_BUF_SIZE);
+		buff_seg.header.flag = ICE_BUFF_SEG_HEADER_FLAG;
+		buff_seg.header.length = seg->len;
+		buff_seg.header.type = seg->type;
+		buff_seg.header.reserve = 0x0;
+		buff_seg.header.header_len =
+			sizeof(struct ice_buff_seg_header);
+		buff_seg.header.data_size =
+			buff_seg.header.length - buff_seg.header.header_len;
+		buff_seg.seg_end = seg->seg_end;
+
+		memset(buffer, 0x00, buff_seg.header.length);
+		memcpy(buffer, &buff_seg, sizeof(struct ice_buff_seg_simple));
+	}
+}
+
+static void
+write_buffer_block(uint8_t **buff)
+{
+	uint16_t i;
+	/* ICE ddp package multiple segments template 1 */
+	const struct ice_buff_seg_series_data buff_data[] = {
+		{0x000c, 0x03000, 0x1000, 0x05000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x0010, 0x0a000, 0x0fd0, 0x16000, 0x0310, 0x0015, 0x0004, 0},
+		{0x0016, 0x1b000, 0x1000, 0x1d000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x001a, 0x22000, 0x0f90, 0x26000, 0x0210, 0x001f, 0x0004, 0},
+		{0x0020, 0x2b000, 0x1000, 0x2d000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x0024, 0x32000, 0x0fd0, 0x35000, 0x00d0, 0x002a, 0x0002, 0},
+		{0x002a, 0x3a000, 0x1000, 0x3c000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x002e, 0x41000, 0x0fd0, 0x44000, 0x00d0, 0x002a, 0x0002, 0},
+		{0x0032, 0x47000, 0x1000, 0x4f000, 0x0090, 0x00ff, 0x0008, 0},
+		{0x0033, 0x50000, 0x1000, 0x53000, 0x0040, 0x0154, 0x0004, 0},
+		{0x0034, 0x54000, 0x1000, 0x56000, 0x0430, 0x0055, 0x0016, 0},
+		{0x0039, 0x65000, 0x1000, 0x66000, 0x0220, 0x00aa, 0x0016, 0},
+		{0x003c, 0x69000, 0x1000, 0x71000, 0x0090, 0x00ff, 0x0008, 0},
+		{0x003d, 0x72000, 0x1000, 0x75000, 0x0040, 0x0154, 0x0004, 0},
+		{0x003e, 0x76000, 0x1000, 0x78000, 0x0430, 0x0055, 0x0016, 0},
+		{0x0043, 0x87000, 0x1000, 0x88000, 0x0220, 0x00aa, 0x0016, 0},
+		{0x0052, 0x97000, 0x1000, 0x99000, 0x0030, 0x0ff0, 0x0020, 0},
+		{0x0056, 0x9d000, 0x0f90, 0x9e000, 0x0090, 0x001f, 0x0001, 0},
+		{0x020c, 0xa5000, 0x1000, 0xa7000, 0x003c, 0x0fec, 0x0028, 1},
+		{0x0216, 0xac000, 0x1000, 0xae000, 0x003c, 0x0fec, 0x0028, 1},
+		{0x0220, 0xb3000, 0x1000, 0xb5000, 0x003c, 0x0fec, 0x0028, 1},
+		{0x022a, 0xba000, 0x1000, 0xbc000, 0x003c, 0x0fec, 0x0028, 1},
+		{0x0252, 0xc2000, 0x1000, 0xc4000, 0x003c, 0x0fec, 0x0028, 1},
+	};
+
+	for (i = 0; i < ARRAY_SIZE(buff_data); i++) {
+		const struct ice_buff_seg_series_data *seg = &buff_data[i];
+		struct ice_buff_seg_series buff_seg;
+		const uint16_t buff_seg_size =
+			sizeof(struct ice_buff_seg_series);
+		uint32_t addr = seg->begin_addr;
+		__le16 last_offset = 0;
+
+		for (; addr <= seg->end_addr; addr += ICE_PKG_BUF_SIZE) {
+			uint8_t *buffer = &(*buff)[addr];
+
+			memset(buffer, 0xFF, ICE_PKG_BUF_SIZE);
+			buff_seg.header.flag = ICE_BUFF_SEG_HEADER_FLAG;
+			buff_seg.header.length = addr == seg->end_addr ?
+						seg->last_len : seg->len;
+			buff_seg.header.type = seg->type;
+			buff_seg.header.reserve = 0x0;
+			buff_seg.header.header_len = ice_buff_seg_header_size;
+			buff_seg.header.data_size = buff_seg.header.length -
+						buff_seg.header.header_len;
+			buff_seg.offset_delta =  addr < seg->end_addr ?
+				seg->offset_delta : seg->seg_end;
+			buff_seg.offset[!seg->padding] = 0x0;
+			buff_seg.offset[seg->padding] = last_offset;
+
+			memset(buffer, 0x00, buff_seg.header.length);
+			memcpy(buffer, &buff_seg, buff_seg_size);
+
+			last_offset += seg->offset_delta;
+		}
+	}
+}
+
+static void
+write_buffer_block2(uint8_t **buff)
+{
+	uint16_t i;
+	/* ICE ddp package multiple segments template 2 */
+	struct ice_buff_seg_series_with_sub_data buff_data[] = {
+		{0x000e, 0x07000, 0x1000, 0x08000, 0x0a1c, 13},
+		{0x0018, 0x1f000, 0x1000, 0x20000, 0x0a1c, 13},
+		{0x0022, 0x2f000, 0x1000, 0x30000, 0x0a1c, 13},
+		{0x002c, 0x3e000, 0x1000, 0x3f000, 0x0a1c, 13},
+		{0x0037, 0x58000, 0x1000, 0x5e000, 0x0070, 24},
+		{0x0038, 0x5f000, 0x0fe0, 0x64000, 0x0900, 88},
+		{0x0041, 0x7a000, 0x1000, 0x80000, 0x0070, 24},
+		{0x0042, 0x81000, 0x0fe0, 0x86000, 0x0900, 88},
+		{0x0054, 0x9b000, 0x034e, 0x9b000, 0x034e, 13},
+		{0x005c, 0xa3000, 0x0a10, 0xa3000, 0x0a10, 40},
+	};
+
+	for (i = 0; i < ARRAY_SIZE(buff_data); i++) {
+		struct ice_buff_seg_series_with_sub_data *seg = &buff_data[i];
+		struct ice_buff_seg_series_with_sub buff_seg;
+		const uint16_t buff_seg_size =
+			sizeof(struct ice_buff_seg_series_with_sub);
+		uint32_t addr;
+		uint16_t last_idx = 0;
+
+		for (addr = seg->begin_addr;
+		     addr <= seg->end_addr; addr += ICE_PKG_BUF_SIZE) {
+			uint8_t *buffer = &(*buff)[addr];
+			uint16_t total_sblk_size;
+			uint16_t idx = 0;
+			uint32_t pos = buff_seg_size;
+
+			memset(buffer, 0xFF, ICE_PKG_BUF_SIZE);
+			buff_seg.header.flag = ICE_BUFF_SEG_HEADER_FLAG;
+			buff_seg.header.length =
+				addr == seg->end_addr ?
+					seg->last_len : seg->len;
+			buff_seg.header.type = seg->type;
+			buff_seg.header.reserve = 0x0;
+			buff_seg.header.header_len = ice_buff_seg_header_size;
+			buff_seg.header.data_size = buff_seg.header.length -
+					buff_seg.header.header_len;
+
+			total_sblk_size = buff_seg.header.data_size
+					  - sizeof(buff_seg.sub_block_num);
+			buff_seg.sub_block_num =
+					total_sblk_size / seg->sblk_size;
+
+			memset(buffer, 0x00, buff_seg.header.length);
+			memcpy(buffer, &buff_seg, buff_seg_size);
+
+			/* padding if needed */
+			if (total_sblk_size % seg->sblk_size)
+				pos += sizeof(uint16_t);
+
+			for (idx = last_idx;
+			     idx < last_idx + buff_seg.sub_block_num; idx++) {
+				memcpy(buffer + pos, &idx, sizeof(uint16_t));
+				pos += seg->sblk_size;
+			}
+
+			last_idx = idx;
+		}
+	}
+}
+
+static int
+ice_dump_pkg(struct rte_eth_dev *dev, uint8_t **buff, uint32_t *size)
+{
+	struct ice_hw *hw;
+	struct ice_buf pkg_buff;
+	uint8_t *next_buff;
+	uint16_t i = 0;
+	uint16_t count;
+	struct ice_package_header *cache;
+	uint32_t cache_size;
+
+	write_buffer_simple(buff);
+	write_buffer_block(buff);
+	write_buffer_block2(buff);
+
+	hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	if (*size % ICE_PKG_BUF_SIZE)
+		return -EINVAL;
+
+	count = *size / ICE_PKG_BUF_SIZE;
+	for (i = 0; i < count; i++) {
+		next_buff = (uint8_t *)(*buff) + i * ICE_PKG_BUF_SIZE;
+		rte_memcpy(pkg_buff.buf, next_buff, ICE_PKG_BUF_SIZE);
+		if (ice_aq_upload_section(hw,
+					  (struct ice_buf_hdr *)&pkg_buff.buf[0],
+					  ICE_PKG_BUF_SIZE,
+					  NULL))
+			return -EINVAL;
+		rte_memcpy(next_buff, pkg_buff.buf, ICE_PKG_BUF_SIZE);
+	}
+
+	cache_size = sizeof(struct ice_package_header) + *size;
+	cache = (struct ice_package_header *)malloc(cache_size);
+	if (!cache)
+		return -ENOSPC;
+
+	cache->header.h1 = ICE_PKG_HDR_HEADR_PART1;
+	cache->header.h2 = ICE_PKG_HDR_HEADR_PART2;
+	cache->gm_seg_offset = ICE_PKG_HDR_GM_SEG_OFFSET;
+	cache->ice_seg_offset = ICE_PKG_HDR_ICE_SEG_OFFSET;
+	cache->gm_seg.hdr.seg_type = ICE_PKG_GM_SEG_TYPE;
+	cache->gm_seg.hdr.seg_format_ver.major = ICE_PKG_MAJOR_VERSION;
+	cache->gm_seg.hdr.seg_size = ICE_PKG_GM_SEG_SIZE;
+	ICE_PKG_COPY_STRING(cache->gm_seg.hdr.seg_id, "Global Metadata");
+
+	cache->gm_seg.pkg_ver.major = ICE_PKG_MAJOR_VERSION;
+	cache->gm_seg.rsvd = 1;
+	ICE_PKG_COPY_STRING(cache->gm_seg.pkg_name, "DEFAULT");
+
+	cache->ice_seg.hdr.seg_type = ICE_PKG_ICE_SEG_TYPE;
+	cache->ice_seg.hdr.seg_format_ver.major = ICE_PKG_MAJOR_VERSION;
+	cache->ice_seg.hdr.seg_size = ICE_PKG_ICE_SEG_SIZE_BASE + *size;
+	cache->ice_seg.devid_count = 0;
+	cache->ice_seg.nvm_ver.major = 0;
+	ICE_PKG_COPY_STRING(cache->ice_seg.hdr.seg_id, "CPK Configuration Data");
+
+	cache->buff_count = count;
+
+	next_buff = (uint8_t *)cache;
+	next_buff += sizeof(struct ice_package_header);
+	memcpy(next_buff, *buff, *size);
+
+	free(*buff);
+	*buff = (uint8_t *)cache;
+	*size = cache_size;
+
+	return 0;
+}
+
+int rte_pmd_ice_dump_package(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_pkg(dev, buff, size);
+}
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 35ab542e61..20079d038e 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -5930,3 +5930,8 @@ RTE_LOG_REGISTER_SUFFIX(ice_logtype_rx, rx, DEBUG);
 #ifdef RTE_ETHDEV_DEBUG_TX
 RTE_LOG_REGISTER_SUFFIX(ice_logtype_tx, tx, DEBUG);
 #endif
+
+bool is_ice_supported(struct rte_eth_dev *dev)
+{
+	return !strcmp(dev->device->driver->name, rte_ice_pmd.driver.name);
+}
diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index f9f4a1c71b..3345356d9f 100644
--- a/drivers/net/ice/ice_ethdev.h
+++ b/drivers/net/ice/ice_ethdev.h
@@ -663,6 +663,7 @@ struct ice_vsi_vlan_pvid_info {
 #define ICE_PF_TO_ETH_DEV(pf) \
 	(((struct ice_pf *)pf)->adapter->eth_dev)
 
+bool is_ice_supported(struct rte_eth_dev *dev);
 int
 ice_load_pkg(struct ice_adapter *adapter, bool use_dsn, uint64_t dsn);
 struct ice_vsi *
diff --git a/drivers/net/ice/ice_testpmd.c b/drivers/net/ice/ice_testpmd.c
new file mode 100644
index 0000000000..f1b5a6a2e6
--- /dev/null
+++ b/drivers/net/ice/ice_testpmd.c
@@ -0,0 +1,90 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation.
+ */
+#include <rte_pmd_ice.h>
+
+#include <cmdline_parse_num.h>
+#include <cmdline_parse_string.h>
+
+#include "testpmd.h"
+
+/* Fixed size for ICE ddp runtime configure */
+#define ICE_BUFF_SIZE	0x000c9000
+
+/* Dump device ddp package, only for ice PF */
+struct cmd_ddp_dump_result {
+	cmdline_fixed_string_t ddp;
+	cmdline_fixed_string_t add;
+	portid_t port_id;
+	char filepath[];
+};
+
+cmdline_parse_token_string_t cmd_ddp_dump_ddp =
+	TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, ddp, "ddp");
+cmdline_parse_token_string_t cmd_ddp_dump_dump =
+	TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, add, "dump");
+cmdline_parse_token_num_t cmd_ddp_dump_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_ddp_dump_result, port_id, RTE_UINT16);
+cmdline_parse_token_string_t cmd_ddp_dump_filepath =
+	TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, filepath, NULL);
+
+static void
+cmd_ddp_dump_parsed(void *parsed_result,
+		    __rte_unused struct cmdline *cl,
+		    __rte_unused void *data)
+{
+	struct cmd_ddp_dump_result *res = parsed_result;
+	uint8_t *buff;
+	uint32_t size;
+	int ret = -ENOTSUP;
+
+	size = ICE_BUFF_SIZE;
+	buff = (uint8_t *)malloc(ICE_BUFF_SIZE);
+	if (buff) {
+		ret = rte_pmd_ice_dump_package(res->port_id, &buff, &size);
+		switch (ret) {
+		case 0:
+			save_file(res->filepath, buff, size);
+			break;
+		case -EINVAL:
+			fprintf(stderr, "Invalid buffer size\n");
+			break;
+		case -ENOTSUP:
+			fprintf(stderr,
+				"Device doesn't support "
+				"dump DDP runtime configure.\n");
+			break;
+		default:
+			fprintf(stderr,
+				"Failed to dump DDP runtime configure,"
+				" error: (%s)\n", strerror(-ret));
+		}
+	}
+	free(buff);
+}
+
+cmdline_parse_inst_t cmd_ddp_dump = {
+	.f = cmd_ddp_dump_parsed,
+	.data = NULL,
+	.help_str = "ddp dump <port_id> <config_path>",
+	.tokens = {
+		(void *)&cmd_ddp_dump_ddp,
+		(void *)&cmd_ddp_dump_dump,
+		(void *)&cmd_ddp_dump_port_id,
+		(void *)&cmd_ddp_dump_filepath,
+		NULL,
+	},
+};
+
+static struct testpmd_driver_commands ice_cmds = {
+	.commands = {
+	{
+		&cmd_ddp_dump,
+		"ddp dump (port_id) (config_path)\n"
+		"    Dump a runtime configure on a port\n\n",
+
+	},
+	{ NULL, NULL },
+	},
+};
+TESTPMD_ADD_DRIVER_COMMANDS(ice_cmds)
diff --git a/drivers/net/ice/meson.build b/drivers/net/ice/meson.build
index de307c9e71..89f9abaaa7 100644
--- a/drivers/net/ice/meson.build
+++ b/drivers/net/ice/meson.build
@@ -13,8 +13,11 @@ sources = files(
         'ice_rxtx.c',
         'ice_switch_filter.c',
         'ice_tm.c',
+        'ice_ddp_package.c'
 )
 
+testpmd_sources = files('ice_testpmd.c')
+
 deps += ['hash', 'net', 'common_iavf']
 includes += include_directories('base', '../../common/iavf')
 
diff --git a/drivers/net/ice/rte_pmd_ice.h b/drivers/net/ice/rte_pmd_ice.h
index 9a436a140b..53c81ccf4e 100644
--- a/drivers/net/ice/rte_pmd_ice.h
+++ b/drivers/net/ice/rte_pmd_ice.h
@@ -237,6 +237,9 @@ rte_net_ice_dump_proto_xtr_metadata(struct rte_mbuf *m)
 		       data.ip_ofs);
 }
 
+__rte_experimental
+int rte_pmd_ice_dump_package(uint16_t port, uint8_t **buff, uint32_t *size);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/drivers/net/ice/version.map b/drivers/net/ice/version.map
index cc837f1c00..60a3f17393 100644
--- a/drivers/net/ice/version.map
+++ b/drivers/net/ice/version.map
@@ -13,4 +13,5 @@ EXPERIMENTAL {
 	rte_net_ice_dynflag_proto_xtr_ipv6_flow_mask;
 	rte_net_ice_dynflag_proto_xtr_tcp_mask;
 	rte_net_ice_dynflag_proto_xtr_ip_offset_mask;
+	rte_pmd_ice_dump_package;
 };
-- 
2.34.1


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

* RE: [PATCH v4] net/ice: support dump DDP runtime configure
  2022-06-09  8:40       ` Zhang, Qi Z
@ 2022-06-10  1:16         ` Zhang, Qi Z
  0 siblings, 0 replies; 24+ messages in thread
From: Zhang, Qi Z @ 2022-06-10  1:16 UTC (permalink / raw)
  To: Yang, SteveX, dev; +Cc: Yang, Qiming



> -----Original Message-----
> From: Zhang, Qi Z
> Sent: Thursday, June 9, 2022 4:41 PM
> To: Yang, SteveX <stevex.yang@intel.com>; dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>
> Subject: RE: [PATCH v4] net/ice: support dump DDP runtime configure
> 
> 
> 
> > -----Original Message-----
> > From: Yang, SteveX <stevex.yang@intel.com>
> > Sent: Thursday, June 9, 2022 3:40 PM
> > To: dev@dpdk.org
> > Cc: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> > <qi.z.zhang@intel.com>; Yang, SteveX <stevex.yang@intel.com>
> > Subject: [PATCH v4] net/ice: support dump DDP runtime configure
> >
> > Dump DDP runtime configure into a binary(package) file from ice PF port.
> >
> > Add command line:
> >     ddp dump <port_id> <config_path>
> >
> > Parameters:
> >     <port_id>       the PF Port ID
> >     <config_path>   dumped runtime configure file, if not a absolute path,
> >                     it will be dumped to testpmd running directory.
> >
> > For example:
> > testpmd> ddp dump 0 current.pkg
> >
> > If you want to dump ice VF DDP runtime configure, you need bind other
> > unused PF port of the NIC first, and then dump the PF's runtime
> > configure as target output.
> >
> > Signed-off-by: Steve Yang <stevex.yang@intel.com>
> 
> Acked-by: Qi Zhang <qi.z.zhang@intel.com>
> 
> Applied to dpdk-next-net-intel.

This has been dropped due to compile error after rebase, v5 is required.

> 
> Thanks
> Qi

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

* RE: [PATCH v5] net/ice: support dump DDP runtime configure
  2022-06-10  1:14       ` [PATCH v5] " Steve Yang
@ 2022-06-10  2:25         ` Zhang, Qi Z
  2022-06-23 13:10           ` Thomas Monjalon
  0 siblings, 1 reply; 24+ messages in thread
From: Zhang, Qi Z @ 2022-06-10  2:25 UTC (permalink / raw)
  To: Yang, SteveX, dev; +Cc: Yang, Qiming



> -----Original Message-----
> From: Yang, SteveX <stevex.yang@intel.com>
> Sent: Friday, June 10, 2022 9:14 AM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; Yang, SteveX <stevex.yang@intel.com>
> Subject: [PATCH v5] net/ice: support dump DDP runtime configure
> 
> Dump DDP runtime configure into a binary(package) file from ice PF port.
> 
> Add command line:
>     ddp dump <port_id> <config_path>
> 
> Parameters:
>     <port_id>       the PF Port ID
>     <config_path>   dumped runtime configure file, if not a absolute path,
>                     it will be dumped to testpmd running directory.
> 
> For example:
> testpmd> ddp dump 0 current.pkg
> 
> If you want to dump ice VF DDP runtime configure, you need bind other
> unused PF port of the NIC first, and then dump the PF's runtime configure as
> target output.
> 
> Signed-off-by: Steve Yang <stevex.yang@intel.com>

Acked-by: Qi Zhang <qi.z.zhang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi

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

* Re: [PATCH v5] net/ice: support dump DDP runtime configure
  2022-06-10  2:25         ` Zhang, Qi Z
@ 2022-06-23 13:10           ` Thomas Monjalon
  2022-06-23 13:13             ` Thomas Monjalon
  0 siblings, 1 reply; 24+ messages in thread
From: Thomas Monjalon @ 2022-06-23 13:10 UTC (permalink / raw)
  To: Zhang, Qi Z
  Cc: Yang, SteveX, dev, Yang, Qiming, ferruh.yigit, andrew.rybchenko,
	david.marchand

> > Signed-off-by: Steve Yang <stevex.yang@intel.com>
> 
> Acked-by: Qi Zhang <qi.z.zhang@intel.com>
> 
> Applied to dpdk-next-net-intel.

Please run devtools/check-meson.py
These are the misses:
Error: Missing trailing "," in list at drivers/net/ice/meson.build:16
and in another patch:
Error parsing drivers/net/iavf/meson.build:68, got some tabulation






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

* Re: [PATCH v5] net/ice: support dump DDP runtime configure
  2022-06-23 13:10           ` Thomas Monjalon
@ 2022-06-23 13:13             ` Thomas Monjalon
  0 siblings, 0 replies; 24+ messages in thread
From: Thomas Monjalon @ 2022-06-23 13:13 UTC (permalink / raw)
  To: Zhang, Qi Z, dev
  Cc: Yang, SteveX, dev, Yang, Qiming, ferruh.yigit, andrew.rybchenko,
	david.marchand

23/06/2022 15:10, Thomas Monjalon:
> > > Signed-off-by: Steve Yang <stevex.yang@intel.com>
> > 
> > Acked-by: Qi Zhang <qi.z.zhang@intel.com>
> > 
> > Applied to dpdk-next-net-intel.
> 
> Please run devtools/check-meson.py
> These are the misses:
> Error: Missing trailing "," in list at drivers/net/ice/meson.build:16
> and in another patch:
> Error parsing drivers/net/iavf/meson.build:68, got some tabulation

I'll fix while pulling, and at the same time,
keep the alphabetical order in the list of files in meson.build.
Please pay attention to every details.



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

end of thread, other threads:[~2022-06-23 13:14 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11  8:02 [PATCH v1 0/2] ICE ddp download tool Steve Yang
2022-05-11  8:02 ` [PATCH v1 1/2] net/ice: support dump ice ddp package Steve Yang
2022-05-18  4:22   ` Zhang, Qi Z
2022-05-24  2:49     ` Zhang, Qi Z
2022-05-18 15:21   ` Stephen Hemminger
2022-05-11  8:02 ` [PATCH v1 2/2] app/testpmd: support dump_pkg command for ice Steve Yang
2022-05-18  4:32   ` Zhang, Qi Z
2022-05-12  2:06 ` [PATCH v2 0/2] ICE ddp download tool Steve Yang
2022-05-12  2:06   ` [PATCH v2 1/2] net/ice: support dump ice ddp package Steve Yang
2022-05-12  2:06   ` [PATCH v2 2/2] app/testpmd: support dump_pkg command for ice Steve Yang
2022-05-18  6:58   ` [PATCH v3] app/testpmd: support ddp dump " Steve Yang
2022-05-18 15:24     ` Stephen Hemminger
2022-05-19  8:14       ` Andrew Rybchenko
2022-05-19 12:12     ` David Marchand
2022-05-20  3:07       ` Zhang, Qi Z
2022-05-21  1:19         ` Zhang, Qi Z
2022-05-23  7:14           ` David Marchand
2022-06-09  7:39     ` [PATCH v4] net/ice: support dump DDP runtime configure Steve Yang
2022-06-09  8:40       ` Zhang, Qi Z
2022-06-10  1:16         ` Zhang, Qi Z
2022-06-10  1:14       ` [PATCH v5] " Steve Yang
2022-06-10  2:25         ` Zhang, Qi Z
2022-06-23 13:10           ` Thomas Monjalon
2022-06-23 13:13             ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).