Skip to contentSkip to conversation

add support for idpf PMD in DPDK

PATCH In review Junfeng Guo 9 participants 376 messages Aug 3, 2022 – Nov 3, 2022 Page 1 of 5

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

cover add support for idpf PMD in DPDK

This patchset introduced the idpf (Infrastructure Data Path Function) PMD [*EXPERIMENTAL*] in DPDK for Intel Device ID of 0x1452.

Junfeng Guo (13):
net/idpf/base: introduce base code net/idpf/base: add logs and OS specific implementation net/idpf: support device initialization net/idpf: add queue operations
net/idpf: add support to get device information net/idpf: add support to get packet type net/idpf: add support to update link status net/idpf: add basic Rx/Tx datapath
net/idpf: add support for RSS
net/idpf: add mtu configuration
net/idpf: add hw statistics
net/idpf: support write back based on ITR expire net/idpf: add AVX512 data path for single queue model

 drivers/net/idpf/base/iecm_alloc.h            |   22 +
 drivers/net/idpf/base/iecm_common.c           |  359 +++
 drivers/net/idpf/base/iecm_controlq.c         |  662 ++++
 drivers/net/idpf/base/iecm_controlq.h         |  214 ++
 drivers/net/idpf/base/iecm_controlq_api.h     |  227 ++
 drivers/net/idpf/base/iecm_controlq_setup.c   |  179 ++
 drivers/net/idpf/base/iecm_devids.h           |   17 +
 drivers/net/idpf/base/iecm_lan_pf_regs.h      |  134 +
 drivers/net/idpf/base/iecm_lan_txrx.h         |  428 +++
 drivers/net/idpf/base/iecm_lan_vf_regs.h      |  114 +
 drivers/net/idpf/base/iecm_osdep.h            |  365 +++
 drivers/net/idpf/base/iecm_prototype.h        |   45 +
 drivers/net/idpf/base/iecm_type.h             |  106 +
 drivers/net/idpf/base/meson.build             |   27 +
 drivers/net/idpf/base/siov_regs.h             |   41 +
 drivers/net/idpf/base/virtchnl.h              | 2743 +++++++++++++++++
 drivers/net/idpf/base/virtchnl2.h             | 1411 +++++++++
 drivers/net/idpf/base/virtchnl2_lan_desc.h    |  603 ++++
 drivers/net/idpf/base/virtchnl_inline_ipsec.h |  567 ++++
 drivers/net/idpf/idpf_ethdev.c                | 1194 +++++++
 drivers/net/idpf/idpf_ethdev.h                |  247 ++
 drivers/net/idpf/idpf_logs.h                  |   38 +
 drivers/net/idpf/idpf_rxtx.c                  | 2348 ++++++++++++++
 drivers/net/idpf/idpf_rxtx.h                  |  228 ++
 drivers/net/idpf/idpf_rxtx_vec_avx512.c       |  917 ++++++
 drivers/net/idpf/idpf_rxtx_vec_common.h       |   85 +
 drivers/net/idpf/idpf_vchnl.c                 | 1206 ++++++++
 drivers/net/idpf/meson.build                  |   47 +
 drivers/net/idpf/version.map                  |    3 +
 drivers/net/meson.build                       |    1 +
 30 files changed, 14578 insertions(+)
 create mode 100644 drivers/net/idpf/base/iecm_alloc.h
 create mode 100644 drivers/net/idpf/base/iecm_common.c
 create mode 100644 drivers/net/idpf/base/iecm_controlq.c
 create mode 100644 drivers/net/idpf/base/iecm_controlq.h
 create mode 100644 drivers/net/idpf/base/iecm_controlq_api.h
 create mode 100644 drivers/net/idpf/base/iecm_controlq_setup.c
 create mode 100644 drivers/net/idpf/base/iecm_devids.h
 create mode 100644 drivers/net/idpf/base/iecm_lan_pf_regs.h
 create mode 100644 drivers/net/idpf/base/iecm_lan_txrx.h
 create mode 100644 drivers/net/idpf/base/iecm_lan_vf_regs.h
 create mode 100644 drivers/net/idpf/base/iecm_osdep.h
 create mode 100644 drivers/net/idpf/base/iecm_prototype.h
 create mode 100644 drivers/net/idpf/base/iecm_type.h
 create mode 100644 drivers/net/idpf/base/meson.build
 create mode 100644 drivers/net/idpf/base/siov_regs.h
 create mode 100644 drivers/net/idpf/base/virtchnl.h
 create mode 100644 drivers/net/idpf/base/virtchnl2.h
 create mode 100644 drivers/net/idpf/base/virtchnl2_lan_desc.h
 create mode 100644 drivers/net/idpf/base/virtchnl_inline_ipsec.h
 create mode 100644 drivers/net/idpf/idpf_ethdev.c
 create mode 100644 drivers/net/idpf/idpf_ethdev.h
 create mode 100644 drivers/net/idpf/idpf_logs.h
 create mode 100644 drivers/net/idpf/idpf_rxtx.c
 create mode 100644 drivers/net/idpf/idpf_rxtx.h
 create mode 100644 drivers/net/idpf/idpf_rxtx_vec_avx512.c
 create mode 100644 drivers/net/idpf/idpf_rxtx_vec_common.h
 create mode 100644 drivers/net/idpf/idpf_vchnl.c
 create mode 100644 drivers/net/idpf/meson.build
 create mode 100644 drivers/net/idpf/version.map
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/13 net/idpf/base: introduce base code

Introduce base code for IDPF (Infrastructure Data Path Function) PMD.

---
 drivers/net/idpf/base/iecm_alloc.h            |   22 +
 drivers/net/idpf/base/iecm_common.c           |  359 +++
 drivers/net/idpf/base/iecm_controlq.c         |  662 ++++
 drivers/net/idpf/base/iecm_controlq.h         |  214 ++
 drivers/net/idpf/base/iecm_controlq_api.h     |  227 ++
 drivers/net/idpf/base/iecm_controlq_setup.c   |  179 ++
 drivers/net/idpf/base/iecm_devids.h           |   17 +
 drivers/net/idpf/base/iecm_lan_pf_regs.h      |  134 +
 drivers/net/idpf/base/iecm_lan_txrx.h         |  428 +++
 drivers/net/idpf/base/iecm_lan_vf_regs.h      |  114 +
 drivers/net/idpf/base/iecm_prototype.h        |   45 +
 drivers/net/idpf/base/iecm_type.h             |  106 +
 drivers/net/idpf/base/meson.build             |   27 +
 drivers/net/idpf/base/siov_regs.h             |   41 +
 drivers/net/idpf/base/virtchnl.h              | 2743 +++++++++++++++++
 drivers/net/idpf/base/virtchnl2.h             | 1411 +++++++++
 drivers/net/idpf/base/virtchnl2_lan_desc.h    |  603 ++++
 drivers/net/idpf/base/virtchnl_inline_ipsec.h |  567 ++++
 18 files changed, 7899 insertions(+)
 create mode 100644 drivers/net/idpf/base/iecm_alloc.h
 create mode 100644 drivers/net/idpf/base/iecm_common.c
 create mode 100644 drivers/net/idpf/base/iecm_controlq.c
 create mode 100644 drivers/net/idpf/base/iecm_controlq.h
 create mode 100644 drivers/net/idpf/base/iecm_controlq_api.h
 create mode 100644 drivers/net/idpf/base/iecm_controlq_setup.c
 create mode 100644 drivers/net/idpf/base/iecm_devids.h
 create mode 100644 drivers/net/idpf/base/iecm_lan_pf_regs.h
 create mode 100644 drivers/net/idpf/base/iecm_lan_txrx.h
 create mode 100644 drivers/net/idpf/base/iecm_lan_vf_regs.h
 create mode 100644 drivers/net/idpf/base/iecm_prototype.h
 create mode 100644 drivers/net/idpf/base/iecm_type.h
 create mode 100644 drivers/net/idpf/base/meson.build
 create mode 100644 drivers/net/idpf/base/siov_regs.h
 create mode 100644 drivers/net/idpf/base/virtchnl.h
 create mode 100644 drivers/net/idpf/base/virtchnl2.h
 create mode 100644 drivers/net/idpf/base/virtchnl2_lan_desc.h
 create mode 100644 drivers/net/idpf/base/virtchnl_inline_ipsec.h
drivers/net/idpf/base/iecm_alloc.h new file +22 -0
new file mode 100644
index 0000000000..7ea219c784
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2022 Intel Corporation
+ */
+
+#ifndef _IECM_ALLOC_H_
+#define _IECM_ALLOC_H_
+
+/* Memory types */
+enum iecm_memset_type {
+	IECM_NONDMA_MEM = 0,
+	IECM_DMA_MEM
+};
+
+/* Memcpy types */
+enum iecm_memcpy_type {
+	IECM_NONDMA_TO_NONDMA = 0,
+	IECM_NONDMA_TO_DMA,
+	IECM_DMA_TO_DMA,
+	IECM_DMA_TO_NONDMA
+};
+
+#endif /* _IECM_ALLOC_H_ */
drivers/net/idpf/base/iecm_common.c new file +359 -0

359 lines not on this page · raw message

drivers/net/idpf/base/iecm_controlq.c new file +662 -0

662 lines not on this page · raw message

drivers/net/idpf/base/iecm_controlq.h new file +214 -0

214 lines not on this page · raw message

drivers/net/idpf/base/iecm_controlq_api.h new file +227 -0

227 lines not on this page · raw message

drivers/net/idpf/base/iecm_controlq_setup.c new file +179 -0

179 lines not on this page · raw message

drivers/net/idpf/base/iecm_devids.h new file +17 -0
new file mode 100644
index 0000000000..839214cb40
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2022 Intel Corporation
+ */
+
+#ifndef _IECM_DEVIDS_H_
+#define _IECM_DEVIDS_H_
+
+/* Vendor ID */
+#define IECM_INTEL_VENDOR_ID		0x8086
+
+/* Device IDs */
+#define IECM_DEV_ID_PF			0x1452
+
+
+
+
+#endif /* _IECM_DEVIDS_H_ */
drivers/net/idpf/base/iecm_lan_pf_regs.h new file +134 -0

134 lines not on this page · raw message

drivers/net/idpf/base/iecm_lan_txrx.h new file +428 -0

428 lines not on this page · raw message

drivers/net/idpf/base/iecm_lan_vf_regs.h new file +114 -0

114 lines not on this page · raw message

drivers/net/idpf/base/iecm_prototype.h new file +45 -0

45 lines not on this page · raw message

drivers/net/idpf/base/iecm_type.h new file +106 -0

106 lines not on this page · raw message

drivers/net/idpf/base/meson.build new file +27 -0
new file mode 100644
index 0000000000..1ad9a87d9d
@@ -0,0 +1,27 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+sources = [
+	'iecm_common.c',
+	'iecm_controlq.c',
+	'iecm_controlq_setup.c',
+]
+
+error_cflags = ['-Wno-unused-value',
+		'-Wno-unused-but-set-variable',
+		'-Wno-unused-variable',
+		'-Wno-unused-parameter',
+]
+
+c_args = cflags
+
+foreach flag: error_cflags
+	if cc.has_argument(flag)
+		c_args += flag
+	endif
+endforeach
+
+base_lib = static_library('idpf_base', sources,
+	 dependencies: static_rte_eal,
+	 c_args: c_args)
+base_objs = base_lib.extract_all_objects()
\ No newline at end of file
drivers/net/idpf/base/siov_regs.h new file +41 -0

41 lines not on this page · raw message

drivers/net/idpf/base/virtchnl.h new file +2743 -0

424 lines not on this page · raw message

drivers/net/idpf/base/virtchnl2.h new file +1411 -0

1,411 lines not on this page · raw message

drivers/net/idpf/base/virtchnl2_lan_desc.h new file +603 -0

603 lines not on this page · raw message

drivers/net/idpf/base/virtchnl_inline_ipsec.h new file +567 -0

567 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.25.1

Part of the diff is not shown here. View the raw message.

#2 lore raw

PATCH 2/13 net/idpf/base: add logs and OS specific implementation

In reply to Junfeng Guo

Add PMD logs.
Add some MACRO definations and small functions which are specific for DPDK.

---
 drivers/net/idpf/base/iecm_osdep.h | 365 +++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_logs.h       |  38 +++
 2 files changed, 403 insertions(+)
 create mode 100644 drivers/net/idpf/base/iecm_osdep.h
 create mode 100644 drivers/net/idpf/idpf_logs.h
drivers/net/idpf/base/iecm_osdep.h new file +365 -0
new file mode 100644
index 0000000000..60e21fbc1b
@@ -0,0 +1,365 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2022 Intel Corporation
+ */
+
+#ifndef _IECM_OSDEP_H_
+#define _IECM_OSDEP_H_
+
+#include <string.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <inttypes.h>
+#include <sys/queue.h>
+#include <stdbool.h>
+
+#include <rte_common.h>
+#include <rte_memcpy.h>
+#include <rte_malloc.h>
+#include <rte_memzone.h>
+#include <rte_byteorder.h>
+#include <rte_cycles.h>
+#include <rte_spinlock.h>
+#include <rte_log.h>
+#include <rte_random.h>
+#include <rte_io.h>
+
+#include "../idpf_logs.h"
+
+#define INLINE inline
+#define STATIC static
+
+typedef uint8_t		u8;
+typedef int8_t		s8;
+typedef uint16_t	u16;
+typedef int16_t		s16;
+typedef uint32_t	u32;
+typedef int32_t		s32;
+typedef uint64_t	u64;
+typedef uint64_t	s64;
+
+typedef enum iecm_status iecm_status;
+typedef struct iecm_lock iecm_lock;
+
+#define __iomem
+#define hw_dbg(hw, S, A...)	do {} while (0)
+#define upper_32_bits(n)	((u32)(((n) >> 16) >> 16))
+#define lower_32_bits(n)	((u32)(n))
+#define low_16_bits(x)		((x) & 0xFFFF)
+#define high_16_bits(x)		(((x) & 0xFFFF0000) >> 16)
+
+#ifndef ETH_ADDR_LEN
+#define ETH_ADDR_LEN		6
+#endif
+
+#ifndef __le16
+#define __le16	uint16_t
+#endif
+#ifndef __le32
+#define __le32	uint32_t
+#endif
+#ifndef __le64
+#define __le64	uint64_t
+#endif
+#ifndef __be16
+#define __be16	uint16_t
+#endif
+#ifndef __be32
+#define __be32	uint32_t
+#endif
+#ifndef __be64
+#define __be64	uint64_t
+#endif
+
+#ifndef __always_unused
+#define __always_unused  __attribute__((__unused__))
+#endif
+#ifndef __maybe_unused
+#define __maybe_unused  __attribute__((__unused__))
+#endif
+#ifndef __packed
+#define __packed  __attribute__((packed))
+#endif
+
+#ifndef BIT_ULL
+#define BIT_ULL(a) (1ULL << (a))
+#endif
+
+#ifndef BIT
+#define BIT(a) (1ULL << (a))
+#endif
+
+#define FALSE	0
+#define TRUE	1
+#define false	0
+#define true	1
+
+#define min(a, b) RTE_MIN(a, b)
+#define max(a, b) RTE_MAX(a, b)
+
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
+#define FIELD_SIZEOF(t, f) (sizeof(((t *)0)->(f)))
+#define MAKEMASK(m, s) ((m) << (s))
+
+#define DEBUGOUT(S) PMD_DRV_LOG_RAW(DEBUG, S)
+#define DEBUGOUT2(S, A...) PMD_DRV_LOG_RAW(DEBUG, S, ##A)
+#define DEBUGFUNC(F) PMD_DRV_LOG_RAW(DEBUG, F)
+
+#define iecm_debug(h, m, s, ...)					\
+	do {								\
+		if (((m) & (h)->debug_mask))				\
+			PMD_DRV_LOG_RAW(DEBUG, "iecm %02x.%x " s,       \
+					(h)->bus.device, (h)->bus.func,	\
+					##__VA_ARGS__);			\
+	} while (0)
+
+#define iecm_info(hw, fmt, args...) iecm_debug(hw, IECM_DBG_ALL, fmt, ##args)
+#define iecm_warn(hw, fmt, args...) iecm_debug(hw, IECM_DBG_ALL, fmt, ##args)
+#define iecm_debug_array(hw, type, rowsize, groupsize, buf, len)	\
+	do {								\
+		struct iecm_hw *hw_l = hw;				\
+		u16 len_l = len;					\
+		u8 *buf_l = buf;					\
+		int i;							\
+		for (i = 0; i < len_l; i += 8)				\
+			iecm_debug(hw_l, type,				\
+				   "0x%04X  0x%016"PRIx64"\n",		\
+				   i, *((u64 *)((buf_l) + i)));		\
+	} while (0)
+#define iecm_snprintf snprintf
+#ifndef SNPRINTF
+#define SNPRINTF iecm_snprintf
+#endif
+
+#define IECM_PCI_REG(reg)     rte_read32(reg)
+#define IECM_PCI_REG_ADDR(a, reg)				\
+	((volatile uint32_t *)((char *)(a)->hw_addr + (reg)))
+#define IECM_PCI_REG64(reg)     rte_read64(reg)
+#define IECM_PCI_REG_ADDR64(a, reg)				\
+	((volatile uint64_t *)((char *)(a)->hw_addr + (reg)))
+
+#define iecm_wmb() rte_io_wmb()
+#define iecm_rmb() rte_io_rmb()
+#define iecm_mb() rte_io_mb()
+
+static inline uint32_t iecm_read_addr(volatile void *addr)
+{
+	return rte_le_to_cpu_32(IECM_PCI_REG(addr));
+}
+
+static inline uint64_t iecm_read_addr64(volatile void *addr)
+{
+	return rte_le_to_cpu_64(IECM_PCI_REG64(addr));
+}
+
+#define IECM_PCI_REG_WRITE(reg, value)			\
+	rte_write32((rte_cpu_to_le_32(value)), reg)
+
+#define IECM_PCI_REG_WRITE64(reg, value)		\
+	rte_write64((rte_cpu_to_le_64(value)), reg)
+
+#define IECM_READ_REG(hw, reg) iecm_read_addr(IECM_PCI_REG_ADDR((hw), (reg)))
+#define IECM_WRITE_REG(hw, reg, value)					\
+	IECM_PCI_REG_WRITE(IECM_PCI_REG_ADDR((hw), (reg)), (value))
+
+#define rd32(a, reg) iecm_read_addr(IECM_PCI_REG_ADDR((a), (reg)))
+#define wr32(a, reg, value)						\
+	IECM_PCI_REG_WRITE(IECM_PCI_REG_ADDR((a), (reg)), (value))
+#define div64_long(n, d) ((n) / (d))
+#define rd64(a, reg) iecm_read_addr64(IECM_PCI_REG_ADDR64((a), (reg)))
+
+#define BITS_PER_BYTE       8
+
+/* memory allocation tracking */
+struct iecm_dma_mem {
+	void *va;
+	u64 pa;
+	u32 size;
+	const void *zone;
+} __attribute__((packed));
+
+struct iecm_virt_mem {
+	void *va;
+	u32 size;
+} __attribute__((packed));
+
+#define iecm_malloc(h, s)	rte_zmalloc(NULL, s, 0)
+#define iecm_calloc(h, c, s)	rte_zmalloc(NULL, (c) * (s), 0)
+#define iecm_free(h, m)		rte_free(m)
+
+#define iecm_memset(a, b, c, d)	memset((a), (b), (c))
+#define iecm_memcpy(a, b, c, d)	rte_memcpy((a), (b), (c))
+#define iecm_memdup(a, b, c, d)	rte_memcpy(iecm_malloc(a, c), b, c)
+
+#define CPU_TO_BE16(o) rte_cpu_to_be_16(o)
+#define CPU_TO_BE32(o) rte_cpu_to_be_32(o)
+#define CPU_TO_BE64(o) rte_cpu_to_be_64(o)
+#define CPU_TO_LE16(o) rte_cpu_to_le_16(o)
+#define CPU_TO_LE32(s) rte_cpu_to_le_32(s)
+#define CPU_TO_LE64(h) rte_cpu_to_le_64(h)
+#define LE16_TO_CPU(a) rte_le_to_cpu_16(a)
+#define LE32_TO_CPU(c) rte_le_to_cpu_32(c)
+#define LE64_TO_CPU(k) rte_le_to_cpu_64(k)
+
+#define NTOHS(a) rte_be_to_cpu_16(a)
+#define NTOHL(a) rte_be_to_cpu_32(a)
+#define HTONS(a) rte_cpu_to_be_16(a)
+#define HTONL(a) rte_cpu_to_be_32(a)
+
+/* SW spinlock */
+struct iecm_lock {
+	rte_spinlock_t spinlock;
+};
+
+static inline void
+iecm_init_lock(struct iecm_lock *sp)
+{
+	rte_spinlock_init(&sp->spinlock);
+}
+
+static inline void
+iecm_acquire_lock(struct iecm_lock *sp)
+{
+	rte_spinlock_lock(&sp->spinlock);
+}
+
+static inline void
+iecm_release_lock(struct iecm_lock *sp)
+{
+	rte_spinlock_unlock(&sp->spinlock);
+}
+
+static inline void
+iecm_destroy_lock(__attribute__((unused)) struct iecm_lock *sp)
+{
+}
+
+struct iecm_hw;
+
+static inline void *
+iecm_alloc_dma_mem(__attribute__((unused)) struct iecm_hw *hw,
+		   struct iecm_dma_mem *mem, u64 size)
+{
+	const struct rte_memzone *mz = NULL;
+	char z_name[RTE_MEMZONE_NAMESIZE];
+
+	if (!mem)
+		return NULL;
+
+	snprintf(z_name, sizeof(z_name), "iecm_dma_%"PRIu64, rte_rand());
+	mz = rte_memzone_reserve_aligned(z_name, size, SOCKET_ID_ANY,
+					 RTE_MEMZONE_IOVA_CONTIG, RTE_PGSIZE_4K);
+	if (!mz)
+		return NULL;
+
+	mem->size = size;
+	mem->va = mz->addr;
+	mem->pa = mz->iova;
+	mem->zone = (const void *)mz;
+	memset(mem->va, 0, size);
+
+	return mem->va;
+}
+
+static inline void
+iecm_free_dma_mem(__attribute__((unused)) struct iecm_hw *hw,
+		  struct iecm_dma_mem *mem)
+{
+	rte_memzone_free((const struct rte_memzone *)mem->zone);
+	mem->size = 0;
+	mem->va = NULL;
+	mem->pa = 0;
+}
+
+static inline u8
+iecm_hweight8(u32 num)
+{
+	u8 bits = 0;
+	u32 i;
+
+	for (i = 0; i < 8; i++) {
+		bits += (u8)(num & 0x1);
+		num >>= 1;
+	}
+
+	return bits;
+}
+
+static inline u8
+iecm_hweight32(u32 num)
+{
+	u8 bits = 0;
+	u32 i;
+
+	for (i = 0; i < 32; i++) {
+		bits += (u8)(num & 0x1);
+		num >>= 1;
+	}
+
+	return bits;
+}
+
+#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
+#define DELAY(x) rte_delay_us(x)
+#define iecm_usec_delay(x) rte_delay_us(x)
+#define iecm_msec_delay(x, y) rte_delay_us(1000 * (x))
+#define udelay(x) DELAY(x)
+#define msleep(x) DELAY(1000 * (x))
+#define usleep_range(min, max) msleep(DIV_ROUND_UP(min, 1000))
+
+#ifndef IECM_DBG_TRACE
+#define IECM_DBG_TRACE	  BIT_ULL(0)
+#endif
+
+#ifndef DIVIDE_AND_ROUND_UP
+#define DIVIDE_AND_ROUND_UP(a, b) (((a) + (b) - 1) / (b))
+#endif
+
+#ifndef IECM_INTEL_VENDOR_ID
+#define IECM_INTEL_VENDOR_ID	    0x8086
+#endif
+
+#ifndef IS_UNICAST_ETHER_ADDR
+#define IS_UNICAST_ETHER_ADDR(addr)			\
+	((bool)((((u8 *)(addr))[0] % ((u8)0x2)) == 0))
+#endif
+
+#ifndef IS_MULTICAST_ETHER_ADDR
+#define IS_MULTICAST_ETHER_ADDR(addr)			\
+	((bool)((((u8 *)(addr))[0] % ((u8)0x2)) == 1))
+#endif
+
+#ifndef IS_BROADCAST_ETHER_ADDR
+/* Check whether an address is broadcast. */
+#define IS_BROADCAST_ETHER_ADDR(addr)			\
+	((bool)((((u16 *)(addr))[0] == ((u16)0xffff))))
+#endif
+
+#ifndef IS_ZERO_ETHER_ADDR
+#define IS_ZERO_ETHER_ADDR(addr)				\
+	(((bool)((((u16 *)(addr))[0] == ((u16)0x0)))) &&	\
+	 ((bool)((((u16 *)(addr))[1] == ((u16)0x0)))) &&	\
+	 ((bool)((((u16 *)(addr))[2] == ((u16)0x0)))))
+#endif
+
+#ifndef LIST_HEAD_TYPE
+#define LIST_HEAD_TYPE(list_name, type) LIST_HEAD(list_name, type)
+#endif
+
+#ifndef LIST_ENTRY_TYPE
+#define LIST_ENTRY_TYPE(type)	   LIST_ENTRY(type)
+#endif
+
+#ifndef LIST_FOR_EACH_ENTRY_SAFE
+#define LIST_FOR_EACH_ENTRY_SAFE(pos, temp, head, entry_type, list)	\
+	LIST_FOREACH(pos, head, list)
+
+#endif
+
+#ifndef LIST_FOR_EACH_ENTRY
+#define LIST_FOR_EACH_ENTRY(pos, head, entry_type, list)		\
+	LIST_FOREACH(pos, head, list)
+
+#endif
+
+#endif /* _IECM_OSDEP_H_ */
drivers/net/idpf/idpf_logs.h new file +38 -0
new file mode 100644
index 0000000000..906aae8463
@@ -0,0 +1,38 @@
+#ifndef _IDPF_LOGS_H_
+#define _IDPF_LOGS_H_
+
+#include <rte_log.h>
+
+extern int idpf_logtype_init;
+extern int idpf_logtype_driver;
+
+#define PMD_INIT_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, idpf_logtype_init, \
+		"%s(): " fmt "\n", __func__, ##args)
+
+#define PMD_INIT_FUNC_TRACE() PMD_DRV_LOG(DEBUG, " >>")
+
+#define PMD_DRV_LOG_RAW(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, idpf_logtype_driver, \
+		"%s(): " fmt "\n", __func__, ##args)
+
+#define PMD_DRV_LOG(level, fmt, args...) \
+	PMD_DRV_LOG_RAW(level, fmt "\n", ## args)
+
+#define PMD_DRV_FUNC_TRACE() PMD_DRV_LOG(DEBUG, " >>")
+
+#ifdef RTE_LIBRTE_IDPF_DEBUG_RX
+#define PMD_RX_LOG(level, fmt, args...) \
+	RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
+#else
+#define PMD_RX_LOG(level, fmt, args...) do { } while (0)
+#endif
+
+#ifdef RTE_LIBRTE_IDPF_DEBUG_TX
+#define PMD_TX_LOG(level, fmt, args...) \
+	RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
+#else
+#define PMD_TX_LOG(level, fmt, args...) do { } while (0)
+#endif
+
+#endif /* _IDPF_LOGS_H_ */
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/13 net/idpf: support device initialization

In reply to Junfeng Guo

Support device init and the following dev ops:
- dev_configure
- dev_start
- dev_stop
- dev_close

---
 drivers/net/idpf/idpf_ethdev.c | 651 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h | 205 +++++++++++
 drivers/net/idpf/idpf_vchnl.c  | 476 ++++++++++++++++++++++++
 drivers/net/idpf/meson.build   |  18 +
 drivers/net/idpf/version.map   |   3 +
 drivers/net/meson.build        |   1 +
 6 files changed, 1354 insertions(+)
 create mode 100644 drivers/net/idpf/idpf_ethdev.c
 create mode 100644 drivers/net/idpf/idpf_ethdev.h
 create mode 100644 drivers/net/idpf/idpf_vchnl.c
 create mode 100644 drivers/net/idpf/meson.build
 create mode 100644 drivers/net/idpf/version.map
drivers/net/idpf/idpf_ethdev.c new file +651 -0
new file mode 100644
index 0000000000..87c68226dd
@@ -0,0 +1,651 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#include <rte_atomic.h>
+#include <rte_eal.h>
+#include <rte_ether.h>
+#include <ethdev_driver.h>
+#include <ethdev_pci.h>
+#include <rte_malloc.h>
+#include <rte_memzone.h>
+#include <rte_dev.h>
+
+#include "idpf_ethdev.h"
+
+#define REPRESENTOR		"representor"
+
+struct idpf_adapter *adapter;
+uint16_t used_vecs_num;
+
+static const char * const idpf_valid_args[] = {
+	REPRESENTOR,
+	NULL
+};
+
+static int idpf_dev_configure(struct rte_eth_dev *dev);
+static int idpf_dev_start(struct rte_eth_dev *dev);
+static int idpf_dev_stop(struct rte_eth_dev *dev);
+static int idpf_dev_close(struct rte_eth_dev *dev);
+
+static const struct eth_dev_ops idpf_eth_dev_ops = {
+	.dev_configure			= idpf_dev_configure,
+	.dev_start			= idpf_dev_start,
+	.dev_stop			= idpf_dev_stop,
+	.dev_close			= idpf_dev_close,
+};
+
+static int
+idpf_init_vport_req_info(struct rte_eth_dev *dev)
+{
+	struct virtchnl2_create_vport *vport_info;
+	uint16_t idx = adapter->next_vport_idx;
+
+	if (!adapter->vport_req_info[idx]) {
+		adapter->vport_req_info[idx] = rte_zmalloc(NULL,
+				    sizeof(struct virtchnl2_create_vport), 0);
+		if (!adapter->vport_req_info[idx]) {
+			PMD_INIT_LOG(ERR, "Failed to allocate vport_req_info");
+			return -1;
+		}
+	}
+
+	vport_info =
+		(struct virtchnl2_create_vport *)adapter->vport_req_info[idx];
+
+	vport_info->vport_type = rte_cpu_to_le_16(VIRTCHNL2_VPORT_TYPE_DEFAULT);
+
+	return 0;
+}
+
+static uint16_t
+idpf_get_next_vport_idx(struct idpf_vport **vports, uint16_t max_vport_nb,
+			uint16_t cur_vport_idx)
+{
+	uint16_t vport_idx;
+	uint16_t i;
+
+	if (cur_vport_idx < max_vport_nb && !vports[cur_vport_idx + 1]) {
+		vport_idx = cur_vport_idx + 1;
+		return vport_idx;
+	}
+
+	for (i = 0; i < max_vport_nb; i++) {
+		if (!vports[i])
+			break;
+	}
+
+	if (i == max_vport_nb)
+		vport_idx = IDPF_INVALID_VPORT_IDX;
+	else
+		vport_idx = i;
+
+	return vport_idx;
+}
+
+#ifndef IDPF_RSS_KEY_LEN
+#define IDPF_RSS_KEY_LEN 52
+#endif
+
+static int
+idpf_init_vport(struct rte_eth_dev *dev)
+{
+	uint16_t idx = adapter->next_vport_idx;
+	struct virtchnl2_create_vport *vport_info =
+		(struct virtchnl2_create_vport *)adapter->vport_recv_info[idx];
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;
+	int i;
+
+	vport->adapter = adapter;
+	vport->vport_id = vport_info->vport_id;
+	vport->txq_model = vport_info->txq_model;
+	vport->rxq_model = vport_info->rxq_model;
+	vport->num_tx_q = vport_info->num_tx_q;
+	vport->num_tx_complq = vport_info->num_tx_complq;
+	vport->num_rx_q = vport_info->num_rx_q;
+	vport->num_rx_bufq = vport_info->num_rx_bufq;
+	vport->max_mtu = vport_info->max_mtu;
+	rte_memcpy(vport->default_mac_addr,
+		   vport_info->default_mac_addr, ETH_ALEN);
+	vport->rss_algorithm = vport_info->rss_algorithm;
+	vport->rss_key_size = RTE_MIN(IDPF_RSS_KEY_LEN,
+				     vport_info->rss_key_size);
+	vport->rss_lut_size = vport_info->rss_lut_size;
+	vport->sw_idx = idx;
+
+	for (i = 0; i < vport_info->chunks.num_chunks; i++) {
+		if (vport_info->chunks.chunks[i].type ==
+		    VIRTCHNL2_QUEUE_TYPE_TX) {
+			vport->chunks_info.tx_start_qid =
+				vport_info->chunks.chunks[i].start_queue_id;
+			vport->chunks_info.tx_qtail_start =
+				vport_info->chunks.chunks[i].qtail_reg_start;
+			vport->chunks_info.tx_qtail_spacing =
+				vport_info->chunks.chunks[i].qtail_reg_spacing;
+		} else if (vport_info->chunks.chunks[i].type ==
+			 VIRTCHNL2_QUEUE_TYPE_RX) {
+			vport->chunks_info.rx_start_qid =
+				vport_info->chunks.chunks[i].start_queue_id;
+			vport->chunks_info.rx_qtail_start =
+				vport_info->chunks.chunks[i].qtail_reg_start;
+			vport->chunks_info.rx_qtail_spacing =
+				vport_info->chunks.chunks[i].qtail_reg_spacing;
+		} else if (vport_info->chunks.chunks[i].type ==
+			 VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION) {
+			vport->chunks_info.tx_compl_start_qid =
+				vport_info->chunks.chunks[i].start_queue_id;
+			vport->chunks_info.tx_compl_qtail_start =
+				vport_info->chunks.chunks[i].qtail_reg_start;
+			vport->chunks_info.tx_compl_qtail_spacing =
+				vport_info->chunks.chunks[i].qtail_reg_spacing;
+		} else if (vport_info->chunks.chunks[i].type ==
+			 VIRTCHNL2_QUEUE_TYPE_RX_BUFFER) {
+			vport->chunks_info.rx_buf_start_qid =
+				vport_info->chunks.chunks[i].start_queue_id;
+			vport->chunks_info.rx_buf_qtail_start =
+				vport_info->chunks.chunks[i].qtail_reg_start;
+			vport->chunks_info.rx_buf_qtail_spacing =
+				vport_info->chunks.chunks[i].qtail_reg_spacing;
+		}
+	}
+
+	adapter->vports[idx] = vport;
+	adapter->cur_vport_nb++;
+	adapter->next_vport_idx = idpf_get_next_vport_idx(adapter->vports,
+						  adapter->max_vport_nb, idx);
+	if (adapter->next_vport_idx == IDPF_INVALID_VPORT_IDX) {
+		PMD_INIT_LOG(ERR, "Failed to get next vport id");
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+idpf_dev_configure(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;
+	int ret = 0;
+
+	ret = idpf_init_vport_req_info(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to init vport req_info.");
+		return ret;
+	}
+
+	ret = idpf_create_vport(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to create vport.");
+		return ret;
+	}
+
+	ret = idpf_init_vport(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to init vports.");
+		return ret;
+	}
+
+	rte_ether_addr_copy((struct rte_ether_addr *)vport->default_mac_addr,
+			    &dev->data->mac_addrs[0]);
+
+	return ret;
+}
+
+static int
+idpf_dev_start(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;
+
+	PMD_INIT_FUNC_TRACE();
+
+	vport->stopped = 0;
+
+	if (idpf_ena_dis_vport(vport, true)) {
+		PMD_DRV_LOG(ERR, "Failed to enable vport");
+		goto err_vport;
+	}
+
+	return 0;
+
+err_vport:
+	return -1;
+}
+
+static int
+idpf_dev_stop(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (vport->stopped == 1)
+		return 0;
+
+	if (idpf_ena_dis_vport(vport, false))
+		PMD_DRV_LOG(ERR, "disable vport failed");
+
+	vport->stopped = 1;
+	dev->data->dev_started = 0;
+
+	return 0;
+}
+
+static int
+idpf_dev_close(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	idpf_dev_stop(dev);
+	idpf_destroy_vport(vport);
+
+	return 0;
+}
+
+static int idpf_parse_devargs(struct rte_eth_dev *dev)
+{
+	struct rte_devargs *devargs = dev->device->devargs;
+	struct rte_kvargs *kvlist;
+	int ret = 0;
+
+	if (!devargs)
+		return 0;
+
+	kvlist = rte_kvargs_parse(devargs->args, idpf_valid_args);
+	if (!kvlist) {
+		PMD_INIT_LOG(ERR, "invalid kvargs key");
+		return -EINVAL;
+	}
+
+	rte_kvargs_free(kvlist);
+	return ret;
+}
+
+static void
+idpf_reset_pf(struct iecm_hw *hw)
+{
+	uint32_t reg;
+
+	reg = IECM_READ_REG(hw, PFGEN_CTRL);
+	IECM_WRITE_REG(hw, PFGEN_CTRL, (reg | PFGEN_CTRL_PFSWR));
+}
+
+#define IDPF_RESET_WAIT_CNT 100
+static int
+idpf_check_pf_reset_done(struct iecm_hw *hw)
+{
+	uint32_t reg;
+	int i;
+
+	for (i = 0; i < IDPF_RESET_WAIT_CNT; i++) {
+		reg = IECM_READ_REG(hw, PFGEN_RSTAT);
+		if (reg != 0xFFFFFFFF && (reg & PFGEN_RSTAT_PFR_STATE_M))
+			return 0;
+		rte_delay_ms(1000);
+	}
+
+	PMD_INIT_LOG(ERR, "IDPF reset timeout");
+	return -EBUSY;
+}
+
+#define CTLQ_NUM 2
+static int
+idpf_init_mbx(struct iecm_hw *hw)
+{
+	struct iecm_ctlq_create_info ctlq_info[CTLQ_NUM] = {
+		{
+			.type = IECM_CTLQ_TYPE_MAILBOX_TX,
+			.id = IDPF_CTLQ_ID,
+			.len = IDPF_CTLQ_LEN,
+			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+			.reg = {
+				.head = PF_FW_ATQH,
+				.tail = PF_FW_ATQT,
+				.len = PF_FW_ATQLEN,
+				.bah = PF_FW_ATQBAH,
+				.bal = PF_FW_ATQBAL,
+				.len_mask = PF_FW_ATQLEN_ATQLEN_M,
+				.len_ena_mask = PF_FW_ATQLEN_ATQENABLE_M,
+				.head_mask = PF_FW_ATQH_ATQH_M,
+			}
+		},
+		{
+			.type = IECM_CTLQ_TYPE_MAILBOX_RX,
+			.id = IDPF_CTLQ_ID,
+			.len = IDPF_CTLQ_LEN,
+			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+			.reg = {
+				.head = PF_FW_ARQH,
+				.tail = PF_FW_ARQT,
+				.len = PF_FW_ARQLEN,
+				.bah = PF_FW_ARQBAH,
+				.bal = PF_FW_ARQBAL,
+				.len_mask = PF_FW_ARQLEN_ARQLEN_M,
+				.len_ena_mask = PF_FW_ARQLEN_ARQENABLE_M,
+				.head_mask = PF_FW_ARQH_ARQH_M,
+			}
+		}
+	};
+	struct iecm_ctlq_info *ctlq;
+	int ret = 0;
+
+	ret = iecm_ctlq_init(hw, CTLQ_NUM, ctlq_info);
+	if (ret)
+		return ret;
+
+	LIST_FOR_EACH_ENTRY_SAFE(ctlq, NULL, &hw->cq_list_head,
+				 struct iecm_ctlq_info, cq_list) {
+		if (ctlq->q_id == IDPF_CTLQ_ID && ctlq->cq_type == IECM_CTLQ_TYPE_MAILBOX_TX)
+			hw->asq = ctlq;
+		if (ctlq->q_id == IDPF_CTLQ_ID && ctlq->cq_type == IECM_CTLQ_TYPE_MAILBOX_RX)
+			hw->arq = ctlq;
+	}
+
+	if (!hw->asq || !hw->arq) {
+		iecm_ctlq_deinit(hw);
+		ret = -ENOENT;
+	}
+
+	return ret;
+}
+
+static int
+idpf_adapter_init(struct rte_eth_dev *dev)
+{
+	struct iecm_hw *hw = &adapter->hw;
+	struct rte_pci_device *pci_dev = IDPF_DEV_TO_PCI(dev);
+	int ret = 0;
+
+	if (adapter->initialized)
+		return 0;
+
+	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
+	hw->hw_addr_len = pci_dev->mem_resource[0].len;
+	hw->back = adapter;
+	hw->vendor_id = pci_dev->id.vendor_id;
+	hw->device_id = pci_dev->id.device_id;
+	hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
+
+	ret = idpf_parse_devargs(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to parse devargs");
+		goto err;
+	}
+
+	idpf_reset_pf(hw);
+	ret = idpf_check_pf_reset_done(hw);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "IDPF is still resetting");
+		goto err;
+	}
+
+	ret = idpf_init_mbx(hw);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to init mailbox");
+		goto err;
+	}
+
+	adapter->mbx_resp = rte_zmalloc("idpf_adapter_mbx_resp", IDPF_DFLT_MBX_BUF_SIZE, 0);
+	if (!adapter->mbx_resp) {
+		PMD_INIT_LOG(ERR, "Failed to allocate idpf_adapter_mbx_resp memory");
+		goto err_mbx;
+	}
+
+	if (idpf_check_api_version(adapter)) {
+		PMD_INIT_LOG(ERR, "Failed to check api version");
+		goto err_api;
+	}
+
+	adapter->caps = rte_zmalloc("idpf_caps",
+			       sizeof(struct virtchnl2_get_capabilities), 0);
+	if (!adapter->caps) {
+		PMD_INIT_LOG(ERR, "Failed to allocate idpf_caps memory");
+		goto err_api;
+	}
+
+	if (idpf_get_caps(adapter)) {
+		PMD_INIT_LOG(ERR, "Failed to get capabilities");
+		goto err_caps;
+	}
+
+	adapter->max_vport_nb = adapter->caps->max_vports;
+
+	adapter->vport_req_info = rte_zmalloc("vport_req_info",
+					      adapter->max_vport_nb *
+					      sizeof(*adapter->vport_req_info),
+					      0);
+	if (!adapter->vport_req_info) {
+		PMD_INIT_LOG(ERR, "Failed to allocate vport_req_info memory");
+		goto err_caps;
+	}
+
+	adapter->vport_recv_info = rte_zmalloc("vport_recv_info",
+					       adapter->max_vport_nb *
+					       sizeof(*adapter->vport_recv_info),
+					       0);
+	if (!adapter->vport_recv_info) {
+		PMD_INIT_LOG(ERR, "Failed to allocate vport_recv_info memory");
+		goto err_vport_recv_info;
+	}
+
+	adapter->vports = rte_zmalloc("vports",
+				      adapter->max_vport_nb *
+				      sizeof(*adapter->vports),
+				      0);
+	if (!adapter->vports) {
+		PMD_INIT_LOG(ERR, "Failed to allocate vports memory");
+		goto err_vports;
+	}
+
+	adapter->max_rxq_per_msg = (IDPF_DFLT_MBX_BUF_SIZE -
+			       sizeof(struct virtchnl2_config_rx_queues)) /
+			       sizeof(struct virtchnl2_rxq_info);
+	adapter->max_txq_per_msg = (IDPF_DFLT_MBX_BUF_SIZE -
+			       sizeof(struct virtchnl2_config_tx_queues)) /
+			       sizeof(struct virtchnl2_txq_info);
+
+	adapter->cur_vport_nb = 0;
+	adapter->next_vport_idx = 0;
+	adapter->initialized = true;
+
+	return ret;
+
+err_vports:
+	rte_free(adapter->vports);
+	adapter->vports = NULL;
+err_vport_recv_info:
+	rte_free(adapter->vport_req_info);
+	adapter->vport_req_info = NULL;
+err_caps:
+	rte_free(adapter->caps);
+	adapter->caps = NULL;
+err_api:
+	rte_free(adapter->mbx_resp);
+	adapter->mbx_resp = NULL;
+err_mbx:
+	iecm_ctlq_deinit(hw);
+err:
+	return -1;
+}
+
+
+static int
+idpf_dev_init(struct rte_eth_dev *dev, __rte_unused void *init_params)
+{
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;
+	int ret = 0;
+
+	PMD_INIT_FUNC_TRACE();
+
+	dev->dev_ops = &idpf_eth_dev_ops;
+
+	/* for secondary processes, we don't initialise any further as primary
+	 * has already done this work.
+	 */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return ret;
+
+	ret = idpf_adapter_init(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to init adapter.");
+		return ret;
+	}
+
+	dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
+
+	vport->dev_data = dev->data;
+
+	dev->data->mac_addrs = rte_zmalloc(NULL, RTE_ETHER_ADDR_LEN, 0);
+	if (dev->data->mac_addrs == NULL) {
+		PMD_INIT_LOG(ERR, "Cannot allocate mac_addr memory.");
+		ret = -ENOMEM;
+		goto err;
+	}
+
+err:
+	return ret;
+}
+
+static int
+idpf_dev_uninit(struct rte_eth_dev *dev)
+{
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	idpf_dev_close(dev);
+
+	return 0;
+}
+
+static const struct rte_pci_id pci_id_idpf_map[] = {
+	{ RTE_PCI_DEVICE(IECM_INTEL_VENDOR_ID, IECM_DEV_ID_PF) },
+	{ .vendor_id = 0, /* sentinel */ },
+};
+
+static int
+idpf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+	      struct rte_pci_device *pci_dev)
+{
+	struct rte_eth_devargs eth_da = { .nb_representor_ports = 0 };
+	char name[RTE_ETH_NAME_MAX_LEN];
+	int i, retval;
+
+	if (pci_dev->device.devargs) {
+		retval = rte_eth_devargs_parse(pci_dev->device.devargs->args,
+				&eth_da);
+		if (retval)
+			return retval;
+	}
+
+	if (!eth_da.nb_representor_ports) {
+		PMD_INIT_LOG(ERR, "Failed to probe, need to add representor devargs.");
+		return -1;
+	}
+
+	if (!adapter) {
+		adapter = (struct idpf_adapter *)rte_zmalloc("idpf_adapter",
+					     sizeof(struct idpf_adapter), 0);
+		if (!adapter) {
+			PMD_INIT_LOG(ERR, "Failed to allocate adapter.");
+			return -1;
+		}
+	}
+
+	for (i = 0; i < eth_da.nb_representor_ports; i++) {
+		snprintf(name, sizeof(name), "idpf_vport_%d",
+			 eth_da.representor_ports[i]);
+		retval = rte_eth_dev_create(&pci_dev->device, name,
+					    sizeof(struct idpf_vport),
+					    NULL, NULL, idpf_dev_init,
+					    NULL);
+		if (retval)
+			PMD_DRV_LOG(ERR, "failed to creat vport %d", i);
+	}
+
+	return 0;
+}
+
+static void
+idpf_adapter_rel(struct idpf_adapter *adapter)
+{
+	struct iecm_hw *hw = &adapter->hw;
+	int i;
+
+	iecm_ctlq_deinit(hw);
+
+	if (adapter->caps) {
+		rte_free(adapter->caps);
+		adapter->caps = NULL;
+	}
+
+	if (adapter->mbx_resp) {
+		rte_free(adapter->mbx_resp);
+		adapter->mbx_resp = NULL;
+	}
+
+	if (adapter->vport_req_info) {
+		for (i = 0; i < adapter->max_vport_nb; i++) {
+			if (adapter->vport_req_info[i]) {
+				rte_free(adapter->vport_req_info[i]);
+				adapter->vport_req_info[i] = NULL;
+			}
+		}
+		rte_free(adapter->vport_req_info);
+		adapter->vport_req_info = NULL;
+	}
+
+	if (adapter->vport_recv_info) {
+		for (i = 0; i < adapter->max_vport_nb; i++) {
+			if (adapter->vport_recv_info[i]) {
+				rte_free(adapter->vport_recv_info[i]);
+				adapter->vport_recv_info[i] = NULL;
+			}
+		}
+	}
+
+	if (adapter->vports) {
+		/* Needn't free adapter->vports[i] since it's private data */
+		rte_free(adapter->vports);
+		adapter->vports = NULL;
+	}
+}
+
+static int
+idpf_pci_remove(struct rte_pci_device *pci_dev)
+{
+	if (adapter) {
+		idpf_adapter_rel(adapter);
+		rte_free(adapter);
+		adapter = NULL;
+	}
+
+	return rte_eth_dev_pci_generic_remove(pci_dev, idpf_dev_uninit);
+}
+
+static struct rte_pci_driver rte_idpf_pmd = {
+	.id_table	= pci_id_idpf_map,
+	.drv_flags	= RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
+			  RTE_PCI_DRV_PROBE_AGAIN,
+	.probe		= idpf_pci_probe,
+	.remove		= idpf_pci_remove,
+};
+
+/**
+ * Driver initialization routine.
+ * Invoked once at EAL init time.
+ * Register itself as the [Poll Mode] Driver of PCI devices.
+ */
+RTE_PMD_REGISTER_PCI(net_idpf, rte_idpf_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(net_idpf, pci_id_idpf_map);
+RTE_PMD_REGISTER_KMOD_DEP(net_ice, "* igb_uio | uio_pci_generic | vfio-pci");
+
+RTE_LOG_REGISTER_SUFFIX(idpf_logtype_init, init, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(idpf_logtype_driver, driver, NOTICE);
drivers/net/idpf/idpf_ethdev.h new file +205 -0

205 lines not on this page · raw message

drivers/net/idpf/idpf_vchnl.c new file +476 -0

476 lines not on this page · raw message

drivers/net/idpf/meson.build new file +18 -0
new file mode 100644
index 0000000000..3a84162f93
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+if is_windows
+	build = false
+	reason = 'not supported on Windows'
+	subdir_done()
+endif
+
+subdir('base')
+objs = [base_objs]
+
+sources = files(
+	'idpf_ethdev.c',
+	'idpf_vchnl.c',
+)
+
+includes += include_directories('base')
drivers/net/idpf/version.map new file +3 -0
new file mode 100644
index 0000000000..b7da224860
@@ -0,0 +1,3 @@
+DPDK_22 {
+	local: *;
+};
\ No newline at end of file
drivers/net/meson.build +1 -0
index e35652fe63..8910154544 100644
@@ -28,6 +28,7 @@ drivers = [
         'i40e',
         'iavf',
         'ice',
+        'idpf',
         'igc',
         'ionic',
         'ipn3ke',
Signature · 1 line
2.25.1
#4 lore raw

Re: [PATCH 03/13] net/idpf: support device initialization

drivers/net/idpf/idpf_ethdev.c line 169

Quoted 6 lines · On Wed, 3 Aug 2022 19:30:54 +0800 Junfeng Guo <[email protected]> wrote:
drivers/net/idpf/idpf_ethdev.c new file +6 -0
+
+static int
+idpf_dev_configure(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;

Cast of void pointer dev_private is unnecessary in C (only in C++ is it needed).

Review

Quoted 1 line
(quoted diff) +1 -0
+	int ret = 0;

Useless initialization, you are setting in next line.

Quoted 3 lines
drivers/net/idpf/idpf_ethdev.c new file +3 -0
+
+	ret = idpf_init_vport_req_info(dev);
+	if (ret) {
#5 lore raw

RE: [PATCH 03/13] net/idpf: support device initialization

Quoted 25 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, August 3, 2022 23:12
To: Guo, Junfeng <[email protected]>
Cc: Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; [email protected]; Li, Xiaoyun <[email protected]>; Wang, Xiao W <[email protected]>
Subject: Re: [PATCH 03/13] net/idpf: support device initialization

drivers/net/idpf/idpf_ethdev.c line 169

Quoted 6 lines · On Wed, 3 Aug 2022 19:30:54 +0800 Junfeng Guo <[email protected]> wrote:
drivers/net/idpf/idpf_ethdev.c new file +6 -0
+
+static int
+idpf_dev_configure(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;

Cast of void pointer dev_private is unnecessary in C (only in C++ is it needed).

Quoted 3 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	int ret = 0;

Useless initialization, you are setting in next line.

Thanks for your review! Will refine this in the patchset of upcoming version.

Quoted 4 lines
Quoted 4 lines
drivers/net/idpf/idpf_ethdev.c new file +3 -0
+
+	ret = idpf_init_vport_req_info(dev);
+	if (ret) {
#6 lore raw

RE: [PATCH 03/13] net/idpf: support device initialization

In reply to Junfeng Guo
Quoted 14 lines

-----Original Message-----
From: Junfeng Guo <[email protected]>
Sent: Wednesday, August 3, 2022 2:31 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Xiaoyun Li <[email protected]>; Xiao Wang <[email protected]>
Subject: [PATCH 03/13] net/idpf: support device initialization

Support device init and the following dev ops:
- dev_configure
- dev_start
- dev_stop
- dev_close

Quoted 5 lines

---

Hello,

This patch is causing the following build failure in latest main (6a88cbc) with clang 3.4.2 in CentOS 7:
drivers/net/idpf/idpf_vchnl.c:141:13: error: comparison of constant 522 with expression of type 'enum virtchnl_ops' is always false [-Werror,-Wtautological-constant-out-of-range-compare]

Regards,
Ali

#7 lore raw

RE: [PATCH 03/13] net/idpf: support device initialization

Quoted 33 lines

-----Original Message-----
From: Ali Alnubani <[email protected]>
Sent: Tuesday, November 1, 2022 2:01 AM
To: Guo, Junfeng <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; Wang, Xiao W <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>
Subject: RE: [PATCH 03/13] net/idpf: support device initialization

Quoted 14 lines

-----Original Message-----
From: Junfeng Guo <[email protected]>
Sent: Wednesday, August 3, 2022 2:31 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Xiaoyun Li <[email protected]>; Xiao Wang <[email protected]>
Subject: [PATCH 03/13] net/idpf: support device initialization

Support device init and the following dev ops:
- dev_configure
- dev_start
- dev_stop
- dev_close

Quoted 5 lines

---

Quoted 8 lines

Hello,

This patch is causing the following build failure in latest main (6a88cbc) with clang 3.4.2 in CentOS 7:
drivers/net/idpf/idpf_vchnl.c:141:13: error: comparison of constant 522 with expression of type 'enum virtchnl_ops' is always false [-Werror,- Wtautological-constant-out-of-range-compare]

Hi,

Thanks for reporting the issue, fix patch has been sent, https://patches.dpdk.org/project/dpdk/patch/[email protected]/

Quoted 2 lines

Regards,
Ali

#8 lore raw

RE: [PATCH 03/13] net/idpf: support device initialization

In reply to Junfeng Guo

Hi,

Quoted 1,464 lines

-----Original Message-----
From: Junfeng Guo <[email protected]>
Sent: Wednesday, August 3, 2022 2:31 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Xiaoyun Li <[email protected]>; Xiao Wang <[email protected]>
Subject: [PATCH 03/13] net/idpf: support device initialization

Support device init and the following dev ops:
- dev_configure
- dev_start
- dev_stop
- dev_close

---
 drivers/net/idpf/idpf_ethdev.c | 651
+++++++++++++++++++++++++++++++++  drivers/net/idpf/idpf_ethdev.h
| 205 +++++++++++  drivers/net/idpf/idpf_vchnl.c  | 476
++++++++++++++++++++++++
 drivers/net/idpf/meson.build   |  18 +
 drivers/net/idpf/version.map   |   3 +
 drivers/net/meson.build        |   1 +
 6 files changed, 1354 insertions(+)
 create mode 100644 drivers/net/idpf/idpf_ethdev.c  create mode 100644

drivers/net/idpf/idpf_ethdev.h create mode 100644 drivers/net/idpf/idpf_vchnl.c create mode 100644 drivers/net/idpf/meson.build create mode 100644 drivers/net/idpf/version.map

drivers/net/idpf/idpf_ethdev.c new file +47 -0
new file mode 100644 index 0000000000..87c68226dd
@@ -0,0 +1,651 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#include <rte_atomic.h>
+#include <rte_eal.h>
+#include <rte_ether.h>
+#include <ethdev_driver.h>
+#include <ethdev_pci.h>
+#include <rte_malloc.h>
+#include <rte_memzone.h>
+#include <rte_dev.h>
+
+#include "idpf_ethdev.h"
+
+#define REPRESENTOR		"representor"
+
+struct idpf_adapter *adapter;
+uint16_t used_vecs_num;
+
+static const char * const idpf_valid_args[] = {
+	REPRESENTOR,
+	NULL
+};
+
+static int idpf_dev_configure(struct rte_eth_dev *dev); static int
+idpf_dev_start(struct rte_eth_dev *dev); static int
+idpf_dev_stop(struct rte_eth_dev *dev); static int
+idpf_dev_close(struct rte_eth_dev *dev);
+
+static const struct eth_dev_ops idpf_eth_dev_ops = {
+	.dev_configure			= idpf_dev_configure,
+	.dev_start			= idpf_dev_start,
+	.dev_stop			= idpf_dev_stop,
+	.dev_close			= idpf_dev_close,
+};
+
+static int
+idpf_init_vport_req_info(struct rte_eth_dev *dev) {
+	struct virtchnl2_create_vport *vport_info;
+	uint16_t idx = adapter->next_vport_idx;
+
+	if (!adapter->vport_req_info[idx]) {
+		adapter->vport_req_info[idx] = rte_zmalloc(NULL,
+				    sizeof(struct virtchnl2_create_vport), 0);
+		if (!adapter->vport_req_info[idx]) {
+			PMD_INIT_LOG(ERR, "Failed to allocate

vport_req_info");

drivers/net/idpf/idpf_ethdev.c new file +6 -0
+			return -1;
+		}
+	}
+
+	vport_info =
+		(struct virtchnl2_create_vport *)adapter-
Quoted 1 line

vport_req_info[idx];

drivers/net/idpf/idpf_ethdev.c new file +9 -0
+
+	vport_info->vport_type =
+rte_cpu_to_le_16(VIRTCHNL2_VPORT_TYPE_DEFAULT);
+
+	return 0;
+}
+
+static uint16_t
+idpf_get_next_vport_idx(struct idpf_vport **vports, uint16_t

max_vport_nb,

drivers/net/idpf/idpf_ethdev.c new file +32 -0
+			uint16_t cur_vport_idx)
+{
+	uint16_t vport_idx;
+	uint16_t i;
+
+	if (cur_vport_idx < max_vport_nb && !vports[cur_vport_idx + 1]) {
+		vport_idx = cur_vport_idx + 1;
+		return vport_idx;
+	}
+
+	for (i = 0; i < max_vport_nb; i++) {
+		if (!vports[i])
+			break;
+	}
+
+	if (i == max_vport_nb)
+		vport_idx = IDPF_INVALID_VPORT_IDX;
+	else
+		vport_idx = i;
+
+	return vport_idx;
+}
+
+#ifndef IDPF_RSS_KEY_LEN
+#define IDPF_RSS_KEY_LEN 52
+#endif
+
+static int
+idpf_init_vport(struct rte_eth_dev *dev) {
+	uint16_t idx = adapter->next_vport_idx;
+	struct virtchnl2_create_vport *vport_info =
+		(struct virtchnl2_create_vport *)adapter-
Quoted 1 line

vport_recv_info[idx];

drivers/net/idpf/idpf_ethdev.c new file +26 -0
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;
+	int i;
+
+	vport->adapter = adapter;
+	vport->vport_id = vport_info->vport_id;
+	vport->txq_model = vport_info->txq_model;
+	vport->rxq_model = vport_info->rxq_model;
+	vport->num_tx_q = vport_info->num_tx_q;
+	vport->num_tx_complq = vport_info->num_tx_complq;
+	vport->num_rx_q = vport_info->num_rx_q;
+	vport->num_rx_bufq = vport_info->num_rx_bufq;
+	vport->max_mtu = vport_info->max_mtu;
+	rte_memcpy(vport->default_mac_addr,
+		   vport_info->default_mac_addr, ETH_ALEN);
+	vport->rss_algorithm = vport_info->rss_algorithm;
+	vport->rss_key_size = RTE_MIN(IDPF_RSS_KEY_LEN,
+				     vport_info->rss_key_size);
+	vport->rss_lut_size = vport_info->rss_lut_size;
+	vport->sw_idx = idx;
+
+	for (i = 0; i < vport_info->chunks.num_chunks; i++) {
+		if (vport_info->chunks.chunks[i].type ==
+		    VIRTCHNL2_QUEUE_TYPE_TX) {
+			vport->chunks_info.tx_start_qid =
+				vport_info-
Quoted 1 line

chunks.chunks[i].start_queue_id;

drivers/net/idpf/idpf_ethdev.c new file +2 -0
+			vport->chunks_info.tx_qtail_start =
+				vport_info-
Quoted 1 line

chunks.chunks[i].qtail_reg_start;

drivers/net/idpf/idpf_ethdev.c new file +2 -0
+			vport->chunks_info.tx_qtail_spacing =
+				vport_info-
Quoted 1 line

chunks.chunks[i].qtail_reg_spacing;

drivers/net/idpf/idpf_ethdev.c new file +4 -0
+		} else if (vport_info->chunks.chunks[i].type ==
+			 VIRTCHNL2_QUEUE_TYPE_RX) {
+			vport->chunks_info.rx_start_qid =
+				vport_info-
Quoted 1 line

chunks.chunks[i].start_queue_id;

drivers/net/idpf/idpf_ethdev.c new file +2 -0
+			vport->chunks_info.rx_qtail_start =
+				vport_info-
Quoted 1 line

chunks.chunks[i].qtail_reg_start;

drivers/net/idpf/idpf_ethdev.c new file +2 -0
+			vport->chunks_info.rx_qtail_spacing =
+				vport_info-
Quoted 1 line

chunks.chunks[i].qtail_reg_spacing;

drivers/net/idpf/idpf_ethdev.c new file +4 -0
+		} else if (vport_info->chunks.chunks[i].type ==
+			 VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION) {
+			vport->chunks_info.tx_compl_start_qid =
+				vport_info-
Quoted 1 line

chunks.chunks[i].start_queue_id;

drivers/net/idpf/idpf_ethdev.c new file +2 -0
+			vport->chunks_info.tx_compl_qtail_start =
+				vport_info-
Quoted 1 line

chunks.chunks[i].qtail_reg_start;

drivers/net/idpf/idpf_ethdev.c new file +2 -0
+			vport->chunks_info.tx_compl_qtail_spacing =
+				vport_info-
Quoted 1 line

chunks.chunks[i].qtail_reg_spacing;

drivers/net/idpf/idpf_ethdev.c new file +4 -0
+		} else if (vport_info->chunks.chunks[i].type ==
+			 VIRTCHNL2_QUEUE_TYPE_RX_BUFFER) {
+			vport->chunks_info.rx_buf_start_qid =
+				vport_info-
Quoted 1 line

chunks.chunks[i].start_queue_id;

drivers/net/idpf/idpf_ethdev.c new file +2 -0
+			vport->chunks_info.rx_buf_qtail_start =
+				vport_info-
Quoted 1 line

chunks.chunks[i].qtail_reg_start;

drivers/net/idpf/idpf_ethdev.c new file +2 -0
+			vport->chunks_info.rx_buf_qtail_spacing =
+				vport_info-
Quoted 1 line

chunks.chunks[i].qtail_reg_spacing;

drivers/net/idpf/idpf_ethdev.c new file +6 -0
+		}
+	}
+
+	adapter->vports[idx] = vport;
+	adapter->cur_vport_nb++;
+	adapter->next_vport_idx = idpf_get_next_vport_idx(adapter-
Quoted 1 line

vports,

drivers/net/idpf/idpf_ethdev.c new file +1 -0
+						  adapter->max_vport_nb,

idx);

drivers/net/idpf/idpf_ethdev.c new file +33 -0
+	if (adapter->next_vport_idx == IDPF_INVALID_VPORT_IDX) {
+		PMD_INIT_LOG(ERR, "Failed to get next vport id");
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+idpf_dev_configure(struct rte_eth_dev *dev) {
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;
+	int ret = 0;
+
+	ret = idpf_init_vport_req_info(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to init vport req_info.");
+		return ret;
+	}
+
+	ret = idpf_create_vport(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to create vport.");
+		return ret;
+	}
+
+	ret = idpf_init_vport(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to init vports.");
+		return ret;
+	}
+
+	rte_ether_addr_copy((struct rte_ether_addr *)vport-
Quoted 1 line

default_mac_addr,

drivers/net/idpf/idpf_ethdev.c new file +94 -0
+			    &dev->data->mac_addrs[0]);
+
+	return ret;
+}
+
+static int
+idpf_dev_start(struct rte_eth_dev *dev) {
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;
+
+	PMD_INIT_FUNC_TRACE();
+
+	vport->stopped = 0;
+
+	if (idpf_ena_dis_vport(vport, true)) {
+		PMD_DRV_LOG(ERR, "Failed to enable vport");
+		goto err_vport;
+	}
+
+	return 0;
+
+err_vport:
+	return -1;
+}
+
+static int
+idpf_dev_stop(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (vport->stopped == 1)
+		return 0;
+
+	if (idpf_ena_dis_vport(vport, false))
+		PMD_DRV_LOG(ERR, "disable vport failed");
+
+	vport->stopped = 1;
+	dev->data->dev_started = 0;
+
+	return 0;
+}
+
+static int
+idpf_dev_close(struct rte_eth_dev *dev) {
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	idpf_dev_stop(dev);
+	idpf_destroy_vport(vport);
+
+	return 0;
+}
+
+static int idpf_parse_devargs(struct rte_eth_dev *dev) {
+	struct rte_devargs *devargs = dev->device->devargs;
+	struct rte_kvargs *kvlist;
+	int ret = 0;
+
+	if (!devargs)
+		return 0;
+
+	kvlist = rte_kvargs_parse(devargs->args, idpf_valid_args);
+	if (!kvlist) {
+		PMD_INIT_LOG(ERR, "invalid kvargs key");
+		return -EINVAL;
+	}
+
+	rte_kvargs_free(kvlist);
+	return ret;
+}
+
+static void
+idpf_reset_pf(struct iecm_hw *hw)
+{
+	uint32_t reg;
+
+	reg = IECM_READ_REG(hw, PFGEN_CTRL);
+	IECM_WRITE_REG(hw, PFGEN_CTRL, (reg | PFGEN_CTRL_PFSWR)); }
+
+#define IDPF_RESET_WAIT_CNT 100
+static int
+idpf_check_pf_reset_done(struct iecm_hw *hw) {
+	uint32_t reg;
+	int i;
+
+	for (i = 0; i < IDPF_RESET_WAIT_CNT; i++) {
+		reg = IECM_READ_REG(hw, PFGEN_RSTAT);
+		if (reg != 0xFFFFFFFF && (reg &

PFGEN_RSTAT_PFR_STATE_M))

drivers/net/idpf/idpf_ethdev.c new file +26 -0
+			return 0;
+		rte_delay_ms(1000);
+	}
+
+	PMD_INIT_LOG(ERR, "IDPF reset timeout");
+	return -EBUSY;
+}
+
+#define CTLQ_NUM 2
+static int
+idpf_init_mbx(struct iecm_hw *hw)
+{
+	struct iecm_ctlq_create_info ctlq_info[CTLQ_NUM] = {
+		{
+			.type = IECM_CTLQ_TYPE_MAILBOX_TX,
+			.id = IDPF_CTLQ_ID,
+			.len = IDPF_CTLQ_LEN,
+			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+			.reg = {
+				.head = PF_FW_ATQH,
+				.tail = PF_FW_ATQT,
+				.len = PF_FW_ATQLEN,
+				.bah = PF_FW_ATQBAH,
+				.bal = PF_FW_ATQBAL,
+				.len_mask = PF_FW_ATQLEN_ATQLEN_M,
+				.len_ena_mask =

PF_FW_ATQLEN_ATQENABLE_M,

drivers/net/idpf/idpf_ethdev.c new file +16 -0
+				.head_mask = PF_FW_ATQH_ATQH_M,
+			}
+		},
+		{
+			.type = IECM_CTLQ_TYPE_MAILBOX_RX,
+			.id = IDPF_CTLQ_ID,
+			.len = IDPF_CTLQ_LEN,
+			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+			.reg = {
+				.head = PF_FW_ARQH,
+				.tail = PF_FW_ARQT,
+				.len = PF_FW_ARQLEN,
+				.bah = PF_FW_ARQBAH,
+				.bal = PF_FW_ARQBAL,
+				.len_mask = PF_FW_ARQLEN_ARQLEN_M,
+				.len_ena_mask =

PF_FW_ARQLEN_ARQENABLE_M,

drivers/net/idpf/idpf_ethdev.c new file +14 -0
+				.head_mask = PF_FW_ARQH_ARQH_M,
+			}
+		}
+	};
+	struct iecm_ctlq_info *ctlq;
+	int ret = 0;
+
+	ret = iecm_ctlq_init(hw, CTLQ_NUM, ctlq_info);
+	if (ret)
+		return ret;
+
+	LIST_FOR_EACH_ENTRY_SAFE(ctlq, NULL, &hw->cq_list_head,
+				 struct iecm_ctlq_info, cq_list) {
+		if (ctlq->q_id == IDPF_CTLQ_ID && ctlq->cq_type ==

IECM_CTLQ_TYPE_MAILBOX_TX)

drivers/net/idpf/idpf_ethdev.c new file +2 -0
+			hw->asq = ctlq;
+		if (ctlq->q_id == IDPF_CTLQ_ID && ctlq->cq_type ==

IECM_CTLQ_TYPE_MAILBOX_RX)

drivers/net/idpf/idpf_ethdev.c new file +47 -0
+			hw->arq = ctlq;
+	}
+
+	if (!hw->asq || !hw->arq) {
+		iecm_ctlq_deinit(hw);
+		ret = -ENOENT;
+	}
+
+	return ret;
+}
+
+static int
+idpf_adapter_init(struct rte_eth_dev *dev) {
+	struct iecm_hw *hw = &adapter->hw;
+	struct rte_pci_device *pci_dev = IDPF_DEV_TO_PCI(dev);
+	int ret = 0;
+
+	if (adapter->initialized)
+		return 0;
+
+	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
+	hw->hw_addr_len = pci_dev->mem_resource[0].len;
+	hw->back = adapter;
+	hw->vendor_id = pci_dev->id.vendor_id;
+	hw->device_id = pci_dev->id.device_id;
+	hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
+
+	ret = idpf_parse_devargs(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to parse devargs");
+		goto err;
+	}
+
+	idpf_reset_pf(hw);
+	ret = idpf_check_pf_reset_done(hw);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "IDPF is still resetting");
+		goto err;
+	}
+
+	ret = idpf_init_mbx(hw);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to init mailbox");
+		goto err;
+	}
+
+	adapter->mbx_resp = rte_zmalloc("idpf_adapter_mbx_resp",

IDPF_DFLT_MBX_BUF_SIZE, 0);

drivers/net/idpf/idpf_ethdev.c new file +2 -0
+	if (!adapter->mbx_resp) {
+		PMD_INIT_LOG(ERR, "Failed to allocate

idpf_adapter_mbx_resp memory");

drivers/net/idpf/idpf_ethdev.c new file +25 -0
+		goto err_mbx;
+	}
+
+	if (idpf_check_api_version(adapter)) {
+		PMD_INIT_LOG(ERR, "Failed to check api version");
+		goto err_api;
+	}
+
+	adapter->caps = rte_zmalloc("idpf_caps",
+			       sizeof(struct virtchnl2_get_capabilities), 0);
+	if (!adapter->caps) {
+		PMD_INIT_LOG(ERR, "Failed to allocate idpf_caps memory");
+		goto err_api;
+	}
+
+	if (idpf_get_caps(adapter)) {
+		PMD_INIT_LOG(ERR, "Failed to get capabilities");
+		goto err_caps;
+	}
+
+	adapter->max_vport_nb = adapter->caps->max_vports;
+
+	adapter->vport_req_info = rte_zmalloc("vport_req_info",
+					      adapter->max_vport_nb *
+					      sizeof(*adapter-
Quoted 1 line

vport_req_info),

drivers/net/idpf/idpf_ethdev.c new file +3 -0
+					      0);
+	if (!adapter->vport_req_info) {
+		PMD_INIT_LOG(ERR, "Failed to allocate vport_req_info

memory");

drivers/net/idpf/idpf_ethdev.c new file +6 -0
+		goto err_caps;
+	}
+
+	adapter->vport_recv_info = rte_zmalloc("vport_recv_info",
+					       adapter->max_vport_nb *
+					       sizeof(*adapter-
Quoted 1 line

vport_recv_info),

drivers/net/idpf/idpf_ethdev.c new file +3 -0
+					       0);
+	if (!adapter->vport_recv_info) {
+		PMD_INIT_LOG(ERR, "Failed to allocate vport_recv_info

memory");

drivers/net/idpf/idpf_ethdev.c new file +72 -0
+		goto err_vport_recv_info;
+	}
+
+	adapter->vports = rte_zmalloc("vports",
+				      adapter->max_vport_nb *
+				      sizeof(*adapter->vports),
+				      0);
+	if (!adapter->vports) {
+		PMD_INIT_LOG(ERR, "Failed to allocate vports memory");
+		goto err_vports;
+	}
+
+	adapter->max_rxq_per_msg = (IDPF_DFLT_MBX_BUF_SIZE -
+			       sizeof(struct virtchnl2_config_rx_queues)) /
+			       sizeof(struct virtchnl2_rxq_info);
+	adapter->max_txq_per_msg = (IDPF_DFLT_MBX_BUF_SIZE -
+			       sizeof(struct virtchnl2_config_tx_queues)) /
+			       sizeof(struct virtchnl2_txq_info);
+
+	adapter->cur_vport_nb = 0;
+	adapter->next_vport_idx = 0;
+	adapter->initialized = true;
+
+	return ret;
+
+err_vports:
+	rte_free(adapter->vports);
+	adapter->vports = NULL;
+err_vport_recv_info:
+	rte_free(adapter->vport_req_info);
+	adapter->vport_req_info = NULL;
+err_caps:
+	rte_free(adapter->caps);
+	adapter->caps = NULL;
+err_api:
+	rte_free(adapter->mbx_resp);
+	adapter->mbx_resp = NULL;
+err_mbx:
+	iecm_ctlq_deinit(hw);
+err:
+	return -1;
+}
+
+
+static int
+idpf_dev_init(struct rte_eth_dev *dev, __rte_unused void *init_params)
+{
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;
+	int ret = 0;
+
+	PMD_INIT_FUNC_TRACE();
+
+	dev->dev_ops = &idpf_eth_dev_ops;
+
+	/* for secondary processes, we don't initialise any further as primary
+	 * has already done this work.
+	 */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return ret;
+
+	ret = idpf_adapter_init(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to init adapter.");
+		return ret;
+	}
+
+	dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
+
+	vport->dev_data = dev->data;
+
+	dev->data->mac_addrs = rte_zmalloc(NULL, RTE_ETHER_ADDR_LEN,

0);

drivers/net/idpf/idpf_ethdev.c new file +35 -0
+	if (dev->data->mac_addrs == NULL) {
+		PMD_INIT_LOG(ERR, "Cannot allocate mac_addr memory.");
+		ret = -ENOMEM;
+		goto err;
+	}
+
+err:
+	return ret;
+}
+
+static int
+idpf_dev_uninit(struct rte_eth_dev *dev) {
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	idpf_dev_close(dev);
+
+	return 0;
+}
+
+static const struct rte_pci_id pci_id_idpf_map[] = {
+	{ RTE_PCI_DEVICE(IECM_INTEL_VENDOR_ID, IECM_DEV_ID_PF) },
+	{ .vendor_id = 0, /* sentinel */ },
+};
+
+static int
+idpf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+	      struct rte_pci_device *pci_dev)
+{
+	struct rte_eth_devargs eth_da = { .nb_representor_ports = 0 };
+	char name[RTE_ETH_NAME_MAX_LEN];
+	int i, retval;
+
+	if (pci_dev->device.devargs) {
+		retval = rte_eth_devargs_parse(pci_dev->device.devargs-
Quoted 1 line

args,

drivers/net/idpf/idpf_ethdev.c new file +7 -0
+				&eth_da);
+		if (retval)
+			return retval;
+	}
+
+	if (!eth_da.nb_representor_ports) {
+		PMD_INIT_LOG(ERR, "Failed to probe, need to add

representor devargs.");

drivers/net/idpf/idpf_ethdev.c new file +79 -0
+		return -1;
+	}
+
+	if (!adapter) {
+		adapter = (struct idpf_adapter *)rte_zmalloc("idpf_adapter",
+					     sizeof(struct idpf_adapter), 0);
+		if (!adapter) {
+			PMD_INIT_LOG(ERR, "Failed to allocate adapter.");
+			return -1;
+		}
+	}
+
+	for (i = 0; i < eth_da.nb_representor_ports; i++) {
+		snprintf(name, sizeof(name), "idpf_vport_%d",
+			 eth_da.representor_ports[i]);
+		retval = rte_eth_dev_create(&pci_dev->device, name,
+					    sizeof(struct idpf_vport),
+					    NULL, NULL, idpf_dev_init,
+					    NULL);
+		if (retval)
+			PMD_DRV_LOG(ERR, "failed to creat vport %d", i);
+	}
+
+	return 0;
+}
+
+static void
+idpf_adapter_rel(struct idpf_adapter *adapter) {
+	struct iecm_hw *hw = &adapter->hw;
+	int i;
+
+	iecm_ctlq_deinit(hw);
+
+	if (adapter->caps) {
+		rte_free(adapter->caps);
+		adapter->caps = NULL;
+	}
+
+	if (adapter->mbx_resp) {
+		rte_free(adapter->mbx_resp);
+		adapter->mbx_resp = NULL;
+	}
+
+	if (adapter->vport_req_info) {
+		for (i = 0; i < adapter->max_vport_nb; i++) {
+			if (adapter->vport_req_info[i]) {
+				rte_free(adapter->vport_req_info[i]);
+				adapter->vport_req_info[i] = NULL;
+			}
+		}
+		rte_free(adapter->vport_req_info);
+		adapter->vport_req_info = NULL;
+	}
+
+	if (adapter->vport_recv_info) {
+		for (i = 0; i < adapter->max_vport_nb; i++) {
+			if (adapter->vport_recv_info[i]) {
+				rte_free(adapter->vport_recv_info[i]);
+				adapter->vport_recv_info[i] = NULL;
+			}
+		}
+	}
+
+	if (adapter->vports) {
+		/* Needn't free adapter->vports[i] since it's private data */
+		rte_free(adapter->vports);
+		adapter->vports = NULL;
+	}
+}
+
+static int
+idpf_pci_remove(struct rte_pci_device *pci_dev) {
+	if (adapter) {
+		idpf_adapter_rel(adapter);
+		rte_free(adapter);
+		adapter = NULL;
+	}
+
+	return rte_eth_dev_pci_generic_remove(pci_dev, idpf_dev_uninit);

}

drivers/net/idpf/idpf_ethdev.c new file +4 -0
+
+static struct rte_pci_driver rte_idpf_pmd = {
+	.id_table	= pci_id_idpf_map,
+	.drv_flags	= RTE_PCI_DRV_NEED_MAPPING |

RTE_PCI_DRV_INTR_LSC |

drivers/net/idpf/idpf_ethdev.c new file +17 -0
+			  RTE_PCI_DRV_PROBE_AGAIN,
+	.probe		= idpf_pci_probe,
+	.remove		= idpf_pci_remove,
+};
+
+/**
+ * Driver initialization routine.
+ * Invoked once at EAL init time.
+ * Register itself as the [Poll Mode] Driver of PCI devices.
+ */
+RTE_PMD_REGISTER_PCI(net_idpf, rte_idpf_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(net_idpf, pci_id_idpf_map);
+RTE_PMD_REGISTER_KMOD_DEP(net_ice, "* igb_uio | uio_pci_generic |
+vfio-pci");
+
+RTE_LOG_REGISTER_SUFFIX(idpf_logtype_init, init, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(idpf_logtype_driver, driver, NOTICE);
drivers/net/idpf/idpf_ethdev.h new file +48 -0
new file mode 100644 index 0000000000..501f772fa8
@@ -0,0 +1,205 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#ifndef _IDPF_ETHDEV_H_
+#define _IDPF_ETHDEV_H_
+
+#include <stdint.h>
+#include <rte_mbuf.h>
+#include <rte_mempool.h>
+#include <rte_malloc.h>
+#include <rte_spinlock.h>
+#include <rte_ethdev.h>
+#include <rte_kvargs.h>
+#include <ethdev_driver.h>
+
+#include "base/iecm_osdep.h"
+#include "base/iecm_type.h"
+#include "base/iecm_devids.h"
+#include "base/iecm_lan_txrx.h"
+#include "base/iecm_lan_pf_regs.h"
+#include "base/virtchnl.h"
+#include "base/virtchnl2.h"
+
+#define IDPF_INVALID_VPORT_IDX	0xffff
+#define IDPF_TXQ_PER_GRP	1
+#define IDPF_TX_COMPLQ_PER_GRP	1
+#define IDPF_RXQ_PER_GRP	1
+#define IDPF_RX_BUFQ_PER_GRP	2
+
+#define IDPF_CTLQ_ID		-1
+#define IDPF_CTLQ_LEN		64
+#define IDPF_DFLT_MBX_BUF_SIZE	4096
+
+#define IDPF_DFLT_Q_VEC_NUM	1
+#define IDPF_DFLT_INTERVAL	16
+
+#define IDPF_MAX_NUM_QUEUES	256
+#define IDPF_MIN_BUF_SIZE	1024
+#define IDPF_MAX_FRAME_SIZE	9728
+
+#define IDPF_NUM_MACADDR_MAX	64
+
+#define IDPF_MAX_PKT_TYPE	1024
+
+#define IDPF_VLAN_TAG_SIZE	4
+#define IDPF_ETH_OVERHEAD \
+	(RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN +

IDPF_VLAN_TAG_SIZE * 2)

drivers/net/idpf/idpf_ethdev.h new file +32 -0
+
+#ifndef ETH_ADDR_LEN
+#define ETH_ADDR_LEN		6
+#endif
+
+/* Message type read in virtual channel from PF */ enum idpf_vc_result
+{
+	IDPF_MSG_ERR = -1, /* Meet error when accessing admin queue */
+	IDPF_MSG_NON,      /* Read nothing from admin queue */
+	IDPF_MSG_SYS,      /* Read system msg from admin queue */
+	IDPF_MSG_CMD,      /* Read async command result */
+};
+
+struct idpf_chunks_info {
+	uint32_t tx_start_qid;
+	uint32_t rx_start_qid;
+	/* Valid only if split queue model */
+	uint32_t tx_compl_start_qid;
+	uint32_t rx_buf_start_qid;
+
+	uint64_t tx_qtail_start;
+	uint32_t tx_qtail_spacing;
+	uint64_t rx_qtail_start;
+	uint32_t rx_qtail_spacing;
+	uint64_t tx_compl_qtail_start;
+	uint32_t tx_compl_qtail_spacing;
+	uint64_t rx_buf_qtail_start;
+	uint32_t rx_buf_qtail_spacing;
+};
+
+struct idpf_vport {
+	struct idpf_adapter *adapter; /* Backreference to associated

adapter */

drivers/net/idpf/idpf_ethdev.h new file +44 -0
+	uint16_t vport_id;
+	uint32_t txq_model;
+	uint32_t rxq_model;
+	uint16_t num_tx_q;
+	/* valid only if txq_model is split Q */
+	uint16_t num_tx_complq;
+	uint16_t num_rx_q;
+	/* valid only if rxq_model is split Q */
+	uint16_t num_rx_bufq;
+
+	uint16_t max_mtu;
+	uint8_t default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
+
+	enum virtchnl_rss_algorithm rss_algorithm;
+	uint16_t rss_key_size;
+	uint16_t rss_lut_size;
+
+	uint16_t sw_idx; /* SW idx */
+
+	struct rte_eth_dev_data *dev_data; /* Pointer to the device data */
+	uint16_t max_pkt_len; /* Maximum packet length */
+
+	/* RSS info */
+	uint32_t *rss_lut;
+	uint8_t *rss_key;
+	uint64_t rss_hf;
+
+	/* Chunk info */
+	struct idpf_chunks_info chunks_info;
+
+	/* Event from ipf */
+	bool link_up;
+	uint32_t link_speed;
+
+	bool stopped;
+	struct virtchnl2_vport_stats eth_stats_offset; };
+
+struct idpf_adapter {
+	struct iecm_hw hw;
+
+	struct virtchnl_version_info virtchnl_version;
+	struct virtchnl2_get_capabilities *caps;
+
+	volatile enum virtchnl_ops pend_cmd; /* pending command not

finished */

drivers/net/idpf/idpf_ethdev.h new file +2 -0
+	uint32_t cmd_retval; /* return value of the cmd response from ipf */
+	uint8_t *mbx_resp; /* buffer to store the mailbox response from ipf

*/

drivers/net/idpf/idpf_ethdev.h new file +17 -0
+
+	uint32_t txq_model;
+	uint32_t rxq_model;
+
+	/* Vport info */
+	uint8_t **vport_req_info;
+	uint8_t **vport_recv_info;
+	struct idpf_vport **vports;
+	uint16_t max_vport_nb;
+	uint16_t cur_vport_nb;
+	uint16_t next_vport_idx;
+
+	/* Max config queue number per VC message */
+	uint32_t max_rxq_per_msg;
+	uint32_t max_txq_per_msg;
+
+	uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE]

__rte_cache_min_aligned;

drivers/net/idpf/idpf_ethdev.h new file +41 -0
+
+	bool initialized;
+	bool stopped;
+};
+
+extern struct idpf_adapter *adapter;
+
+#define IDPF_DEV_TO_PCI(eth_dev)		\
+	RTE_DEV_TO_PCI((eth_dev)->device)
+
+/* structure used for sending and checking response of virtchnl ops */
+struct idpf_cmd_info {
+	uint32_t ops;
+	uint8_t *in_args;       /* buffer for sending */
+	uint32_t in_args_size;  /* buffer size for sending */
+	uint8_t *out_buffer;    /* buffer for response */
+	uint32_t out_size;      /* buffer size for response */
+};
+
+/* notify current command done. Only call in case execute
+ * _atomic_set_cmd successfully.
+ */
+static inline void
+_notify_cmd(struct idpf_adapter *adapter, int msg_ret) {
+	adapter->cmd_retval = msg_ret;
+	rte_wmb();
+	adapter->pend_cmd = VIRTCHNL_OP_UNKNOWN; }
+
+/* clear current command. Only call in case execute
+ * _atomic_set_cmd successfully.
+ */
+static inline void
+_clear_cmd(struct idpf_adapter *adapter) {
+	rte_wmb();
+	adapter->pend_cmd = VIRTCHNL_OP_UNKNOWN;
+	adapter->cmd_retval = VIRTCHNL_STATUS_SUCCESS; }
+
+/* Check there is pending cmd in execution. If none, set new command.
+*/ static inline int _atomic_set_cmd(struct idpf_adapter *adapter, enum
+virtchnl_ops ops) {
+	int ret = rte_atomic32_cmpset(&adapter->pend_cmd,

VIRTCHNL_OP_UNKNOWN,

drivers/net/idpf/idpf_ethdev.h new file +4 -0
+ops);
+
+	if (!ret)
+		PMD_DRV_LOG(ERR, "There is incomplete cmd %d",

adapter->pend_cmd);

drivers/net/idpf/idpf_ethdev.h new file +12 -0
+
+	return !ret;
+}
+
+void idpf_handle_virtchnl_msg(struct rte_eth_dev *dev); int
+idpf_check_api_version(struct idpf_adapter *adapter); int
+idpf_get_caps(struct idpf_adapter *adapter); int
+idpf_create_vport(__rte_unused struct rte_eth_dev *dev); int
+idpf_destroy_vport(struct idpf_vport *vport); int
+idpf_ena_dis_vport(struct idpf_vport *vport, bool enable);
+
+#endif /* _IDPF_ETHDEV_H_ */
drivers/net/idpf/idpf_vchnl.c new renamed from drivers/net/idpf/idpf_vchnl.c +0 -0

file mode 100644 index 0000000000..4fc15d5b71

drivers/net/idpf/idpf_vchnl.c new file +38 -0
@@ -0,0 +1,476 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <inttypes.h>
+#include <rte_byteorder.h>
+#include <rte_common.h>
+
+#include <rte_debug.h>
+#include <rte_atomic.h>
+#include <rte_eal.h>
+#include <rte_ether.h>
+#include <ethdev_driver.h>
+#include <ethdev_pci.h>
+#include <rte_dev.h>
+
+#include "idpf_ethdev.h"
+
+#include "base/iecm_prototype.h"
+
+#define IDPF_CTLQ_LEN	64
+
+static int
+idpf_vc_clean(struct idpf_adapter *adapter) {
+	struct iecm_ctlq_msg *q_msg[IDPF_CTLQ_LEN];
+	uint16_t num_q_msg = IDPF_CTLQ_LEN;
+	struct iecm_dma_mem *dma_mem;
+	int err = 0;
+	uint32_t i;
+
+	for (i = 0; i < 10; i++) {
+		err = iecm_ctlq_clean_sq(adapter->hw.asq, &num_q_msg,

q_msg);

drivers/net/idpf/idpf_vchnl.c new file +49 -0
+		msleep(20);
+		if (num_q_msg)
+			break;
+	}
+	if (err)
+		goto error;
+
+	/* Empty queue is not an error */
+	for (i = 0; i < num_q_msg; i++) {
+		dma_mem = q_msg[i]->ctx.indirect.payload;
+		if (dma_mem) {
+			iecm_free_dma_mem(&adapter->hw, dma_mem);
+			rte_free(dma_mem);
+		}
+		rte_free(q_msg[i]);
+	}
+
+error:
+	return err;
+}
+
+static int
+idpf_send_vc_msg(struct idpf_adapter *adapter, enum virtchnl_ops op,
+		 uint16_t msg_size, uint8_t *msg)
+{
+	struct iecm_ctlq_msg *ctlq_msg;
+	struct iecm_dma_mem *dma_mem;
+	int err = 0;
+
+	err = idpf_vc_clean(adapter);
+	if (err)
+		goto err;
+
+	ctlq_msg = (struct iecm_ctlq_msg *)rte_zmalloc(NULL,
+				sizeof(struct iecm_ctlq_msg), 0);
+	if (!ctlq_msg) {
+		err = -ENOMEM;
+		goto err;
+	}
+
+	dma_mem = (struct iecm_dma_mem *)rte_zmalloc(NULL,
+				sizeof(struct iecm_dma_mem), 0);
+	if (!dma_mem) {
+		err = -ENOMEM;
+		goto dma_mem_error;
+	}
+
+	dma_mem->size = IDPF_DFLT_MBX_BUF_SIZE;
+	iecm_alloc_dma_mem(&adapter->hw, dma_mem, dma_mem-
Quoted 1 line

size);

drivers/net/idpf/idpf_vchnl.c new file +53 -0
+	if (!dma_mem->va) {
+		err = -ENOMEM;
+		goto dma_alloc_error;
+	}
+
+	memcpy(dma_mem->va, msg, msg_size);
+
+	ctlq_msg->opcode = iecm_mbq_opc_send_msg_to_pf;
+	ctlq_msg->func_id = 0;
+	ctlq_msg->data_len = msg_size;
+	ctlq_msg->cookie.mbx.chnl_opcode = op;
+	ctlq_msg->cookie.mbx.chnl_retval = VIRTCHNL_STATUS_SUCCESS;
+	ctlq_msg->ctx.indirect.payload = dma_mem;
+
+	err = iecm_ctlq_send(&adapter->hw, adapter->hw.asq, 1, ctlq_msg);
+	if (err)
+		goto send_error;
+
+	return err;
+
+send_error:
+	iecm_free_dma_mem(&adapter->hw, dma_mem);
+dma_alloc_error:
+	rte_free(dma_mem);
+dma_mem_error:
+	rte_free(ctlq_msg);
+err:
+	return err;
+}
+
+static enum idpf_vc_result
+idpf_read_msg_from_ipf(struct idpf_adapter *adapter, uint16_t buf_len,
+		       uint8_t *buf)
+{
+	struct iecm_hw *hw = &adapter->hw;
+	struct iecm_ctlq_msg ctlq_msg;
+	struct iecm_dma_mem *dma_mem = NULL;
+	enum idpf_vc_result result = IDPF_MSG_NON;
+	enum virtchnl_ops opcode;
+	uint16_t pending = 1;
+	int ret;
+
+	ret = iecm_ctlq_recv(hw->arq, &pending, &ctlq_msg);
+	if (ret) {
+		PMD_DRV_LOG(DEBUG, "Can't read msg from AQ");
+		if (ret != IECM_ERR_CTLQ_NO_WORK)
+			result = IDPF_MSG_ERR;
+		return result;
+	}
+
+	rte_memcpy(buf, ctlq_msg.ctx.indirect.payload->va, buf_len);
+
+	opcode = (enum

virtchnl_ops)rte_le_to_cpu_32(ctlq_msg.cookie.mbx.chnl_opcode);

drivers/net/idpf/idpf_vchnl.c new file +10 -0
+	adapter->cmd_retval =
+		(enum
+virtchnl_status_code)rte_le_to_cpu_32(ctlq_msg.cookie.mbx.chnl_retval);
+
+	PMD_DRV_LOG(DEBUG, "CQ from ipf carries opcode %u, retval %d",
+		    opcode, adapter->cmd_retval);
+
+	if (opcode == VIRTCHNL2_OP_EVENT) {
+		struct virtchnl2_event *ve =
+			(struct virtchnl2_event

*)ctlq_msg.ctx.indirect.payload->va;

drivers/net/idpf/idpf_vchnl.c new file +8 -0
+
+		result = IDPF_MSG_SYS;
+		switch (ve->event) {
+		case VIRTCHNL2_EVENT_LINK_CHANGE:
+			/* TBD */
+			break;
+		default:
+			PMD_DRV_LOG(ERR, "%s: Unknown event %d from

ipf",

drivers/net/idpf/idpf_vchnl.c new file +8 -0
+				    __func__, ve->event);
+			break;
+		}
+	} else {
+		/* async reply msg on command issued by pf previously */
+		result = IDPF_MSG_CMD;
+		if (opcode != adapter->pend_cmd) {
+			PMD_DRV_LOG(WARNING, "command mismatch,

expect %u, get %u",

drivers/net/idpf/idpf_vchnl.c new file +11 -0
+				    adapter->pend_cmd, opcode);
+			result = IDPF_MSG_ERR;
+		}
+	}
+
+	if (ctlq_msg.data_len)
+		dma_mem = ctlq_msg.ctx.indirect.payload;
+	else
+		pending = 0;
+
+	ret = iecm_ctlq_post_rx_buffs(hw, hw->arq, &pending,

&dma_mem);

drivers/net/idpf/idpf_vchnl.c new file +56 -0
+	if (ret && dma_mem)
+		iecm_free_dma_mem(hw, dma_mem);
+
+	return result;
+}
+
+#define MAX_TRY_TIMES 200
+#define ASQ_DELAY_MS  10
+
+static int
+idpf_execute_vc_cmd(struct idpf_adapter *adapter, struct idpf_cmd_info
+*args) {
+	enum idpf_vc_result result;
+	int err = 0;
+	int i = 0;
+	int ret;
+
+	if (_atomic_set_cmd(adapter, args->ops))
+		return -1;
+
+	ret = idpf_send_vc_msg(adapter, args->ops,
+			       args->in_args_size,
+			       args->in_args);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "fail to send cmd %d", args->ops);
+		_clear_cmd(adapter);
+		return ret;
+	}
+
+	switch (args->ops) {
+	case VIRTCHNL_OP_VERSION:
+	case VIRTCHNL2_OP_GET_CAPS:
+	case VIRTCHNL2_OP_CREATE_VPORT:
+	case VIRTCHNL2_OP_DESTROY_VPORT:
+	case VIRTCHNL2_OP_SET_RSS_KEY:
+	case VIRTCHNL2_OP_SET_RSS_LUT:
+	case VIRTCHNL2_OP_SET_RSS_HASH:
+	case VIRTCHNL2_OP_CONFIG_RX_QUEUES:
+	case VIRTCHNL2_OP_CONFIG_TX_QUEUES:
+	case VIRTCHNL2_OP_ENABLE_QUEUES:
+	case VIRTCHNL2_OP_DISABLE_QUEUES:
+	case VIRTCHNL2_OP_ENABLE_VPORT:
+	case VIRTCHNL2_OP_DISABLE_VPORT:
+		/* for init virtchnl ops, need to poll the response */
+		do {
+			result = idpf_read_msg_from_ipf(adapter,
+							args->out_size,
+							args->out_buffer);
+			if (result == IDPF_MSG_CMD)
+				break;
+			rte_delay_ms(ASQ_DELAY_MS);
+		} while (i++ < MAX_TRY_TIMES);
+		if (i >= MAX_TRY_TIMES ||
+		    adapter->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {
+			err = -1;
+			PMD_DRV_LOG(ERR, "No response or return failure

(%d) for cmd %d",

drivers/net/idpf/idpf_vchnl.c new file +10 -0
+				    adapter->cmd_retval, args->ops);
+		}
+		_clear_cmd(adapter);
+		break;
+	default:
+		/* For other virtchnl ops in running time,
+		 * wait for the cmd done flag.
+		 */
+		do {
+			if (adapter->pend_cmd ==

VIRTCHNL_OP_UNKNOWN)

drivers/net/idpf/idpf_vchnl.c new file +9 -0
+				break;
+			rte_delay_ms(ASQ_DELAY_MS);
+			/* If don't read msg or read sys event, continue */
+		} while (i++ < MAX_TRY_TIMES);
+		/* If there's no response is received, clear command */
+		if (i >= MAX_TRY_TIMES  ||
+		    adapter->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {
+			err = -1;
+			PMD_DRV_LOG(ERR, "No response or return failure

(%d) for cmd %d",

drivers/net/idpf/idpf_vchnl.c new file +29 -0
+				    adapter->cmd_retval, args->ops);
+			_clear_cmd(adapter);
+		}
+		break;
+	}
+
+	return err;
+}
+
+int
+idpf_check_api_version(struct idpf_adapter *adapter) {
+	struct virtchnl_version_info version;
+	struct idpf_cmd_info args;
+	int err;
+
+	memset(&version, 0, sizeof(struct virtchnl_version_info));
+	version.major = VIRTCHNL_VERSION_MAJOR_2;
+	version.minor = VIRTCHNL_VERSION_MINOR_0;
+
+	args.ops = VIRTCHNL_OP_VERSION;
+	args.in_args = (uint8_t *)&version;
+	args.in_args_size = sizeof(version);
+	args.out_buffer = adapter->mbx_resp;
+	args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
+
+	err = idpf_execute_vc_cmd(adapter, &args);
+	if (err) {
+		PMD_DRV_LOG(ERR,
+			    "Failed to execute command of

VIRTCHNL_OP_VERSION");

drivers/net/idpf/idpf_vchnl.c new file +90 -0
+		return err;
+	}
+
+	return err;
+}
+
+int
+idpf_get_caps(struct idpf_adapter *adapter) {
+	struct virtchnl2_get_capabilities caps_msg;
+	struct idpf_cmd_info args;
+	int err;
+
+	 memset(&caps_msg, 0, sizeof(struct virtchnl2_get_capabilities));
+	 caps_msg.csum_caps =
+		 VIRTCHNL2_CAP_TX_CSUM_L3_IPV4		|
+		 VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP	|
+		 VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP	|
+		 VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP	|
+		 VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP	|
+		 VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP	|
+		 VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP	|
+		 VIRTCHNL2_CAP_TX_CSUM_GENERIC		|
+		 VIRTCHNL2_CAP_RX_CSUM_L3_IPV4		|
+		 VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP	|
+		 VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP	|
+		 VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP	|
+		 VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP	|
+		 VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP	|
+		 VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP	|
+		 VIRTCHNL2_CAP_RX_CSUM_GENERIC;
+
+	 caps_msg.seg_caps =
+		 VIRTCHNL2_CAP_SEG_IPV4_TCP		|
+		 VIRTCHNL2_CAP_SEG_IPV4_UDP		|
+		 VIRTCHNL2_CAP_SEG_IPV4_SCTP		|
+		 VIRTCHNL2_CAP_SEG_IPV6_TCP		|
+		 VIRTCHNL2_CAP_SEG_IPV6_UDP		|
+		 VIRTCHNL2_CAP_SEG_IPV6_SCTP		|
+		 VIRTCHNL2_CAP_SEG_GENERIC;
+
+	 caps_msg.rss_caps =
+		 VIRTCHNL2_CAP_RSS_IPV4_TCP		|
+		 VIRTCHNL2_CAP_RSS_IPV4_UDP		|
+		 VIRTCHNL2_CAP_RSS_IPV4_SCTP		|
+		 VIRTCHNL2_CAP_RSS_IPV4_OTHER		|
+		 VIRTCHNL2_CAP_RSS_IPV6_TCP		|
+		 VIRTCHNL2_CAP_RSS_IPV6_UDP		|
+		 VIRTCHNL2_CAP_RSS_IPV6_SCTP		|
+		 VIRTCHNL2_CAP_RSS_IPV6_OTHER		|
+		 VIRTCHNL2_CAP_RSS_IPV4_AH		|
+		 VIRTCHNL2_CAP_RSS_IPV4_ESP		|
+		 VIRTCHNL2_CAP_RSS_IPV4_AH_ESP		|
+		 VIRTCHNL2_CAP_RSS_IPV6_AH		|
+		 VIRTCHNL2_CAP_RSS_IPV6_ESP		|
+		 VIRTCHNL2_CAP_RSS_IPV6_AH_ESP;
+
+	 caps_msg.hsplit_caps =
+		 VIRTCHNL2_CAP_RX_HSPLIT_AT_L2		|
+		 VIRTCHNL2_CAP_RX_HSPLIT_AT_L3		|
+		 VIRTCHNL2_CAP_RX_HSPLIT_AT_L4V4	|
+		 VIRTCHNL2_CAP_RX_HSPLIT_AT_L4V6;
+
+	 caps_msg.rsc_caps =
+		 VIRTCHNL2_CAP_RSC_IPV4_TCP		|
+		 VIRTCHNL2_CAP_RSC_IPV4_SCTP		|
+		 VIRTCHNL2_CAP_RSC_IPV6_TCP		|
+		 VIRTCHNL2_CAP_RSC_IPV6_SCTP;
+
+	 caps_msg.other_caps =
+		 VIRTCHNL2_CAP_RDMA			|
+		 VIRTCHNL2_CAP_SRIOV			|
+		 VIRTCHNL2_CAP_MACFILTER		|
+		 VIRTCHNL2_CAP_FLOW_DIRECTOR		|
+		 VIRTCHNL2_CAP_SPLITQ_QSCHED		|
+		 VIRTCHNL2_CAP_CRC			|
+		 VIRTCHNL2_CAP_WB_ON_ITR		|
+		 VIRTCHNL2_CAP_PROMISC			|
+		 VIRTCHNL2_CAP_LINK_SPEED		|
+		 VIRTCHNL2_CAP_VLAN;
+
+	args.ops = VIRTCHNL2_OP_GET_CAPS;
+	args.in_args = (uint8_t *)&caps_msg;
+	args.in_args_size = sizeof(caps_msg);
+	args.out_buffer = adapter->mbx_resp;
+	args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
+
+	err = idpf_execute_vc_cmd(adapter, &args);
+	if (err) {
+		PMD_DRV_LOG(ERR,
+			    "Failed to execute command of

VIRTCHNL2_OP_GET_CAPS");

drivers/net/idpf/idpf_vchnl.c new file +13 -0
+		return err;
+	}
+
+	rte_memcpy(adapter->caps, args.out_buffer, sizeof(caps_msg));
+
+	return err;
+}
+
+int
+idpf_create_vport(__rte_unused struct rte_eth_dev *dev) {
+	uint16_t idx = adapter->next_vport_idx;
+	struct virtchnl2_create_vport *vport_req_info =
+		(struct virtchnl2_create_vport *)adapter-
Quoted 1 line

vport_req_info[idx];

drivers/net/idpf/idpf_vchnl.c new file +24 -0
+	struct virtchnl2_create_vport vport_msg;
+	struct idpf_cmd_info args;
+	int err = -1;
+
+	memset(&vport_msg, 0, sizeof(struct virtchnl2_create_vport));
+	vport_msg.vport_type = vport_req_info->vport_type;
+	vport_msg.txq_model = vport_req_info->txq_model;
+	vport_msg.rxq_model = vport_req_info->rxq_model;
+	vport_msg.num_tx_q = vport_req_info->num_tx_q;
+	vport_msg.num_tx_complq = vport_req_info->num_tx_complq;
+	vport_msg.num_rx_q = vport_req_info->num_rx_q;
+	vport_msg.num_rx_bufq = vport_req_info->num_rx_bufq;
+
+	memset(&args, 0, sizeof(args));
+	args.ops = VIRTCHNL2_OP_CREATE_VPORT;
+	args.in_args = (uint8_t *)&vport_msg;
+	args.in_args_size = sizeof(vport_msg);
+	args.out_buffer = adapter->mbx_resp;
+	args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
+
+	err = idpf_execute_vc_cmd(adapter, &args);
+	if (err) {
+		PMD_DRV_LOG(ERR,
+			    "Failed to execute command of

VIRTCHNL2_OP_CREATE_VPORT");

drivers/net/idpf/idpf_vchnl.c new file +6 -0
+		return err;
+	}
+
+	if (!adapter->vport_recv_info[idx]) {
+		adapter->vport_recv_info[idx] = rte_zmalloc(NULL,
+

IDPF_DFLT_MBX_BUF_SIZE, 0);

drivers/net/idpf/idpf_vchnl.c new file +2 -0
+		if (!adapter->vport_recv_info[idx]) {
+			PMD_INIT_LOG(ERR, "Failed to alloc

vport_recv_info.");

drivers/net/idpf/idpf_vchnl.c new file +26 -0
+			return err;
+		}
+	}
+	rte_memcpy(adapter->vport_recv_info[idx], args.out_buffer,
+		   IDPF_DFLT_MBX_BUF_SIZE);
+	return err;
+}
+
+int
+idpf_destroy_vport(struct idpf_vport *vport) {
+	struct virtchnl2_vport vc_vport;
+	struct idpf_cmd_info args;
+	int err;
+
+	vc_vport.vport_id = vport->vport_id;
+
+	memset(&args, 0, sizeof(args));
+	args.ops = VIRTCHNL2_OP_DESTROY_VPORT;
+	args.in_args = (uint8_t *)&vc_vport;
+	args.in_args_size = sizeof(vc_vport);
+	args.out_buffer = adapter->mbx_resp;
+	args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
+
+	err = idpf_execute_vc_cmd(adapter, &args);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to execute command of

VIRTCHNL2_OP_DESTROY_VPORT");

drivers/net/idpf/idpf_vchnl.c new file +23 -0
+		return err;
+	}
+
+	return err;
+}
+
+int
+idpf_ena_dis_vport(struct idpf_vport *vport, bool enable) {
+	struct virtchnl2_vport vc_vport;
+	struct idpf_cmd_info args;
+	int err;
+
+	vc_vport.vport_id = vport->vport_id;
+	args.ops = enable ? VIRTCHNL2_OP_ENABLE_VPORT :
+			    VIRTCHNL2_OP_DISABLE_VPORT;
+	args.in_args = (u8 *)&vc_vport;
+	args.in_args_size = sizeof(vc_vport);
+	args.out_buffer = adapter->mbx_resp;
+	args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
+
+	err = idpf_execute_vc_cmd(adapter, &args);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to execute command of

VIRTCHNL2_OP_%s_VPORT",

drivers/net/idpf/idpf_vchnl.c new file +6 -0
+			    enable ? "ENABLE" : "DISABLE");
+	}
+
+	return err;
+}
+
drivers/net/idpf/meson.build new file +18 -0
new file mode 100644 index 0000000000..3a84162f93
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2022 Intel
+Corporation
+
+if is_windows
+	build = false
+	reason = 'not supported on Windows'
+	subdir_done()
+endif
+
+subdir('base')
+objs = [base_objs]
+
+sources = files(
+	'idpf_ethdev.c',
+	'idpf_vchnl.c',
+)
+
+includes += include_directories('base')
drivers/net/idpf/version.map new file +3 -0
new file mode 100644 index 0000000000..b7da224860
@@ -0,0 +1,3 @@
+DPDK_22 {
+	local: *;
+};
\ No newline at end of file
drivers/net/meson.build index renamed from drivers/net/meson.build +0 -0

e35652fe63..8910154544 100644

drivers/net/meson.build +1 -1
@@ -28,6 +28,7 @@ drivers = [
         'i40e',
         'iavf',
         'ice',
+        'idpf',
         'igc',
         'ionic',
         'ipn3ke',
--
Quoted 1 line

2.25.1

I'd like to report that this patch is causing a compilation failure over the main tree 22.11-rc2:

this is the failure which I see:
ing-field-initializers -D_GNU_SOURCE -fPIC -march=native -mno-avx512f -mno-avx512f -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -DRTE_LOG_DEFAULT_LOGTYPE=pmd.net.idpf -MD -MQ drivers/libtmp_rte_net_idpf.a.p/net_idpf_idpf_vchnl.c.o -MF drivers/libtmp_rte_net_idpf.a.p/net_idpf_idpf_vchnl.c.o.d -o drivers/libtmp_rte_net_idpf.a.p/net_idpf_idpf_vchnl.c.o -c ../../root/dpdk/drivers/net/idpf/idpf_vchnl.c ../../root/dpdk/drivers/net/idpf/idpf_vchnl.c:142:13: error: comparison of constant 522 with expression of type 'enum virtchnl_ops' is always false [-Werror,-Wtautological-constant-out-of-range-compare]

        if (opcode == VIRTCHNL2_OP_EVENT) {
            ~~~~~~ ^  ~~~~~~~~~~~~~~~~~~

1 error generated.
[1424/2559] Generating eal.sym_chk with a meson_exe.py custom command
ninja: build stopped: subcommand failed.

And it's happening with the CLANG compiler:
clang version 3.4.2 (tags/RELEASE_34/dot2-final)

Kindest regards,
Raslan Darawsheh

#9 lore raw

Re: [PATCH 03/13] net/idpf: support device initialization

02/11/2022 16:31, Raslan Darawsheh:

Quoted 4 lines
Quoted 4 lines

[...]

Quoted 5 lines

I'd like to report that this patch is causing a compilation failure over the main tree 22.11-rc2:

this is the failure which I see:
ing-field-initializers -D_GNU_SOURCE -fPIC -march=native -mno-avx512f -mno-avx512f -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -DRTE_LOG_DEFAULT_LOGTYPE=pmd.net.idpf -MD -MQ drivers/libtmp_rte_net_idpf.a.p/net_idpf_idpf_vchnl.c.o -MF drivers/libtmp_rte_net_idpf.a.p/net_idpf_idpf_vchnl.c.o.d -o drivers/libtmp_rte_net_idpf.a.p/net_idpf_idpf_vchnl.c.o -c ../../root/dpdk/drivers/net/idpf/idpf_vchnl.c ../../root/dpdk/drivers/net/idpf/idpf_vchnl.c:142:13: error: comparison of constant 522 with expression of type 'enum virtchnl_ops' is always false [-Werror,-Wtautological-constant-out-of-range-compare]

Quoted 8 lines
        if (opcode == VIRTCHNL2_OP_EVENT) {
            ~~~~~~ ^  ~~~~~~~~~~~~~~~~~~

1 error generated.
[1424/2559] Generating eal.sym_chk with a meson_exe.py custom command
ninja: build stopped: subcommand failed.

And it's happening with the CLANG compiler:
clang version 3.4.2 (tags/RELEASE_34/dot2-final)

That's unfortunate.
Please Beilei, Xiaoyun, Xiao and Junfeng,
is it something you could fix quickly?
Thanks

#10 lore raw

RE: [PATCH 03/13] net/idpf: support device initialization

In reply to Raslan Darawsheh
Quoted 15 lines

-----Original Message-----
From: Raslan Darawsheh <[email protected]>
Sent: Wednesday, November 2, 2022 11:31 PM
To: Guo, Junfeng <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; Wang, Xiao W <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>
Subject: RE: [PATCH 03/13] net/idpf: support device initialization

Hi,

[snip]

Quoted 22 lines
Quoted 2 lines

--
2.25.1

I'd like to report that this patch is causing a compilation failure over the main tree 22.11-rc2:

this is the failure which I see:
ing-field-initializers -D_GNU_SOURCE -fPIC -march=native -mno-avx512f - mno-avx512f -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API - DRTE_LOG_DEFAULT_LOGTYPE=pmd.net.idpf -MD -MQ drivers/libtmp_rte_net_idpf.a.p/net_idpf_idpf_vchnl.c.o -MF drivers/libtmp_rte_net_idpf.a.p/net_idpf_idpf_vchnl.c.o.d -o drivers/libtmp_rte_net_idpf.a.p/net_idpf_idpf_vchnl.c.o -
c ../../root/dpdk/drivers/net/idpf/idpf_vchnl.c ../../root/dpdk/drivers/net/idpf/idpf_vchnl.c:142:13: error: comparison of constant 522 with expression of type 'enum virtchnl_ops' is always false [- Werror,-Wtautological-constant-out-of-range-compare]

        if (opcode == VIRTCHNL2_OP_EVENT) {
            ~~~~~~ ^  ~~~~~~~~~~~~~~~~~~

1 error generated.
[1424/2559] Generating eal.sym_chk with a meson_exe.py custom command
ninja: build stopped: subcommand failed.

Quoted 5 lines

And it's happening with the CLANG compiler:
clang version 3.4.2 (tags/RELEASE_34/dot2-final)

Kindest regards,
Raslan Darawsheh

Thanks for reporting, it should be fixed with the fix patch https://patches.dpdk.org/project/dpdk/patch/[email protected]/.

BR,
Beilei

#11 lore raw

PATCH 4/13 net/idpf: add queue operations

In reply to Junfeng Guo

Add support for queue operations:
- rx_queue_start
- rx_queue_stop
- tx_queue_start
- tx_queue_stop
- rx_queue_setup
- rx_queue_release
- tx_queue_setup
- tx_queue_release

---
 drivers/net/idpf/idpf_ethdev.c |   53 +-
 drivers/net/idpf/idpf_ethdev.h |    7 +
 drivers/net/idpf/idpf_rxtx.c   | 1264 ++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  182 +++++
 drivers/net/idpf/idpf_vchnl.c  |  503 +++++++++++++
 drivers/net/idpf/meson.build   |    1 +
 6 files changed, 2009 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/idpf/idpf_rxtx.c
 create mode 100644 drivers/net/idpf/idpf_rxtx.h
drivers/net/idpf/idpf_ethdev.c +52 -1
index 87c68226dd..b302e42a9c 100644
@@ -12,6 +12,7 @@
 #include <rte_dev.h>
 
 #include "idpf_ethdev.h"
+#include "idpf_rxtx.h"
 
 #define REPRESENTOR		"representor"
 
@@ -33,10 +34,18 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_start			= idpf_dev_start,
 	.dev_stop			= idpf_dev_stop,
 	.dev_close			= idpf_dev_close,
+	.rx_queue_start			= idpf_rx_queue_start,
+	.rx_queue_stop			= idpf_rx_queue_stop,
+	.tx_queue_start			= idpf_tx_queue_start,
+	.tx_queue_stop			= idpf_tx_queue_stop,
+	.rx_queue_setup			= idpf_rx_queue_setup,
+	.rx_queue_release		= idpf_dev_rx_queue_release,
+	.tx_queue_setup			= idpf_tx_queue_setup,
+	.tx_queue_release		= idpf_dev_tx_queue_release,
 };
 
 static int
-idpf_init_vport_req_info(struct rte_eth_dev *dev)
+idpf_init_vport_req_info(__rte_unused struct rte_eth_dev *dev)
 {
 	struct virtchnl2_create_vport *vport_info;
 	uint16_t idx = adapter->next_vport_idx;
@@ -193,6 +202,39 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static int
+idpf_start_queues(struct rte_eth_dev *dev)
+{
+	struct idpf_rx_queue *rxq;
+	struct idpf_tx_queue *txq;
+	int err = 0;
+	int i;
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		txq = dev->data->tx_queues[i];
+		if (!txq || txq->tx_deferred_start)
+			continue;
+		err = idpf_tx_queue_start(dev, i);
+		if (err) {
+			PMD_DRV_LOG(ERR, "Fail to start Tx queue %u", i);
+			return err;
+		}
+	}
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		rxq = dev->data->rx_queues[i];
+		if (!rxq || rxq->rx_deferred_start)
+			continue;
+		err = idpf_rx_queue_start(dev, i);
+		if (err) {
+			PMD_DRV_LOG(ERR, "Fail to start Rx queue %u", i);
+			return err;
+		}
+	}
+
+	return err;
+}
+
 static int
 idpf_dev_start(struct rte_eth_dev *dev)
 {
@@ -203,6 +245,11 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	vport->stopped = 0;
 
+	if (idpf_start_queues(dev)) {
+		PMD_DRV_LOG(ERR, "Failed to start queues");
+		goto err_mtu;
+	}
+
 	if (idpf_ena_dis_vport(vport, true)) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
 		goto err_vport;
@@ -211,6 +258,8 @@ idpf_dev_start(struct rte_eth_dev *dev)
 	return 0;
 
 err_vport:
+	idpf_stop_queues(dev);
+err_mtu:
 	return -1;
 }
 
@@ -228,6 +277,8 @@ idpf_dev_stop(struct rte_eth_dev *dev)
 	if (idpf_ena_dis_vport(vport, false))
 		PMD_DRV_LOG(ERR, "disable vport failed");
 
+	idpf_stop_queues(dev);
+
 	vport->stopped = 1;
 	dev->data->dev_started = 0;
 
drivers/net/idpf/idpf_ethdev.h +7 -0
index 501f772fa8..25e0c5cae7 100644
@@ -200,6 +200,13 @@ int idpf_check_api_version(struct idpf_adapter *adapter);
 int idpf_get_caps(struct idpf_adapter *adapter);
 int idpf_create_vport(__rte_unused struct rte_eth_dev *dev);
 int idpf_destroy_vport(struct idpf_vport *vport);
+int idpf_config_rxqs(struct idpf_vport *vport);
+int idpf_config_rxq(struct idpf_vport *vport, uint16_t rxq_id);
+int idpf_config_txqs(struct idpf_vport *vport);
+int idpf_config_txq(struct idpf_vport *vport, uint16_t txq_id);
+int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,
+		      bool rx, bool on);
+int idpf_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_ena_dis_vport(struct idpf_vport *vport, bool enable);
 
 #endif /* _IDPF_ETHDEV_H_ */
drivers/net/idpf/idpf_rxtx.c new file +1264 -0

1,264 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h new file +182 -0

182 lines not on this page · raw message

drivers/net/idpf/idpf_vchnl.c +503 -0

515 lines not on this page · raw message

drivers/net/idpf/meson.build +1 -0
index 3a84162f93..fce53ef50c 100644
@@ -12,6 +12,7 @@ objs = [base_objs]
 
 sources = files(
 	'idpf_ethdev.c',
+	'idpf_rxtx.c',
 	'idpf_vchnl.c',
 )
 
Signature · 1 line
2.25.1
#12 lore raw

Re: [PATCH 04/13] net/idpf: add queue operations

drivers/net/idpf/idpf_rxtx.c line 162

Quoted 10 lines · On Wed, 3 Aug 2022 19:30:55 +0800 Junfeng Guo <[email protected]> wrote:
drivers/net/idpf/idpf_rxtx.c new file +10 -0
+static void
+idpf_tx_queue_release(void *txq)
+{
+	struct idpf_tx_queue *q = (struct idpf_tx_queue *)txq;
+
+	if (!q)
+		return;
+
+	if (q->complq)
+		rte_free(q->complq);

null pointer check before calling rte_free is unnecessary. rte_free(NULL) works.

There is even a script used to scan DPDK to fix this.
devtools/cocci/nullfree.cocci

#13 lore raw

RE: [PATCH 04/13] net/idpf: add queue operations

Quoted 14 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, August 3, 2022 23:16
To: Guo, Junfeng <[email protected]>
Cc: Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; [email protected]; Li, Xiaoyun <[email protected]>
Subject: Re: [PATCH 04/13] net/idpf: add queue operations

On Wed, 3 Aug 2022 19:30:55 +0800
Junfeng Guo <[email protected]> wrote:

Quoted 13 lines

drivers/net/idpf/idpf_rxtx.c line 162

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c new file +10 -0
+static void
+idpf_tx_queue_release(void *txq)
+{
+	struct idpf_tx_queue *q = (struct idpf_tx_queue *)txq;
+
+	if (!q)
+		return;
+
+	if (q->complq)
+		rte_free(q->complq);

null pointer check before calling rte_free is unnecessary. rte_free(NULL) works.

Thanks for your review! Will refine this in the patchset of upcoming version.

Quoted 3 lines

There is even a script used to scan DPDK to fix this.
devtools/cocci/nullfree.cocci

#14 lore raw

PATCH 5/13 net/idpf: add support to get device information

In reply to Junfeng Guo

Add dev ops dev_infos_get.

---
 drivers/net/idpf/idpf_ethdev.c | 71 ++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)
drivers/net/idpf/idpf_ethdev.c +71 -0
index b302e42a9c..ab991f9181 100644
@@ -28,6 +28,8 @@ static int idpf_dev_configure(struct rte_eth_dev *dev);
 static int idpf_dev_start(struct rte_eth_dev *dev);
 static int idpf_dev_stop(struct rte_eth_dev *dev);
 static int idpf_dev_close(struct rte_eth_dev *dev);
+static int idpf_dev_info_get(struct rte_eth_dev *dev,
+			     struct rte_eth_dev_info *dev_info);
 
 static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_configure			= idpf_dev_configure,
@@ -42,8 +44,77 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.rx_queue_release		= idpf_dev_rx_queue_release,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.tx_queue_release		= idpf_dev_tx_queue_release,
+	.dev_infos_get			= idpf_dev_info_get,
 };
 
+static int
+idpf_dev_info_get(__rte_unused struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
+{
+	dev_info->max_rx_queues = adapter->caps->max_rx_q;
+	dev_info->max_tx_queues = adapter->caps->max_tx_q;
+	dev_info->min_rx_bufsize = IDPF_MIN_BUF_SIZE;
+	dev_info->max_rx_pktlen = IDPF_MAX_FRAME_SIZE;
+
+	dev_info->max_mtu = dev_info->max_rx_pktlen - IDPF_ETH_OVERHEAD;
+	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
+
+	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
+	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
+		RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
+	dev_info->rx_offload_capa =
+		RTE_ETH_RX_OFFLOAD_VLAN_STRIP		|
+		RTE_ETH_RX_OFFLOAD_QINQ_STRIP		|
+		RTE_ETH_RX_OFFLOAD_IPV4_CKSUM		|
+		RTE_ETH_RX_OFFLOAD_UDP_CKSUM		|
+		RTE_ETH_RX_OFFLOAD_TCP_CKSUM		|
+		RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM	|
+		RTE_ETH_RX_OFFLOAD_SCATTER		|
+		RTE_ETH_RX_OFFLOAD_VLAN_FILTER		|
+		RTE_ETH_RX_OFFLOAD_RSS_HASH;
+
+	dev_info->tx_offload_capa =
+		RTE_ETH_TX_OFFLOAD_VLAN_INSERT		|
+		RTE_ETH_TX_OFFLOAD_QINQ_INSERT		|
+		RTE_ETH_TX_OFFLOAD_IPV4_CKSUM		|
+		RTE_ETH_TX_OFFLOAD_UDP_CKSUM		|
+		RTE_ETH_TX_OFFLOAD_TCP_CKSUM		|
+		RTE_ETH_TX_OFFLOAD_SCTP_CKSUM		|
+		RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM	|
+		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
+		RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO	|
+		RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO		|
+		RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO		|
+		RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO	|
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS		|
+		RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	dev_info->default_rxconf = (struct rte_eth_rxconf) {
+		.rx_free_thresh = IDPF_DEFAULT_RX_FREE_THRESH,
+		.rx_drop_en = 0,
+		.offloads = 0,
+	};
+
+	dev_info->default_txconf = (struct rte_eth_txconf) {
+		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
+		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
+		.offloads = 0,
+	};
+
+	dev_info->rx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = IDPF_MAX_RING_DESC,
+		.nb_min = IDPF_MIN_RING_DESC,
+		.nb_align = IDPF_ALIGN_RING_DESC,
+	};
+
+	dev_info->tx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = IDPF_MAX_RING_DESC,
+		.nb_min = IDPF_MIN_RING_DESC,
+		.nb_align = IDPF_ALIGN_RING_DESC,
+	};
+
+	return 0;
+}
+
 static int
 idpf_init_vport_req_info(__rte_unused struct rte_eth_dev *dev)
 {
Signature · 1 line
2.25.1
#15 lore raw

PATCH 6/13 net/idpf: add support to get packet type

In reply to Junfeng Guo

Add dev ops dev_supported_ptypes_get.

---
 drivers/net/idpf/idpf_ethdev.c |  3 ++
 drivers/net/idpf/idpf_rxtx.c   | 51 ++++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  3 ++
 3 files changed, 57 insertions(+)
drivers/net/idpf/idpf_ethdev.c +3 -0
index ab991f9181..cc70e2e03a 100644
@@ -32,6 +32,7 @@ static int idpf_dev_info_get(struct rte_eth_dev *dev,
 			     struct rte_eth_dev_info *dev_info);
 
 static const struct eth_dev_ops idpf_eth_dev_ops = {
+	.dev_supported_ptypes_get	= idpf_dev_supported_ptypes_get,
 	.dev_configure			= idpf_dev_configure,
 	.dev_start			= idpf_dev_start,
 	.dev_stop			= idpf_dev_stop,
@@ -488,6 +489,8 @@ idpf_adapter_init(struct rte_eth_dev *dev)
 	if (adapter->initialized)
 		return 0;
 
+	idpf_set_default_ptype_table(dev);
+
 	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
 	hw->hw_addr_len = pci_dev->mem_resource[0].len;
 	hw->back = adapter;
drivers/net/idpf/idpf_rxtx.c +51 -0

57 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +3 -0
index 3997082b21..5e57995f8c 100644
@@ -178,5 +178,8 @@ void idpf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 
 void idpf_stop_queues(struct rte_eth_dev *dev);
 
+void idpf_set_default_ptype_table(struct rte_eth_dev *dev);
+const uint32_t *idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev);
+
 #endif /* _IDPF_RXTX_H_ */
 
Signature · 1 line
2.25.1
#16 lore raw

PATCH 7/13 net/idpf: add support to update link status

In reply to Junfeng Guo

Add dev ops link_update.

---
 drivers/net/idpf/idpf_ethdev.c | 22 ++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h |  2 ++
 2 files changed, 24 insertions(+)
drivers/net/idpf/idpf_ethdev.c +22 -0
index cc70e2e03a..668e488843 100644
@@ -31,6 +31,27 @@ static int idpf_dev_close(struct rte_eth_dev *dev);
 static int idpf_dev_info_get(struct rte_eth_dev *dev,
 			     struct rte_eth_dev_info *dev_info);
 
+int
+idpf_dev_link_update(struct rte_eth_dev *dev,
+		     __rte_unused int wait_to_complete)
+{
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;
+	struct rte_eth_link new_link;
+
+	memset(&new_link, 0, sizeof(new_link));
+
+	new_link.link_speed = RTE_ETH_SPEED_NUM_NONE;
+
+	new_link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
+	new_link.link_status = vport->link_up ? RTE_ETH_LINK_UP :
+		RTE_ETH_LINK_DOWN;
+	new_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
+				  RTE_ETH_LINK_SPEED_FIXED);
+
+	return rte_eth_linkstatus_set(dev, &new_link);
+}
+
 static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_supported_ptypes_get	= idpf_dev_supported_ptypes_get,
 	.dev_configure			= idpf_dev_configure,
@@ -46,6 +67,7 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.tx_queue_release		= idpf_dev_tx_queue_release,
 	.dev_infos_get			= idpf_dev_info_get,
+	.link_update			= idpf_dev_link_update,
 };
 
 static int
drivers/net/idpf/idpf_ethdev.h +2 -0
index 25e0c5cae7..130bb7ad2d 100644
@@ -195,6 +195,8 @@ _atomic_set_cmd(struct idpf_adapter *adapter, enum virtchnl_ops ops)
 	return !ret;
 }
 
+int idpf_dev_link_update(struct rte_eth_dev *dev,
+			 __rte_unused int wait_to_complete);
 void idpf_handle_virtchnl_msg(struct rte_eth_dev *dev);
 int idpf_check_api_version(struct idpf_adapter *adapter);
 int idpf_get_caps(struct idpf_adapter *adapter);
Signature · 1 line
2.25.1
#17 lore raw

PATCH 8/13 net/idpf: add basic Rx/Tx datapath

In reply to Junfeng Guo

Add basic RX & TX support in split queue mode and single queue mode. Split queue mode is selected by default.

---
 drivers/net/idpf/idpf_ethdev.c |  69 ++-
 drivers/net/idpf/idpf_rxtx.c   | 896 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  35 ++
 3 files changed, 998 insertions(+), 2 deletions(-)
drivers/net/idpf/idpf_ethdev.c +67 -2
index 668e488843..55ec24872e 100644
@@ -14,12 +14,16 @@
 #include "idpf_ethdev.h"
 #include "idpf_rxtx.h"
 
+#define IDPF_TX_SINGLE_Q	"tx_single"
+#define IDPF_RX_SINGLE_Q	"rx_single"
 #define REPRESENTOR		"representor"
 
 struct idpf_adapter *adapter;
 uint16_t used_vecs_num;
 
 static const char * const idpf_valid_args[] = {
+	IDPF_TX_SINGLE_Q,
+	IDPF_RX_SINGLE_Q,
 	REPRESENTOR,
 	NULL
 };
@@ -157,6 +161,30 @@ idpf_init_vport_req_info(__rte_unused struct rte_eth_dev *dev)
 		(struct virtchnl2_create_vport *)adapter->vport_req_info[idx];
 
 	vport_info->vport_type = rte_cpu_to_le_16(VIRTCHNL2_VPORT_TYPE_DEFAULT);
+	if (!adapter->txq_model) {
+		vport_info->txq_model =
+			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SPLIT);
+		vport_info->num_tx_q = dev->data->nb_tx_queues;
+		vport_info->num_tx_complq =
+			dev->data->nb_tx_queues * IDPF_TX_COMPLQ_PER_GRP;
+	} else {
+		vport_info->txq_model =
+			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SINGLE);
+		vport_info->num_tx_q = dev->data->nb_tx_queues;
+		vport_info->num_tx_complq = 0;
+	}
+	if (!adapter->rxq_model) {
+		vport_info->rxq_model =
+			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SPLIT);
+		vport_info->num_rx_q = dev->data->nb_rx_queues;
+		vport_info->num_rx_bufq =
+			dev->data->nb_rx_queues * IDPF_RX_BUFQ_PER_GRP;
+	} else {
+		vport_info->rxq_model =
+			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SINGLE);
+		vport_info->num_rx_q = dev->data->nb_rx_queues;
+		vport_info->num_rx_bufq = 0;
+	}
 
 	return 0;
 }
@@ -344,6 +372,9 @@ idpf_dev_start(struct rte_eth_dev *dev)
 		goto err_mtu;
 	}
 
+	idpf_set_rx_function(dev);
+	idpf_set_tx_function(dev);
+
 	if (idpf_ena_dis_vport(vport, true)) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
 		goto err_vport;
@@ -394,11 +425,31 @@ idpf_dev_close(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+parse_bool(const char *key, const char *value, void *args)
+{
+	int *i = (int *)args;
+	char *end;
+	int num;
+
+	num = strtoul(value, &end, 10);
+
+	if (num != 0 && num != 1) {
+		PMD_DRV_LOG(WARNING, "invalid value:\"%s\" for key:\"%s\", "
+			"value must be 0 or 1",
+			value, key);
+		return -1;
+	}
+
+	*i = num;
+	return 0;
+}
+
 static int idpf_parse_devargs(struct rte_eth_dev *dev)
 {
 	struct rte_devargs *devargs = dev->device->devargs;
 	struct rte_kvargs *kvlist;
-	int ret = 0;
+	int ret;
 
 	if (!devargs)
 		return 0;
@@ -409,6 +460,17 @@ static int idpf_parse_devargs(struct rte_eth_dev *dev)
 		return -EINVAL;
 	}
 
+	ret = rte_kvargs_process(kvlist, IDPF_TX_SINGLE_Q, &parse_bool,
+				 &adapter->txq_model);
+	if (ret)
+		goto bail;
+
+	ret = rte_kvargs_process(kvlist, IDPF_RX_SINGLE_Q, &parse_bool,
+				 &adapter->rxq_model);
+	if (ret)
+		goto bail;
+
+bail:
 	rte_kvargs_free(kvlist);
 	return ret;
 }
@@ -637,8 +699,11 @@ idpf_dev_init(struct rte_eth_dev *dev, __rte_unused void *init_params)
 	/* for secondary processes, we don't initialise any further as primary
 	 * has already done this work.
 	 */
-	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		idpf_set_rx_function(dev);
+		idpf_set_tx_function(dev);
 		return ret;
+	}
 
 	ret = idpf_adapter_init(dev);
 	if (ret) {
drivers/net/idpf/idpf_rxtx.c +896 -0

900 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +35 -0
index 5e57995f8c..3e79c0ac2a 100644
@@ -42,6 +42,25 @@
 #define IDPF_TSO_MAX_SEG	UINT8_MAX
 #define IDPF_TX_MAX_MTU_SEG     8
 
+#define IDPF_TX_CKSUM_OFFLOAD_MASK (		\
+		RTE_MBUF_F_TX_IP_CKSUM |	\
+		RTE_MBUF_F_TX_L4_MASK |		\
+		RTE_MBUF_F_TX_TCP_SEG)
+
+#define IDPF_TX_OFFLOAD_MASK (			\
+		RTE_MBUF_F_TX_OUTER_IPV6 |	\
+		RTE_MBUF_F_TX_OUTER_IPV4 |	\
+		RTE_MBUF_F_TX_IPV6 |		\
+		RTE_MBUF_F_TX_IPV4 |		\
+		RTE_MBUF_F_TX_VLAN |		\
+		RTE_MBUF_F_TX_IP_CKSUM |	\
+		RTE_MBUF_F_TX_L4_MASK |		\
+		RTE_MBUF_F_TX_TCP_SEG |		\
+		RTE_ETH_TX_OFFLOAD_SECURITY)
+
+#define IDPF_TX_OFFLOAD_NOTSUP_MASK \
+		(RTE_MBUF_F_TX_OFFLOAD_MASK ^ IDPF_TX_OFFLOAD_MASK)
+
 struct idpf_rx_queue {
 	struct idpf_adapter *adapter;	/* the adapter this queue belongs to */
 	struct rte_mempool *mp;		/* mbuf pool to populate Rx ring */
@@ -176,8 +195,24 @@ int idpf_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 int idpf_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 void idpf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 
+uint16_t idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+				uint16_t nb_pkts);
+uint16_t idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+			       uint16_t nb_pkts);
+uint16_t idpf_singleq_recv_pkts_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
+				       uint16_t nb_pkts);
+uint16_t idpf_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+				uint16_t nb_pkts);
+uint16_t idpf_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+			       uint16_t nb_pkts);
+uint16_t idpf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+			uint16_t nb_pkts);
+
 void idpf_stop_queues(struct rte_eth_dev *dev);
 
+void idpf_set_rx_function(struct rte_eth_dev *dev);
+void idpf_set_tx_function(struct rte_eth_dev *dev);
+
 void idpf_set_default_ptype_table(struct rte_eth_dev *dev);
 const uint32_t *idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
Signature · 1 line
2.25.1
#18 lore raw

PATCH 9/13 net/idpf: add support for RSS

In reply to Junfeng Guo

Add RSS support.

---
 drivers/net/idpf/idpf_ethdev.c | 108 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h |  18 ++++++
 drivers/net/idpf/idpf_vchnl.c  |  93 ++++++++++++++++++++++++++++
 3 files changed, 219 insertions(+)
drivers/net/idpf/idpf_ethdev.c +108 -0
index 55ec24872e..0b03ec860a 100644
@@ -85,6 +85,7 @@ idpf_dev_info_get(__rte_unused struct rte_eth_dev *dev, struct rte_eth_dev_info
 	dev_info->max_mtu = dev_info->max_rx_pktlen - IDPF_ETH_OVERHEAD;
 	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
 
+	dev_info->flow_type_rss_offloads = IDPF_RSS_OFFLOAD_ALL;
 	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
 	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
 		RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
@@ -293,6 +294,91 @@ idpf_init_vport(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+idpf_config_rss(struct idpf_vport *vport)
+{
+	int ret;
+
+	ret = idpf_set_rss_key(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS key");
+		return ret;
+	}
+
+	ret = idpf_set_rss_lut(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS lut");
+		return ret;
+	}
+
+	ret = idpf_set_rss_hash(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS hash");
+		return ret;
+	}
+
+	return ret;
+}
+
+static int
+idpf_init_rss(struct idpf_vport *vport)
+{
+	struct rte_eth_rss_conf *rss_conf;
+	uint16_t i, nb_q, lut_size;
+	int ret = 0;
+
+	rss_conf = &vport->dev_data->dev_conf.rx_adv_conf.rss_conf;
+	nb_q = vport->num_rx_q;
+
+	vport->rss_key = (uint8_t *)rte_zmalloc("rss_key",
+					     vport->rss_key_size, 0);
+	if (!vport->rss_key) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS key");
+		ret = -ENOMEM;
+		goto err_key;
+	}
+
+	lut_size = vport->rss_lut_size;
+	vport->rss_lut = (uint32_t *)rte_zmalloc("rss_lut",
+					      sizeof(uint32_t) * lut_size, 0);
+	if (!vport->rss_lut) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS lut");
+		ret = -ENOMEM;
+		goto err_lut;
+	}
+
+	if (!rss_conf->rss_key) {
+		for (i = 0; i < vport->rss_key_size; i++)
+			vport->rss_key[i] = (uint8_t)rte_rand();
+	} else {
+		rte_memcpy(vport->rss_key, rss_conf->rss_key,
+			   RTE_MIN(rss_conf->rss_key_len,
+				   vport->rss_key_size));
+	}
+
+	for (i = 0; i < lut_size; i++)
+		vport->rss_lut[i] = i % nb_q;
+
+	vport->rss_hf = IECM_DEFAULT_RSS_HASH_EXPANDED;
+
+	ret = idpf_config_rss(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS");
+		goto err_cfg;
+	}
+
+	return ret;
+
+err_cfg:
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+err_lut:
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+err_key:
+	return ret;
+}
+
 static int
 idpf_dev_configure(struct rte_eth_dev *dev)
 {
@@ -300,6 +386,10 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 		(struct idpf_vport *)dev->data->dev_private;
 	int ret = 0;
 
+	if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+		dev->data->dev_conf.rxmode.offloads |=
+			RTE_ETH_RX_OFFLOAD_RSS_HASH;
+
 	ret = idpf_init_vport_req_info(dev);
 	if (ret) {
 		PMD_INIT_LOG(ERR, "Failed to init vport req_info.");
@@ -321,6 +411,14 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 	rte_ether_addr_copy((struct rte_ether_addr *)vport->default_mac_addr,
 			    &dev->data->mac_addrs[0]);
 
+	if (adapter->caps->rss_caps) {
+		ret = idpf_init_rss(vport);
+		if (ret) {
+			PMD_INIT_LOG(ERR, "Failed to init rss");
+			return ret;
+		}
+	}
+
 	return ret;
 }
 
@@ -422,6 +520,16 @@ idpf_dev_close(struct rte_eth_dev *dev)
 	idpf_dev_stop(dev);
 	idpf_destroy_vport(vport);
 
+	if (vport->rss_lut) {
+		rte_free(vport->rss_lut);
+		vport->rss_lut = NULL;
+	}
+
+	if (vport->rss_key) {
+		rte_free(vport->rss_key);
+		vport->rss_key = NULL;
+	}
+
 	return 0;
 }
 
drivers/net/idpf/idpf_ethdev.h +18 -0
index 130bb7ad2d..22096c4185 100644
@@ -47,6 +47,20 @@
 #define IDPF_ETH_OVERHEAD \
 	(RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + IDPF_VLAN_TAG_SIZE * 2)
 
+#define IDPF_RSS_OFFLOAD_ALL ( \
+	RTE_ETH_RSS_IPV4		| \
+	RTE_ETH_RSS_FRAG_IPV4		| \
+	RTE_ETH_RSS_NONFRAG_IPV4_TCP	| \
+	RTE_ETH_RSS_NONFRAG_IPV4_UDP	| \
+	RTE_ETH_RSS_NONFRAG_IPV4_SCTP	| \
+	RTE_ETH_RSS_NONFRAG_IPV4_OTHER	| \
+	RTE_ETH_RSS_IPV6		| \
+	RTE_ETH_RSS_FRAG_IPV6		| \
+	RTE_ETH_RSS_NONFRAG_IPV6_TCP	| \
+	RTE_ETH_RSS_NONFRAG_IPV6_UDP	| \
+	RTE_ETH_RSS_NONFRAG_IPV6_SCTP	| \
+	RTE_ETH_RSS_NONFRAG_IPV6_OTHER)
+
 #ifndef ETH_ADDR_LEN
 #define ETH_ADDR_LEN		6
 #endif
@@ -202,6 +216,9 @@ int idpf_check_api_version(struct idpf_adapter *adapter);
 int idpf_get_caps(struct idpf_adapter *adapter);
 int idpf_create_vport(__rte_unused struct rte_eth_dev *dev);
 int idpf_destroy_vport(struct idpf_vport *vport);
+int idpf_set_rss_key(struct idpf_vport *vport);
+int idpf_set_rss_lut(struct idpf_vport *vport);
+int idpf_set_rss_hash(struct idpf_vport *vport);
 int idpf_config_rxqs(struct idpf_vport *vport);
 int idpf_config_rxq(struct idpf_vport *vport, uint16_t rxq_id);
 int idpf_config_txqs(struct idpf_vport *vport);
@@ -212,3 +229,4 @@ int idpf_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_ena_dis_vport(struct idpf_vport *vport, bool enable);
 
 #endif /* _IDPF_ETHDEV_H_ */
+
drivers/net/idpf/idpf_vchnl.c +93 -0

99 lines not on this page · raw message

Signature · 1 line
2.25.1
#19 lore raw

PATCH 10/13 net/idpf: add mtu configuration

In reply to Junfeng Guo

Add dev ops mtu_set.

---
 drivers/net/idpf/idpf_ethdev.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/net/idpf/idpf_ethdev.c +21 -0
index 0b03ec860a..4b8e3c4d5b 100644
@@ -34,6 +34,7 @@ static int idpf_dev_stop(struct rte_eth_dev *dev);
 static int idpf_dev_close(struct rte_eth_dev *dev);
 static int idpf_dev_info_get(struct rte_eth_dev *dev,
 			     struct rte_eth_dev_info *dev_info);
+static int idpf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
 int
 idpf_dev_link_update(struct rte_eth_dev *dev,
@@ -72,6 +73,7 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.tx_queue_release		= idpf_dev_tx_queue_release,
 	.dev_infos_get			= idpf_dev_info_get,
 	.link_update			= idpf_dev_link_update,
+	.mtu_set			= idpf_dev_mtu_set,
 };
 
 static int
@@ -143,6 +145,18 @@ idpf_dev_info_get(__rte_unused struct rte_eth_dev *dev, struct rte_eth_dev_info
 	return 0;
 }
 
+static int
+idpf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu __rte_unused)
+{
+	/* mtu setting is forbidden if port is start */
+	if (dev->data->dev_started) {
+		PMD_DRV_LOG(ERR, "port must be stopped before configuration");
+		return -EBUSY;
+	}
+
+	return 0;
+}
+
 static int
 idpf_init_vport_req_info(__rte_unused struct rte_eth_dev *dev)
 {
@@ -465,6 +479,13 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	vport->stopped = 0;
 
+	if (dev->data->mtu > vport->max_mtu) {
+		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
+		goto err_mtu;
+	}
+
+	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
+
 	if (idpf_start_queues(dev)) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
 		goto err_mtu;
Signature · 1 line
2.25.1
#20 lore raw

PATCH 11/13 net/idpf: add hw statistics

In reply to Junfeng Guo

Add hardware packets/bytes statisticsi query and reset.

---
 drivers/net/idpf/idpf_ethdev.c | 82 +++++++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_ethdev.h |  2 +
 drivers/net/idpf/idpf_vchnl.c  | 26 +++++++++++
 3 files changed, 109 insertions(+), 1 deletion(-)
drivers/net/idpf/idpf_ethdev.c +81 -1
index 4b8e3c4d5b..b934488d0b 100644
@@ -35,6 +35,9 @@ static int idpf_dev_close(struct rte_eth_dev *dev);
 static int idpf_dev_info_get(struct rte_eth_dev *dev,
 			     struct rte_eth_dev_info *dev_info);
 static int idpf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
+static int idpf_dev_stats_get(struct rte_eth_dev *dev,
+			struct rte_eth_stats *stats);
+static int idpf_dev_stats_reset(struct rte_eth_dev *dev);
 
 int
 idpf_dev_link_update(struct rte_eth_dev *dev,
@@ -74,6 +77,8 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_infos_get			= idpf_dev_info_get,
 	.link_update			= idpf_dev_link_update,
 	.mtu_set			= idpf_dev_mtu_set,
+	.stats_get				= idpf_dev_stats_get,
+	.stats_reset			= idpf_dev_stats_reset,
 };
 
 static int
@@ -157,8 +162,79 @@ idpf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu __rte_unused)
 	return 0;
 }
 
+static void
+idpf_stat_update(uint64_t *offset, uint64_t *stat)
+{
+	*stat = *stat - *offset;
+}
+
+
+static void
+idpf_update_stats(struct virtchnl2_vport_stats *oes, struct virtchnl2_vport_stats *nes)
+{
+	idpf_stat_update(&oes->rx_bytes, &nes->rx_bytes);
+	idpf_stat_update(&oes->rx_unicast, &nes->rx_unicast);
+	idpf_stat_update(&oes->rx_multicast, &nes->rx_multicast);
+	idpf_stat_update(&oes->rx_broadcast, &nes->rx_broadcast);
+	idpf_stat_update(&oes->rx_discards, &nes->rx_discards);
+	idpf_stat_update(&oes->tx_bytes, &nes->tx_bytes);
+	idpf_stat_update(&oes->tx_unicast, &nes->tx_unicast);
+	idpf_stat_update(&oes->tx_multicast, &nes->tx_multicast);
+	idpf_stat_update(&oes->tx_broadcast, &nes->tx_broadcast);
+	idpf_stat_update(&oes->tx_errors, &nes->tx_errors);
+	idpf_stat_update(&oes->tx_discards, &nes->tx_discards);
+}
+
 static int
-idpf_init_vport_req_info(__rte_unused struct rte_eth_dev *dev)
+idpf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;
+	struct virtchnl2_vport_stats *pstats = NULL;
+	int ret;
+
+	ret = idpf_query_stats(vport, &pstats);
+	if (ret == 0) {
+		uint8_t crc_stats_len = (dev->data->dev_conf.rxmode.offloads &
+					 RTE_ETH_RX_OFFLOAD_KEEP_CRC) ? 0 :
+					 RTE_ETHER_CRC_LEN;
+		idpf_update_stats(&vport->eth_stats_offset, pstats);
+		stats->ipackets = pstats->rx_unicast + pstats->rx_multicast +
+				pstats->rx_broadcast - pstats->rx_discards;
+		stats->opackets = pstats->tx_broadcast + pstats->tx_multicast +
+						pstats->tx_unicast;
+		stats->imissed = pstats->rx_discards;
+		stats->oerrors = pstats->tx_errors + pstats->tx_discards;
+		stats->ibytes = pstats->rx_bytes;
+		stats->ibytes -= stats->ipackets * crc_stats_len;
+		stats->obytes = pstats->tx_bytes;
+	} else {
+		PMD_DRV_LOG(ERR, "Get statistics failed");
+	}
+	return ret;
+}
+
+
+static int
+idpf_dev_stats_reset(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;
+	struct virtchnl2_vport_stats *pstats = NULL;
+	int ret;
+
+	ret = idpf_query_stats(vport, &pstats);
+	if (ret != 0)
+		return ret;
+
+	/* set stats offset base on current values */
+	vport->eth_stats_offset = *pstats;
+
+	return 0;
+}
+
+static int
+idpf_init_vport_req_info(struct rte_eth_dev *dev)
 {
 	struct virtchnl2_create_vport *vport_info;
 	uint16_t idx = adapter->next_vport_idx;
@@ -499,6 +575,10 @@ idpf_dev_start(struct rte_eth_dev *dev)
 		goto err_vport;
 	}
 
+	if (idpf_dev_stats_reset(dev)) {
+		PMD_DRV_LOG(ERR, "Failed to reset stats");
+		goto err_vport;
+	}
 	return 0;
 
 err_vport:
drivers/net/idpf/idpf_ethdev.h +2 -0
index 22096c4185..c0cbf4c3c6 100644
@@ -227,6 +227,8 @@ int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,
 		      bool rx, bool on);
 int idpf_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_ena_dis_vport(struct idpf_vport *vport, bool enable);
+int idpf_query_stats(struct idpf_vport *vport,
+			struct virtchnl2_vport_stats **pstats);
 
 #endif /* _IDPF_ETHDEV_H_ */
 
drivers/net/idpf/idpf_vchnl.c +26 -0
index 07b220016f..563f8f649e 100644
@@ -219,6 +219,7 @@ idpf_execute_vc_cmd(struct idpf_adapter *adapter, struct idpf_cmd_info *args)
 	case VIRTCHNL2_OP_DISABLE_QUEUES:
 	case VIRTCHNL2_OP_ENABLE_VPORT:
 	case VIRTCHNL2_OP_DISABLE_VPORT:
+	case VIRTCHNL2_OP_GET_STATS:
 		/* for init virtchnl ops, need to poll the response */
 		do {
 			result = idpf_read_msg_from_ipf(adapter,
@@ -1070,3 +1071,28 @@ idpf_ena_dis_vport(struct idpf_vport *vport, bool enable)
 	return err;
 }
 
+int
+idpf_query_stats(struct idpf_vport *vport,
+		struct virtchnl2_vport_stats **pstats)
+{
+	struct virtchnl2_vport vc_vport;
+	struct idpf_cmd_info args;
+	int err;
+
+	vc_vport.vport_id = vport->vport_id;
+	args.ops = VIRTCHNL2_OP_GET_STATS;
+	args.in_args = (u8 *)&vc_vport;
+	args.in_args_size = sizeof(vc_vport);
+	args.out_buffer = adapter->mbx_resp;
+	args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
+
+	err = idpf_execute_vc_cmd(adapter, &args);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_GET_STATS");
+		*pstats = NULL;
+		return err;
+	}
+	*pstats = (struct virtchnl2_vport_stats *)args.out_buffer;
+	return 0;
+}
+
Signature · 1 line
2.25.1
#21 lore raw

PATCH 12/13 net/idpf: support write back based on ITR expire

In reply to Junfeng Guo

Force write-backs by setting WB_ON_ITR bit in DYN_CTL register, so that the packets can be received once at a time.

---
 drivers/net/idpf/idpf_ethdev.c | 117 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h |   8 +++
 drivers/net/idpf/idpf_vchnl.c  | 108 ++++++++++++++++++++++++++++++
 3 files changed, 233 insertions(+)
drivers/net/idpf/idpf_ethdev.c +117 -0
index b934488d0b..1e9564a5a9 100644
@@ -512,6 +512,87 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static int
+idpf_config_rx_queues_irqs(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport =
+		(struct idpf_vport *)dev->data->dev_private;
+	struct virtchnl2_queue_vector *qv_map;
+	struct iecm_hw *hw = &adapter->hw;
+	uint32_t dynctl_reg_start;
+	uint32_t itrn_reg_start;
+	uint32_t dynctl_val, itrn_val;
+	uint16_t i;
+
+	qv_map = rte_zmalloc("qv_map",
+			dev->data->nb_rx_queues *
+			sizeof(struct virtchnl2_queue_vector), 0);
+	if (!qv_map) {
+		PMD_DRV_LOG(ERR, "Failed to allocate %d queue-vector map",
+			    dev->data->nb_rx_queues);
+		goto qv_map_alloc_err;
+	}
+
+	/* Rx interrupt disabled, Map interrupt only for writeback */
+
+	/* The capability flags adapter->caps->other_caps here should be
+	 * compared with bit VIRTCHNL2_CAP_WB_ON_ITR. The if condition should
+	 * be updated when the FW can return correct flag bits.
+	 */
+	if (adapter->caps->other_caps) {
+		dynctl_reg_start = vport->recv_vectors->vchunks.vchunks->dynctl_reg_start;
+		itrn_reg_start = vport->recv_vectors->vchunks.vchunks->itrn_reg_start;
+		dynctl_val = IECM_READ_REG(hw, dynctl_reg_start);
+		PMD_DRV_LOG(DEBUG, "Value of dynctl_reg_start is 0x%x", dynctl_val);
+		itrn_val = IECM_READ_REG(hw, itrn_reg_start);
+		PMD_DRV_LOG(DEBUG, "Value of itrn_reg_start is 0x%x", itrn_val);
+		/* Force write-backs by setting WB_ON_ITR bit in DYN_CTL
+		 * register. WB_ON_ITR and INTENA are mutually exclusive
+		 * bits. Setting WB_ON_ITR bits means TX and RX Descs
+		 * are writen back based on ITR expiration irrespective
+		 * of INTENA setting.
+		 */
+		/* TBD: need to tune INTERVAL value for better performance. */
+		if (itrn_val)
+			IECM_WRITE_REG(hw,
+				       dynctl_reg_start,
+				       VIRTCHNL2_ITR_IDX_0  <<
+				       PF_GLINT_DYN_CTL_ITR_INDX_S |
+				       PF_GLINT_DYN_CTL_WB_ON_ITR_M |
+				       itrn_val <<
+				       PF_GLINT_DYN_CTL_INTERVAL_S);
+		else
+			IECM_WRITE_REG(hw,
+				       dynctl_reg_start,
+				       VIRTCHNL2_ITR_IDX_0  <<
+				       PF_GLINT_DYN_CTL_ITR_INDX_S |
+				       PF_GLINT_DYN_CTL_WB_ON_ITR_M |
+				       IDPF_DFLT_INTERVAL <<
+				       PF_GLINT_DYN_CTL_INTERVAL_S);
+	}
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		/* map all queues to the same vector */
+		qv_map[i].queue_id = vport->chunks_info.rx_start_qid + i;
+		qv_map[i].vector_id =
+			vport->recv_vectors->vchunks.vchunks->start_vector_id;
+	}
+	vport->qv_map = qv_map;
+
+	if (idpf_config_irq_map_unmap(vport, true)) {
+		PMD_DRV_LOG(ERR, "config interrupt mapping failed");
+		goto config_irq_map_err;
+	}
+
+	return 0;
+
+config_irq_map_err:
+	rte_free(vport->qv_map);
+	vport->qv_map = NULL;
+
+qv_map_alloc_err:
+	return -1;
+}
+
 static int
 idpf_start_queues(struct rte_eth_dev *dev)
 {
@@ -550,6 +631,9 @@ idpf_dev_start(struct rte_eth_dev *dev)
 {
 	struct idpf_vport *vport =
 		(struct idpf_vport *)dev->data->dev_private;
+	uint16_t num_allocated_vectors =
+		adapter->caps->num_allocated_vectors;
+	uint16_t req_vecs_num;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -562,6 +646,23 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
 
+	req_vecs_num = IDPF_DFLT_Q_VEC_NUM;
+	if (req_vecs_num + used_vecs_num > num_allocated_vectors) {
+		PMD_DRV_LOG(ERR, "The accumulated request vectors' number should be less than %d",
+			    num_allocated_vectors);
+		goto err_mtu;
+	}
+	if (idpf_alloc_vectors(vport, req_vecs_num)) {
+		PMD_DRV_LOG(ERR, "Failed to allocate interrupt vectors");
+		goto err_mtu;
+	}
+	used_vecs_num += req_vecs_num;
+
+	if (idpf_config_rx_queues_irqs(dev)) {
+		PMD_DRV_LOG(ERR, "Failed to configure irqs");
+		goto err_mtu;
+	}
+
 	if (idpf_start_queues(dev)) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
 		goto err_mtu;
@@ -603,6 +704,12 @@ idpf_dev_stop(struct rte_eth_dev *dev)
 
 	idpf_stop_queues(dev);
 
+	if (idpf_config_irq_map_unmap(vport, false))
+		PMD_DRV_LOG(ERR, "config interrupt unmapping failed");
+
+	if (idpf_dealloc_vectors(vport))
+		PMD_DRV_LOG(ERR, "deallocate interrupt vectors failed");
+
 	vport->stopped = 1;
 	dev->data->dev_started = 0;
 
@@ -631,6 +738,16 @@ idpf_dev_close(struct rte_eth_dev *dev)
 		vport->rss_key = NULL;
 	}
 
+	if (vport->recv_vectors) {
+		rte_free(vport->recv_vectors);
+		vport->recv_vectors = NULL;
+	}
+
+	if (vport->qv_map) {
+		rte_free(vport->qv_map);
+		vport->qv_map = NULL;
+	}
+
 	return 0;
 }
 
drivers/net/idpf/idpf_ethdev.h +8 -0
index c0cbf4c3c6..32520c03bb 100644
@@ -119,6 +119,11 @@ struct idpf_vport {
 	uint8_t *rss_key;
 	uint64_t rss_hf;
 
+	/* MSIX info*/
+	struct virtchnl2_queue_vector *qv_map; /* queue vector mapping */
+	uint16_t max_vectors;
+	struct virtchnl2_alloc_vectors *recv_vectors;
+
 	/* Chunk info */
 	struct idpf_chunks_info chunks_info;
 
@@ -229,6 +234,9 @@ int idpf_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_ena_dis_vport(struct idpf_vport *vport, bool enable);
 int idpf_query_stats(struct idpf_vport *vport,
 			struct virtchnl2_vport_stats **pstats);
+int idpf_config_irq_map_unmap(struct idpf_vport *vport, bool map);
+int idpf_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors);
+int idpf_dealloc_vectors(struct idpf_vport *vport);
 
 #endif /* _IDPF_ETHDEV_H_ */
 
drivers/net/idpf/idpf_vchnl.c +108 -0

120 lines not on this page · raw message

Signature · 1 line
2.25.1
#22 lore raw

PATCH 13/13 net/idpf: add AVX512 data path for single queue model

In reply to Junfeng Guo

Add support of AVX512 vector data path for single queue model.

---
 drivers/net/idpf/idpf_ethdev.c          |   5 +
 drivers/net/idpf/idpf_ethdev.h          |   5 +
 drivers/net/idpf/idpf_rxtx.c            | 137 ++++
 drivers/net/idpf/idpf_rxtx.h            |   8 +
 drivers/net/idpf/idpf_rxtx_vec_avx512.c | 917 ++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx_vec_common.h |  85 +++
 drivers/net/idpf/meson.build            |  28 +
 7 files changed, 1185 insertions(+)
 create mode 100644 drivers/net/idpf/idpf_rxtx_vec_avx512.c
 create mode 100644 drivers/net/idpf/idpf_rxtx_vec_common.h
drivers/net/idpf/idpf_ethdev.c +5 -0
index 1e9564a5a9..590f1b25aa 100644
@@ -147,6 +147,11 @@ idpf_dev_info_get(__rte_unused struct rte_eth_dev *dev, struct rte_eth_dev_info
 		.nb_align = IDPF_ALIGN_RING_DESC,
 	};
 
+	dev_info->default_rxportconf.burst_size = IDPF_RX_MAX_BURST;
+	dev_info->default_txportconf.burst_size = IDPF_TX_MAX_BURST;
+	dev_info->default_rxportconf.nb_queues = 1;
+	dev_info->default_txportconf.nb_queues = 1;
+
 	return 0;
 }
 
drivers/net/idpf/idpf_ethdev.h +5 -0
index 32520c03bb..7ad60f36a8 100644
@@ -164,6 +164,11 @@ struct idpf_adapter {
 
 	bool initialized;
 	bool stopped;
+
+	bool rx_vec_allowed;
+	bool tx_vec_allowed;
+	bool rx_use_avx512;
+	bool tx_use_avx512;
 };
 
 extern struct idpf_adapter *adapter;
drivers/net/idpf/idpf_rxtx.c +137 -0

174 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +8 -0
index 3e79c0ac2a..dad048a6dc 100644
@@ -114,6 +114,10 @@ struct idpf_tx_entry {
 	uint16_t last_id;
 };
 
+struct idpf_tx_vec_entry {
+	struct rte_mbuf *mbuf;
+};
+
 /* Structure associated with each TX queue. */
 struct idpf_tx_queue {
 	const struct rte_memzone *mz;		/* memzone for Tx ring */
@@ -205,8 +209,12 @@ uint16_t idpf_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 				uint16_t nb_pkts);
 uint16_t idpf_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			       uint16_t nb_pkts);
+uint16_t idpf_singleq_xmit_pkts_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
+				      uint16_t nb_pkts);
+int idpf_singleq_tx_vec_setup_avx512(struct idpf_tx_queue *txq);
 uint16_t idpf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			uint16_t nb_pkts);
+int idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq);
 
 void idpf_stop_queues(struct rte_eth_dev *dev);
 
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +917 -0

917 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx_vec_common.h new file +85 -0

85 lines not on this page · raw message

drivers/net/idpf/meson.build +28 -0
index fce53ef50c..403f5e45a0 100644
@@ -16,4 +16,32 @@ sources = files(
 	'idpf_vchnl.c',
 )
 
+if arch_subdir == 'x86'
+	idpf_avx512_cpu_support = (
+		cc.get_define('__AVX512F__', args: machine_args) != '' and
+		cc.get_define('__AVX512BW__', args: machine_args) != ''
+	)
+
+	idpf_avx512_cc_support = (
+		not machine_args.contains('-mno-avx512f') and
+		cc.has_argument('-mavx512f') and
+		cc.has_argument('-mavx512bw')
+	)
+
+	if idpf_avx512_cpu_support == true or idpf_avx512_cc_support == true
+		cflags += ['-DCC_AVX512_SUPPORT']
+		avx512_args = [cflags, '-mavx512f', '-mavx512bw']
+		if cc.has_argument('-march=skylake-avx512')
+			avx512_args += '-march=skylake-avx512'
+		endif
+		idpf_avx512_lib = static_library('idpf_avx512_lib',
+			'idpf_rxtx_vec_avx512.c',
+			dependencies: [static_rte_ethdev,
+			static_rte_kvargs, static_rte_hash],
+			include_directories: includes,
+			c_args: avx512_args)
+		objs += idpf_avx512_lib.extract_objects('idpf_rxtx_vec_avx512.c')
+	endif
+endif
+
 includes += include_directories('base')
Signature · 1 line
2.25.1
#23 lore raw

v2 cover add support for idpf PMD in DPDK

In reply to Junfeng Guo

This patchset introduced the idpf (Infrastructure Data Path Function) PMD [*EXPERIMENTAL*] in DPDK for Intel Device ID of 0x1452.

v2:
fixed some coding style issues and did some refactors.

Junfeng Guo (14):
net/idpf/base: introduce base code net/idpf/base: add logs and OS specific implementation net/idpf: add support for device initialization net/idpf: add support for queue operations net/idpf: add support for device information get net/idpf: add support for packet type get net/idpf: add support for link status update net/idpf: add support for basic Rx/Tx datapath net/idpf: add support for RSS
net/idpf: add support for mtu configuration net/idpf: add support for hw statistics net/idpf: add support for write back based on ITR expire net/idpf: add AVX512 data path for single queue model net/idpf: add support for timestamp offload

 drivers/net/idpf/base/iecm_alloc.h            |   22 +
 drivers/net/idpf/base/iecm_common.c           |  359 +++
 drivers/net/idpf/base/iecm_controlq.c         |  662 ++++
 drivers/net/idpf/base/iecm_controlq.h         |  214 ++
 drivers/net/idpf/base/iecm_controlq_api.h     |  227 ++
 drivers/net/idpf/base/iecm_controlq_setup.c   |  179 ++
 drivers/net/idpf/base/iecm_devids.h           |   18 +
 drivers/net/idpf/base/iecm_lan_pf_regs.h      |  134 +
 drivers/net/idpf/base/iecm_lan_txrx.h         |  428 +++
 drivers/net/idpf/base/iecm_lan_vf_regs.h      |  114 +
 drivers/net/idpf/base/iecm_osdep.h            |  365 +++
 drivers/net/idpf/base/iecm_prototype.h        |   45 +
 drivers/net/idpf/base/iecm_type.h             |  106 +
 drivers/net/idpf/base/meson.build             |   27 +
 drivers/net/idpf/base/siov_regs.h             |   41 +
 drivers/net/idpf/base/virtchnl.h              | 2743 +++++++++++++++++
 drivers/net/idpf/base/virtchnl2.h             | 1411 +++++++++
 drivers/net/idpf/base/virtchnl2_lan_desc.h    |  603 ++++
 drivers/net/idpf/base/virtchnl_inline_ipsec.h |  567 ++++
 drivers/net/idpf/idpf_ethdev.c                | 1341 ++++++++
 drivers/net/idpf/idpf_ethdev.h                |  270 ++
 drivers/net/idpf/idpf_logs.h                  |   38 +
 drivers/net/idpf/idpf_rxtx.c                  | 2393 ++++++++++++++
 drivers/net/idpf/idpf_rxtx.h                  |  322 ++
 drivers/net/idpf/idpf_rxtx_vec_avx512.c       |  917 ++++++
 drivers/net/idpf/idpf_rxtx_vec_common.h       |   89 +
 drivers/net/idpf/idpf_vchnl.c                 | 1470 +++++++++
 drivers/net/idpf/meson.build                  |   48 +
 drivers/net/idpf/version.map                  |    3 +
 drivers/net/meson.build                       |    1 +
 30 files changed, 15157 insertions(+)
 create mode 100644 drivers/net/idpf/base/iecm_alloc.h
 create mode 100644 drivers/net/idpf/base/iecm_common.c
 create mode 100644 drivers/net/idpf/base/iecm_controlq.c
 create mode 100644 drivers/net/idpf/base/iecm_controlq.h
 create mode 100644 drivers/net/idpf/base/iecm_controlq_api.h
 create mode 100644 drivers/net/idpf/base/iecm_controlq_setup.c
 create mode 100644 drivers/net/idpf/base/iecm_devids.h
 create mode 100644 drivers/net/idpf/base/iecm_lan_pf_regs.h
 create mode 100644 drivers/net/idpf/base/iecm_lan_txrx.h
 create mode 100644 drivers/net/idpf/base/iecm_lan_vf_regs.h
 create mode 100644 drivers/net/idpf/base/iecm_osdep.h
 create mode 100644 drivers/net/idpf/base/iecm_prototype.h
 create mode 100644 drivers/net/idpf/base/iecm_type.h
 create mode 100644 drivers/net/idpf/base/meson.build
 create mode 100644 drivers/net/idpf/base/siov_regs.h
 create mode 100644 drivers/net/idpf/base/virtchnl.h
 create mode 100644 drivers/net/idpf/base/virtchnl2.h
 create mode 100644 drivers/net/idpf/base/virtchnl2_lan_desc.h
 create mode 100644 drivers/net/idpf/base/virtchnl_inline_ipsec.h
 create mode 100644 drivers/net/idpf/idpf_ethdev.c
 create mode 100644 drivers/net/idpf/idpf_ethdev.h
 create mode 100644 drivers/net/idpf/idpf_logs.h
 create mode 100644 drivers/net/idpf/idpf_rxtx.c
 create mode 100644 drivers/net/idpf/idpf_rxtx.h
 create mode 100644 drivers/net/idpf/idpf_rxtx_vec_avx512.c
 create mode 100644 drivers/net/idpf/idpf_rxtx_vec_common.h
 create mode 100644 drivers/net/idpf/idpf_vchnl.c
 create mode 100644 drivers/net/idpf/meson.build
 create mode 100644 drivers/net/idpf/version.map
Signature · 1 line
2.25.1
#24 lore raw

PATCH v2 1/14 net/idpf/base: introduce base code

Introduce base code for IDPF (Infrastructure Data Path Function) PMD.

---
 drivers/net/idpf/base/iecm_alloc.h            |   22 +
 drivers/net/idpf/base/iecm_common.c           |  359 +++
 drivers/net/idpf/base/iecm_controlq.c         |  662 ++++
 drivers/net/idpf/base/iecm_controlq.h         |  214 ++
 drivers/net/idpf/base/iecm_controlq_api.h     |  227 ++
 drivers/net/idpf/base/iecm_controlq_setup.c   |  179 ++
 drivers/net/idpf/base/iecm_devids.h           |   18 +
 drivers/net/idpf/base/iecm_lan_pf_regs.h      |  134 +
 drivers/net/idpf/base/iecm_lan_txrx.h         |  428 +++
 drivers/net/idpf/base/iecm_lan_vf_regs.h      |  114 +
 drivers/net/idpf/base/iecm_prototype.h        |   45 +
 drivers/net/idpf/base/iecm_type.h             |  106 +
 drivers/net/idpf/base/meson.build             |   27 +
 drivers/net/idpf/base/siov_regs.h             |   41 +
 drivers/net/idpf/base/virtchnl.h              | 2743 +++++++++++++++++
 drivers/net/idpf/base/virtchnl2.h             | 1411 +++++++++
 drivers/net/idpf/base/virtchnl2_lan_desc.h    |  603 ++++
 drivers/net/idpf/base/virtchnl_inline_ipsec.h |  567 ++++
 18 files changed, 7900 insertions(+)
 create mode 100644 drivers/net/idpf/base/iecm_alloc.h
 create mode 100644 drivers/net/idpf/base/iecm_common.c
 create mode 100644 drivers/net/idpf/base/iecm_controlq.c
 create mode 100644 drivers/net/idpf/base/iecm_controlq.h
 create mode 100644 drivers/net/idpf/base/iecm_controlq_api.h
 create mode 100644 drivers/net/idpf/base/iecm_controlq_setup.c
 create mode 100644 drivers/net/idpf/base/iecm_devids.h
 create mode 100644 drivers/net/idpf/base/iecm_lan_pf_regs.h
 create mode 100644 drivers/net/idpf/base/iecm_lan_txrx.h
 create mode 100644 drivers/net/idpf/base/iecm_lan_vf_regs.h
 create mode 100644 drivers/net/idpf/base/iecm_prototype.h
 create mode 100644 drivers/net/idpf/base/iecm_type.h
 create mode 100644 drivers/net/idpf/base/meson.build
 create mode 100644 drivers/net/idpf/base/siov_regs.h
 create mode 100644 drivers/net/idpf/base/virtchnl.h
 create mode 100644 drivers/net/idpf/base/virtchnl2.h
 create mode 100644 drivers/net/idpf/base/virtchnl2_lan_desc.h
 create mode 100644 drivers/net/idpf/base/virtchnl_inline_ipsec.h
drivers/net/idpf/base/iecm_alloc.h new file +22 -0
new file mode 100644
index 0000000000..7ea219c784
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2022 Intel Corporation
+ */
+
+#ifndef _IECM_ALLOC_H_
+#define _IECM_ALLOC_H_
+
+/* Memory types */
+enum iecm_memset_type {
+	IECM_NONDMA_MEM = 0,
+	IECM_DMA_MEM
+};
+
+/* Memcpy types */
+enum iecm_memcpy_type {
+	IECM_NONDMA_TO_NONDMA = 0,
+	IECM_NONDMA_TO_DMA,
+	IECM_DMA_TO_DMA,
+	IECM_DMA_TO_NONDMA
+};
+
+#endif /* _IECM_ALLOC_H_ */
drivers/net/idpf/base/iecm_common.c new file +359 -0

359 lines not on this page · raw message

drivers/net/idpf/base/iecm_controlq.c new file +662 -0

662 lines not on this page · raw message

drivers/net/idpf/base/iecm_controlq.h new file +214 -0

214 lines not on this page · raw message

drivers/net/idpf/base/iecm_controlq_api.h new file +227 -0

227 lines not on this page · raw message

drivers/net/idpf/base/iecm_controlq_setup.c new file +179 -0

179 lines not on this page · raw message

drivers/net/idpf/base/iecm_devids.h new file +18 -0
new file mode 100644
index 0000000000..aa58982db2
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2022 Intel Corporation
+ */
+
+#ifndef _IECM_DEVIDS_H_
+#define _IECM_DEVIDS_H_
+
+/* Vendor ID */
+#define IECM_INTEL_VENDOR_ID		0x8086
+
+/* Device IDs */
+#define IECM_DEV_ID_PF			0x1452
+#define IECM_DEV_ID_CPF			0x1453
+
+
+
+
+#endif /* _IECM_DEVIDS_H_ */
drivers/net/idpf/base/iecm_lan_pf_regs.h new file +134 -0

134 lines not on this page · raw message

drivers/net/idpf/base/iecm_lan_txrx.h new file +428 -0

428 lines not on this page · raw message

drivers/net/idpf/base/iecm_lan_vf_regs.h new file +114 -0

114 lines not on this page · raw message

drivers/net/idpf/base/iecm_prototype.h new file +45 -0

45 lines not on this page · raw message

drivers/net/idpf/base/iecm_type.h new file +106 -0

106 lines not on this page · raw message

drivers/net/idpf/base/meson.build new file +27 -0
new file mode 100644
index 0000000000..1ad9a87d9d
@@ -0,0 +1,27 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+sources = [
+	'iecm_common.c',
+	'iecm_controlq.c',
+	'iecm_controlq_setup.c',
+]
+
+error_cflags = ['-Wno-unused-value',
+		'-Wno-unused-but-set-variable',
+		'-Wno-unused-variable',
+		'-Wno-unused-parameter',
+]
+
+c_args = cflags
+
+foreach flag: error_cflags
+	if cc.has_argument(flag)
+		c_args += flag
+	endif
+endforeach
+
+base_lib = static_library('idpf_base', sources,
+	 dependencies: static_rte_eal,
+	 c_args: c_args)
+base_objs = base_lib.extract_all_objects()
\ No newline at end of file
drivers/net/idpf/base/siov_regs.h new file +41 -0

41 lines not on this page · raw message

drivers/net/idpf/base/virtchnl.h new file +2743 -0

423 lines not on this page · raw message

drivers/net/idpf/base/virtchnl2.h new file +1411 -0

1,411 lines not on this page · raw message

drivers/net/idpf/base/virtchnl2_lan_desc.h new file +603 -0

603 lines not on this page · raw message

drivers/net/idpf/base/virtchnl_inline_ipsec.h new file +567 -0

567 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.25.1

Part of the diff is not shown here. View the raw message.

#25 lore raw

Re: [PATCH v2 01/14] net/idpf/base: introduce base code

Quoted 4 lines · Junfeng Guo

Introduce base code for IDPF (Infrastructure Data Path Function) PMD.

I'm OK to import base driver in one patch, but it should not be the first patch with dead code which is not actually built just after the patch.

The first patch should add a driver stub which is built. Subsequent patches should add base driver and functionality to the ethdev driver itself.

#26 lore raw

RE: [PATCH v2 01/14] net/idpf/base: introduce base code

Quoted 17 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 3, 2022 21:20
To: Guo, Junfeng <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>
Subject: Re: [PATCH v2 01/14] net/idpf/base: introduce base code

Quoted 4 lines · Junfeng Guo

Introduce base code for IDPF (Infrastructure Data Path Function) PMD.

Quoted 7 lines

I'm OK to import base driver in one patch, but it should not be the first patch with dead code which is not actually built just after the patch.

The first patch should add a driver stub which is built. Subsequent patches should add base driver and functionality to the ethdev driver itself.

Sure, thanks for the advice!
We will do some refactor work and move the base driver at common folder. That would look better in the coming version. Thanks!

#27 lore raw

PATCH v2 2/14 net/idpf/base: add logs and OS specific implementation

In reply to Junfeng Guo

Add PMD logs.
Add some MACRO definations and small functions which are specific for DPDK.

---
 drivers/net/idpf/base/iecm_osdep.h | 365 +++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_logs.h       |  38 +++
 2 files changed, 403 insertions(+)
 create mode 100644 drivers/net/idpf/base/iecm_osdep.h
 create mode 100644 drivers/net/idpf/idpf_logs.h
drivers/net/idpf/base/iecm_osdep.h new file +365 -0
new file mode 100644
index 0000000000..60e21fbc1b
@@ -0,0 +1,365 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2022 Intel Corporation
+ */
+
+#ifndef _IECM_OSDEP_H_
+#define _IECM_OSDEP_H_
+
+#include <string.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <inttypes.h>
+#include <sys/queue.h>
+#include <stdbool.h>
+
+#include <rte_common.h>
+#include <rte_memcpy.h>
+#include <rte_malloc.h>
+#include <rte_memzone.h>
+#include <rte_byteorder.h>
+#include <rte_cycles.h>
+#include <rte_spinlock.h>
+#include <rte_log.h>
+#include <rte_random.h>
+#include <rte_io.h>
+
+#include "../idpf_logs.h"
+
+#define INLINE inline
+#define STATIC static
+
+typedef uint8_t		u8;
+typedef int8_t		s8;
+typedef uint16_t	u16;
+typedef int16_t		s16;
+typedef uint32_t	u32;
+typedef int32_t		s32;
+typedef uint64_t	u64;
+typedef uint64_t	s64;
+
+typedef enum iecm_status iecm_status;
+typedef struct iecm_lock iecm_lock;
+
+#define __iomem
+#define hw_dbg(hw, S, A...)	do {} while (0)
+#define upper_32_bits(n)	((u32)(((n) >> 16) >> 16))
+#define lower_32_bits(n)	((u32)(n))
+#define low_16_bits(x)		((x) & 0xFFFF)
+#define high_16_bits(x)		(((x) & 0xFFFF0000) >> 16)
+
+#ifndef ETH_ADDR_LEN
+#define ETH_ADDR_LEN		6
+#endif
+
+#ifndef __le16
+#define __le16	uint16_t
+#endif
+#ifndef __le32
+#define __le32	uint32_t
+#endif
+#ifndef __le64
+#define __le64	uint64_t
+#endif
+#ifndef __be16
+#define __be16	uint16_t
+#endif
+#ifndef __be32
+#define __be32	uint32_t
+#endif
+#ifndef __be64
+#define __be64	uint64_t
+#endif
+
+#ifndef __always_unused
+#define __always_unused  __attribute__((__unused__))
+#endif
+#ifndef __maybe_unused
+#define __maybe_unused  __attribute__((__unused__))
+#endif
+#ifndef __packed
+#define __packed  __attribute__((packed))
+#endif
+
+#ifndef BIT_ULL
+#define BIT_ULL(a) (1ULL << (a))
+#endif
+
+#ifndef BIT
+#define BIT(a) (1ULL << (a))
+#endif
+
+#define FALSE	0
+#define TRUE	1
+#define false	0
+#define true	1
+
+#define min(a, b) RTE_MIN(a, b)
+#define max(a, b) RTE_MAX(a, b)
+
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
+#define FIELD_SIZEOF(t, f) (sizeof(((t *)0)->(f)))
+#define MAKEMASK(m, s) ((m) << (s))
+
+#define DEBUGOUT(S) PMD_DRV_LOG_RAW(DEBUG, S)
+#define DEBUGOUT2(S, A...) PMD_DRV_LOG_RAW(DEBUG, S, ##A)
+#define DEBUGFUNC(F) PMD_DRV_LOG_RAW(DEBUG, F)
+
+#define iecm_debug(h, m, s, ...)					\
+	do {								\
+		if (((m) & (h)->debug_mask))				\
+			PMD_DRV_LOG_RAW(DEBUG, "iecm %02x.%x " s,       \
+					(h)->bus.device, (h)->bus.func,	\
+					##__VA_ARGS__);			\
+	} while (0)
+
+#define iecm_info(hw, fmt, args...) iecm_debug(hw, IECM_DBG_ALL, fmt, ##args)
+#define iecm_warn(hw, fmt, args...) iecm_debug(hw, IECM_DBG_ALL, fmt, ##args)
+#define iecm_debug_array(hw, type, rowsize, groupsize, buf, len)	\
+	do {								\
+		struct iecm_hw *hw_l = hw;				\
+		u16 len_l = len;					\
+		u8 *buf_l = buf;					\
+		int i;							\
+		for (i = 0; i < len_l; i += 8)				\
+			iecm_debug(hw_l, type,				\
+				   "0x%04X  0x%016"PRIx64"\n",		\
+				   i, *((u64 *)((buf_l) + i)));		\
+	} while (0)
+#define iecm_snprintf snprintf
+#ifndef SNPRINTF
+#define SNPRINTF iecm_snprintf
+#endif
+
+#define IECM_PCI_REG(reg)     rte_read32(reg)
+#define IECM_PCI_REG_ADDR(a, reg)				\
+	((volatile uint32_t *)((char *)(a)->hw_addr + (reg)))
+#define IECM_PCI_REG64(reg)     rte_read64(reg)
+#define IECM_PCI_REG_ADDR64(a, reg)				\
+	((volatile uint64_t *)((char *)(a)->hw_addr + (reg)))
+
+#define iecm_wmb() rte_io_wmb()
+#define iecm_rmb() rte_io_rmb()
+#define iecm_mb() rte_io_mb()
+
+static inline uint32_t iecm_read_addr(volatile void *addr)
+{
+	return rte_le_to_cpu_32(IECM_PCI_REG(addr));
+}
+
+static inline uint64_t iecm_read_addr64(volatile void *addr)
+{
+	return rte_le_to_cpu_64(IECM_PCI_REG64(addr));
+}
+
+#define IECM_PCI_REG_WRITE(reg, value)			\
+	rte_write32((rte_cpu_to_le_32(value)), reg)
+
+#define IECM_PCI_REG_WRITE64(reg, value)		\
+	rte_write64((rte_cpu_to_le_64(value)), reg)
+
+#define IECM_READ_REG(hw, reg) iecm_read_addr(IECM_PCI_REG_ADDR((hw), (reg)))
+#define IECM_WRITE_REG(hw, reg, value)					\
+	IECM_PCI_REG_WRITE(IECM_PCI_REG_ADDR((hw), (reg)), (value))
+
+#define rd32(a, reg) iecm_read_addr(IECM_PCI_REG_ADDR((a), (reg)))
+#define wr32(a, reg, value)						\
+	IECM_PCI_REG_WRITE(IECM_PCI_REG_ADDR((a), (reg)), (value))
+#define div64_long(n, d) ((n) / (d))
+#define rd64(a, reg) iecm_read_addr64(IECM_PCI_REG_ADDR64((a), (reg)))
+
+#define BITS_PER_BYTE       8
+
+/* memory allocation tracking */
+struct iecm_dma_mem {
+	void *va;
+	u64 pa;
+	u32 size;
+	const void *zone;
+} __attribute__((packed));
+
+struct iecm_virt_mem {
+	void *va;
+	u32 size;
+} __attribute__((packed));
+
+#define iecm_malloc(h, s)	rte_zmalloc(NULL, s, 0)
+#define iecm_calloc(h, c, s)	rte_zmalloc(NULL, (c) * (s), 0)
+#define iecm_free(h, m)		rte_free(m)
+
+#define iecm_memset(a, b, c, d)	memset((a), (b), (c))
+#define iecm_memcpy(a, b, c, d)	rte_memcpy((a), (b), (c))
+#define iecm_memdup(a, b, c, d)	rte_memcpy(iecm_malloc(a, c), b, c)
+
+#define CPU_TO_BE16(o) rte_cpu_to_be_16(o)
+#define CPU_TO_BE32(o) rte_cpu_to_be_32(o)
+#define CPU_TO_BE64(o) rte_cpu_to_be_64(o)
+#define CPU_TO_LE16(o) rte_cpu_to_le_16(o)
+#define CPU_TO_LE32(s) rte_cpu_to_le_32(s)
+#define CPU_TO_LE64(h) rte_cpu_to_le_64(h)
+#define LE16_TO_CPU(a) rte_le_to_cpu_16(a)
+#define LE32_TO_CPU(c) rte_le_to_cpu_32(c)
+#define LE64_TO_CPU(k) rte_le_to_cpu_64(k)
+
+#define NTOHS(a) rte_be_to_cpu_16(a)
+#define NTOHL(a) rte_be_to_cpu_32(a)
+#define HTONS(a) rte_cpu_to_be_16(a)
+#define HTONL(a) rte_cpu_to_be_32(a)
+
+/* SW spinlock */
+struct iecm_lock {
+	rte_spinlock_t spinlock;
+};
+
+static inline void
+iecm_init_lock(struct iecm_lock *sp)
+{
+	rte_spinlock_init(&sp->spinlock);
+}
+
+static inline void
+iecm_acquire_lock(struct iecm_lock *sp)
+{
+	rte_spinlock_lock(&sp->spinlock);
+}
+
+static inline void
+iecm_release_lock(struct iecm_lock *sp)
+{
+	rte_spinlock_unlock(&sp->spinlock);
+}
+
+static inline void
+iecm_destroy_lock(__attribute__((unused)) struct iecm_lock *sp)
+{
+}
+
+struct iecm_hw;
+
+static inline void *
+iecm_alloc_dma_mem(__attribute__((unused)) struct iecm_hw *hw,
+		   struct iecm_dma_mem *mem, u64 size)
+{
+	const struct rte_memzone *mz = NULL;
+	char z_name[RTE_MEMZONE_NAMESIZE];
+
+	if (!mem)
+		return NULL;
+
+	snprintf(z_name, sizeof(z_name), "iecm_dma_%"PRIu64, rte_rand());
+	mz = rte_memzone_reserve_aligned(z_name, size, SOCKET_ID_ANY,
+					 RTE_MEMZONE_IOVA_CONTIG, RTE_PGSIZE_4K);
+	if (!mz)
+		return NULL;
+
+	mem->size = size;
+	mem->va = mz->addr;
+	mem->pa = mz->iova;
+	mem->zone = (const void *)mz;
+	memset(mem->va, 0, size);
+
+	return mem->va;
+}
+
+static inline void
+iecm_free_dma_mem(__attribute__((unused)) struct iecm_hw *hw,
+		  struct iecm_dma_mem *mem)
+{
+	rte_memzone_free((const struct rte_memzone *)mem->zone);
+	mem->size = 0;
+	mem->va = NULL;
+	mem->pa = 0;
+}
+
+static inline u8
+iecm_hweight8(u32 num)
+{
+	u8 bits = 0;
+	u32 i;
+
+	for (i = 0; i < 8; i++) {
+		bits += (u8)(num & 0x1);
+		num >>= 1;
+	}
+
+	return bits;
+}
+
+static inline u8
+iecm_hweight32(u32 num)
+{
+	u8 bits = 0;
+	u32 i;
+
+	for (i = 0; i < 32; i++) {
+		bits += (u8)(num & 0x1);
+		num >>= 1;
+	}
+
+	return bits;
+}
+
+#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
+#define DELAY(x) rte_delay_us(x)
+#define iecm_usec_delay(x) rte_delay_us(x)
+#define iecm_msec_delay(x, y) rte_delay_us(1000 * (x))
+#define udelay(x) DELAY(x)
+#define msleep(x) DELAY(1000 * (x))
+#define usleep_range(min, max) msleep(DIV_ROUND_UP(min, 1000))
+
+#ifndef IECM_DBG_TRACE
+#define IECM_DBG_TRACE	  BIT_ULL(0)
+#endif
+
+#ifndef DIVIDE_AND_ROUND_UP
+#define DIVIDE_AND_ROUND_UP(a, b) (((a) + (b) - 1) / (b))
+#endif
+
+#ifndef IECM_INTEL_VENDOR_ID
+#define IECM_INTEL_VENDOR_ID	    0x8086
+#endif
+
+#ifndef IS_UNICAST_ETHER_ADDR
+#define IS_UNICAST_ETHER_ADDR(addr)			\
+	((bool)((((u8 *)(addr))[0] % ((u8)0x2)) == 0))
+#endif
+
+#ifndef IS_MULTICAST_ETHER_ADDR
+#define IS_MULTICAST_ETHER_ADDR(addr)			\
+	((bool)((((u8 *)(addr))[0] % ((u8)0x2)) == 1))
+#endif
+
+#ifndef IS_BROADCAST_ETHER_ADDR
+/* Check whether an address is broadcast. */
+#define IS_BROADCAST_ETHER_ADDR(addr)			\
+	((bool)((((u16 *)(addr))[0] == ((u16)0xffff))))
+#endif
+
+#ifndef IS_ZERO_ETHER_ADDR
+#define IS_ZERO_ETHER_ADDR(addr)				\
+	(((bool)((((u16 *)(addr))[0] == ((u16)0x0)))) &&	\
+	 ((bool)((((u16 *)(addr))[1] == ((u16)0x0)))) &&	\
+	 ((bool)((((u16 *)(addr))[2] == ((u16)0x0)))))
+#endif
+
+#ifndef LIST_HEAD_TYPE
+#define LIST_HEAD_TYPE(list_name, type) LIST_HEAD(list_name, type)
+#endif
+
+#ifndef LIST_ENTRY_TYPE
+#define LIST_ENTRY_TYPE(type)	   LIST_ENTRY(type)
+#endif
+
+#ifndef LIST_FOR_EACH_ENTRY_SAFE
+#define LIST_FOR_EACH_ENTRY_SAFE(pos, temp, head, entry_type, list)	\
+	LIST_FOREACH(pos, head, list)
+
+#endif
+
+#ifndef LIST_FOR_EACH_ENTRY
+#define LIST_FOR_EACH_ENTRY(pos, head, entry_type, list)		\
+	LIST_FOREACH(pos, head, list)
+
+#endif
+
+#endif /* _IECM_OSDEP_H_ */
drivers/net/idpf/idpf_logs.h new file +38 -0
new file mode 100644
index 0000000000..906aae8463
@@ -0,0 +1,38 @@
+#ifndef _IDPF_LOGS_H_
+#define _IDPF_LOGS_H_
+
+#include <rte_log.h>
+
+extern int idpf_logtype_init;
+extern int idpf_logtype_driver;
+
+#define PMD_INIT_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, idpf_logtype_init, \
+		"%s(): " fmt "\n", __func__, ##args)
+
+#define PMD_INIT_FUNC_TRACE() PMD_DRV_LOG(DEBUG, " >>")
+
+#define PMD_DRV_LOG_RAW(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, idpf_logtype_driver, \
+		"%s(): " fmt "\n", __func__, ##args)
+
+#define PMD_DRV_LOG(level, fmt, args...) \
+	PMD_DRV_LOG_RAW(level, fmt "\n", ## args)
+
+#define PMD_DRV_FUNC_TRACE() PMD_DRV_LOG(DEBUG, " >>")
+
+#ifdef RTE_LIBRTE_IDPF_DEBUG_RX
+#define PMD_RX_LOG(level, fmt, args...) \
+	RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
+#else
+#define PMD_RX_LOG(level, fmt, args...) do { } while (0)
+#endif
+
+#ifdef RTE_LIBRTE_IDPF_DEBUG_TX
+#define PMD_TX_LOG(level, fmt, args...) \
+	RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
+#else
+#define PMD_TX_LOG(level, fmt, args...) do { } while (0)
+#endif
+
+#endif /* _IDPF_LOGS_H_ */
Signature · 1 line
2.25.1
#28 lore raw

Re: [PATCH v2 02/14] net/idpf/base: add logs and OS specific implementation

Quoted 6 lines · Junfeng Guo

Add PMD logs.
Add some MACRO definations and small functions which are specific for DPDK.

The patch adds dead code as well. Added headers are used nowhere.

One more question is what's the point to have two things in one patch? Typically such descriptions suggest that it could be separate patches in a right order.

#29 lore raw

RE: [PATCH v2 02/14] net/idpf/base: add logs and OS specific implementation

Quoted 20 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 3, 2022 21:20
To: Guo, Junfeng <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>
Subject: Re: [PATCH v2 02/14] net/idpf/base: add logs and OS specific implementation

Quoted 6 lines · Junfeng Guo

Add PMD logs.
Add some MACRO definations and small functions which are specific for DPDK.

Quoted 6 lines

The patch adds dead code as well. Added headers are used nowhere.

One more question is what's the point to have two things in one patch? Typically such descriptions suggest that it could be separate patches in a right order.

Sure, will improve this in the coming version patchset. Thanks!

#30 lore raw

RE: [PATCH v2 02/14] net/idpf/base: add logs and OS specific implementation

In reply to Junfeng Guo

drivers/net/idpf/idpf_logs.h

Quoted 393 lines

-----Original Message-----
From: Junfeng Guo <[email protected]>
Sent: Monday, September 5, 2022 6:58 PM
To: Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>; Guo, Junfeng <[email protected]>
Subject: [PATCH v2 02/14] net/idpf/base: add logs and OS specific implementation

Add PMD logs.
Add some MACRO definations and small functions which are specific for DPDK.

---
 drivers/net/idpf/base/iecm_osdep.h | 365
+++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_logs.h       |  38 +++
 2 files changed, 403 insertions(+)
 create mode 100644 drivers/net/idpf/base/iecm_osdep.h
 create mode 100644 drivers/net/idpf/idpf_logs.h
drivers/net/idpf/base/iecm_osdep.h new file +99 -0
new file mode 100644
index 0000000000..60e21fbc1b
@@ -0,0 +1,365 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2022 Intel Corporation  */
+
+#ifndef _IECM_OSDEP_H_
+#define _IECM_OSDEP_H_
+
+#include <string.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <inttypes.h>
+#include <sys/queue.h>
+#include <stdbool.h>
+
+#include <rte_common.h>
+#include <rte_memcpy.h>
+#include <rte_malloc.h>
+#include <rte_memzone.h>
+#include <rte_byteorder.h>
+#include <rte_cycles.h>
+#include <rte_spinlock.h>
+#include <rte_log.h>
+#include <rte_random.h>
+#include <rte_io.h>
+
+#include "../idpf_logs.h"
+
+#define INLINE inline
+#define STATIC static
+
+typedef uint8_t		u8;
+typedef int8_t		s8;
+typedef uint16_t	u16;
+typedef int16_t		s16;
+typedef uint32_t	u32;
+typedef int32_t		s32;
+typedef uint64_t	u64;
+typedef uint64_t	s64;
+
+typedef enum iecm_status iecm_status;
+typedef struct iecm_lock iecm_lock;
+
+#define __iomem
+#define hw_dbg(hw, S, A...)	do {} while (0)
+#define upper_32_bits(n)	((u32)(((n) >> 16) >> 16))
+#define lower_32_bits(n)	((u32)(n))
+#define low_16_bits(x)		((x) & 0xFFFF)
+#define high_16_bits(x)		(((x) & 0xFFFF0000) >> 16)
+
+#ifndef ETH_ADDR_LEN
+#define ETH_ADDR_LEN		6
+#endif
+
+#ifndef __le16
+#define __le16	uint16_t
+#endif
+#ifndef __le32
+#define __le32	uint32_t
+#endif
+#ifndef __le64
+#define __le64	uint64_t
+#endif
+#ifndef __be16
+#define __be16	uint16_t
+#endif
+#ifndef __be32
+#define __be32	uint32_t
+#endif
+#ifndef __be64
+#define __be64	uint64_t
+#endif
+
+#ifndef __always_unused
+#define __always_unused  __attribute__((__unused__)) #endif #ifndef
+__maybe_unused #define __maybe_unused  __attribute__((__unused__))
+#endif #ifndef __packed #define __packed  __attribute__((packed))
+#endif
+
+#ifndef BIT_ULL
+#define BIT_ULL(a) (1ULL << (a))
+#endif
+
+#ifndef BIT
+#define BIT(a) (1ULL << (a))
+#endif
+
+#define FALSE	0
+#define TRUE	1
+#define false	0
+#define true	1
+
+#define min(a, b) RTE_MIN(a, b)
+#define max(a, b) RTE_MAX(a, b)
+
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) #define
+FIELD_SIZEOF(t, f) (sizeof(((t *)0)->(f))) #define MAKEMASK(m, s) ((m)
+<< (s))
+
+#define DEBUGOUT(S) PMD_DRV_LOG_RAW(DEBUG, S) #define

DEBUGOUT2(S,

drivers/net/idpf/base/iecm_osdep.h new file +7 -0
+A...) PMD_DRV_LOG_RAW(DEBUG, S, ##A) #define DEBUGFUNC(F)
+PMD_DRV_LOG_RAW(DEBUG, F)
+
+#define iecm_debug(h, m, s, ...)					\
+	do {								\
+		if (((m) & (h)->debug_mask))				\
+			PMD_DRV_LOG_RAW(DEBUG, "iecm %02x.%x " s,

\

drivers/net/idpf/base/iecm_osdep.h new file +2 -0
+					(h)->bus.device, (h)->bus.func,	\
+					##__VA_ARGS__);
	\
drivers/net/idpf/base/iecm_osdep.h new file +4 -0
+	} while (0)
+
+#define iecm_info(hw, fmt, args...) iecm_debug(hw, IECM_DBG_ALL, fmt,
+##args) #define iecm_warn(hw, fmt, args...) iecm_debug(hw,

IECM_DBG_ALL, fmt, ##args)

drivers/net/idpf/base/iecm_osdep.h new file +8 -0
+#define iecm_debug_array(hw, type, rowsize, groupsize, buf, len)	\
+	do {								\
+		struct iecm_hw *hw_l = hw;				\
+		u16 len_l = len;					\
+		u8 *buf_l = buf;					\
+		int i;							\
+		for (i = 0; i < len_l; i += 8)				\
+			iecm_debug(hw_l, type,
	\
drivers/net/idpf/base/iecm_osdep.h new file +1 -0
+				   "0x%04X  0x%016"PRIx64"\n",
	\
drivers/net/idpf/base/iecm_osdep.h new file +33 -0
+				   i, *((u64 *)((buf_l) + i)));		\
+	} while (0)
+#define iecm_snprintf snprintf
+#ifndef SNPRINTF
+#define SNPRINTF iecm_snprintf
+#endif
+
+#define IECM_PCI_REG(reg)     rte_read32(reg)
+#define IECM_PCI_REG_ADDR(a, reg)				\
+	((volatile uint32_t *)((char *)(a)->hw_addr + (reg)))
+#define IECM_PCI_REG64(reg)     rte_read64(reg)
+#define IECM_PCI_REG_ADDR64(a, reg)				\
+	((volatile uint64_t *)((char *)(a)->hw_addr + (reg)))
+
+#define iecm_wmb() rte_io_wmb()
+#define iecm_rmb() rte_io_rmb()
+#define iecm_mb() rte_io_mb()
+
+static inline uint32_t iecm_read_addr(volatile void *addr) {
+	return rte_le_to_cpu_32(IECM_PCI_REG(addr));
+}
+
+static inline uint64_t iecm_read_addr64(volatile void *addr) {
+	return rte_le_to_cpu_64(IECM_PCI_REG64(addr));
+}
+
+#define IECM_PCI_REG_WRITE(reg, value)			\
+	rte_write32((rte_cpu_to_le_32(value)), reg)
+
+#define IECM_PCI_REG_WRITE64(reg, value)		\
+	rte_write64((rte_cpu_to_le_64(value)), reg)
+
+#define IECM_READ_REG(hw, reg)

iecm_read_addr(IECM_PCI_REG_ADDR((hw), (reg)))
+#define IECM_WRITE_REG(hw, reg, value)

	\
drivers/net/idpf/base/iecm_osdep.h new file +5 -0
+	IECM_PCI_REG_WRITE(IECM_PCI_REG_ADDR((hw), (reg)), (value))
+
+#define rd32(a, reg) iecm_read_addr(IECM_PCI_REG_ADDR((a), (reg)))
+#define wr32(a, reg, value)						\
+	IECM_PCI_REG_WRITE(IECM_PCI_REG_ADDR((a), (reg)), (value))

#define

drivers/net/idpf/base/iecm_osdep.h new file +28 -0
+div64_long(n, d) ((n) / (d)) #define rd64(a, reg)
+iecm_read_addr64(IECM_PCI_REG_ADDR64((a), (reg)))
+
+#define BITS_PER_BYTE       8
+
+/* memory allocation tracking */
+struct iecm_dma_mem {
+	void *va;
+	u64 pa;
+	u32 size;
+	const void *zone;
+} __attribute__((packed));
+
+struct iecm_virt_mem {
+	void *va;
+	u32 size;
+} __attribute__((packed));
+
+#define iecm_malloc(h, s)	rte_zmalloc(NULL, s, 0)
+#define iecm_calloc(h, c, s)	rte_zmalloc(NULL, (c) * (s), 0)
+#define iecm_free(h, m)		rte_free(m)
+
+#define iecm_memset(a, b, c, d)	memset((a), (b), (c))
+#define iecm_memcpy(a, b, c, d)	rte_memcpy((a), (b), (c))
+#define iecm_memdup(a, b, c, d)	rte_memcpy(iecm_malloc(a, c), b, c)
+
+#define CPU_TO_BE16(o) rte_cpu_to_be_16(o) #define CPU_TO_BE32(o)
+rte_cpu_to_be_32(o) #define CPU_TO_BE64(o) rte_cpu_to_be_64(o)

#define

drivers/net/idpf/base/iecm_osdep.h new file +48 -0
+CPU_TO_LE16(o) rte_cpu_to_le_16(o) #define CPU_TO_LE32(s)
+rte_cpu_to_le_32(s) #define CPU_TO_LE64(h) rte_cpu_to_le_64(h) #define
+LE16_TO_CPU(a) rte_le_to_cpu_16(a) #define LE32_TO_CPU(c)
+rte_le_to_cpu_32(c) #define LE64_TO_CPU(k) rte_le_to_cpu_64(k)
+
+#define NTOHS(a) rte_be_to_cpu_16(a)
+#define NTOHL(a) rte_be_to_cpu_32(a)
+#define HTONS(a) rte_cpu_to_be_16(a)
+#define HTONL(a) rte_cpu_to_be_32(a)
+
+/* SW spinlock */
+struct iecm_lock {
+	rte_spinlock_t spinlock;
+};
+
+static inline void
+iecm_init_lock(struct iecm_lock *sp)
+{
+	rte_spinlock_init(&sp->spinlock);
+}
+
+static inline void
+iecm_acquire_lock(struct iecm_lock *sp) {
+	rte_spinlock_lock(&sp->spinlock);
+}
+
+static inline void
+iecm_release_lock(struct iecm_lock *sp) {
+	rte_spinlock_unlock(&sp->spinlock);
+}
+
+static inline void
+iecm_destroy_lock(__attribute__((unused)) struct iecm_lock *sp) { }
+
+struct iecm_hw;
+
+static inline void *
+iecm_alloc_dma_mem(__attribute__((unused)) struct iecm_hw *hw,
+		   struct iecm_dma_mem *mem, u64 size) {
+	const struct rte_memzone *mz = NULL;
+	char z_name[RTE_MEMZONE_NAMESIZE];
+
+	if (!mem)
+		return NULL;
+
+	snprintf(z_name, sizeof(z_name), "iecm_dma_%"PRIu64, rte_rand());
+	mz = rte_memzone_reserve_aligned(z_name, size, SOCKET_ID_ANY,
+					 RTE_MEMZONE_IOVA_CONTIG,

RTE_PGSIZE_4K);

drivers/net/idpf/base/iecm_osdep.h new file +96 -0
+	if (!mz)
+		return NULL;
+
+	mem->size = size;
+	mem->va = mz->addr;
+	mem->pa = mz->iova;
+	mem->zone = (const void *)mz;
+	memset(mem->va, 0, size);
+
+	return mem->va;
+}
+
+static inline void
+iecm_free_dma_mem(__attribute__((unused)) struct iecm_hw *hw,
+		  struct iecm_dma_mem *mem)
+{
+	rte_memzone_free((const struct rte_memzone *)mem->zone);
+	mem->size = 0;
+	mem->va = NULL;
+	mem->pa = 0;
+}
+
+static inline u8
+iecm_hweight8(u32 num)
+{
+	u8 bits = 0;
+	u32 i;
+
+	for (i = 0; i < 8; i++) {
+		bits += (u8)(num & 0x1);
+		num >>= 1;
+	}
+
+	return bits;
+}
+
+static inline u8
+iecm_hweight32(u32 num)
+{
+	u8 bits = 0;
+	u32 i;
+
+	for (i = 0; i < 32; i++) {
+		bits += (u8)(num & 0x1);
+		num >>= 1;
+	}
+
+	return bits;
+}
+
+#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) #define DELAY(x)
+rte_delay_us(x) #define iecm_usec_delay(x) rte_delay_us(x) #define
+iecm_msec_delay(x, y) rte_delay_us(1000 * (x)) #define udelay(x)
+DELAY(x) #define msleep(x) DELAY(1000 * (x)) #define usleep_range(min,
+max) msleep(DIV_ROUND_UP(min, 1000))
+
+#ifndef IECM_DBG_TRACE
+#define IECM_DBG_TRACE	  BIT_ULL(0)
+#endif
+
+#ifndef DIVIDE_AND_ROUND_UP
+#define DIVIDE_AND_ROUND_UP(a, b) (((a) + (b) - 1) / (b)) #endif
+
+#ifndef IECM_INTEL_VENDOR_ID
+#define IECM_INTEL_VENDOR_ID	    0x8086
+#endif
+
+#ifndef IS_UNICAST_ETHER_ADDR
+#define IS_UNICAST_ETHER_ADDR(addr)			\
+	((bool)((((u8 *)(addr))[0] % ((u8)0x2)) == 0)) #endif
+
+#ifndef IS_MULTICAST_ETHER_ADDR
+#define IS_MULTICAST_ETHER_ADDR(addr)			\
+	((bool)((((u8 *)(addr))[0] % ((u8)0x2)) == 1)) #endif
+
+#ifndef IS_BROADCAST_ETHER_ADDR
+/* Check whether an address is broadcast. */
+#define IS_BROADCAST_ETHER_ADDR(addr)			\
+	((bool)((((u16 *)(addr))[0] == ((u16)0xffff)))) #endif
+
+#ifndef IS_ZERO_ETHER_ADDR
+#define IS_ZERO_ETHER_ADDR(addr)				\
+	(((bool)((((u16 *)(addr))[0] == ((u16)0x0)))) &&	\
+	 ((bool)((((u16 *)(addr))[1] == ((u16)0x0)))) &&	\
+	 ((bool)((((u16 *)(addr))[2] == ((u16)0x0))))) #endif
+
+#ifndef LIST_HEAD_TYPE
+#define LIST_HEAD_TYPE(list_name, type) LIST_HEAD(list_name, type)
+#endif
+
+#ifndef LIST_ENTRY_TYPE
+#define LIST_ENTRY_TYPE(type)	   LIST_ENTRY(type)
+#endif
+
+#ifndef LIST_FOR_EACH_ENTRY_SAFE
+#define LIST_FOR_EACH_ENTRY_SAFE(pos, temp, head, entry_type, list)
	\
drivers/net/idpf/base/iecm_osdep.h new file +11 -0
+	LIST_FOREACH(pos, head, list)
+
+#endif
+
+#ifndef LIST_FOR_EACH_ENTRY
+#define LIST_FOR_EACH_ENTRY(pos, head, entry_type, list)		\
+	LIST_FOREACH(pos, head, list)
+
+#endif
+
+#endif /* _IECM_OSDEP_H_ */
drivers/net/idpf/idpf_logs.h new renamed from drivers/net/idpf/idpf_logs.h +0 -0

file mode 100644 index 0000000000..906aae8463

drivers/net/idpf/idpf_logs.h new file +0 -0
@@ -0,0 +1,38 @@

License description is missed in this new file.

Quoted 36 lines
drivers/net/idpf/idpf_logs.h new file +34 -1
+#ifndef _IDPF_LOGS_H_
+#define _IDPF_LOGS_H_
+
+#include <rte_log.h>
+
+extern int idpf_logtype_init;
+extern int idpf_logtype_driver;
+
+#define PMD_INIT_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, idpf_logtype_init, \
+		"%s(): " fmt "\n", __func__, ##args)
+
+#define PMD_INIT_FUNC_TRACE() PMD_DRV_LOG(DEBUG, " >>")
+
+#define PMD_DRV_LOG_RAW(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, idpf_logtype_driver, \
+		"%s(): " fmt "\n", __func__, ##args)
+
+#define PMD_DRV_LOG(level, fmt, args...) \
+	PMD_DRV_LOG_RAW(level, fmt "\n", ## args)
+
+#define PMD_DRV_FUNC_TRACE() PMD_DRV_LOG(DEBUG, " >>")
+
+#ifdef RTE_LIBRTE_IDPF_DEBUG_RX
+#define PMD_RX_LOG(level, fmt, args...) \
+	RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args) #else
+#define PMD_RX_LOG(level, fmt, args...) do { } while (0) #endif
+
+#ifdef RTE_LIBRTE_IDPF_DEBUG_TX
+#define PMD_TX_LOG(level, fmt, args...) \
+	RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args) #else
+#define PMD_TX_LOG(level, fmt, args...) do { } while (0) #endif
+
+#endif /* _IDPF_LOGS_H_ */
--

2.25.1

#31 lore raw

PATCH v2 3/14 net/idpf: add support for device initialization

In reply to Junfeng Guo

Support device init and the following dev ops:
- dev_configure
- dev_start
- dev_stop
- dev_close

---
 drivers/net/idpf/idpf_ethdev.c | 810 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h | 229 ++++++++++
 drivers/net/idpf/idpf_vchnl.c  | 495 ++++++++++++++++++++
 drivers/net/idpf/meson.build   |  18 +
 drivers/net/idpf/version.map   |   3 +
 drivers/net/meson.build        |   1 +
 6 files changed, 1556 insertions(+)
 create mode 100644 drivers/net/idpf/idpf_ethdev.c
 create mode 100644 drivers/net/idpf/idpf_ethdev.h
 create mode 100644 drivers/net/idpf/idpf_vchnl.c
 create mode 100644 drivers/net/idpf/meson.build
 create mode 100644 drivers/net/idpf/version.map
drivers/net/idpf/idpf_ethdev.c new file +810 -0
new file mode 100644
index 0000000000..f0452de09e
@@ -0,0 +1,810 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#include <rte_atomic.h>
+#include <rte_eal.h>
+#include <rte_ether.h>
+#include <rte_malloc.h>
+#include <rte_memzone.h>
+#include <rte_dev.h>
+
+#include "idpf_ethdev.h"
+
+#define IDPF_VPORT		"vport"
+
+struct idpf_adapter_list adapter_list;
+bool adapter_list_init;
+
+uint64_t idpf_timestamp_dynflag;
+
+static const char * const idpf_valid_args[] = {
+	IDPF_VPORT,
+	NULL
+};
+
+static int idpf_dev_configure(struct rte_eth_dev *dev);
+static int idpf_dev_start(struct rte_eth_dev *dev);
+static int idpf_dev_stop(struct rte_eth_dev *dev);
+static int idpf_dev_close(struct rte_eth_dev *dev);
+
+static const struct eth_dev_ops idpf_eth_dev_ops = {
+	.dev_configure			= idpf_dev_configure,
+	.dev_start			= idpf_dev_start,
+	.dev_stop			= idpf_dev_stop,
+	.dev_close			= idpf_dev_close,
+};
+
+static int
+idpf_init_vport_req_info(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	struct virtchnl2_create_vport *vport_info;
+	uint16_t idx = adapter->next_vport_idx;
+
+	if (!adapter->vport_req_info[idx]) {
+		adapter->vport_req_info[idx] = rte_zmalloc(NULL,
+				    sizeof(struct virtchnl2_create_vport), 0);
+		if (!adapter->vport_req_info[idx]) {
+			PMD_INIT_LOG(ERR, "Failed to allocate vport_req_info");
+			return -1;
+		}
+	}
+
+	vport_info =
+		(struct virtchnl2_create_vport *)adapter->vport_req_info[idx];
+
+	vport_info->vport_type = rte_cpu_to_le_16(VIRTCHNL2_VPORT_TYPE_DEFAULT);
+	if (!adapter->txq_model) {
+		vport_info->txq_model =
+			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SPLIT);
+		vport_info->num_tx_q = IDPF_DEFAULT_TXQ_NUM;
+		vport_info->num_tx_complq =
+			IDPF_DEFAULT_TXQ_NUM * IDPF_TX_COMPLQ_PER_GRP;
+	} else {
+		vport_info->txq_model =
+			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SINGLE);
+		vport_info->num_tx_q = IDPF_DEFAULT_TXQ_NUM;
+		vport_info->num_tx_complq = 0;
+	}
+	if (!adapter->rxq_model) {
+		vport_info->rxq_model =
+			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SPLIT);
+		vport_info->num_rx_q = IDPF_DEFAULT_RXQ_NUM;
+		vport_info->num_rx_bufq =
+			IDPF_DEFAULT_RXQ_NUM * IDPF_RX_BUFQ_PER_GRP;
+	} else {
+		vport_info->rxq_model =
+			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SINGLE);
+		vport_info->num_rx_q = IDPF_DEFAULT_RXQ_NUM;
+		vport_info->num_rx_bufq = 0;
+	}
+
+	return 0;
+}
+
+static uint16_t
+idpf_get_next_vport_idx(struct idpf_vport **vports, uint16_t max_vport_nb,
+			uint16_t cur_vport_idx)
+{
+	uint16_t vport_idx;
+	uint16_t i;
+
+	if (cur_vport_idx < max_vport_nb && !vports[cur_vport_idx + 1]) {
+		vport_idx = cur_vport_idx + 1;
+		return vport_idx;
+	}
+
+	for (i = 0; i < max_vport_nb; i++) {
+		if (!vports[i])
+			break;
+	}
+
+	if (i == max_vport_nb)
+		vport_idx = IDPF_INVALID_VPORT_IDX;
+	else
+		vport_idx = i;
+
+	return vport_idx;
+}
+
+static uint16_t
+idpf_parse_devarg_id(char *name)
+{
+	uint16_t val;
+	char *p;
+
+	p = strstr(name, "vport_");
+	p += sizeof("vport_") - 1;
+
+	val = strtoul(p, NULL, 10);
+
+	return val;
+}
+
+#ifndef IDPF_RSS_KEY_LEN
+#define IDPF_RSS_KEY_LEN 52
+#endif
+
+static int
+idpf_init_vport(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	uint16_t idx = adapter->next_vport_idx;
+	struct virtchnl2_create_vport *vport_info =
+		(struct virtchnl2_create_vport *)adapter->vport_recv_info[idx];
+	int i;
+
+	vport->vport_id = vport_info->vport_id;
+	vport->txq_model = vport_info->txq_model;
+	vport->rxq_model = vport_info->rxq_model;
+	vport->num_tx_q = vport_info->num_tx_q;
+	vport->num_tx_complq = vport_info->num_tx_complq;
+	vport->num_rx_q = vport_info->num_rx_q;
+	vport->num_rx_bufq = vport_info->num_rx_bufq;
+	vport->max_mtu = vport_info->max_mtu;
+	rte_memcpy(vport->default_mac_addr,
+		   vport_info->default_mac_addr, ETH_ALEN);
+	vport->rss_algorithm = vport_info->rss_algorithm;
+	vport->rss_key_size = RTE_MIN(IDPF_RSS_KEY_LEN,
+				     vport_info->rss_key_size);
+	vport->rss_lut_size = vport_info->rss_lut_size;
+	vport->sw_idx = idx;
+
+	for (i = 0; i < vport_info->chunks.num_chunks; i++) {
+		if (vport_info->chunks.chunks[i].type ==
+		    VIRTCHNL2_QUEUE_TYPE_TX) {
+			vport->chunks_info.tx_start_qid =
+				vport_info->chunks.chunks[i].start_queue_id;
+			vport->chunks_info.tx_qtail_start =
+				vport_info->chunks.chunks[i].qtail_reg_start;
+			vport->chunks_info.tx_qtail_spacing =
+				vport_info->chunks.chunks[i].qtail_reg_spacing;
+		} else if (vport_info->chunks.chunks[i].type ==
+			 VIRTCHNL2_QUEUE_TYPE_RX) {
+			vport->chunks_info.rx_start_qid =
+				vport_info->chunks.chunks[i].start_queue_id;
+			vport->chunks_info.rx_qtail_start =
+				vport_info->chunks.chunks[i].qtail_reg_start;
+			vport->chunks_info.rx_qtail_spacing =
+				vport_info->chunks.chunks[i].qtail_reg_spacing;
+		} else if (vport_info->chunks.chunks[i].type ==
+			 VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION) {
+			vport->chunks_info.tx_compl_start_qid =
+				vport_info->chunks.chunks[i].start_queue_id;
+			vport->chunks_info.tx_compl_qtail_start =
+				vport_info->chunks.chunks[i].qtail_reg_start;
+			vport->chunks_info.tx_compl_qtail_spacing =
+				vport_info->chunks.chunks[i].qtail_reg_spacing;
+		} else if (vport_info->chunks.chunks[i].type ==
+			 VIRTCHNL2_QUEUE_TYPE_RX_BUFFER) {
+			vport->chunks_info.rx_buf_start_qid =
+				vport_info->chunks.chunks[i].start_queue_id;
+			vport->chunks_info.rx_buf_qtail_start =
+				vport_info->chunks.chunks[i].qtail_reg_start;
+			vport->chunks_info.rx_buf_qtail_spacing =
+				vport_info->chunks.chunks[i].qtail_reg_spacing;
+		}
+	}
+
+	adapter->vports[idx] = vport;
+	adapter->next_vport_idx = idpf_get_next_vport_idx(adapter->vports,
+						  adapter->max_vport_nb, idx);
+	if (adapter->next_vport_idx == IDPF_INVALID_VPORT_IDX) {
+		PMD_INIT_LOG(ERR, "Failed to get next vport id");
+		return -1;
+	}
+
+	vport->devarg_id = idpf_parse_devarg_id(dev->data->name);
+	vport->dev_data = dev->data;
+
+	return 0;
+}
+
+static int
+idpf_dev_configure(__rte_unused struct rte_eth_dev *dev)
+{
+	return 0;
+}
+
+static int
+idpf_dev_start(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+
+	PMD_INIT_FUNC_TRACE();
+
+	vport->stopped = 0;
+
+	if (idpf_ena_dis_vport(vport, true)) {
+		PMD_DRV_LOG(ERR, "Failed to enable vport");
+		goto err_vport;
+	}
+
+	return 0;
+
+err_vport:
+	return -1;
+}
+
+static int
+idpf_dev_stop(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (vport->stopped == 1)
+		return 0;
+
+	if (idpf_ena_dis_vport(vport, false))
+		PMD_DRV_LOG(ERR, "disable vport failed");
+
+	vport->stopped = 1;
+	dev->data->dev_started = 0;
+
+	return 0;
+}
+
+static int
+idpf_dev_close(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	idpf_dev_stop(dev);
+	idpf_destroy_vport(vport);
+
+	adapter->cur_vports &= ~BIT(vport->devarg_id);
+
+	rte_free(vport);
+	dev->data->dev_private = NULL;
+
+	return 0;
+}
+
+static int
+insert_value(struct idpf_adapter *adapter, uint16_t id)
+{
+	uint16_t i;
+
+	for (i = 0; i < adapter->req_vport_nb; i++) {
+		if (adapter->req_vports[i] == id)
+			return 0;
+	}
+
+	if (adapter->req_vport_nb >= RTE_DIM(adapter->req_vports)) {
+		PMD_INIT_LOG(ERR, "Total vport number can't be > %d",
+			     IDPF_MAX_VPORT_NUM);
+		return -1;
+	}
+
+	adapter->req_vports[adapter->req_vport_nb] = id;
+	adapter->req_vport_nb++;
+
+	return 0;
+}
+
+static const char *
+parse_range(const char *value, struct idpf_adapter *adapter)
+{
+	uint16_t lo, hi, i;
+	int n = 0;
+	int result;
+	const char *pos = value;
+
+	result = sscanf(value, "%hu%n-%hu%n", &lo, &n, &hi, &n);
+	if (result == 1) {
+		if (lo >= IDPF_MAX_VPORT_NUM)
+			return NULL;
+		if (insert_value(adapter, lo))
+			return NULL;
+	} else if (result == 2) {
+		if (lo > hi || hi >= IDPF_MAX_VPORT_NUM)
+			return NULL;
+		for (i = lo; i <= hi; i++) {
+			if (insert_value(adapter, i))
+				return NULL;
+		}
+	} else {
+		return NULL;
+	}
+
+	return pos + n;
+}
+
+static int
+parse_vport(const char *key, const char *value, void *args)
+{
+	struct idpf_adapter *adapter = (struct idpf_adapter *)args;
+	const char *pos = value;
+	int i;
+
+	adapter->req_vport_nb = 0;
+
+	if (*pos == '[')
+		pos++;
+
+	while (1) {
+		pos = parse_range(pos, adapter);
+		if (pos == NULL) {
+			PMD_INIT_LOG(ERR, "invalid value:\"%s\" for key:\"%s\", ",
+				     value, key);
+			return -1;
+		}
+		if (*pos != ',')
+			break;
+		pos++;
+	}
+
+	if (*value == '[' && *pos != ']') {
+		PMD_INIT_LOG(ERR, "invalid value:\"%s\" for key:\"%s\", ",
+			    value, key);
+		return -1;
+	}
+
+	if (adapter->cur_vport_nb + adapter->req_vport_nb >
+	    IDPF_MAX_VPORT_NUM) {
+		PMD_INIT_LOG(ERR, "Total vport number can't be > %d",
+			    IDPF_MAX_VPORT_NUM);
+		return -1;
+	}
+
+	for (i = 0; i < adapter->req_vport_nb; i++) {
+		if (!(adapter->cur_vports & BIT(adapter->req_vports[i]))) {
+			adapter->cur_vports |= BIT(adapter->req_vports[i]);
+			adapter->cur_vport_nb++;
+		} else {
+			PMD_INIT_LOG(ERR, "Vport %d has been created", adapter->req_vports[i]);
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
+static int
+idpf_parse_devargs(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
+{
+	struct rte_devargs *devargs = pci_dev->device.devargs;
+	struct rte_kvargs *kvlist;
+	int ret;
+
+	if (!devargs)
+		return 0;
+
+	kvlist = rte_kvargs_parse(devargs->args, idpf_valid_args);
+	if (!kvlist) {
+		PMD_INIT_LOG(ERR, "invalid kvargs key");
+		return -EINVAL;
+	}
+
+	ret = rte_kvargs_process(kvlist, IDPF_VPORT, &parse_vport,
+		adapter);
+
+	rte_kvargs_free(kvlist);
+	return ret;
+}
+
+static void
+idpf_reset_pf(struct iecm_hw *hw)
+{
+	uint32_t reg;
+
+	reg = IECM_READ_REG(hw, PFGEN_CTRL);
+	IECM_WRITE_REG(hw, PFGEN_CTRL, (reg | PFGEN_CTRL_PFSWR));
+}
+
+#define IDPF_RESET_WAIT_CNT 100
+static int
+idpf_check_pf_reset_done(struct iecm_hw *hw)
+{
+	uint32_t reg;
+	int i;
+
+	for (i = 0; i < IDPF_RESET_WAIT_CNT; i++) {
+		reg = IECM_READ_REG(hw, PFGEN_RSTAT);
+		if (reg != 0xFFFFFFFF && (reg & PFGEN_RSTAT_PFR_STATE_M))
+			return 0;
+		rte_delay_ms(1000);
+	}
+
+	PMD_INIT_LOG(ERR, "IDPF reset timeout");
+	return -EBUSY;
+}
+
+#define CTLQ_NUM 2
+static int
+idpf_init_mbx(struct iecm_hw *hw)
+{
+	struct iecm_ctlq_create_info ctlq_info[CTLQ_NUM] = {
+		{
+			.type = IECM_CTLQ_TYPE_MAILBOX_TX,
+			.id = IDPF_CTLQ_ID,
+			.len = IDPF_CTLQ_LEN,
+			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+			.reg = {
+				.head = PF_FW_ATQH,
+				.tail = PF_FW_ATQT,
+				.len = PF_FW_ATQLEN,
+				.bah = PF_FW_ATQBAH,
+				.bal = PF_FW_ATQBAL,
+				.len_mask = PF_FW_ATQLEN_ATQLEN_M,
+				.len_ena_mask = PF_FW_ATQLEN_ATQENABLE_M,
+				.head_mask = PF_FW_ATQH_ATQH_M,
+			}
+		},
+		{
+			.type = IECM_CTLQ_TYPE_MAILBOX_RX,
+			.id = IDPF_CTLQ_ID,
+			.len = IDPF_CTLQ_LEN,
+			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+			.reg = {
+				.head = PF_FW_ARQH,
+				.tail = PF_FW_ARQT,
+				.len = PF_FW_ARQLEN,
+				.bah = PF_FW_ARQBAH,
+				.bal = PF_FW_ARQBAL,
+				.len_mask = PF_FW_ARQLEN_ARQLEN_M,
+				.len_ena_mask = PF_FW_ARQLEN_ARQENABLE_M,
+				.head_mask = PF_FW_ARQH_ARQH_M,
+			}
+		}
+	};
+	struct iecm_ctlq_info *ctlq;
+	int ret;
+
+	ret = iecm_ctlq_init(hw, CTLQ_NUM, ctlq_info);
+	if (ret)
+		return ret;
+
+	LIST_FOR_EACH_ENTRY_SAFE(ctlq, NULL, &hw->cq_list_head,
+				 struct iecm_ctlq_info, cq_list) {
+		if (ctlq->q_id == IDPF_CTLQ_ID && ctlq->cq_type == IECM_CTLQ_TYPE_MAILBOX_TX)
+			hw->asq = ctlq;
+		if (ctlq->q_id == IDPF_CTLQ_ID && ctlq->cq_type == IECM_CTLQ_TYPE_MAILBOX_RX)
+			hw->arq = ctlq;
+	}
+
+	if (!hw->asq || !hw->arq) {
+		iecm_ctlq_deinit(hw);
+		ret = -ENOENT;
+	}
+
+	return ret;
+}
+
+static int
+idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
+{
+	struct iecm_hw *hw = &adapter->hw;
+	int ret = 0;
+
+	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
+	hw->hw_addr_len = pci_dev->mem_resource[0].len;
+	hw->back = adapter;
+	hw->vendor_id = pci_dev->id.vendor_id;
+	hw->device_id = pci_dev->id.device_id;
+	hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
+
+	strncpy(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE);
+
+	idpf_reset_pf(hw);
+	ret = idpf_check_pf_reset_done(hw);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "IDPF is still resetting");
+		goto err;
+	}
+
+	ret = idpf_init_mbx(hw);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to init mailbox");
+		goto err;
+	}
+
+	adapter->mbx_resp = rte_zmalloc("idpf_adapter_mbx_resp", IDPF_DFLT_MBX_BUF_SIZE, 0);
+	if (!adapter->mbx_resp) {
+		PMD_INIT_LOG(ERR, "Failed to allocate idpf_adapter_mbx_resp memory");
+		goto err_mbx;
+	}
+
+	if (idpf_check_api_version(adapter)) {
+		PMD_INIT_LOG(ERR, "Failed to check api version");
+		goto err_api;
+	}
+
+	adapter->caps = rte_zmalloc("idpf_caps",
+			       sizeof(struct virtchnl2_get_capabilities), 0);
+	if (!adapter->caps) {
+		PMD_INIT_LOG(ERR, "Failed to allocate idpf_caps memory");
+		goto err_api;
+	}
+
+	if (idpf_get_caps(adapter)) {
+		PMD_INIT_LOG(ERR, "Failed to get capabilities");
+		goto err_caps;
+	}
+
+	adapter->max_vport_nb = adapter->caps->max_vports;
+
+	adapter->vport_req_info = rte_zmalloc("vport_req_info",
+					      adapter->max_vport_nb *
+					      sizeof(*adapter->vport_req_info),
+					      0);
+	if (!adapter->vport_req_info) {
+		PMD_INIT_LOG(ERR, "Failed to allocate vport_req_info memory");
+		goto err_caps;
+	}
+
+	adapter->vport_recv_info = rte_zmalloc("vport_recv_info",
+					       adapter->max_vport_nb *
+					       sizeof(*adapter->vport_recv_info),
+					       0);
+	if (!adapter->vport_recv_info) {
+		PMD_INIT_LOG(ERR, "Failed to allocate vport_recv_info memory");
+		goto err_vport_recv_info;
+	}
+
+	adapter->vports = rte_zmalloc("vports",
+				      adapter->max_vport_nb *
+				      sizeof(*adapter->vports),
+				      0);
+	if (!adapter->vports) {
+		PMD_INIT_LOG(ERR, "Failed to allocate vports memory");
+		goto err_vports;
+	}
+
+	adapter->max_rxq_per_msg = (IDPF_DFLT_MBX_BUF_SIZE -
+			       sizeof(struct virtchnl2_config_rx_queues)) /
+			       sizeof(struct virtchnl2_rxq_info);
+	adapter->max_txq_per_msg = (IDPF_DFLT_MBX_BUF_SIZE -
+			       sizeof(struct virtchnl2_config_tx_queues)) /
+			       sizeof(struct virtchnl2_txq_info);
+
+	adapter->cur_vports = 0;
+	adapter->cur_vport_nb = 0;
+	adapter->next_vport_idx = 0;
+
+	return ret;
+
+err_vports:
+	rte_free(adapter->vports);
+	adapter->vports = NULL;
+err_vport_recv_info:
+	rte_free(adapter->vport_req_info);
+	adapter->vport_req_info = NULL;
+err_caps:
+	rte_free(adapter->caps);
+	adapter->caps = NULL;
+err_api:
+	rte_free(adapter->mbx_resp);
+	adapter->mbx_resp = NULL;
+err_mbx:
+	iecm_ctlq_deinit(hw);
+err:
+	return -1;
+}
+
+
+static int
+idpf_dev_init(struct rte_eth_dev *dev, void *init_params)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = init_params;
+	int ret = 0;
+
+	PMD_INIT_FUNC_TRACE();
+
+	dev->dev_ops = &idpf_eth_dev_ops;
+	vport->adapter = adapter;
+
+	/* for secondary processes, we don't initialise any further as primary
+	 * has already done this work.
+	 */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return ret;
+
+	dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
+
+	ret = idpf_init_vport_req_info(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to init vport req_info.");
+		goto err;
+	}
+
+	ret = idpf_create_vport(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to create vport.");
+		goto err_create_vport;
+	}
+
+	ret = idpf_init_vport(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to init vports.");
+		goto err_init_vport;
+	}
+
+	dev->data->mac_addrs = rte_zmalloc(NULL, RTE_ETHER_ADDR_LEN, 0);
+	if (dev->data->mac_addrs == NULL) {
+		PMD_INIT_LOG(ERR, "Cannot allocate mac_addr memory.");
+		ret = -ENOMEM;
+		goto err_init_vport;
+	}
+
+	rte_ether_addr_copy((struct rte_ether_addr *)vport->default_mac_addr,
+			    &dev->data->mac_addrs[0]);
+
+	return 0;
+
+err_init_vport:
+	idpf_destroy_vport(vport);
+err_create_vport:
+	rte_free(vport->adapter->vport_req_info[vport->adapter->next_vport_idx]);
+err:
+	return ret;
+}
+
+static int
+idpf_dev_uninit(struct rte_eth_dev *dev)
+{
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	idpf_dev_close(dev);
+
+	return 0;
+}
+
+static const struct rte_pci_id pci_id_idpf_map[] = {
+	{ RTE_PCI_DEVICE(IECM_INTEL_VENDOR_ID, IECM_DEV_ID_PF) },
+	{ .vendor_id = 0, /* sentinel */ },
+};
+
+struct idpf_adapter *
+idpf_find_adapter(struct rte_pci_device *pci_dev)
+{
+	struct idpf_adapter *adapter;
+
+	TAILQ_FOREACH(adapter, &adapter_list, next) {
+		if (!strncmp(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE))
+			return adapter;
+	}
+
+	return NULL;
+}
+
+static int
+idpf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+	       struct rte_pci_device *pci_dev)
+{
+	struct idpf_adapter *adapter;
+	char name[RTE_ETH_NAME_MAX_LEN];
+	int i, retval;
+
+	if (!adapter_list_init) {
+		TAILQ_INIT(&adapter_list);
+		adapter_list_init = true;
+	}
+
+	adapter = idpf_find_adapter(pci_dev);
+	if (!adapter) {
+		adapter = (struct idpf_adapter *)rte_zmalloc("idpf_adapter",
+					     sizeof(struct idpf_adapter), 0);
+		if (!adapter) {
+			PMD_INIT_LOG(ERR, "Failed to allocate adapter.");
+			return -1;
+		}
+
+		retval = idpf_adapter_init(pci_dev, adapter);
+		if (retval) {
+			PMD_INIT_LOG(ERR, "Failed to init adapter.");
+			return retval;
+		}
+
+		TAILQ_INSERT_TAIL(&adapter_list, adapter, next);
+	}
+
+	retval = idpf_parse_devargs(pci_dev, adapter);
+	if (retval) {
+		PMD_INIT_LOG(ERR, "Failed to parse devargs");
+		return retval;
+	}
+
+	for (i = 0; i < adapter->req_vport_nb; i++) {
+		snprintf(name, sizeof(name), "idpf_%s_vport_%d",
+			 pci_dev->device.name,
+			 adapter->req_vports[i]);
+		retval = rte_eth_dev_create(&pci_dev->device, name,
+					    sizeof(struct idpf_vport),
+					    NULL, NULL, idpf_dev_init,
+					    adapter);
+		if (retval)
+			PMD_DRV_LOG(ERR, "failed to creat vport %d",
+				    adapter->req_vports[i]);
+	}
+
+	return 0;
+}
+
+static void
+idpf_adapter_rel(struct idpf_adapter *adapter)
+{
+	struct iecm_hw *hw = &adapter->hw;
+	int i;
+
+	iecm_ctlq_deinit(hw);
+
+	rte_free(adapter->caps);
+	adapter->caps = NULL;
+
+	rte_free(adapter->mbx_resp);
+	adapter->mbx_resp = NULL;
+
+	if (adapter->vport_req_info) {
+		for (i = 0; i < adapter->max_vport_nb; i++) {
+			rte_free(adapter->vport_req_info[i]);
+			adapter->vport_req_info[i] = NULL;
+		}
+		rte_free(adapter->vport_req_info);
+		adapter->vport_req_info = NULL;
+	}
+
+	if (adapter->vport_recv_info) {
+		for (i = 0; i < adapter->max_vport_nb; i++) {
+			rte_free(adapter->vport_recv_info[i]);
+			adapter->vport_recv_info[i] = NULL;
+		}
+	}
+
+	rte_free(adapter->vports);
+	adapter->vports = NULL;
+}
+
+static int
+idpf_pci_remove(struct rte_pci_device *pci_dev)
+{
+	struct idpf_adapter *adapter = idpf_find_adapter(pci_dev);
+	char name[RTE_ETH_NAME_MAX_LEN];
+	struct rte_eth_dev *eth_dev;
+	int i;
+
+	for (i = 0; i < IDPF_MAX_VPORT_NUM; i++) {
+		if (adapter->cur_vports & BIT(i)) {
+			snprintf(name, sizeof(name), "idpf_%s_vport_%d",
+				 pci_dev->device.name, i);
+			eth_dev = rte_eth_dev_allocated(name);
+			if (eth_dev)
+				rte_eth_dev_destroy(eth_dev, idpf_dev_uninit);
+		}
+	}
+
+	TAILQ_REMOVE(&adapter_list, adapter, next);
+	idpf_adapter_rel(adapter);
+	rte_free(adapter);
+
+	return 0;
+}
+
+static struct rte_pci_driver rte_idpf_pmd = {
+	.id_table	= pci_id_idpf_map,
+	.drv_flags	= RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_PROBE_AGAIN,
+	.probe		= idpf_pci_probe,
+	.remove		= idpf_pci_remove,
+};
+
+/**
+ * Driver initialization routine.
+ * Invoked once at EAL init time.
+ * Register itself as the [Poll Mode] Driver of PCI devices.
+ */
+RTE_PMD_REGISTER_PCI(net_idpf, rte_idpf_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(net_idpf, pci_id_idpf_map);
+RTE_PMD_REGISTER_KMOD_DEP(net_ice, "* igb_uio | uio_pci_generic | vfio-pci");
+
+RTE_LOG_REGISTER_SUFFIX(idpf_logtype_init, init, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(idpf_logtype_driver, driver, NOTICE);
drivers/net/idpf/idpf_ethdev.h new file +229 -0

229 lines not on this page · raw message

drivers/net/idpf/idpf_vchnl.c new file +495 -0

495 lines not on this page · raw message

drivers/net/idpf/meson.build new file +18 -0
new file mode 100644
index 0000000000..7d776d3a15
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+if is_windows
+	build = false
+	reason = 'not supported on Windows'
+	subdir_done()
+endif
+
+subdir('base')
+objs = [base_objs]
+
+sources = files(
+        'idpf_ethdev.c',
+	'idpf_vchnl.c',
+)
+
+includes += include_directories('base')
\ No newline at end of file
drivers/net/idpf/version.map new file +3 -0
new file mode 100644
index 0000000000..b7da224860
@@ -0,0 +1,3 @@
+DPDK_22 {
+	local: *;
+};
\ No newline at end of file
drivers/net/meson.build +1 -0
index e35652fe63..8faf8120c2 100644
@@ -28,6 +28,7 @@ drivers = [
         'i40e',
         'iavf',
         'ice',
+	'idpf',
         'igc',
         'ionic',
         'ipn3ke',
Signature · 1 line
2.25.1
#32 lore raw

RE: [PATCH v2 03/14] net/idpf: add support for device initialization

Quoted 36 lines

-----Original Message-----
From: Guo, Junfeng <[email protected]>
Sent: Monday, September 5, 2022 6:58 PM
To: Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>; Guo, Junfeng <[email protected]>; Li, Xiaoyun <[email protected]>
Subject: [PATCH v2 03/14] net/idpf: add support for device initialization

Support device init and the following dev ops:
- dev_configure
- dev_start
- dev_stop
- dev_close

---
 drivers/net/idpf/idpf_ethdev.c | 810
+++++++++++++++++++++++++++++++++  drivers/net/idpf/idpf_ethdev.h |
229 ++++++++++  drivers/net/idpf/idpf_vchnl.c  | 495
++++++++++++++++++++
 drivers/net/idpf/meson.build   |  18 +
 drivers/net/idpf/version.map   |   3 +
 drivers/net/meson.build        |   1 +
 6 files changed, 1556 insertions(+)
 create mode 100644 drivers/net/idpf/idpf_ethdev.c  create mode 100644

drivers/net/idpf/idpf_ethdev.h create mode 100644 drivers/net/idpf/idpf_vchnl.c create mode 100644 drivers/net/idpf/meson.build create mode 100644 drivers/net/idpf/version.map

<...>

Quoted 91 lines
drivers/net/idpf/idpf_ethdev.c new file +29 -0
+static int
+idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter
+*adapter) {
+	struct iecm_hw *hw = &adapter->hw;
+	int ret = 0;
+
+	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
+	hw->hw_addr_len = pci_dev->mem_resource[0].len;
+	hw->back = adapter;
+	hw->vendor_id = pci_dev->id.vendor_id;
+	hw->device_id = pci_dev->id.device_id;
+	hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
+
+	strncpy(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE);
+
+	idpf_reset_pf(hw);
+	ret = idpf_check_pf_reset_done(hw);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "IDPF is still resetting");
+		goto err;
+	}
+
+	ret = idpf_init_mbx(hw);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to init mailbox");
+		goto err;
+	}
+
+	adapter->mbx_resp = rte_zmalloc("idpf_adapter_mbx_resp",

IDPF_DFLT_MBX_BUF_SIZE, 0);

(quoted diff) +2 -0
+	if (!adapter->mbx_resp) {
+		PMD_INIT_LOG(ERR, "Failed to allocate

idpf_adapter_mbx_resp memory");

drivers/net/idpf/idpf_ethdev.c new file +28 -0
+		goto err_mbx;
+	}
+
+	if (idpf_check_api_version(adapter)) {
+		PMD_INIT_LOG(ERR, "Failed to check api version");
+		goto err_api;
+	}
+
+	adapter->caps = rte_zmalloc("idpf_caps",
+			       sizeof(struct virtchnl2_get_capabilities), 0);
+	if (!adapter->caps) {
+		PMD_INIT_LOG(ERR, "Failed to allocate idpf_caps memory");
+		goto err_api;
+	}
+
+	if (idpf_get_caps(adapter)) {
+		PMD_INIT_LOG(ERR, "Failed to get capabilities");
+		goto err_caps;
+	}
+
+	adapter->max_vport_nb = adapter->caps->max_vports;
+
+	adapter->vport_req_info = rte_zmalloc("vport_req_info",
+					      adapter->max_vport_nb *
+					      sizeof(*adapter->vport_req_info),
+					      0);
+	if (!adapter->vport_req_info) {
+		PMD_INIT_LOG(ERR, "Failed to allocate vport_req_info

memory");

drivers/net/idpf/idpf_ethdev.c new file +6 -0
+		goto err_caps;
+	}
+
+	adapter->vport_recv_info = rte_zmalloc("vport_recv_info",
+					       adapter->max_vport_nb *
+					       sizeof(*adapter-
Quoted 1 line

vport_recv_info),

drivers/net/idpf/idpf_ethdev.c new file +3 -0
+					       0);
+	if (!adapter->vport_recv_info) {
+		PMD_INIT_LOG(ERR, "Failed to allocate vport_recv_info

memory");

drivers/net/idpf/idpf_ethdev.c new file +18 -0
+		goto err_vport_recv_info;
+	}
+
+	adapter->vports = rte_zmalloc("vports",
+				      adapter->max_vport_nb *
+				      sizeof(*adapter->vports),
+				      0);
+	if (!adapter->vports) {
+		PMD_INIT_LOG(ERR, "Failed to allocate vports memory");
+		goto err_vports;
+	}
+
+	adapter->max_rxq_per_msg = (IDPF_DFLT_MBX_BUF_SIZE -
+			       sizeof(struct virtchnl2_config_rx_queues)) /
+			       sizeof(struct virtchnl2_rxq_info);
+	adapter->max_txq_per_msg = (IDPF_DFLT_MBX_BUF_SIZE -
+			       sizeof(struct virtchnl2_config_tx_queues)) /
+			       sizeof(struct virtchnl2_txq_info);

drivers/net/idpf/idpf_ethdev.c line 577

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c new file +10 -0
+
+	adapter->cur_vports = 0;
+	adapter->cur_vport_nb = 0;
+	adapter->next_vport_idx = 0;
+
+	return ret;
+
+err_vports:
+	rte_free(adapter->vports);
+	adapter->vports = NULL;

Need to free adapter->vport_recv_info here but not adapter->vports.

Quoted 16 lines
drivers/net/idpf/idpf_ethdev.c new file +16 -0
+err_vport_recv_info:
+	rte_free(adapter->vport_req_info);
+	adapter->vport_req_info = NULL;
+err_caps:
+	rte_free(adapter->caps);
+	adapter->caps = NULL;
+err_api:
+	rte_free(adapter->mbx_resp);
+	adapter->mbx_resp = NULL;
+err_mbx:
+	iecm_ctlq_deinit(hw);
+err:
+	return -1;
+}
+
+
#33 lore raw

RE: [PATCH v2 03/14] net/idpf: add support for device initialization

In reply to Junfeng Guo
Quoted 18 lines
drivers/net/idpf/idpf_ethdev.c new file +17 -0
+static void
+idpf_adapter_rel(struct idpf_adapter *adapter) {
+	struct iecm_hw *hw = &adapter->hw;
+	int i;
+
+	iecm_ctlq_deinit(hw);
+
+	rte_free(adapter->caps);
+	adapter->caps = NULL;
+
+	rte_free(adapter->mbx_resp);
+	adapter->mbx_resp = NULL;
+
+	if (adapter->vport_req_info) {
+		for (i = 0; i < adapter->max_vport_nb; i++) {
+			rte_free(adapter->vport_req_info[i]);
+			adapter->vport_req_info[i] = NULL;

drivers/net/idpf/idpf_ethdev.c line 761

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c new file +10 -0
+		}
+		rte_free(adapter->vport_req_info);
+		adapter->vport_req_info = NULL;
+	}
+
+	if (adapter->vport_recv_info) {
+		for (i = 0; i < adapter->max_vport_nb; i++) {
+			rte_free(adapter->vport_recv_info[i]);
+			adapter->vport_recv_info[i] = NULL;
+		}

Also need to free adapter->vport_recv_info here.

Quoted 6 lines
drivers/net/idpf/idpf_ethdev.c new file +6 -0
+	}
+
+	rte_free(adapter->vports);
+	adapter->vports = NULL;
+}
+
#34 lore raw

Re: [PATCH v2 03/14] net/idpf: add support for device initialization

In reply to Junfeng Guo
Quoted 5 lines · Junfeng Guo

Support device init and the following dev ops:
- dev_configure
- dev_start
- dev_stop
- dev_close

A bit strange set from my point of view since you can't start without setup queues. Each patch should be testable. It should be no dead code. It should be possible to stop after the patch, build, run, for example, testpmd and probe, configure, start, stop, close, unplug (depeneding on stage in the patch series).

The patch is really big. It definitely worse to split configre/close and start/stop (and reorder to have start after queues setup supported).

Quoted 61 lines
---
  drivers/net/idpf/idpf_ethdev.c | 810 +++++++++++++++++++++++++++++++++
  drivers/net/idpf/idpf_ethdev.h | 229 ++++++++++
  drivers/net/idpf/idpf_vchnl.c  | 495 ++++++++++++++++++++
  drivers/net/idpf/meson.build   |  18 +
  drivers/net/idpf/version.map   |   3 +
  drivers/net/meson.build        |   1 +
  6 files changed, 1556 insertions(+)

create mode 100644 drivers/net/idpf/idpf_ethdev.c create mode 100644 drivers/net/idpf/idpf_ethdev.h create mode 100644 drivers/net/idpf/idpf_vchnl.c create mode 100644 drivers/net/idpf/meson.build create mode 100644 drivers/net/idpf/version.map

drivers/net/idpf/idpf_ethdev.c new file +36 -0
new file mode 100644
index 0000000000..f0452de09e
@@ -0,0 +1,810 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#include <rte_atomic.h>
+#include <rte_eal.h>
+#include <rte_ether.h>
+#include <rte_malloc.h>
+#include <rte_memzone.h>
+#include <rte_dev.h>
+
+#include "idpf_ethdev.h"
+
+#define IDPF_VPORT		"vport"
+
+struct idpf_adapter_list adapter_list;
+bool adapter_list_init;
+
+uint64_t idpf_timestamp_dynflag;
+
+static const char * const idpf_valid_args[] = {
+	IDPF_VPORT,
+	NULL
+};
+
+static int idpf_dev_configure(struct rte_eth_dev *dev);
+static int idpf_dev_start(struct rte_eth_dev *dev);
+static int idpf_dev_stop(struct rte_eth_dev *dev);
+static int idpf_dev_close(struct rte_eth_dev *dev);
+
+static const struct eth_dev_ops idpf_eth_dev_ops = {
+	.dev_configure			= idpf_dev_configure,
+	.dev_start			= idpf_dev_start,
+	.dev_stop			= idpf_dev_stop,
+	.dev_close			= idpf_dev_close,
+};

drivers/net/idpf/idpf_ethdev.c line 46

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c new file +10 -0
+
+static int
+idpf_init_vport_req_info(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	struct virtchnl2_create_vport *vport_info;
+	uint16_t idx = adapter->next_vport_idx;
+
+	if (!adapter->vport_req_info[idx]) {

DPDK coding style requires explicit comparison vs NULL [1]. It is not applicable to base driver, but PMD itself should follow it. There is really huge number of places to fix.

It is applicable to comparision integers vs 0 as well.

[1] https://doc.dpdk.org/guides/contributing/coding_style.html#null-pointers

[snip]

drivers/net/idpf/idpf_ethdev.c line 208

Quoted 3 lines
drivers/net/idpf/idpf_ethdev.c new file +3 -0
+static int
+idpf_dev_configure(__rte_unused struct rte_eth_dev *dev)
+{

I'm really confusing that the configure as empty. It must validate configuration provided via rte_eth_dev_configure() and reject if something is not supported if ethdev does not the job.

Quoted 2 lines
drivers/net/idpf/idpf_ethdev.c new file +2 -0
+	return 0;
+}

[snip]

Quoted 11 lines
drivers/net/idpf/meson.build new file +5 -0
new file mode 100644
index 0000000000..7d776d3a15
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+if is_windows
+	build = false

drivers/net/idpf/meson.build line 15

Quoted 10 lines
drivers/net/idpf/meson.build new file +10 -0
+	reason = 'not supported on Windows'
+	subdir_done()
+endif
+
+subdir('base')
+objs = [base_objs]
+
+sources = files(
+        'idpf_ethdev.c',
+	'idpf_vchnl.c',

TAB vs spaces? Or is it just mail glitch?

Quoted 10 lines
drivers/net/idpf/meson.build new file +3 -0
+)
+
+includes += include_directories('base')
\ No newline at end of file
drivers/net/idpf/version.map new file +0 -0
new file mode 100644
index 0000000000..b7da224860

drivers/net/idpf/version.map line 3

Quoted 4 lines
drivers/net/idpf/version.map new file +3 -0
@@ -0,0 +1,3 @@
+DPDK_22 {
+	local: *;
+};
\ No newline at end of file

It must be an empty line at the end of file.

drivers/net/meson.build drivers = [ · line 31

Quoted 9 lines
drivers/net/meson.build +1 -0
index e35652fe63..8faf8120c2 100644
@@ -28,6 +28,7 @@ drivers = [
          'i40e',
          'iavf',
          'ice',
+	'idpf',

TAB vs spaces? Or is it just mail glitch?

Quoted 3 lines
drivers/net/meson.build +0 -0
          'igc',
          'ionic',
          'ipn3ke',
#35 lore raw

RE: [PATCH v2 03/14] net/idpf: add support for device initialization

Quoted 27 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 3, 2022 21:44
To: Guo, Junfeng <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>; Li, Xiaoyun <[email protected]>
Subject: Re: [PATCH v2 03/14] net/idpf: add support for device initialization

Quoted 5 lines · Junfeng Guo

Support device init and the following dev ops:
- dev_configure
- dev_start
- dev_stop
- dev_close

A bit strange set from my point of view since you can't start without setup queues. Each patch should be testable. It should be no dead code. It should be possible to stop after the patch, build, run, for example, testpmd and probe, configure, start, stop, close, unplug (depeneding on stage in the patch series).

Quoted 3 lines

The patch is really big. It definitely worse to split configre/close and start/stop (and reorder to have start after queues setup supported).

Well, this patch mainly implemented the device initiation, as well as adding the framework/skeleton of the config/start/stop/close ops. As for the dev start ops, we decide to firstly add the vports setup at this stage in this patch and later add other setups like queues and queue irqs. So in this way, it may be reasonable that the device could still start even without the queues setup. And yes, this PMD contains too much code with so many INITs. We will try to split them in the coming versions. Thanks!

Quoted 79 lines
Quoted 8 lines
---
  drivers/net/idpf/idpf_ethdev.c | 810

+++++++++++++++++++++++++++++++++

Quoted 6 lines
  drivers/net/idpf/idpf_ethdev.h | 229 ++++++++++
  drivers/net/idpf/idpf_vchnl.c  | 495 ++++++++++++++++++++
  drivers/net/idpf/meson.build   |  18 +
  drivers/net/idpf/version.map   |   3 +
  drivers/net/meson.build        |   1 +
  6 files changed, 1556 insertions(+)

Review

Quoted 7 lines

create mode 100644 drivers/net/idpf/idpf_ethdev.c create mode 100644 drivers/net/idpf/idpf_ethdev.h create mode 100644 drivers/net/idpf/idpf_vchnl.c create mode 100644 drivers/net/idpf/meson.build create mode 100644 drivers/net/idpf/version.map

(quoted diff) +0 -0

b/drivers/net/idpf/idpf_ethdev.c

Quoted 41 lines

new file mode 100644
index 0000000000..f0452de09e

drivers/net/idpf/idpf_ethdev.c new file +36 -0
@@ -0,0 +1,810 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#include <rte_atomic.h>
+#include <rte_eal.h>
+#include <rte_ether.h>
+#include <rte_malloc.h>
+#include <rte_memzone.h>
+#include <rte_dev.h>
+
+#include "idpf_ethdev.h"
+
+#define IDPF_VPORT		"vport"
+
+struct idpf_adapter_list adapter_list;
+bool adapter_list_init;
+
+uint64_t idpf_timestamp_dynflag;
+
+static const char * const idpf_valid_args[] = {
+	IDPF_VPORT,
+	NULL
+};
+
+static int idpf_dev_configure(struct rte_eth_dev *dev);
+static int idpf_dev_start(struct rte_eth_dev *dev);
+static int idpf_dev_stop(struct rte_eth_dev *dev);
+static int idpf_dev_close(struct rte_eth_dev *dev);
+
+static const struct eth_dev_ops idpf_eth_dev_ops = {
+	.dev_configure			= idpf_dev_configure,
+	.dev_start			= idpf_dev_start,
+	.dev_stop			= idpf_dev_stop,
+	.dev_close			= idpf_dev_close,
+};

drivers/net/idpf/idpf_ethdev.c line 46

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c new file +10 -0
+
+static int
+idpf_init_vport_req_info(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	struct virtchnl2_create_vport *vport_info;
+	uint16_t idx = adapter->next_vport_idx;
+
+	if (!adapter->vport_req_info[idx]) {

DPDK coding style requires explicit comparison vs NULL [1]. It is not applicable to base driver, but PMD itself should follow it. There is really huge number of places to fix.

Quoted 1 line

It is applicable to comparision integers vs 0 as well.

Will fix these in the coming versions. Thanks!

Quoted 6 lines

[1] https://doc.dpdk.org/guides/contributing/coding_style.html#null-
pointers

[snip]

Quoted 8 lines

drivers/net/idpf/idpf_ethdev.c line 208

Quoted 3 lines
drivers/net/idpf/idpf_ethdev.c new file +3 -0
+static int
+idpf_dev_configure(__rte_unused struct rte_eth_dev *dev)
+{

I'm really confusing that the configure as empty. It must validate configuration provided via rte_eth_dev_configure() and reject if something is not supported if ethdev does not the job.

Well, the initiation of some resources like vports are not put at this stage. It is flexible to add the framework/skeleton of the config/start/stop/close ops. Looks that it ok to implement like this... Thanks!

Quoted 21 lines
Quoted 3 lines
drivers/net/idpf/idpf_ethdev.c new file +2 -0
+	return 0;
+}

[snip]

Quoted 15 lines
drivers/net/idpf/meson.build new file +9 -0
new file mode 100644
index 0000000000..7d776d3a15
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+if is_windows
+	build = false
+	reason = 'not supported on Windows'
+	subdir_done()
+endif
+
Quoted 8 lines

drivers/net/idpf/meson.build line 15

Quoted 6 lines
drivers/net/idpf/meson.build new file +6 -0
+subdir('base')
+objs = [base_objs]
+
+sources = files(
+        'idpf_ethdev.c',
+	'idpf_vchnl.c',

TAB vs spaces? Or is it just mail glitch?

Will double check for this, thanks!

Quoted 17 lines
Quoted 11 lines
drivers/net/idpf/meson.build new file +3 -0
+)
+
+includes += include_directories('base')
\ No newline at end of file
drivers/net/idpf/version.map new file +0 -0
new file mode 100644
index 0000000000..b7da224860

drivers/net/idpf/version.map line 3

Quoted 4 lines
drivers/net/idpf/version.map new file +3 -0
@@ -0,0 +1,3 @@
+DPDK_22 {
+	local: *;
+};
\ No newline at end of file

It must be an empty line at the end of file.

Newline at EOF is not required for DPDK code.
This warning may be added by mistake.
Will double check for this, thanks!

Quoted 12 lines

drivers/net/meson.build drivers = [ · line 31

Quoted 10 lines
drivers/net/meson.build +1 -0
index e35652fe63..8faf8120c2 100644
@@ -28,6 +28,7 @@ drivers = [
          'i40e',
          'iavf',
          'ice',
+	'idpf',

TAB vs spaces? Or is it just mail glitch?

Will double check for this, thanks!

Quoted 4 lines
Quoted 4 lines
drivers/net/meson.build +0 -0
          'igc',
          'ionic',
          'ipn3ke',
#36 lore raw

RE: [PATCH v2 03/14] net/idpf: add support for device initialization

In reply to Junfeng Guo
Quoted 1,621 lines

-----Original Message-----
From: Junfeng Guo <[email protected]>
Sent: Monday, September 5, 2022 6:58 PM
To: Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>; Guo, Junfeng <[email protected]>; Li, Xiaoyun <[email protected]>
Subject: [PATCH v2 03/14] net/idpf: add support for device initialization

Support device init and the following dev ops:
- dev_configure
- dev_start
- dev_stop
- dev_close

---
 drivers/net/idpf/idpf_ethdev.c | 810
+++++++++++++++++++++++++++++++++  drivers/net/idpf/idpf_ethdev.h |
229 ++++++++++  drivers/net/idpf/idpf_vchnl.c  | 495
++++++++++++++++++++
 drivers/net/idpf/meson.build   |  18 +
 drivers/net/idpf/version.map   |   3 +
 drivers/net/meson.build        |   1 +
 6 files changed, 1556 insertions(+)
 create mode 100644 drivers/net/idpf/idpf_ethdev.c  create mode 100644

drivers/net/idpf/idpf_ethdev.h create mode 100644 drivers/net/idpf/idpf_vchnl.c create mode 100644 drivers/net/idpf/meson.build create mode 100644 drivers/net/idpf/version.map

drivers/net/idpf/idpf_ethdev.c new file +49 -0
new file mode 100644 index 0000000000..f0452de09e
@@ -0,0 +1,810 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#include <rte_atomic.h>
+#include <rte_eal.h>
+#include <rte_ether.h>
+#include <rte_malloc.h>
+#include <rte_memzone.h>
+#include <rte_dev.h>
+
+#include "idpf_ethdev.h"
+
+#define IDPF_VPORT		"vport"
+
+struct idpf_adapter_list adapter_list;
+bool adapter_list_init;
+
+uint64_t idpf_timestamp_dynflag;
+
+static const char * const idpf_valid_args[] = {
+	IDPF_VPORT,
+	NULL
+};
+
+static int idpf_dev_configure(struct rte_eth_dev *dev); static int
+idpf_dev_start(struct rte_eth_dev *dev); static int
+idpf_dev_stop(struct rte_eth_dev *dev); static int
+idpf_dev_close(struct rte_eth_dev *dev);
+
+static const struct eth_dev_ops idpf_eth_dev_ops = {
+	.dev_configure			= idpf_dev_configure,
+	.dev_start			= idpf_dev_start,
+	.dev_stop			= idpf_dev_stop,
+	.dev_close			= idpf_dev_close,
+};
+
+static int
+idpf_init_vport_req_info(struct rte_eth_dev *dev) {
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	struct virtchnl2_create_vport *vport_info;
+	uint16_t idx = adapter->next_vport_idx;
+
+	if (!adapter->vport_req_info[idx]) {
+		adapter->vport_req_info[idx] = rte_zmalloc(NULL,
+				    sizeof(struct virtchnl2_create_vport), 0);
+		if (!adapter->vport_req_info[idx]) {
+			PMD_INIT_LOG(ERR, "Failed to allocate

vport_req_info");

drivers/net/idpf/idpf_ethdev.c new file +6 -0
+			return -1;
+		}
+	}
+
+	vport_info =
+		(struct virtchnl2_create_vport *)adapter-
Quoted 1 line

vport_req_info[idx];

drivers/net/idpf/idpf_ethdev.c new file +2 -0
+
+	vport_info->vport_type =

rte_cpu_to_le_16(VIRTCHNL2_VPORT_TYPE_DEFAULT);

drivers/net/idpf/idpf_ethdev.c new file +6 -0
+	if (!adapter->txq_model) {
+		vport_info->txq_model =
+			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SPLIT);
+		vport_info->num_tx_q = IDPF_DEFAULT_TXQ_NUM;
+		vport_info->num_tx_complq =
+			IDPF_DEFAULT_TXQ_NUM *

IDPF_TX_COMPLQ_PER_GRP;

drivers/net/idpf/idpf_ethdev.c new file +3 -0
+	} else {
+		vport_info->txq_model =
+
	rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SINGLE);
drivers/net/idpf/idpf_ethdev.c new file +9 -0
+		vport_info->num_tx_q = IDPF_DEFAULT_TXQ_NUM;
+		vport_info->num_tx_complq = 0;
+	}
+	if (!adapter->rxq_model) {
+		vport_info->rxq_model =
+			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SPLIT);
+		vport_info->num_rx_q = IDPF_DEFAULT_RXQ_NUM;
+		vport_info->num_rx_bufq =
+			IDPF_DEFAULT_RXQ_NUM *

IDPF_RX_BUFQ_PER_GRP;

drivers/net/idpf/idpf_ethdev.c new file +3 -0
+	} else {
+		vport_info->rxq_model =
+
	rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SINGLE);
drivers/net/idpf/idpf_ethdev.c new file +9 -0
+		vport_info->num_rx_q = IDPF_DEFAULT_RXQ_NUM;
+		vport_info->num_rx_bufq = 0;
+	}
+
+	return 0;
+}
+
+static uint16_t
+idpf_get_next_vport_idx(struct idpf_vport **vports, uint16_t

max_vport_nb,

drivers/net/idpf/idpf_ethdev.c new file +48 -0
+			uint16_t cur_vport_idx)
+{
+	uint16_t vport_idx;
+	uint16_t i;
+
+	if (cur_vport_idx < max_vport_nb && !vports[cur_vport_idx + 1]) {
+		vport_idx = cur_vport_idx + 1;
+		return vport_idx;
+	}
+
+	for (i = 0; i < max_vport_nb; i++) {
+		if (!vports[i])
+			break;
+	}
+
+	if (i == max_vport_nb)
+		vport_idx = IDPF_INVALID_VPORT_IDX;
+	else
+		vport_idx = i;
+
+	return vport_idx;
+}
+
+static uint16_t
+idpf_parse_devarg_id(char *name)
+{
+	uint16_t val;
+	char *p;
+
+	p = strstr(name, "vport_");
+	p += sizeof("vport_") - 1;
+
+	val = strtoul(p, NULL, 10);
+
+	return val;
+}
+
+#ifndef IDPF_RSS_KEY_LEN
+#define IDPF_RSS_KEY_LEN 52
+#endif
+
+static int
+idpf_init_vport(struct rte_eth_dev *dev) {
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	uint16_t idx = adapter->next_vport_idx;
+	struct virtchnl2_create_vport *vport_info =
+		(struct virtchnl2_create_vport *)adapter-
Quoted 1 line

vport_recv_info[idx];

drivers/net/idpf/idpf_ethdev.c new file +27 -0
+	int i;
+
+	vport->vport_id = vport_info->vport_id;
+	vport->txq_model = vport_info->txq_model;
+	vport->rxq_model = vport_info->rxq_model;
+	vport->num_tx_q = vport_info->num_tx_q;
+	vport->num_tx_complq = vport_info->num_tx_complq;
+	vport->num_rx_q = vport_info->num_rx_q;
+	vport->num_rx_bufq = vport_info->num_rx_bufq;
+	vport->max_mtu = vport_info->max_mtu;
+	rte_memcpy(vport->default_mac_addr,
+		   vport_info->default_mac_addr, ETH_ALEN);
+	vport->rss_algorithm = vport_info->rss_algorithm;
+	vport->rss_key_size = RTE_MIN(IDPF_RSS_KEY_LEN,
+				     vport_info->rss_key_size);
+	vport->rss_lut_size = vport_info->rss_lut_size;
+	vport->sw_idx = idx;
+
+	for (i = 0; i < vport_info->chunks.num_chunks; i++) {
+		if (vport_info->chunks.chunks[i].type ==
+		    VIRTCHNL2_QUEUE_TYPE_TX) {
+			vport->chunks_info.tx_start_qid =
+				vport_info->chunks.chunks[i].start_queue_id;
+			vport->chunks_info.tx_qtail_start =
+				vport_info->chunks.chunks[i].qtail_reg_start;
+			vport->chunks_info.tx_qtail_spacing =
+				vport_info-
Quoted 1 line

chunks.chunks[i].qtail_reg_spacing;

drivers/net/idpf/idpf_ethdev.c new file +8 -0
+		} else if (vport_info->chunks.chunks[i].type ==
+			 VIRTCHNL2_QUEUE_TYPE_RX) {
+			vport->chunks_info.rx_start_qid =
+				vport_info->chunks.chunks[i].start_queue_id;
+			vport->chunks_info.rx_qtail_start =
+				vport_info->chunks.chunks[i].qtail_reg_start;
+			vport->chunks_info.rx_qtail_spacing =
+				vport_info-
Quoted 1 line

chunks.chunks[i].qtail_reg_spacing;

drivers/net/idpf/idpf_ethdev.c new file +8 -0
+		} else if (vport_info->chunks.chunks[i].type ==
+			 VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION) {
+			vport->chunks_info.tx_compl_start_qid =
+				vport_info->chunks.chunks[i].start_queue_id;
+			vport->chunks_info.tx_compl_qtail_start =
+				vport_info->chunks.chunks[i].qtail_reg_start;
+			vport->chunks_info.tx_compl_qtail_spacing =
+				vport_info-
Quoted 1 line

chunks.chunks[i].qtail_reg_spacing;

drivers/net/idpf/idpf_ethdev.c new file +8 -0
+		} else if (vport_info->chunks.chunks[i].type ==
+			 VIRTCHNL2_QUEUE_TYPE_RX_BUFFER) {
+			vport->chunks_info.rx_buf_start_qid =
+				vport_info->chunks.chunks[i].start_queue_id;
+			vport->chunks_info.rx_buf_qtail_start =
+				vport_info->chunks.chunks[i].qtail_reg_start;
+			vport->chunks_info.rx_buf_qtail_spacing =
+				vport_info-
Quoted 1 line

chunks.chunks[i].qtail_reg_spacing;

drivers/net/idpf/idpf_ethdev.c new file +6 -0
+		}
+	}
+
+	adapter->vports[idx] = vport;
+	adapter->next_vport_idx = idpf_get_next_vport_idx(adapter->vports,
+						  adapter->max_vport_nb,

idx);

drivers/net/idpf/idpf_ethdev.c new file +136 -0
+	if (adapter->next_vport_idx == IDPF_INVALID_VPORT_IDX) {
+		PMD_INIT_LOG(ERR, "Failed to get next vport id");
+		return -1;
+	}
+
+	vport->devarg_id = idpf_parse_devarg_id(dev->data->name);
+	vport->dev_data = dev->data;
+
+	return 0;
+}
+
+static int
+idpf_dev_configure(__rte_unused struct rte_eth_dev *dev) {
+	return 0;
+}
+
+static int
+idpf_dev_start(struct rte_eth_dev *dev) {
+	struct idpf_vport *vport = dev->data->dev_private;
+
+	PMD_INIT_FUNC_TRACE();
+
+	vport->stopped = 0;
+
+	if (idpf_ena_dis_vport(vport, true)) {
+		PMD_DRV_LOG(ERR, "Failed to enable vport");
+		goto err_vport;
+	}
+
+	return 0;
+
+err_vport:
+	return -1;
+}
+
+static int
+idpf_dev_stop(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (vport->stopped == 1)
+		return 0;
+
+	if (idpf_ena_dis_vport(vport, false))
+		PMD_DRV_LOG(ERR, "disable vport failed");
+
+	vport->stopped = 1;
+	dev->data->dev_started = 0;
+
+	return 0;
+}
+
+static int
+idpf_dev_close(struct rte_eth_dev *dev) {
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	idpf_dev_stop(dev);
+	idpf_destroy_vport(vport);
+
+	adapter->cur_vports &= ~BIT(vport->devarg_id);
+
+	rte_free(vport);
+	dev->data->dev_private = NULL;
+
+	return 0;
+}
+
+static int
+insert_value(struct idpf_adapter *adapter, uint16_t id) {
+	uint16_t i;
+
+	for (i = 0; i < adapter->req_vport_nb; i++) {
+		if (adapter->req_vports[i] == id)
+			return 0;
+	}
+
+	if (adapter->req_vport_nb >= RTE_DIM(adapter->req_vports)) {
+		PMD_INIT_LOG(ERR, "Total vport number can't be > %d",
+			     IDPF_MAX_VPORT_NUM);
+		return -1;
+	}
+
+	adapter->req_vports[adapter->req_vport_nb] = id;
+	adapter->req_vport_nb++;
+
+	return 0;
+}
+
+static const char *
+parse_range(const char *value, struct idpf_adapter *adapter) {
+	uint16_t lo, hi, i;
+	int n = 0;
+	int result;
+	const char *pos = value;
+
+	result = sscanf(value, "%hu%n-%hu%n", &lo, &n, &hi, &n);
+	if (result == 1) {
+		if (lo >= IDPF_MAX_VPORT_NUM)
+			return NULL;
+		if (insert_value(adapter, lo))
+			return NULL;
+	} else if (result == 2) {
+		if (lo > hi || hi >= IDPF_MAX_VPORT_NUM)
+			return NULL;
+		for (i = lo; i <= hi; i++) {
+			if (insert_value(adapter, i))
+				return NULL;
+		}
+	} else {
+		return NULL;
+	}
+
+	return pos + n;
+}
+
+static int
+parse_vport(const char *key, const char *value, void *args) {
+	struct idpf_adapter *adapter = (struct idpf_adapter *)args;
+	const char *pos = value;
+	int i;
+
+	adapter->req_vport_nb = 0;
+
+	if (*pos == '[')
+		pos++;
+
+	while (1) {
+		pos = parse_range(pos, adapter);
+		if (pos == NULL) {
+			PMD_INIT_LOG(ERR, "invalid value:\"%s\" for

key:\"%s\", ",

drivers/net/idpf/idpf_ethdev.c new file +27 -0
+				     value, key);
+			return -1;
+		}
+		if (*pos != ',')
+			break;
+		pos++;
+	}
+
+	if (*value == '[' && *pos != ']') {
+		PMD_INIT_LOG(ERR, "invalid value:\"%s\" for key:\"%s\", ",
+			    value, key);
+		return -1;
+	}
+
+	if (adapter->cur_vport_nb + adapter->req_vport_nb >
+	    IDPF_MAX_VPORT_NUM) {
+		PMD_INIT_LOG(ERR, "Total vport number can't be > %d",
+			    IDPF_MAX_VPORT_NUM);
+		return -1;
+	}
+
+	for (i = 0; i < adapter->req_vport_nb; i++) {
+		if (!(adapter->cur_vports & BIT(adapter->req_vports[i]))) {
+			adapter->cur_vports |= BIT(adapter->req_vports[i]);
+			adapter->cur_vport_nb++;
+		} else {
+			PMD_INIT_LOG(ERR, "Vport %d has been created",

adapter->req_vports[i]);

drivers/net/idpf/idpf_ethdev.c new file +73 -0
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
+static int
+idpf_parse_devargs(struct rte_pci_device *pci_dev, struct idpf_adapter
+*adapter) {
+	struct rte_devargs *devargs = pci_dev->device.devargs;
+	struct rte_kvargs *kvlist;
+	int ret;
+
+	if (!devargs)
+		return 0;
+
+	kvlist = rte_kvargs_parse(devargs->args, idpf_valid_args);
+	if (!kvlist) {
+		PMD_INIT_LOG(ERR, "invalid kvargs key");
+		return -EINVAL;
+	}
+
+	ret = rte_kvargs_process(kvlist, IDPF_VPORT, &parse_vport,
+		adapter);
+
+	rte_kvargs_free(kvlist);
+	return ret;
+}
+
+static void
+idpf_reset_pf(struct iecm_hw *hw)
+{
+	uint32_t reg;
+
+	reg = IECM_READ_REG(hw, PFGEN_CTRL);
+	IECM_WRITE_REG(hw, PFGEN_CTRL, (reg | PFGEN_CTRL_PFSWR)); }
+
+#define IDPF_RESET_WAIT_CNT 100
+static int
+idpf_check_pf_reset_done(struct iecm_hw *hw) {
+	uint32_t reg;
+	int i;
+
+	for (i = 0; i < IDPF_RESET_WAIT_CNT; i++) {
+		reg = IECM_READ_REG(hw, PFGEN_RSTAT);
+		if (reg != 0xFFFFFFFF && (reg & PFGEN_RSTAT_PFR_STATE_M))
+			return 0;
+		rte_delay_ms(1000);
+	}
+
+	PMD_INIT_LOG(ERR, "IDPF reset timeout");
+	return -EBUSY;
+}
+
+#define CTLQ_NUM 2
+static int
+idpf_init_mbx(struct iecm_hw *hw)
+{
+	struct iecm_ctlq_create_info ctlq_info[CTLQ_NUM] = {
+		{
+			.type = IECM_CTLQ_TYPE_MAILBOX_TX,
+			.id = IDPF_CTLQ_ID,
+			.len = IDPF_CTLQ_LEN,
+			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+			.reg = {
+				.head = PF_FW_ATQH,
+				.tail = PF_FW_ATQT,
+				.len = PF_FW_ATQLEN,
+				.bah = PF_FW_ATQBAH,
+				.bal = PF_FW_ATQBAL,
+				.len_mask = PF_FW_ATQLEN_ATQLEN_M,
+				.len_ena_mask =

PF_FW_ATQLEN_ATQENABLE_M,

drivers/net/idpf/idpf_ethdev.c new file +16 -0
+				.head_mask = PF_FW_ATQH_ATQH_M,
+			}
+		},
+		{
+			.type = IECM_CTLQ_TYPE_MAILBOX_RX,
+			.id = IDPF_CTLQ_ID,
+			.len = IDPF_CTLQ_LEN,
+			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+			.reg = {
+				.head = PF_FW_ARQH,
+				.tail = PF_FW_ARQT,
+				.len = PF_FW_ARQLEN,
+				.bah = PF_FW_ARQBAH,
+				.bal = PF_FW_ARQBAL,
+				.len_mask = PF_FW_ARQLEN_ARQLEN_M,
+				.len_ena_mask =

PF_FW_ARQLEN_ARQENABLE_M,

drivers/net/idpf/idpf_ethdev.c new file +14 -0
+				.head_mask = PF_FW_ARQH_ARQH_M,
+			}
+		}
+	};
+	struct iecm_ctlq_info *ctlq;
+	int ret;
+
+	ret = iecm_ctlq_init(hw, CTLQ_NUM, ctlq_info);
+	if (ret)
+		return ret;
+
+	LIST_FOR_EACH_ENTRY_SAFE(ctlq, NULL, &hw->cq_list_head,
+				 struct iecm_ctlq_info, cq_list) {
+		if (ctlq->q_id == IDPF_CTLQ_ID && ctlq->cq_type ==

IECM_CTLQ_TYPE_MAILBOX_TX)

drivers/net/idpf/idpf_ethdev.c new file +2 -0
+			hw->asq = ctlq;
+		if (ctlq->q_id == IDPF_CTLQ_ID && ctlq->cq_type ==

IECM_CTLQ_TYPE_MAILBOX_RX)

drivers/net/idpf/idpf_ethdev.c new file +40 -0
+			hw->arq = ctlq;
+	}
+
+	if (!hw->asq || !hw->arq) {
+		iecm_ctlq_deinit(hw);
+		ret = -ENOENT;
+	}
+
+	return ret;
+}
+
+static int
+idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter
+*adapter) {
+	struct iecm_hw *hw = &adapter->hw;
+	int ret = 0;
+
+	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
+	hw->hw_addr_len = pci_dev->mem_resource[0].len;
+	hw->back = adapter;
+	hw->vendor_id = pci_dev->id.vendor_id;
+	hw->device_id = pci_dev->id.device_id;
+	hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
+
+	strncpy(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE);
+
+	idpf_reset_pf(hw);
+	ret = idpf_check_pf_reset_done(hw);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "IDPF is still resetting");
+		goto err;
+	}
+
+	ret = idpf_init_mbx(hw);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to init mailbox");
+		goto err;
+	}
+
+	adapter->mbx_resp = rte_zmalloc("idpf_adapter_mbx_resp",

IDPF_DFLT_MBX_BUF_SIZE, 0);

drivers/net/idpf/idpf_ethdev.c new file +2 -0
+	if (!adapter->mbx_resp) {
+		PMD_INIT_LOG(ERR, "Failed to allocate

idpf_adapter_mbx_resp memory");

drivers/net/idpf/idpf_ethdev.c new file +28 -0
+		goto err_mbx;
+	}
+
+	if (idpf_check_api_version(adapter)) {
+		PMD_INIT_LOG(ERR, "Failed to check api version");
+		goto err_api;
+	}
+
+	adapter->caps = rte_zmalloc("idpf_caps",
+			       sizeof(struct virtchnl2_get_capabilities), 0);
+	if (!adapter->caps) {
+		PMD_INIT_LOG(ERR, "Failed to allocate idpf_caps memory");
+		goto err_api;
+	}
+
+	if (idpf_get_caps(adapter)) {
+		PMD_INIT_LOG(ERR, "Failed to get capabilities");
+		goto err_caps;
+	}
+
+	adapter->max_vport_nb = adapter->caps->max_vports;
+
+	adapter->vport_req_info = rte_zmalloc("vport_req_info",
+					      adapter->max_vport_nb *
+					      sizeof(*adapter->vport_req_info),
+					      0);
+	if (!adapter->vport_req_info) {
+		PMD_INIT_LOG(ERR, "Failed to allocate vport_req_info

memory");

drivers/net/idpf/idpf_ethdev.c new file +6 -0
+		goto err_caps;
+	}
+
+	adapter->vport_recv_info = rte_zmalloc("vport_recv_info",
+					       adapter->max_vport_nb *
+					       sizeof(*adapter-
Quoted 1 line

vport_recv_info),

drivers/net/idpf/idpf_ethdev.c new file +3 -0
+					       0);
+	if (!adapter->vport_recv_info) {
+		PMD_INIT_LOG(ERR, "Failed to allocate vport_recv_info

memory");

drivers/net/idpf/idpf_ethdev.c new file +82 -0
+		goto err_vport_recv_info;
+	}
+
+	adapter->vports = rte_zmalloc("vports",
+				      adapter->max_vport_nb *
+				      sizeof(*adapter->vports),
+				      0);
+	if (!adapter->vports) {
+		PMD_INIT_LOG(ERR, "Failed to allocate vports memory");
+		goto err_vports;
+	}
+
+	adapter->max_rxq_per_msg = (IDPF_DFLT_MBX_BUF_SIZE -
+			       sizeof(struct virtchnl2_config_rx_queues)) /
+			       sizeof(struct virtchnl2_rxq_info);
+	adapter->max_txq_per_msg = (IDPF_DFLT_MBX_BUF_SIZE -
+			       sizeof(struct virtchnl2_config_tx_queues)) /
+			       sizeof(struct virtchnl2_txq_info);
+
+	adapter->cur_vports = 0;
+	adapter->cur_vport_nb = 0;
+	adapter->next_vport_idx = 0;
+
+	return ret;
+
+err_vports:
+	rte_free(adapter->vports);
+	adapter->vports = NULL;
+err_vport_recv_info:
+	rte_free(adapter->vport_req_info);
+	adapter->vport_req_info = NULL;
+err_caps:
+	rte_free(adapter->caps);
+	adapter->caps = NULL;
+err_api:
+	rte_free(adapter->mbx_resp);
+	adapter->mbx_resp = NULL;
+err_mbx:
+	iecm_ctlq_deinit(hw);
+err:
+	return -1;
+}
+
+
+static int
+idpf_dev_init(struct rte_eth_dev *dev, void *init_params) {
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = init_params;
+	int ret = 0;
+
+	PMD_INIT_FUNC_TRACE();
+
+	dev->dev_ops = &idpf_eth_dev_ops;
+	vport->adapter = adapter;
+
+	/* for secondary processes, we don't initialise any further as primary
+	 * has already done this work.
+	 */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return ret;
+
+	dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
+
+	ret = idpf_init_vport_req_info(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to init vport req_info.");
+		goto err;
+	}
+
+	ret = idpf_create_vport(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to create vport.");
+		goto err_create_vport;
+	}
+
+	ret = idpf_init_vport(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to init vports.");
+		goto err_init_vport;
+	}
+
+	dev->data->mac_addrs = rte_zmalloc(NULL, RTE_ETHER_ADDR_LEN,

0);

drivers/net/idpf/idpf_ethdev.c new file +7 -0
+	if (dev->data->mac_addrs == NULL) {
+		PMD_INIT_LOG(ERR, "Cannot allocate mac_addr memory.");
+		ret = -ENOMEM;
+		goto err_init_vport;
+	}
+
+	rte_ether_addr_copy((struct rte_ether_addr *)vport-
Quoted 1 line

default_mac_addr,

drivers/net/idpf/idpf_ethdev.c new file +35 -0
+			    &dev->data->mac_addrs[0]);
+
+	return 0;
+
+err_init_vport:
+	idpf_destroy_vport(vport);
+err_create_vport:
+
+rte_free(vport->adapter->vport_req_info[vport->adapter->next_vport_idx]
+);
+err:
+	return ret;
+}
+
+static int
+idpf_dev_uninit(struct rte_eth_dev *dev) {
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	idpf_dev_close(dev);
+
+	return 0;
+}
+
+static const struct rte_pci_id pci_id_idpf_map[] = {
+	{ RTE_PCI_DEVICE(IECM_INTEL_VENDOR_ID, IECM_DEV_ID_PF) },
+	{ .vendor_id = 0, /* sentinel */ },
+};
+
+struct idpf_adapter *
+idpf_find_adapter(struct rte_pci_device *pci_dev) {
+	struct idpf_adapter *adapter;
+
+	TAILQ_FOREACH(adapter, &adapter_list, next) {
+		if (!strncmp(adapter->name, pci_dev->device.name,

PCI_PRI_STR_SIZE))

drivers/net/idpf/idpf_ethdev.c new file +105 -0
+			return adapter;
+	}
+
+	return NULL;
+}
+
+static int
+idpf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+	       struct rte_pci_device *pci_dev) {
+	struct idpf_adapter *adapter;
+	char name[RTE_ETH_NAME_MAX_LEN];
+	int i, retval;
+
+	if (!adapter_list_init) {
+		TAILQ_INIT(&adapter_list);
+		adapter_list_init = true;
+	}
+
+	adapter = idpf_find_adapter(pci_dev);
+	if (!adapter) {
+		adapter = (struct idpf_adapter *)rte_zmalloc("idpf_adapter",
+					     sizeof(struct idpf_adapter), 0);
+		if (!adapter) {
+			PMD_INIT_LOG(ERR, "Failed to allocate adapter.");
+			return -1;
+		}
+
+		retval = idpf_adapter_init(pci_dev, adapter);
+		if (retval) {
+			PMD_INIT_LOG(ERR, "Failed to init adapter.");
+			return retval;
+		}
+
+		TAILQ_INSERT_TAIL(&adapter_list, adapter, next);
+	}
+
+	retval = idpf_parse_devargs(pci_dev, adapter);
+	if (retval) {
+		PMD_INIT_LOG(ERR, "Failed to parse devargs");
+		return retval;
+	}
+
+	for (i = 0; i < adapter->req_vport_nb; i++) {
+		snprintf(name, sizeof(name), "idpf_%s_vport_%d",
+			 pci_dev->device.name,
+			 adapter->req_vports[i]);
+		retval = rte_eth_dev_create(&pci_dev->device, name,
+					    sizeof(struct idpf_vport),
+					    NULL, NULL, idpf_dev_init,
+					    adapter);
+		if (retval)
+			PMD_DRV_LOG(ERR, "failed to creat vport %d",
+				    adapter->req_vports[i]);
+	}
+
+	return 0;
+}
+
+static void
+idpf_adapter_rel(struct idpf_adapter *adapter) {
+	struct iecm_hw *hw = &adapter->hw;
+	int i;
+
+	iecm_ctlq_deinit(hw);
+
+	rte_free(adapter->caps);
+	adapter->caps = NULL;
+
+	rte_free(adapter->mbx_resp);
+	adapter->mbx_resp = NULL;
+
+	if (adapter->vport_req_info) {
+		for (i = 0; i < adapter->max_vport_nb; i++) {
+			rte_free(adapter->vport_req_info[i]);
+			adapter->vport_req_info[i] = NULL;
+		}
+		rte_free(adapter->vport_req_info);
+		adapter->vport_req_info = NULL;
+	}
+
+	if (adapter->vport_recv_info) {
+		for (i = 0; i < adapter->max_vport_nb; i++) {
+			rte_free(adapter->vport_recv_info[i]);
+			adapter->vport_recv_info[i] = NULL;
+		}
+	}
+
+	rte_free(adapter->vports);
+	adapter->vports = NULL;
+}
+
+static int
+idpf_pci_remove(struct rte_pci_device *pci_dev) {
+	struct idpf_adapter *adapter = idpf_find_adapter(pci_dev);
+	char name[RTE_ETH_NAME_MAX_LEN];
+	struct rte_eth_dev *eth_dev;
+	int i;
+
+	for (i = 0; i < IDPF_MAX_VPORT_NUM; i++) {
+		if (adapter->cur_vports & BIT(i)) {
+			snprintf(name, sizeof(name), "idpf_%s_vport_%d",
+				 pci_dev->device.name, i);
+			eth_dev = rte_eth_dev_allocated(name);
+			if (eth_dev)
+				rte_eth_dev_destroy(eth_dev,

idpf_dev_uninit);

drivers/net/idpf/idpf_ethdev.c new file +13 -0
+		}
+	}
+
+	TAILQ_REMOVE(&adapter_list, adapter, next);
+	idpf_adapter_rel(adapter);
+	rte_free(adapter);
+
+	return 0;
+}
+
+static struct rte_pci_driver rte_idpf_pmd = {
+	.id_table	= pci_id_idpf_map,
+	.drv_flags	= RTE_PCI_DRV_NEED_MAPPING |

RTE_PCI_DRV_PROBE_AGAIN,

drivers/net/idpf/idpf_ethdev.c new file +16 -0
+	.probe		= idpf_pci_probe,
+	.remove		= idpf_pci_remove,
+};
+
+/**
+ * Driver initialization routine.
+ * Invoked once at EAL init time.
+ * Register itself as the [Poll Mode] Driver of PCI devices.
+ */
+RTE_PMD_REGISTER_PCI(net_idpf, rte_idpf_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(net_idpf, pci_id_idpf_map);
+RTE_PMD_REGISTER_KMOD_DEP(net_ice, "* igb_uio | uio_pci_generic |
+vfio-pci");
+
+RTE_LOG_REGISTER_SUFFIX(idpf_logtype_init, init, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(idpf_logtype_driver, driver, NOTICE);
drivers/net/idpf/idpf_ethdev.h new file +54 -0
new file mode 100644 index 0000000000..e60ba73ec1
@@ -0,0 +1,229 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#ifndef _IDPF_ETHDEV_H_
+#define _IDPF_ETHDEV_H_
+
+#include <stdint.h>
+#include <rte_mbuf.h>
+#include <rte_mempool.h>
+#include <rte_malloc.h>
+#include <rte_spinlock.h>
+#include <rte_ethdev.h>
+#include <rte_kvargs.h>
+#include <ethdev_driver.h>
+#include <ethdev_pci.h>
+
+#include "base/iecm_osdep.h"
+#include "base/iecm_type.h"
+#include "base/iecm_devids.h"
+#include "base/iecm_lan_txrx.h"
+#include "base/iecm_lan_pf_regs.h"
+#include "base/virtchnl.h"
+#include "base/virtchnl2.h"
+
+#define IDPF_MAX_VPORT_NUM	8
+
+#define IDPF_DEFAULT_RXQ_NUM	16
+#define IDPF_DEFAULT_TXQ_NUM	16
+
+#define IDPF_INVALID_VPORT_IDX	0xffff
+#define IDPF_TXQ_PER_GRP	1
+#define IDPF_TX_COMPLQ_PER_GRP	1
+#define IDPF_RXQ_PER_GRP	1
+#define IDPF_RX_BUFQ_PER_GRP	2
+
+#define IDPF_CTLQ_ID		-1
+#define IDPF_CTLQ_LEN		64
+#define IDPF_DFLT_MBX_BUF_SIZE	4096
+
+#define IDPF_DFLT_Q_VEC_NUM	1
+#define IDPF_DFLT_INTERVAL	16
+
+#define IDPF_MAX_NUM_QUEUES	256
+#define IDPF_MIN_BUF_SIZE	1024
+#define IDPF_MAX_FRAME_SIZE	9728
+
+#define IDPF_NUM_MACADDR_MAX	64
+
+#define IDPF_MAX_PKT_TYPE	1024
+
+#define IDPF_VLAN_TAG_SIZE	4
+#define IDPF_ETH_OVERHEAD \
+	(RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN +

IDPF_VLAN_TAG_SIZE * 2)

drivers/net/idpf/idpf_ethdev.h new file +34 -0
+
+#ifndef ETH_ADDR_LEN
+#define ETH_ADDR_LEN		6
+#endif
+
+#define IDPF_ADAPTER_NAME_LEN	(PCI_PRI_STR_SIZE + 1)
+
+/* Message type read in virtual channel from PF */ enum idpf_vc_result
+{
+	IDPF_MSG_ERR = -1, /* Meet error when accessing admin queue */
+	IDPF_MSG_NON,      /* Read nothing from admin queue */
+	IDPF_MSG_SYS,      /* Read system msg from admin queue */
+	IDPF_MSG_CMD,      /* Read async command result */
+};
+
+struct idpf_chunks_info {
+	uint32_t tx_start_qid;
+	uint32_t rx_start_qid;
+	/* Valid only if split queue model */
+	uint32_t tx_compl_start_qid;
+	uint32_t rx_buf_start_qid;
+
+	uint64_t tx_qtail_start;
+	uint32_t tx_qtail_spacing;
+	uint64_t rx_qtail_start;
+	uint32_t rx_qtail_spacing;
+	uint64_t tx_compl_qtail_start;
+	uint32_t tx_compl_qtail_spacing;
+	uint64_t rx_buf_qtail_start;
+	uint32_t rx_buf_qtail_spacing;
+};
+
+struct idpf_vport {
+	struct idpf_adapter *adapter; /* Backreference to associated adapter

*/

drivers/net/idpf/idpf_ethdev.h new file +52 -0
+	uint16_t vport_id;
+	uint32_t txq_model;
+	uint32_t rxq_model;
+	uint16_t num_tx_q;
+	/* valid only if txq_model is split Q */
+	uint16_t num_tx_complq;
+	uint16_t num_rx_q;
+	/* valid only if rxq_model is split Q */
+	uint16_t num_rx_bufq;
+
+	uint16_t max_mtu;
+	uint8_t default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
+
+	enum virtchnl_rss_algorithm rss_algorithm;
+	uint16_t rss_key_size;
+	uint16_t rss_lut_size;
+
+	uint16_t sw_idx; /* SW idx */
+
+	struct rte_eth_dev_data *dev_data; /* Pointer to the device data */
+	uint16_t max_pkt_len; /* Maximum packet length */
+
+	/* RSS info */
+	uint32_t *rss_lut;
+	uint8_t *rss_key;
+	uint64_t rss_hf;
+
+	/* MSIX info*/
+	struct virtchnl2_queue_vector *qv_map; /* queue vector mapping */
+	uint16_t max_vectors;
+	struct virtchnl2_alloc_vectors *recv_vectors;
+
+	/* Chunk info */
+	struct idpf_chunks_info chunks_info;
+
+	/* Event from ipf */
+	bool link_up;
+	uint32_t link_speed;
+
+	uint16_t devarg_id;
+	bool stopped;
+	struct virtchnl2_vport_stats eth_stats_offset; };
+
+struct idpf_adapter {
+	TAILQ_ENTRY(idpf_adapter) next;
+	struct iecm_hw hw;
+	char name[IDPF_ADAPTER_NAME_LEN];
+
+	struct virtchnl_version_info virtchnl_version;
+	struct virtchnl2_get_capabilities *caps;
+
+	volatile enum virtchnl_ops pend_cmd; /* pending command not

finished */

drivers/net/idpf/idpf_ethdev.h new file +2 -0
+	uint32_t cmd_retval; /* return value of the cmd response from ipf */
+	uint8_t *mbx_resp; /* buffer to store the mailbox response from ipf

*/

drivers/net/idpf/idpf_ethdev.h new file +63 -0
+
+	uint32_t txq_model;
+	uint32_t rxq_model;
+
+	/* Vport info */
+	uint8_t **vport_req_info;
+	uint8_t **vport_recv_info;
+	struct idpf_vport **vports;
+	uint16_t max_vport_nb;
+	uint16_t req_vports[IDPF_MAX_VPORT_NUM];
+	uint16_t req_vport_nb;
+	uint16_t cur_vports;
+	uint16_t cur_vport_nb;
+	uint16_t next_vport_idx;
+
+	uint16_t used_vecs_num;
+
+	/* Max config queue number per VC message */
+	uint32_t max_rxq_per_msg;
+	uint32_t max_txq_per_msg;
+
+	uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned;
+
+	bool stopped;
+};
+
+TAILQ_HEAD(idpf_adapter_list, idpf_adapter); extern struct
+idpf_adapter_list adapter_list;
+
+#define IDPF_DEV_TO_PCI(eth_dev)		\
+	RTE_DEV_TO_PCI((eth_dev)->device)
+
+/* structure used for sending and checking response of virtchnl ops */
+struct idpf_cmd_info {
+	uint32_t ops;
+	uint8_t *in_args;       /* buffer for sending */
+	uint32_t in_args_size;  /* buffer size for sending */
+	uint8_t *out_buffer;    /* buffer for response */
+	uint32_t out_size;      /* buffer size for response */
+};
+
+/* notify current command done. Only call in case execute
+ * _atomic_set_cmd successfully.
+ */
+static inline void
+_notify_cmd(struct idpf_adapter *adapter, int msg_ret) {
+	adapter->cmd_retval = msg_ret;
+	rte_wmb();
+	adapter->pend_cmd = VIRTCHNL_OP_UNKNOWN; }
+
+/* clear current command. Only call in case execute
+ * _atomic_set_cmd successfully.
+ */
+static inline void
+_clear_cmd(struct idpf_adapter *adapter) {
+	rte_wmb();
+	adapter->pend_cmd = VIRTCHNL_OP_UNKNOWN;
+	adapter->cmd_retval = VIRTCHNL_STATUS_SUCCESS; }
+
+/* Check there is pending cmd in execution. If none, set new command.
+*/ static inline int _atomic_set_cmd(struct idpf_adapter *adapter, enum
+virtchnl_ops ops) {
+	int ret = rte_atomic32_cmpset(&adapter->pend_cmd,

VIRTCHNL_OP_UNKNOWN,

drivers/net/idpf/idpf_ethdev.h new file +4 -0
+ops);
+
+	if (!ret)
+		PMD_DRV_LOG(ERR, "There is incomplete cmd %d", adapter-
Quoted 1 line

pend_cmd);

drivers/net/idpf/idpf_ethdev.h new file +15 -0
+
+	return !ret;
+}
+
+struct idpf_adapter *idpf_find_adapter(struct rte_pci_device *pci_dev);
+void idpf_handle_virtchnl_msg(struct rte_eth_dev *dev); int
+idpf_check_api_version(struct idpf_adapter *adapter); int
+idpf_get_caps(struct idpf_adapter *adapter); int
+idpf_create_vport(struct rte_eth_dev *dev); int
+idpf_destroy_vport(struct idpf_vport *vport); int
+idpf_ena_dis_vport(struct idpf_vport *vport, bool enable); int
+idpf_read_one_msg(struct idpf_adapter *adapter, uint32_t ops,
+		      uint16_t buf_len, uint8_t *buf);
+
+#endif /* _IDPF_ETHDEV_H_ */
drivers/net/idpf/idpf_vchnl.c new renamed from drivers/net/idpf/idpf_vchnl.c +0 -0

file mode 100644 index 0000000000..4708fb0666

drivers/net/idpf/idpf_vchnl.c new file +38 -0
@@ -0,0 +1,495 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <inttypes.h>
+#include <rte_byteorder.h>
+#include <rte_common.h>
+
+#include <rte_debug.h>
+#include <rte_atomic.h>
+#include <rte_eal.h>
+#include <rte_ether.h>
+#include <ethdev_driver.h>
+#include <ethdev_pci.h>
+#include <rte_dev.h>
+
+#include "idpf_ethdev.h"
+
+#include "base/iecm_prototype.h"
+
+#define IDPF_CTLQ_LEN	64
+
+static int
+idpf_vc_clean(struct idpf_adapter *adapter) {
+	struct iecm_ctlq_msg *q_msg[IDPF_CTLQ_LEN];
+	uint16_t num_q_msg = IDPF_CTLQ_LEN;
+	struct iecm_dma_mem *dma_mem;
+	int err = 0;
+	uint32_t i;
+
+	for (i = 0; i < 10; i++) {
+		err = iecm_ctlq_clean_sq(adapter->hw.asq, &num_q_msg,

q_msg);

drivers/net/idpf/idpf_vchnl.c new file +102 -0
+		msleep(20);
+		if (num_q_msg)
+			break;
+	}
+	if (err)
+		goto error;
+
+	/* Empty queue is not an error */
+	for (i = 0; i < num_q_msg; i++) {
+		dma_mem = q_msg[i]->ctx.indirect.payload;
+		if (dma_mem) {
+			iecm_free_dma_mem(&adapter->hw, dma_mem);
+			rte_free(dma_mem);
+		}
+		rte_free(q_msg[i]);
+	}
+
+error:
+	return err;
+}
+
+static int
+idpf_send_vc_msg(struct idpf_adapter *adapter, enum virtchnl_ops op,
+		 uint16_t msg_size, uint8_t *msg)
+{
+	struct iecm_ctlq_msg *ctlq_msg;
+	struct iecm_dma_mem *dma_mem;
+	int err = 0;
+
+	err = idpf_vc_clean(adapter);
+	if (err)
+		goto err;
+
+	ctlq_msg = (struct iecm_ctlq_msg *)rte_zmalloc(NULL,
+				sizeof(struct iecm_ctlq_msg), 0);
+	if (!ctlq_msg) {
+		err = -ENOMEM;
+		goto err;
+	}
+
+	dma_mem = (struct iecm_dma_mem *)rte_zmalloc(NULL,
+				sizeof(struct iecm_dma_mem), 0);
+	if (!dma_mem) {
+		err = -ENOMEM;
+		goto dma_mem_error;
+	}
+
+	dma_mem->size = IDPF_DFLT_MBX_BUF_SIZE;
+	iecm_alloc_dma_mem(&adapter->hw, dma_mem, dma_mem->size);
+	if (!dma_mem->va) {
+		err = -ENOMEM;
+		goto dma_alloc_error;
+	}
+
+	memcpy(dma_mem->va, msg, msg_size);
+
+	ctlq_msg->opcode = iecm_mbq_opc_send_msg_to_pf;
+	ctlq_msg->func_id = 0;
+	ctlq_msg->data_len = msg_size;
+	ctlq_msg->cookie.mbx.chnl_opcode = op;
+	ctlq_msg->cookie.mbx.chnl_retval = VIRTCHNL_STATUS_SUCCESS;
+	ctlq_msg->ctx.indirect.payload = dma_mem;
+
+	err = iecm_ctlq_send(&adapter->hw, adapter->hw.asq, 1, ctlq_msg);
+	if (err)
+		goto send_error;
+
+	return err;
+
+send_error:
+	iecm_free_dma_mem(&adapter->hw, dma_mem);
+dma_alloc_error:
+	rte_free(dma_mem);
+dma_mem_error:
+	rte_free(ctlq_msg);
+err:
+	return err;
+}
+
+static enum idpf_vc_result
+idpf_read_msg_from_ipf(struct idpf_adapter *adapter, uint16_t buf_len,
+		       uint8_t *buf)
+{
+	struct iecm_hw *hw = &adapter->hw;
+	struct iecm_ctlq_msg ctlq_msg;
+	struct iecm_dma_mem *dma_mem = NULL;
+	enum idpf_vc_result result = IDPF_MSG_NON;
+	enum virtchnl_ops opcode;
+	uint16_t pending = 1;
+	int ret;
+
+	ret = iecm_ctlq_recv(hw->arq, &pending, &ctlq_msg);
+	if (ret) {
+		PMD_DRV_LOG(DEBUG, "Can't read msg from AQ");
+		if (ret != IECM_ERR_CTLQ_NO_WORK)
+			result = IDPF_MSG_ERR;
+		return result;
+	}
+
+	rte_memcpy(buf, ctlq_msg.ctx.indirect.payload->va, buf_len);
+
+	opcode = (enum

virtchnl_ops)rte_le_to_cpu_32(ctlq_msg.cookie.mbx.chnl_opcode);

drivers/net/idpf/idpf_vchnl.c new file +10 -0
+	adapter->cmd_retval =
+		(enum
+virtchnl_status_code)rte_le_to_cpu_32(ctlq_msg.cookie.mbx.chnl_retval);
+
+	PMD_DRV_LOG(DEBUG, "CQ from ipf carries opcode %u, retval %d",
+		    opcode, adapter->cmd_retval);
+
+	if (opcode == VIRTCHNL2_OP_EVENT) {
+		struct virtchnl2_event *ve =
+			(struct virtchnl2_event

*)ctlq_msg.ctx.indirect.payload->va;

drivers/net/idpf/idpf_vchnl.c new file +8 -0
+
+		result = IDPF_MSG_SYS;
+		switch (ve->event) {
+		case VIRTCHNL2_EVENT_LINK_CHANGE:
+			/* TBD */
+			break;
+		default:
+			PMD_DRV_LOG(ERR, "%s: Unknown event %d from

ipf",

drivers/net/idpf/idpf_vchnl.c new file +8 -0
+				    __func__, ve->event);
+			break;
+		}
+	} else {
+		/* async reply msg on command issued by pf previously */
+		result = IDPF_MSG_CMD;
+		if (opcode != adapter->pend_cmd) {
+			PMD_DRV_LOG(WARNING, "command mismatch,

expect %u, get %u",

drivers/net/idpf/idpf_vchnl.c new file +22 -0
+				    adapter->pend_cmd, opcode);
+			result = IDPF_MSG_ERR;
+		}
+	}
+
+	if (ctlq_msg.data_len)
+		dma_mem = ctlq_msg.ctx.indirect.payload;
+	else
+		pending = 0;
+
+	ret = iecm_ctlq_post_rx_buffs(hw, hw->arq, &pending, &dma_mem);
+	if (ret && dma_mem)
+		iecm_free_dma_mem(hw, dma_mem);
+
+	return result;
+}
+
+#define MAX_TRY_TIMES 200
+#define ASQ_DELAY_MS  10
+
+int
+idpf_read_one_msg(struct idpf_adapter *adapter, uint32_t ops, uint16_t

buf_len,

drivers/net/idpf/idpf_vchnl.c new file +14 -0
+		  uint8_t *buf)
+{
+	int ret, err = 0, i = 0;
+
+	do {
+		ret = idpf_read_msg_from_ipf(adapter, buf_len, buf);
+		if (ret == IDPF_MSG_CMD)
+			break;
+		rte_delay_ms(ASQ_DELAY_MS);
+	} while (i++ < MAX_TRY_TIMES);
+	if (i >= MAX_TRY_TIMES ||
+	    adapter->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {
+		err = -1;
+		PMD_DRV_LOG(ERR, "No response or return failure (%d) for

cmd %d",

drivers/net/idpf/idpf_vchnl.c new file +17 -0
+			    adapter->cmd_retval, ops);
+	}
+
+	return err;
+}
+
+static int
+idpf_execute_vc_cmd(struct idpf_adapter *adapter, struct idpf_cmd_info
+*args) {
+	int err = 0;
+	int i = 0;
+	int ret;
+
+	if (_atomic_set_cmd(adapter, args->ops))
+		return -1;
+
+	ret = idpf_send_vc_msg(adapter, args->ops, args->in_args_size, args-
Quoted 1 line

in_args);

drivers/net/idpf/idpf_vchnl.c new file +27 -0
+	if (ret) {
+		PMD_DRV_LOG(ERR, "fail to send cmd %d", args->ops);
+		_clear_cmd(adapter);
+		return ret;
+	}
+
+	switch (args->ops) {
+	case VIRTCHNL_OP_VERSION:
+	case VIRTCHNL2_OP_GET_CAPS:
+	case VIRTCHNL2_OP_CREATE_VPORT:
+	case VIRTCHNL2_OP_DESTROY_VPORT:
+	case VIRTCHNL2_OP_SET_RSS_KEY:
+	case VIRTCHNL2_OP_SET_RSS_LUT:
+	case VIRTCHNL2_OP_SET_RSS_HASH:
+	case VIRTCHNL2_OP_CONFIG_RX_QUEUES:
+	case VIRTCHNL2_OP_CONFIG_TX_QUEUES:
+	case VIRTCHNL2_OP_ENABLE_QUEUES:
+	case VIRTCHNL2_OP_DISABLE_QUEUES:
+	case VIRTCHNL2_OP_ENABLE_VPORT:
+	case VIRTCHNL2_OP_DISABLE_VPORT:
+	case VIRTCHNL2_OP_MAP_QUEUE_VECTOR:
+	case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR:
+	case VIRTCHNL2_OP_ALLOC_VECTORS:
+	case VIRTCHNL2_OP_DEALLOC_VECTORS:
+	case VIRTCHNL2_OP_GET_STATS:
+		/* for init virtchnl ops, need to poll the response */
+		err = idpf_read_one_msg(adapter, args->ops, args->out_size,

args->out_buffer);

drivers/net/idpf/idpf_vchnl.c new file +22 -0
+		_clear_cmd(adapter);
+		break;
+	case VIRTCHNL2_OP_GET_PTYPE_INFO:
+		/* for multuple response message,
+		 * do not handle the response here.
+		 */
+		break;
+	default:
+		/* For other virtchnl ops in running time,
+		 * wait for the cmd done flag.
+		 */
+		do {
+			if (adapter->pend_cmd == VIRTCHNL_OP_UNKNOWN)
+				break;
+			rte_delay_ms(ASQ_DELAY_MS);
+			/* If don't read msg or read sys event, continue */
+		} while (i++ < MAX_TRY_TIMES);
+		/* If there's no response is received, clear command */
+		if (i >= MAX_TRY_TIMES  ||
+		    adapter->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {
+			err = -1;
+			PMD_DRV_LOG(ERR, "No response or return failure

(%d) for cmd %d",

drivers/net/idpf/idpf_vchnl.c new file +29 -0
+				    adapter->cmd_retval, args->ops);
+			_clear_cmd(adapter);
+		}
+		break;
+	}
+
+	return err;
+}
+
+int
+idpf_check_api_version(struct idpf_adapter *adapter) {
+	struct virtchnl_version_info version;
+	struct idpf_cmd_info args;
+	int err;
+
+	memset(&version, 0, sizeof(struct virtchnl_version_info));
+	version.major = VIRTCHNL_VERSION_MAJOR_2;
+	version.minor = VIRTCHNL_VERSION_MINOR_0;
+
+	args.ops = VIRTCHNL_OP_VERSION;
+	args.in_args = (uint8_t *)&version;
+	args.in_args_size = sizeof(version);
+	args.out_buffer = adapter->mbx_resp;
+	args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
+
+	err = idpf_execute_vc_cmd(adapter, &args);
+	if (err) {
+		PMD_DRV_LOG(ERR,
+			    "Failed to execute command of

VIRTCHNL_OP_VERSION");

drivers/net/idpf/idpf_vchnl.c new file +90 -0
+		return err;
+	}
+
+	return err;
+}
+
+int
+idpf_get_caps(struct idpf_adapter *adapter) {
+	struct virtchnl2_get_capabilities caps_msg;
+	struct idpf_cmd_info args;
+	int err;
+
+	 memset(&caps_msg, 0, sizeof(struct virtchnl2_get_capabilities));
+	 caps_msg.csum_caps =
+		 VIRTCHNL2_CAP_TX_CSUM_L3_IPV4		|
+		 VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP	|
+		 VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP	|
+		 VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP	|
+		 VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP	|
+		 VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP	|
+		 VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP	|
+		 VIRTCHNL2_CAP_TX_CSUM_GENERIC		|
+		 VIRTCHNL2_CAP_RX_CSUM_L3_IPV4		|
+		 VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP	|
+		 VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP	|
+		 VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP	|
+		 VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP	|
+		 VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP	|
+		 VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP	|
+		 VIRTCHNL2_CAP_RX_CSUM_GENERIC;
+
+	 caps_msg.seg_caps =
+		 VIRTCHNL2_CAP_SEG_IPV4_TCP		|
+		 VIRTCHNL2_CAP_SEG_IPV4_UDP		|
+		 VIRTCHNL2_CAP_SEG_IPV4_SCTP		|
+		 VIRTCHNL2_CAP_SEG_IPV6_TCP		|
+		 VIRTCHNL2_CAP_SEG_IPV6_UDP		|
+		 VIRTCHNL2_CAP_SEG_IPV6_SCTP		|
+		 VIRTCHNL2_CAP_SEG_GENERIC;
+
+	 caps_msg.rss_caps =
+		 VIRTCHNL2_CAP_RSS_IPV4_TCP		|
+		 VIRTCHNL2_CAP_RSS_IPV4_UDP		|
+		 VIRTCHNL2_CAP_RSS_IPV4_SCTP		|
+		 VIRTCHNL2_CAP_RSS_IPV4_OTHER		|
+		 VIRTCHNL2_CAP_RSS_IPV6_TCP		|
+		 VIRTCHNL2_CAP_RSS_IPV6_UDP		|
+		 VIRTCHNL2_CAP_RSS_IPV6_SCTP		|
+		 VIRTCHNL2_CAP_RSS_IPV6_OTHER		|
+		 VIRTCHNL2_CAP_RSS_IPV4_AH		|
+		 VIRTCHNL2_CAP_RSS_IPV4_ESP		|
+		 VIRTCHNL2_CAP_RSS_IPV4_AH_ESP		|
+		 VIRTCHNL2_CAP_RSS_IPV6_AH		|
+		 VIRTCHNL2_CAP_RSS_IPV6_ESP		|
+		 VIRTCHNL2_CAP_RSS_IPV6_AH_ESP;
+
+	 caps_msg.hsplit_caps =
+		 VIRTCHNL2_CAP_RX_HSPLIT_AT_L2		|
+		 VIRTCHNL2_CAP_RX_HSPLIT_AT_L3		|
+		 VIRTCHNL2_CAP_RX_HSPLIT_AT_L4V4	|
+		 VIRTCHNL2_CAP_RX_HSPLIT_AT_L4V6;
+
+	 caps_msg.rsc_caps =
+		 VIRTCHNL2_CAP_RSC_IPV4_TCP		|
+		 VIRTCHNL2_CAP_RSC_IPV4_SCTP		|
+		 VIRTCHNL2_CAP_RSC_IPV6_TCP		|
+		 VIRTCHNL2_CAP_RSC_IPV6_SCTP;
+
+	 caps_msg.other_caps =
+		 VIRTCHNL2_CAP_RDMA			|
+		 VIRTCHNL2_CAP_SRIOV			|
+		 VIRTCHNL2_CAP_MACFILTER		|
+		 VIRTCHNL2_CAP_FLOW_DIRECTOR		|
+		 VIRTCHNL2_CAP_SPLITQ_QSCHED		|
+		 VIRTCHNL2_CAP_CRC			|
+		 VIRTCHNL2_CAP_WB_ON_ITR		|
+		 VIRTCHNL2_CAP_PROMISC			|
+		 VIRTCHNL2_CAP_LINK_SPEED		|
+		 VIRTCHNL2_CAP_VLAN;
+
+	args.ops = VIRTCHNL2_OP_GET_CAPS;
+	args.in_args = (uint8_t *)&caps_msg;
+	args.in_args_size = sizeof(caps_msg);
+	args.out_buffer = adapter->mbx_resp;
+	args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
+
+	err = idpf_execute_vc_cmd(adapter, &args);
+	if (err) {
+		PMD_DRV_LOG(ERR,
+			    "Failed to execute command of

VIRTCHNL2_OP_GET_CAPS");

drivers/net/idpf/idpf_vchnl.c new file +15 -0
+		return err;
+	}
+
+	rte_memcpy(adapter->caps, args.out_buffer, sizeof(caps_msg));
+
+	return err;
+}
+
+int
+idpf_create_vport(struct rte_eth_dev *dev) {
+	struct rte_pci_device *pci_dev = IDPF_DEV_TO_PCI(dev);
+	struct idpf_adapter *adapter = idpf_find_adapter(pci_dev);
+	uint16_t idx = adapter->next_vport_idx;
+	struct virtchnl2_create_vport *vport_req_info =
+		(struct virtchnl2_create_vport *)adapter-
Quoted 1 line

vport_req_info[idx];

drivers/net/idpf/idpf_vchnl.c new file +24 -0
+	struct virtchnl2_create_vport vport_msg;
+	struct idpf_cmd_info args;
+	int err = -1;
+
+	memset(&vport_msg, 0, sizeof(struct virtchnl2_create_vport));
+	vport_msg.vport_type = vport_req_info->vport_type;
+	vport_msg.txq_model = vport_req_info->txq_model;
+	vport_msg.rxq_model = vport_req_info->rxq_model;
+	vport_msg.num_tx_q = vport_req_info->num_tx_q;
+	vport_msg.num_tx_complq = vport_req_info->num_tx_complq;
+	vport_msg.num_rx_q = vport_req_info->num_rx_q;
+	vport_msg.num_rx_bufq = vport_req_info->num_rx_bufq;
+
+	memset(&args, 0, sizeof(args));
+	args.ops = VIRTCHNL2_OP_CREATE_VPORT;
+	args.in_args = (uint8_t *)&vport_msg;
+	args.in_args_size = sizeof(vport_msg);
+	args.out_buffer = adapter->mbx_resp;
+	args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
+
+	err = idpf_execute_vc_cmd(adapter, &args);
+	if (err) {
+		PMD_DRV_LOG(ERR,
+			    "Failed to execute command of

VIRTCHNL2_OP_CREATE_VPORT");

drivers/net/idpf/idpf_vchnl.c new file +6 -0
+		return err;
+	}
+
+	if (!adapter->vport_recv_info[idx]) {
+		adapter->vport_recv_info[idx] = rte_zmalloc(NULL,
+						    IDPF_DFLT_MBX_BUF_SIZE,

0);

drivers/net/idpf/idpf_vchnl.c new file +2 -0
+		if (!adapter->vport_recv_info[idx]) {
+			PMD_INIT_LOG(ERR, "Failed to alloc

vport_recv_info.");

drivers/net/idpf/idpf_vchnl.c new file +27 -0
+			return err;
+		}
+	}
+	rte_memcpy(adapter->vport_recv_info[idx], args.out_buffer,
+		   IDPF_DFLT_MBX_BUF_SIZE);
+	return err;
+}
+
+int
+idpf_destroy_vport(struct idpf_vport *vport) {
+	struct idpf_adapter *adapter = vport->adapter;
+	struct virtchnl2_vport vc_vport;
+	struct idpf_cmd_info args;
+	int err;
+
+	vc_vport.vport_id = vport->vport_id;
+
+	memset(&args, 0, sizeof(args));
+	args.ops = VIRTCHNL2_OP_DESTROY_VPORT;
+	args.in_args = (uint8_t *)&vc_vport;
+	args.in_args_size = sizeof(vc_vport);
+	args.out_buffer = adapter->mbx_resp;
+	args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
+
+	err = idpf_execute_vc_cmd(adapter, &args);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to execute command of

VIRTCHNL2_OP_DESTROY_VPORT");

drivers/net/idpf/idpf_vchnl.c new file +24 -0
+		return err;
+	}
+
+	return err;
+}
+
+int
+idpf_ena_dis_vport(struct idpf_vport *vport, bool enable) {
+	struct idpf_adapter *adapter = vport->adapter;
+	struct virtchnl2_vport vc_vport;
+	struct idpf_cmd_info args;
+	int err;
+
+	vc_vport.vport_id = vport->vport_id;
+	args.ops = enable ? VIRTCHNL2_OP_ENABLE_VPORT :
+			    VIRTCHNL2_OP_DISABLE_VPORT;
+	args.in_args = (u8 *)&vc_vport;
+	args.in_args_size = sizeof(vc_vport);
+	args.out_buffer = adapter->mbx_resp;
+	args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
+
+	err = idpf_execute_vc_cmd(adapter, &args);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to execute command of

VIRTCHNL2_OP_%s_VPORT",

drivers/net/idpf/idpf_vchnl.c new file +5 -0
+			    enable ? "ENABLE" : "DISABLE");
+	}
+
+	return err;
+}
drivers/net/idpf/meson.build new file +0 -0
new file mode 100644 index 0000000000..7d776d3a15

drivers/net/idpf/meson.build line 7

Quoted 7 lines
drivers/net/idpf/meson.build new file +7 -0
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2022 Intel
+Corporation
+
+if is_windows
+	build = false
+	reason = 'not supported on Windows'
+	subdir_done()

We should use 4 spaces instead of a tab in meson files.

drivers/net/idpf/meson.build line 15

Quoted 8 lines
drivers/net/idpf/meson.build new file +8 -0
+endif
+
+subdir('base')
+objs = [base_objs]
+
+sources = files(
+        'idpf_ethdev.c',
+	'idpf_vchnl.c',

Ditto.

Quoted 18 lines
drivers/net/idpf/meson.build new file +3 -0
+)
+
+includes += include_directories('base')
\ No newline at end of file
drivers/net/idpf/version.map new file +3 -0
new file mode 100644 index 0000000000..b7da224860
@@ -0,0 +1,3 @@
+DPDK_22 {
+	local: *;
+};
\ No newline at end of file
drivers/net/meson.build index renamed from drivers/net/meson.build +0 -0

e35652fe63..8faf8120c2 100644

drivers/net/meson.build drivers = [ · line 31

Quoted 4 lines
drivers/net/meson.build +1 -0
@@ -28,6 +28,7 @@ drivers = [
         'i40e',
         'iavf',
         'ice',
+	'idpf',

Ditto.

Quoted 5 lines
drivers/net/meson.build +0 -1
         'igc',
         'ionic',
         'ipn3ke',
--

2.25.1

#37 lore raw

PATCH v2 4/14 net/idpf: add support for queue operations

In reply to Junfeng Guo

Add support for queue operations:
- rx_queue_start
- rx_queue_stop
- tx_queue_start
- tx_queue_stop
- rx_queue_setup
- rx_queue_release
- tx_queue_setup
- tx_queue_release

---
 drivers/net/idpf/idpf_ethdev.c |   49 ++
 drivers/net/idpf/idpf_ethdev.h |    7 +
 drivers/net/idpf/idpf_rxtx.c   | 1270 ++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  190 +++++
 drivers/net/idpf/idpf_vchnl.c  |  509 +++++++++++++
 drivers/net/idpf/meson.build   |    1 +
 6 files changed, 2026 insertions(+)
 create mode 100644 drivers/net/idpf/idpf_rxtx.c
 create mode 100644 drivers/net/idpf/idpf_rxtx.h
drivers/net/idpf/idpf_ethdev.c +49 -0
index f0452de09e..0349ec6e9d 100644
@@ -10,6 +10,7 @@
 #include <rte_dev.h>
 
 #include "idpf_ethdev.h"
+#include "idpf_rxtx.h"
 
 #define IDPF_VPORT		"vport"
 
@@ -33,6 +34,14 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_start			= idpf_dev_start,
 	.dev_stop			= idpf_dev_stop,
 	.dev_close			= idpf_dev_close,
+	.rx_queue_start			= idpf_rx_queue_start,
+	.rx_queue_stop			= idpf_rx_queue_stop,
+	.tx_queue_start			= idpf_tx_queue_start,
+	.tx_queue_stop			= idpf_tx_queue_stop,
+	.rx_queue_setup			= idpf_rx_queue_setup,
+	.rx_queue_release		= idpf_dev_rx_queue_release,
+	.tx_queue_setup			= idpf_tx_queue_setup,
+	.tx_queue_release		= idpf_dev_tx_queue_release,
 };
 
 static int
@@ -209,6 +218,39 @@ idpf_dev_configure(__rte_unused struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+idpf_start_queues(struct rte_eth_dev *dev)
+{
+	struct idpf_rx_queue *rxq;
+	struct idpf_tx_queue *txq;
+	int err = 0;
+	int i;
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		txq = dev->data->tx_queues[i];
+		if (!txq || txq->tx_deferred_start)
+			continue;
+		err = idpf_tx_queue_start(dev, i);
+		if (err) {
+			PMD_DRV_LOG(ERR, "Fail to start Tx queue %u", i);
+			return err;
+		}
+	}
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		rxq = dev->data->rx_queues[i];
+		if (!rxq || rxq->rx_deferred_start)
+			continue;
+		err = idpf_rx_queue_start(dev, i);
+		if (err) {
+			PMD_DRV_LOG(ERR, "Fail to start Rx queue %u", i);
+			return err;
+		}
+	}
+
+	return err;
+}
+
 static int
 idpf_dev_start(struct rte_eth_dev *dev)
 {
@@ -218,6 +260,11 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	vport->stopped = 0;
 
+	if (idpf_start_queues(dev)) {
+		PMD_DRV_LOG(ERR, "Failed to start queues");
+		goto err_mtu;
+	}
+
 	if (idpf_ena_dis_vport(vport, true)) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
 		goto err_vport;
@@ -226,6 +273,8 @@ idpf_dev_start(struct rte_eth_dev *dev)
 	return 0;
 
 err_vport:
+	idpf_stop_queues(dev);
+err_mtu:
 	return -1;
 }
 
drivers/net/idpf/idpf_ethdev.h +7 -0
index e60ba73ec1..4a98e7739b 100644
@@ -222,6 +222,13 @@ int idpf_check_api_version(struct idpf_adapter *adapter);
 int idpf_get_caps(struct idpf_adapter *adapter);
 int idpf_create_vport(struct rte_eth_dev *dev);
 int idpf_destroy_vport(struct idpf_vport *vport);
+int idpf_config_rxqs(struct idpf_vport *vport);
+int idpf_config_rxq(struct idpf_vport *vport, uint16_t rxq_id);
+int idpf_config_txqs(struct idpf_vport *vport);
+int idpf_config_txq(struct idpf_vport *vport, uint16_t txq_id);
+int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,
+		      bool rx, bool on);
+int idpf_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_ena_dis_vport(struct idpf_vport *vport, bool enable);
 int idpf_read_one_msg(struct idpf_adapter *adapter, uint32_t ops,
 		      uint16_t buf_len, uint8_t *buf);
drivers/net/idpf/idpf_rxtx.c new file +1270 -0

1,270 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h new file +190 -0

190 lines not on this page · raw message

drivers/net/idpf/idpf_vchnl.c +509 -0

521 lines not on this page · raw message

drivers/net/idpf/meson.build +1 -0
index 7d776d3a15..338a39e391 100644
@@ -12,6 +12,7 @@ objs = [base_objs]
 
 sources = files(
         'idpf_ethdev.c',
+	'idpf_rxtx.c',
 	'idpf_vchnl.c',
 )
 
Signature · 1 line
2.25.1
#38 lore raw

Re: [PATCH v2 04/14] net/idpf: add support for queue operations

Quoted 9 lines · Junfeng Guo

Add support for queue operations:
- rx_queue_start
- rx_queue_stop
- tx_queue_start
- tx_queue_stop
- rx_queue_setup
- rx_queue_release
- tx_queue_setup
- tx_queue_release

The patch is huge. Please, factor out deferred queues start/stop (may be even separate for Rx and Tx) into separate patch.

#39 lore raw

RE: [PATCH v2 04/14] net/idpf: add support for queue operations

Quoted 23 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 3, 2022 21:48
To: Guo, Junfeng <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>; Li, Xiaoyun <[email protected]>
Subject: Re: [PATCH v2 04/14] net/idpf: add support for queue operations

Quoted 9 lines · Junfeng Guo

Add support for queue operations:
- rx_queue_start
- rx_queue_stop
- tx_queue_start
- tx_queue_stop
- rx_queue_setup
- rx_queue_release
- tx_queue_setup
- tx_queue_release

Quoted 3 lines

The patch is huge. Please, factor out deferred queues start/stop (may be even separate for Rx and Tx) into separate patch.

Okay... Will try to do this. Thanks!

#40 lore raw

PATCH v2 5/14 net/idpf: add support for device information get

In reply to Junfeng Guo

Add dev ops dev_infos_get.

---
 drivers/net/idpf/idpf_ethdev.c | 80 ++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)
drivers/net/idpf/idpf_ethdev.c +80 -0
index 0349ec6e9d..8852b7ce22 100644
@@ -28,6 +28,8 @@ static int idpf_dev_configure(struct rte_eth_dev *dev);
 static int idpf_dev_start(struct rte_eth_dev *dev);
 static int idpf_dev_stop(struct rte_eth_dev *dev);
 static int idpf_dev_close(struct rte_eth_dev *dev);
+static int idpf_dev_info_get(struct rte_eth_dev *dev,
+			     struct rte_eth_dev_info *dev_info);
 
 static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_configure			= idpf_dev_configure,
@@ -42,8 +44,86 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.rx_queue_release		= idpf_dev_rx_queue_release,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.tx_queue_release		= idpf_dev_tx_queue_release,
+	.dev_infos_get			= idpf_dev_info_get,
 };
 
+static int
+idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+
+	dev_info->max_rx_queues = adapter->caps->max_rx_q;
+	dev_info->max_tx_queues = adapter->caps->max_tx_q;
+	dev_info->min_rx_bufsize = IDPF_MIN_BUF_SIZE;
+	dev_info->max_rx_pktlen = IDPF_MAX_FRAME_SIZE;
+
+	dev_info->max_mtu = dev_info->max_rx_pktlen - IDPF_ETH_OVERHEAD;
+	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
+
+	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
+	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
+		RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
+	dev_info->rx_offload_capa =
+		RTE_ETH_RX_OFFLOAD_VLAN_STRIP		|
+		RTE_ETH_RX_OFFLOAD_QINQ_STRIP		|
+		RTE_ETH_RX_OFFLOAD_IPV4_CKSUM		|
+		RTE_ETH_RX_OFFLOAD_UDP_CKSUM		|
+		RTE_ETH_RX_OFFLOAD_TCP_CKSUM		|
+		RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM	|
+		RTE_ETH_RX_OFFLOAD_SCATTER		|
+		RTE_ETH_RX_OFFLOAD_VLAN_FILTER		|
+		RTE_ETH_RX_OFFLOAD_RSS_HASH		|
+		RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+
+	dev_info->tx_offload_capa =
+		RTE_ETH_TX_OFFLOAD_VLAN_INSERT		|
+		RTE_ETH_TX_OFFLOAD_QINQ_INSERT		|
+		RTE_ETH_TX_OFFLOAD_IPV4_CKSUM		|
+		RTE_ETH_TX_OFFLOAD_UDP_CKSUM		|
+		RTE_ETH_TX_OFFLOAD_TCP_CKSUM		|
+		RTE_ETH_TX_OFFLOAD_SCTP_CKSUM		|
+		RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM	|
+		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
+		RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO	|
+		RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO		|
+		RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO		|
+		RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO	|
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS		|
+		RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	dev_info->default_rxconf = (struct rte_eth_rxconf) {
+		.rx_free_thresh = IDPF_DEFAULT_RX_FREE_THRESH,
+		.rx_drop_en = 0,
+		.offloads = 0,
+	};
+
+	dev_info->default_txconf = (struct rte_eth_txconf) {
+		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
+		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
+		.offloads = 0,
+	};
+
+	dev_info->rx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = IDPF_MAX_RING_DESC,
+		.nb_min = IDPF_MIN_RING_DESC,
+		.nb_align = IDPF_ALIGN_RING_DESC,
+	};
+
+	dev_info->tx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = IDPF_MAX_RING_DESC,
+		.nb_min = IDPF_MIN_RING_DESC,
+		.nb_align = IDPF_ALIGN_RING_DESC,
+	};
+
+	dev_info->default_rxportconf.burst_size = IDPF_RX_MAX_BURST;
+	dev_info->default_txportconf.burst_size = IDPF_TX_MAX_BURST;
+	dev_info->default_rxportconf.nb_queues = 1;
+	dev_info->default_txportconf.nb_queues = 1;
+
+	return 0;
+}
+
 static int
 idpf_init_vport_req_info(struct rte_eth_dev *dev)
 {
Signature · 1 line
2.25.1
#41 lore raw

Re: [PATCH v2 05/14] net/idpf: add support for device information get

Quoted 1 line · Junfeng Guo

Add dev ops dev_infos_get.

The hook may be called on very earlier stages of the driver life. So, I'd recommend to move the patch even before configure/clsoe. User may request the dev_info in just probed state.

Quoted 34 lines
---
  drivers/net/idpf/idpf_ethdev.c | 80 ++++++++++++++++++++++++++++++++++
  1 file changed, 80 insertions(+)
drivers/net/idpf/idpf_ethdev.c +10 -0
index 0349ec6e9d..8852b7ce22 100644
@@ -28,6 +28,8 @@ static int idpf_dev_configure(struct rte_eth_dev *dev);
  static int idpf_dev_start(struct rte_eth_dev *dev);
  static int idpf_dev_stop(struct rte_eth_dev *dev);
  static int idpf_dev_close(struct rte_eth_dev *dev);
+static int idpf_dev_info_get(struct rte_eth_dev *dev,
+			     struct rte_eth_dev_info *dev_info);
 
  static const struct eth_dev_ops idpf_eth_dev_ops = {
  	.dev_configure			= idpf_dev_configure,
@@ -42,8 +44,86 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
  	.rx_queue_release		= idpf_dev_rx_queue_release,
  	.tx_queue_setup			= idpf_tx_queue_setup,
  	.tx_queue_release		= idpf_dev_tx_queue_release,
+	.dev_infos_get			= idpf_dev_info_get,
  };
 
+static int
+idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+
+	dev_info->max_rx_queues = adapter->caps->max_rx_q;

drivers/net/idpf/idpf_ethdev.c static const struct eth_dev_ops idpf_eth_dev_ops = { · line 66

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +10 -0
+	dev_info->max_tx_queues = adapter->caps->max_tx_q;
+	dev_info->min_rx_bufsize = IDPF_MIN_BUF_SIZE;
+	dev_info->max_rx_pktlen = IDPF_MAX_FRAME_SIZE;
+
+	dev_info->max_mtu = dev_info->max_rx_pktlen - IDPF_ETH_OVERHEAD;
+	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
+
+	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
+	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
+		RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;

All above feature must be advertised as soon as it is really supported by the driver. Do you really support runtime queues setup at this point? In fact it is a separate feature and its better to have dedicated patch to support it which updates reported device capabilties.

drivers/net/idpf/idpf_ethdev.c static const struct eth_dev_ops idpf_eth_dev_ops = { · line 68

Quoted 2 lines
drivers/net/idpf/idpf_ethdev.c +2 -0
+	dev_info->rx_offload_capa =
+		RTE_ETH_RX_OFFLOAD_VLAN_STRIP		|

All offloads must be reported as soon at it is actually supported. So, the patch which adds support for an offload must update the device info callback to advirtise it.

Quoted 42 lines
drivers/net/idpf/idpf_ethdev.c +42 -0
+		RTE_ETH_RX_OFFLOAD_QINQ_STRIP		|
+		RTE_ETH_RX_OFFLOAD_IPV4_CKSUM		|
+		RTE_ETH_RX_OFFLOAD_UDP_CKSUM		|
+		RTE_ETH_RX_OFFLOAD_TCP_CKSUM		|
+		RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM	|
+		RTE_ETH_RX_OFFLOAD_SCATTER		|
+		RTE_ETH_RX_OFFLOAD_VLAN_FILTER		|
+		RTE_ETH_RX_OFFLOAD_RSS_HASH		|
+		RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+
+	dev_info->tx_offload_capa =
+		RTE_ETH_TX_OFFLOAD_VLAN_INSERT		|
+		RTE_ETH_TX_OFFLOAD_QINQ_INSERT		|
+		RTE_ETH_TX_OFFLOAD_IPV4_CKSUM		|
+		RTE_ETH_TX_OFFLOAD_UDP_CKSUM		|
+		RTE_ETH_TX_OFFLOAD_TCP_CKSUM		|
+		RTE_ETH_TX_OFFLOAD_SCTP_CKSUM		|
+		RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM	|
+		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
+		RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO	|
+		RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO		|
+		RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO		|
+		RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO	|
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS		|
+		RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	dev_info->default_rxconf = (struct rte_eth_rxconf) {
+		.rx_free_thresh = IDPF_DEFAULT_RX_FREE_THRESH,
+		.rx_drop_en = 0,
+		.offloads = 0,
+	};
+
+	dev_info->default_txconf = (struct rte_eth_txconf) {
+		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
+		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
+		.offloads = 0,
+	};
+
+	dev_info->rx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = IDPF_MAX_RING_DESC,
+		.nb_min = IDPF_MIN_RING_DESC,
+		.nb_align = IDPF_ALIGN_RING_DESC,

drivers/net/idpf/idpf_ethdev.c static const struct eth_dev_ops idpf_eth_dev_ops = { · line 120

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +10 -0
+	};
+
+	dev_info->tx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = IDPF_MAX_RING_DESC,
+		.nb_min = IDPF_MIN_RING_DESC,
+		.nb_align = IDPF_ALIGN_RING_DESC,
+	};
+
+	dev_info->default_rxportconf.burst_size = IDPF_RX_MAX_BURST;
+	dev_info->default_txportconf.burst_size = IDPF_TX_MAX_BURST;

Is it really an intent to recommend maximum burst side by default?

Quoted 9 lines
drivers/net/idpf/idpf_ethdev.c +6 -0
+	dev_info->default_rxportconf.nb_queues = 1;
+	dev_info->default_txportconf.nb_queues = 1;
+
+	return 0;
+}
+
  static int
  idpf_init_vport_req_info(struct rte_eth_dev *dev)
  {
#42 lore raw

PATCH v2 6/14 net/idpf: add support for packet type get

In reply to Junfeng Guo

Add dev ops dev_supported_ptypes_get.

---
 drivers/net/idpf/idpf_ethdev.c |   7 +
 drivers/net/idpf/idpf_ethdev.h |   2 +
 drivers/net/idpf/idpf_rxtx.c   |  19 +++
 drivers/net/idpf/idpf_rxtx.h   |   6 +
 drivers/net/idpf/idpf_vchnl.c  | 235 +++++++++++++++++++++++++++++++++
 5 files changed, 269 insertions(+)
drivers/net/idpf/idpf_ethdev.c +7 -0
index 8852b7ce22..0ed2c99dd2 100644
@@ -32,6 +32,7 @@ static int idpf_dev_info_get(struct rte_eth_dev *dev,
 			     struct rte_eth_dev_info *dev_info);
 
 static const struct eth_dev_ops idpf_eth_dev_ops = {
+	.dev_supported_ptypes_get	= idpf_dev_supported_ptypes_get,
 	.dev_configure			= idpf_dev_configure,
 	.dev_start			= idpf_dev_start,
 	.dev_stop			= idpf_dev_stop,
@@ -647,6 +648,12 @@ idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
 		goto err_api;
 	}
 
+	ret = idpf_get_pkt_type(adapter);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to set ptype table");
+		goto err_api;
+	}
+
 	adapter->caps = rte_zmalloc("idpf_caps",
 			       sizeof(struct virtchnl2_get_capabilities), 0);
 	if (!adapter->caps) {
drivers/net/idpf/idpf_ethdev.h +2 -0
index 4a98e7739b..1833c6e57d 100644
@@ -219,6 +219,7 @@ _atomic_set_cmd(struct idpf_adapter *adapter, enum virtchnl_ops ops)
 struct idpf_adapter *idpf_find_adapter(struct rte_pci_device *pci_dev);
 void idpf_handle_virtchnl_msg(struct rte_eth_dev *dev);
 int idpf_check_api_version(struct idpf_adapter *adapter);
+int idpf_get_pkt_type(struct idpf_adapter *adapter);
 int idpf_get_caps(struct idpf_adapter *adapter);
 int idpf_create_vport(struct rte_eth_dev *dev);
 int idpf_destroy_vport(struct idpf_vport *vport);
@@ -230,6 +231,7 @@ int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,
 		      bool rx, bool on);
 int idpf_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_ena_dis_vport(struct idpf_vport *vport, bool enable);
+int idpf_query_ptype_info(struct idpf_adapter *adapter);
 int idpf_read_one_msg(struct idpf_adapter *adapter, uint32_t ops,
 		      uint16_t buf_len, uint8_t *buf);
 
drivers/net/idpf/idpf_rxtx.c +19 -0
index fe044a80c9..1c5c4688cc 100644
@@ -8,6 +8,25 @@
 #include "idpf_ethdev.h"
 #include "idpf_rxtx.h"
 
+const uint32_t *
+idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)
+{
+	static const uint32_t ptypes[] = {
+		RTE_PTYPE_L2_ETHER,
+		RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
+		RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
+		RTE_PTYPE_L4_FRAG,
+		RTE_PTYPE_L4_NONFRAG,
+		RTE_PTYPE_L4_UDP,
+		RTE_PTYPE_L4_TCP,
+		RTE_PTYPE_L4_SCTP,
+		RTE_PTYPE_L4_ICMP,
+		RTE_PTYPE_UNKNOWN
+	};
+
+	return ptypes;
+}
+
 static inline int
 check_rx_thresh(uint16_t nb_desc, uint16_t thresh)
 {
drivers/net/idpf/idpf_rxtx.h +6 -0
index d930bb75ff..f2947a8492 100644
@@ -46,6 +46,10 @@
 #define IDPF_TX_OFFLOAD_NOTSUP_MASK \
 		(RTE_MBUF_F_TX_OFFLOAD_MASK ^ IDPF_TX_OFFLOAD_MASK)
 
+#define IDPF_GET_PTYPE_SIZE(p) \
+	(sizeof(struct virtchnl2_ptype) + \
+	(((p)->proto_id_count ? ((p)->proto_id_count - 1) : 0) * sizeof((p)->proto_id[0])))
+
 struct idpf_rx_queue {
 	struct idpf_adapter *adapter;	/* the adapter this queue belongs to */
 	struct rte_mempool *mp;		/* mbuf pool to populate Rx ring */
@@ -186,5 +190,7 @@ void idpf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 void idpf_stop_queues(struct rte_eth_dev *dev);
 
 
+const uint32_t *idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev);
+
 #endif /* _IDPF_RXTX_H_ */
 
drivers/net/idpf/idpf_vchnl.c +235 -0

244 lines not on this page · raw message

Signature · 1 line
2.25.1
#43 lore raw

Re: [PATCH v2 06/14] net/idpf: add support for packet type get

Quoted 5 lines · Junfeng Guo

Add dev ops dev_supported_ptypes_get.

[snip]

Quoted 13 lines
drivers/net/idpf/idpf_rxtx.c +5 -0
index fe044a80c9..1c5c4688cc 100644
@@ -8,6 +8,25 @@
  #include "idpf_ethdev.h"
  #include "idpf_rxtx.h"
 
+const uint32_t *
+idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)
+{
+	static const uint32_t ptypes[] = {
+		RTE_PTYPE_L2_ETHER,

drivers/net/idpf/idpf_rxtx.c line 25

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c +10 -0
+		RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
+		RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
+		RTE_PTYPE_L4_FRAG,
+		RTE_PTYPE_L4_NONFRAG,
+		RTE_PTYPE_L4_UDP,
+		RTE_PTYPE_L4_TCP,
+		RTE_PTYPE_L4_SCTP,
+		RTE_PTYPE_L4_ICMP,
+		RTE_PTYPE_UNKNOWN
+	};

How am I supported to verify that these packet types are really recognized by the driver? The patch should include the part of Rx burst callback which does recognition and fill in corresponding data in mbuf.

Quoted 7 lines
drivers/net/idpf/idpf_rxtx.c +4 -0
+
+	return ptypes;
+}
+
  static inline int
  check_rx_thresh(uint16_t nb_desc, uint16_t thresh)
  {
#44 lore raw

RE: [PATCH v2 06/14] net/idpf: add support for packet type get

Quoted 42 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 3, 2022 21:59
To: Guo, Junfeng <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>; Wu, Wenjun1 <[email protected]>
Subject: Re: [PATCH v2 06/14] net/idpf: add support for packet type get

Quoted 5 lines · Junfeng Guo

Add dev ops dev_supported_ptypes_get.

[snip]

drivers/net/idpf/idpf_rxtx.c line 12

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c +2 -0
index fe044a80c9..1c5c4688cc 100644
@@ -8,6 +8,25 @@
  #include "idpf_ethdev.h"
  #include "idpf_rxtx.h"
 
+const uint32_t *
+idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev

__rte_unused)

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c +10 -0
+{
+	static const uint32_t ptypes[] = {
+		RTE_PTYPE_L2_ETHER,
+		RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
+		RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
+		RTE_PTYPE_L4_FRAG,
+		RTE_PTYPE_L4_NONFRAG,
+		RTE_PTYPE_L4_UDP,
+		RTE_PTYPE_L4_TCP,
+		RTE_PTYPE_L4_SCTP,
Quoted 8 lines

drivers/net/idpf/idpf_rxtx.c line 25

Quoted 3 lines
drivers/net/idpf/idpf_rxtx.c +3 -0
+		RTE_PTYPE_L4_ICMP,
+		RTE_PTYPE_UNKNOWN
+	};

How am I supported to verify that these packet types are really recognized by the driver? The patch should include the part of Rx burst callback which does recognition and fill in corresponding data in mbuf.

You can verify the PTYPE via sending & receiving certain packets. After setting the cmd verbose, the corresponding PTYPE may show up in the testpmd. You can then check if the PTYPE is exactly what you just sent.

The ptype_tbl will be filled when func idpf_get_pkt_type is called. And then the corresponding part will be filled in Rx burst phase. This part patch will also be improved to make it more clear. Thanks!

Quoted 8 lines
Quoted 8 lines
drivers/net/idpf/idpf_rxtx.c +4 -0
+
+	return ptypes;
+}
+
  static inline int
  check_rx_thresh(uint16_t nb_desc, uint16_t thresh)
  {
#45 lore raw

PATCH v2 7/14 net/idpf: add support for link status update

In reply to Junfeng Guo

Add dev ops link_update.

---
 drivers/net/idpf/idpf_ethdev.c | 21 +++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h |  2 ++
 2 files changed, 23 insertions(+)
drivers/net/idpf/idpf_ethdev.c +21 -0
index 0ed2c99dd2..2cbf2f0e19 100644
@@ -31,6 +31,26 @@ static int idpf_dev_close(struct rte_eth_dev *dev);
 static int idpf_dev_info_get(struct rte_eth_dev *dev,
 			     struct rte_eth_dev_info *dev_info);
 
+int
+idpf_dev_link_update(struct rte_eth_dev *dev,
+		     __rte_unused int wait_to_complete)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct rte_eth_link new_link;
+
+	memset(&new_link, 0, sizeof(new_link));
+
+	new_link.link_speed = RTE_ETH_SPEED_NUM_NONE;
+
+	new_link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
+	new_link.link_status = vport->link_up ? RTE_ETH_LINK_UP :
+		RTE_ETH_LINK_DOWN;
+	new_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
+				  RTE_ETH_LINK_SPEED_FIXED);
+
+	return rte_eth_linkstatus_set(dev, &new_link);
+}
+
 static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_supported_ptypes_get	= idpf_dev_supported_ptypes_get,
 	.dev_configure			= idpf_dev_configure,
@@ -46,6 +66,7 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.tx_queue_release		= idpf_dev_tx_queue_release,
 	.dev_infos_get			= idpf_dev_info_get,
+	.link_update			= idpf_dev_link_update,
 };
 
 static int
drivers/net/idpf/idpf_ethdev.h +2 -0
index 1833c6e57d..e3a2a98c5b 100644
@@ -217,6 +217,8 @@ _atomic_set_cmd(struct idpf_adapter *adapter, enum virtchnl_ops ops)
 }
 
 struct idpf_adapter *idpf_find_adapter(struct rte_pci_device *pci_dev);
+int idpf_dev_link_update(struct rte_eth_dev *dev,
+			 __rte_unused int wait_to_complete);
 void idpf_handle_virtchnl_msg(struct rte_eth_dev *dev);
 int idpf_check_api_version(struct idpf_adapter *adapter);
 int idpf_get_pkt_type(struct idpf_adapter *adapter);
Signature · 1 line
2.25.1
#46 lore raw

PATCH v2 8/14 net/idpf: add support for basic Rx/Tx datapath

In reply to Junfeng Guo

Add basic RX & TX support in split queue mode and single queue mode. Split queue mode is selected by default.

---
 drivers/net/idpf/idpf_ethdev.c |  47 +-
 drivers/net/idpf/idpf_rxtx.c   | 896 ++++++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_rxtx.h   |  28 ++
 3 files changed, 966 insertions(+), 5 deletions(-)
drivers/net/idpf/idpf_ethdev.c +46 -1
index 2cbf2f0e19..6310745684 100644
@@ -12,6 +12,8 @@
 #include "idpf_ethdev.h"
 #include "idpf_rxtx.h"
 
+#define IDPF_TX_SINGLE_Q	"tx_single"
+#define IDPF_RX_SINGLE_Q	"rx_single"
 #define IDPF_VPORT		"vport"
 
 struct idpf_adapter_list adapter_list;
@@ -20,6 +22,8 @@ bool adapter_list_init;
 uint64_t idpf_timestamp_dynflag;
 
 static const char * const idpf_valid_args[] = {
+	IDPF_TX_SINGLE_Q,
+	IDPF_RX_SINGLE_Q,
 	IDPF_VPORT,
 	NULL
 };
@@ -367,6 +371,9 @@ idpf_dev_start(struct rte_eth_dev *dev)
 		goto err_mtu;
 	}
 
+	idpf_set_rx_function(dev);
+	idpf_set_tx_function(dev);
+
 	if (idpf_ena_dis_vport(vport, true)) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
 		goto err_vport;
@@ -393,6 +400,8 @@ idpf_dev_stop(struct rte_eth_dev *dev)
 	if (idpf_ena_dis_vport(vport, false))
 		PMD_DRV_LOG(ERR, "disable vport failed");
 
+	idpf_stop_queues(dev);
+
 	vport->stopped = 1;
 	dev->data->dev_started = 0;
 
@@ -519,6 +528,26 @@ parse_vport(const char *key, const char *value, void *args)
 	return 0;
 }
 
+static int
+parse_bool(const char *key, const char *value, void *args)
+{
+	int *i = (int *)args;
+	char *end;
+	int num;
+
+	num = strtoul(value, &end, 10);
+
+	if (num != 0 && num != 1) {
+		PMD_INIT_LOG(ERR, "invalid value:\"%s\" for key:\"%s\", "
+			"value must be 0 or 1",
+			value, key);
+		return -1;
+	}
+
+	*i = num;
+	return 0;
+}
+
 static int
 idpf_parse_devargs(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
 {
@@ -537,7 +566,20 @@ idpf_parse_devargs(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
 
 	ret = rte_kvargs_process(kvlist, IDPF_VPORT, &parse_vport,
 		adapter);
+	if (ret)
+		goto bail;
+
+	ret = rte_kvargs_process(kvlist, IDPF_TX_SINGLE_Q, &parse_bool,
+				 &adapter->txq_model);
+	if (ret)
+		goto bail;
+
+	ret = rte_kvargs_process(kvlist, IDPF_RX_SINGLE_Q, &parse_bool,
+				 &adapter->rxq_model);
+	if (ret)
+		goto bail;
 
+bail:
 	rte_kvargs_free(kvlist);
 	return ret;
 }
@@ -763,8 +805,11 @@ idpf_dev_init(struct rte_eth_dev *dev, void *init_params)
 	/* for secondary processes, we don't initialise any further as primary
 	 * has already done this work.
 	 */
-	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		idpf_set_rx_function(dev);
+		idpf_set_tx_function(dev);
 		return ret;
+	}
 
 	dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
 
drivers/net/idpf/idpf_rxtx.c +892 -4

905 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +28 -0
index f2947a8492..3ccf9efe50 100644
@@ -43,6 +43,22 @@
 #define IDPF_TSO_MAX_SEG	UINT8_MAX
 #define IDPF_TX_MAX_MTU_SEG     8
 
+#define IDPF_TX_CKSUM_OFFLOAD_MASK (		\
+		RTE_MBUF_F_TX_IP_CKSUM |	\
+		RTE_MBUF_F_TX_L4_MASK |		\
+		RTE_MBUF_F_TX_TCP_SEG)
+
+#define IDPF_TX_OFFLOAD_MASK (			\
+		RTE_MBUF_F_TX_OUTER_IPV6 |	\
+		RTE_MBUF_F_TX_OUTER_IPV4 |	\
+		RTE_MBUF_F_TX_IPV6 |		\
+		RTE_MBUF_F_TX_IPV4 |		\
+		RTE_MBUF_F_TX_VLAN |		\
+		RTE_MBUF_F_TX_IP_CKSUM |	\
+		RTE_MBUF_F_TX_L4_MASK |		\
+		RTE_MBUF_F_TX_TCP_SEG |		\
+		RTE_ETH_TX_OFFLOAD_SECURITY)
+
 #define IDPF_TX_OFFLOAD_NOTSUP_MASK \
 		(RTE_MBUF_F_TX_OFFLOAD_MASK ^ IDPF_TX_OFFLOAD_MASK)
 
@@ -187,8 +203,20 @@ int idpf_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 int idpf_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 void idpf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 
+uint16_t idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+				uint16_t nb_pkts);
+uint16_t idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+			       uint16_t nb_pkts);
+uint16_t idpf_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+				uint16_t nb_pkts);
+uint16_t idpf_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+			       uint16_t nb_pkts);
+uint16_t idpf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+			uint16_t nb_pkts);
 void idpf_stop_queues(struct rte_eth_dev *dev);
 
+void idpf_set_rx_function(struct rte_eth_dev *dev);
+void idpf_set_tx_function(struct rte_eth_dev *dev);
 
 const uint32_t *idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
Signature · 1 line
2.25.1
#47 lore raw

Re: [PATCH v2 08/14] net/idpf: add support for basic Rx/Tx datapath

Quoted 1 line · Junfeng Guo

Add basic RX & TX support in split queue mode and single queue mode.

RX -> Rx, TX -> Tx

Quoted 1 line

Split queue mode is selected by default.

What is split queue mode? Where is it defined/described?

The patch is very big again. Please, start from really basic Rx and Tx functionality and then add offloads one by one. Otherwise it is really hard to review everything at once.

#48 lore raw

RE: [PATCH v2 08/14] net/idpf: add support for basic Rx/Tx datapath

Quoted 18 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 3, 2022 22:03
To: Guo, Junfeng <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>; Li, Xiaoyun <[email protected]>
Subject: Re: [PATCH v2 08/14] net/idpf: add support for basic Rx/Tx datapath

Quoted 1 line · Junfeng Guo

Add basic RX & TX support in split queue mode and single queue mode.

RX -> Rx, TX -> Tx

Quoted 7 lines
Quoted 1 line

Split queue mode is selected by default.

What is split queue mode? Where is it defined/described?

The patch is very big again. Please, start from really basic Rx and Tx functionality and then add offloads one by one. Otherwise it is really hard to review everything at once.

Sure, will split the basic Rx/Tx and the offloads, and also add doc to describe the queue modes. Thanks!

#49 lore raw

PATCH v2 9/14 net/idpf: add support for RSS

In reply to Junfeng Guo

Add RSS support.

---
 drivers/net/idpf/idpf_ethdev.c | 118 ++++++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_ethdev.h |  17 +++++
 drivers/net/idpf/idpf_vchnl.c  |  96 +++++++++++++++++++++++++++
 3 files changed, 229 insertions(+), 2 deletions(-)
drivers/net/idpf/idpf_ethdev.c +116 -2
index 6310745684..b1e2ca21ca 100644
@@ -87,6 +87,7 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->max_mtu = dev_info->max_rx_pktlen - IDPF_ETH_OVERHEAD;
 	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
 
+	dev_info->flow_type_rss_offloads = IDPF_RSS_OFFLOAD_ALL;
 	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
 	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
 		RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
@@ -319,9 +320,116 @@ idpf_init_vport(struct rte_eth_dev *dev)
 }
 
 static int
-idpf_dev_configure(__rte_unused struct rte_eth_dev *dev)
+idpf_config_rss(struct idpf_vport *vport)
 {
-	return 0;
+	int ret;
+
+	ret = idpf_set_rss_key(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS key");
+		return ret;
+	}
+
+	ret = idpf_set_rss_lut(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS lut");
+		return ret;
+	}
+
+	ret = idpf_set_rss_hash(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS hash");
+		return ret;
+	}
+
+	return ret;
+}
+
+static int
+idpf_init_rss(struct idpf_vport *vport)
+{
+	struct rte_eth_rss_conf *rss_conf;
+	uint16_t i, nb_q, lut_size;
+	int ret = 0;
+
+	rss_conf = &vport->dev_data->dev_conf.rx_adv_conf.rss_conf;
+	nb_q = vport->dev_data->nb_rx_queues;
+
+	vport->rss_key = (uint8_t *)rte_zmalloc("rss_key",
+					     vport->rss_key_size, 0);
+	if (!vport->rss_key) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS key");
+		ret = -ENOMEM;
+		goto err_key;
+	}
+
+	lut_size = vport->rss_lut_size;
+	vport->rss_lut = (uint32_t *)rte_zmalloc("rss_lut",
+					      sizeof(uint32_t) * lut_size, 0);
+	if (!vport->rss_lut) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS lut");
+		ret = -ENOMEM;
+		goto err_lut;
+	}
+
+	if (!rss_conf->rss_key) {
+		for (i = 0; i < vport->rss_key_size; i++)
+			vport->rss_key[i] = (uint8_t)rte_rand();
+	} else {
+		rte_memcpy(vport->rss_key, rss_conf->rss_key,
+			   RTE_MIN(rss_conf->rss_key_len,
+				   vport->rss_key_size));
+	}
+
+	for (i = 0; i < lut_size; i++)
+		vport->rss_lut[i] = i % nb_q;
+
+	vport->rss_hf = IECM_DEFAULT_RSS_HASH_EXPANDED;
+
+	ret = idpf_config_rss(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS");
+		goto err_cfg;
+	}
+
+	return ret;
+
+err_cfg:
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+err_lut:
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+err_key:
+	return ret;
+}
+
+static int
+idpf_dev_configure(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	int ret = 0;
+
+	if (dev->data->nb_tx_queues > IDPF_DEFAULT_TXQ_NUM ||
+	    dev->data->nb_rx_queues > IDPF_DEFAULT_RXQ_NUM) {
+		PMD_INIT_LOG(ERR, "Invalid queue number.");
+		return -EINVAL;
+	}
+
+	if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+		dev->data->dev_conf.rxmode.offloads |=
+			RTE_ETH_RX_OFFLOAD_RSS_HASH;
+
+	if (adapter->caps->rss_caps) {
+		ret = idpf_init_rss(vport);
+		if (ret) {
+			PMD_INIT_LOG(ERR, "Failed to init rss");
+			return ret;
+		}
+	}
+
+	return ret;
 }
 
 static int
@@ -420,6 +528,12 @@ idpf_dev_close(struct rte_eth_dev *dev)
 	idpf_dev_stop(dev);
 	idpf_destroy_vport(vport);
 
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+
 	adapter->cur_vports &= ~BIT(vport->devarg_id);
 
 	rte_free(vport);
drivers/net/idpf/idpf_ethdev.h +17 -0
index e3a2a98c5b..a37582d7b9 100644
@@ -53,6 +53,20 @@
 #define IDPF_ETH_OVERHEAD \
 	(RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + IDPF_VLAN_TAG_SIZE * 2)
 
+#define IDPF_RSS_OFFLOAD_ALL ( \
+	RTE_ETH_RSS_IPV4		| \
+	RTE_ETH_RSS_FRAG_IPV4		| \
+	RTE_ETH_RSS_NONFRAG_IPV4_TCP	| \
+	RTE_ETH_RSS_NONFRAG_IPV4_UDP	| \
+	RTE_ETH_RSS_NONFRAG_IPV4_SCTP	| \
+	RTE_ETH_RSS_NONFRAG_IPV4_OTHER	| \
+	RTE_ETH_RSS_IPV6		| \
+	RTE_ETH_RSS_FRAG_IPV6		| \
+	RTE_ETH_RSS_NONFRAG_IPV6_TCP	| \
+	RTE_ETH_RSS_NONFRAG_IPV6_UDP	| \
+	RTE_ETH_RSS_NONFRAG_IPV6_SCTP	| \
+	RTE_ETH_RSS_NONFRAG_IPV6_OTHER)
+
 #ifndef ETH_ADDR_LEN
 #define ETH_ADDR_LEN		6
 #endif
@@ -225,6 +239,9 @@ int idpf_get_pkt_type(struct idpf_adapter *adapter);
 int idpf_get_caps(struct idpf_adapter *adapter);
 int idpf_create_vport(struct rte_eth_dev *dev);
 int idpf_destroy_vport(struct idpf_vport *vport);
+int idpf_set_rss_key(struct idpf_vport *vport);
+int idpf_set_rss_lut(struct idpf_vport *vport);
+int idpf_set_rss_hash(struct idpf_vport *vport);
 int idpf_config_rxqs(struct idpf_vport *vport);
 int idpf_config_rxq(struct idpf_vport *vport, uint16_t rxq_id);
 int idpf_config_txqs(struct idpf_vport *vport);
drivers/net/idpf/idpf_vchnl.c +96 -0

102 lines not on this page · raw message

Signature · 1 line
2.25.1
#50 lore raw

Re: [PATCH v2 09/14] net/idpf: add support for RSS

Quoted 73 lines · Junfeng Guo

Add RSS support.

---
  drivers/net/idpf/idpf_ethdev.c | 118 ++++++++++++++++++++++++++++++++-
  drivers/net/idpf/idpf_ethdev.h |  17 +++++
  drivers/net/idpf/idpf_vchnl.c  |  96 +++++++++++++++++++++++++++
  3 files changed, 229 insertions(+), 2 deletions(-)
drivers/net/idpf/idpf_ethdev.c +45 -2
index 6310745684..b1e2ca21ca 100644
@@ -87,6 +87,7 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
  	dev_info->max_mtu = dev_info->max_rx_pktlen - IDPF_ETH_OVERHEAD;
  	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
 
+	dev_info->flow_type_rss_offloads = IDPF_RSS_OFFLOAD_ALL;
  	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
  	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
  		RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
@@ -319,9 +320,116 @@ idpf_init_vport(struct rte_eth_dev *dev)
  }
 
  static int
-idpf_dev_configure(__rte_unused struct rte_eth_dev *dev)
+idpf_config_rss(struct idpf_vport *vport)
  {
-	return 0;
+	int ret;
+
+	ret = idpf_set_rss_key(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS key");
+		return ret;
+	}
+
+	ret = idpf_set_rss_lut(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS lut");
+		return ret;
+	}
+
+	ret = idpf_set_rss_hash(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS hash");
+		return ret;
+	}
+
+	return ret;
+}
+
+static int
+idpf_init_rss(struct idpf_vport *vport)
+{
+	struct rte_eth_rss_conf *rss_conf;
+	uint16_t i, nb_q, lut_size;
+	int ret = 0;
+
+	rss_conf = &vport->dev_data->dev_conf.rx_adv_conf.rss_conf;
+	nb_q = vport->dev_data->nb_rx_queues;
+
+	vport->rss_key = (uint8_t *)rte_zmalloc("rss_key",
+					     vport->rss_key_size, 0);
+	if (!vport->rss_key) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS key");
+		ret = -ENOMEM;
+		goto err_key;
+	}
+
+	lut_size = vport->rss_lut_size;
+	vport->rss_lut = (uint32_t *)rte_zmalloc("rss_lut",

drivers/net/idpf/idpf_ethdev.c idpf_init_vport(struct rte_eth_dev *dev) · line 377

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +10 -0
+					      sizeof(uint32_t) * lut_size, 0);
+	if (!vport->rss_lut) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS lut");
+		ret = -ENOMEM;
+		goto err_lut;
+	}
+
+	if (!rss_conf->rss_key) {
+		for (i = 0; i < vport->rss_key_size; i++)
+			vport->rss_key[i] = (uint8_t)rte_rand();

IMHO it is a bad idea. Random key could result in very bad distribution of the traffic.

drivers/net/idpf/idpf_ethdev.c idpf_init_vport(struct rte_eth_dev *dev) · line 381

Quoted 4 lines
drivers/net/idpf/idpf_ethdev.c +4 -0
+	} else {
+		rte_memcpy(vport->rss_key, rss_conf->rss_key,
+			   RTE_MIN(rss_conf->rss_key_len,
+				   vport->rss_key_size));

It looks like rss_key_len from rss_conf is saved nowhere. How do you know which bits of the RSS key are really valid/ initialized.

drivers/net/idpf/idpf_ethdev.c idpf_init_vport(struct rte_eth_dev *dev) · line 387

Quoted 6 lines
drivers/net/idpf/idpf_ethdev.c +6 -0
+	}
+
+	for (i = 0; i < lut_size; i++)
+		vport->rss_lut[i] = i % nb_q;
+
+	vport->rss_hf = IECM_DEFAULT_RSS_HASH_EXPANDED;

Hm, what about rss_conf->rss_hf?

Quoted 21 lines
drivers/net/idpf/idpf_ethdev.c +21 -0
+
+	ret = idpf_config_rss(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS");
+		goto err_cfg;
+	}
+
+	return ret;
+
+err_cfg:
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+err_lut:
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+err_key:
+	return ret;
+}
+
+static int
+idpf_dev_configure(struct rte_eth_dev *dev)

drivers/net/idpf/idpf_ethdev.c idpf_init_vport(struct rte_eth_dev *dev) · line 418

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +10 -0
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	int ret = 0;
+
+	if (dev->data->nb_tx_queues > IDPF_DEFAULT_TXQ_NUM ||
+	    dev->data->nb_rx_queues > IDPF_DEFAULT_RXQ_NUM) {
+		PMD_INIT_LOG(ERR, "Invalid queue number.");
+		return -EINVAL;
+	}

Above is checked on ethdev level if you report maximums correctly.

drivers/net/idpf/idpf_ethdev.c idpf_init_vport(struct rte_eth_dev *dev) · line 422

Quoted 4 lines
drivers/net/idpf/idpf_ethdev.c +4 -0
+
+	if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+		dev->data->dev_conf.rxmode.offloads |=
+			RTE_ETH_RX_OFFLOAD_RSS_HASH;

It looks wrong. Offload configuration is a user choice.

Quoted 13 lines
drivers/net/idpf/idpf_ethdev.c +10 -0
+
+	if (adapter->caps->rss_caps) {
+		ret = idpf_init_rss(vport);
+		if (ret) {
+			PMD_INIT_LOG(ERR, "Failed to init rss");
+			return ret;
+		}
+	}
+
+	return ret;
  }
 
  static int

[snip]

#51 lore raw

PATCH v2 10/14 net/idpf: add support for mtu configuration

In reply to Junfeng Guo

Add dev ops mtu_set.

---
 drivers/net/idpf/idpf_ethdev.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/net/idpf/idpf_ethdev.c +21 -0
index b1e2ca21ca..6b3e7eff89 100644
@@ -34,6 +34,7 @@ static int idpf_dev_stop(struct rte_eth_dev *dev);
 static int idpf_dev_close(struct rte_eth_dev *dev);
 static int idpf_dev_info_get(struct rte_eth_dev *dev,
 			     struct rte_eth_dev_info *dev_info);
+static int idpf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
 int
 idpf_dev_link_update(struct rte_eth_dev *dev,
@@ -71,6 +72,7 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.tx_queue_release		= idpf_dev_tx_queue_release,
 	.dev_infos_get			= idpf_dev_info_get,
 	.link_update			= idpf_dev_link_update,
+	.mtu_set			= idpf_dev_mtu_set,
 };
 
 static int
@@ -151,6 +153,18 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	return 0;
 }
 
+static int
+idpf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu __rte_unused)
+{
+	/* mtu setting is forbidden if port is start */
+	if (dev->data->dev_started) {
+		PMD_DRV_LOG(ERR, "port must be stopped before configuration");
+		return -EBUSY;
+	}
+
+	return 0;
+}
+
 static int
 idpf_init_vport_req_info(struct rte_eth_dev *dev)
 {
@@ -474,6 +488,13 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	vport->stopped = 0;
 
+	if (dev->data->mtu > vport->max_mtu) {
+		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
+		goto err_mtu;
+	}
+
+	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
+
 	if (idpf_start_queues(dev)) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
 		goto err_mtu;
Signature · 1 line
2.25.1
#52 lore raw

Re: [PATCH v2 10/14] net/idpf: add support for mtu configuration

Quoted 1 line · Junfeng Guo

Add dev ops mtu_set.

It would be useful to mention in the description that changing MTU is not supported when device is started.

#53 lore raw

RE: [PATCH v2 10/14] net/idpf: add support for mtu configuration

Quoted 11 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 3, 2022 22:12
To: Guo, Junfeng <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>
Subject: Re: [PATCH v2 10/14] net/idpf: add support for mtu configuration

Quoted 5 lines
Quoted 1 line · Junfeng Guo

Add dev ops mtu_set.

It would be useful to mention in the description that changing MTU is not supported when device is started.

Okay... There will be a feature list to announce the supported features. And the supported features may be added gradually along with each commit. That would be clear enough to track. Thanks!

#54 lore raw

PATCH v2 11/14 net/idpf: add support for hw statistics

In reply to Junfeng Guo

Add hardware packets/bytes statisticsi query and reset.

---
 drivers/net/idpf/idpf_ethdev.c | 78 ++++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h |  2 +
 drivers/net/idpf/idpf_vchnl.c  | 27 ++++++++++++
 3 files changed, 107 insertions(+)
drivers/net/idpf/idpf_ethdev.c +78 -0
index 6b3e7eff89..9fee7a783f 100644
@@ -35,6 +35,9 @@ static int idpf_dev_close(struct rte_eth_dev *dev);
 static int idpf_dev_info_get(struct rte_eth_dev *dev,
 			     struct rte_eth_dev_info *dev_info);
 static int idpf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
+static int idpf_dev_stats_get(struct rte_eth_dev *dev,
+			struct rte_eth_stats *stats);
+static int idpf_dev_stats_reset(struct rte_eth_dev *dev);
 
 int
 idpf_dev_link_update(struct rte_eth_dev *dev,
@@ -73,6 +76,8 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_infos_get			= idpf_dev_info_get,
 	.link_update			= idpf_dev_link_update,
 	.mtu_set			= idpf_dev_mtu_set,
+	.stats_get			= idpf_dev_stats_get,
+	.stats_reset			= idpf_dev_stats_reset,
 };
 
 static int
@@ -165,6 +170,75 @@ idpf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu __rte_unused)
 	return 0;
 }
 
+static void
+idpf_stat_update(uint64_t *offset, uint64_t *stat)
+{
+	*stat = *stat - *offset;
+}
+
+
+static void
+idpf_update_stats(struct virtchnl2_vport_stats *oes, struct virtchnl2_vport_stats *nes)
+{
+	idpf_stat_update(&oes->rx_bytes, &nes->rx_bytes);
+	idpf_stat_update(&oes->rx_unicast, &nes->rx_unicast);
+	idpf_stat_update(&oes->rx_multicast, &nes->rx_multicast);
+	idpf_stat_update(&oes->rx_broadcast, &nes->rx_broadcast);
+	idpf_stat_update(&oes->rx_discards, &nes->rx_discards);
+	idpf_stat_update(&oes->tx_bytes, &nes->tx_bytes);
+	idpf_stat_update(&oes->tx_unicast, &nes->tx_unicast);
+	idpf_stat_update(&oes->tx_multicast, &nes->tx_multicast);
+	idpf_stat_update(&oes->tx_broadcast, &nes->tx_broadcast);
+	idpf_stat_update(&oes->tx_errors, &nes->tx_errors);
+	idpf_stat_update(&oes->tx_discards, &nes->tx_discards);
+}
+
+static int
+idpf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct virtchnl2_vport_stats *pstats = NULL;
+	int ret;
+
+	ret = idpf_query_stats(vport, &pstats);
+	if (ret == 0) {
+		uint8_t crc_stats_len = (dev->data->dev_conf.rxmode.offloads &
+					 RTE_ETH_RX_OFFLOAD_KEEP_CRC) ? 0 :
+					 RTE_ETHER_CRC_LEN;
+		idpf_update_stats(&vport->eth_stats_offset, pstats);
+		stats->ipackets = pstats->rx_unicast + pstats->rx_multicast +
+				pstats->rx_broadcast - pstats->rx_discards;
+		stats->opackets = pstats->tx_broadcast + pstats->tx_multicast +
+						pstats->tx_unicast;
+		stats->imissed = pstats->rx_discards;
+		stats->oerrors = pstats->tx_errors + pstats->tx_discards;
+		stats->ibytes = pstats->rx_bytes;
+		stats->ibytes -= stats->ipackets * crc_stats_len;
+		stats->obytes = pstats->tx_bytes;
+	} else {
+		PMD_DRV_LOG(ERR, "Get statistics failed");
+	}
+	return ret;
+}
+
+
+static int
+idpf_dev_stats_reset(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct virtchnl2_vport_stats *pstats = NULL;
+	int ret;
+
+	ret = idpf_query_stats(vport, &pstats);
+	if (ret != 0)
+		return ret;
+
+	/* set stats offset base on current values */
+	vport->eth_stats_offset = *pstats;
+
+	return 0;
+}
+
 static int
 idpf_init_vport_req_info(struct rte_eth_dev *dev)
 {
@@ -508,6 +582,10 @@ idpf_dev_start(struct rte_eth_dev *dev)
 		goto err_vport;
 	}
 
+	if (idpf_dev_stats_reset(dev)) {
+		PMD_DRV_LOG(ERR, "Failed to reset stats");
+		goto err_vport;
+	}
 	return 0;
 
 err_vport:
drivers/net/idpf/idpf_ethdev.h +2 -0
index a37582d7b9..2657b75c95 100644
@@ -250,6 +250,8 @@ int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,
 		      bool rx, bool on);
 int idpf_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_ena_dis_vport(struct idpf_vport *vport, bool enable);
+int idpf_query_stats(struct idpf_vport *vport,
+		     struct virtchnl2_vport_stats **pstats);
 int idpf_query_ptype_info(struct idpf_adapter *adapter);
 int idpf_read_one_msg(struct idpf_adapter *adapter, uint32_t ops,
 		      uint16_t buf_len, uint8_t *buf);
drivers/net/idpf/idpf_vchnl.c +27 -0
index 6f9b24ab62..49572dc83c 100644
@@ -1307,6 +1307,33 @@ idpf_ena_dis_vport(struct idpf_vport *vport, bool enable)
 
 	return err;
 }
+
+int
+idpf_query_stats(struct idpf_vport *vport,
+		struct virtchnl2_vport_stats **pstats)
+{
+	struct idpf_adapter *adapter = vport->adapter;
+	struct virtchnl2_vport vc_vport;
+	struct idpf_cmd_info args;
+	int err;
+
+	vc_vport.vport_id = vport->vport_id;
+	args.ops = VIRTCHNL2_OP_GET_STATS;
+	args.in_args = (u8 *)&vc_vport;
+	args.in_args_size = sizeof(vc_vport);
+	args.out_buffer = adapter->mbx_resp;
+	args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
+
+	err = idpf_execute_vc_cmd(adapter, &args);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_GET_STATS");
+		*pstats = NULL;
+		return err;
+	}
+	*pstats = (struct virtchnl2_vport_stats *)args.out_buffer;
+	return 0;
+}
+
 int
 idpf_query_ptype_info(struct idpf_adapter *adapter)
 {
Signature · 1 line
2.25.1
#55 lore raw

PATCH v2 12/14 net/idpf: add support for write back based on ITR expire

In reply to Junfeng Guo

Force write-backs by setting WB_ON_ITR bit in DYN_CTL register, so that the packets can be received once at a time.

---
 drivers/net/idpf/idpf_ethdev.c | 116 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h |   3 +
 drivers/net/idpf/idpf_vchnl.c  | 108 ++++++++++++++++++++++++++++++
 3 files changed, 227 insertions(+)
drivers/net/idpf/idpf_ethdev.c +116 -0
index 9fee7a783f..b3ca4e3326 100644
@@ -520,6 +520,87 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static int
+idpf_config_rx_queues_irqs(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	struct virtchnl2_queue_vector *qv_map;
+	struct iecm_hw *hw = &adapter->hw;
+	uint32_t dynctl_reg_start;
+	uint32_t itrn_reg_start;
+	uint32_t dynctl_val, itrn_val;
+	uint16_t i;
+
+	qv_map = rte_zmalloc("qv_map",
+			dev->data->nb_rx_queues *
+			sizeof(struct virtchnl2_queue_vector), 0);
+	if (!qv_map) {
+		PMD_DRV_LOG(ERR, "Failed to allocate %d queue-vector map",
+			    dev->data->nb_rx_queues);
+		goto qv_map_alloc_err;
+	}
+
+	/* Rx interrupt disabled, Map interrupt only for writeback */
+
+	/* The capability flags adapter->caps->other_caps here should be
+	 * compared with bit VIRTCHNL2_CAP_WB_ON_ITR. The if condition should
+	 * be updated when the FW can return correct flag bits.
+	 */
+	if (adapter->caps->other_caps) {
+		dynctl_reg_start = vport->recv_vectors->vchunks.vchunks->dynctl_reg_start;
+		itrn_reg_start = vport->recv_vectors->vchunks.vchunks->itrn_reg_start;
+		dynctl_val = IECM_READ_REG(hw, dynctl_reg_start);
+		PMD_DRV_LOG(DEBUG, "Value of dynctl_reg_start is 0x%x", dynctl_val);
+		itrn_val = IECM_READ_REG(hw, itrn_reg_start);
+		PMD_DRV_LOG(DEBUG, "Value of itrn_reg_start is 0x%x", itrn_val);
+		/* Force write-backs by setting WB_ON_ITR bit in DYN_CTL
+		 * register. WB_ON_ITR and INTENA are mutually exclusive
+		 * bits. Setting WB_ON_ITR bits means TX and RX Descs
+		 * are writen back based on ITR expiration irrespective
+		 * of INTENA setting.
+		 */
+		/* TBD: need to tune INTERVAL value for better performance. */
+		if (itrn_val)
+			IECM_WRITE_REG(hw,
+				       dynctl_reg_start,
+				       VIRTCHNL2_ITR_IDX_0  <<
+				       PF_GLINT_DYN_CTL_ITR_INDX_S |
+				       PF_GLINT_DYN_CTL_WB_ON_ITR_M |
+				       itrn_val <<
+				       PF_GLINT_DYN_CTL_INTERVAL_S);
+		else
+			IECM_WRITE_REG(hw,
+				       dynctl_reg_start,
+				       VIRTCHNL2_ITR_IDX_0  <<
+				       PF_GLINT_DYN_CTL_ITR_INDX_S |
+				       PF_GLINT_DYN_CTL_WB_ON_ITR_M |
+				       IDPF_DFLT_INTERVAL <<
+				       PF_GLINT_DYN_CTL_INTERVAL_S);
+	}
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		/* map all queues to the same vector */
+		qv_map[i].queue_id = vport->chunks_info.rx_start_qid + i;
+		qv_map[i].vector_id =
+			vport->recv_vectors->vchunks.vchunks->start_vector_id;
+	}
+	vport->qv_map = qv_map;
+
+	if (idpf_config_irq_map_unmap(vport, true)) {
+		PMD_DRV_LOG(ERR, "config interrupt mapping failed");
+		goto config_irq_map_err;
+	}
+
+	return 0;
+
+config_irq_map_err:
+	rte_free(vport->qv_map);
+	vport->qv_map = NULL;
+
+qv_map_alloc_err:
+	return -1;
+}
+
 static int
 idpf_start_queues(struct rte_eth_dev *dev)
 {
@@ -557,6 +638,10 @@ static int
 idpf_dev_start(struct rte_eth_dev *dev)
 {
 	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	uint16_t num_allocated_vectors =
+		adapter->caps->num_allocated_vectors;
+	uint16_t req_vecs_num;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -569,6 +654,23 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
 
+	req_vecs_num = IDPF_DFLT_Q_VEC_NUM;
+	if (req_vecs_num + adapter->used_vecs_num > num_allocated_vectors) {
+		PMD_DRV_LOG(ERR, "The accumulated request vectors' number should be less than %d",
+			    num_allocated_vectors);
+		goto err_mtu;
+	}
+	if (idpf_alloc_vectors(vport, req_vecs_num)) {
+		PMD_DRV_LOG(ERR, "Failed to allocate interrupt vectors");
+		goto err_mtu;
+	}
+	adapter->used_vecs_num += req_vecs_num;
+
+	if (idpf_config_rx_queues_irqs(dev)) {
+		PMD_DRV_LOG(ERR, "Failed to configure irqs");
+		goto err_mtu;
+	}
+
 	if (idpf_start_queues(dev)) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
 		goto err_mtu;
@@ -609,6 +711,12 @@ idpf_dev_stop(struct rte_eth_dev *dev)
 
 	idpf_stop_queues(dev);
 
+	if (idpf_config_irq_map_unmap(vport, false))
+		PMD_DRV_LOG(ERR, "config interrupt unmapping failed");
+
+	if (idpf_dealloc_vectors(vport))
+		PMD_DRV_LOG(ERR, "deallocate interrupt vectors failed");
+
 	vport->stopped = 1;
 	dev->data->dev_started = 0;
 
@@ -633,6 +741,12 @@ idpf_dev_close(struct rte_eth_dev *dev)
 	rte_free(vport->rss_key);
 	vport->rss_key = NULL;
 
+	rte_free(vport->recv_vectors);
+	vport->recv_vectors = NULL;
+
+	rte_free(vport->qv_map);
+	vport->qv_map = NULL;
+
 	adapter->cur_vports &= ~BIT(vport->devarg_id);
 
 	rte_free(vport);
@@ -982,6 +1096,8 @@ idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
 	adapter->cur_vport_nb = 0;
 	adapter->next_vport_idx = 0;
 
+	adapter->used_vecs_num = 0;
+
 	return ret;
 
 err_vports:
drivers/net/idpf/idpf_ethdev.h +3 -0
index 2657b75c95..f96867f3d5 100644
@@ -252,6 +252,9 @@ int idpf_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_ena_dis_vport(struct idpf_vport *vport, bool enable);
 int idpf_query_stats(struct idpf_vport *vport,
 		     struct virtchnl2_vport_stats **pstats);
+int idpf_config_irq_map_unmap(struct idpf_vport *vport, bool map);
+int idpf_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors);
+int idpf_dealloc_vectors(struct idpf_vport *vport);
 int idpf_query_ptype_info(struct idpf_adapter *adapter);
 int idpf_read_one_msg(struct idpf_adapter *adapter, uint32_t ops,
 		      uint16_t buf_len, uint8_t *buf);
drivers/net/idpf/idpf_vchnl.c +108 -0

114 lines not on this page · raw message

Signature · 1 line
2.25.1
#56 lore raw

PATCH v2 13/14 net/idpf: add AVX512 data path for single queue model

In reply to Junfeng Guo

Add support of AVX512 vector data path for single queue model.

---
 drivers/net/idpf/idpf_ethdev.h          |   5 +
 drivers/net/idpf/idpf_rxtx.c            | 137 ++++
 drivers/net/idpf/idpf_rxtx.h            |  11 +
 drivers/net/idpf/idpf_rxtx_vec_avx512.c | 917 ++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx_vec_common.h |  89 +++
 drivers/net/idpf/meson.build            |  31 +-
 6 files changed, 1189 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/idpf/idpf_rxtx_vec_avx512.c
 create mode 100644 drivers/net/idpf/idpf_rxtx_vec_common.h
drivers/net/idpf/idpf_ethdev.h +5 -0
index f96867f3d5..a32d5758ac 100644
@@ -179,6 +179,11 @@ struct idpf_adapter {
 	uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned;
 
 	bool stopped;
+
+	bool rx_vec_allowed;
+	bool tx_vec_allowed;
+	bool rx_use_avx512;
+	bool tx_use_avx512;
 };
 
 TAILQ_HEAD(idpf_adapter_list, idpf_adapter);
drivers/net/idpf/idpf_rxtx.c +137 -0

173 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +11 -0
index 3ccf9efe50..decd0a98c2 100644
@@ -122,6 +122,10 @@ struct idpf_tx_entry {
 	uint16_t last_id;
 };
 
+struct idpf_tx_vec_entry {
+	struct rte_mbuf *mbuf;
+};
+
 /* Structure associated with each TX queue. */
 struct idpf_tx_queue {
 	const struct rte_memzone *mz;		/* memzone for Tx ring */
@@ -207,12 +211,19 @@ uint16_t idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 				uint16_t nb_pkts);
 uint16_t idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 			       uint16_t nb_pkts);
+uint16_t idpf_singleq_recv_pkts_avx512(void *rx_queue, struct rte_mbuf **rx_pkts,
+				       uint16_t nb_pkts);
 uint16_t idpf_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 				uint16_t nb_pkts);
 uint16_t idpf_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			       uint16_t nb_pkts);
+uint16_t idpf_singleq_xmit_pkts_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
+				       uint16_t nb_pkts);
+int idpf_singleq_tx_vec_setup_avx512(struct idpf_tx_queue *txq);
 uint16_t idpf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			uint16_t nb_pkts);
+int idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq);
+
 void idpf_stop_queues(struct rte_eth_dev *dev);
 
 void idpf_set_rx_function(struct rte_eth_dev *dev);
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +917 -0

917 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx_vec_common.h new file +89 -0

89 lines not on this page · raw message

drivers/net/idpf/meson.build +30 -1
index 338a39e391..ee4bb94a97 100644
@@ -16,4 +16,33 @@ sources = files(
 	'idpf_vchnl.c',
 )
 
-includes += include_directories('base')
\ No newline at end of file
+if arch_subdir == 'x86'
+	idpf_avx512_cpu_support = (
+		cc.get_define('__AVX512F__', args: machine_args) != '' and
+		cc.get_define('__AVX512BW__', args: machine_args) != ''
+	)
+
+	idpf_avx512_cc_support = (
+		not machine_args.contains('-mno-avx512f') and
+		cc.has_argument('-mavx512f') and
+		cc.has_argument('-mavx512bw')
+	)
+
+	if idpf_avx512_cpu_support == true or idpf_avx512_cc_support == true
+		cflags += ['-DCC_AVX512_SUPPORT']
+		avx512_args = [cflags, '-mavx512f', '-mavx512bw']
+		if cc.has_argument('-march=skylake-avx512')
+			avx512_args += '-march=skylake-avx512'
+		endif
+		idpf_avx512_lib = static_library('idpf_avx512_lib',
+			'idpf_rxtx_vec_avx512.c',
+			dependencies: [static_rte_ethdev, static_rte_bus_pci,
+			static_rte_kvargs, static_rte_hash],
+			include_directories: includes,
+			c_args: avx512_args)
+		objs += idpf_avx512_lib.extract_objects('idpf_rxtx_vec_avx512.c')
+	endif
+endif
+
+includes += include_directories('base')
+
Signature · 1 line
2.25.1
#57 lore raw

Re: [PATCH v2 13/14] net/idpf: add AVX512 data path for single queue model

Quoted 4 lines · Junfeng Guo

Add support of AVX512 vector data path for single queue model.

[snip]

Quoted 3 lines
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +3 -0
+static __rte_always_inline void
+idpf_singleq_rearm(struct idpf_rx_queue *rxq)
+{

[snip]

drivers/net/idpf/idpf_rxtx_vec_avx512.c line 193

Quoted 5 lines
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +5 -0
+	const __m512i iova_offsets =  _mm512_set1_epi64(offsetof
+							(struct rte_mbuf, buf_iova));
+	const __m512i headroom = _mm512_set1_epi64(RTE_PKTMBUF_HEADROOM);
+
+#ifndef RTE_LIBRTE_IDPF_16BYTE_RX_DESC

As far as I remember, support for such build time options is deprecated in DPDK and new options are not accepted. Cc Thomas to correct me if I'm wrong.

Quoted 7 lines
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +7 -0
+	/* to shuffle the addresses to correct slots. Values 4-7 will contain
+	 * zeros, so use 7 for a zero-value.
+	 */
+	const __m512i permute_idx = _mm512_set_epi64(7, 7, 3, 1, 7, 7, 2, 0);
+#else
+	const __m512i permute_idx = _mm512_set_epi64(7, 3, 6, 2, 5, 1, 4, 0);
+#endif

[snip]

Quoted 1 line

+#ifdef IDPF_RX_PTYPE_OFFLOAD

Same here.

Quoted 19 lines
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +19 -0
+		/**
+		 * to get packet types, shift 64-bit values down 30 bits
+		 * and so ptype is in lower 8-bits in each
+		 */
+		const __m512i ptypes4_7 = _mm512_srli_epi64(desc4_7, 16);
+		const __m256i ptypes6_7 = _mm512_extracti64x4_epi64(ptypes4_7, 1);
+		const __m256i ptypes4_5 = _mm512_extracti64x4_epi64(ptypes4_7, 0);
+		const uint8_t ptype7 = _mm256_extract_epi8(ptypes6_7, 16);
+		const uint8_t ptype6 = _mm256_extract_epi8(ptypes6_7, 0);
+		const uint8_t ptype5 = _mm256_extract_epi8(ptypes4_5, 16);
+		const uint8_t ptype4 = _mm256_extract_epi8(ptypes4_5, 0);
+
+		const __m512i ptype4_7 = _mm512_set_epi32
+			(0, 0, 0, type_table[ptype7],
+			 0, 0, 0, type_table[ptype6],
+			 0, 0, 0, type_table[ptype5],
+			 0, 0, 0, type_table[ptype4]);
+		mb4_7 = _mm512_mask_blend_epi32(0x1111, mb4_7, ptype4_7);
+#endif

[snip]

#58 lore raw

RE: [PATCH v2 13/14] net/idpf: add AVX512 data path for single queue model

Quoted 31 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 3, 2022 22:21
To: Guo, Junfeng <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>; Wu, Wenjun1 <[email protected]>; Thomas Monjalon <[email protected]>
Subject: Re: [PATCH v2 13/14] net/idpf: add AVX512 data path for single queue model

Quoted 4 lines · Junfeng Guo

Add support of AVX512 vector data path for single queue model.

[snip]

Quoted 3 lines
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +3 -0
+static __rte_always_inline void
+idpf_singleq_rearm(struct idpf_rx_queue *rxq)
+{

[snip]

Review

Quoted 2 lines
(quoted diff) +2 -0
+	const __m512i iova_offsets =  _mm512_set1_epi64(offsetof
+							(struct rte_mbuf,

buf_iova));

Quoted 8 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	const __m512i headroom =

_mm512_set1_epi64(RTE_PKTMBUF_HEADROOM);

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+#ifndef RTE_LIBRTE_IDPF_16BYTE_RX_DESC

As far as I remember, support for such build time options is deprecated in DPDK and new options are not accepted. Cc Thomas to correct me if I'm wrong.

Yes, we will also remove this MACRO in the coming version. Thanks!

Quoted 7 lines

Review

Quoted 2 lines
(quoted diff) +1 -0
+	/* to shuffle the addresses to correct slots. Values 4-7 will

contain

drivers/net/idpf/idpf_rxtx_vec_avx512.c

Quoted 3 lines
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +3 -0
+	 * zeros, so use 7 for a zero-value.
+	 */
+	const __m512i permute_idx = _mm512_set_epi64(7, 7, 3, 1, 7, 7,

2, 0);

Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+#else
+	const __m512i permute_idx = _mm512_set_epi64(7, 3, 6, 2, 5, 1,

4, 0);

Quoted 1 line

+#endif

[snip]

Quoted 1 line

+#ifdef IDPF_RX_PTYPE_OFFLOAD

This one is only a local MACRO defined in this file. So it may have no impact. Thanks!

Quoted 32 lines

Same here.

drivers/net/idpf/idpf_rxtx_vec_avx512.c

Quoted 5 lines
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +5 -0
+		/**
+		 * to get packet types, shift 64-bit values down 30 bits
+		 * and so ptype is in lower 8-bits in each
+		 */
+		const __m512i ptypes4_7 = _mm512_srli_epi64(desc4_7,

16);

Review

Quoted 1 line
(quoted diff) +1 -0
+		const __m256i ptypes6_7 =

_mm512_extracti64x4_epi64(ptypes4_7, 1);

Review

Quoted 1 line
(quoted diff) +1 -0
+		const __m256i ptypes4_5 =

_mm512_extracti64x4_epi64(ptypes4_7, 0);

Review

Quoted 1 line
(quoted diff) +1 -0
+		const uint8_t ptype7 = _mm256_extract_epi8(ptypes6_7,

16);

Review

Quoted 1 line
(quoted diff) +1 -0
+		const uint8_t ptype6 = _mm256_extract_epi8(ptypes6_7,

0);

Review

Quoted 1 line
(quoted diff) +1 -0
+		const uint8_t ptype5 = _mm256_extract_epi8(ptypes4_5,

16);

Review

Quoted 1 line
(quoted diff) +1 -0
+		const uint8_t ptype4 = _mm256_extract_epi8(ptypes4_5,

0);

drivers/net/idpf/idpf_rxtx_vec_avx512.c

Quoted 7 lines
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +7 -0
+
+		const __m512i ptype4_7 = _mm512_set_epi32
+			(0, 0, 0, type_table[ptype7],
+			 0, 0, 0, type_table[ptype6],
+			 0, 0, 0, type_table[ptype5],
+			 0, 0, 0, type_table[ptype4]);
+		mb4_7 = _mm512_mask_blend_epi32(0x1111, mb4_7,

ptype4_7);

Quoted 1 line

+#endif

[snip]

#59 lore raw

RE: [PATCH v2 13/14] net/idpf: add AVX512 data path for single queue model

In reply to Junfeng Guo
Quoted 308 lines

-----Original Message-----
From: Guo, Junfeng <[email protected]>
Sent: Monday, September 5, 2022 6:58 PM
To: Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>; Guo, Junfeng <[email protected]>; Wu, Wenjun1 <[email protected]>
Subject: [PATCH v2 13/14] net/idpf: add AVX512 data path for single queue model

Add support of AVX512 vector data path for single queue model.

---
 drivers/net/idpf/idpf_ethdev.h          |   5 +
 drivers/net/idpf/idpf_rxtx.c            | 137 ++++
 drivers/net/idpf/idpf_rxtx.h            |  11 +
 drivers/net/idpf/idpf_rxtx_vec_avx512.c | 917 ++++++++++++++++++++++++
drivers/net/idpf/idpf_rxtx_vec_common.h |  89 +++
 drivers/net/idpf/meson.build            |  31 +-
 6 files changed, 1189 insertions(+), 1 deletion(-)  create mode 100644
drivers/net/idpf/idpf_rxtx_vec_avx512.c
 create mode 100644 drivers/net/idpf/idpf_rxtx_vec_common.h
drivers/net/idpf/idpf_ethdev.h +5 -0
index f96867f3d5..a32d5758ac 100644
@@ -179,6 +179,11 @@ struct idpf_adapter {
 	uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned;
 
 	bool stopped;
+
+	bool rx_vec_allowed;
+	bool tx_vec_allowed;
+	bool rx_use_avx512;
+	bool tx_use_avx512;
 };
 
 TAILQ_HEAD(idpf_adapter_list, idpf_adapter); diff --git

a/drivers/net/idpf/idpf_rxtx.c b/drivers/net/idpf/idpf_rxtx.c index 54d83a7c61..e31d202646 100644

drivers/net/idpf/idpf_rxtx.c +61 -0
@@ -4,9 +4,11 @@
 
 #include <ethdev_driver.h>
 #include <rte_net.h>
+#include <rte_vect.h>
 
 #include "idpf_ethdev.h"
 #include "idpf_rxtx.h"
+#include "idpf_rxtx_vec_common.h"
 
 const uint32_t *
 idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)
@@ -2146,15 +2148,110 @@ idpf_prep_pkts(__rte_unused void *tx_queue,
 struct rte_mbuf **tx_pkts,
 	return i;
 }
 
+static void __rte_cold
+release_rxq_mbufs_vec(struct idpf_rx_queue *rxq) {
+	const uint16_t mask = rxq->nb_rx_desc - 1;
+	uint16_t i;
+
+	if (!rxq->sw_ring || rxq->rxrearm_nb >= rxq->nb_rx_desc)
+		return;
+
+	/* free all mbufs that are valid in the ring */
+	if (rxq->rxrearm_nb == 0) {
+		for (i = 0; i < rxq->nb_rx_desc; i++) {
+			if (rxq->sw_ring[i])
+				rte_pktmbuf_free_seg(rxq->sw_ring[i]);
+		}
+	} else {
+		for (i = rxq->rx_tail; i != rxq->rxrearm_start; i = (i + 1) & mask)
 {
+			if (rxq->sw_ring[i])
+				rte_pktmbuf_free_seg(rxq->sw_ring[i]);
+		}
+	}
+
+	rxq->rxrearm_nb = rxq->nb_rx_desc;
+
+	/* set all entries to NULL */
+	memset(rxq->sw_ring, 0, sizeof(rxq->sw_ring[0]) * rxq-
 >nb_rx_desc); }
+
+static const struct idpf_rxq_ops def_singleq_rx_ops_vec = {
+	.release_mbufs = release_rxq_mbufs_vec, };
+
+static inline int
+idpf_singleq_rx_vec_setup_default(struct idpf_rx_queue *rxq) {
+	uintptr_t p;
+	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
+
+	mb_def.nb_segs = 1;
+	mb_def.data_off = RTE_PKTMBUF_HEADROOM;
+	mb_def.port = rxq->port_id;
+	rte_mbuf_refcnt_set(&mb_def, 1);
+
+	/* prevent compiler reordering: rearm_data covers previous fields */
+	rte_compiler_barrier();
+	p = (uintptr_t)&mb_def.rearm_data;
+	rxq->mbuf_initializer = *(uint64_t *)p;
+	return 0;
+}
+
+int __rte_cold
+idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq) {
+	rxq->ops = &def_singleq_rx_ops_vec;
+	return idpf_singleq_rx_vec_setup_default(rxq);
+}
+
 void
 idpf_set_rx_function(struct rte_eth_dev *dev)  {
 	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *ad = vport->adapter;
+	struct idpf_rx_queue *rxq;
+	int i;
+
+#ifdef RTE_ARCH_X86
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		if (idpf_rx_vec_dev_check_default(dev) ==

IDPF_VECTOR_PATH &&

drivers/net/idpf/idpf_rxtx.c +1 -0
+		    rte_vect_get_max_simd_bitwidth() >=

RTE_VECT_SIMD_128) {

drivers/net/idpf/idpf_rxtx.c +3 -0
+			ad->rx_vec_allowed = true;
+
+			if (rte_vect_get_max_simd_bitwidth() >=

RTE_VECT_SIMD_512) #ifdef

drivers/net/idpf/idpf_rxtx.c +2 -0
+CC_AVX512_SUPPORT
+				if

(rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1 && + rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1)

drivers/net/idpf/idpf_rxtx.c +4 -0
+					ad->rx_use_avx512 = true;
+#else
+			PMD_DRV_LOG(NOTICE,
+				"AVX512 is not supported in build env");

#endif /*

drivers/net/idpf/idpf_rxtx.c +15 -0
+CC_AVX512_SUPPORT */
+		} else {
+			ad->rx_vec_allowed = false;
+		}
+	}
+#endif /* RTE_ARCH_X86 */
 
 	if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {
 		dev->rx_pkt_burst = idpf_splitq_recv_pkts;
 		return;
 	} else {
+#ifdef RTE_ARCH_X86
+		if (ad->rx_vec_allowed) {
+			for (i = 0; i < dev->data->nb_tx_queues; i++) {
+				rxq = dev->data->rx_queues[i];
+				(void)idpf_singleq_rx_vec_setup(rxq);
+			}
+#ifdef CC_AVX512_SUPPORT
+			if (ad->rx_use_avx512) {
+				dev->rx_pkt_burst =

idpf_singleq_recv_pkts_avx512;

drivers/net/idpf/idpf_rxtx.c +12 -0
+				return;
+			}
+#endif /* CC_AVX512_SUPPORT */
+		}
+#endif /* RTE_ARCH_X86 */
 		dev->rx_pkt_burst = idpf_singleq_recv_pkts;
 		return;
 	}
@@ -2164,12 +2261,52 @@ void
 idpf_set_tx_function(struct rte_eth_dev *dev)  {
 	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *ad = vport->adapter;
+	struct idpf_tx_queue *txq;
+	int i;
+
+#ifdef RTE_ARCH_X86
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		if (idpf_rx_vec_dev_check_default(dev) ==

IDPF_VECTOR_PATH &&

drivers/net/idpf/idpf_rxtx.c +1 -0
+		    rte_vect_get_max_simd_bitwidth() >=

RTE_VECT_SIMD_128) {

drivers/net/idpf/idpf_rxtx.c +2 -0
+			ad->tx_vec_allowed = true;
+			if (rte_vect_get_max_simd_bitwidth() >=

RTE_VECT_SIMD_512) #ifdef

drivers/net/idpf/idpf_rxtx.c +2 -0
+CC_AVX512_SUPPORT
+				if

(rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1 && + rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1)

drivers/net/idpf/idpf_rxtx.c +4 -0
+					ad->tx_use_avx512 = true;
+#else
+				PMD_DRV_LOG(NOTICE,
+					"AVX512 is not supported in build

env"); #endif /*

drivers/net/idpf/idpf_rxtx.c +15 -0
+CC_AVX512_SUPPORT */
+		} else {
+			ad->tx_vec_allowed = false;
+		}
+	}
+#endif /* RTE_ARCH_X86 */
 
 	if (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {
 		dev->tx_pkt_burst = idpf_splitq_xmit_pkts;
 		dev->tx_pkt_prepare = idpf_prep_pkts;
 		return;
 	} else {
+#ifdef RTE_ARCH_X86
+		if (ad->tx_vec_allowed) {
+#ifdef CC_AVX512_SUPPORT
+			if (ad->tx_use_avx512) {
+				for (i = 0; i < dev->data->nb_tx_queues; i++) {
+					txq = dev->data->tx_queues[i];
+					if (!txq)
+						continue;
+
	idpf_singleq_tx_vec_setup_avx512(txq);
drivers/net/idpf/idpf_rxtx.c +2 -0
+				}
+				dev->tx_pkt_burst =

idpf_singleq_xmit_pkts_avx512;

drivers/net/idpf/idpf_rxtx.c +6 -0
+				dev->tx_pkt_prepare = idpf_prep_pkts;
+				return;
+			}
+#endif /* CC_AVX512_SUPPORT */
+		}
+#endif /* RTE_ARCH_X86 */
 		dev->tx_pkt_burst = idpf_singleq_xmit_pkts;
 		dev->tx_pkt_prepare = idpf_prep_pkts;
 		return;
drivers/net/idpf/idpf_rxtx.h index renamed from drivers/net/idpf/idpf_rxtx.h +0 -0

3ccf9efe50..decd0a98c2 100644

drivers/net/idpf/idpf_rxtx.h +4 -0
@@ -122,6 +122,10 @@ struct idpf_tx_entry {
 	uint16_t last_id;
 };
 
+struct idpf_tx_vec_entry {
+	struct rte_mbuf *mbuf;
+};
+
 /* Structure associated with each TX queue. */  struct idpf_tx_queue {
 	const struct rte_memzone *mz;		/* memzone for Tx

ring */

drivers/net/idpf/idpf_rxtx.h +7 -0
@@ -207,12 +211,19 @@ uint16_t idpf_singleq_recv_pkts(void *rx_queue,
 struct rte_mbuf **rx_pkts,
 				uint16_t nb_pkts);
 uint16_t idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 			       uint16_t nb_pkts);
+uint16_t idpf_singleq_recv_pkts_avx512(void *rx_queue, struct rte_mbuf
 **rx_pkts,
+				       uint16_t nb_pkts);
 uint16_t idpf_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 				uint16_t nb_pkts);
 uint16_t idpf_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			       uint16_t nb_pkts);
+uint16_t idpf_singleq_xmit_pkts_avx512(void *tx_queue, struct rte_mbuf
 **tx_pkts,
+				       uint16_t nb_pkts);
+int idpf_singleq_tx_vec_setup_avx512(struct idpf_tx_queue *txq);
 uint16_t idpf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			uint16_t nb_pkts);
+int idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq);
+

void idpf_stop_queues(struct rte_eth_dev *dev);

void idpf_set_rx_function(struct rte_eth_dev *dev); diff --git
a/drivers/net/idpf/idpf_rxtx_vec_avx512.c b/drivers/net/idpf/idpf_rxtx_vec_avx512.c
new file mode 100644
index 0000000000..70eb5e1e7e

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +16 -0
@@ -0,0 +1,917 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#include "idpf_rxtx_vec_common.h"
+
+#include <rte_vect.h>
+
+#ifndef __INTEL_COMPILER
+#pragma GCC diagnostic ignored "-Wcast-qual"
+#endif
+
+#define IDPF_DESCS_PER_LOOP_AVX 8
+#define PKTLEN_SHIFT 10
+
+/**************************************************************

********

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +11 -0
+********
+ * If user knows a specific offload is not enabled by APP,
+ * the macro can be commented to save the effort of fast path.
+ * Currently below 2 features are supported in RX path,
+ * 1, checksum offload
+ * 2, VLAN/QINQ stripping
+ * 3, RSS hash
+ * 4, packet type analysis
+ * 5, flow director ID report
+
+***************************************************************

********

drivers/net/idpf/idpf_rxtx_vec_avx512.c

Quoted 2 lines
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +2 -0
+*******/
+#define IDPF_RX_PTYPE_OFFLOAD

The comments should be reworked since it does not fully match the code.

Quoted 183 lines
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +33 -0
+
+static __rte_always_inline void
+idpf_singleq_rearm_common(struct idpf_rx_queue *rxq) {
+	struct rte_mbuf **rxp = &rxq->sw_ring[rxq->rxrearm_start];
+	volatile union virtchnl2_rx_desc *rxdp = rxq->rx_ring;
+	uint16_t rx_id;
+	int i;
+
+	rxdp += rxq->rxrearm_start;
+
+	/* Pull 'n' more MBUFs into the software ring */
+	if (rte_mempool_get_bulk(rxq->mp,
+				 (void *)rxp,
+				 IDPF_RXQ_REARM_THRESH) < 0) {
+		if (rxq->rxrearm_nb + IDPF_RXQ_REARM_THRESH >=
+		    rxq->nb_rx_desc) {
+			__m128i dma_addr0;
+
+			dma_addr0 = _mm_setzero_si128();
+			for (i = 0; i < IDPF_VPMD_DESCS_PER_LOOP; i++) {
+				rxp[i] = &rxq->fake_mbuf;
+				_mm_store_si128((__m128i *)&rxdp[i].read,
+						dma_addr0);
+			}
+		}
+		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
+			IDPF_RXQ_REARM_THRESH;
+		return;
+	}
+	struct rte_mbuf *mb0, *mb1, *mb2, *mb3;
+	struct rte_mbuf *mb4, *mb5, *mb6, *mb7;
+	__m512i dma_addr0_3, dma_addr4_7;
+	__m512i hdr_room =

_mm512_set1_epi64(RTE_PKTMBUF_HEADROOM);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +36 -0
+	/* Initialize the mbufs in vector, process 8 mbufs in one loop */
+	for (i = 0; i < IDPF_RXQ_REARM_THRESH;
+			i += 8, rxp += 8, rxdp += 8) {
+		__m128i vaddr0, vaddr1, vaddr2, vaddr3;
+		__m128i vaddr4, vaddr5, vaddr6, vaddr7;
+		__m256i vaddr0_1, vaddr2_3;
+		__m256i vaddr4_5, vaddr6_7;
+		__m512i vaddr0_3, vaddr4_7;
+
+		mb0 = rxp[0];
+		mb1 = rxp[1];
+		mb2 = rxp[2];
+		mb3 = rxp[3];
+		mb4 = rxp[4];
+		mb5 = rxp[5];
+		mb6 = rxp[6];
+		mb7 = rxp[7];
+
+		/* load buf_addr(lo 64bit) and buf_iova(hi 64bit) */
+		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, buf_iova) !=
+				offsetof(struct rte_mbuf, buf_addr) + 8);
+		vaddr0 = _mm_loadu_si128((__m128i *)&mb0->buf_addr);
+		vaddr1 = _mm_loadu_si128((__m128i *)&mb1->buf_addr);
+		vaddr2 = _mm_loadu_si128((__m128i *)&mb2->buf_addr);
+		vaddr3 = _mm_loadu_si128((__m128i *)&mb3->buf_addr);
+		vaddr4 = _mm_loadu_si128((__m128i *)&mb4->buf_addr);
+		vaddr5 = _mm_loadu_si128((__m128i *)&mb5->buf_addr);
+		vaddr6 = _mm_loadu_si128((__m128i *)&mb6->buf_addr);
+		vaddr7 = _mm_loadu_si128((__m128i *)&mb7->buf_addr);
+
+		/**
+		 * merge 0 & 1, by casting 0 to 256-bit and inserting 1
+		 * into the high lanes. Similarly for 2 & 3, and so on.
+		 */
+		vaddr0_1 =
+
	_mm256_inserti128_si256(_mm256_castsi128_si256(vaddr0),
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +3 -0
+						vaddr1, 1);
+		vaddr2_3 =
+
	_mm256_inserti128_si256(_mm256_castsi128_si256(vaddr2),
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +3 -0
+						vaddr3, 1);
+		vaddr4_5 =
+
	_mm256_inserti128_si256(_mm256_castsi128_si256(vaddr4),
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +3 -0
+						vaddr5, 1);
+		vaddr6_7 =
+
	_mm256_inserti128_si256(_mm256_castsi128_si256(vaddr6),
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +3 -0
+						vaddr7, 1);
+		vaddr0_3 =
+
	_mm512_inserti64x4(_mm512_castsi256_si512(vaddr0_1),
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +3 -0
+						vaddr2_3, 1);
+		vaddr4_7 =
+
	_mm512_inserti64x4(_mm512_castsi256_si512(vaddr4_5),
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +4 -0
+						vaddr6_7, 1);
+
+		/* convert pa to dma_addr hdr/data */
+		dma_addr0_3 = _mm512_unpackhi_epi64(vaddr0_3,

vaddr0_3);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+		dma_addr4_7 = _mm512_unpackhi_epi64(vaddr4_7,

vaddr4_7);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +3 -0
+
+		/* add headroom to pa values */
+		dma_addr0_3 = _mm512_add_epi64(dma_addr0_3,

hdr_room);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+		dma_addr4_7 = _mm512_add_epi64(dma_addr4_7,

hdr_room);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +3 -0
+
+		/* flush desc with pa dma_addr */
+		_mm512_store_si512((__m512i *)&rxdp->read,

dma_addr0_3);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+		_mm512_store_si512((__m512i *)&(rxdp + 4)->read,

dma_addr4_7);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +29 -0
+	}
+
+	rxq->rxrearm_start += IDPF_RXQ_REARM_THRESH;
+	if (rxq->rxrearm_start >= rxq->nb_rx_desc)
+		rxq->rxrearm_start = 0;
+
+	rxq->rxrearm_nb -= IDPF_RXQ_REARM_THRESH;
+
+	rx_id = (uint16_t)((rxq->rxrearm_start == 0) ?
+			     (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));
+
+	/* Update the tail pointer on the NIC */
+	IECM_PCI_REG_WRITE(rxq->qrx_tail, rx_id); }
+
+static __rte_always_inline void
+idpf_singleq_rearm(struct idpf_rx_queue *rxq) {
+	int i;
+	uint16_t rx_id;
+	volatile union virtchnl2_rx_desc *rxdp = rxq->rx_ring;
+	struct rte_mempool_cache *cache =
+		rte_mempool_default_cache(rxq->mp, rte_lcore_id());
+	struct rte_mbuf **rxp = &rxq->sw_ring[rxq->rxrearm_start];
+
+	rxdp += rxq->rxrearm_start;
+
+	if (unlikely(!cache))
+		return idpf_singleq_rearm_common(rxq);
+
+	/* We need to pull 'n' more MBUFs into the software ring from

mempool

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+	 * We inline the mempool function here, so we can vectorize the

copy

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +10 -0
+	 * from the cache into the shadow ring.
+	 */
+
+	/* Can this be satisfied from the cache? */
+	if (cache->len < IDPF_RXQ_REARM_THRESH) {
+		/* No. Backfill the cache first, and then fill from it */
+		uint32_t req = IDPF_RXQ_REARM_THRESH + (cache->size -
+							cache->len);
+
+		/* How many do we require i.e. number to fill the cache + the

request */

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +11 -0
+		int ret = rte_mempool_ops_dequeue_bulk
+				(rxq->mp, &cache->objs[cache->len], req);
+		if (ret == 0) {
+			cache->len += req;
+		} else {
+			if (rxq->rxrearm_nb + IDPF_RXQ_REARM_THRESH >=
+			    rxq->nb_rx_desc) {
+				__m128i dma_addr0;
+
+				dma_addr0 = _mm_setzero_si128();
+				for (i = 0; i < IDPF_VPMD_DESCS_PER_LOOP;

i++) {

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +2 -0
+					rxp[i] = &rxq->fake_mbuf;
+					_mm_storeu_si128((__m128i

*)&rxdp[i].read,

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +4 -0
+							 dma_addr0);
+				}
+			}
+			rte_eth_devices[rxq->port_id].data-
Quoted 1 line

rx_mbuf_alloc_failed +=

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +7 -0
+					IDPF_RXQ_REARM_THRESH;
+			return;
+		}
+	}
+
+	const __m512i iova_offsets =  _mm512_set1_epi64(offsetof
+							(struct rte_mbuf,

buf_iova));

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+	const __m512i headroom =

_mm512_set1_epi64(RTE_PKTMBUF_HEADROOM);

drivers/net/idpf/idpf_rxtx_vec_avx512.c line 200

Quoted 9 lines
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +9 -0
+
+#ifndef RTE_LIBRTE_IDPF_16BYTE_RX_DESC
+	/* to shuffle the addresses to correct slots. Values 4-7 will contain
+	 * zeros, so use 7 for a zero-value.
+	 */
+	const __m512i permute_idx = _mm512_set_epi64(7, 7, 3, 1, 7, 7, 2, 0);
+#else
+	const __m512i permute_idx = _mm512_set_epi64(7, 3, 6, 2, 5, 1, 4, 0);
+#endif

Conditional compilation is not necessary here.

Quoted 18 lines
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +5 -0
+
+	/* Initialize the mbufs in vector, process 8 mbufs in one loop, taking
+	 * from mempool cache and populating both shadow and HW rings
+	 */
+	for (i = 0; i < IDPF_RXQ_REARM_THRESH /

IDPF_DESCS_PER_LOOP_AVX; i++) {

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +2 -0
+		const __m512i mbuf_ptrs = _mm512_loadu_si512
+			(&cache->objs[cache->len -

IDPF_DESCS_PER_LOOP_AVX]);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +4 -0
+		_mm512_storeu_si512(rxp, mbuf_ptrs);
+
+		const __m512i iova_base_addrs = _mm512_i64gather_epi64
+				(_mm512_add_epi64(mbuf_ptrs,

iova_offsets),

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +3 -0
+				 0, /* base */
+				 1  /* scale */);
+		const __m512i iova_addrs =

_mm512_add_epi64(iova_base_addrs,

drivers/net/idpf/idpf_rxtx_vec_avx512.c line 216

Quoted 2 lines
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +2 -0
+				headroom);
+#ifndef RTE_LIBRTE_IDPF_16BYTE_RX_DESC

Conditional compilation is not necessary here.

Quoted 149 lines
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +6 -0
+		const __m512i iovas0 = _mm512_castsi256_si512
+				(_mm512_extracti64x4_epi64(iova_addrs, 0));
+		const __m512i iovas1 = _mm512_castsi256_si512
+				(_mm512_extracti64x4_epi64(iova_addrs, 1));
+
+		/* permute leaves desc 2-3 addresses in header address slots

0-1

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +18 -0
+		 * but these are ignored by driver since header split not
+		 * enabled. Similarly for desc 6 & 7.
+		 */
+		const __m512i desc0_1 = _mm512_permutexvar_epi64
+				(permute_idx,
+				 iovas0);
+		const __m512i desc2_3 = _mm512_bsrli_epi128(desc0_1, 8);
+
+		const __m512i desc4_5 = _mm512_permutexvar_epi64
+				(permute_idx,
+				 iovas1);
+		const __m512i desc6_7 = _mm512_bsrli_epi128(desc4_5, 8);
+
+		_mm512_storeu_si512((void *)rxdp, desc0_1);
+		_mm512_storeu_si512((void *)(rxdp + 2), desc2_3);
+		_mm512_storeu_si512((void *)(rxdp + 4), desc4_5);
+		_mm512_storeu_si512((void *)(rxdp + 6), desc6_7); #else
+		/* permute leaves desc 4-7 addresses in header address slots

0-3

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +4 -0
+		 * but these are ignored by driver since header split not
+		 * enabled.
+		 */
+		const __m512i desc0_3 =

_mm512_permutexvar_epi64(permute_idx,

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +54 -0
+								 iova_addrs);
+		const __m512i desc4_7 = _mm512_bsrli_epi128(desc0_3, 8);
+
+		_mm512_storeu_si512((void *)rxdp, desc0_3);
+		_mm512_storeu_si512((void *)(rxdp + 4), desc4_7); #endif
+		rxp += IDPF_DESCS_PER_LOOP_AVX;
+		rxdp += IDPF_DESCS_PER_LOOP_AVX;
+		cache->len -= IDPF_DESCS_PER_LOOP_AVX;
+	}
+
+	rxq->rxrearm_start += IDPF_RXQ_REARM_THRESH;
+	if (rxq->rxrearm_start >= rxq->nb_rx_desc)
+		rxq->rxrearm_start = 0;
+
+	rxq->rxrearm_nb -= IDPF_RXQ_REARM_THRESH;
+
+	rx_id = (uint16_t)((rxq->rxrearm_start == 0) ?
+			   (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));
+
+	/* Update the tail pointer on the NIC */
+	IECM_PCI_REG_WRITE(rxq->qrx_tail, rx_id); }
+
+#define IDPF_RX_LEN_MASK 0x80808080
+static __rte_always_inline uint16_t
+_idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
+				   struct rte_mbuf **rx_pkts,
+				   uint16_t nb_pkts)
+{
+#ifdef IDPF_RX_PTYPE_OFFLOAD
+	const uint32_t *type_table = rxq->adapter->ptype_tbl; #endif
+
+	const __m256i mbuf_init = _mm256_set_epi64x(0, 0, 0,
+						    rxq->mbuf_initializer);
+	struct rte_mbuf **sw_ring = &rxq->sw_ring[rxq->rx_tail];
+	volatile union virtchnl2_rx_desc *rxdp = rxq->rx_ring;
+
+	rxdp += rxq->rx_tail;
+
+	rte_prefetch0(rxdp);
+
+	/* nb_pkts has to be floor-aligned to IDPF_DESCS_PER_LOOP_AVX */
+	nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, IDPF_DESCS_PER_LOOP_AVX);
+
+	/* See if we need to rearm the RX queue - gives the prefetch a bit
+	 * of time to act
+	 */
+	if (rxq->rxrearm_nb > IDPF_RXQ_REARM_THRESH)
+		idpf_singleq_rearm(rxq);
+
+	/* Before we start moving massive data around, check to see if
+	 * there is actually a packet available
+	 */
+	if (!(rxdp->flex_nic_wb.status_error0  &
+	      rte_cpu_to_le_32(1 <<

VIRTCHNL2_RX_FLEX_DESC_STATUS0_DD_S)))

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +38 -0
+		return 0;
+
+	/* constants used in processing loop */
+	const __m512i crc_adjust =
+		_mm512_set_epi32
+			(/* 1st descriptor */
+			 0,             /* ignore non-length fields */
+			 -rxq->crc_len, /* sub crc on data_len */
+			 -rxq->crc_len, /* sub crc on pkt_len */
+			 0,             /* ignore pkt_type field */
+			 /* 2nd descriptor */
+			 0,             /* ignore non-length fields */
+			 -rxq->crc_len, /* sub crc on data_len */
+			 -rxq->crc_len, /* sub crc on pkt_len */
+			 0,             /* ignore pkt_type field */
+			 /* 3rd descriptor */
+			 0,             /* ignore non-length fields */
+			 -rxq->crc_len, /* sub crc on data_len */
+			 -rxq->crc_len, /* sub crc on pkt_len */
+			 0,             /* ignore pkt_type field */
+			 /* 4th descriptor */
+			 0,             /* ignore non-length fields */
+			 -rxq->crc_len, /* sub crc on data_len */
+			 -rxq->crc_len, /* sub crc on pkt_len */
+			 0              /* ignore pkt_type field */
+			);
+
+	/* 8 packets DD mask, LSB in each 32-bit value */
+	const __m256i dd_check = _mm256_set1_epi32(1);
+
+	/* mask to shuffle from desc. to mbuf (4 descriptors)*/
+	const __m512i shuf_msk =
+		_mm512_set_epi32
+			(/* 1st descriptor */
+			 0xFFFFFFFF,    /* octet 4~7, 32bits rss */
+			 0xFFFF0504,    /* octet 2~3, low 16 bits vlan_macip */
+					/* octet 15~14, 16 bits data_len */
+			 0xFFFF0504,    /* skip high 16 bits pkt_len, zero out

*/

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +7 -0
+					/* octet 15~14, low 16 bits pkt_len */
+			 0xFFFFFFFF,    /* pkt_type set as unknown */
+			 /* 2nd descriptor */
+			 0xFFFFFFFF,    /* octet 4~7, 32bits rss */
+			 0xFFFF0504,    /* octet 2~3, low 16 bits vlan_macip */
+					/* octet 15~14, 16 bits data_len */
+			 0xFFFF0504,    /* skip high 16 bits pkt_len, zero out

*/

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +7 -0
+					/* octet 15~14, low 16 bits pkt_len */
+			 0xFFFFFFFF,    /* pkt_type set as unknown */
+			 /* 3rd descriptor */
+			 0xFFFFFFFF,    /* octet 4~7, 32bits rss */
+			 0xFFFF0504,    /* octet 2~3, low 16 bits vlan_macip */
+					/* octet 15~14, 16 bits data_len */
+			 0xFFFF0504,    /* skip high 16 bits pkt_len, zero out

*/

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +7 -0
+					/* octet 15~14, low 16 bits pkt_len */
+			 0xFFFFFFFF,    /* pkt_type set as unknown */
+			 /* 4th descriptor */
+			 0xFFFFFFFF,    /* octet 4~7, 32bits rss */
+			 0xFFFF0504,    /* octet 2~3, low 16 bits vlan_macip */
+					/* octet 15~14, 16 bits data_len */
+			 0xFFFF0504,    /* skip high 16 bits pkt_len, zero out

*/

drivers/net/idpf/idpf_rxtx_vec_avx512.c line 364

Quoted 3 lines
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +3 -0
+					/* octet 15~14, low 16 bits pkt_len */
+			 0xFFFFFFFF     /* pkt_type set as unknown */
+			);

The comments should be reworked since it does not fully match the code.

Quoted 724 lines
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +22 -0
+	/**
+	 * compile-time check the above crc and shuffle layout is correct.
+	 * NOTE: the first field (lowest address) is given last in set_epi
+	 * calls above.
+	 */
+	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) !=
+			 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
+	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) !=
+			 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
+	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, vlan_tci) !=
+			 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
+	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
+			 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
+
+	uint16_t i, received;
+
+	for (i = 0, received = 0; i < nb_pkts;
+	     i += IDPF_DESCS_PER_LOOP_AVX,
+	     rxdp += IDPF_DESCS_PER_LOOP_AVX) {
+		/* step 1, copy over 8 mbuf pointers to rx_pkts array */
+		_mm256_storeu_si256((void *)&rx_pkts[i],
+				    _mm256_loadu_si256((void *)&sw_ring[i]));

#ifdef

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +4 -0
+RTE_ARCH_X86_64
+		_mm256_storeu_si256
+			((void *)&rx_pkts[i + 4],
+			 _mm256_loadu_si256((void *)&sw_ring[i + 4]));

#endif

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +28 -0
+
+		__m512i raw_desc0_3, raw_desc4_7;
+		const __m128i raw_desc7 =
+			_mm_load_si128((void *)(rxdp + 7));
+		rte_compiler_barrier();
+		const __m128i raw_desc6 =
+			_mm_load_si128((void *)(rxdp + 6));
+		rte_compiler_barrier();
+		const __m128i raw_desc5 =
+			_mm_load_si128((void *)(rxdp + 5));
+		rte_compiler_barrier();
+		const __m128i raw_desc4 =
+			_mm_load_si128((void *)(rxdp + 4));
+		rte_compiler_barrier();
+		const __m128i raw_desc3 =
+			_mm_load_si128((void *)(rxdp + 3));
+		rte_compiler_barrier();
+		const __m128i raw_desc2 =
+			_mm_load_si128((void *)(rxdp + 2));
+		rte_compiler_barrier();
+		const __m128i raw_desc1 =
+			_mm_load_si128((void *)(rxdp + 1));
+		rte_compiler_barrier();
+		const __m128i raw_desc0 =
+			_mm_load_si128((void *)(rxdp + 0));
+
+		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
+		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7,

raw_desc5, 1);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7,

raw_desc6, 2);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7,

raw_desc7, 3);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +2 -0
+		raw_desc0_3 = _mm512_broadcast_i32x4(raw_desc0);
+		raw_desc0_3 = _mm512_inserti32x4(raw_desc0_3,

raw_desc1, 1);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+		raw_desc0_3 = _mm512_inserti32x4(raw_desc0_3,

raw_desc2, 2);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+		raw_desc0_3 = _mm512_inserti32x4(raw_desc0_3,

raw_desc3, 3);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +8 -0
+
+		/**
+		 * convert descriptors 4-7 into mbufs, adjusting length and
+		 * re-arranging fields. Then write into the mbuf
+		 */
+		const __m512i len4_7 = _mm512_slli_epi32(raw_desc4_7,
+							 PKTLEN_SHIFT);
+		const __m512i desc4_7 =

_mm512_mask_blend_epi16(IDPF_RX_LEN_MASK,

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +12 -0
+								raw_desc4_7,
+								len4_7);
+		__m512i mb4_7 = _mm512_shuffle_epi8(desc4_7, shuf_msk);
+
+		mb4_7 = _mm512_add_epi32(mb4_7, crc_adjust); #ifdef
+IDPF_RX_PTYPE_OFFLOAD
+		/**
+		 * to get packet types, shift 64-bit values down 30 bits
+		 * and so ptype is in lower 8-bits in each
+		 */
+		const __m512i ptypes4_7 = _mm512_srli_epi64(desc4_7, 16);
+		const __m256i ptypes6_7 =

_mm512_extracti64x4_epi64(ptypes4_7, 1);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+		const __m256i ptypes4_5 =

_mm512_extracti64x4_epi64(ptypes4_7, 0);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +11 -0
+		const uint8_t ptype7 = _mm256_extract_epi8(ptypes6_7, 16);
+		const uint8_t ptype6 = _mm256_extract_epi8(ptypes6_7, 0);
+		const uint8_t ptype5 = _mm256_extract_epi8(ptypes4_5, 16);
+		const uint8_t ptype4 = _mm256_extract_epi8(ptypes4_5, 0);
+
+		const __m512i ptype4_7 = _mm512_set_epi32
+			(0, 0, 0, type_table[ptype7],
+			 0, 0, 0, type_table[ptype6],
+			 0, 0, 0, type_table[ptype5],
+			 0, 0, 0, type_table[ptype4]);
+		mb4_7 = _mm512_mask_blend_epi32(0x1111, mb4_7,

ptype4_7); #endif

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +8 -0
+
+		/**
+		 * convert descriptors 0-3 into mbufs, adjusting length and
+		 * re-arranging fields. Then write into the mbuf
+		 */
+		const __m512i len0_3 = _mm512_slli_epi32(raw_desc0_3,
+							 PKTLEN_SHIFT);
+		const __m512i desc0_3 =

_mm512_mask_blend_epi16(IDPF_RX_LEN_MASK,

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +9 -0
+								raw_desc0_3,
+								len0_3);
+		__m512i mb0_3 = _mm512_shuffle_epi8(desc0_3, shuf_msk);
+
+		mb0_3 = _mm512_add_epi32(mb0_3, crc_adjust); #ifdef
+IDPF_RX_PTYPE_OFFLOAD
+		/* get the packet types */
+		const __m512i ptypes0_3 = _mm512_srli_epi64(desc0_3, 16);
+		const __m256i ptypes2_3 =

_mm512_extracti64x4_epi64(ptypes0_3, 1);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+		const __m256i ptypes0_1 =

_mm512_extracti64x4_epi64(ptypes0_3, 0);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +11 -0
+		const uint8_t ptype3 = _mm256_extract_epi8(ptypes2_3, 16);
+		const uint8_t ptype2 = _mm256_extract_epi8(ptypes2_3, 0);
+		const uint8_t ptype1 = _mm256_extract_epi8(ptypes0_1, 16);
+		const uint8_t ptype0 = _mm256_extract_epi8(ptypes0_1, 0);
+
+		const __m512i ptype0_3 = _mm512_set_epi32
+			(0, 0, 0, type_table[ptype3],
+			 0, 0, 0, type_table[ptype2],
+			 0, 0, 0, type_table[ptype1],
+			 0, 0, 0, type_table[ptype0]);
+		mb0_3 = _mm512_mask_blend_epi32(0x1111, mb0_3,

ptype0_3); #endif

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +13 -0
+
+		/**
+		 * use permute/extract to get status content
+		 * After the operations, the packets status flags are in the
+		 * order (hi->lo): [1, 3, 5, 7, 0, 2, 4, 6]
+		 */
+		/* merge the status bits into one register */
+		const __m512i status_permute_msk = _mm512_set_epi32
+			(0, 0, 0, 0,
+			 0, 0, 0, 0,
+			 22, 30, 6, 14,
+			 18, 26, 2, 10);
+		const __m512i raw_status0_7 =

_mm512_permutex2var_epi32

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +10 -0
+			(raw_desc4_7, status_permute_msk, raw_desc0_3);
+		__m256i status0_7 = _mm512_extracti64x4_epi64
+			(raw_status0_7, 0);
+
+		/* now do flag manipulation */
+
+		/**
+		 * At this point, we have the 8 sets of flags in the low 16-bits
+		 * of each 32-bit value in vlan0.
+		 * We want to extract these, and merge them with the mbuf

init

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+		 * data so we can do a single write to the mbuf to set the

flags

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +2 -0
+		 * and all the other initialization fields. Extracting the
+		 * appropriate flags means that we have to do a shift and

blend

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+		 * for each mbuf before we do the write. However, we can

also

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +7 -0
+		 * add in the previously computed rx_descriptor fields to
+		 * make a single 256-bit write per mbuf
+		 */
+		/* check the structure matches expectations */
+		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
+				 offsetof(struct rte_mbuf, rearm_data) + 8);
+		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf,

rearm_data) !=

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +7 -0
+				 RTE_ALIGN(offsetof(struct rte_mbuf,
+						    rearm_data),
+						    16));
+		/* build up data and do writes */
+		__m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5,
+			rearm6, rearm7;
+		const __m256i mb4_5 = _mm512_extracti64x4_epi64(mb4_7,

0);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+		const __m256i mb6_7 = _mm512_extracti64x4_epi64(mb4_7,

1);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+		const __m256i mb0_1 = _mm512_extracti64x4_epi64(mb0_3,

0);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+		const __m256i mb2_3 = _mm512_extracti64x4_epi64(mb0_3,

1);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +2 -0
+
+		rearm6 = _mm256_permute2f128_si256(mbuf_init, mb6_7,

0x20);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+		rearm4 = _mm256_permute2f128_si256(mbuf_init, mb4_5,

0x20);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+		rearm2 = _mm256_permute2f128_si256(mbuf_init, mb2_3,

0x20);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+		rearm0 = _mm256_permute2f128_si256(mbuf_init, mb0_1,

0x20);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +3 -0
+
+		/* write to mbuf */
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]-
Quoted 1 line

rearm_data,

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +2 -0
+				    rearm6);
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]-
Quoted 1 line

rearm_data,

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +2 -0
+				    rearm4);
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]-
Quoted 1 line

rearm_data,

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +2 -0
+				    rearm2);
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]-
Quoted 1 line

rearm_data,

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +9 -0
+				    rearm0);
+
+		rearm7 = _mm256_blend_epi32(mbuf_init, mb6_7, 0xF0);
+		rearm5 = _mm256_blend_epi32(mbuf_init, mb4_5, 0xF0);
+		rearm3 = _mm256_blend_epi32(mbuf_init, mb2_3, 0xF0);
+		rearm1 = _mm256_blend_epi32(mbuf_init, mb0_1, 0xF0);
+
+		/* again write to mbufs */
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]-
Quoted 1 line

rearm_data,

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +2 -0
+				    rearm7);
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]-
Quoted 1 line

rearm_data,

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +2 -0
+				    rearm5);
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]-
Quoted 1 line

rearm_data,

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +2 -0
+				    rearm3);
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]-
Quoted 1 line

rearm_data,

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +14 -0
+				    rearm1);
+
+		/* perform dd_check */
+		status0_7 = _mm256_and_si256(status0_7, dd_check);
+		status0_7 = _mm256_packs_epi32(status0_7,
+					       _mm256_setzero_si256());
+
+		uint64_t burst = __builtin_popcountll
+					(_mm_cvtsi128_si64
+						(_mm256_extracti128_si256
+							(status0_7, 1)));
+		burst += __builtin_popcountll
+				(_mm_cvtsi128_si64
+
	(_mm256_castsi256_si128(status0_7)));
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +23 -0
+		received += burst;
+		if (burst != IDPF_DESCS_PER_LOOP_AVX)
+			break;
+	}
+
+	/* update tail pointers */
+	rxq->rx_tail += received;
+	rxq->rx_tail &= (rxq->nb_rx_desc - 1);
+	if ((rxq->rx_tail & 1) == 1 && received > 1) { /* keep aligned */
+		rxq->rx_tail--;
+		received--;
+	}
+	rxq->rxrearm_nb += received;
+	return received;
+}
+
+/**
+ * Notice:
+ * - nb_pkts < IDPF_DESCS_PER_LOOP, just return no packet  */ uint16_t
+idpf_singleq_recv_pkts_avx512(void *rx_queue, struct rte_mbuf **rx_pkts,
+			  uint16_t nb_pkts)
+{
+	return _idpf_singleq_recv_raw_pkts_avx512(rx_queue, rx_pkts,

nb_pkts);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +14 -0
+}
+
+static __rte_always_inline int
+idpf_tx_free_bufs_avx512(struct idpf_tx_queue *txq) {
+	struct idpf_tx_vec_entry *txep;
+	uint32_t n;
+	uint32_t i;
+	int nb_free = 0;
+	struct rte_mbuf *m, *free[txq->rs_thresh];
+
+	/* check DD bits on threshold descriptor */
+	if ((txq->tx_ring[txq->next_dd].qw1 &
+			rte_cpu_to_le_64(IECM_TXD_QW1_DTYPE_M)) !=
+
	rte_cpu_to_le_64(IECM_TX_DESC_DTYPE_DESC_DONE))
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +11 -0
+		return 0;
+
+	n = txq->rs_thresh;
+
+	 /* first buffer to free from S/W ring is at index
+	  * tx_next_dd - (tx_rs_thresh-1)
+	  */
+	txep = (void *)txq->sw_ring;
+	txep += txq->next_dd - (n - 1);
+
+	if (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE && (n

& 31) == 0) {

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +2 -0
+		struct rte_mempool *mp = txep[0].mbuf->pool;
+		struct rte_mempool_cache *cache =

rte_mempool_default_cache(mp,
+

	rte_lcore_id());
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +9 -0
+		void **cache_objs;
+
+		if (!cache || cache->len == 0)
+			goto normal;
+
+		cache_objs = &cache->objs[cache->len];
+
+		if (n > RTE_MEMPOOL_CACHE_MAX_SIZE) {
+			rte_mempool_ops_enqueue_bulk(mp, (void *)txep,

n);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +6 -0
+			goto done;
+		}
+
+		/* The cache follows the following algorithm
+		 *   1. Add the objects to the cache
+		 *   2. Anything greater than the cache min value (if it crosses

the

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +7 -0
+		 *   cache flush threshold) is flushed to the ring.
+		 */
+		/* Add elements back into the cache */
+		uint32_t copied = 0;
+		/* n is multiple of 32 */
+		while (copied < n) {
+			const __m512i a =

_mm512_loadu_si512(&txep[copied]);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+			const __m512i b =

_mm512_loadu_si512(&txep[copied + 8]);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+			const __m512i c =

_mm512_loadu_si512(&txep[copied + 16]);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +1 -0
+			const __m512i d =

_mm512_loadu_si512(&txep[copied + 24]);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +38 -0
+
+			_mm512_storeu_si512(&cache_objs[copied], a);
+			_mm512_storeu_si512(&cache_objs[copied + 8], b);
+			_mm512_storeu_si512(&cache_objs[copied + 16], c);
+			_mm512_storeu_si512(&cache_objs[copied + 24], d);
+			copied += 32;
+		}
+		cache->len += n;
+
+		if (cache->len >= cache->flushthresh) {
+			rte_mempool_ops_enqueue_bulk(mp,
+						     &cache->objs[cache->size],
+						     cache->len - cache->size);
+			cache->len = cache->size;
+		}
+		goto done;
+	}
+
+normal:
+	m = rte_pktmbuf_prefree_seg(txep[0].mbuf);
+	if (likely(m)) {
+		free[0] = m;
+		nb_free = 1;
+		for (i = 1; i < n; i++) {
+			m = rte_pktmbuf_prefree_seg(txep[i].mbuf);
+			if (likely(m)) {
+				if (likely(m->pool == free[0]->pool)) {
+					free[nb_free++] = m;
+				} else {
+					rte_mempool_put_bulk(free[0]->pool,
+							     (void *)free,
+							     nb_free);
+					free[0] = m;
+					nb_free = 1;
+				}
+			}
+		}
+		rte_mempool_put_bulk(free[0]->pool, (void **)free,

nb_free);

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +94 -0
+	} else {
+		for (i = 1; i < n; i++) {
+			m = rte_pktmbuf_prefree_seg(txep[i].mbuf);
+			if (m)
+				rte_mempool_put(m->pool, m);
+		}
+	}
+
+done:
+	/* buffers were freed, update counters */
+	txq->nb_free = (uint16_t)(txq->nb_free + txq->rs_thresh);
+	txq->next_dd = (uint16_t)(txq->next_dd + txq->rs_thresh);
+	if (txq->next_dd >= txq->nb_tx_desc)
+		txq->next_dd = (uint16_t)(txq->rs_thresh - 1);
+
+	return txq->rs_thresh;
+}
+
+static __rte_always_inline void
+tx_backlog_entry_avx512(struct idpf_tx_vec_entry *txep,
+			struct rte_mbuf **tx_pkts, uint16_t nb_pkts) {
+	int i;
+
+	for (i = 0; i < (int)nb_pkts; ++i)
+		txep[i].mbuf = tx_pkts[i];
+}
+
+static __rte_always_inline void
+idpf_vtx1(volatile struct iecm_base_tx_desc *txdp,
+	  struct rte_mbuf *pkt, uint64_t flags) {
+	uint64_t high_qw =
+		(IECM_TX_DESC_DTYPE_DATA |
+		 ((uint64_t)flags  << IECM_TXD_QW1_CMD_S) |
+		 ((uint64_t)pkt->data_len << IECM_TXD_QW1_TX_BUF_SZ_S));
+
+	__m128i descriptor = _mm_set_epi64x(high_qw,
+					    pkt->buf_iova + pkt->data_off);
+	_mm_storeu_si128((__m128i *)txdp, descriptor); }
+
+#define IDPF_TX_LEN_MASK 0xAA
+#define IDPF_TX_OFF_MASK 0x55
+static __rte_always_inline void
+idpf_vtx(volatile struct iecm_base_tx_desc *txdp,
+	 struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags) {
+	const uint64_t hi_qw_tmpl = (IECM_TX_DESC_DTYPE_DATA  |
+			((uint64_t)flags  << IECM_TXD_QW1_CMD_S));
+
+	/* if unaligned on 32-bit boundary, do one to align */
+	if (((uintptr_t)txdp & 0x1F) != 0 && nb_pkts != 0) {
+		idpf_vtx1(txdp, *pkt, flags);
+		nb_pkts--, txdp++, pkt++;
+	}
+
+	/* do 4 at a time while possible, in bursts */
+	for (; nb_pkts > 3; txdp += 4, pkt += 4, nb_pkts -= 4) {
+		uint64_t hi_qw3 =
+			hi_qw_tmpl |
+			((uint64_t)pkt[3]->data_len <<
+			 IECM_TXD_QW1_TX_BUF_SZ_S);
+		uint64_t hi_qw2 =
+			hi_qw_tmpl |
+			((uint64_t)pkt[2]->data_len <<
+			 IECM_TXD_QW1_TX_BUF_SZ_S);
+		uint64_t hi_qw1 =
+			hi_qw_tmpl |
+			((uint64_t)pkt[1]->data_len <<
+			 IECM_TXD_QW1_TX_BUF_SZ_S);
+		uint64_t hi_qw0 =
+			hi_qw_tmpl |
+			((uint64_t)pkt[0]->data_len <<
+			 IECM_TXD_QW1_TX_BUF_SZ_S);
+
+		__m512i desc0_3 =
+			_mm512_set_epi64
+				(hi_qw3,
+				 pkt[3]->buf_iova + pkt[3]->data_off,
+				 hi_qw2,
+				 pkt[2]->buf_iova + pkt[2]->data_off,
+				 hi_qw1,
+				 pkt[1]->buf_iova + pkt[1]->data_off,
+				 hi_qw0,
+				 pkt[0]->buf_iova + pkt[0]->data_off);
+		_mm512_storeu_si512((void *)txdp, desc0_3);
+	}
+
+	/* do any last ones */
+	while (nb_pkts) {
+		idpf_vtx1(txdp, *pkt, flags);
+		txdp++, pkt++, nb_pkts--;
+	}
+}
+
+static __rte_always_inline uint16_t
+idpf_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf

**tx_pkts,

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +56 -0
+				 uint16_t nb_pkts)
+{
+	struct idpf_tx_queue *txq = (struct idpf_tx_queue *)tx_queue;
+	volatile struct iecm_base_tx_desc *txdp;
+	struct idpf_tx_vec_entry *txep;
+	uint16_t n, nb_commit, tx_id;
+	/* bit2 is reserved and must be set to 1 according to Spec */
+	uint64_t flags = IECM_TX_DESC_CMD_EOP | 0x04;
+	uint64_t rs = IECM_TX_DESC_CMD_RS | flags;
+
+	/* cross rx_thresh boundary is not allowed */
+	nb_pkts = RTE_MIN(nb_pkts, txq->rs_thresh);
+
+	if (txq->nb_free < txq->free_thresh)
+		idpf_tx_free_bufs_avx512(txq);
+
+	nb_commit = nb_pkts = (uint16_t)RTE_MIN(txq->nb_free, nb_pkts);
+	if (unlikely(nb_pkts == 0))
+		return 0;
+
+	tx_id = txq->tx_tail;
+	txdp = &txq->tx_ring[tx_id];
+	txep = (void *)txq->sw_ring;
+	txep += tx_id;
+
+	txq->nb_free = (uint16_t)(txq->nb_free - nb_pkts);
+
+	n = (uint16_t)(txq->nb_tx_desc - tx_id);
+	if (nb_commit >= n) {
+		tx_backlog_entry_avx512(txep, tx_pkts, n);
+
+		idpf_vtx(txdp, tx_pkts, n - 1, flags);
+		tx_pkts += (n - 1);
+		txdp += (n - 1);
+
+		idpf_vtx1(txdp, *tx_pkts++, rs);
+
+		nb_commit = (uint16_t)(nb_commit - n);
+
+		tx_id = 0;
+		txq->next_rs = (uint16_t)(txq->rs_thresh - 1);
+
+		/* avoid reach the end of ring */
+		txdp = &txq->tx_ring[tx_id];
+		txep = (void *)txq->sw_ring;
+		txep += tx_id;
+	}
+
+	tx_backlog_entry_avx512(txep, tx_pkts, nb_commit);
+
+	idpf_vtx(txdp, tx_pkts, nb_commit, flags);
+
+	tx_id = (uint16_t)(tx_id + nb_commit);
+	if (tx_id > txq->next_rs) {
+		txq->tx_ring[txq->next_rs].qw1 |=
+
	rte_cpu_to_le_64(((uint64_t)IECM_TX_DESC_CMD_RS) <<
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +14 -0
+					 IECM_TXD_QW1_CMD_S);
+		txq->next_rs =
+			(uint16_t)(txq->next_rs + txq->rs_thresh);
+	}
+
+	txq->tx_tail = tx_id;
+
+	IECM_PCI_REG_WRITE(txq->qtx_tail, txq->tx_tail);
+
+	return nb_pkts;
+}
+
+static __rte_always_inline uint16_t
+idpf_xmit_pkts_vec_avx512_cmn(void *tx_queue, struct rte_mbuf

**tx_pkts,

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +10 -0
+			      uint16_t nb_pkts)
+{
+	uint16_t nb_tx = 0;
+	struct idpf_tx_queue *txq = (struct idpf_tx_queue *)tx_queue;
+
+	while (nb_pkts) {
+		uint16_t ret, num;
+
+		num = (uint16_t)RTE_MIN(nb_pkts, txq->rs_thresh);
+		ret = idpf_xmit_fixed_burst_vec_avx512(tx_queue,

&tx_pkts[nb_tx],

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +15 -0
+						       num);
+		nb_tx += ret;
+		nb_pkts -= ret;
+		if (ret < num)
+			break;
+	}
+
+	return nb_tx;
+}
+
+uint16_t
+idpf_singleq_xmit_pkts_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
+			     uint16_t nb_pkts)
+{
+	return idpf_xmit_pkts_vec_avx512_cmn(tx_queue, tx_pkts,

nb_pkts); }

drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +29 -0
+
+static inline void
+idpf_singleq_tx_release_mbufs_avx512(struct idpf_tx_queue *txq) {
+	unsigned int i;
+	const uint16_t max_desc = (uint16_t)(txq->nb_tx_desc - 1);
+	struct idpf_tx_vec_entry *swr = (void *)txq->sw_ring;
+
+	if (!txq->sw_ring || txq->nb_free == max_desc)
+		return;
+
+	i = txq->next_dd - txq->rs_thresh + 1;
+	if (txq->tx_tail < i) {
+		for (; i < txq->nb_tx_desc; i++) {
+			rte_pktmbuf_free_seg(swr[i].mbuf);
+			swr[i].mbuf = NULL;
+		}
+		i = 0;
+	}
+}
+
+static const struct idpf_txq_ops avx512_singleq_tx_vec_ops = {
+	.release_mbufs = idpf_singleq_tx_release_mbufs_avx512,
+};
+
+int __rte_cold
+idpf_singleq_tx_vec_setup_avx512(struct idpf_tx_queue *txq) {
+	txq->ops = &avx512_singleq_tx_vec_ops;
+	return 0;
+}
drivers/net/idpf/idpf_rxtx_vec_common.h new file +85 -0
new file mode 100644
index 0000000000..336d4c8b25
@@ -0,0 +1,89 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#ifndef _IDPF_RXTX_VEC_COMMON_H_
+#define _IDPF_RXTX_VEC_COMMON_H_
+#include <stdint.h>
+#include <ethdev_driver.h>
+#include <rte_malloc.h>
+
+#include "idpf_ethdev.h"
+#include "idpf_rxtx.h"
+
+#ifndef __INTEL_COMPILER
+#pragma GCC diagnostic ignored "-Wcast-qual"
+#endif
+
+#define IDPF_VECTOR_PATH		0
+
+static inline int
+idpf_rx_vec_queue_default(struct idpf_rx_queue *rxq) {
+	if (!rxq)
+		return -1;
+
+	if (!rte_is_power_of_2(rxq->nb_rx_desc))
+		return -1;
+
+	if (rxq->rx_free_thresh < IDPF_VPMD_RX_MAX_BURST)
+		return -1;
+
+	if (rxq->nb_rx_desc % rxq->rx_free_thresh)
+		return -1;
+
+	/* Currently, vector path doesn't support timestamp. */
+	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
+		return -1;
+
+	return IDPF_VECTOR_PATH;
+}
+
+static inline int
+idpf_tx_vec_queue_default(struct idpf_tx_queue *txq) {
+	if (!txq)
+		return -1;
+
+	if (txq->rs_thresh < IDPF_VPMD_TX_MAX_BURST ||
+	    (txq->rs_thresh & 3) != 0)
+		return -1;
+
+	return IDPF_VECTOR_PATH;
+}
+
+static inline int
+idpf_rx_vec_dev_check_default(struct rte_eth_dev *dev) {
+	int i;
+	struct idpf_rx_queue *rxq;
+	int ret = 0;
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		rxq = dev->data->rx_queues[i];
+		ret = (idpf_rx_vec_queue_default(rxq));
+		if (ret < 0)
+			return -1;
+	}
+
+	return IDPF_VECTOR_PATH;
+}
+
+static inline int
+idpf_tx_vec_dev_check_default(struct rte_eth_dev *dev) {
+	int i;
+	struct idpf_tx_queue *txq;
+	int ret = 0;
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		txq = dev->data->tx_queues[i];
+		ret = idpf_tx_vec_queue_default(txq);
+		if (ret < 0)
+			return -1;
+	}
+
+	return IDPF_VECTOR_PATH;
+}
+
+#endif /*_IDPF_RXTX_VEC_COMMON_H_*/
drivers/net/idpf/meson.build +13 -1
index 338a39e391..ee4bb94a97 100644
@@ -16,4 +16,33 @@ sources = files(
 	'idpf_vchnl.c',
 )
 
-includes += include_directories('base') \ No newline at end of file
+if arch_subdir == 'x86'
+	idpf_avx512_cpu_support = (
+		cc.get_define('__AVX512F__', args: machine_args) != '' and
+		cc.get_define('__AVX512BW__', args: machine_args) != ''
+	)
+
+	idpf_avx512_cc_support = (
+		not machine_args.contains('-mno-avx512f') and
+		cc.has_argument('-mavx512f') and
+		cc.has_argument('-mavx512bw')
+	)
+
+	if idpf_avx512_cpu_support == true or idpf_avx512_cc_support ==

true

drivers/net/idpf/meson.build +12 -0
+		cflags += ['-DCC_AVX512_SUPPORT']
+		avx512_args = [cflags, '-mavx512f', '-mavx512bw']
+		if cc.has_argument('-march=skylake-avx512')
+			avx512_args += '-march=skylake-avx512'
+		endif
+		idpf_avx512_lib = static_library('idpf_avx512_lib',
+			'idpf_rxtx_vec_avx512.c',
+			dependencies: [static_rte_ethdev, static_rte_bus_pci,
+			static_rte_kvargs, static_rte_hash],
+			include_directories: includes,
+			c_args: avx512_args)
+		objs +=

idpf_avx512_lib.extract_objects('idpf_rxtx_vec_avx512.c')

drivers/net/idpf/meson.build sources = files( · line 48

Quoted 5 lines
drivers/net/idpf/meson.build +5 -0
+	endif
+endif
+
+includes += include_directories('base')
+

4 spaces should be used instead of a tab.

Quoted 2 lines

--
2.25.1

#60 lore raw

PATCH v2 14/14 net/idpf: add support for timestamp offload

In reply to Junfeng Guo

Add support for timestamp offload.

---
 drivers/net/idpf/idpf_ethdev.h |  3 ++
 drivers/net/idpf/idpf_rxtx.c   | 79 ++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   | 89 +++++++++++++++++++++++++++++++++-
 3 files changed, 170 insertions(+), 1 deletion(-)
drivers/net/idpf/idpf_ethdev.h +3 -0
index a32d5758ac..968e0e3cbf 100644
@@ -184,6 +184,9 @@ struct idpf_adapter {
 	bool tx_vec_allowed;
 	bool rx_use_avx512;
 	bool tx_use_avx512;
+
+	/* For PTP */
+	uint64_t time_hw;
 };
 
 TAILQ_HEAD(idpf_adapter_list, idpf_adapter);
drivers/net/idpf/idpf_rxtx.c +79 -0

139 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +88 -1

105 lines not on this page · raw message

Signature · 1 line
2.25.1
#61 lore raw

Re: [PATCH v2 14/14] net/idpf: add support for timestamp offload

Quoted 4 lines · Junfeng Guo

Add support for timestamp offload.

[snip]

Quoted 38 lines
drivers/net/idpf/idpf_rxtx.h +38 -0
+/* Helper function to convert a 32b nanoseconds timestamp to 64b. */
+static inline uint64_t
+idpf_tstamp_convert_32b_64b(struct iecm_hw *hw, struct idpf_adapter *ad,
+			    uint32_t flag, uint32_t in_timestamp)
+{
+/* TODO: timestamp for ACC */
+#ifdef RTE_ARCH_ARM64
+	return 0;
+#endif /* RTE_ARCH_ARM64 */
+
+#ifdef RTE_ARCH_X86_64
+	const uint64_t mask = 0xFFFFFFFF;
+	uint32_t hi, lo, lo2, delta;
+	uint64_t ns;
+
+	if (flag) {
+		IECM_WRITE_REG(hw, GLTSYN_CMD_SYNC_0_0, PF_GLTSYN_CMD_SYNC_SHTIME_EN_M);
+		IECM_WRITE_REG(hw, GLTSYN_CMD_SYNC_0_0, PF_GLTSYN_CMD_SYNC_EXEC_CMD_M |
+			       PF_GLTSYN_CMD_SYNC_SHTIME_EN_M);
+		lo = IECM_READ_REG(hw, PF_GLTSYN_SHTIME_L_0);
+		hi = IECM_READ_REG(hw, PF_GLTSYN_SHTIME_H_0);
+		/*
+		 * On typical system, the delta between lo and lo2 is ~1000ns,
+		 * so 10000 seems a large-enough but not overly-big guard band.
+		 */
+		if (lo > (UINT32_MAX - IDPF_TIMESYNC_REG_WRAP_GUARD_BAND))
+			lo2 = IECM_READ_REG(hw, PF_GLTSYN_SHTIME_L_0);
+		else
+			lo2 = lo;
+
+		if (lo2 < lo) {
+			lo = IECM_READ_REG(hw, PF_GLTSYN_SHTIME_L_0);
+			hi = IECM_READ_REG(hw, PF_GLTSYN_SHTIME_H_0);
+		}
+
+		ad->time_hw = ((uint64_t)hi << 32) | lo;
+	}
+

drivers/net/idpf/idpf_rxtx.h void idpf_set_tx_function(struct rte_eth_dev *dev); · line 319

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.h +10 -0
+	delta = (in_timestamp - (uint32_t)(ad->time_hw & mask));
+	if (delta > (mask / 2)) {
+		delta = ((uint32_t)(ad->time_hw & mask) - in_timestamp);
+		ns = ad->time_hw - delta;
+	} else {
+		ns = ad->time_hw + delta;
+	}
+
+	return ns;
+#endif /* RTE_ARCH_X86_64 */

Conditional compilation is rather strange above.
Will it break build on some architectures?
Non-x86-64 and non-ARM64.

Quoted 3 lines
drivers/net/idpf/idpf_rxtx.h +2 -0
+}
 
+#endif /* _IDPF_RXTX_H_ */
#62 lore raw

RE: [PATCH v2 14/14] net/idpf: add support for timestamp offload

Quoted 74 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 3, 2022 22:22
To: Guo, Junfeng <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>; Qiao, Wenjing <[email protected]>
Subject: Re: [PATCH v2 14/14] net/idpf: add support for timestamp offload

Quoted 4 lines · Junfeng Guo

Add support for timestamp offload.

[snip]

drivers/net/idpf/idpf_rxtx.h void idpf_set_tx_function(struct rte_eth_dev *dev);

Quoted 3 lines
drivers/net/idpf/idpf_rxtx.h +3 -0
+/* Helper function to convert a 32b nanoseconds timestamp to 64b. */
+static inline uint64_t
+idpf_tstamp_convert_32b_64b(struct iecm_hw *hw, struct

idpf_adapter *ad,

Quoted 4 lines
drivers/net/idpf/idpf_rxtx.h +4 -0
+			    uint32_t flag, uint32_t in_timestamp)
+{
+/* TODO: timestamp for ACC */
+#ifdef RTE_ARCH_ARM64

drivers/net/idpf/idpf_rxtx.h void idpf_set_tx_function(struct rte_eth_dev *dev);

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.h +10 -0
+	return 0;
+#endif /* RTE_ARCH_ARM64 */
+
+#ifdef RTE_ARCH_X86_64
+	const uint64_t mask = 0xFFFFFFFF;
+	uint32_t hi, lo, lo2, delta;
+	uint64_t ns;
+
+	if (flag) {
+		IECM_WRITE_REG(hw, GLTSYN_CMD_SYNC_0_0,

PF_GLTSYN_CMD_SYNC_SHTIME_EN_M);

Review

Quoted 1 line
(quoted diff) +1 -0
+		IECM_WRITE_REG(hw, GLTSYN_CMD_SYNC_0_0,

PF_GLTSYN_CMD_SYNC_EXEC_CMD_M |

drivers/net/idpf/idpf_rxtx.h void idpf_set_tx_function(struct rte_eth_dev *dev);

Quoted 5 lines
drivers/net/idpf/idpf_rxtx.h +5 -0
+			       PF_GLTSYN_CMD_SYNC_SHTIME_EN_M);
+		lo = IECM_READ_REG(hw, PF_GLTSYN_SHTIME_L_0);
+		hi = IECM_READ_REG(hw, PF_GLTSYN_SHTIME_H_0);
+		/*
+		 * On typical system, the delta between lo and lo2 is

~1000ns,

Review

Quoted 1 line
(quoted diff) +1 -0
+		 * so 10000 seems a large-enough but not overly-big

guard band.

Review

Quoted 2 lines
(quoted diff) +2 -0
+		 */
+		if (lo > (UINT32_MAX -

IDPF_TIMESYNC_REG_WRAP_GUARD_BAND))

Review

Quoted 1 line
(quoted diff) +1 -0
+			lo2 = IECM_READ_REG(hw,

PF_GLTSYN_SHTIME_L_0);

drivers/net/idpf/idpf_rxtx.h void idpf_set_tx_function(struct rte_eth_dev *dev);

Quoted 5 lines
drivers/net/idpf/idpf_rxtx.h +5 -0
+		else
+			lo2 = lo;
+
+		if (lo2 < lo) {
+			lo = IECM_READ_REG(hw,

PF_GLTSYN_SHTIME_L_0);

Review

Quoted 1 line
(quoted diff) +1 -0
+			hi = IECM_READ_REG(hw,

PF_GLTSYN_SHTIME_H_0);

Quoted 11 lines
drivers/net/idpf/idpf_rxtx.h +11 -0
+		}
+
+		ad->time_hw = ((uint64_t)hi << 32) | lo;
+	}
+
+	delta = (in_timestamp - (uint32_t)(ad->time_hw & mask));
+	if (delta > (mask / 2)) {
+		delta = ((uint32_t)(ad->time_hw & mask) - in_timestamp);
+		ns = ad->time_hw - delta;
+	} else {
+		ns = ad->time_hw + delta;
Quoted 8 lines

drivers/net/idpf/idpf_rxtx.h void idpf_set_tx_function(struct rte_eth_dev *dev); · line 319

Quoted 4 lines
drivers/net/idpf/idpf_rxtx.h +4 -0
+	}
+
+	return ns;
+#endif /* RTE_ARCH_X86_64 */

Conditional compilation is rather strange above. Will it break build on some architectures? Non-x86-64 and non-ARM64.

Actually the timestamp feature currently is only supported on x86_64 architecture. On the rest conditions will just return 0. We will update this part in the coming version. Thanks!

Quoted 4 lines
Quoted 4 lines
drivers/net/idpf/idpf_rxtx.h +2 -0
+}
 
+#endif /* _IDPF_RXTX_H_ */
#63 lore raw

RE: [PATCH v2 14/14] net/idpf: add support for timestamp offload

In reply to Junfeng Guo
Quoted 75 lines

-----Original Message-----
From: Junfeng Guo <[email protected]>
Sent: Monday, September 5, 2022 6:58 PM
To: Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>; Guo, Junfeng <[email protected]>; Qiao, Wenjing <[email protected]>
Subject: [PATCH v2 14/14] net/idpf: add support for timestamp offload

Add support for timestamp offload.

---
 drivers/net/idpf/idpf_ethdev.h |  3 ++
 drivers/net/idpf/idpf_rxtx.c   | 79 ++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   | 89 +++++++++++++++++++++++++++++++++-
 3 files changed, 170 insertions(+), 1 deletion(-)
drivers/net/idpf/idpf_ethdev.h +3 -0
index a32d5758ac..968e0e3cbf 100644
@@ -184,6 +184,9 @@ struct idpf_adapter {
 	bool tx_vec_allowed;
 	bool rx_use_avx512;
 	bool tx_use_avx512;
+
+	/* For PTP */
+	uint64_t time_hw;
 };
 
 TAILQ_HEAD(idpf_adapter_list, idpf_adapter); diff --git

a/drivers/net/idpf/idpf_rxtx.c b/drivers/net/idpf/idpf_rxtx.c index e31d202646..b0037eca08 100644

drivers/net/idpf/idpf_rxtx.c +2 -0
@@ -10,6 +10,8 @@
 #include "idpf_rxtx.h"
 #include "idpf_rxtx_vec_common.h"
 
+static int idpf_timestamp_dynfield_offset = -1;
+
 const uint32_t *
 idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)
 { @@ -965,6 +967,24 @@ idpf_tx_queue_setup(struct rte_eth_dev *dev,

uint16_t queue_idx,

drivers/net/idpf/idpf_rxtx.c +11 -0
 						 socket_id, tx_conf);
 }
 
+static int
+idpf_register_ts_mbuf(struct idpf_rx_queue *rxq) {
+	int err;
+	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
+		/* Register mbuf field and flag for Rx timestamp */
+		err = rte_mbuf_dyn_rx_timestamp_register(
+				&idpf_timestamp_dynfield_offset,
+				&idpf_timestamp_dynflag);
+		if (err) {
+			PMD_DRV_LOG(ERR,
+				"Cannot register mbuf field/flag for

timestamp");

drivers/net/idpf/idpf_rxtx.c +7 -0
+			return -EINVAL;
+		}
+	}
+	return 0;
+}
+
 static int
 idpf_alloc_single_rxq_mbufs(struct idpf_rx_queue *rxq)  { @@ -992,6
+1012,10 @@ idpf_alloc_single_rxq_mbufs(struct idpf_rx_queue *rxq)
 		rxd = &((volatile struct virtchnl2_singleq_rx_buf_desc *)(rxq-
Quoted 1 line

rx_ring))[i];

drivers/net/idpf/idpf_rxtx.c idpf_alloc_single_rxq_mbufs(struct idpf_rx_queue *rxq) · line 1018

Quoted 6 lines
drivers/net/idpf/idpf_rxtx.c +4 -0
 		rxd->pkt_addr = dma_addr;
 		rxd->hdr_addr = 0;
+#ifndef RTE_LIBRTE_IDPF_16BYTE_RX_DESC
+		rxd->rsvd1 = 0;
+		rxd->rsvd2 = 0;
+#endif

It seems that IDPF does not add any configuration related to descriptor length. The descriptor length is always the default 32B, so the conditional compilation is not necessary.

Quoted 21 lines
drivers/net/idpf/idpf_rxtx.c +7 -0
 		rxq->sw_ring[i] = mbuf;
 	}
@@ -1057,6 +1081,13 @@ idpf_rx_queue_init(struct rte_eth_dev *dev,
 uint16_t rx_queue_id)
 		return -EINVAL;
 	}
 
+	err = idpf_register_ts_mbuf(rxq);
+	if (err) {
+		PMD_DRV_LOG(ERR, "fail to regidter timestamp mbuf %u",
+					rx_queue_id);
+		return -EIO;
+	}
+
 	if (!rxq->bufq1) {
 		/* Single queue */

err = idpf_alloc_single_rxq_mbufs(rxq); @@ -1441,6
+1472,12 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,

drivers/net/idpf/idpf_rxtx.c idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, · line 1482

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c +5 -0
 	nb_rx = 0;
 	rxq = (struct idpf_rx_queue *)rx_queue;
 
+#ifndef RTE_LIBRTE_IDPF_16BYTE_RX_DESC
+	uint64_t ts_ns;
+	struct iecm_hw *hw = &rxq->adapter->hw;
+	struct idpf_adapter *ad = rxq->adapter; #endif
+
 	if (unlikely(!rxq) || unlikely(!rxq->q_started))
 		return nb_rx;

Ditto.

drivers/net/idpf/idpf_rxtx.c idpf_splitq_recv_pkts(void *rx_queue, struct · line 1496

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c +5 -0
@@ -1451,6 +1488,11 @@ idpf_splitq_recv_pkts(void *rx_queue, struct
 rte_mbuf **rx_pkts,
 	       (volatile struct virtchnl2_rx_flex_desc_adv_nic_3 *)rxq->rx_ring;
 	ptype_tbl = rxq->adapter->ptype_tbl;
 
+#ifndef RTE_LIBRTE_IDPF_16BYTE_RX_DESC
+	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
+		rxq->hw_register_set = 1;
+#endif
+

Ditto.

Quoted 13 lines
drivers/net/idpf/idpf_rxtx.c +5 -0
 	while (nb_rx < nb_pkts) {
 		rx_desc = &rx_desc_ring[rx_id];
@@ -1507,6 +1549,19 @@ idpf_splitq_recv_pkts(void *rx_queue, struct
 rte_mbuf **rx_pkts,
 		status_err0_qw1 = rx_desc->status_err0_qw1;
 		pkt_flags = idpf_splitq_rx_csum_offload(status_err0_qw1);
 		pkt_flags |= idpf_splitq_rx_rss_offload(rxm, rx_desc);
+#ifndef RTE_LIBRTE_IDPF_16BYTE_RX_DESC
+		if (idpf_timestamp_dynflag > 0) {
+			/* timestamp */
+			ts_ns = idpf_tstamp_convert_32b_64b(hw, ad,
+							    rxq-

drivers/net/idpf/idpf_rxtx.c idpf_splitq_recv_pkts(void *rx_queue, struct · line 1567

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c +8 -0
 >hw_register_set,
+
 rte_le_to_cpu_32(rx_desc->ts_high));
+			rxq->hw_register_set = 0;
+			*RTE_MBUF_DYNFIELD(rxm,
+					   idpf_timestamp_dynfield_offset,
+					   rte_mbuf_timestamp_t *) = ts_ns;
+			rxm->ol_flags |= idpf_timestamp_dynflag;
+		}
+#endif

Ditto.

drivers/net/idpf/idpf_rxtx.c idpf_singleq_recv_pkts(void *rx_queue, struct · line 1839

Quoted 11 lines
drivers/net/idpf/idpf_rxtx.c +3 -0
 		rxm->ol_flags |= pkt_flags;
 
 		rx_pkts[nb_rx++] = rxm;
@@ -1778,6 +1833,10 @@ idpf_singleq_recv_pkts(void *rx_queue, struct
 rte_mbuf **rx_pkts,
 	nb_hold = 0;
 	rxq = rx_queue;
 
+#ifndef RTE_LIBRTE_IDPF_16BYTE_RX_DESC
+	uint64_t ts_ns;
+#endif

Ditto.

Quoted 5 lines
drivers/net/idpf/idpf_rxtx.c +1 -0
+
 	if (unlikely(!rxq) || unlikely(!rxq->q_started))
 		return nb_rx;

drivers/net/idpf/idpf_rxtx.c idpf_singleq_recv_pkts(void *rx_queue, struct · line 1853

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c +6 -0
@@ -1785,6 +1844,13 @@ idpf_singleq_recv_pkts(void *rx_queue, struct
 rte_mbuf **rx_pkts,
 	rx_ring = rxq->rx_ring;
 	ptype_tbl = rxq->adapter->ptype_tbl;
 
+#ifndef RTE_LIBRTE_IDPF_16BYTE_RX_DESC
+	struct iecm_hw *hw = &rxq->adapter->hw;
+	struct idpf_adapter *ad = rxq->adapter;
+	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
+		rxq->hw_register_set = 1;
+#endif

Ditto.

Quoted 20 lines
drivers/net/idpf/idpf_rxtx.c +1 -0
+
 	while (nb_rx < nb_pkts) {
 		rxdp = &rx_ring[rx_id];

rx_status0 = rte_le_to_cpu_16(rxdp-

Quoted 1 line

flex_nic_wb.status_error0);

drivers/net/idpf/idpf_rxtx.c +0 -0
@@ -1841,6 +1907,19 @@ idpf_singleq_recv_pkts(void *rx_queue, struct
 rte_mbuf **rx_pkts,
 		rxm->packet_type =
 
 	ptype_tbl[(uint8_t)(rte_cpu_to_le_16(rxd.flex_nic_wb.ptype_flex_fla

gs0) &

drivers/net/idpf/idpf_rxtx.c +5 -0
 				VIRTCHNL2_RX_FLEX_DESC_PTYPE_M)];
+#ifndef RTE_LIBRTE_IDPF_16BYTE_RX_DESC
+		if (idpf_timestamp_dynflag > 0) {
+			/* timestamp */
+			ts_ns = idpf_tstamp_convert_32b_64b(hw, ad,
+							    rxq-
Quoted 1 line

hw_register_set,

+ rte_le_to_cpu_32(rxdp->flex_nic_wb.flex_ts.ts_high));

drivers/net/idpf/idpf_rxtx.c idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, · line 1564

Quoted 7 lines
drivers/net/idpf/idpf_rxtx.c +7 -0
+			rxq->hw_register_set = 0;
+			*RTE_MBUF_DYNFIELD(rxm,
+					   idpf_timestamp_dynfield_offset,
+					   rte_mbuf_timestamp_t *) = ts_ns;
+			rxm->ol_flags |= idpf_timestamp_dynflag;
+		}
+#endif

Ditto.

Quoted 123 lines
drivers/net/idpf/idpf_rxtx.c +0 -0
 		rx_pkts[nb_rx++] = rxm;
 	}
 	rxq->rx_tail = rx_id;
drivers/net/idpf/idpf_rxtx.h index renamed from drivers/net/idpf/idpf_rxtx.h +0 -0

decd0a98c2..6fcb441143 100644

drivers/net/idpf/idpf_rxtx.h +37 -0
@@ -15,6 +15,41 @@
 #include "base/virtchnl2_lan_desc.h"
 #include "idpf_ethdev.h"
 
+/* MTS */
+#define GLTSYN_CMD_SYNC_0_0	(PF_TIMESYNC_BASE + 0x0)
+#define PF_GLTSYN_SHTIME_0_0	(PF_TIMESYNC_BASE + 0x4)
+#define PF_GLTSYN_SHTIME_L_0	(PF_TIMESYNC_BASE + 0x8)
+#define PF_GLTSYN_SHTIME_H_0	(PF_TIMESYNC_BASE + 0xC)
+#define GLTSYN_ART_L_0		(PF_TIMESYNC_BASE + 0x10)
+#define GLTSYN_ART_H_0		(PF_TIMESYNC_BASE + 0x14)
+#define PF_GLTSYN_SHTIME_0_1	(PF_TIMESYNC_BASE + 0x24)
+#define PF_GLTSYN_SHTIME_L_1	(PF_TIMESYNC_BASE + 0x28)
+#define PF_GLTSYN_SHTIME_H_1	(PF_TIMESYNC_BASE + 0x2C)
+#define PF_GLTSYN_SHTIME_0_2	(PF_TIMESYNC_BASE + 0x44)
+#define PF_GLTSYN_SHTIME_L_2	(PF_TIMESYNC_BASE + 0x48)
+#define PF_GLTSYN_SHTIME_H_2	(PF_TIMESYNC_BASE + 0x4C)
+#define PF_GLTSYN_SHTIME_0_3	(PF_TIMESYNC_BASE + 0x64)
+#define PF_GLTSYN_SHTIME_L_3	(PF_TIMESYNC_BASE + 0x68)
+#define PF_GLTSYN_SHTIME_H_3	(PF_TIMESYNC_BASE + 0x6C)
+
+#define PF_TIMESYNC_BAR4_BASE	0x0E400000
+#define GLTSYN_ENA		(PF_TIMESYNC_BAR4_BASE + 0x90)
+#define GLTSYN_CMD		(PF_TIMESYNC_BAR4_BASE + 0x94)
+#define GLTSYC_TIME_L		(PF_TIMESYNC_BAR4_BASE + 0x104)
+#define GLTSYC_TIME_H		(PF_TIMESYNC_BAR4_BASE + 0x108)
+
+#define GLTSYN_CMD_SYNC_0_4	(PF_TIMESYNC_BAR4_BASE + 0x110)
+#define PF_GLTSYN_SHTIME_L_4	(PF_TIMESYNC_BAR4_BASE + 0x118)
+#define PF_GLTSYN_SHTIME_H_4	(PF_TIMESYNC_BAR4_BASE + 0x11C)
+#define GLTSYN_INCVAL_L		(PF_TIMESYNC_BAR4_BASE + 0x150)
+#define GLTSYN_INCVAL_H		(PF_TIMESYNC_BAR4_BASE + 0x154)
+#define GLTSYN_SHADJ_L		(PF_TIMESYNC_BAR4_BASE + 0x158)
+#define GLTSYN_SHADJ_H		(PF_TIMESYNC_BAR4_BASE + 0x15C)
+
+#define GLTSYN_CMD_SYNC_0_5	(PF_TIMESYNC_BAR4_BASE + 0x130)
+#define PF_GLTSYN_SHTIME_L_5	(PF_TIMESYNC_BAR4_BASE + 0x138)
+#define PF_GLTSYN_SHTIME_H_5	(PF_TIMESYNC_BAR4_BASE + 0x13C)
+
 /* In QLEN must be whole number of 32 descriptors. */
 #define IDPF_ALIGN_RING_DESC	32
 #define IDPF_MIN_RING_DESC	32
@@ -66,6 +101,8 @@
 	(sizeof(struct virtchnl2_ptype) + \
 	(((p)->proto_id_count ? ((p)->proto_id_count - 1) : 0) * sizeof((p)-
 >proto_id[0])))
 
+extern uint64_t idpf_timestamp_dynflag;
+
 struct idpf_rx_queue {
 	struct idpf_adapter *adapter;	/* the adapter this queue belongs to

*/
struct rte_mempool *mp; /* mbuf pool to populate Rx
ring */

drivers/net/idpf/idpf_rxtx.h +18 -1
@@ -231,5 +268,55 @@ void idpf_set_tx_function(struct rte_eth_dev *dev);
 
 const uint32_t *idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
-#endif /* _IDPF_RXTX_H_ */
+#define IDPF_TIMESYNC_REG_WRAP_GUARD_BAND  10000
+/* Helper function to convert a 32b nanoseconds timestamp to 64b. */
+static inline uint64_t idpf_tstamp_convert_32b_64b(struct iecm_hw *hw,
+struct idpf_adapter *ad,
+			    uint32_t flag, uint32_t in_timestamp) {
+/* TODO: timestamp for ACC */
+#ifdef RTE_ARCH_ARM64
+	return 0;
+#endif /* RTE_ARCH_ARM64 */
+
+#ifdef RTE_ARCH_X86_64
+	const uint64_t mask = 0xFFFFFFFF;
+	uint32_t hi, lo, lo2, delta;
+	uint64_t ns;
+
+	if (flag) {
+		IECM_WRITE_REG(hw, GLTSYN_CMD_SYNC_0_0,
 PF_GLTSYN_CMD_SYNC_SHTIME_EN_M);
+		IECM_WRITE_REG(hw, GLTSYN_CMD_SYNC_0_0,

PF_GLTSYN_CMD_SYNC_EXEC_CMD_M |

drivers/net/idpf/idpf_rxtx.h +6 -0
+			       PF_GLTSYN_CMD_SYNC_SHTIME_EN_M);
+		lo = IECM_READ_REG(hw, PF_GLTSYN_SHTIME_L_0);
+		hi = IECM_READ_REG(hw, PF_GLTSYN_SHTIME_H_0);
+		/*
+		 * On typical system, the delta between lo and lo2 is ~1000ns,
+		 * so 10000 seems a large-enough but not overly-big guard

band.

drivers/net/idpf/idpf_rxtx.h +2 -0
+		 */
+		if (lo > (UINT32_MAX -

IDPF_TIMESYNC_REG_WRAP_GUARD_BAND))

drivers/net/idpf/idpf_rxtx.h +24 -1
+			lo2 = IECM_READ_REG(hw, PF_GLTSYN_SHTIME_L_0);
+		else
+			lo2 = lo;
+
+		if (lo2 < lo) {
+			lo = IECM_READ_REG(hw, PF_GLTSYN_SHTIME_L_0);
+			hi = IECM_READ_REG(hw, PF_GLTSYN_SHTIME_H_0);
+		}
+
+		ad->time_hw = ((uint64_t)hi << 32) | lo;
+	}
+
+	delta = (in_timestamp - (uint32_t)(ad->time_hw & mask));
+	if (delta > (mask / 2)) {
+		delta = ((uint32_t)(ad->time_hw & mask) - in_timestamp);
+		ns = ad->time_hw - delta;
+	} else {
+		ns = ad->time_hw + delta;
+	}
+
+	return ns;
+#endif /* RTE_ARCH_X86_64 */
+}
 
+#endif /* _IDPF_RXTX_H_ */
--

2.25.1

#64 lore raw
In reply to Junfeng Guo
Quoted 5 lines · Junfeng Guo

This patchset introduced the idpf (Infrastructure Data Path Function) PMD [*EXPERIMENTAL*] in DPDK for Intel Device ID of 0x1452.

v2:
fixed some coding style issues and did some refactors.

The patch series should:
- add entry in MAINTAINERS
- add driver documentation to doc/guides/nics/idpf.rst
- advertise the driver in release notes
- when features are added it should be added to
doc/guides/nics/features/idpf.ini

#65 lore raw
Quoted 7 lines · Andrew Rybchenko
Quoted 5 lines · Junfeng Guo

This patchset introduced the idpf (Infrastructure Data Path Function) PMD [*EXPERIMENTAL*] in DPDK for Intel Device ID of 0x1452.

v2:
fixed some coding style issues and did some refactors.

Quoted 6 lines

The patch series should:
 - add entry in MAINTAINERS
 - add driver documentation to doc/guides/nics/idpf.rst
 - advertise the driver in release notes
 - when features are added it should be added to
doc/guides/nics/features/idpf.ini

I'd really like to add one more point.
There is a long road for the driver to be accepted since many changes are required, but it is definitely doable.

More important to get replies on generic questions. What is it? What is the HW? Is it released? Where I can read about it?

#66 lore raw
Quoted 11 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 3, 2022 22:36
To: Guo, Junfeng <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>
Subject: Re: [PATCH v2 00/14] add support for idpf PMD in DPDK

Quoted 14 lines
Quoted 13 lines · Andrew Rybchenko
Quoted 5 lines · Junfeng Guo

This patchset introduced the idpf (Infrastructure Data Path Function) PMD [*EXPERIMENTAL*] in DPDK for Intel Device ID of 0x1452.

v2:
fixed some coding style issues and did some refactors.

The patch series should:
 - add entry in MAINTAINERS
 - add driver documentation to doc/guides/nics/idpf.rst
 - advertise the driver in release notes
 - when features are added it should be added to
doc/guides/nics/features/idpf.ini

Sure, thanks for your advice!
We will improve the commit order and items in the coming versions.

Currently we are still trying to improve the description related files. Please also help review for the coming versions, thanks a lot!

Quoted 8 lines

I'd really like to add one more point.
There is a long road for the driver to be accepted since many changes are required, but it is definitely doable.

More important to get replies on generic questions. What is it? What is the HW? Is it released? Where I can read about it?

Well, this is the new ``idpf`` net driver for Intel® IPU Ethernet ES2000 Series. The spec has not been released at this point.

Could you help review the coming version patch set, thanks!

#67 lore raw

v3 cover add support for idpf PMD in DPDK

In reply to Junfeng Guo

This patchset introduced the idpf (Infrastructure Data Path Function) PMD in DPDK for Intel® IPU Ethernet ES2000 Series (Device ID: 0x1452).

v2:
fixed some coding style issues and did some refactors.

v3:
fixed some coding style issues and did some refactors.

Junfeng Guo (15):
common/idpf: introduce common library
net/idpf: add support for device initialization net/idpf: add queue setup and release in single queue model net/idpf: add queue setup and release in split queue model net/idpf: add support for queue start and stop net/idpf: add support for device information get net/idpf: add support for packet type get net/idpf: add support for link status update net/idpf: add support for basic Rx/Tx datapath net/idpf: add support for Rx/Tx offloading net/idpf: add support for RSS
net/idpf: add support for MTU configuration net/idpf: add support for write back based on ITR expire net/idpf: add AVX512 data path for single queue model net/idpf: add support for timestamp offload

 MAINTAINERS                                 |    9 +
 doc/guides/nics/features/idpf.ini           |   24 +
 doc/guides/nics/idpf.rst                    |   94 +
 doc/guides/nics/index.rst                   |    1 +
 doc/guides/rel_notes/release_22_11.rst      |    5 +
 drivers/common/idpf/idpf_alloc.h            |   22 +
 drivers/common/idpf/idpf_common.c           |  364 +++
 drivers/common/idpf/idpf_controlq.c         |  691 +++++
 drivers/common/idpf/idpf_controlq.h         |  224 ++
 drivers/common/idpf/idpf_controlq_api.h     |  234 ++
 drivers/common/idpf/idpf_controlq_setup.c   |  179 ++
 drivers/common/idpf/idpf_devids.h           |   18 +
 drivers/common/idpf/idpf_lan_pf_regs.h      |  134 +
 drivers/common/idpf/idpf_lan_txrx.h         |  428 +++
 drivers/common/idpf/idpf_lan_vf_regs.h      |  114 +
 drivers/common/idpf/idpf_osdep.h            |  365 +++
 drivers/common/idpf/idpf_prototype.h        |   45 +
 drivers/common/idpf/idpf_type.h             |  106 +
 drivers/common/idpf/meson.build             |   15 +
 drivers/common/idpf/siov_regs.h             |   41 +
 drivers/common/idpf/version.map             |   12 +
 drivers/common/idpf/virtchnl.h              | 2866 +++++++++++++++++++
 drivers/common/idpf/virtchnl2.h             | 1462 ++++++++++
 drivers/common/idpf/virtchnl2_lan_desc.h    |  606 ++++
 drivers/common/idpf/virtchnl_inline_ipsec.h |  567 ++++
 drivers/common/meson.build                  |    1 +
 drivers/net/idpf/idpf_ethdev.c              | 1244 ++++++++
 drivers/net/idpf/idpf_ethdev.h              |  271 ++
 drivers/net/idpf/idpf_logs.h                |   42 +
 drivers/net/idpf/idpf_rxtx.c                | 2398 ++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h                |  324 +++
 drivers/net/idpf/idpf_rxtx_vec_avx512.c     |  870 ++++++
 drivers/net/idpf/idpf_rxtx_vec_common.h     |  100 +
 drivers/net/idpf/idpf_vchnl.c               | 1443 ++++++++++
 drivers/net/idpf/meson.build                |   45 +
 drivers/net/idpf/version.map                |    3 +
 drivers/net/meson.build                     |    1 +
 37 files changed, 15368 insertions(+)
 create mode 100644 doc/guides/nics/features/idpf.ini
 create mode 100644 doc/guides/nics/idpf.rst
 create mode 100644 drivers/common/idpf/idpf_alloc.h
 create mode 100644 drivers/common/idpf/idpf_common.c
 create mode 100644 drivers/common/idpf/idpf_controlq.c
 create mode 100644 drivers/common/idpf/idpf_controlq.h
 create mode 100644 drivers/common/idpf/idpf_controlq_api.h
 create mode 100644 drivers/common/idpf/idpf_controlq_setup.c
 create mode 100644 drivers/common/idpf/idpf_devids.h
 create mode 100644 drivers/common/idpf/idpf_lan_pf_regs.h
 create mode 100644 drivers/common/idpf/idpf_lan_txrx.h
 create mode 100644 drivers/common/idpf/idpf_lan_vf_regs.h
 create mode 100644 drivers/common/idpf/idpf_osdep.h
 create mode 100644 drivers/common/idpf/idpf_prototype.h
 create mode 100644 drivers/common/idpf/idpf_type.h
 create mode 100644 drivers/common/idpf/meson.build
 create mode 100644 drivers/common/idpf/siov_regs.h
 create mode 100644 drivers/common/idpf/version.map
 create mode 100644 drivers/common/idpf/virtchnl.h
 create mode 100644 drivers/common/idpf/virtchnl2.h
 create mode 100644 drivers/common/idpf/virtchnl2_lan_desc.h
 create mode 100644 drivers/common/idpf/virtchnl_inline_ipsec.h
 create mode 100644 drivers/net/idpf/idpf_ethdev.c
 create mode 100644 drivers/net/idpf/idpf_ethdev.h
 create mode 100644 drivers/net/idpf/idpf_logs.h
 create mode 100644 drivers/net/idpf/idpf_rxtx.c
 create mode 100644 drivers/net/idpf/idpf_rxtx.h
 create mode 100644 drivers/net/idpf/idpf_rxtx_vec_avx512.c
 create mode 100644 drivers/net/idpf/idpf_rxtx_vec_common.h
 create mode 100644 drivers/net/idpf/idpf_vchnl.c
 create mode 100644 drivers/net/idpf/meson.build
 create mode 100644 drivers/net/idpf/version.map
Signature · 1 line
2.34.1
#68 lore raw

PATCH v3 1/15 common/idpf: introduce common library

Introduce common library for IDPF (Infrastructure Data Path Function) PMD.

Also add OS specific implementation about some MACRO definations and small functions which are specific for DPDK.

---
 drivers/common/idpf/idpf_alloc.h            |   22 +
 drivers/common/idpf/idpf_common.c           |  364 +++
 drivers/common/idpf/idpf_controlq.c         |  691 +++++
 drivers/common/idpf/idpf_controlq.h         |  224 ++
 drivers/common/idpf/idpf_controlq_api.h     |  234 ++
 drivers/common/idpf/idpf_controlq_setup.c   |  179 ++
 drivers/common/idpf/idpf_devids.h           |   18 +
 drivers/common/idpf/idpf_lan_pf_regs.h      |  134 +
 drivers/common/idpf/idpf_lan_txrx.h         |  428 +++
 drivers/common/idpf/idpf_lan_vf_regs.h      |  114 +
 drivers/common/idpf/idpf_osdep.h            |  365 +++
 drivers/common/idpf/idpf_prototype.h        |   45 +
 drivers/common/idpf/idpf_type.h             |  106 +
 drivers/common/idpf/meson.build             |   15 +
 drivers/common/idpf/siov_regs.h             |   41 +
 drivers/common/idpf/version.map             |   12 +
 drivers/common/idpf/virtchnl.h              | 2866 +++++++++++++++++++
 drivers/common/idpf/virtchnl2.h             | 1462 ++++++++++
 drivers/common/idpf/virtchnl2_lan_desc.h    |  606 ++++
 drivers/common/idpf/virtchnl_inline_ipsec.h |  567 ++++
 drivers/common/meson.build                  |    1 +
 21 files changed, 8494 insertions(+)
 create mode 100644 drivers/common/idpf/idpf_alloc.h
 create mode 100644 drivers/common/idpf/idpf_common.c
 create mode 100644 drivers/common/idpf/idpf_controlq.c
 create mode 100644 drivers/common/idpf/idpf_controlq.h
 create mode 100644 drivers/common/idpf/idpf_controlq_api.h
 create mode 100644 drivers/common/idpf/idpf_controlq_setup.c
 create mode 100644 drivers/common/idpf/idpf_devids.h
 create mode 100644 drivers/common/idpf/idpf_lan_pf_regs.h
 create mode 100644 drivers/common/idpf/idpf_lan_txrx.h
 create mode 100644 drivers/common/idpf/idpf_lan_vf_regs.h
 create mode 100644 drivers/common/idpf/idpf_osdep.h
 create mode 100644 drivers/common/idpf/idpf_prototype.h
 create mode 100644 drivers/common/idpf/idpf_type.h
 create mode 100644 drivers/common/idpf/meson.build
 create mode 100644 drivers/common/idpf/siov_regs.h
 create mode 100644 drivers/common/idpf/version.map
 create mode 100644 drivers/common/idpf/virtchnl.h
 create mode 100644 drivers/common/idpf/virtchnl2.h
 create mode 100644 drivers/common/idpf/virtchnl2_lan_desc.h
 create mode 100644 drivers/common/idpf/virtchnl_inline_ipsec.h
drivers/common/idpf/idpf_alloc.h new file +22 -0
new file mode 100644
index 0000000000..bc054851b3
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2022 Intel Corporation
+ */
+
+#ifndef _IDPF_ALLOC_H_
+#define _IDPF_ALLOC_H_
+
+/* Memory types */
+enum idpf_memset_type {
+	IDPF_NONDMA_MEM = 0,
+	IDPF_DMA_MEM
+};
+
+/* Memcpy types */
+enum idpf_memcpy_type {
+	IDPF_NONDMA_TO_NONDMA = 0,
+	IDPF_NONDMA_TO_DMA,
+	IDPF_DMA_TO_DMA,
+	IDPF_DMA_TO_NONDMA
+};
+
+#endif /* _IDPF_ALLOC_H_ */
drivers/common/idpf/idpf_common.c new file +364 -0

364 lines not on this page · raw message

drivers/common/idpf/idpf_controlq.c new file +691 -0

691 lines not on this page · raw message

drivers/common/idpf/idpf_controlq.h new file +224 -0

224 lines not on this page · raw message

drivers/common/idpf/idpf_controlq_api.h new file +234 -0

234 lines not on this page · raw message

drivers/common/idpf/idpf_controlq_setup.c new file +179 -0

179 lines not on this page · raw message

drivers/common/idpf/idpf_devids.h new file +18 -0
new file mode 100644
index 0000000000..2a8d8f9295
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2022 Intel Corporation
+ */
+
+#ifndef _IDPF_DEVIDS_H_
+#define _IDPF_DEVIDS_H_
+
+/* Vendor ID */
+#define IDPF_INTEL_VENDOR_ID		0x8086
+
+/* Device IDs */
+#define IDPF_DEV_ID_PF			0x1452
+#define IDPF_DEV_ID_VF			0x1889
+#define IDPF_DEV_ID_CPF			0x1453
+
+
+
+#endif /* _IDPF_DEVIDS_H_ */
drivers/common/idpf/idpf_lan_pf_regs.h new file +134 -0

134 lines not on this page · raw message

drivers/common/idpf/idpf_lan_txrx.h new file +428 -0

428 lines not on this page · raw message

drivers/common/idpf/idpf_lan_vf_regs.h new file +114 -0

114 lines not on this page · raw message

drivers/common/idpf/idpf_osdep.h new file +365 -0

365 lines not on this page · raw message

drivers/common/idpf/idpf_prototype.h new file +45 -0

45 lines not on this page · raw message

drivers/common/idpf/idpf_type.h new file +106 -0

106 lines not on this page · raw message

drivers/common/idpf/meson.build new file +15 -0
new file mode 100644
index 0000000000..3f1f421ef1
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+sources = files(
+        'idpf_common.c',
+        'idpf_controlq.c',
+        'idpf_controlq_setup.c',
+)
+
+cflags += ['-Wno-unused-value']
+cflags += ['-Wno-unused-but-set-variable']
+cflags += ['-Wno-unused-variable']
+cflags += ['-Wno-unused-parameter']
+cflags += ['-Wno-implicit-fallthrough']
+cflags += ['-Wno-strict-aliasing']
drivers/common/idpf/siov_regs.h new file +41 -0

41 lines not on this page · raw message

drivers/common/idpf/version.map new file +12 -0
new file mode 100644
index 0000000000..bfb246c752
@@ -0,0 +1,12 @@
+INTERNAL {
+	global:
+
+	idpf_ctlq_deinit;
+	idpf_ctlq_init;
+	idpf_ctlq_clean_sq;
+	idpf_ctlq_recv;
+	idpf_ctlq_send;
+	idpf_ctlq_post_rx_buffs;
+
+	local: *;
+};
drivers/common/idpf/virtchnl.h new file +2866 -0

8 lines not on this page · raw message

drivers/common/idpf/virtchnl2.h new file +1462 -0

1,462 lines not on this page · raw message

drivers/common/idpf/virtchnl2_lan_desc.h new file +606 -0

606 lines not on this page · raw message

drivers/common/idpf/virtchnl_inline_ipsec.h new file +567 -0

567 lines not on this page · raw message

drivers/common/meson.build +1 -0
index ea261dd70a..b63d899d50 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.34.1

Part of the diff is not shown here. View the raw message.

#69 lore raw

v4 cover add support for idpf PMD in DPDK

This patchset introduced the idpf (Infrastructure Data Path Function) PMD in DPDK for Intel® IPU Ethernet ES2000 Series (Device ID: 0x1452).

v2:
fixed some coding style issues and did some refactors.

v3:
fixed some coding style issues and did some refactors.

v4:
fixed some coding style issues and build errors.

Junfeng Guo (14):
common/idpf: introduce common library
net/idpf: add support for device initialization net/idpf: add queue setup and release in single queue model net/idpf: add queue setup and release in split queue model net/idpf: add support for queue start and stop net/idpf: add support for device information get net/idpf: add support for packet type get net/idpf: add support for basic Rx/Tx datapath net/idpf: add support for Rx/Tx offloading net/idpf: add support for RSS
net/idpf: add support for MTU configuration net/idpf: add support for write back based on ITR expire net/idpf: add AVX512 data path for single queue model net/idpf: add support for timestamp offload

 MAINTAINERS                                 |    9 +
 doc/guides/nics/features/idpf.ini           |   24 +
 doc/guides/nics/idpf.rst                    |   94 +
 doc/guides/nics/index.rst                   |    1 +
 doc/guides/rel_notes/release_22_11.rst      |    5 +
 drivers/common/idpf/idpf_alloc.h            |   22 +
 drivers/common/idpf/idpf_common.c           |  364 +++
 drivers/common/idpf/idpf_controlq.c         |  691 +++++
 drivers/common/idpf/idpf_controlq.h         |  224 ++
 drivers/common/idpf/idpf_controlq_api.h     |  234 ++
 drivers/common/idpf/idpf_controlq_setup.c   |  179 ++
 drivers/common/idpf/idpf_devids.h           |   18 +
 drivers/common/idpf/idpf_lan_pf_regs.h      |  134 +
 drivers/common/idpf/idpf_lan_txrx.h         |  428 +++
 drivers/common/idpf/idpf_lan_vf_regs.h      |  114 +
 drivers/common/idpf/idpf_osdep.h            |  375 +++
 drivers/common/idpf/idpf_prototype.h        |   45 +
 drivers/common/idpf/idpf_type.h             |  106 +
 drivers/common/idpf/meson.build             |   15 +
 drivers/common/idpf/siov_regs.h             |   47 +
 drivers/common/idpf/version.map             |   12 +
 drivers/common/idpf/virtchnl.h              | 2866 +++++++++++++++++++
 drivers/common/idpf/virtchnl2.h             | 1462 ++++++++++
 drivers/common/idpf/virtchnl2_lan_desc.h    |  606 ++++
 drivers/common/idpf/virtchnl_inline_ipsec.h |  567 ++++
 drivers/common/meson.build                  |    1 +
 drivers/net/idpf/idpf_ethdev.c              | 1244 ++++++++
 drivers/net/idpf/idpf_ethdev.h              |  271 ++
 drivers/net/idpf/idpf_logs.h                |   42 +
 drivers/net/idpf/idpf_rxtx.c                | 2398 ++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h                |  324 +++
 drivers/net/idpf/idpf_rxtx_vec_avx512.c     |  871 ++++++
 drivers/net/idpf/idpf_rxtx_vec_common.h     |  100 +
 drivers/net/idpf/idpf_vchnl.c               | 1443 ++++++++++
 drivers/net/idpf/meson.build                |   45 +
 drivers/net/idpf/version.map                |    3 +
 drivers/net/meson.build                     |    1 +
 37 files changed, 15385 insertions(+)
 create mode 100644 doc/guides/nics/features/idpf.ini
 create mode 100644 doc/guides/nics/idpf.rst
 create mode 100644 drivers/common/idpf/idpf_alloc.h
 create mode 100644 drivers/common/idpf/idpf_common.c
 create mode 100644 drivers/common/idpf/idpf_controlq.c
 create mode 100644 drivers/common/idpf/idpf_controlq.h
 create mode 100644 drivers/common/idpf/idpf_controlq_api.h
 create mode 100644 drivers/common/idpf/idpf_controlq_setup.c
 create mode 100644 drivers/common/idpf/idpf_devids.h
 create mode 100644 drivers/common/idpf/idpf_lan_pf_regs.h
 create mode 100644 drivers/common/idpf/idpf_lan_txrx.h
 create mode 100644 drivers/common/idpf/idpf_lan_vf_regs.h
 create mode 100644 drivers/common/idpf/idpf_osdep.h
 create mode 100644 drivers/common/idpf/idpf_prototype.h
 create mode 100644 drivers/common/idpf/idpf_type.h
 create mode 100644 drivers/common/idpf/meson.build
 create mode 100644 drivers/common/idpf/siov_regs.h
 create mode 100644 drivers/common/idpf/version.map
 create mode 100644 drivers/common/idpf/virtchnl.h
 create mode 100644 drivers/common/idpf/virtchnl2.h
 create mode 100644 drivers/common/idpf/virtchnl2_lan_desc.h
 create mode 100644 drivers/common/idpf/virtchnl_inline_ipsec.h
 create mode 100644 drivers/net/idpf/idpf_ethdev.c
 create mode 100644 drivers/net/idpf/idpf_ethdev.h
 create mode 100644 drivers/net/idpf/idpf_logs.h
 create mode 100644 drivers/net/idpf/idpf_rxtx.c
 create mode 100644 drivers/net/idpf/idpf_rxtx.h
 create mode 100644 drivers/net/idpf/idpf_rxtx_vec_avx512.c
 create mode 100644 drivers/net/idpf/idpf_rxtx_vec_common.h
 create mode 100644 drivers/net/idpf/idpf_vchnl.c
 create mode 100644 drivers/net/idpf/meson.build
 create mode 100644 drivers/net/idpf/version.map
Signature · 1 line
2.34.1
#70 lore raw

PATCH v4 1/14 common/idpf: introduce common library

Introduce common library for IDPF (Infrastructure Data Path Function) PMD.

Also add OS specific implementation about some MACRO definitions and small functions which are specific for DPDK.

---
 drivers/common/idpf/idpf_alloc.h            |   22 +
 drivers/common/idpf/idpf_common.c           |  364 +++
 drivers/common/idpf/idpf_controlq.c         |  691 +++++
 drivers/common/idpf/idpf_controlq.h         |  224 ++
 drivers/common/idpf/idpf_controlq_api.h     |  234 ++
 drivers/common/idpf/idpf_controlq_setup.c   |  179 ++
 drivers/common/idpf/idpf_devids.h           |   18 +
 drivers/common/idpf/idpf_lan_pf_regs.h      |  134 +
 drivers/common/idpf/idpf_lan_txrx.h         |  428 +++
 drivers/common/idpf/idpf_lan_vf_regs.h      |  114 +
 drivers/common/idpf/idpf_osdep.h            |  375 +++
 drivers/common/idpf/idpf_prototype.h        |   45 +
 drivers/common/idpf/idpf_type.h             |  106 +
 drivers/common/idpf/meson.build             |   15 +
 drivers/common/idpf/siov_regs.h             |   47 +
 drivers/common/idpf/version.map             |   12 +
 drivers/common/idpf/virtchnl.h              | 2866 +++++++++++++++++++
 drivers/common/idpf/virtchnl2.h             | 1462 ++++++++++
 drivers/common/idpf/virtchnl2_lan_desc.h    |  606 ++++
 drivers/common/idpf/virtchnl_inline_ipsec.h |  567 ++++
 drivers/common/meson.build                  |    1 +
 21 files changed, 8510 insertions(+)
 create mode 100644 drivers/common/idpf/idpf_alloc.h
 create mode 100644 drivers/common/idpf/idpf_common.c
 create mode 100644 drivers/common/idpf/idpf_controlq.c
 create mode 100644 drivers/common/idpf/idpf_controlq.h
 create mode 100644 drivers/common/idpf/idpf_controlq_api.h
 create mode 100644 drivers/common/idpf/idpf_controlq_setup.c
 create mode 100644 drivers/common/idpf/idpf_devids.h
 create mode 100644 drivers/common/idpf/idpf_lan_pf_regs.h
 create mode 100644 drivers/common/idpf/idpf_lan_txrx.h
 create mode 100644 drivers/common/idpf/idpf_lan_vf_regs.h
 create mode 100644 drivers/common/idpf/idpf_osdep.h
 create mode 100644 drivers/common/idpf/idpf_prototype.h
 create mode 100644 drivers/common/idpf/idpf_type.h
 create mode 100644 drivers/common/idpf/meson.build
 create mode 100644 drivers/common/idpf/siov_regs.h
 create mode 100644 drivers/common/idpf/version.map
 create mode 100644 drivers/common/idpf/virtchnl.h
 create mode 100644 drivers/common/idpf/virtchnl2.h
 create mode 100644 drivers/common/idpf/virtchnl2_lan_desc.h
 create mode 100644 drivers/common/idpf/virtchnl_inline_ipsec.h
drivers/common/idpf/idpf_alloc.h new file +22 -0
new file mode 100644
index 0000000000..bc054851b3
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2022 Intel Corporation
+ */
+
+#ifndef _IDPF_ALLOC_H_
+#define _IDPF_ALLOC_H_
+
+/* Memory types */
+enum idpf_memset_type {
+	IDPF_NONDMA_MEM = 0,
+	IDPF_DMA_MEM
+};
+
+/* Memcpy types */
+enum idpf_memcpy_type {
+	IDPF_NONDMA_TO_NONDMA = 0,
+	IDPF_NONDMA_TO_DMA,
+	IDPF_DMA_TO_DMA,
+	IDPF_DMA_TO_NONDMA
+};
+
+#endif /* _IDPF_ALLOC_H_ */
drivers/common/idpf/idpf_common.c new file +364 -0

364 lines not on this page · raw message

drivers/common/idpf/idpf_controlq.c new file +691 -0

691 lines not on this page · raw message

drivers/common/idpf/idpf_controlq.h new file +224 -0

224 lines not on this page · raw message

drivers/common/idpf/idpf_controlq_api.h new file +234 -0

234 lines not on this page · raw message

drivers/common/idpf/idpf_controlq_setup.c new file +179 -0

179 lines not on this page · raw message

drivers/common/idpf/idpf_devids.h new file +18 -0
new file mode 100644
index 0000000000..a91eb4e02a
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2022 Intel Corporation
+ */
+
+#ifndef _IDPF_DEVIDS_H_
+#define _IDPF_DEVIDS_H_
+
+/* Vendor ID */
+#define IDPF_INTEL_VENDOR_ID		0x8086
+
+/* Device IDs */
+#define IDPF_DEV_ID_PF			0x1452
+#define IDPF_DEV_ID_VF			0x1889
+
+
+
+
+#endif /* _IDPF_DEVIDS_H_ */
drivers/common/idpf/idpf_lan_pf_regs.h new file +134 -0

134 lines not on this page · raw message

drivers/common/idpf/idpf_lan_txrx.h new file +428 -0

428 lines not on this page · raw message

drivers/common/idpf/idpf_lan_vf_regs.h new file +114 -0

114 lines not on this page · raw message

drivers/common/idpf/idpf_osdep.h new file +375 -0

375 lines not on this page · raw message

drivers/common/idpf/idpf_prototype.h new file +45 -0

45 lines not on this page · raw message

drivers/common/idpf/idpf_type.h new file +106 -0

106 lines not on this page · raw message

drivers/common/idpf/meson.build new file +15 -0
new file mode 100644
index 0000000000..3f1f421ef1
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+sources = files(
+        'idpf_common.c',
+        'idpf_controlq.c',
+        'idpf_controlq_setup.c',
+)
+
+cflags += ['-Wno-unused-value']
+cflags += ['-Wno-unused-but-set-variable']
+cflags += ['-Wno-unused-variable']
+cflags += ['-Wno-unused-parameter']
+cflags += ['-Wno-implicit-fallthrough']
+cflags += ['-Wno-strict-aliasing']
drivers/common/idpf/siov_regs.h new file +47 -0

47 lines not on this page · raw message

drivers/common/idpf/version.map new file +12 -0
new file mode 100644
index 0000000000..bfb246c752
@@ -0,0 +1,12 @@
+INTERNAL {
+	global:
+
+	idpf_ctlq_deinit;
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

drivers/common/idpf/virtchnl.h new file +2866 -0

2,866 lines not on this page · raw message

drivers/common/idpf/virtchnl2.h new file +1462 -0

1,462 lines not on this page · raw message

drivers/common/idpf/virtchnl2_lan_desc.h new file +606 -0

606 lines not on this page · raw message

drivers/common/idpf/virtchnl_inline_ipsec.h new file +567 -0

567 lines not on this page · raw message

drivers/common/meson.build +1 -0
index ea261dd70a..b63d899d50 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.34.1

Part of the diff is not shown here. View the raw message.

#71 lore raw

v5 cover add support for idpf PMD in DPDK

This patchset introduced the idpf (Infrastructure Data Path Function) PMD in DPDK for Intel® IPU Ethernet ES2000 Series (Device ID: 0x1452).

v2:
fixed some coding style issues and did some refactors.

v3:
fixed some coding style issues and did some refactors.

v4:
fixed some coding style issues and build errors.

v5:
fixed typo.

Junfeng Guo (14):
common/idpf: introduce common library
net/idpf: add support for device initialization net/idpf: add queue setup and release in single queue model net/idpf: add queue setup and release in split queue model net/idpf: add support for queue start and stop net/idpf: add support for device information get net/idpf: add support for packet type get net/idpf: add support for basic Rx/Tx datapath net/idpf: add support for Rx/Tx offloading net/idpf: add support for RSS
net/idpf: add support for MTU configuration net/idpf: add support for write back based on ITR expire net/idpf: add AVX512 data path for single queue model net/idpf: add support for timestamp offload

 MAINTAINERS                                 |    9 +
 doc/guides/nics/features/idpf.ini           |   24 +
 doc/guides/nics/idpf.rst                    |   94 +
 doc/guides/nics/index.rst                   |    1 +
 doc/guides/rel_notes/release_22_11.rst      |    5 +
 drivers/common/idpf/idpf_alloc.h            |   22 +
 drivers/common/idpf/idpf_common.c           |  364 +++
 drivers/common/idpf/idpf_controlq.c         |  691 +++++
 drivers/common/idpf/idpf_controlq.h         |  224 ++
 drivers/common/idpf/idpf_controlq_api.h     |  234 ++
 drivers/common/idpf/idpf_controlq_setup.c   |  179 ++
 drivers/common/idpf/idpf_devids.h           |   18 +
 drivers/common/idpf/idpf_lan_pf_regs.h      |  134 +
 drivers/common/idpf/idpf_lan_txrx.h         |  428 +++
 drivers/common/idpf/idpf_lan_vf_regs.h      |  114 +
 drivers/common/idpf/idpf_osdep.h            |  375 +++
 drivers/common/idpf/idpf_prototype.h        |   45 +
 drivers/common/idpf/idpf_type.h             |  106 +
 drivers/common/idpf/meson.build             |   15 +
 drivers/common/idpf/siov_regs.h             |   47 +
 drivers/common/idpf/version.map             |   12 +
 drivers/common/idpf/virtchnl.h              | 2866 +++++++++++++++++++
 drivers/common/idpf/virtchnl2.h             | 1462 ++++++++++
 drivers/common/idpf/virtchnl2_lan_desc.h    |  606 ++++
 drivers/common/idpf/virtchnl_inline_ipsec.h |  567 ++++
 drivers/common/meson.build                  |    1 +
 drivers/net/idpf/idpf_ethdev.c              | 1244 ++++++++
 drivers/net/idpf/idpf_ethdev.h              |  271 ++
 drivers/net/idpf/idpf_logs.h                |   42 +
 drivers/net/idpf/idpf_rxtx.c                | 2400 ++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h                |  324 +++
 drivers/net/idpf/idpf_rxtx_vec_avx512.c     |  871 ++++++
 drivers/net/idpf/idpf_rxtx_vec_common.h     |  100 +
 drivers/net/idpf/idpf_vchnl.c               | 1443 ++++++++++
 drivers/net/idpf/meson.build                |   45 +
 drivers/net/idpf/version.map                |    3 +
 drivers/net/meson.build                     |    1 +
 37 files changed, 15387 insertions(+)
 create mode 100644 doc/guides/nics/features/idpf.ini
 create mode 100644 doc/guides/nics/idpf.rst
 create mode 100644 drivers/common/idpf/idpf_alloc.h
 create mode 100644 drivers/common/idpf/idpf_common.c
 create mode 100644 drivers/common/idpf/idpf_controlq.c
 create mode 100644 drivers/common/idpf/idpf_controlq.h
 create mode 100644 drivers/common/idpf/idpf_controlq_api.h
 create mode 100644 drivers/common/idpf/idpf_controlq_setup.c
 create mode 100644 drivers/common/idpf/idpf_devids.h
 create mode 100644 drivers/common/idpf/idpf_lan_pf_regs.h
 create mode 100644 drivers/common/idpf/idpf_lan_txrx.h
 create mode 100644 drivers/common/idpf/idpf_lan_vf_regs.h
 create mode 100644 drivers/common/idpf/idpf_osdep.h
 create mode 100644 drivers/common/idpf/idpf_prototype.h
 create mode 100644 drivers/common/idpf/idpf_type.h
 create mode 100644 drivers/common/idpf/meson.build
 create mode 100644 drivers/common/idpf/siov_regs.h
 create mode 100644 drivers/common/idpf/version.map
 create mode 100644 drivers/common/idpf/virtchnl.h
 create mode 100644 drivers/common/idpf/virtchnl2.h
 create mode 100644 drivers/common/idpf/virtchnl2_lan_desc.h
 create mode 100644 drivers/common/idpf/virtchnl_inline_ipsec.h
 create mode 100644 drivers/net/idpf/idpf_ethdev.c
 create mode 100644 drivers/net/idpf/idpf_ethdev.h
 create mode 100644 drivers/net/idpf/idpf_logs.h
 create mode 100644 drivers/net/idpf/idpf_rxtx.c
 create mode 100644 drivers/net/idpf/idpf_rxtx.h
 create mode 100644 drivers/net/idpf/idpf_rxtx_vec_avx512.c
 create mode 100644 drivers/net/idpf/idpf_rxtx_vec_common.h
 create mode 100644 drivers/net/idpf/idpf_vchnl.c
 create mode 100644 drivers/net/idpf/meson.build
 create mode 100644 drivers/net/idpf/version.map
Signature · 1 line
2.34.1
#72 lore raw

PATCH v5 1/14 common/idpf: introduce common library

Introduce common library for IDPF (Infrastructure Data Path Function) PMD.

Also add OS specific implementation about some MACRO definitions and small functions which are specific for DPDK.

---
 drivers/common/idpf/idpf_alloc.h            |   22 +
 drivers/common/idpf/idpf_common.c           |  364 +++
 drivers/common/idpf/idpf_controlq.c         |  691 +++++
 drivers/common/idpf/idpf_controlq.h         |  224 ++
 drivers/common/idpf/idpf_controlq_api.h     |  234 ++
 drivers/common/idpf/idpf_controlq_setup.c   |  179 ++
 drivers/common/idpf/idpf_devids.h           |   18 +
 drivers/common/idpf/idpf_lan_pf_regs.h      |  134 +
 drivers/common/idpf/idpf_lan_txrx.h         |  428 +++
 drivers/common/idpf/idpf_lan_vf_regs.h      |  114 +
 drivers/common/idpf/idpf_osdep.h            |  375 +++
 drivers/common/idpf/idpf_prototype.h        |   45 +
 drivers/common/idpf/idpf_type.h             |  106 +
 drivers/common/idpf/meson.build             |   15 +
 drivers/common/idpf/siov_regs.h             |   47 +
 drivers/common/idpf/version.map             |   12 +
 drivers/common/idpf/virtchnl.h              | 2866 +++++++++++++++++++
 drivers/common/idpf/virtchnl2.h             | 1462 ++++++++++
 drivers/common/idpf/virtchnl2_lan_desc.h    |  606 ++++
 drivers/common/idpf/virtchnl_inline_ipsec.h |  567 ++++
 drivers/common/meson.build                  |    1 +
 21 files changed, 8510 insertions(+)
 create mode 100644 drivers/common/idpf/idpf_alloc.h
 create mode 100644 drivers/common/idpf/idpf_common.c
 create mode 100644 drivers/common/idpf/idpf_controlq.c
 create mode 100644 drivers/common/idpf/idpf_controlq.h
 create mode 100644 drivers/common/idpf/idpf_controlq_api.h
 create mode 100644 drivers/common/idpf/idpf_controlq_setup.c
 create mode 100644 drivers/common/idpf/idpf_devids.h
 create mode 100644 drivers/common/idpf/idpf_lan_pf_regs.h
 create mode 100644 drivers/common/idpf/idpf_lan_txrx.h
 create mode 100644 drivers/common/idpf/idpf_lan_vf_regs.h
 create mode 100644 drivers/common/idpf/idpf_osdep.h
 create mode 100644 drivers/common/idpf/idpf_prototype.h
 create mode 100644 drivers/common/idpf/idpf_type.h
 create mode 100644 drivers/common/idpf/meson.build
 create mode 100644 drivers/common/idpf/siov_regs.h
 create mode 100644 drivers/common/idpf/version.map
 create mode 100644 drivers/common/idpf/virtchnl.h
 create mode 100644 drivers/common/idpf/virtchnl2.h
 create mode 100644 drivers/common/idpf/virtchnl2_lan_desc.h
 create mode 100644 drivers/common/idpf/virtchnl_inline_ipsec.h
drivers/common/idpf/idpf_alloc.h new file +22 -0
new file mode 100644
index 0000000000..bc054851b3
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2022 Intel Corporation
+ */
+
+#ifndef _IDPF_ALLOC_H_
+#define _IDPF_ALLOC_H_
+
+/* Memory types */
+enum idpf_memset_type {
+	IDPF_NONDMA_MEM = 0,
+	IDPF_DMA_MEM
+};
+
+/* Memcpy types */
+enum idpf_memcpy_type {
+	IDPF_NONDMA_TO_NONDMA = 0,
+	IDPF_NONDMA_TO_DMA,
+	IDPF_DMA_TO_DMA,
+	IDPF_DMA_TO_NONDMA
+};
+
+#endif /* _IDPF_ALLOC_H_ */
drivers/common/idpf/idpf_common.c new file +364 -0

364 lines not on this page · raw message

drivers/common/idpf/idpf_controlq.c new file +691 -0

691 lines not on this page · raw message

drivers/common/idpf/idpf_controlq.h new file +224 -0

224 lines not on this page · raw message

drivers/common/idpf/idpf_controlq_api.h new file +234 -0

234 lines not on this page · raw message

drivers/common/idpf/idpf_controlq_setup.c new file +179 -0

179 lines not on this page · raw message

drivers/common/idpf/idpf_devids.h new file +18 -0
new file mode 100644
index 0000000000..a91eb4e02a
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2022 Intel Corporation
+ */
+
+#ifndef _IDPF_DEVIDS_H_
+#define _IDPF_DEVIDS_H_
+
+/* Vendor ID */
+#define IDPF_INTEL_VENDOR_ID		0x8086
+
+/* Device IDs */
+#define IDPF_DEV_ID_PF			0x1452
+#define IDPF_DEV_ID_VF			0x1889
+
+
+
+
+#endif /* _IDPF_DEVIDS_H_ */
drivers/common/idpf/idpf_lan_pf_regs.h new file +134 -0

134 lines not on this page · raw message

drivers/common/idpf/idpf_lan_txrx.h new file +428 -0

428 lines not on this page · raw message

drivers/common/idpf/idpf_lan_vf_regs.h new file +114 -0

114 lines not on this page · raw message

drivers/common/idpf/idpf_osdep.h new file +375 -0

375 lines not on this page · raw message

drivers/common/idpf/idpf_prototype.h new file +45 -0

45 lines not on this page · raw message

drivers/common/idpf/idpf_type.h new file +106 -0

106 lines not on this page · raw message

drivers/common/idpf/meson.build new file +15 -0
new file mode 100644
index 0000000000..3f1f421ef1
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+sources = files(
+        'idpf_common.c',
+        'idpf_controlq.c',
+        'idpf_controlq_setup.c',
+)
+
+cflags += ['-Wno-unused-value']
+cflags += ['-Wno-unused-but-set-variable']
+cflags += ['-Wno-unused-variable']
+cflags += ['-Wno-unused-parameter']
+cflags += ['-Wno-implicit-fallthrough']
+cflags += ['-Wno-strict-aliasing']
drivers/common/idpf/siov_regs.h new file +47 -0

47 lines not on this page · raw message

drivers/common/idpf/version.map new file +12 -0
new file mode 100644
index 0000000000..bfb246c752
@@ -0,0 +1,12 @@
+INTERNAL {
+	global:
+
+	idpf_ctlq_deinit;
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

drivers/common/idpf/virtchnl.h new file +2866 -0

2,866 lines not on this page · raw message

drivers/common/idpf/virtchnl2.h new file +1462 -0

1,462 lines not on this page · raw message

drivers/common/idpf/virtchnl2_lan_desc.h new file +606 -0

606 lines not on this page · raw message

drivers/common/idpf/virtchnl_inline_ipsec.h new file +567 -0

567 lines not on this page · raw message

drivers/common/meson.build +1 -0
index ea261dd70a..b63d899d50 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.34.1

Part of the diff is not shown here. View the raw message.

#73 lore raw

v6 cover add support for idpf PMD in DPDK

This patchset introduced the idpf (Infrastructure Data Path Function) PMD in DPDK for Intel® IPU Ethernet ES2000 Series (Device ID: 0x1452).

v2:
fixed some coding style issues and did some refactors.

v3:
fixed some coding style issues and did some refactors.

v4:
fixed some coding style issues and build errors.

v5:
fixed typo.

v6:
fixed build errors.

Junfeng Guo (14):
common/idpf: introduce common library
net/idpf: add support for device initialization net/idpf: add queue setup and release in single queue model net/idpf: add queue setup and release in split queue model net/idpf: add support for queue start and stop net/idpf: add support for device information get net/idpf: add support for packet type get net/idpf: add support for basic Rx/Tx datapath net/idpf: add support for Rx/Tx offloading net/idpf: add support for RSS
net/idpf: add support for MTU configuration net/idpf: add support for write back based on ITR expire net/idpf: add AVX512 data path for single queue model net/idpf: add support for timestamp offload

 MAINTAINERS                                 |    9 +
 doc/guides/nics/features/idpf.ini           |   24 +
 doc/guides/nics/idpf.rst                    |   94 +
 doc/guides/nics/index.rst                   |    1 +
 doc/guides/rel_notes/release_22_11.rst      |    5 +
 drivers/common/idpf/idpf_alloc.h            |   22 +
 drivers/common/idpf/idpf_common.c           |  364 +++
 drivers/common/idpf/idpf_controlq.c         |  691 +++++
 drivers/common/idpf/idpf_controlq.h         |  224 ++
 drivers/common/idpf/idpf_controlq_api.h     |  234 ++
 drivers/common/idpf/idpf_controlq_setup.c   |  179 ++
 drivers/common/idpf/idpf_devids.h           |   18 +
 drivers/common/idpf/idpf_lan_pf_regs.h      |  134 +
 drivers/common/idpf/idpf_lan_txrx.h         |  428 +++
 drivers/common/idpf/idpf_lan_vf_regs.h      |  114 +
 drivers/common/idpf/idpf_osdep.h            |  375 +++
 drivers/common/idpf/idpf_prototype.h        |   45 +
 drivers/common/idpf/idpf_type.h             |  106 +
 drivers/common/idpf/meson.build             |   14 +
 drivers/common/idpf/siov_regs.h             |   47 +
 drivers/common/idpf/version.map             |   12 +
 drivers/common/idpf/virtchnl.h              | 2866 +++++++++++++++++++
 drivers/common/idpf/virtchnl2.h             | 1462 ++++++++++
 drivers/common/idpf/virtchnl2_lan_desc.h    |  606 ++++
 drivers/common/idpf/virtchnl_inline_ipsec.h |  567 ++++
 drivers/common/meson.build                  |    1 +
 drivers/net/idpf/idpf_ethdev.c              | 1244 ++++++++
 drivers/net/idpf/idpf_ethdev.h              |  271 ++
 drivers/net/idpf/idpf_logs.h                |   42 +
 drivers/net/idpf/idpf_rxtx.c                | 2375 +++++++++++++++
 drivers/net/idpf/idpf_rxtx.h                |  324 +++
 drivers/net/idpf/idpf_rxtx_vec_avx512.c     |  871 ++++++
 drivers/net/idpf/idpf_rxtx_vec_common.h     |  100 +
 drivers/net/idpf/idpf_vchnl.c               | 1443 ++++++++++
 drivers/net/idpf/meson.build                |   45 +
 drivers/net/idpf/version.map                |    3 +
 drivers/net/meson.build                     |    1 +
 37 files changed, 15361 insertions(+)
 create mode 100644 doc/guides/nics/features/idpf.ini
 create mode 100644 doc/guides/nics/idpf.rst
 create mode 100644 drivers/common/idpf/idpf_alloc.h
 create mode 100644 drivers/common/idpf/idpf_common.c
 create mode 100644 drivers/common/idpf/idpf_controlq.c
 create mode 100644 drivers/common/idpf/idpf_controlq.h
 create mode 100644 drivers/common/idpf/idpf_controlq_api.h
 create mode 100644 drivers/common/idpf/idpf_controlq_setup.c
 create mode 100644 drivers/common/idpf/idpf_devids.h
 create mode 100644 drivers/common/idpf/idpf_lan_pf_regs.h
 create mode 100644 drivers/common/idpf/idpf_lan_txrx.h
 create mode 100644 drivers/common/idpf/idpf_lan_vf_regs.h
 create mode 100644 drivers/common/idpf/idpf_osdep.h
 create mode 100644 drivers/common/idpf/idpf_prototype.h
 create mode 100644 drivers/common/idpf/idpf_type.h
 create mode 100644 drivers/common/idpf/meson.build
 create mode 100644 drivers/common/idpf/siov_regs.h
 create mode 100644 drivers/common/idpf/version.map
 create mode 100644 drivers/common/idpf/virtchnl.h
 create mode 100644 drivers/common/idpf/virtchnl2.h
 create mode 100644 drivers/common/idpf/virtchnl2_lan_desc.h
 create mode 100644 drivers/common/idpf/virtchnl_inline_ipsec.h
 create mode 100644 drivers/net/idpf/idpf_ethdev.c
 create mode 100644 drivers/net/idpf/idpf_ethdev.h
 create mode 100644 drivers/net/idpf/idpf_logs.h
 create mode 100644 drivers/net/idpf/idpf_rxtx.c
 create mode 100644 drivers/net/idpf/idpf_rxtx.h
 create mode 100644 drivers/net/idpf/idpf_rxtx_vec_avx512.c
 create mode 100644 drivers/net/idpf/idpf_rxtx_vec_common.h
 create mode 100644 drivers/net/idpf/idpf_vchnl.c
 create mode 100644 drivers/net/idpf/meson.build
 create mode 100644 drivers/net/idpf/version.map
Signature · 1 line
2.34.1