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 3 of 5

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

PATCH v16 17/18 net/idpf: add AVX512 data path for single queue model

In reply to [email protected]

From: Junfeng Guo <[email protected]>

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

---
 doc/guides/nics/idpf.rst                |  19 +
 drivers/net/idpf/idpf_ethdev.c          |   3 +-
 drivers/net/idpf/idpf_ethdev.h          |   5 +
 drivers/net/idpf/idpf_rxtx.c            | 145 ++++
 drivers/net/idpf/idpf_rxtx.h            |  21 +
 drivers/net/idpf/idpf_rxtx_vec_avx512.c | 871 ++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx_vec_common.h | 100 +++
 drivers/net/idpf/meson.build            |  28 +
 8 files changed, 1191 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
doc/guides/nics/idpf.rst +19 -0
index c1001d5d0c..3039c61748 100644
@@ -64,3 +64,22 @@ Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and
 for details.
 
 
+Features
+--------
+
+Vector PMD
+~~~~~~~~~~
+
+Vector path for RX and TX path are selected automatically. The paths
+are chosen based on 2 conditions.
+
+- ``CPU``
+  On the X86 platform, the driver checks if the CPU supports AVX512.
+  If the CPU supports AVX512 and EAL argument ``--force-max-simd-bitwidth``
+  is set to 512, AVX512 paths will be chosen.
+
+- ``Offload features``
+  The supported HW offload features are described in the document idpf.ini,
+  A value "P" means the offload feature is not supported by vector path.
+  If any not supported features are used, idpf vector PMD is disabled and the
+  scalar paths are chosen.
drivers/net/idpf/idpf_ethdev.c +2 -1
index 084426260c..cd4ebcc2c6 100644
@@ -69,7 +69,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->tx_offload_capa =
 		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
-		RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS		|
+		RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
 	dev_info->default_txconf = (struct rte_eth_txconf) {
 		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
drivers/net/idpf/idpf_ethdev.h +5 -0
index 8d0804f603..7d54e5db60 100644
@@ -162,6 +162,11 @@ struct idpf_adapter {
 	uint32_t max_txq_per_msg;
 
 	uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned;
+
+	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 +145 -0

185 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +21 -0
index 54d297aac6..506bf8a57d 100644
@@ -18,6 +18,12 @@
 #define IDPF_RX_MAX_BURST		32
 #define IDPF_DEFAULT_RX_FREE_THRESH	32
 
+/* used for Vector PMD */
+#define IDPF_VPMD_RX_MAX_BURST	32
+#define IDPF_VPMD_TX_MAX_BURST	32
+#define IDPF_VPMD_DESCS_PER_LOOP	4
+#define IDPF_RXQ_REARM_THRESH	64
+
 #define IDPF_DEFAULT_TX_RS_THRESH	32
 #define IDPF_DEFAULT_TX_FREE_THRESH	32
 
@@ -54,6 +60,11 @@ struct idpf_rx_queue {
 	struct rte_mbuf *pkt_last_seg;  /* last segment of current packet */
 	struct rte_mbuf fake_mbuf;      /* dummy mbuf */
 
+	/* used for VPMD */
+	uint16_t rxrearm_nb;       /* number of remaining to be re-armed */
+	uint16_t rxrearm_start;    /* the idx we start the re-arming from */
+	uint64_t mbuf_initializer; /* value to init mbufs */
+
 	uint16_t rx_nb_avail;
 	uint16_t rx_next_avail;
 
@@ -84,6 +95,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 */
@@ -149,6 +164,7 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_rxconf *rx_conf,
 			struct rte_mempool *mp);
+int idpf_singleq_tx_vec_setup_avx512(struct idpf_tx_queue *txq);
 int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
@@ -157,16 +173,21 @@ void idpf_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
+int idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq);
 int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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_singleq_recv_pkts_avx512(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_singleq_xmit_pkts_avx512(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,
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +871 -0

871 lines not on this page · raw message

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

100 lines not on this page · raw message

drivers/net/idpf/meson.build +28 -0
index b632b76656..da99c098ab 100644
@@ -14,3 +14,31 @@ sources = files(
     'idpf_rxtx.c',
     '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_common_idpf, 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
Signature · 1 line
2.26.2
#169 lore raw

PATCH v16 18/18 net/idpf: add support for timestamp offload

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add support for timestamp offload.

---
 doc/guides/nics/features/idpf.ini |  1 +
 drivers/net/idpf/idpf_ethdev.c    |  5 +-
 drivers/net/idpf/idpf_ethdev.h    |  3 ++
 drivers/net/idpf/idpf_rxtx.c      | 65 ++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h      | 90 +++++++++++++++++++++++++++++++
 5 files changed, 163 insertions(+), 1 deletion(-)
doc/guides/nics/features/idpf.ini +1 -0
index d82b4aa0ff..099fd7f216 100644
@@ -11,6 +11,7 @@ MTU update           = Y
 TSO                  = P
 L3 checksum offload  = P
 L4 checksum offload  = P
+Timestamp offload    = P
 Linux                = Y
 x86-32               = Y
 x86-64               = Y
drivers/net/idpf/idpf_ethdev.c +4 -1
index cd4ebcc2c6..50aac65daf 100644
@@ -22,6 +22,8 @@ rte_spinlock_t idpf_adapter_lock;
 struct idpf_adapter_list idpf_adapter_list;
 bool idpf_adapter_list_init;
 
+uint64_t idpf_timestamp_dynflag;
+
 static const char * const idpf_valid_args[] = {
 	IDPF_TX_SINGLE_Q,
 	IDPF_RX_SINGLE_Q,
@@ -65,7 +67,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		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_OUTER_IPV4_CKSUM     |
+		RTE_ETH_RX_OFFLOAD_TIMESTAMP;
 
 	dev_info->tx_offload_capa =
 		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
drivers/net/idpf/idpf_ethdev.h +3 -0
index 7d54e5db60..ccdf4abe40 100644
@@ -167,6 +167,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 +65 -0

140 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +90 -0

106 lines not on this page · raw message

Signature · 1 line
2.26.2
#170 lore raw

v17 cover add support for idpf PMD in DPDK

In reply to [email protected]

From: Beilei Xing <[email protected]>

This patchset introduced the idpf (Infrastructure Data Path Function) PMD in DPDK for Intel® IPU E2000 (Device ID: 0x1452). The Intel® IPU E2000 targets to deliver high performance under real workloads with security and isolation. Please refer to
https://www.intel.com/content/www/us/en/products/network-io/infrastructure-processing-units/asic/e2000-asic.html
for more information.

Linux upstream is still ongoing, previous work refers to https://patchwork.ozlabs.org/project/intel-wired-lan/patch/[email protected]/.

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

v5:
fixed typo.

v6-v9:
fixed build errors and coding style issues.

v11:
- move shared code to common/idpf/base
- Create one vport if there's no vport devargs
- Refactor if conditions according to coding style
- Refactor virtual channel return values
- Refine dev_stop function
- Refine RSS lut/key
- Fix build error

v12:
- Refine dev_configure
- Fix coding style according to the comments
- Re-order patch
- Romove dev_supported_ptypes_get

v13:
- refine dev_start/stop and queue_start/stop
- fix timestamp offload

v14:
- fix wrong position for rte_validate_tx_offload

v15:
- refine the return value for ethdev ops.
- removce forward static declarations.
- refine get caps.
- fix lock/unlock handling.

v16:
- refine errno in shared code
- remove the conditional compilation IDPF_RX_PTYPE_OFFLOAD

v17:
- fix build error on FreeBSD

Junfeng Guo (18):
common/idpf: introduce common library
net/idpf: add support for device initialization net/idpf: add Tx queue setup
net/idpf: add Rx queue setup
net/idpf: add support for device start and stop net/idpf: add support for queue start
net/idpf: add support for queue stop
net/idpf: add queue release
net/idpf: add support for MTU configuration net/idpf: add support for basic Rx datapath net/idpf: add support for basic Tx datapath net/idpf: support parsing packet type
net/idpf: add support for write back based on ITR expire net/idpf: add support for RSS
net/idpf: add support for Rx offloading net/idpf: add support for Tx offloading 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             |   17 +
 doc/guides/nics/idpf.rst                      |   85 +
 doc/guides/nics/index.rst                     |    1 +
 doc/guides/rel_notes/release_22_11.rst        |    6 +
 drivers/common/idpf/base/idpf_alloc.h         |   22 +
 drivers/common/idpf/base/idpf_common.c        |  364 +++
 drivers/common/idpf/base/idpf_controlq.c      |  691 ++++
 drivers/common/idpf/base/idpf_controlq.h      |  224 ++
 drivers/common/idpf/base/idpf_controlq_api.h  |  207 ++
 .../common/idpf/base/idpf_controlq_setup.c    |  179 +
 drivers/common/idpf/base/idpf_devids.h        |   18 +
 drivers/common/idpf/base/idpf_lan_pf_regs.h   |  134 +
 drivers/common/idpf/base/idpf_lan_txrx.h      |  428 +++
 drivers/common/idpf/base/idpf_lan_vf_regs.h   |  114 +
 drivers/common/idpf/base/idpf_osdep.h         |  364 +++
 drivers/common/idpf/base/idpf_prototype.h     |   45 +
 drivers/common/idpf/base/idpf_type.h          |  106 +
 drivers/common/idpf/base/meson.build          |   14 +
 drivers/common/idpf/base/siov_regs.h          |   47 +
 drivers/common/idpf/base/virtchnl.h           | 2866 +++++++++++++++++
 drivers/common/idpf/base/virtchnl2.h          | 1462 +++++++++
 drivers/common/idpf/base/virtchnl2_lan_desc.h |  606 ++++
 .../common/idpf/base/virtchnl_inline_ipsec.h  |  567 ++++
 drivers/common/idpf/meson.build               |    4 +
 drivers/common/idpf/version.map               |   12 +
 drivers/common/meson.build                    |    1 +
 drivers/net/idpf/idpf_ethdev.c                | 1293 ++++++++
 drivers/net/idpf/idpf_ethdev.h                |  252 ++
 drivers/net/idpf/idpf_logs.h                  |   56 +
 drivers/net/idpf/idpf_rxtx.c                  | 2308 +++++++++++++
 drivers/net/idpf/idpf_rxtx.h                  |  291 ++
 drivers/net/idpf/idpf_rxtx_vec_avx512.c       |  871 +++++
 drivers/net/idpf/idpf_rxtx_vec_common.h       |  100 +
 drivers/net/idpf/idpf_vchnl.c                 | 1416 ++++++++
 drivers/net/idpf/meson.build                  |   44 +
 drivers/net/idpf/version.map                  |    3 +
 drivers/net/meson.build                       |    1 +
 38 files changed, 15228 insertions(+)
 create mode 100644 doc/guides/nics/features/idpf.ini
 create mode 100644 doc/guides/nics/idpf.rst
 create mode 100644 drivers/common/idpf/base/idpf_alloc.h
 create mode 100644 drivers/common/idpf/base/idpf_common.c
 create mode 100644 drivers/common/idpf/base/idpf_controlq.c
 create mode 100644 drivers/common/idpf/base/idpf_controlq.h
 create mode 100644 drivers/common/idpf/base/idpf_controlq_api.h
 create mode 100644 drivers/common/idpf/base/idpf_controlq_setup.c
 create mode 100644 drivers/common/idpf/base/idpf_devids.h
 create mode 100644 drivers/common/idpf/base/idpf_lan_pf_regs.h
 create mode 100644 drivers/common/idpf/base/idpf_lan_txrx.h
 create mode 100644 drivers/common/idpf/base/idpf_lan_vf_regs.h
 create mode 100644 drivers/common/idpf/base/idpf_osdep.h
 create mode 100644 drivers/common/idpf/base/idpf_prototype.h
 create mode 100644 drivers/common/idpf/base/idpf_type.h
 create mode 100644 drivers/common/idpf/base/meson.build
 create mode 100644 drivers/common/idpf/base/siov_regs.h
 create mode 100644 drivers/common/idpf/base/virtchnl.h
 create mode 100644 drivers/common/idpf/base/virtchnl2.h
 create mode 100644 drivers/common/idpf/base/virtchnl2_lan_desc.h
 create mode 100644 drivers/common/idpf/base/virtchnl_inline_ipsec.h
 create mode 100644 drivers/common/idpf/meson.build
 create mode 100644 drivers/common/idpf/version.map
 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.26.2
#171 lore raw

PATCH v17 1/18 common/idpf: introduce common library

From: Junfeng Guo <[email protected]>

Introduce common library for IDPF (Infrastructure Data Path Function) PMD.
Add base code and OS specific implementation first.

---
 drivers/common/idpf/base/idpf_alloc.h         |   22 +
 drivers/common/idpf/base/idpf_common.c        |  364 +++
 drivers/common/idpf/base/idpf_controlq.c      |  691 ++++
 drivers/common/idpf/base/idpf_controlq.h      |  224 ++
 drivers/common/idpf/base/idpf_controlq_api.h  |  207 ++
 .../common/idpf/base/idpf_controlq_setup.c    |  179 +
 drivers/common/idpf/base/idpf_devids.h        |   18 +
 drivers/common/idpf/base/idpf_lan_pf_regs.h   |  134 +
 drivers/common/idpf/base/idpf_lan_txrx.h      |  428 +++
 drivers/common/idpf/base/idpf_lan_vf_regs.h   |  114 +
 drivers/common/idpf/base/idpf_osdep.h         |  364 +++
 drivers/common/idpf/base/idpf_prototype.h     |   45 +
 drivers/common/idpf/base/idpf_type.h          |  106 +
 drivers/common/idpf/base/meson.build          |   14 +
 drivers/common/idpf/base/siov_regs.h          |   47 +
 drivers/common/idpf/base/virtchnl.h           | 2866 +++++++++++++++++
 drivers/common/idpf/base/virtchnl2.h          | 1462 +++++++++
 drivers/common/idpf/base/virtchnl2_lan_desc.h |  606 ++++
 .../common/idpf/base/virtchnl_inline_ipsec.h  |  567 ++++
 drivers/common/idpf/meson.build               |    4 +
 drivers/common/idpf/version.map               |   12 +
 drivers/common/meson.build                    |    1 +
 22 files changed, 8475 insertions(+)
 create mode 100644 drivers/common/idpf/base/idpf_alloc.h
 create mode 100644 drivers/common/idpf/base/idpf_common.c
 create mode 100644 drivers/common/idpf/base/idpf_controlq.c
 create mode 100644 drivers/common/idpf/base/idpf_controlq.h
 create mode 100644 drivers/common/idpf/base/idpf_controlq_api.h
 create mode 100644 drivers/common/idpf/base/idpf_controlq_setup.c
 create mode 100644 drivers/common/idpf/base/idpf_devids.h
 create mode 100644 drivers/common/idpf/base/idpf_lan_pf_regs.h
 create mode 100644 drivers/common/idpf/base/idpf_lan_txrx.h
 create mode 100644 drivers/common/idpf/base/idpf_lan_vf_regs.h
 create mode 100644 drivers/common/idpf/base/idpf_osdep.h
 create mode 100644 drivers/common/idpf/base/idpf_prototype.h
 create mode 100644 drivers/common/idpf/base/idpf_type.h
 create mode 100644 drivers/common/idpf/base/meson.build
 create mode 100644 drivers/common/idpf/base/siov_regs.h
 create mode 100644 drivers/common/idpf/base/virtchnl.h
 create mode 100644 drivers/common/idpf/base/virtchnl2.h
 create mode 100644 drivers/common/idpf/base/virtchnl2_lan_desc.h
 create mode 100644 drivers/common/idpf/base/virtchnl_inline_ipsec.h
 create mode 100644 drivers/common/idpf/meson.build
 create mode 100644 drivers/common/idpf/version.map
drivers/common/idpf/base/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/base/idpf_common.c new file +364 -0

364 lines not on this page · raw message

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

691 lines not on this page · raw message

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

224 lines not on this page · raw message

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

207 lines not on this page · raw message

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

179 lines not on this page · raw message

drivers/common/idpf/base/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/base/idpf_lan_pf_regs.h new file +134 -0

134 lines not on this page · raw message

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

428 lines not on this page · raw message

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

114 lines not on this page · raw message

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

364 lines not on this page · raw message

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

45 lines not on this page · raw message

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

106 lines not on this page · raw message

drivers/common/idpf/base/meson.build new file +14 -0
new file mode 100644
index 0000000000..ce2b5346e4
@@ -0,0 +1,14 @@
+# 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-variable']
+cflags += ['-Wno-unused-parameter']
+cflags += ['-Wno-implicit-fallthrough']
+cflags += ['-Wno-strict-aliasing']
\ No newline at end of file
drivers/common/idpf/base/siov_regs.h new file +47 -0

47 lines not on this page · raw message

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

42 lines not on this page · raw message

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

1,462 lines not on this page · raw message

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

606 lines not on this page · raw message

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

567 lines not on this page · raw message

drivers/common/idpf/meson.build new file +4 -0
new file mode 100644
index 0000000000..26881166e9

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

drivers/common/idpf/version.map new file +12 -0
new file mode 100644
index 0000000000..bfb246c752

Lines of this file are not shown. View the 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.26.2

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

#172 lore raw

PATCH v17 2/18 net/idpf: add support for device initialization

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Support device init and add the following dev ops:
- dev_configure
- dev_close
- dev_infos_get

---
 MAINTAINERS                            |   9 +
 doc/guides/nics/features/idpf.ini      |   9 +
 doc/guides/nics/idpf.rst               |  66 ++
 doc/guides/nics/index.rst              |   1 +
 doc/guides/rel_notes/release_22_11.rst |   6 +
 drivers/net/idpf/idpf_ethdev.c         | 891 +++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h         | 189 ++++++
 drivers/net/idpf/idpf_logs.h           |  56 ++
 drivers/net/idpf/idpf_vchnl.c          | 416 ++++++++++++
 drivers/net/idpf/meson.build           |  15 +
 drivers/net/idpf/version.map           |   3 +
 drivers/net/meson.build                |   1 +
 12 files changed, 1662 insertions(+)
 create mode 100644 doc/guides/nics/features/idpf.ini
 create mode 100644 doc/guides/nics/idpf.rst
 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_vchnl.c
 create mode 100644 drivers/net/idpf/meson.build
 create mode 100644 drivers/net/idpf/version.map
MAINTAINERS +9 -0
index bdf233c9f8..cc66db25e8 100644
@@ -770,6 +770,15 @@ F: drivers/net/ice/
 F: doc/guides/nics/ice.rst
 F: doc/guides/nics/features/ice.ini
 
+Intel idpf
+M: Jingjing Wu <[email protected]>
+M: Beilei Xing <[email protected]>
+T: git://dpdk.org/next/dpdk-next-net-intel
+F: drivers/net/idpf/
+F: drivers/common/idpf/
+F: doc/guides/nics/idpf.rst
+F: doc/guides/nics/features/idpf.ini
+
 Intel igc
 M: Junfeng Guo <[email protected]>
 M: Simei Su <[email protected]>
doc/guides/nics/features/idpf.ini new file +9 -0
new file mode 100644
index 0000000000..46aab2eb61
@@ -0,0 +1,9 @@
+;
+; Supported features of the 'idpf' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-32               = Y
+x86-64               = Y
doc/guides/nics/idpf.rst new file +66 -0

66 lines not on this page · raw message

doc/guides/nics/index.rst +1 -0
index 4d40ea29a3..12841ce407 100644
@@ -34,6 +34,7 @@ Network Interface Controller Drivers
     hns3
     i40e
     ice
+    idpf
     igb
     igc
     ionic
doc/guides/rel_notes/release_22_11.rst +6 -0
index 28812e092f..77674f2b06 100644
@@ -158,6 +158,12 @@ New Features
 
   * Added protocol based buffer split support in scalar path.
 
+* **Added IDPF PMD [*EXPERIMENTAL*].**
+
+  Added the new ``idpf`` net driver for Intel® Infrastructure Processing Unit
+  (Intel® IPU) E2000.
+  See the :doc:`../nics/idpf` NIC guide for more details on this new driver.
+
 * **Updated Marvell cnxk driver.**
 
   * Added support for flow action REPRESENTED_PORT.
drivers/net/idpf/idpf_ethdev.c new file +891 -0

891 lines not on this page · raw message

drivers/net/idpf/idpf_ethdev.h new file +189 -0

189 lines not on this page · raw message

drivers/net/idpf/idpf_logs.h new file +56 -0

56 lines not on this page · raw message

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

416 lines not on this page · raw message

drivers/net/idpf/meson.build new file +15 -0
new file mode 100644
index 0000000000..ecf73355c3
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
+deps += ['common_idpf']
+
+sources = files(
+    'idpf_ethdev.c',
+    'idpf_vchnl.c',
+)
drivers/net/idpf/version.map new file +3 -0
new file mode 100644
index 0000000000..78c3585d7c
@@ -0,0 +1,3 @@
+DPDK_23 {
+	local: *;
+};
drivers/net/meson.build +1 -0
index 589399400a..6470bf3636 100644
@@ -29,6 +29,7 @@ drivers = [
         'i40e',
         'iavf',
         'ice',
+        'idpf',
         'igc',
         'ionic',
         'ipn3ke',
Signature · 1 line
2.26.2
#173 lore raw

PATCH v17 3/18 net/idpf: add Tx queue setup

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add support for tx_queue_setup ops.

In the single queue model, the same descriptor queue is used by SW to post buffer descriptors to HW and by HW to post completed descriptors to SW.

In the split queue model, "RX buffer queues" are used to pass descriptor buffers from SW to HW while Rx queues are used only to pass the descriptor completions, that is, descriptors that point to completed buffers, from HW to SW. This is contrary to the single queue model in which Rx queues are used for both purposes.

---
 drivers/net/idpf/idpf_ethdev.c |  13 ++
 drivers/net/idpf/idpf_rxtx.c   | 364 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  70 +++++++
 drivers/net/idpf/meson.build   |   1 +
 4 files changed, 448 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 +13 -0
index 035f563275..54f20d30ca 100644
@@ -11,6 +11,7 @@
 #include <errno.h>
 
 #include "idpf_ethdev.h"
+#include "idpf_rxtx.h"
 
 #define IDPF_TX_SINGLE_Q	"tx_single"
 #define IDPF_RX_SINGLE_Q	"rx_single"
@@ -42,6 +43,17 @@ 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->default_txconf = (struct rte_eth_txconf) {
+		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
+		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
+	};
+
+	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;
 }
 
@@ -631,6 +643,7 @@ idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
 static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_configure			= idpf_dev_configure,
 	.dev_close			= idpf_dev_close,
+	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
 };
 
drivers/net/idpf/idpf_rxtx.c new file +364 -0

364 lines not on this page · raw message

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

70 lines not on this page · raw message

drivers/net/idpf/meson.build +1 -0
index ecf73355c3..b632b76656 100644
@@ -11,5 +11,6 @@ deps += ['common_idpf']
 
 sources = files(
     'idpf_ethdev.c',
+    'idpf_rxtx.c',
     'idpf_vchnl.c',
 )
Signature · 1 line
2.26.2
#174 lore raw

PATCH v17 4/18 net/idpf: add Rx queue setup

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add support for rx_queue_setup ops.

---
 drivers/net/idpf/idpf_ethdev.c |  11 +
 drivers/net/idpf/idpf_rxtx.c   | 400 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  46 ++++
 3 files changed, 457 insertions(+)
drivers/net/idpf/idpf_ethdev.c +11 -0
index 54f20d30ca..fb5cd1b111 100644
@@ -48,12 +48,22 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
 	};
 
+	dev_info->default_rxconf = (struct rte_eth_rxconf) {
+		.rx_free_thresh = IDPF_DEFAULT_RX_FREE_THRESH,
+	};
+
 	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->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,
+	};
+
 	return 0;
 }
 
@@ -643,6 +653,7 @@ idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
 static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_configure			= idpf_dev_configure,
 	.dev_close			= idpf_dev_close,
+	.rx_queue_setup			= idpf_rx_queue_setup,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
 };
drivers/net/idpf/idpf_rxtx.c +400 -0

418 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +46 -0

61 lines not on this page · raw message

Signature · 1 line
2.26.2
#175 lore raw

PATCH v17 5/18 net/idpf: add support for device start and stop

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add dev ops dev_start, dev_stop and link_update.

---
 drivers/net/idpf/idpf_ethdev.c | 55 ++++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.c   | 20 +++++++++++++
 2 files changed, 75 insertions(+)
drivers/net/idpf/idpf_ethdev.c +55 -0
index fb5cd1b111..621bf9aad5 100644
@@ -29,6 +29,22 @@ static const char * const idpf_valid_args[] = {
 	NULL
 };
 
+static int
+idpf_dev_link_update(struct rte_eth_dev *dev,
+		     __rte_unused int wait_to_complete)
+{
+	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_autoneg = !(dev->data->dev_conf.link_speeds &
+				  RTE_ETH_LINK_SPEED_FIXED);
+
+	return rte_eth_linkstatus_set(dev, &new_link);
+}
+
 static int
 idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
@@ -267,6 +283,42 @@ idpf_dev_configure(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;
+	int ret;
+
+	if (dev->data->mtu > vport->max_mtu) {
+		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
+		return -EINVAL;
+	}
+
+	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
+
+	/* TODO: start queues */
+
+	ret = idpf_vc_ena_dis_vport(vport, true);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to enable vport");
+		return ret;
+	}
+
+	return 0;
+}
+
+static int
+idpf_dev_stop(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+
+	idpf_vc_ena_dis_vport(vport, false);
+
+	/* TODO: stop queues */
+
+	return 0;
+}
+
 static int
 idpf_dev_close(struct rte_eth_dev *dev)
 {
@@ -656,6 +708,9 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.rx_queue_setup			= idpf_rx_queue_setup,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
+	.dev_start			= idpf_dev_start,
+	.dev_stop			= idpf_dev_stop,
+	.link_update			= idpf_dev_link_update,
 };
 
 static uint16_t
drivers/net/idpf/idpf_rxtx.c +20 -0
index 25dd5d85d5..3528d2f2c7 100644
@@ -334,6 +334,11 @@ idpf_rx_split_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	if (check_rx_thresh(nb_desc, rx_free_thresh) != 0)
 		return -EINVAL;
 
+	if (rx_conf->rx_deferred_start) {
+		PMD_INIT_LOG(ERR, "Queue start is not supported currently.");
+		return -EINVAL;
+	}
+
 	/* Setup Rx description queue */
 	rxq = rte_zmalloc_socket("idpf rxq",
 				 sizeof(struct idpf_rx_queue),
@@ -465,6 +470,11 @@ idpf_rx_single_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	if (check_rx_thresh(nb_desc, rx_free_thresh) != 0)
 		return -EINVAL;
 
+	if (rx_conf->rx_deferred_start) {
+		PMD_INIT_LOG(ERR, "Queue start is not supported currently.");
+		return -EINVAL;
+	}
+
 	/* Setup Rx description queue */
 	rxq = rte_zmalloc_socket("idpf rxq",
 				 sizeof(struct idpf_rx_queue),
@@ -569,6 +579,11 @@ idpf_tx_split_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	if (check_tx_thresh(nb_desc, tx_rs_thresh, tx_free_thresh) != 0)
 		return -EINVAL;
 
+	if (tx_conf->tx_deferred_start) {
+		PMD_INIT_LOG(ERR, "Queue start is not supported currently.");
+		return -EINVAL;
+	}
+
 	/* Allocate the TX queue data structure. */
 	txq = rte_zmalloc_socket("idpf split txq",
 				 sizeof(struct idpf_tx_queue),
@@ -691,6 +706,11 @@ idpf_tx_single_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	if (check_tx_thresh(nb_desc, tx_rs_thresh, tx_free_thresh) != 0)
 		return -EINVAL;
 
+	if (tx_conf->tx_deferred_start) {
+		PMD_INIT_LOG(ERR, "Queue start is not supported currently.");
+		return -EINVAL;
+	}
+
 	/* Allocate the TX queue data structure. */
 	txq = rte_zmalloc_socket("idpf txq",
 				 sizeof(struct idpf_tx_queue),
Signature · 1 line
2.26.2
#176 lore raw

PATCH v17 6/18 net/idpf: add support for queue start

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add support for these device ops:
- rx_queue_start
- tx_queue_start

---
 drivers/net/idpf/idpf_ethdev.c |  42 +++-
 drivers/net/idpf/idpf_ethdev.h |   9 +
 drivers/net/idpf/idpf_rxtx.c   | 237 +++++++++++++++--
 drivers/net/idpf/idpf_rxtx.h   |   6 +
 drivers/net/idpf/idpf_vchnl.c  | 447 +++++++++++++++++++++++++++++++++
 5 files changed, 720 insertions(+), 21 deletions(-)
drivers/net/idpf/idpf_ethdev.c +41 -1
index 621bf9aad5..0400ed611f 100644
@@ -283,6 +283,39 @@ idpf_dev_configure(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 == NULL || txq->tx_deferred_start)
+			continue;
+		err = idpf_tx_queue_start(dev, i);
+		if (err != 0) {
+			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 == NULL || rxq->rx_deferred_start)
+			continue;
+		err = idpf_rx_queue_start(dev, i);
+		if (err != 0) {
+			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)
 {
@@ -296,11 +329,16 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
 
-	/* TODO: start queues */
+	ret = idpf_start_queues(dev);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to start queues");
+		return ret;
+	}
 
 	ret = idpf_vc_ena_dis_vport(vport, true);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
+		/* TODO: stop queues */
 		return ret;
 	}
 
@@ -711,6 +749,8 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_start			= idpf_dev_start,
 	.dev_stop			= idpf_dev_stop,
 	.link_update			= idpf_dev_link_update,
+	.rx_queue_start			= idpf_rx_queue_start,
+	.tx_queue_start			= idpf_tx_queue_start,
 };
 
 static uint16_t
drivers/net/idpf/idpf_ethdev.h +9 -0
index 84ae6641e2..96c22009e9 100644
@@ -24,7 +24,9 @@
 #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
@@ -182,6 +184,13 @@ int idpf_vc_check_api_version(struct idpf_adapter *adapter);
 int idpf_vc_get_caps(struct idpf_adapter *adapter);
 int idpf_vc_create_vport(struct idpf_adapter *adapter);
 int idpf_vc_destroy_vport(struct idpf_vport *vport);
+int idpf_vc_config_rxqs(struct idpf_vport *vport);
+int idpf_vc_config_rxq(struct idpf_vport *vport, uint16_t rxq_id);
+int idpf_vc_config_txqs(struct idpf_vport *vport);
+int idpf_vc_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_vc_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_vc_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 +217 -20

288 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +6 -0
index 3f3932c3eb..ab9b3830fd 100644
@@ -50,6 +50,7 @@ struct idpf_rx_queue {
 
 	bool q_set;             /* if rx queue has been configured */
 	bool q_started;         /* if rx queue has been started */
+	bool rx_deferred_start; /* don't start this queue in dev start */
 
 	/* only valid for split queue mode */
 	uint8_t expected_gen_id;
@@ -95,6 +96,7 @@ struct idpf_tx_queue {
 
 	bool q_set;		/* if tx queue has been configured */
 	bool q_started;		/* if tx queue has been started */
+	bool tx_deferred_start; /* don't start this queue in dev start */
 
 	/* only valid for split queue mode */
 	uint16_t sw_nb_desc;
@@ -109,8 +111,12 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_rxconf *rx_conf,
 			struct rte_mempool *mp);
+int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
+int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
+int idpf_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 
 #endif /* _IDPF_RXTX_H_ */
drivers/net/idpf/idpf_vchnl.c +447 -0

465 lines not on this page · raw message

Signature · 1 line
2.26.2
#177 lore raw

PATCH v17 7/18 net/idpf: add support for queue stop

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add support for these device ops:
- rx_queue_stop
- tx_queue_stop

---
 drivers/net/idpf/idpf_ethdev.c |  17 ++--
 drivers/net/idpf/idpf_rxtx.c   | 148 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  13 +++
 drivers/net/idpf/idpf_vchnl.c  |  69 +++++++++++++++
 4 files changed, 242 insertions(+), 5 deletions(-)
drivers/net/idpf/idpf_ethdev.c +12 -5
index 0400ed611f..9f1e1e6a18 100644
@@ -324,7 +324,8 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	if (dev->data->mtu > vport->max_mtu) {
 		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto err_mtu;
 	}
 
 	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
@@ -332,17 +333,21 @@ idpf_dev_start(struct rte_eth_dev *dev)
 	ret = idpf_start_queues(dev);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
-		return ret;
+		goto err_mtu;
 	}
 
 	ret = idpf_vc_ena_dis_vport(vport, true);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
-		/* TODO: stop queues */
-		return ret;
+		goto err_vport;
 	}
 
 	return 0;
+
+err_vport:
+	idpf_stop_queues(dev);
+err_mtu:
+	return ret;
 }
 
 static int
@@ -352,7 +357,7 @@ idpf_dev_stop(struct rte_eth_dev *dev)
 
 	idpf_vc_ena_dis_vport(vport, false);
 
-	/* TODO: stop queues */
+	idpf_stop_queues(dev);
 
 	return 0;
 }
@@ -751,6 +756,8 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.link_update			= idpf_dev_link_update,
 	.rx_queue_start			= idpf_rx_queue_start,
 	.tx_queue_start			= idpf_tx_queue_start,
+	.rx_queue_stop			= idpf_rx_queue_stop,
+	.tx_queue_stop			= idpf_tx_queue_stop,
 };
 
 static uint16_t
drivers/net/idpf/idpf_rxtx.c +148 -0

187 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +13 -0
index ab9b3830fd..b959638489 100644
@@ -51,6 +51,7 @@ struct idpf_rx_queue {
 	bool q_set;             /* if rx queue has been configured */
 	bool q_started;         /* if rx queue has been started */
 	bool rx_deferred_start; /* don't start this queue in dev start */
+	const struct idpf_rxq_ops *ops;
 
 	/* only valid for split queue mode */
 	uint8_t expected_gen_id;
@@ -97,6 +98,7 @@ struct idpf_tx_queue {
 	bool q_set;		/* if tx queue has been configured */
 	bool q_started;		/* if tx queue has been started */
 	bool tx_deferred_start; /* don't start this queue in dev start */
+	const struct idpf_txq_ops *ops;
 
 	/* only valid for split queue mode */
 	uint16_t sw_nb_desc;
@@ -107,16 +109,27 @@ struct idpf_tx_queue {
 	struct idpf_tx_queue *complq;
 };
 
+struct idpf_rxq_ops {
+	void (*release_mbufs)(struct idpf_rx_queue *rxq);
+};
+
+struct idpf_txq_ops {
+	void (*release_mbufs)(struct idpf_tx_queue *txq);
+};
+
 int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_rxconf *rx_conf,
 			struct rte_mempool *mp);
 int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int idpf_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
 int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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_stop_queues(struct rte_eth_dev *dev);
 #endif /* _IDPF_RXTX_H_ */
drivers/net/idpf/idpf_vchnl.c +69 -0

75 lines not on this page · raw message

Signature · 1 line
2.26.2
#178 lore raw

PATCH v17 8/18 net/idpf: add queue release

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add support for queue operations:
- rx_queue_release
- tx_queue_release

---
 drivers/net/idpf/idpf_ethdev.c |  2 +
 drivers/net/idpf/idpf_rxtx.c   | 81 ++++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  3 ++
 3 files changed, 86 insertions(+)
drivers/net/idpf/idpf_ethdev.c +2 -0
index 9f1e1e6a18..1485f40e71 100644
@@ -758,6 +758,8 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.tx_queue_start			= idpf_tx_queue_start,
 	.rx_queue_stop			= idpf_rx_queue_stop,
 	.tx_queue_stop			= idpf_tx_queue_stop,
+	.rx_queue_release		= idpf_dev_rx_queue_release,
+	.tx_queue_release		= idpf_dev_tx_queue_release,
 };
 
 static uint16_t
drivers/net/idpf/idpf_rxtx.c +81 -0

117 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +3 -0
index b959638489..37944edcac 100644
@@ -124,12 +124,15 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+void idpf_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
+
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
 int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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);
 
 void idpf_stop_queues(struct rte_eth_dev *dev);
 #endif /* _IDPF_RXTX_H_ */
Signature · 1 line
2.26.2
#179 lore raw

PATCH v17 9/18 net/idpf: add support for MTU configuration

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add dev ops mtu_set.

---
 doc/guides/nics/features/idpf.ini |  1 +
 drivers/net/idpf/idpf_ethdev.c    | 13 +++++++++++++
 2 files changed, 14 insertions(+)
doc/guides/nics/features/idpf.ini +1 -0
index 46aab2eb61..d722c49fde 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+MTU update           = Y
 Linux                = Y
 x86-32               = Y
 x86-64               = Y
drivers/net/idpf/idpf_ethdev.c +13 -0
index 1485f40e71..856f3d7266 100644
@@ -83,6 +83,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)
 {
@@ -760,6 +772,7 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.tx_queue_stop			= idpf_tx_queue_stop,
 	.rx_queue_release		= idpf_dev_rx_queue_release,
 	.tx_queue_release		= idpf_dev_tx_queue_release,
+	.mtu_set			= idpf_dev_mtu_set,
 };
 
 static uint16_t
Signature · 1 line
2.26.2
#180 lore raw

PATCH v17 10/18 net/idpf: add support for basic Rx datapath

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add basic Rx support in split queue mode and single queue mode.

---
 drivers/net/idpf/idpf_ethdev.c |   2 +
 drivers/net/idpf/idpf_rxtx.c   | 273 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |   7 +-
 3 files changed, 281 insertions(+), 1 deletion(-)
drivers/net/idpf/idpf_ethdev.c +2 -0
index 856f3d7266..2f1f9eeee5 100644
@@ -348,6 +348,8 @@ idpf_dev_start(struct rte_eth_dev *dev)
 		goto err_mtu;
 	}
 
+	idpf_set_rx_function(dev);
+
 	ret = idpf_vc_ena_dis_vport(vport, true);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
drivers/net/idpf/idpf_rxtx.c +273 -0

276 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +6 -1
index 37944edcac..650c6c1c3a 100644
@@ -133,6 +133,11 @@ int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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);
 void idpf_stop_queues(struct rte_eth_dev *dev);
+
+void idpf_set_rx_function(struct rte_eth_dev *dev);
 #endif /* _IDPF_RXTX_H_ */
Signature · 1 line
2.26.2
#181 lore raw

PATCH v17 11/18 net/idpf: add support for basic Tx datapath

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add basic Tx support in split queue mode and single queue mode.

---
 drivers/net/idpf/idpf_ethdev.c |   3 +
 drivers/net/idpf/idpf_ethdev.h |   1 +
 drivers/net/idpf/idpf_rxtx.c   | 357 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  10 +
 4 files changed, 371 insertions(+)
drivers/net/idpf/idpf_ethdev.c +3 -0
index 2f1f9eeee5..f9f6fe1162 100644
@@ -59,6 +59,8 @@ 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->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+
 	dev_info->default_txconf = (struct rte_eth_txconf) {
 		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
 		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
@@ -349,6 +351,7 @@ idpf_dev_start(struct rte_eth_dev *dev)
 	}
 
 	idpf_set_rx_function(dev);
+	idpf_set_tx_function(dev);
 
 	ret = idpf_vc_ena_dis_vport(vport, true);
 	if (ret != 0) {
drivers/net/idpf/idpf_ethdev.h +1 -0
index 96c22009e9..af0a8e2970 100644
@@ -35,6 +35,7 @@
 
 #define IDPF_MIN_BUF_SIZE	1024
 #define IDPF_MAX_FRAME_SIZE	9728
+#define IDPF_MIN_FRAME_SIZE	14
 
 #define IDPF_NUM_MACADDR_MAX	64
 
drivers/net/idpf/idpf_rxtx.c +357 -0

372 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +10 -0
index 650c6c1c3a..30dc94b3dd 100644
@@ -21,6 +21,8 @@
 #define IDPF_DEFAULT_TX_RS_THRESH	32
 #define IDPF_DEFAULT_TX_FREE_THRESH	32
 
+#define IDPF_TX_MAX_MTU_SEG	10
+
 struct idpf_rx_queue {
 	struct idpf_adapter *adapter;   /* the adapter this queue belongs to */
 	struct rte_mempool *mp;         /* mbuf pool to populate Rx ring */
@@ -137,7 +139,15 @@ 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);
 #endif /* _IDPF_RXTX_H_ */
Signature · 1 line
2.26.2
#182 lore raw

PATCH v17 12/18 net/idpf: support parsing packet type

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Parse packet type during receiving packets.

---
 drivers/net/idpf/idpf_ethdev.c |   6 +
 drivers/net/idpf/idpf_ethdev.h |   6 +
 drivers/net/idpf/idpf_rxtx.c   |  11 ++
 drivers/net/idpf/idpf_rxtx.h   |   5 +
 drivers/net/idpf/idpf_vchnl.c  | 240 +++++++++++++++++++++++++++++++++
 5 files changed, 268 insertions(+)
drivers/net/idpf/idpf_ethdev.c +6 -0
index f9f6fe1162..d0821ec3f3 100644
@@ -686,6 +686,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 != 0) {
+		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 == NULL) {
drivers/net/idpf/idpf_ethdev.h +6 -0
index af0a8e2970..db9af58f72 100644
@@ -39,6 +39,8 @@
 
 #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)
@@ -125,6 +127,8 @@ struct idpf_adapter {
 	/* 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;
 };
 
 TAILQ_HEAD(idpf_adapter_list, idpf_adapter);
@@ -182,6 +186,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_vc_check_api_version(struct idpf_adapter *adapter);
+int idpf_get_pkt_type(struct idpf_adapter *adapter);
 int idpf_vc_get_caps(struct idpf_adapter *adapter);
 int idpf_vc_create_vport(struct idpf_adapter *adapter);
 int idpf_vc_destroy_vport(struct idpf_vport *vport);
@@ -193,6 +198,7 @@ int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,
 		      bool rx, bool on);
 int idpf_vc_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_vc_ena_dis_vport(struct idpf_vport *vport, bool enable);
+int idpf_vc_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 +11 -0
index f55d2143b9..a980714060 100644
@@ -1281,6 +1281,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	volatile struct virtchnl2_rx_flex_desc_adv_nic_3 *rx_desc;
 	uint16_t pktlen_gen_bufq_id;
 	struct idpf_rx_queue *rxq;
+	const uint32_t *ptype_tbl;
 	struct rte_mbuf *rxm;
 	uint16_t rx_id_bufq1;
 	uint16_t rx_id_bufq2;
@@ -1300,6 +1301,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	rx_id_bufq1 = rxq->bufq1->rx_next_avail;
 	rx_id_bufq2 = rxq->bufq2->rx_next_avail;
 	rx_desc_ring = rxq->rx_ring;
+	ptype_tbl = rxq->adapter->ptype_tbl;
 
 	while (nb_rx < nb_pkts) {
 		rx_desc = &rx_desc_ring[rx_id];
@@ -1347,6 +1349,10 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		rxm->next = NULL;
 		rxm->nb_segs = 1;
 		rxm->port = rxq->port_id;
+		rxm->packet_type =
+			ptype_tbl[(rte_le_to_cpu_16(rx_desc->ptype_err_fflags0) &
+				   VIRTCHNL2_RX_FLEX_DESC_ADV_PTYPE_M) >>
+				  VIRTCHNL2_RX_FLEX_DESC_ADV_PTYPE_S];
 
 		rx_pkts[nb_rx++] = rxm;
 	}
@@ -1533,6 +1539,7 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	volatile union virtchnl2_rx_desc *rxdp;
 	union virtchnl2_rx_desc rxd;
 	struct idpf_rx_queue *rxq;
+	const uint32_t *ptype_tbl;
 	uint16_t rx_id, nb_hold;
 	struct rte_eth_dev *dev;
 	uint16_t rx_packet_len;
@@ -1551,6 +1558,7 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 
 	rx_id = rxq->rx_tail;
 	rx_ring = rxq->rx_ring;
+	ptype_tbl = rxq->adapter->ptype_tbl;
 
 	while (nb_rx < nb_pkts) {
 		rxdp = &rx_ring[rx_id];
@@ -1603,6 +1611,9 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		rxm->pkt_len = rx_packet_len;
 		rxm->data_len = rx_packet_len;
 		rxm->port = rxq->port_id;
+		rxm->packet_type =
+			ptype_tbl[(uint8_t)(rte_cpu_to_le_16(rxd.flex_nic_wb.ptype_flex_flags0) &
+					    VIRTCHNL2_RX_FLEX_DESC_PTYPE_M)];
 
 		rx_pkts[nb_rx++] = rxm;
 	}
drivers/net/idpf/idpf_rxtx.h +5 -0
index 30dc94b3dd..3853ed55c9 100644
@@ -23,6 +23,10 @@
 
 #define IDPF_TX_MAX_MTU_SEG	10
 
+#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 */
@@ -150,4 +154,5 @@ 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);
+
 #endif /* _IDPF_RXTX_H_ */
drivers/net/idpf/idpf_vchnl.c +240 -0

255 lines not on this page · raw message

Signature · 1 line
2.26.2
#183 lore raw

PATCH v17 13/18 net/idpf: add support for write back based on ITR expire

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Enable write back on ITR expire, then packets can be received one by one.

---
 drivers/net/idpf/idpf_ethdev.c | 120 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h |  13 ++++
 drivers/net/idpf/idpf_vchnl.c  | 113 +++++++++++++++++++++++++++++++
 3 files changed, 246 insertions(+)
drivers/net/idpf/idpf_ethdev.c +120 -0
index d0821ec3f3..957cc10616 100644
@@ -297,6 +297,90 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
+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 idpf_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 == NULL) {
+		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 should be
+	 * compared with bit VIRTCHNL2_CAP_WB_ON_ITR here. The if
+	 * condition should be updated when the FW can return the
+	 * correct flag bits.
+	 */
+	dynctl_reg_start =
+		vport->recv_vectors->vchunks.vchunks->dynctl_reg_start;
+	itrn_reg_start =
+		vport->recv_vectors->vchunks.vchunks->itrn_reg_start;
+	dynctl_val = IDPF_READ_REG(hw, dynctl_reg_start);
+	PMD_DRV_LOG(DEBUG, "Value of dynctl_reg_start is 0x%x",
+		    dynctl_val);
+	itrn_val = IDPF_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 written back based on ITR expiration irrespective
+	 * of INTENA setting.
+	 */
+	/* TBD: need to tune INTERVAL value for better performance. */
+	if (itrn_val != 0)
+		IDPF_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
+		IDPF_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_vc_config_irq_map_unmap(vport, true) != 0) {
+		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)
 {
@@ -334,6 +418,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;
 	int ret;
 
 	if (dev->data->mtu > vport->max_mtu) {
@@ -344,6 +432,27 @@ 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);
+		ret = -EINVAL;
+		goto err_mtu;
+	}
+
+	ret = idpf_vc_alloc_vectors(vport, req_vecs_num);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to allocate interrupt vectors");
+		goto err_mtu;
+	}
+	adapter->used_vecs_num += req_vecs_num;
+
+	ret = idpf_config_rx_queues_irqs(dev);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to configure irqs");
+		goto err_mtu;
+	}
+
 	ret = idpf_start_queues(dev);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
@@ -376,6 +485,10 @@ idpf_dev_stop(struct rte_eth_dev *dev)
 
 	idpf_stop_queues(dev);
 
+	idpf_vc_config_irq_map_unmap(vport, false);
+
+	idpf_vc_dealloc_vectors(vport);
+
 	return 0;
 }
 
@@ -387,6 +500,11 @@ idpf_dev_close(struct rte_eth_dev *dev)
 
 	idpf_vc_destroy_vport(vport);
 
+	rte_free(vport->recv_vectors);
+	vport->recv_vectors = NULL;
+
+	rte_free(vport->qv_map);
+	vport->qv_map = NULL;
 
 	adapter->cur_vports &= ~RTE_BIT32(vport->devarg_id);
 
@@ -748,6 +866,8 @@ idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
 	adapter->cur_vports = 0;
 	adapter->cur_vport_nb = 0;
 
+	adapter->used_vecs_num = 0;
+
 	return ret;
 
 err_vports:
drivers/net/idpf/idpf_ethdev.h +13 -0
index db9af58f72..811240c386 100644
@@ -33,6 +33,9 @@
 #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_MIN_BUF_SIZE	1024
 #define IDPF_MAX_FRAME_SIZE	9728
 #define IDPF_MIN_FRAME_SIZE	14
@@ -92,6 +95,11 @@ struct idpf_vport {
 	struct rte_eth_dev_data *dev_data; /* Pointer to the device data */
 	uint16_t max_pkt_len; /* Maximum packet length */
 
+	/* 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;
 
@@ -124,6 +132,8 @@ struct idpf_adapter {
 	uint16_t cur_vport_nb;
 	uint16_t cur_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;
@@ -198,6 +208,9 @@ int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,
 		      bool rx, bool on);
 int idpf_vc_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_vc_ena_dis_vport(struct idpf_vport *vport, bool enable);
+int idpf_vc_config_irq_map_unmap(struct idpf_vport *vport, bool map);
+int idpf_vc_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors);
+int idpf_vc_dealloc_vectors(struct idpf_vport *vport);
 int idpf_vc_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 +113 -0

131 lines not on this page · raw message

Signature · 1 line
2.26.2
#184 lore raw

PATCH v17 14/18 net/idpf: add support for RSS

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add RSS support.

---
 drivers/net/idpf/idpf_ethdev.c | 120 ++++++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_ethdev.h |  26 +++++++
 drivers/net/idpf/idpf_vchnl.c  | 113 +++++++++++++++++++++++++++++++
 3 files changed, 258 insertions(+), 1 deletion(-)
drivers/net/idpf/idpf_ethdev.c +119 -1
index 957cc10616..58560ea404 100644
@@ -59,6 +59,8 @@ 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->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
 	dev_info->default_txconf = (struct rte_eth_txconf) {
@@ -169,6 +171,8 @@ idpf_parse_devarg_id(char *name)
 	return val;
 }
 
+#define IDPF_RSS_KEY_LEN 52
+
 static int
 idpf_init_vport(struct rte_eth_dev *dev)
 {
@@ -189,6 +193,10 @@ idpf_init_vport(struct rte_eth_dev *dev)
 	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++) {
@@ -246,17 +254,110 @@ idpf_init_vport(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+idpf_config_rss(struct idpf_vport *vport)
+{
+	int ret;
+
+	ret = idpf_vc_set_rss_key(vport);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS key");
+		return ret;
+	}
+
+	ret = idpf_vc_set_rss_lut(vport);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS lut");
+		return ret;
+	}
+
+	ret = idpf_vc_set_rss_hash(vport);
+	if (ret != 0) {
+		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 = rte_zmalloc("rss_key",
+				     vport->rss_key_size, 0);
+	if (vport->rss_key == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS key");
+		ret = -ENOMEM;
+		goto err_alloc_key;
+	}
+
+	lut_size = vport->rss_lut_size;
+	vport->rss_lut = rte_zmalloc("rss_lut",
+				     sizeof(uint32_t) * lut_size, 0);
+	if (vport->rss_lut == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS lut");
+		ret = -ENOMEM;
+		goto err_alloc_lut;
+	}
+
+	if (rss_conf->rss_key == NULL) {
+		for (i = 0; i < vport->rss_key_size; i++)
+			vport->rss_key[i] = (uint8_t)rte_rand();
+	} else if (rss_conf->rss_key_len != vport->rss_key_size) {
+		PMD_INIT_LOG(ERR, "Invalid RSS key length in RSS configuration, should be %d",
+			     vport->rss_key_size);
+		ret = -EINVAL;
+		goto err_cfg_key;
+	} else {
+		rte_memcpy(vport->rss_key, rss_conf->rss_key,
+			   vport->rss_key_size);
+	}
+
+	for (i = 0; i < lut_size; i++)
+		vport->rss_lut[i] = i % nb_q;
+
+	vport->rss_hf = IDPF_DEFAULT_RSS_HASH_EXPANDED;
+
+	ret = idpf_config_rss(vport);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS");
+		goto err_cfg_key;
+	}
+
+	return ret;
+
+err_cfg_key:
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+err_alloc_lut:
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+err_alloc_key:
+	return ret;
+}
+
 static int
 idpf_dev_configure(struct rte_eth_dev *dev)
 {
+	struct idpf_vport *vport = dev->data->dev_private;
 	struct rte_eth_conf *conf = &dev->data->dev_conf;
+	struct idpf_adapter *adapter = vport->adapter;
+	int ret;
 
 	if (conf->link_speeds & RTE_ETH_LINK_SPEED_FIXED) {
 		PMD_INIT_LOG(ERR, "Setting link speed is not supported");
 		return -ENOTSUP;
 	}
 
-	if (dev->data->nb_rx_queues == 1 && conf->rxmode.mq_mode != RTE_ETH_MQ_RX_NONE) {
+	if ((dev->data->nb_rx_queues == 1 && conf->rxmode.mq_mode != RTE_ETH_MQ_RX_NONE) ||
+	    (dev->data->nb_rx_queues > 1 && conf->rxmode.mq_mode != RTE_ETH_MQ_RX_RSS)) {
 		PMD_INIT_LOG(ERR, "Multi-queue packet distribution mode %d is not supported",
 			     conf->rxmode.mq_mode);
 		return -ENOTSUP;
@@ -294,6 +395,17 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 		return -ENOTSUP;
 	}
 
+	if (adapter->caps->rss_caps != 0 && dev->data->nb_rx_queues != 0) {
+		ret = idpf_init_rss(vport);
+		if (ret != 0) {
+			PMD_INIT_LOG(ERR, "Failed to init rss");
+			return ret;
+		}
+	} else {
+		PMD_INIT_LOG(ERR, "RSS is not supported.");
+		return -1;
+	}
+
 	return 0;
 }
 
@@ -500,6 +612,12 @@ idpf_dev_close(struct rte_eth_dev *dev)
 
 	idpf_vc_destroy_vport(vport);
 
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+
 	rte_free(vport->recv_vectors);
 	vport->recv_vectors = NULL;
 
drivers/net/idpf/idpf_ethdev.h +26 -0
index 811240c386..8d0804f603 100644
@@ -48,6 +48,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)
+
 #define IDPF_ADAPTER_NAME_LEN	(PCI_PRI_STR_SIZE + 1)
 
 /* Message type read in virtual channel from PF */
@@ -90,11 +104,20 @@ struct idpf_vport {
 	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;
@@ -200,6 +223,9 @@ int idpf_get_pkt_type(struct idpf_adapter *adapter);
 int idpf_vc_get_caps(struct idpf_adapter *adapter);
 int idpf_vc_create_vport(struct idpf_adapter *adapter);
 int idpf_vc_destroy_vport(struct idpf_vport *vport);
+int idpf_vc_set_rss_key(struct idpf_vport *vport);
+int idpf_vc_set_rss_lut(struct idpf_vport *vport);
+int idpf_vc_set_rss_hash(struct idpf_vport *vport);
 int idpf_vc_config_rxqs(struct idpf_vport *vport);
 int idpf_vc_config_rxq(struct idpf_vport *vport, uint16_t rxq_id);
 int idpf_vc_config_txqs(struct idpf_vport *vport);
drivers/net/idpf/idpf_vchnl.c +113 -0

131 lines not on this page · raw message

Signature · 1 line
2.26.2
#185 lore raw

PATCH v17 15/18 net/idpf: add support for Rx offloading

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add Rx offloading support:
- support CHKSUM and RSS offload for split queue model
- support CHKSUM offload for single queue model

---
 doc/guides/nics/features/idpf.ini |   5 ++
 drivers/net/idpf/idpf_ethdev.c    |   6 ++
 drivers/net/idpf/idpf_rxtx.c      | 123 ++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_vchnl.c     |  18 +++++
 4 files changed, 152 insertions(+)
doc/guides/nics/features/idpf.ini +5 -0
index d722c49fde..868571654f 100644
@@ -3,8 +3,13 @@
 ;
 ; Refer to default.ini for the full list of available PMD features.
 ;
+; A feature with "P" indicates only be supported when non-vector path
+; is selected.
+;
 [Features]
 MTU update           = Y
+L3 checksum offload  = P
+L4 checksum offload  = P
 Linux                = Y
 x86-32               = Y
 x86-64               = Y
drivers/net/idpf/idpf_ethdev.c +6 -0
index 58560ea404..a09f104425 100644
@@ -61,6 +61,12 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->flow_type_rss_offloads = IDPF_RSS_OFFLOAD_ALL;
 
+	dev_info->rx_offload_capa =
+		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;
+
 	dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
 	dev_info->default_txconf = (struct rte_eth_txconf) {
drivers/net/idpf/idpf_rxtx.c +123 -0

171 lines not on this page · raw message

drivers/net/idpf/idpf_vchnl.c +18 -0
index 4ef354df89..00ac5b2a6b 100644
@@ -528,6 +528,24 @@ idpf_vc_get_caps(struct idpf_adapter *adapter)
 
 	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.rss_caps =
 		VIRTCHNL2_CAP_RSS_IPV4_TCP             |
 		VIRTCHNL2_CAP_RSS_IPV4_UDP             |
Signature · 1 line
2.26.2
#186 lore raw

PATCH v17 16/18 net/idpf: add support for Tx offloading

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add Tx offloading support:
- support TSO for single queue model and split queue model.

---
 doc/guides/nics/features/idpf.ini |   1 +
 drivers/net/idpf/idpf_ethdev.c    |   4 +-
 drivers/net/idpf/idpf_rxtx.c      | 128 +++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_rxtx.h      |  22 +++++
 4 files changed, 152 insertions(+), 3 deletions(-)
doc/guides/nics/features/idpf.ini +1 -0
index 868571654f..d82b4aa0ff 100644
@@ -8,6 +8,7 @@
 ;
 [Features]
 MTU update           = Y
+TSO                  = P
 L3 checksum offload  = P
 L4 checksum offload  = P
 Linux                = Y
drivers/net/idpf/idpf_ethdev.c +3 -1
index a09f104425..084426260c 100644
@@ -67,7 +67,9 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		RTE_ETH_RX_OFFLOAD_TCP_CKSUM            |
 		RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
 
-	dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+	dev_info->tx_offload_capa =
+		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
 	dev_info->default_txconf = (struct rte_eth_txconf) {
 		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
drivers/net/idpf/idpf_rxtx.c +126 -2

199 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +22 -0
index 3853ed55c9..54d297aac6 100644
@@ -23,6 +23,16 @@
 
 #define IDPF_TX_MAX_MTU_SEG	10
 
+#define IDPF_MIN_TSO_MSS	88
+#define IDPF_MAX_TSO_MSS	9728
+#define IDPF_MAX_TSO_FRAME_SIZE	262143
+#define IDPF_TX_MAX_MTU_SEG     10
+
+#define IDPF_TX_OFFLOAD_MASK RTE_MBUF_F_TX_TCP_SEG
+
+#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])))
@@ -115,6 +125,18 @@ struct idpf_tx_queue {
 	struct idpf_tx_queue *complq;
 };
 
+/* Offload features */
+union idpf_tx_offload {
+	uint64_t data;
+	struct {
+		uint64_t l2_len:7; /* L2 (MAC) Header Length. */
+		uint64_t l3_len:9; /* L3 (IP) Header Length. */
+		uint64_t l4_len:8; /* L4 Header Length. */
+		uint64_t tso_segsz:16; /* TCP TSO segment size */
+		/* uint64_t unused : 24; */
+	};
+};
+
 struct idpf_rxq_ops {
 	void (*release_mbufs)(struct idpf_rx_queue *rxq);
 };
Signature · 1 line
2.26.2
#187 lore raw

PATCH v17 17/18 net/idpf: add AVX512 data path for single queue model

In reply to [email protected]

From: Junfeng Guo <[email protected]>

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

---
 doc/guides/nics/idpf.rst                |  19 +
 drivers/net/idpf/idpf_ethdev.c          |   3 +-
 drivers/net/idpf/idpf_ethdev.h          |   5 +
 drivers/net/idpf/idpf_rxtx.c            | 145 ++++
 drivers/net/idpf/idpf_rxtx.h            |  21 +
 drivers/net/idpf/idpf_rxtx_vec_avx512.c | 871 ++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx_vec_common.h | 100 +++
 drivers/net/idpf/meson.build            |  28 +
 8 files changed, 1191 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
doc/guides/nics/idpf.rst +19 -0
index c1001d5d0c..3039c61748 100644
@@ -64,3 +64,22 @@ Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and
 for details.
 
 
+Features
+--------
+
+Vector PMD
+~~~~~~~~~~
+
+Vector path for RX and TX path are selected automatically. The paths
+are chosen based on 2 conditions.
+
+- ``CPU``
+  On the X86 platform, the driver checks if the CPU supports AVX512.
+  If the CPU supports AVX512 and EAL argument ``--force-max-simd-bitwidth``
+  is set to 512, AVX512 paths will be chosen.
+
+- ``Offload features``
+  The supported HW offload features are described in the document idpf.ini,
+  A value "P" means the offload feature is not supported by vector path.
+  If any not supported features are used, idpf vector PMD is disabled and the
+  scalar paths are chosen.
drivers/net/idpf/idpf_ethdev.c +2 -1
index 084426260c..cd4ebcc2c6 100644
@@ -69,7 +69,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->tx_offload_capa =
 		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
-		RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS		|
+		RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
 	dev_info->default_txconf = (struct rte_eth_txconf) {
 		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
drivers/net/idpf/idpf_ethdev.h +5 -0
index 8d0804f603..7d54e5db60 100644
@@ -162,6 +162,11 @@ struct idpf_adapter {
 	uint32_t max_txq_per_msg;
 
 	uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned;
+
+	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 +145 -0

185 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +21 -0
index 54d297aac6..506bf8a57d 100644
@@ -18,6 +18,12 @@
 #define IDPF_RX_MAX_BURST		32
 #define IDPF_DEFAULT_RX_FREE_THRESH	32
 
+/* used for Vector PMD */
+#define IDPF_VPMD_RX_MAX_BURST	32
+#define IDPF_VPMD_TX_MAX_BURST	32
+#define IDPF_VPMD_DESCS_PER_LOOP	4
+#define IDPF_RXQ_REARM_THRESH	64
+
 #define IDPF_DEFAULT_TX_RS_THRESH	32
 #define IDPF_DEFAULT_TX_FREE_THRESH	32
 
@@ -54,6 +60,11 @@ struct idpf_rx_queue {
 	struct rte_mbuf *pkt_last_seg;  /* last segment of current packet */
 	struct rte_mbuf fake_mbuf;      /* dummy mbuf */
 
+	/* used for VPMD */
+	uint16_t rxrearm_nb;       /* number of remaining to be re-armed */
+	uint16_t rxrearm_start;    /* the idx we start the re-arming from */
+	uint64_t mbuf_initializer; /* value to init mbufs */
+
 	uint16_t rx_nb_avail;
 	uint16_t rx_next_avail;
 
@@ -84,6 +95,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 */
@@ -149,6 +164,7 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_rxconf *rx_conf,
 			struct rte_mempool *mp);
+int idpf_singleq_tx_vec_setup_avx512(struct idpf_tx_queue *txq);
 int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
@@ -157,16 +173,21 @@ void idpf_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
+int idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq);
 int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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_singleq_recv_pkts_avx512(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_singleq_xmit_pkts_avx512(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,
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +871 -0

871 lines not on this page · raw message

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

100 lines not on this page · raw message

drivers/net/idpf/meson.build +28 -0
index b632b76656..da99c098ab 100644
@@ -14,3 +14,31 @@ sources = files(
     'idpf_rxtx.c',
     '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_common_idpf, 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
Signature · 1 line
2.26.2
#188 lore raw

PATCH v17 18/18 net/idpf: add support for timestamp offload

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add support for timestamp offload.

---
 doc/guides/nics/features/idpf.ini |  1 +
 drivers/net/idpf/idpf_ethdev.c    |  5 +-
 drivers/net/idpf/idpf_ethdev.h    |  3 ++
 drivers/net/idpf/idpf_rxtx.c      | 65 ++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h      | 90 +++++++++++++++++++++++++++++++
 5 files changed, 163 insertions(+), 1 deletion(-)
doc/guides/nics/features/idpf.ini +1 -0
index d82b4aa0ff..099fd7f216 100644
@@ -11,6 +11,7 @@ MTU update           = Y
 TSO                  = P
 L3 checksum offload  = P
 L4 checksum offload  = P
+Timestamp offload    = P
 Linux                = Y
 x86-32               = Y
 x86-64               = Y
drivers/net/idpf/idpf_ethdev.c +4 -1
index cd4ebcc2c6..50aac65daf 100644
@@ -22,6 +22,8 @@ rte_spinlock_t idpf_adapter_lock;
 struct idpf_adapter_list idpf_adapter_list;
 bool idpf_adapter_list_init;
 
+uint64_t idpf_timestamp_dynflag;
+
 static const char * const idpf_valid_args[] = {
 	IDPF_TX_SINGLE_Q,
 	IDPF_RX_SINGLE_Q,
@@ -65,7 +67,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		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_OUTER_IPV4_CKSUM     |
+		RTE_ETH_RX_OFFLOAD_TIMESTAMP;
 
 	dev_info->tx_offload_capa =
 		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
drivers/net/idpf/idpf_ethdev.h +3 -0
index 7d54e5db60..ccdf4abe40 100644
@@ -167,6 +167,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 +65 -0

140 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +90 -0

106 lines not on this page · raw message

Signature · 1 line
2.26.2
#189 lore raw

v18 cover add support for idpf PMD in DPDK

In reply to [email protected]

From: Beilei Xing <[email protected]>

This patchset introduced the idpf (Infrastructure Data Path Function) PMD in DPDK for Intel® IPU E2000 (Device ID: 0x1452). The Intel® IPU E2000 targets to deliver high performance under real workloads with security and isolation. Please refer to
https://www.intel.com/content/www/us/en/products/network-io/infrastructure-processing-units/asic/e2000-asic.html
for more information.

Linux upstream is still ongoing, previous work refers to https://patchwork.ozlabs.org/project/intel-wired-lan/patch/[email protected]/.

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

v5:
fixed typo.

v6-v9:
fixed build errors and coding style issues.

v11:
- move shared code to common/idpf/base
- Create one vport if there's no vport devargs
- Refactor if conditions according to coding style
- Refactor virtual channel return values
- Refine dev_stop function
- Refine RSS lut/key
- Fix build error

v12:
- Refine dev_configure
- Fix coding style according to the comments
- Re-order patch
- Romove dev_supported_ptypes_get

v13:
- refine dev_start/stop and queue_start/stop
- fix timestamp offload

v14:
- fix wrong position for rte_validate_tx_offload

v15:
- refine the return value for ethdev ops.
- removce forward static declarations.
- refine get caps.
- fix lock/unlock handling.

v16:
- refine errno in shared code
- remove the conditional compilation IDPF_RX_PTYPE_OFFLOAD

v17:
- fix build error on FreeBSD

v18:
- remove the conditional compilation IDPF_RX_PTYPE_OFFLOAD

Junfeng Guo (18):
common/idpf: introduce common library
net/idpf: add support for device initialization net/idpf: add Tx queue setup
net/idpf: add Rx queue setup
net/idpf: add support for device start and stop net/idpf: add support for queue start
net/idpf: add support for queue stop
net/idpf: add queue release
net/idpf: add support for MTU configuration net/idpf: add support for basic Rx datapath net/idpf: add support for basic Tx datapath net/idpf: support parsing packet type
net/idpf: add support for write back based on ITR expire net/idpf: add support for RSS
net/idpf: add support for Rx offloading net/idpf: add support for Tx offloading 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             |   17 +
 doc/guides/nics/idpf.rst                      |   85 +
 doc/guides/nics/index.rst                     |    1 +
 doc/guides/rel_notes/release_22_11.rst        |    6 +
 drivers/common/idpf/base/idpf_alloc.h         |   22 +
 drivers/common/idpf/base/idpf_common.c        |  364 +++
 drivers/common/idpf/base/idpf_controlq.c      |  691 ++++
 drivers/common/idpf/base/idpf_controlq.h      |  224 ++
 drivers/common/idpf/base/idpf_controlq_api.h  |  207 ++
 .../common/idpf/base/idpf_controlq_setup.c    |  179 +
 drivers/common/idpf/base/idpf_devids.h        |   18 +
 drivers/common/idpf/base/idpf_lan_pf_regs.h   |  134 +
 drivers/common/idpf/base/idpf_lan_txrx.h      |  428 +++
 drivers/common/idpf/base/idpf_lan_vf_regs.h   |  114 +
 drivers/common/idpf/base/idpf_osdep.h         |  364 +++
 drivers/common/idpf/base/idpf_prototype.h     |   45 +
 drivers/common/idpf/base/idpf_type.h          |  106 +
 drivers/common/idpf/base/meson.build          |   14 +
 drivers/common/idpf/base/siov_regs.h          |   47 +
 drivers/common/idpf/base/virtchnl.h           | 2866 +++++++++++++++++
 drivers/common/idpf/base/virtchnl2.h          | 1462 +++++++++
 drivers/common/idpf/base/virtchnl2_lan_desc.h |  606 ++++
 .../common/idpf/base/virtchnl_inline_ipsec.h  |  567 ++++
 drivers/common/idpf/meson.build               |    4 +
 drivers/common/idpf/version.map               |   12 +
 drivers/common/meson.build                    |    1 +
 drivers/net/idpf/idpf_ethdev.c                | 1293 ++++++++
 drivers/net/idpf/idpf_ethdev.h                |  252 ++
 drivers/net/idpf/idpf_logs.h                  |   56 +
 drivers/net/idpf/idpf_rxtx.c                  | 2308 +++++++++++++
 drivers/net/idpf/idpf_rxtx.h                  |  291 ++
 drivers/net/idpf/idpf_rxtx_vec_avx512.c       |  857 +++++
 drivers/net/idpf/idpf_rxtx_vec_common.h       |  100 +
 drivers/net/idpf/idpf_vchnl.c                 | 1416 ++++++++
 drivers/net/idpf/meson.build                  |   44 +
 drivers/net/idpf/version.map                  |    3 +
 drivers/net/meson.build                       |    1 +
 38 files changed, 15214 insertions(+)
 create mode 100644 doc/guides/nics/features/idpf.ini
 create mode 100644 doc/guides/nics/idpf.rst
 create mode 100644 drivers/common/idpf/base/idpf_alloc.h
 create mode 100644 drivers/common/idpf/base/idpf_common.c
 create mode 100644 drivers/common/idpf/base/idpf_controlq.c
 create mode 100644 drivers/common/idpf/base/idpf_controlq.h
 create mode 100644 drivers/common/idpf/base/idpf_controlq_api.h
 create mode 100644 drivers/common/idpf/base/idpf_controlq_setup.c
 create mode 100644 drivers/common/idpf/base/idpf_devids.h
 create mode 100644 drivers/common/idpf/base/idpf_lan_pf_regs.h
 create mode 100644 drivers/common/idpf/base/idpf_lan_txrx.h
 create mode 100644 drivers/common/idpf/base/idpf_lan_vf_regs.h
 create mode 100644 drivers/common/idpf/base/idpf_osdep.h
 create mode 100644 drivers/common/idpf/base/idpf_prototype.h
 create mode 100644 drivers/common/idpf/base/idpf_type.h
 create mode 100644 drivers/common/idpf/base/meson.build
 create mode 100644 drivers/common/idpf/base/siov_regs.h
 create mode 100644 drivers/common/idpf/base/virtchnl.h
 create mode 100644 drivers/common/idpf/base/virtchnl2.h
 create mode 100644 drivers/common/idpf/base/virtchnl2_lan_desc.h
 create mode 100644 drivers/common/idpf/base/virtchnl_inline_ipsec.h
 create mode 100644 drivers/common/idpf/meson.build
 create mode 100644 drivers/common/idpf/version.map
 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.26.2
#190 lore raw

PATCH v18 1/18 common/idpf: introduce common library

From: Junfeng Guo <[email protected]>

Introduce common library for IDPF (Infrastructure Data Path Function) PMD.
Add base code and OS specific implementation first.

---
 drivers/common/idpf/base/idpf_alloc.h         |   22 +
 drivers/common/idpf/base/idpf_common.c        |  364 +++
 drivers/common/idpf/base/idpf_controlq.c      |  691 ++++
 drivers/common/idpf/base/idpf_controlq.h      |  224 ++
 drivers/common/idpf/base/idpf_controlq_api.h  |  207 ++
 .../common/idpf/base/idpf_controlq_setup.c    |  179 +
 drivers/common/idpf/base/idpf_devids.h        |   18 +
 drivers/common/idpf/base/idpf_lan_pf_regs.h   |  134 +
 drivers/common/idpf/base/idpf_lan_txrx.h      |  428 +++
 drivers/common/idpf/base/idpf_lan_vf_regs.h   |  114 +
 drivers/common/idpf/base/idpf_osdep.h         |  364 +++
 drivers/common/idpf/base/idpf_prototype.h     |   45 +
 drivers/common/idpf/base/idpf_type.h          |  106 +
 drivers/common/idpf/base/meson.build          |   14 +
 drivers/common/idpf/base/siov_regs.h          |   47 +
 drivers/common/idpf/base/virtchnl.h           | 2866 +++++++++++++++++
 drivers/common/idpf/base/virtchnl2.h          | 1462 +++++++++
 drivers/common/idpf/base/virtchnl2_lan_desc.h |  606 ++++
 .../common/idpf/base/virtchnl_inline_ipsec.h  |  567 ++++
 drivers/common/idpf/meson.build               |    4 +
 drivers/common/idpf/version.map               |   12 +
 drivers/common/meson.build                    |    1 +
 22 files changed, 8475 insertions(+)
 create mode 100644 drivers/common/idpf/base/idpf_alloc.h
 create mode 100644 drivers/common/idpf/base/idpf_common.c
 create mode 100644 drivers/common/idpf/base/idpf_controlq.c
 create mode 100644 drivers/common/idpf/base/idpf_controlq.h
 create mode 100644 drivers/common/idpf/base/idpf_controlq_api.h
 create mode 100644 drivers/common/idpf/base/idpf_controlq_setup.c
 create mode 100644 drivers/common/idpf/base/idpf_devids.h
 create mode 100644 drivers/common/idpf/base/idpf_lan_pf_regs.h
 create mode 100644 drivers/common/idpf/base/idpf_lan_txrx.h
 create mode 100644 drivers/common/idpf/base/idpf_lan_vf_regs.h
 create mode 100644 drivers/common/idpf/base/idpf_osdep.h
 create mode 100644 drivers/common/idpf/base/idpf_prototype.h
 create mode 100644 drivers/common/idpf/base/idpf_type.h
 create mode 100644 drivers/common/idpf/base/meson.build
 create mode 100644 drivers/common/idpf/base/siov_regs.h
 create mode 100644 drivers/common/idpf/base/virtchnl.h
 create mode 100644 drivers/common/idpf/base/virtchnl2.h
 create mode 100644 drivers/common/idpf/base/virtchnl2_lan_desc.h
 create mode 100644 drivers/common/idpf/base/virtchnl_inline_ipsec.h
 create mode 100644 drivers/common/idpf/meson.build
 create mode 100644 drivers/common/idpf/version.map
drivers/common/idpf/base/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/base/idpf_common.c new file +364 -0

364 lines not on this page · raw message

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

691 lines not on this page · raw message

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

224 lines not on this page · raw message

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

207 lines not on this page · raw message

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

179 lines not on this page · raw message

drivers/common/idpf/base/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/base/idpf_lan_pf_regs.h new file +134 -0

134 lines not on this page · raw message

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

428 lines not on this page · raw message

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

114 lines not on this page · raw message

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

364 lines not on this page · raw message

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

45 lines not on this page · raw message

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

106 lines not on this page · raw message

drivers/common/idpf/base/meson.build new file +14 -0
new file mode 100644
index 0000000000..ce2b5346e4
@@ -0,0 +1,14 @@
+# 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-variable']
+cflags += ['-Wno-unused-parameter']
+cflags += ['-Wno-implicit-fallthrough']
+cflags += ['-Wno-strict-aliasing']
\ No newline at end of file
drivers/common/idpf/base/siov_regs.h new file +47 -0

47 lines not on this page · raw message

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

42 lines not on this page · raw message

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

1,462 lines not on this page · raw message

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

606 lines not on this page · raw message

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

567 lines not on this page · raw message

drivers/common/idpf/meson.build new file +4 -0
new file mode 100644
index 0000000000..26881166e9

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

drivers/common/idpf/version.map new file +12 -0
new file mode 100644
index 0000000000..bfb246c752

Lines of this file are not shown. View the 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.26.2

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

#191 lore raw

PATCH v18 2/18 net/idpf: add support for device initialization

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Support device init and add the following dev ops:
- dev_configure
- dev_close
- dev_infos_get

---
 MAINTAINERS                            |   9 +
 doc/guides/nics/features/idpf.ini      |   9 +
 doc/guides/nics/idpf.rst               |  66 ++
 doc/guides/nics/index.rst              |   1 +
 doc/guides/rel_notes/release_22_11.rst |   6 +
 drivers/net/idpf/idpf_ethdev.c         | 891 +++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h         | 189 ++++++
 drivers/net/idpf/idpf_logs.h           |  56 ++
 drivers/net/idpf/idpf_vchnl.c          | 416 ++++++++++++
 drivers/net/idpf/meson.build           |  15 +
 drivers/net/idpf/version.map           |   3 +
 drivers/net/meson.build                |   1 +
 12 files changed, 1662 insertions(+)
 create mode 100644 doc/guides/nics/features/idpf.ini
 create mode 100644 doc/guides/nics/idpf.rst
 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_vchnl.c
 create mode 100644 drivers/net/idpf/meson.build
 create mode 100644 drivers/net/idpf/version.map
MAINTAINERS +9 -0
index bdf233c9f8..cc66db25e8 100644
@@ -770,6 +770,15 @@ F: drivers/net/ice/
 F: doc/guides/nics/ice.rst
 F: doc/guides/nics/features/ice.ini
 
+Intel idpf
+M: Jingjing Wu <[email protected]>
+M: Beilei Xing <[email protected]>
+T: git://dpdk.org/next/dpdk-next-net-intel
+F: drivers/net/idpf/
+F: drivers/common/idpf/
+F: doc/guides/nics/idpf.rst
+F: doc/guides/nics/features/idpf.ini
+
 Intel igc
 M: Junfeng Guo <[email protected]>
 M: Simei Su <[email protected]>
doc/guides/nics/features/idpf.ini new file +9 -0
new file mode 100644
index 0000000000..46aab2eb61
@@ -0,0 +1,9 @@
+;
+; Supported features of the 'idpf' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-32               = Y
+x86-64               = Y
doc/guides/nics/idpf.rst new file +66 -0

66 lines not on this page · raw message

doc/guides/nics/index.rst +1 -0
index 4d40ea29a3..12841ce407 100644
@@ -34,6 +34,7 @@ Network Interface Controller Drivers
     hns3
     i40e
     ice
+    idpf
     igb
     igc
     ionic
doc/guides/rel_notes/release_22_11.rst +6 -0
index 28812e092f..77674f2b06 100644
@@ -158,6 +158,12 @@ New Features
 
   * Added protocol based buffer split support in scalar path.
 
+* **Added IDPF PMD [*EXPERIMENTAL*].**
+
+  Added the new ``idpf`` net driver for Intel® Infrastructure Processing Unit
+  (Intel® IPU) E2000.
+  See the :doc:`../nics/idpf` NIC guide for more details on this new driver.
+
 * **Updated Marvell cnxk driver.**
 
   * Added support for flow action REPRESENTED_PORT.
drivers/net/idpf/idpf_ethdev.c new file +891 -0

891 lines not on this page · raw message

drivers/net/idpf/idpf_ethdev.h new file +189 -0

189 lines not on this page · raw message

drivers/net/idpf/idpf_logs.h new file +56 -0

56 lines not on this page · raw message

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

416 lines not on this page · raw message

drivers/net/idpf/meson.build new file +15 -0
new file mode 100644
index 0000000000..ecf73355c3
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
+deps += ['common_idpf']
+
+sources = files(
+    'idpf_ethdev.c',
+    'idpf_vchnl.c',
+)
drivers/net/idpf/version.map new file +3 -0
new file mode 100644
index 0000000000..78c3585d7c
@@ -0,0 +1,3 @@
+DPDK_23 {
+	local: *;
+};
drivers/net/meson.build +1 -0
index 589399400a..6470bf3636 100644
@@ -29,6 +29,7 @@ drivers = [
         'i40e',
         'iavf',
         'ice',
+        'idpf',
         'igc',
         'ionic',
         'ipn3ke',
Signature · 1 line
2.26.2
#192 lore raw

PATCH v18 3/18 net/idpf: add Tx queue setup

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add support for tx_queue_setup ops.

In the single queue model, the same descriptor queue is used by SW to post buffer descriptors to HW and by HW to post completed descriptors to SW.

In the split queue model, "RX buffer queues" are used to pass descriptor buffers from SW to HW while Rx queues are used only to pass the descriptor completions, that is, descriptors that point to completed buffers, from HW to SW. This is contrary to the single queue model in which Rx queues are used for both purposes.

---
 drivers/net/idpf/idpf_ethdev.c |  13 ++
 drivers/net/idpf/idpf_rxtx.c   | 364 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  70 +++++++
 drivers/net/idpf/meson.build   |   1 +
 4 files changed, 448 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 +13 -0
index 035f563275..54f20d30ca 100644
@@ -11,6 +11,7 @@
 #include <errno.h>
 
 #include "idpf_ethdev.h"
+#include "idpf_rxtx.h"
 
 #define IDPF_TX_SINGLE_Q	"tx_single"
 #define IDPF_RX_SINGLE_Q	"rx_single"
@@ -42,6 +43,17 @@ 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->default_txconf = (struct rte_eth_txconf) {
+		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
+		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
+	};
+
+	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;
 }
 
@@ -631,6 +643,7 @@ idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
 static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_configure			= idpf_dev_configure,
 	.dev_close			= idpf_dev_close,
+	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
 };
 
drivers/net/idpf/idpf_rxtx.c new file +364 -0

364 lines not on this page · raw message

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

70 lines not on this page · raw message

drivers/net/idpf/meson.build +1 -0
index ecf73355c3..b632b76656 100644
@@ -11,5 +11,6 @@ deps += ['common_idpf']
 
 sources = files(
     'idpf_ethdev.c',
+    'idpf_rxtx.c',
     'idpf_vchnl.c',
 )
Signature · 1 line
2.26.2
#193 lore raw

PATCH v18 4/18 net/idpf: add Rx queue setup

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add support for rx_queue_setup ops.

---
 drivers/net/idpf/idpf_ethdev.c |  11 +
 drivers/net/idpf/idpf_rxtx.c   | 400 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  46 ++++
 3 files changed, 457 insertions(+)
drivers/net/idpf/idpf_ethdev.c +11 -0
index 54f20d30ca..fb5cd1b111 100644
@@ -48,12 +48,22 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
 	};
 
+	dev_info->default_rxconf = (struct rte_eth_rxconf) {
+		.rx_free_thresh = IDPF_DEFAULT_RX_FREE_THRESH,
+	};
+
 	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->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,
+	};
+
 	return 0;
 }
 
@@ -643,6 +653,7 @@ idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
 static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_configure			= idpf_dev_configure,
 	.dev_close			= idpf_dev_close,
+	.rx_queue_setup			= idpf_rx_queue_setup,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
 };
drivers/net/idpf/idpf_rxtx.c +400 -0

418 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +46 -0

61 lines not on this page · raw message

Signature · 1 line
2.26.2
#194 lore raw

PATCH v18 5/18 net/idpf: add support for device start and stop

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add dev ops dev_start, dev_stop and link_update.

---
 drivers/net/idpf/idpf_ethdev.c | 55 ++++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.c   | 20 +++++++++++++
 2 files changed, 75 insertions(+)
drivers/net/idpf/idpf_ethdev.c +55 -0
index fb5cd1b111..621bf9aad5 100644
@@ -29,6 +29,22 @@ static const char * const idpf_valid_args[] = {
 	NULL
 };
 
+static int
+idpf_dev_link_update(struct rte_eth_dev *dev,
+		     __rte_unused int wait_to_complete)
+{
+	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_autoneg = !(dev->data->dev_conf.link_speeds &
+				  RTE_ETH_LINK_SPEED_FIXED);
+
+	return rte_eth_linkstatus_set(dev, &new_link);
+}
+
 static int
 idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
@@ -267,6 +283,42 @@ idpf_dev_configure(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;
+	int ret;
+
+	if (dev->data->mtu > vport->max_mtu) {
+		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
+		return -EINVAL;
+	}
+
+	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
+
+	/* TODO: start queues */
+
+	ret = idpf_vc_ena_dis_vport(vport, true);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to enable vport");
+		return ret;
+	}
+
+	return 0;
+}
+
+static int
+idpf_dev_stop(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+
+	idpf_vc_ena_dis_vport(vport, false);
+
+	/* TODO: stop queues */
+
+	return 0;
+}
+
 static int
 idpf_dev_close(struct rte_eth_dev *dev)
 {
@@ -656,6 +708,9 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.rx_queue_setup			= idpf_rx_queue_setup,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
+	.dev_start			= idpf_dev_start,
+	.dev_stop			= idpf_dev_stop,
+	.link_update			= idpf_dev_link_update,
 };
 
 static uint16_t
drivers/net/idpf/idpf_rxtx.c +20 -0
index 25dd5d85d5..3528d2f2c7 100644
@@ -334,6 +334,11 @@ idpf_rx_split_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	if (check_rx_thresh(nb_desc, rx_free_thresh) != 0)
 		return -EINVAL;
 
+	if (rx_conf->rx_deferred_start) {
+		PMD_INIT_LOG(ERR, "Queue start is not supported currently.");
+		return -EINVAL;
+	}
+
 	/* Setup Rx description queue */
 	rxq = rte_zmalloc_socket("idpf rxq",
 				 sizeof(struct idpf_rx_queue),
@@ -465,6 +470,11 @@ idpf_rx_single_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	if (check_rx_thresh(nb_desc, rx_free_thresh) != 0)
 		return -EINVAL;
 
+	if (rx_conf->rx_deferred_start) {
+		PMD_INIT_LOG(ERR, "Queue start is not supported currently.");
+		return -EINVAL;
+	}
+
 	/* Setup Rx description queue */
 	rxq = rte_zmalloc_socket("idpf rxq",
 				 sizeof(struct idpf_rx_queue),
@@ -569,6 +579,11 @@ idpf_tx_split_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	if (check_tx_thresh(nb_desc, tx_rs_thresh, tx_free_thresh) != 0)
 		return -EINVAL;
 
+	if (tx_conf->tx_deferred_start) {
+		PMD_INIT_LOG(ERR, "Queue start is not supported currently.");
+		return -EINVAL;
+	}
+
 	/* Allocate the TX queue data structure. */
 	txq = rte_zmalloc_socket("idpf split txq",
 				 sizeof(struct idpf_tx_queue),
@@ -691,6 +706,11 @@ idpf_tx_single_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	if (check_tx_thresh(nb_desc, tx_rs_thresh, tx_free_thresh) != 0)
 		return -EINVAL;
 
+	if (tx_conf->tx_deferred_start) {
+		PMD_INIT_LOG(ERR, "Queue start is not supported currently.");
+		return -EINVAL;
+	}
+
 	/* Allocate the TX queue data structure. */
 	txq = rte_zmalloc_socket("idpf txq",
 				 sizeof(struct idpf_tx_queue),
Signature · 1 line
2.26.2
#195 lore raw

PATCH v18 6/18 net/idpf: add support for queue start

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add support for these device ops:
- rx_queue_start
- tx_queue_start

---
 drivers/net/idpf/idpf_ethdev.c |  42 +++-
 drivers/net/idpf/idpf_ethdev.h |   9 +
 drivers/net/idpf/idpf_rxtx.c   | 237 +++++++++++++++--
 drivers/net/idpf/idpf_rxtx.h   |   6 +
 drivers/net/idpf/idpf_vchnl.c  | 447 +++++++++++++++++++++++++++++++++
 5 files changed, 720 insertions(+), 21 deletions(-)
drivers/net/idpf/idpf_ethdev.c +41 -1
index 621bf9aad5..0400ed611f 100644
@@ -283,6 +283,39 @@ idpf_dev_configure(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 == NULL || txq->tx_deferred_start)
+			continue;
+		err = idpf_tx_queue_start(dev, i);
+		if (err != 0) {
+			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 == NULL || rxq->rx_deferred_start)
+			continue;
+		err = idpf_rx_queue_start(dev, i);
+		if (err != 0) {
+			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)
 {
@@ -296,11 +329,16 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
 
-	/* TODO: start queues */
+	ret = idpf_start_queues(dev);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to start queues");
+		return ret;
+	}
 
 	ret = idpf_vc_ena_dis_vport(vport, true);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
+		/* TODO: stop queues */
 		return ret;
 	}
 
@@ -711,6 +749,8 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_start			= idpf_dev_start,
 	.dev_stop			= idpf_dev_stop,
 	.link_update			= idpf_dev_link_update,
+	.rx_queue_start			= idpf_rx_queue_start,
+	.tx_queue_start			= idpf_tx_queue_start,
 };
 
 static uint16_t
drivers/net/idpf/idpf_ethdev.h +9 -0
index 84ae6641e2..96c22009e9 100644
@@ -24,7 +24,9 @@
 #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
@@ -182,6 +184,13 @@ int idpf_vc_check_api_version(struct idpf_adapter *adapter);
 int idpf_vc_get_caps(struct idpf_adapter *adapter);
 int idpf_vc_create_vport(struct idpf_adapter *adapter);
 int idpf_vc_destroy_vport(struct idpf_vport *vport);
+int idpf_vc_config_rxqs(struct idpf_vport *vport);
+int idpf_vc_config_rxq(struct idpf_vport *vport, uint16_t rxq_id);
+int idpf_vc_config_txqs(struct idpf_vport *vport);
+int idpf_vc_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_vc_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_vc_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 +217 -20

288 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +6 -0
index 3f3932c3eb..ab9b3830fd 100644
@@ -50,6 +50,7 @@ struct idpf_rx_queue {
 
 	bool q_set;             /* if rx queue has been configured */
 	bool q_started;         /* if rx queue has been started */
+	bool rx_deferred_start; /* don't start this queue in dev start */
 
 	/* only valid for split queue mode */
 	uint8_t expected_gen_id;
@@ -95,6 +96,7 @@ struct idpf_tx_queue {
 
 	bool q_set;		/* if tx queue has been configured */
 	bool q_started;		/* if tx queue has been started */
+	bool tx_deferred_start; /* don't start this queue in dev start */
 
 	/* only valid for split queue mode */
 	uint16_t sw_nb_desc;
@@ -109,8 +111,12 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_rxconf *rx_conf,
 			struct rte_mempool *mp);
+int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
+int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
+int idpf_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 
 #endif /* _IDPF_RXTX_H_ */
drivers/net/idpf/idpf_vchnl.c +447 -0

465 lines not on this page · raw message

Signature · 1 line
2.26.2
#196 lore raw

PATCH v18 7/18 net/idpf: add support for queue stop

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add support for these device ops:
- rx_queue_stop
- tx_queue_stop

---
 drivers/net/idpf/idpf_ethdev.c |  17 ++--
 drivers/net/idpf/idpf_rxtx.c   | 148 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  13 +++
 drivers/net/idpf/idpf_vchnl.c  |  69 +++++++++++++++
 4 files changed, 242 insertions(+), 5 deletions(-)
drivers/net/idpf/idpf_ethdev.c +12 -5
index 0400ed611f..9f1e1e6a18 100644
@@ -324,7 +324,8 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	if (dev->data->mtu > vport->max_mtu) {
 		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto err_mtu;
 	}
 
 	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
@@ -332,17 +333,21 @@ idpf_dev_start(struct rte_eth_dev *dev)
 	ret = idpf_start_queues(dev);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
-		return ret;
+		goto err_mtu;
 	}
 
 	ret = idpf_vc_ena_dis_vport(vport, true);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
-		/* TODO: stop queues */
-		return ret;
+		goto err_vport;
 	}
 
 	return 0;
+
+err_vport:
+	idpf_stop_queues(dev);
+err_mtu:
+	return ret;
 }
 
 static int
@@ -352,7 +357,7 @@ idpf_dev_stop(struct rte_eth_dev *dev)
 
 	idpf_vc_ena_dis_vport(vport, false);
 
-	/* TODO: stop queues */
+	idpf_stop_queues(dev);
 
 	return 0;
 }
@@ -751,6 +756,8 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.link_update			= idpf_dev_link_update,
 	.rx_queue_start			= idpf_rx_queue_start,
 	.tx_queue_start			= idpf_tx_queue_start,
+	.rx_queue_stop			= idpf_rx_queue_stop,
+	.tx_queue_stop			= idpf_tx_queue_stop,
 };
 
 static uint16_t
drivers/net/idpf/idpf_rxtx.c +148 -0

187 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +13 -0
index ab9b3830fd..b959638489 100644
@@ -51,6 +51,7 @@ struct idpf_rx_queue {
 	bool q_set;             /* if rx queue has been configured */
 	bool q_started;         /* if rx queue has been started */
 	bool rx_deferred_start; /* don't start this queue in dev start */
+	const struct idpf_rxq_ops *ops;
 
 	/* only valid for split queue mode */
 	uint8_t expected_gen_id;
@@ -97,6 +98,7 @@ struct idpf_tx_queue {
 	bool q_set;		/* if tx queue has been configured */
 	bool q_started;		/* if tx queue has been started */
 	bool tx_deferred_start; /* don't start this queue in dev start */
+	const struct idpf_txq_ops *ops;
 
 	/* only valid for split queue mode */
 	uint16_t sw_nb_desc;
@@ -107,16 +109,27 @@ struct idpf_tx_queue {
 	struct idpf_tx_queue *complq;
 };
 
+struct idpf_rxq_ops {
+	void (*release_mbufs)(struct idpf_rx_queue *rxq);
+};
+
+struct idpf_txq_ops {
+	void (*release_mbufs)(struct idpf_tx_queue *txq);
+};
+
 int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_rxconf *rx_conf,
 			struct rte_mempool *mp);
 int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int idpf_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
 int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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_stop_queues(struct rte_eth_dev *dev);
 #endif /* _IDPF_RXTX_H_ */
drivers/net/idpf/idpf_vchnl.c +69 -0

75 lines not on this page · raw message

Signature · 1 line
2.26.2
#197 lore raw

PATCH v18 8/18 net/idpf: add queue release

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add support for queue operations:
- rx_queue_release
- tx_queue_release

---
 drivers/net/idpf/idpf_ethdev.c |  2 +
 drivers/net/idpf/idpf_rxtx.c   | 81 ++++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  3 ++
 3 files changed, 86 insertions(+)
drivers/net/idpf/idpf_ethdev.c +2 -0
index 9f1e1e6a18..1485f40e71 100644
@@ -758,6 +758,8 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.tx_queue_start			= idpf_tx_queue_start,
 	.rx_queue_stop			= idpf_rx_queue_stop,
 	.tx_queue_stop			= idpf_tx_queue_stop,
+	.rx_queue_release		= idpf_dev_rx_queue_release,
+	.tx_queue_release		= idpf_dev_tx_queue_release,
 };
 
 static uint16_t
drivers/net/idpf/idpf_rxtx.c +81 -0

117 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +3 -0
index b959638489..37944edcac 100644
@@ -124,12 +124,15 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+void idpf_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
+
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
 int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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);
 
 void idpf_stop_queues(struct rte_eth_dev *dev);
 #endif /* _IDPF_RXTX_H_ */
Signature · 1 line
2.26.2
#198 lore raw

PATCH v18 9/18 net/idpf: add support for MTU configuration

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add dev ops mtu_set.

---
 doc/guides/nics/features/idpf.ini |  1 +
 drivers/net/idpf/idpf_ethdev.c    | 13 +++++++++++++
 2 files changed, 14 insertions(+)
doc/guides/nics/features/idpf.ini +1 -0
index 46aab2eb61..d722c49fde 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+MTU update           = Y
 Linux                = Y
 x86-32               = Y
 x86-64               = Y
drivers/net/idpf/idpf_ethdev.c +13 -0
index 1485f40e71..856f3d7266 100644
@@ -83,6 +83,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)
 {
@@ -760,6 +772,7 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.tx_queue_stop			= idpf_tx_queue_stop,
 	.rx_queue_release		= idpf_dev_rx_queue_release,
 	.tx_queue_release		= idpf_dev_tx_queue_release,
+	.mtu_set			= idpf_dev_mtu_set,
 };
 
 static uint16_t
Signature · 1 line
2.26.2
#199 lore raw

PATCH v18 10/18 net/idpf: add support for basic Rx datapath

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add basic Rx support in split queue mode and single queue mode.

---
 drivers/net/idpf/idpf_ethdev.c |   2 +
 drivers/net/idpf/idpf_rxtx.c   | 273 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |   7 +-
 3 files changed, 281 insertions(+), 1 deletion(-)
drivers/net/idpf/idpf_ethdev.c +2 -0
index 856f3d7266..2f1f9eeee5 100644
@@ -348,6 +348,8 @@ idpf_dev_start(struct rte_eth_dev *dev)
 		goto err_mtu;
 	}
 
+	idpf_set_rx_function(dev);
+
 	ret = idpf_vc_ena_dis_vport(vport, true);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
drivers/net/idpf/idpf_rxtx.c +273 -0

276 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +6 -1
index 37944edcac..650c6c1c3a 100644
@@ -133,6 +133,11 @@ int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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);
 void idpf_stop_queues(struct rte_eth_dev *dev);
+
+void idpf_set_rx_function(struct rte_eth_dev *dev);
 #endif /* _IDPF_RXTX_H_ */
Signature · 1 line
2.26.2
#200 lore raw

PATCH v18 11/18 net/idpf: add support for basic Tx datapath

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add basic Tx support in split queue mode and single queue mode.

---
 drivers/net/idpf/idpf_ethdev.c |   3 +
 drivers/net/idpf/idpf_ethdev.h |   1 +
 drivers/net/idpf/idpf_rxtx.c   | 357 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  10 +
 4 files changed, 371 insertions(+)
drivers/net/idpf/idpf_ethdev.c +3 -0
index 2f1f9eeee5..f9f6fe1162 100644
@@ -59,6 +59,8 @@ 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->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+
 	dev_info->default_txconf = (struct rte_eth_txconf) {
 		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
 		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
@@ -349,6 +351,7 @@ idpf_dev_start(struct rte_eth_dev *dev)
 	}
 
 	idpf_set_rx_function(dev);
+	idpf_set_tx_function(dev);
 
 	ret = idpf_vc_ena_dis_vport(vport, true);
 	if (ret != 0) {
drivers/net/idpf/idpf_ethdev.h +1 -0
index 96c22009e9..af0a8e2970 100644
@@ -35,6 +35,7 @@
 
 #define IDPF_MIN_BUF_SIZE	1024
 #define IDPF_MAX_FRAME_SIZE	9728
+#define IDPF_MIN_FRAME_SIZE	14
 
 #define IDPF_NUM_MACADDR_MAX	64
 
drivers/net/idpf/idpf_rxtx.c +357 -0

372 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +10 -0
index 650c6c1c3a..30dc94b3dd 100644
@@ -21,6 +21,8 @@
 #define IDPF_DEFAULT_TX_RS_THRESH	32
 #define IDPF_DEFAULT_TX_FREE_THRESH	32
 
+#define IDPF_TX_MAX_MTU_SEG	10
+
 struct idpf_rx_queue {
 	struct idpf_adapter *adapter;   /* the adapter this queue belongs to */
 	struct rte_mempool *mp;         /* mbuf pool to populate Rx ring */
@@ -137,7 +139,15 @@ 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);
 #endif /* _IDPF_RXTX_H_ */
Signature · 1 line
2.26.2
#201 lore raw

PATCH v18 12/18 net/idpf: support parsing packet type

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Parse packet type during receiving packets.

---
 drivers/net/idpf/idpf_ethdev.c |   6 +
 drivers/net/idpf/idpf_ethdev.h |   6 +
 drivers/net/idpf/idpf_rxtx.c   |  11 ++
 drivers/net/idpf/idpf_rxtx.h   |   5 +
 drivers/net/idpf/idpf_vchnl.c  | 240 +++++++++++++++++++++++++++++++++
 5 files changed, 268 insertions(+)
drivers/net/idpf/idpf_ethdev.c +6 -0
index f9f6fe1162..d0821ec3f3 100644
@@ -686,6 +686,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 != 0) {
+		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 == NULL) {
drivers/net/idpf/idpf_ethdev.h +6 -0
index af0a8e2970..db9af58f72 100644
@@ -39,6 +39,8 @@
 
 #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)
@@ -125,6 +127,8 @@ struct idpf_adapter {
 	/* 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;
 };
 
 TAILQ_HEAD(idpf_adapter_list, idpf_adapter);
@@ -182,6 +186,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_vc_check_api_version(struct idpf_adapter *adapter);
+int idpf_get_pkt_type(struct idpf_adapter *adapter);
 int idpf_vc_get_caps(struct idpf_adapter *adapter);
 int idpf_vc_create_vport(struct idpf_adapter *adapter);
 int idpf_vc_destroy_vport(struct idpf_vport *vport);
@@ -193,6 +198,7 @@ int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,
 		      bool rx, bool on);
 int idpf_vc_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_vc_ena_dis_vport(struct idpf_vport *vport, bool enable);
+int idpf_vc_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 +11 -0
index f55d2143b9..a980714060 100644
@@ -1281,6 +1281,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	volatile struct virtchnl2_rx_flex_desc_adv_nic_3 *rx_desc;
 	uint16_t pktlen_gen_bufq_id;
 	struct idpf_rx_queue *rxq;
+	const uint32_t *ptype_tbl;
 	struct rte_mbuf *rxm;
 	uint16_t rx_id_bufq1;
 	uint16_t rx_id_bufq2;
@@ -1300,6 +1301,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	rx_id_bufq1 = rxq->bufq1->rx_next_avail;
 	rx_id_bufq2 = rxq->bufq2->rx_next_avail;
 	rx_desc_ring = rxq->rx_ring;
+	ptype_tbl = rxq->adapter->ptype_tbl;
 
 	while (nb_rx < nb_pkts) {
 		rx_desc = &rx_desc_ring[rx_id];
@@ -1347,6 +1349,10 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		rxm->next = NULL;
 		rxm->nb_segs = 1;
 		rxm->port = rxq->port_id;
+		rxm->packet_type =
+			ptype_tbl[(rte_le_to_cpu_16(rx_desc->ptype_err_fflags0) &
+				   VIRTCHNL2_RX_FLEX_DESC_ADV_PTYPE_M) >>
+				  VIRTCHNL2_RX_FLEX_DESC_ADV_PTYPE_S];
 
 		rx_pkts[nb_rx++] = rxm;
 	}
@@ -1533,6 +1539,7 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	volatile union virtchnl2_rx_desc *rxdp;
 	union virtchnl2_rx_desc rxd;
 	struct idpf_rx_queue *rxq;
+	const uint32_t *ptype_tbl;
 	uint16_t rx_id, nb_hold;
 	struct rte_eth_dev *dev;
 	uint16_t rx_packet_len;
@@ -1551,6 +1558,7 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 
 	rx_id = rxq->rx_tail;
 	rx_ring = rxq->rx_ring;
+	ptype_tbl = rxq->adapter->ptype_tbl;
 
 	while (nb_rx < nb_pkts) {
 		rxdp = &rx_ring[rx_id];
@@ -1603,6 +1611,9 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		rxm->pkt_len = rx_packet_len;
 		rxm->data_len = rx_packet_len;
 		rxm->port = rxq->port_id;
+		rxm->packet_type =
+			ptype_tbl[(uint8_t)(rte_cpu_to_le_16(rxd.flex_nic_wb.ptype_flex_flags0) &
+					    VIRTCHNL2_RX_FLEX_DESC_PTYPE_M)];
 
 		rx_pkts[nb_rx++] = rxm;
 	}
drivers/net/idpf/idpf_rxtx.h +5 -0
index 30dc94b3dd..3853ed55c9 100644
@@ -23,6 +23,10 @@
 
 #define IDPF_TX_MAX_MTU_SEG	10
 
+#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 */
@@ -150,4 +154,5 @@ 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);
+
 #endif /* _IDPF_RXTX_H_ */
drivers/net/idpf/idpf_vchnl.c +240 -0

255 lines not on this page · raw message

Signature · 1 line
2.26.2
#202 lore raw

PATCH v18 13/18 net/idpf: add support for write back based on ITR expire

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Enable write back on ITR expire, then packets can be received one by one.

---
 drivers/net/idpf/idpf_ethdev.c | 120 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h |  13 ++++
 drivers/net/idpf/idpf_vchnl.c  | 113 +++++++++++++++++++++++++++++++
 3 files changed, 246 insertions(+)
drivers/net/idpf/idpf_ethdev.c +120 -0
index d0821ec3f3..957cc10616 100644
@@ -297,6 +297,90 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
+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 idpf_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 == NULL) {
+		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 should be
+	 * compared with bit VIRTCHNL2_CAP_WB_ON_ITR here. The if
+	 * condition should be updated when the FW can return the
+	 * correct flag bits.
+	 */
+	dynctl_reg_start =
+		vport->recv_vectors->vchunks.vchunks->dynctl_reg_start;
+	itrn_reg_start =
+		vport->recv_vectors->vchunks.vchunks->itrn_reg_start;
+	dynctl_val = IDPF_READ_REG(hw, dynctl_reg_start);
+	PMD_DRV_LOG(DEBUG, "Value of dynctl_reg_start is 0x%x",
+		    dynctl_val);
+	itrn_val = IDPF_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 written back based on ITR expiration irrespective
+	 * of INTENA setting.
+	 */
+	/* TBD: need to tune INTERVAL value for better performance. */
+	if (itrn_val != 0)
+		IDPF_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
+		IDPF_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_vc_config_irq_map_unmap(vport, true) != 0) {
+		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)
 {
@@ -334,6 +418,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;
 	int ret;
 
 	if (dev->data->mtu > vport->max_mtu) {
@@ -344,6 +432,27 @@ 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);
+		ret = -EINVAL;
+		goto err_mtu;
+	}
+
+	ret = idpf_vc_alloc_vectors(vport, req_vecs_num);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to allocate interrupt vectors");
+		goto err_mtu;
+	}
+	adapter->used_vecs_num += req_vecs_num;
+
+	ret = idpf_config_rx_queues_irqs(dev);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to configure irqs");
+		goto err_mtu;
+	}
+
 	ret = idpf_start_queues(dev);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
@@ -376,6 +485,10 @@ idpf_dev_stop(struct rte_eth_dev *dev)
 
 	idpf_stop_queues(dev);
 
+	idpf_vc_config_irq_map_unmap(vport, false);
+
+	idpf_vc_dealloc_vectors(vport);
+
 	return 0;
 }
 
@@ -387,6 +500,11 @@ idpf_dev_close(struct rte_eth_dev *dev)
 
 	idpf_vc_destroy_vport(vport);
 
+	rte_free(vport->recv_vectors);
+	vport->recv_vectors = NULL;
+
+	rte_free(vport->qv_map);
+	vport->qv_map = NULL;
 
 	adapter->cur_vports &= ~RTE_BIT32(vport->devarg_id);
 
@@ -748,6 +866,8 @@ idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
 	adapter->cur_vports = 0;
 	adapter->cur_vport_nb = 0;
 
+	adapter->used_vecs_num = 0;
+
 	return ret;
 
 err_vports:
drivers/net/idpf/idpf_ethdev.h +13 -0
index db9af58f72..811240c386 100644
@@ -33,6 +33,9 @@
 #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_MIN_BUF_SIZE	1024
 #define IDPF_MAX_FRAME_SIZE	9728
 #define IDPF_MIN_FRAME_SIZE	14
@@ -92,6 +95,11 @@ struct idpf_vport {
 	struct rte_eth_dev_data *dev_data; /* Pointer to the device data */
 	uint16_t max_pkt_len; /* Maximum packet length */
 
+	/* 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;
 
@@ -124,6 +132,8 @@ struct idpf_adapter {
 	uint16_t cur_vport_nb;
 	uint16_t cur_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;
@@ -198,6 +208,9 @@ int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,
 		      bool rx, bool on);
 int idpf_vc_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_vc_ena_dis_vport(struct idpf_vport *vport, bool enable);
+int idpf_vc_config_irq_map_unmap(struct idpf_vport *vport, bool map);
+int idpf_vc_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors);
+int idpf_vc_dealloc_vectors(struct idpf_vport *vport);
 int idpf_vc_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 +113 -0

131 lines not on this page · raw message

Signature · 1 line
2.26.2
#203 lore raw

PATCH v18 14/18 net/idpf: add support for RSS

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add RSS support.

---
 drivers/net/idpf/idpf_ethdev.c | 120 ++++++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_ethdev.h |  26 +++++++
 drivers/net/idpf/idpf_vchnl.c  | 113 +++++++++++++++++++++++++++++++
 3 files changed, 258 insertions(+), 1 deletion(-)
drivers/net/idpf/idpf_ethdev.c +119 -1
index 957cc10616..58560ea404 100644
@@ -59,6 +59,8 @@ 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->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
 	dev_info->default_txconf = (struct rte_eth_txconf) {
@@ -169,6 +171,8 @@ idpf_parse_devarg_id(char *name)
 	return val;
 }
 
+#define IDPF_RSS_KEY_LEN 52
+
 static int
 idpf_init_vport(struct rte_eth_dev *dev)
 {
@@ -189,6 +193,10 @@ idpf_init_vport(struct rte_eth_dev *dev)
 	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++) {
@@ -246,17 +254,110 @@ idpf_init_vport(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+idpf_config_rss(struct idpf_vport *vport)
+{
+	int ret;
+
+	ret = idpf_vc_set_rss_key(vport);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS key");
+		return ret;
+	}
+
+	ret = idpf_vc_set_rss_lut(vport);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS lut");
+		return ret;
+	}
+
+	ret = idpf_vc_set_rss_hash(vport);
+	if (ret != 0) {
+		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 = rte_zmalloc("rss_key",
+				     vport->rss_key_size, 0);
+	if (vport->rss_key == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS key");
+		ret = -ENOMEM;
+		goto err_alloc_key;
+	}
+
+	lut_size = vport->rss_lut_size;
+	vport->rss_lut = rte_zmalloc("rss_lut",
+				     sizeof(uint32_t) * lut_size, 0);
+	if (vport->rss_lut == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS lut");
+		ret = -ENOMEM;
+		goto err_alloc_lut;
+	}
+
+	if (rss_conf->rss_key == NULL) {
+		for (i = 0; i < vport->rss_key_size; i++)
+			vport->rss_key[i] = (uint8_t)rte_rand();
+	} else if (rss_conf->rss_key_len != vport->rss_key_size) {
+		PMD_INIT_LOG(ERR, "Invalid RSS key length in RSS configuration, should be %d",
+			     vport->rss_key_size);
+		ret = -EINVAL;
+		goto err_cfg_key;
+	} else {
+		rte_memcpy(vport->rss_key, rss_conf->rss_key,
+			   vport->rss_key_size);
+	}
+
+	for (i = 0; i < lut_size; i++)
+		vport->rss_lut[i] = i % nb_q;
+
+	vport->rss_hf = IDPF_DEFAULT_RSS_HASH_EXPANDED;
+
+	ret = idpf_config_rss(vport);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS");
+		goto err_cfg_key;
+	}
+
+	return ret;
+
+err_cfg_key:
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+err_alloc_lut:
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+err_alloc_key:
+	return ret;
+}
+
 static int
 idpf_dev_configure(struct rte_eth_dev *dev)
 {
+	struct idpf_vport *vport = dev->data->dev_private;
 	struct rte_eth_conf *conf = &dev->data->dev_conf;
+	struct idpf_adapter *adapter = vport->adapter;
+	int ret;
 
 	if (conf->link_speeds & RTE_ETH_LINK_SPEED_FIXED) {
 		PMD_INIT_LOG(ERR, "Setting link speed is not supported");
 		return -ENOTSUP;
 	}
 
-	if (dev->data->nb_rx_queues == 1 && conf->rxmode.mq_mode != RTE_ETH_MQ_RX_NONE) {
+	if ((dev->data->nb_rx_queues == 1 && conf->rxmode.mq_mode != RTE_ETH_MQ_RX_NONE) ||
+	    (dev->data->nb_rx_queues > 1 && conf->rxmode.mq_mode != RTE_ETH_MQ_RX_RSS)) {
 		PMD_INIT_LOG(ERR, "Multi-queue packet distribution mode %d is not supported",
 			     conf->rxmode.mq_mode);
 		return -ENOTSUP;
@@ -294,6 +395,17 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 		return -ENOTSUP;
 	}
 
+	if (adapter->caps->rss_caps != 0 && dev->data->nb_rx_queues != 0) {
+		ret = idpf_init_rss(vport);
+		if (ret != 0) {
+			PMD_INIT_LOG(ERR, "Failed to init rss");
+			return ret;
+		}
+	} else {
+		PMD_INIT_LOG(ERR, "RSS is not supported.");
+		return -1;
+	}
+
 	return 0;
 }
 
@@ -500,6 +612,12 @@ idpf_dev_close(struct rte_eth_dev *dev)
 
 	idpf_vc_destroy_vport(vport);
 
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+
 	rte_free(vport->recv_vectors);
 	vport->recv_vectors = NULL;
 
drivers/net/idpf/idpf_ethdev.h +26 -0
index 811240c386..8d0804f603 100644
@@ -48,6 +48,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)
+
 #define IDPF_ADAPTER_NAME_LEN	(PCI_PRI_STR_SIZE + 1)
 
 /* Message type read in virtual channel from PF */
@@ -90,11 +104,20 @@ struct idpf_vport {
 	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;
@@ -200,6 +223,9 @@ int idpf_get_pkt_type(struct idpf_adapter *adapter);
 int idpf_vc_get_caps(struct idpf_adapter *adapter);
 int idpf_vc_create_vport(struct idpf_adapter *adapter);
 int idpf_vc_destroy_vport(struct idpf_vport *vport);
+int idpf_vc_set_rss_key(struct idpf_vport *vport);
+int idpf_vc_set_rss_lut(struct idpf_vport *vport);
+int idpf_vc_set_rss_hash(struct idpf_vport *vport);
 int idpf_vc_config_rxqs(struct idpf_vport *vport);
 int idpf_vc_config_rxq(struct idpf_vport *vport, uint16_t rxq_id);
 int idpf_vc_config_txqs(struct idpf_vport *vport);
drivers/net/idpf/idpf_vchnl.c +113 -0

131 lines not on this page · raw message

Signature · 1 line
2.26.2
#204 lore raw

PATCH v18 15/18 net/idpf: add support for Rx offloading

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add Rx offloading support:
- support CHKSUM and RSS offload for split queue model
- support CHKSUM offload for single queue model

---
 doc/guides/nics/features/idpf.ini |   5 ++
 drivers/net/idpf/idpf_ethdev.c    |   6 ++
 drivers/net/idpf/idpf_rxtx.c      | 123 ++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_vchnl.c     |  18 +++++
 4 files changed, 152 insertions(+)
doc/guides/nics/features/idpf.ini +5 -0
index d722c49fde..868571654f 100644
@@ -3,8 +3,13 @@
 ;
 ; Refer to default.ini for the full list of available PMD features.
 ;
+; A feature with "P" indicates only be supported when non-vector path
+; is selected.
+;
 [Features]
 MTU update           = Y
+L3 checksum offload  = P
+L4 checksum offload  = P
 Linux                = Y
 x86-32               = Y
 x86-64               = Y
drivers/net/idpf/idpf_ethdev.c +6 -0
index 58560ea404..a09f104425 100644
@@ -61,6 +61,12 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->flow_type_rss_offloads = IDPF_RSS_OFFLOAD_ALL;
 
+	dev_info->rx_offload_capa =
+		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;
+
 	dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
 	dev_info->default_txconf = (struct rte_eth_txconf) {
drivers/net/idpf/idpf_rxtx.c +123 -0

171 lines not on this page · raw message

drivers/net/idpf/idpf_vchnl.c +18 -0
index 4ef354df89..00ac5b2a6b 100644
@@ -528,6 +528,24 @@ idpf_vc_get_caps(struct idpf_adapter *adapter)
 
 	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.rss_caps =
 		VIRTCHNL2_CAP_RSS_IPV4_TCP             |
 		VIRTCHNL2_CAP_RSS_IPV4_UDP             |
Signature · 1 line
2.26.2
#205 lore raw

PATCH v18 16/18 net/idpf: add support for Tx offloading

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add Tx offloading support:
- support TSO for single queue model and split queue model.

---
 doc/guides/nics/features/idpf.ini |   1 +
 drivers/net/idpf/idpf_ethdev.c    |   4 +-
 drivers/net/idpf/idpf_rxtx.c      | 128 +++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_rxtx.h      |  22 +++++
 4 files changed, 152 insertions(+), 3 deletions(-)
doc/guides/nics/features/idpf.ini +1 -0
index 868571654f..d82b4aa0ff 100644
@@ -8,6 +8,7 @@
 ;
 [Features]
 MTU update           = Y
+TSO                  = P
 L3 checksum offload  = P
 L4 checksum offload  = P
 Linux                = Y
drivers/net/idpf/idpf_ethdev.c +3 -1
index a09f104425..084426260c 100644
@@ -67,7 +67,9 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		RTE_ETH_RX_OFFLOAD_TCP_CKSUM            |
 		RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
 
-	dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+	dev_info->tx_offload_capa =
+		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
 	dev_info->default_txconf = (struct rte_eth_txconf) {
 		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
drivers/net/idpf/idpf_rxtx.c +126 -2

199 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +22 -0
index 3853ed55c9..54d297aac6 100644
@@ -23,6 +23,16 @@
 
 #define IDPF_TX_MAX_MTU_SEG	10
 
+#define IDPF_MIN_TSO_MSS	88
+#define IDPF_MAX_TSO_MSS	9728
+#define IDPF_MAX_TSO_FRAME_SIZE	262143
+#define IDPF_TX_MAX_MTU_SEG     10
+
+#define IDPF_TX_OFFLOAD_MASK RTE_MBUF_F_TX_TCP_SEG
+
+#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])))
@@ -115,6 +125,18 @@ struct idpf_tx_queue {
 	struct idpf_tx_queue *complq;
 };
 
+/* Offload features */
+union idpf_tx_offload {
+	uint64_t data;
+	struct {
+		uint64_t l2_len:7; /* L2 (MAC) Header Length. */
+		uint64_t l3_len:9; /* L3 (IP) Header Length. */
+		uint64_t l4_len:8; /* L4 Header Length. */
+		uint64_t tso_segsz:16; /* TCP TSO segment size */
+		/* uint64_t unused : 24; */
+	};
+};
+
 struct idpf_rxq_ops {
 	void (*release_mbufs)(struct idpf_rx_queue *rxq);
 };
Signature · 1 line
2.26.2
#206 lore raw

PATCH v18 17/18 net/idpf: add AVX512 data path for single queue model

In reply to [email protected]

From: Junfeng Guo <[email protected]>

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

---
 doc/guides/nics/idpf.rst                |  19 +
 drivers/net/idpf/idpf_ethdev.c          |   3 +-
 drivers/net/idpf/idpf_ethdev.h          |   5 +
 drivers/net/idpf/idpf_rxtx.c            | 145 ++++
 drivers/net/idpf/idpf_rxtx.h            |  21 +
 drivers/net/idpf/idpf_rxtx_vec_avx512.c | 857 ++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx_vec_common.h | 100 +++
 drivers/net/idpf/meson.build            |  28 +
 8 files changed, 1177 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
doc/guides/nics/idpf.rst +19 -0
index c1001d5d0c..3039c61748 100644
@@ -64,3 +64,22 @@ Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and
 for details.
 
 
+Features
+--------
+
+Vector PMD
+~~~~~~~~~~
+
+Vector path for RX and TX path are selected automatically. The paths
+are chosen based on 2 conditions.
+
+- ``CPU``
+  On the X86 platform, the driver checks if the CPU supports AVX512.
+  If the CPU supports AVX512 and EAL argument ``--force-max-simd-bitwidth``
+  is set to 512, AVX512 paths will be chosen.
+
+- ``Offload features``
+  The supported HW offload features are described in the document idpf.ini,
+  A value "P" means the offload feature is not supported by vector path.
+  If any not supported features are used, idpf vector PMD is disabled and the
+  scalar paths are chosen.
drivers/net/idpf/idpf_ethdev.c +2 -1
index 084426260c..cd4ebcc2c6 100644
@@ -69,7 +69,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->tx_offload_capa =
 		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
-		RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS		|
+		RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
 	dev_info->default_txconf = (struct rte_eth_txconf) {
 		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
drivers/net/idpf/idpf_ethdev.h +5 -0
index 8d0804f603..7d54e5db60 100644
@@ -162,6 +162,11 @@ struct idpf_adapter {
 	uint32_t max_txq_per_msg;
 
 	uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned;
+
+	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 +145 -0

185 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +21 -0
index 54d297aac6..506bf8a57d 100644
@@ -18,6 +18,12 @@
 #define IDPF_RX_MAX_BURST		32
 #define IDPF_DEFAULT_RX_FREE_THRESH	32
 
+/* used for Vector PMD */
+#define IDPF_VPMD_RX_MAX_BURST	32
+#define IDPF_VPMD_TX_MAX_BURST	32
+#define IDPF_VPMD_DESCS_PER_LOOP	4
+#define IDPF_RXQ_REARM_THRESH	64
+
 #define IDPF_DEFAULT_TX_RS_THRESH	32
 #define IDPF_DEFAULT_TX_FREE_THRESH	32
 
@@ -54,6 +60,11 @@ struct idpf_rx_queue {
 	struct rte_mbuf *pkt_last_seg;  /* last segment of current packet */
 	struct rte_mbuf fake_mbuf;      /* dummy mbuf */
 
+	/* used for VPMD */
+	uint16_t rxrearm_nb;       /* number of remaining to be re-armed */
+	uint16_t rxrearm_start;    /* the idx we start the re-arming from */
+	uint64_t mbuf_initializer; /* value to init mbufs */
+
 	uint16_t rx_nb_avail;
 	uint16_t rx_next_avail;
 
@@ -84,6 +95,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 */
@@ -149,6 +164,7 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_rxconf *rx_conf,
 			struct rte_mempool *mp);
+int idpf_singleq_tx_vec_setup_avx512(struct idpf_tx_queue *txq);
 int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
@@ -157,16 +173,21 @@ void idpf_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
+int idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq);
 int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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_singleq_recv_pkts_avx512(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_singleq_xmit_pkts_avx512(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,
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +857 -0

857 lines not on this page · raw message

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

100 lines not on this page · raw message

drivers/net/idpf/meson.build +28 -0
index b632b76656..da99c098ab 100644
@@ -14,3 +14,31 @@ sources = files(
     'idpf_rxtx.c',
     '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_common_idpf, 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
Signature · 1 line
2.26.2
#207 lore raw

PATCH v18 18/18 net/idpf: add support for timestamp offload

In reply to [email protected]

From: Junfeng Guo <[email protected]>

Add support for timestamp offload.

---
 doc/guides/nics/features/idpf.ini |  1 +
 drivers/net/idpf/idpf_ethdev.c    |  5 +-
 drivers/net/idpf/idpf_ethdev.h    |  3 ++
 drivers/net/idpf/idpf_rxtx.c      | 65 ++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h      | 90 +++++++++++++++++++++++++++++++
 5 files changed, 163 insertions(+), 1 deletion(-)
doc/guides/nics/features/idpf.ini +1 -0
index d82b4aa0ff..099fd7f216 100644
@@ -11,6 +11,7 @@ MTU update           = Y
 TSO                  = P
 L3 checksum offload  = P
 L4 checksum offload  = P
+Timestamp offload    = P
 Linux                = Y
 x86-32               = Y
 x86-64               = Y
drivers/net/idpf/idpf_ethdev.c +4 -1
index cd4ebcc2c6..50aac65daf 100644
@@ -22,6 +22,8 @@ rte_spinlock_t idpf_adapter_lock;
 struct idpf_adapter_list idpf_adapter_list;
 bool idpf_adapter_list_init;
 
+uint64_t idpf_timestamp_dynflag;
+
 static const char * const idpf_valid_args[] = {
 	IDPF_TX_SINGLE_Q,
 	IDPF_RX_SINGLE_Q,
@@ -65,7 +67,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		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_OUTER_IPV4_CKSUM     |
+		RTE_ETH_RX_OFFLOAD_TIMESTAMP;
 
 	dev_info->tx_offload_capa =
 		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
drivers/net/idpf/idpf_ethdev.h +3 -0
index 7d54e5db60..ccdf4abe40 100644
@@ -167,6 +167,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 +65 -0

140 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +90 -0

106 lines not on this page · raw message

Signature · 1 line
2.26.2
#208 lore raw
In reply to [email protected]

31/10/2022 09:33, [email protected]:

Quoted 9 lines

From: Beilei Xing <[email protected]>

This patchset introduced the idpf (Infrastructure Data Path Function) PMD in DPDK for Intel® IPU E2000 (Device ID: 0x1452). The Intel® IPU E2000 targets to deliver high performance under real workloads with security and isolation. Please refer to
https://www.intel.com/content/www/us/en/products/network-io/infrastructure-processing-units/asic/e2000-asic.html
for more information.

Linux upstream is still ongoing, previous work refers to https://patchwork.ozlabs.org/project/intel-wired-lan/patch/[email protected]/.

I've fixed/improved doc and build files.
Applied, thanks.

#209 lore raw

PATCH v13 2/18 net/idpf: add support for device initialization

In reply to Junfeng Guo

Support device init and add the following dev ops:
- dev_configure
- dev_close
- dev_infos_get

---
 MAINTAINERS                            |   9 +
 doc/guides/nics/features/idpf.ini      |   9 +
 doc/guides/nics/idpf.rst               |  66 ++
 doc/guides/nics/index.rst              |   1 +
 doc/guides/rel_notes/release_22_11.rst |   6 +
 drivers/net/idpf/idpf_ethdev.c         | 886 +++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h         | 189 ++++++
 drivers/net/idpf/idpf_logs.h           |  56 ++
 drivers/net/idpf/idpf_vchnl.c          | 468 +++++++++++++
 drivers/net/idpf/meson.build           |  15 +
 drivers/net/idpf/version.map           |   3 +
 drivers/net/meson.build                |   1 +
 12 files changed, 1709 insertions(+)
 create mode 100644 doc/guides/nics/features/idpf.ini
 create mode 100644 doc/guides/nics/idpf.rst
 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_vchnl.c
 create mode 100644 drivers/net/idpf/meson.build
 create mode 100644 drivers/net/idpf/version.map
MAINTAINERS +9 -0
index 92b381bc30..34f8b9cc61 100644
@@ -764,6 +764,15 @@ F: drivers/net/ice/
 F: doc/guides/nics/ice.rst
 F: doc/guides/nics/features/ice.ini
 
+Intel idpf
+M: Jingjing Wu <[email protected]>
+M: Beilei Xing <[email protected]>
+T: git://dpdk.org/next/dpdk-next-net-intel
+F: drivers/net/idpf/
+F: drivers/common/idpf/
+F: doc/guides/nics/idpf.rst
+F: doc/guides/nics/features/idpf.ini
+
 Intel igc
 M: Junfeng Guo <[email protected]>
 M: Simei Su <[email protected]>
doc/guides/nics/features/idpf.ini new file +9 -0
new file mode 100644
index 0000000000..46aab2eb61
@@ -0,0 +1,9 @@
+;
+; Supported features of the 'idpf' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-32               = Y
+x86-64               = Y
doc/guides/nics/idpf.rst new file +66 -0

66 lines not on this page · raw message

doc/guides/nics/index.rst +1 -0
index 32c7544968..b4dd5ea522 100644
@@ -33,6 +33,7 @@ Network Interface Controller Drivers
     hns3
     i40e
     ice
+    idpf
     igb
     igc
     ionic
doc/guides/rel_notes/release_22_11.rst +6 -0
index 1c3daf141d..4af790de37 100644
@@ -160,6 +160,12 @@ New Features
 
   * Added protocol based buffer split support in scalar path.
 
+* **Added IDPF PMD [*EXPERIMENTAL*].**
+
+  Added the new ``idpf`` net driver for Intel® Infrastructure Processing Unit
+  (Intel® IPU) E2000.
+  See the :doc:`../nics/idpf` NIC guide for more details on this new driver.
+
 * **Updated Marvell cnxk driver.**
 
   * Added support for flow action REPRESENTED_PORT.
drivers/net/idpf/idpf_ethdev.c new file +886 -0

886 lines not on this page · raw message

drivers/net/idpf/idpf_ethdev.h new file +189 -0

189 lines not on this page · raw message

drivers/net/idpf/idpf_logs.h new file +56 -0

56 lines not on this page · raw message

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

468 lines not on this page · raw message

drivers/net/idpf/meson.build new file +15 -0
new file mode 100644
index 0000000000..ecf73355c3
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
+deps += ['common_idpf']
+
+sources = files(
+    'idpf_ethdev.c',
+    'idpf_vchnl.c',
+)
drivers/net/idpf/version.map new file +3 -0
new file mode 100644
index 0000000000..78c3585d7c
@@ -0,0 +1,3 @@
+DPDK_23 {
+	local: *;
+};
drivers/net/meson.build +1 -0
index 35bfa78dee..4a951b95f2 100644
@@ -28,6 +28,7 @@ drivers = [
         'i40e',
         'iavf',
         'ice',
+        'idpf',
         'igc',
         'ionic',
         'ipn3ke',
Signature · 1 line
2.34.1
#210 lore raw

PATCH v13 3/18 net/idpf: add Tx queue setup

In reply to Junfeng Guo

Add support for tx_queue_setup ops.

In the single queue model, the same descriptor queue is used by SW to post buffer descriptors to HW and by HW to post completed descriptors to SW.

In the split queue model, "RX buffer queues" are used to pass descriptor buffers from SW to HW while Rx queues are used only to pass the descriptor completions, that is, descriptors that point to completed buffers, from HW to SW. This is contrary to the single queue model in which Rx queues are used for both purposes.

---
 drivers/net/idpf/idpf_ethdev.c |  13 ++
 drivers/net/idpf/idpf_rxtx.c   | 364 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  70 +++++++
 drivers/net/idpf/idpf_vchnl.c  |   2 -
 drivers/net/idpf/meson.build   |   1 +
 5 files changed, 448 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/idpf/idpf_rxtx.c
 create mode 100644 drivers/net/idpf/idpf_rxtx.h
drivers/net/idpf/idpf_ethdev.c +13 -0
index 112dccf5c9..11f8b4ba1c 100644
@@ -11,6 +11,7 @@
 #include <errno.h>
 
 #include "idpf_ethdev.h"
+#include "idpf_rxtx.h"
 
 #define IDPF_TX_SINGLE_Q	"tx_single"
 #define IDPF_RX_SINGLE_Q	"rx_single"
@@ -37,6 +38,7 @@ static void idpf_adapter_rel(struct idpf_adapter *adapter);
 static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_configure			= idpf_dev_configure,
 	.dev_close			= idpf_dev_close,
+	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
 };
 
@@ -56,6 +58,17 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
 
+	dev_info->default_txconf = (struct rte_eth_txconf) {
+		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
+		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
+	};
+
+	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;
 }
 
drivers/net/idpf/idpf_rxtx.c new file +364 -0

364 lines not on this page · raw message

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

70 lines not on this page · raw message

drivers/net/idpf/idpf_vchnl.c +0 -2
index 9392711b61..4dae1a0b36 100644
@@ -22,8 +22,6 @@
 
 #include "idpf_ethdev.h"
 
-#define IDPF_CTLQ_LEN	64
-
 static int
 idpf_vc_clean(struct idpf_adapter *adapter)
 {
drivers/net/idpf/meson.build +1 -0
index ecf73355c3..b632b76656 100644
@@ -11,5 +11,6 @@ deps += ['common_idpf']
 
 sources = files(
     'idpf_ethdev.c',
+    'idpf_rxtx.c',
     'idpf_vchnl.c',
 )
Signature · 1 line
2.34.1
#211 lore raw

PATCH v13 4/18 net/idpf: add Rx queue setup

In reply to Junfeng Guo

Add support for rx_queue_setup ops.

---
 drivers/net/idpf/idpf_ethdev.c |  11 +
 drivers/net/idpf/idpf_rxtx.c   | 400 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  46 ++++
 3 files changed, 457 insertions(+)
drivers/net/idpf/idpf_ethdev.c +11 -0
index 11f8b4ba1c..0585153f69 100644
@@ -38,6 +38,7 @@ static void idpf_adapter_rel(struct idpf_adapter *adapter);
 static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_configure			= idpf_dev_configure,
 	.dev_close			= idpf_dev_close,
+	.rx_queue_setup			= idpf_rx_queue_setup,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
 };
@@ -63,12 +64,22 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
 	};
 
+	dev_info->default_rxconf = (struct rte_eth_rxconf) {
+		.rx_free_thresh = IDPF_DEFAULT_RX_FREE_THRESH,
+	};
+
 	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->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,
+	};
+
 	return 0;
 }
 
drivers/net/idpf/idpf_rxtx.c +400 -0

418 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +46 -0

61 lines not on this page · raw message

Signature · 1 line
2.34.1
#212 lore raw

PATCH v13 5/18 net/idpf: add support for device start and stop

In reply to Junfeng Guo

Add dev ops dev_start, dev_stop and link_update.

---
 drivers/net/idpf/idpf_ethdev.c | 55 ++++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.c   | 20 +++++++++++++
 2 files changed, 75 insertions(+)
drivers/net/idpf/idpf_ethdev.c +55 -0
index 0585153f69..3430d00e92 100644
@@ -30,17 +30,38 @@ static const char * const idpf_valid_args[] = {
 };
 
 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 void idpf_adapter_rel(struct idpf_adapter *adapter);
 
+static int
+idpf_dev_link_update(struct rte_eth_dev *dev,
+		     __rte_unused int wait_to_complete)
+{
+	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_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_configure			= idpf_dev_configure,
+	.dev_start			= idpf_dev_start,
+	.dev_stop			= idpf_dev_stop,
 	.dev_close			= idpf_dev_close,
 	.rx_queue_setup			= idpf_rx_queue_setup,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
+	.link_update			= idpf_dev_link_update,
 };
 
 static int
@@ -284,6 +305,40 @@ idpf_dev_configure(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;
+
+	if (dev->data->mtu > vport->max_mtu) {
+		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
+		return -1;
+	}
+
+	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
+
+	/* TODO: start queues */
+
+	if (idpf_vc_ena_dis_vport(vport, true) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to enable vport");
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+idpf_dev_stop(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+
+	idpf_vc_ena_dis_vport(vport, false);
+
+	/* TODO: stop queues */
+
+	return 0;
+}
+
 static int
 idpf_dev_close(struct rte_eth_dev *dev)
 {
drivers/net/idpf/idpf_rxtx.c +20 -0
index 25dd5d85d5..3528d2f2c7 100644
@@ -334,6 +334,11 @@ idpf_rx_split_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	if (check_rx_thresh(nb_desc, rx_free_thresh) != 0)
 		return -EINVAL;
 
+	if (rx_conf->rx_deferred_start) {
+		PMD_INIT_LOG(ERR, "Queue start is not supported currently.");
+		return -EINVAL;
+	}
+
 	/* Setup Rx description queue */
 	rxq = rte_zmalloc_socket("idpf rxq",
 				 sizeof(struct idpf_rx_queue),
@@ -465,6 +470,11 @@ idpf_rx_single_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	if (check_rx_thresh(nb_desc, rx_free_thresh) != 0)
 		return -EINVAL;
 
+	if (rx_conf->rx_deferred_start) {
+		PMD_INIT_LOG(ERR, "Queue start is not supported currently.");
+		return -EINVAL;
+	}
+
 	/* Setup Rx description queue */
 	rxq = rte_zmalloc_socket("idpf rxq",
 				 sizeof(struct idpf_rx_queue),
@@ -569,6 +579,11 @@ idpf_tx_split_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	if (check_tx_thresh(nb_desc, tx_rs_thresh, tx_free_thresh) != 0)
 		return -EINVAL;
 
+	if (tx_conf->tx_deferred_start) {
+		PMD_INIT_LOG(ERR, "Queue start is not supported currently.");
+		return -EINVAL;
+	}
+
 	/* Allocate the TX queue data structure. */
 	txq = rte_zmalloc_socket("idpf split txq",
 				 sizeof(struct idpf_tx_queue),
@@ -691,6 +706,11 @@ idpf_tx_single_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	if (check_tx_thresh(nb_desc, tx_rs_thresh, tx_free_thresh) != 0)
 		return -EINVAL;
 
+	if (tx_conf->tx_deferred_start) {
+		PMD_INIT_LOG(ERR, "Queue start is not supported currently.");
+		return -EINVAL;
+	}
+
 	/* Allocate the TX queue data structure. */
 	txq = rte_zmalloc_socket("idpf txq",
 				 sizeof(struct idpf_tx_queue),
Signature · 1 line
2.34.1
#213 lore raw

PATCH v13 6/18 net/idpf: add support for queue start

In reply to Junfeng Guo

Add support for these device ops:
- rx_queue_start
- tx_queue_start

---
 drivers/net/idpf/idpf_ethdev.c |  40 ++-
 drivers/net/idpf/idpf_ethdev.h |   9 +
 drivers/net/idpf/idpf_rxtx.c   | 237 +++++++++++++++--
 drivers/net/idpf/idpf_rxtx.h   |   6 +
 drivers/net/idpf/idpf_vchnl.c  | 447 +++++++++++++++++++++++++++++++++
 5 files changed, 718 insertions(+), 21 deletions(-)
drivers/net/idpf/idpf_ethdev.c +39 -1
index 3430d00e92..abbf519977 100644
@@ -58,6 +58,8 @@ 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,
+	.tx_queue_start			= idpf_tx_queue_start,
 	.rx_queue_setup			= idpf_rx_queue_setup,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
@@ -305,6 +307,39 @@ idpf_dev_configure(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 == NULL || txq->tx_deferred_start)
+			continue;
+		err = idpf_tx_queue_start(dev, i);
+		if (err != 0) {
+			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 == NULL || rxq->rx_deferred_start)
+			continue;
+		err = idpf_rx_queue_start(dev, i);
+		if (err != 0) {
+			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)
 {
@@ -317,7 +352,10 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
 
-	/* TODO: start queues */
+	if (idpf_start_queues(dev) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to start queues");
+		return -1;
+	}
 
 	if (idpf_vc_ena_dis_vport(vport, true) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
drivers/net/idpf/idpf_ethdev.h +9 -0
index 84ae6641e2..96c22009e9 100644
@@ -24,7 +24,9 @@
 #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
@@ -182,6 +184,13 @@ int idpf_vc_check_api_version(struct idpf_adapter *adapter);
 int idpf_vc_get_caps(struct idpf_adapter *adapter);
 int idpf_vc_create_vport(struct idpf_adapter *adapter);
 int idpf_vc_destroy_vport(struct idpf_vport *vport);
+int idpf_vc_config_rxqs(struct idpf_vport *vport);
+int idpf_vc_config_rxq(struct idpf_vport *vport, uint16_t rxq_id);
+int idpf_vc_config_txqs(struct idpf_vport *vport);
+int idpf_vc_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_vc_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_vc_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 +217 -20

288 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +6 -0
index 3f3932c3eb..ab9b3830fd 100644
@@ -50,6 +50,7 @@ struct idpf_rx_queue {
 
 	bool q_set;             /* if rx queue has been configured */
 	bool q_started;         /* if rx queue has been started */
+	bool rx_deferred_start; /* don't start this queue in dev start */
 
 	/* only valid for split queue mode */
 	uint8_t expected_gen_id;
@@ -95,6 +96,7 @@ struct idpf_tx_queue {
 
 	bool q_set;		/* if tx queue has been configured */
 	bool q_started;		/* if tx queue has been started */
+	bool tx_deferred_start; /* don't start this queue in dev start */
 
 	/* only valid for split queue mode */
 	uint16_t sw_nb_desc;
@@ -109,8 +111,12 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_rxconf *rx_conf,
 			struct rte_mempool *mp);
+int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
+int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
+int idpf_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 
 #endif /* _IDPF_RXTX_H_ */
drivers/net/idpf/idpf_vchnl.c +447 -0

465 lines not on this page · raw message

Signature · 1 line
2.34.1
#214 lore raw

PATCH v13 7/18 net/idpf: add support for queue stop

In reply to Junfeng Guo

Add support for these device ops:
- rx_queue_stop
- tx_queue_stop

---
 doc/guides/nics/features/idpf.ini |   1 +
 drivers/net/idpf/idpf_ethdev.c    |  14 ++-
 drivers/net/idpf/idpf_rxtx.c      | 148 ++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h      |  13 +++
 drivers/net/idpf/idpf_vchnl.c     |  69 ++++++++++++++
 5 files changed, 241 insertions(+), 4 deletions(-)
doc/guides/nics/features/idpf.ini +1 -0
index 46aab2eb61..c25fa5de3f 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Queue start/stop     = Y
 Linux                = Y
 x86-32               = Y
 x86-64               = Y
drivers/net/idpf/idpf_ethdev.c +10 -4
index abbf519977..05f087a03c 100644
@@ -59,7 +59,9 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.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,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
@@ -347,22 +349,26 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	if (dev->data->mtu > vport->max_mtu) {
 		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
-		return -1;
+		goto err_mtu;
 	}
 
 	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
 
 	if (idpf_start_queues(dev) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
-		return -1;
+		goto err_mtu;
 	}
 
 	if (idpf_vc_ena_dis_vport(vport, true) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
-		return -1;
+		goto err_vport;
 	}
 
 	return 0;
+err_vport:
+	idpf_stop_queues(dev);
+err_mtu:
+	return -1;
 }
 
 static int
@@ -372,7 +378,7 @@ idpf_dev_stop(struct rte_eth_dev *dev)
 
 	idpf_vc_ena_dis_vport(vport, false);
 
-	/* TODO: stop queues */
+	idpf_stop_queues(dev);
 
 	return 0;
 }
drivers/net/idpf/idpf_rxtx.c +148 -0

187 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +13 -0
index ab9b3830fd..b959638489 100644
@@ -51,6 +51,7 @@ struct idpf_rx_queue {
 	bool q_set;             /* if rx queue has been configured */
 	bool q_started;         /* if rx queue has been started */
 	bool rx_deferred_start; /* don't start this queue in dev start */
+	const struct idpf_rxq_ops *ops;
 
 	/* only valid for split queue mode */
 	uint8_t expected_gen_id;
@@ -97,6 +98,7 @@ struct idpf_tx_queue {
 	bool q_set;		/* if tx queue has been configured */
 	bool q_started;		/* if tx queue has been started */
 	bool tx_deferred_start; /* don't start this queue in dev start */
+	const struct idpf_txq_ops *ops;
 
 	/* only valid for split queue mode */
 	uint16_t sw_nb_desc;
@@ -107,16 +109,27 @@ struct idpf_tx_queue {
 	struct idpf_tx_queue *complq;
 };
 
+struct idpf_rxq_ops {
+	void (*release_mbufs)(struct idpf_rx_queue *rxq);
+};
+
+struct idpf_txq_ops {
+	void (*release_mbufs)(struct idpf_tx_queue *txq);
+};
+
 int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_rxconf *rx_conf,
 			struct rte_mempool *mp);
 int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int idpf_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
 int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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_stop_queues(struct rte_eth_dev *dev);
 #endif /* _IDPF_RXTX_H_ */
drivers/net/idpf/idpf_vchnl.c +69 -0

75 lines not on this page · raw message

Signature · 1 line
2.34.1
#215 lore raw

PATCH v13 8/18 net/idpf: add queue release

In reply to Junfeng Guo

Add support for queue operations:
- rx_queue_release
- tx_queue_release

---
 drivers/net/idpf/idpf_ethdev.c |  2 +
 drivers/net/idpf/idpf_rxtx.c   | 81 ++++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  3 ++
 3 files changed, 86 insertions(+)
drivers/net/idpf/idpf_ethdev.c +2 -0
index 05f087a03c..dee1e03d43 100644
@@ -63,7 +63,9 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.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,
 	.dev_infos_get			= idpf_dev_info_get,
 	.link_update			= idpf_dev_link_update,
 };
drivers/net/idpf/idpf_rxtx.c +81 -0

117 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +3 -0
index b959638489..37944edcac 100644
@@ -124,12 +124,15 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+void idpf_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
+
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
 int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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);
 
 void idpf_stop_queues(struct rte_eth_dev *dev);
 #endif /* _IDPF_RXTX_H_ */
Signature · 1 line
2.34.1
#216 lore raw

PATCH v13 9/18 net/idpf: add support for MTU configuration

In reply to Junfeng Guo

Add dev ops mtu_set.

---
 doc/guides/nics/features/idpf.ini |  1 +
 drivers/net/idpf/idpf_ethdev.c    | 14 ++++++++++++++
 2 files changed, 15 insertions(+)
doc/guides/nics/features/idpf.ini +1 -0
index c25fa5de3f..c8f4a0d6ed 100644
@@ -5,6 +5,7 @@
 ;
 [Features]
 Queue start/stop     = Y
+MTU update           = Y
 Linux                = Y
 x86-32               = Y
 x86-64               = Y
drivers/net/idpf/idpf_ethdev.c +14 -0
index dee1e03d43..94f4671057 100644
@@ -35,6 +35,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);
 static void idpf_adapter_rel(struct idpf_adapter *adapter);
 
 static int
@@ -68,6 +69,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
@@ -110,6 +112,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)
 {
Signature · 1 line
2.34.1
#217 lore raw

PATCH v13 10/18 net/idpf: add support for basic Rx datapath

In reply to Junfeng Guo

Add basic Rx support in split queue mode and single queue mode.

---
 drivers/net/idpf/idpf_ethdev.c |   2 +
 drivers/net/idpf/idpf_rxtx.c   | 273 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |   7 +-
 3 files changed, 281 insertions(+), 1 deletion(-)
drivers/net/idpf/idpf_ethdev.c +2 -0
index 94f4671057..df2a760673 100644
@@ -375,6 +375,8 @@ idpf_dev_start(struct rte_eth_dev *dev)
 		goto err_mtu;
 	}
 
+	idpf_set_rx_function(dev);
+
 	if (idpf_vc_ena_dis_vport(vport, true) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
 		goto err_vport;
drivers/net/idpf/idpf_rxtx.c +273 -0

276 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +6 -1
index 37944edcac..650c6c1c3a 100644
@@ -133,6 +133,11 @@ int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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);
 void idpf_stop_queues(struct rte_eth_dev *dev);
+
+void idpf_set_rx_function(struct rte_eth_dev *dev);
 #endif /* _IDPF_RXTX_H_ */
Signature · 1 line
2.34.1
#218 lore raw

PATCH v13 11/18 net/idpf: add support for basic Tx datapath

In reply to Junfeng Guo

Add basic Tx support in split queue mode and single queue mode.

---
 drivers/net/idpf/idpf_ethdev.c |   3 +
 drivers/net/idpf/idpf_ethdev.h |   1 +
 drivers/net/idpf/idpf_rxtx.c   | 357 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  10 +
 4 files changed, 371 insertions(+)
drivers/net/idpf/idpf_ethdev.c +3 -0
index df2a760673..6fb56e584d 100644
@@ -88,6 +88,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
 
+	dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+
 	dev_info->default_txconf = (struct rte_eth_txconf) {
 		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
 		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
@@ -376,6 +378,7 @@ idpf_dev_start(struct rte_eth_dev *dev)
 	}
 
 	idpf_set_rx_function(dev);
+	idpf_set_tx_function(dev);
 
 	if (idpf_vc_ena_dis_vport(vport, true) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
drivers/net/idpf/idpf_ethdev.h +1 -0
index 96c22009e9..af0a8e2970 100644
@@ -35,6 +35,7 @@
 
 #define IDPF_MIN_BUF_SIZE	1024
 #define IDPF_MAX_FRAME_SIZE	9728
+#define IDPF_MIN_FRAME_SIZE	14
 
 #define IDPF_NUM_MACADDR_MAX	64
 
drivers/net/idpf/idpf_rxtx.c +357 -0

372 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +10 -0
index 650c6c1c3a..30dc94b3dd 100644
@@ -21,6 +21,8 @@
 #define IDPF_DEFAULT_TX_RS_THRESH	32
 #define IDPF_DEFAULT_TX_FREE_THRESH	32
 
+#define IDPF_TX_MAX_MTU_SEG	10
+
 struct idpf_rx_queue {
 	struct idpf_adapter *adapter;   /* the adapter this queue belongs to */
 	struct rte_mempool *mp;         /* mbuf pool to populate Rx ring */
@@ -137,7 +139,15 @@ 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);
 #endif /* _IDPF_RXTX_H_ */
Signature · 1 line
2.34.1
#219 lore raw

PATCH v13 12/18 net/idpf: support parsing packet type

In reply to Junfeng Guo

Parse packet type during receiving packets.

---
 drivers/net/idpf/idpf_ethdev.c |   6 +
 drivers/net/idpf/idpf_ethdev.h |   6 +
 drivers/net/idpf/idpf_rxtx.c   |  11 ++
 drivers/net/idpf/idpf_rxtx.h   |   5 +
 drivers/net/idpf/idpf_vchnl.c  | 240 +++++++++++++++++++++++++++++++++
 5 files changed, 268 insertions(+)
drivers/net/idpf/idpf_ethdev.c +6 -0
index 6fb56e584d..630bdabcd4 100644
@@ -709,6 +709,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 != 0) {
+		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 == NULL) {
drivers/net/idpf/idpf_ethdev.h +6 -0
index af0a8e2970..db9af58f72 100644
@@ -39,6 +39,8 @@
 
 #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)
@@ -125,6 +127,8 @@ struct idpf_adapter {
 	/* 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;
 };
 
 TAILQ_HEAD(idpf_adapter_list, idpf_adapter);
@@ -182,6 +186,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_vc_check_api_version(struct idpf_adapter *adapter);
+int idpf_get_pkt_type(struct idpf_adapter *adapter);
 int idpf_vc_get_caps(struct idpf_adapter *adapter);
 int idpf_vc_create_vport(struct idpf_adapter *adapter);
 int idpf_vc_destroy_vport(struct idpf_vport *vport);
@@ -193,6 +198,7 @@ int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,
 		      bool rx, bool on);
 int idpf_vc_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_vc_ena_dis_vport(struct idpf_vport *vport, bool enable);
+int idpf_vc_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 +11 -0
index f55d2143b9..a980714060 100644
@@ -1281,6 +1281,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	volatile struct virtchnl2_rx_flex_desc_adv_nic_3 *rx_desc;
 	uint16_t pktlen_gen_bufq_id;
 	struct idpf_rx_queue *rxq;
+	const uint32_t *ptype_tbl;
 	struct rte_mbuf *rxm;
 	uint16_t rx_id_bufq1;
 	uint16_t rx_id_bufq2;
@@ -1300,6 +1301,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	rx_id_bufq1 = rxq->bufq1->rx_next_avail;
 	rx_id_bufq2 = rxq->bufq2->rx_next_avail;
 	rx_desc_ring = rxq->rx_ring;
+	ptype_tbl = rxq->adapter->ptype_tbl;
 
 	while (nb_rx < nb_pkts) {
 		rx_desc = &rx_desc_ring[rx_id];
@@ -1347,6 +1349,10 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		rxm->next = NULL;
 		rxm->nb_segs = 1;
 		rxm->port = rxq->port_id;
+		rxm->packet_type =
+			ptype_tbl[(rte_le_to_cpu_16(rx_desc->ptype_err_fflags0) &
+				   VIRTCHNL2_RX_FLEX_DESC_ADV_PTYPE_M) >>
+				  VIRTCHNL2_RX_FLEX_DESC_ADV_PTYPE_S];
 
 		rx_pkts[nb_rx++] = rxm;
 	}
@@ -1533,6 +1539,7 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	volatile union virtchnl2_rx_desc *rxdp;
 	union virtchnl2_rx_desc rxd;
 	struct idpf_rx_queue *rxq;
+	const uint32_t *ptype_tbl;
 	uint16_t rx_id, nb_hold;
 	struct rte_eth_dev *dev;
 	uint16_t rx_packet_len;
@@ -1551,6 +1558,7 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 
 	rx_id = rxq->rx_tail;
 	rx_ring = rxq->rx_ring;
+	ptype_tbl = rxq->adapter->ptype_tbl;
 
 	while (nb_rx < nb_pkts) {
 		rxdp = &rx_ring[rx_id];
@@ -1603,6 +1611,9 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		rxm->pkt_len = rx_packet_len;
 		rxm->data_len = rx_packet_len;
 		rxm->port = rxq->port_id;
+		rxm->packet_type =
+			ptype_tbl[(uint8_t)(rte_cpu_to_le_16(rxd.flex_nic_wb.ptype_flex_flags0) &
+					    VIRTCHNL2_RX_FLEX_DESC_PTYPE_M)];
 
 		rx_pkts[nb_rx++] = rxm;
 	}
drivers/net/idpf/idpf_rxtx.h +5 -0
index 30dc94b3dd..3853ed55c9 100644
@@ -23,6 +23,10 @@
 
 #define IDPF_TX_MAX_MTU_SEG	10
 
+#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 */
@@ -150,4 +154,5 @@ 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);
+
 #endif /* _IDPF_RXTX_H_ */
drivers/net/idpf/idpf_vchnl.c +240 -0

255 lines not on this page · raw message

Signature · 1 line
2.34.1
#220 lore raw

PATCH v13 13/18 net/idpf: add support for write back based on ITR expire

In reply to Junfeng Guo

Enable write back on ITR expire, then packets can be received one by one.

---
 drivers/net/idpf/idpf_ethdev.c | 116 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h |  13 ++++
 drivers/net/idpf/idpf_vchnl.c  | 111 +++++++++++++++++++++++++++++++
 3 files changed, 240 insertions(+)
drivers/net/idpf/idpf_ethdev.c +116 -0
index 630bdabcd4..8045073780 100644
@@ -327,6 +327,90 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
+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 idpf_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 == NULL) {
+		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 != 0) {
+		dynctl_reg_start =
+			vport->recv_vectors->vchunks.vchunks->dynctl_reg_start;
+		itrn_reg_start =
+			vport->recv_vectors->vchunks.vchunks->itrn_reg_start;
+		dynctl_val = IDPF_READ_REG(hw, dynctl_reg_start);
+		PMD_DRV_LOG(DEBUG, "Value of dynctl_reg_start is 0x%x",
+			    dynctl_val);
+		itrn_val = IDPF_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 written back based on ITR expiration irrespective
+		 * of INTENA setting.
+		 */
+		/* TBD: need to tune INTERVAL value for better performance. */
+		if (itrn_val != 0)
+			IDPF_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
+			IDPF_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_vc_config_irq_map_unmap(vport, true) != 0) {
+		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)
 {
@@ -364,6 +448,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;
 
 	if (dev->data->mtu > vport->max_mtu) {
 		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
@@ -372,6 +460,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_vc_alloc_vectors(vport, req_vecs_num) != 0) {
+		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) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to configure irqs");
+		goto err_mtu;
+	}
+
 	if (idpf_start_queues(dev) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
 		goto err_mtu;
@@ -401,6 +506,10 @@ idpf_dev_stop(struct rte_eth_dev *dev)
 
 	idpf_stop_queues(dev);
 
+	idpf_vc_config_irq_map_unmap(vport, false);
+
+	idpf_vc_dealloc_vectors(vport);
+
 	return 0;
 }
 
@@ -412,6 +521,11 @@ idpf_dev_close(struct rte_eth_dev *dev)
 
 	idpf_vc_destroy_vport(vport);
 
+	rte_free(vport->recv_vectors);
+	vport->recv_vectors = NULL;
+
+	rte_free(vport->qv_map);
+	vport->qv_map = NULL;
 
 	adapter->cur_vports &= ~RTE_BIT32(vport->devarg_id);
 
@@ -766,6 +880,8 @@ idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
 	adapter->cur_vports = 0;
 	adapter->cur_vport_nb = 0;
 
+	adapter->used_vecs_num = 0;
+
 	return ret;
 
 err_vports:
drivers/net/idpf/idpf_ethdev.h +13 -0
index db9af58f72..811240c386 100644
@@ -33,6 +33,9 @@
 #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_MIN_BUF_SIZE	1024
 #define IDPF_MAX_FRAME_SIZE	9728
 #define IDPF_MIN_FRAME_SIZE	14
@@ -92,6 +95,11 @@ struct idpf_vport {
 	struct rte_eth_dev_data *dev_data; /* Pointer to the device data */
 	uint16_t max_pkt_len; /* Maximum packet length */
 
+	/* 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;
 
@@ -124,6 +132,8 @@ struct idpf_adapter {
 	uint16_t cur_vport_nb;
 	uint16_t cur_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;
@@ -198,6 +208,9 @@ int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,
 		      bool rx, bool on);
 int idpf_vc_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_vc_ena_dis_vport(struct idpf_vport *vport, bool enable);
+int idpf_vc_config_irq_map_unmap(struct idpf_vport *vport, bool map);
+int idpf_vc_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors);
+int idpf_vc_dealloc_vectors(struct idpf_vport *vport);
 int idpf_vc_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 +111 -0

123 lines not on this page · raw message

Signature · 1 line
2.34.1
#221 lore raw

PATCH v13 14/18 net/idpf: add support for RSS

In reply to Junfeng Guo

Add RSS support.

---
 drivers/net/idpf/idpf_ethdev.c | 116 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h |  26 ++++++++
 drivers/net/idpf/idpf_vchnl.c  |  97 +++++++++++++++++++++++++++
 3 files changed, 239 insertions(+)
drivers/net/idpf/idpf_ethdev.c +116 -0
index 8045073780..ea7d3bfd7e 100644
@@ -86,6 +86,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->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
@@ -198,6 +199,8 @@ idpf_parse_devarg_id(char *name)
 	return val;
 }
 
+#define IDPF_RSS_KEY_LEN 52
+
 static int
 idpf_init_vport(struct rte_eth_dev *dev)
 {
@@ -218,6 +221,10 @@ idpf_init_vport(struct rte_eth_dev *dev)
 	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++) {
@@ -275,10 +282,102 @@ idpf_init_vport(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+idpf_config_rss(struct idpf_vport *vport)
+{
+	int ret;
+
+	ret = idpf_vc_set_rss_key(vport);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS key");
+		return ret;
+	}
+
+	ret = idpf_vc_set_rss_lut(vport);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS lut");
+		return ret;
+	}
+
+	ret = idpf_vc_set_rss_hash(vport);
+	if (ret != 0) {
+		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 = rte_zmalloc("rss_key",
+				     vport->rss_key_size, 0);
+	if (vport->rss_key == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS key");
+		ret = -ENOMEM;
+		goto err_alloc_key;
+	}
+
+	lut_size = vport->rss_lut_size;
+	vport->rss_lut = rte_zmalloc("rss_lut",
+				     sizeof(uint32_t) * lut_size, 0);
+	if (vport->rss_lut == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS lut");
+		ret = -ENOMEM;
+		goto err_alloc_lut;
+	}
+
+	if (rss_conf->rss_key == NULL) {
+		for (i = 0; i < vport->rss_key_size; i++)
+			vport->rss_key[i] = (uint8_t)rte_rand();
+	} else if (rss_conf->rss_key_len != vport->rss_key_size) {
+		PMD_INIT_LOG(ERR, "Invalid RSS key length in RSS configuration, should be %d",
+			     vport->rss_key_size);
+		ret = -EINVAL;
+		goto err_cfg_key;
+	} else {
+		rte_memcpy(vport->rss_key, rss_conf->rss_key,
+			   vport->rss_key_size);
+	}
+
+	for (i = 0; i < lut_size; i++)
+		vport->rss_lut[i] = i % nb_q;
+
+	vport->rss_hf = IDPF_DEFAULT_RSS_HASH_EXPANDED;
+
+	ret = idpf_config_rss(vport);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS");
+		goto err_cfg_key;
+	}
+
+	return ret;
+
+err_cfg_key:
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+err_alloc_lut:
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+err_alloc_key:
+	return ret;
+}
+
 static int
 idpf_dev_configure(struct rte_eth_dev *dev)
 {
+	struct idpf_vport *vport = dev->data->dev_private;
 	struct rte_eth_conf *conf = &dev->data->dev_conf;
+	struct idpf_adapter *adapter = vport->adapter;
+	int ret;
 
 	if (conf->link_speeds & RTE_ETH_LINK_SPEED_FIXED) {
 		PMD_INIT_LOG(ERR, "Setting link speed is not supported");
@@ -324,6 +423,17 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 		return -1;
 	}
 
+	if (adapter->caps->rss_caps != 0 && dev->data->nb_rx_queues != 0) {
+		ret = idpf_init_rss(vport);
+		if (ret != 0) {
+			PMD_INIT_LOG(ERR, "Failed to init rss");
+			return ret;
+		}
+	} else {
+		PMD_INIT_LOG(ERR, "RSS is not supported.");
+		return -1;
+	}
+
 	return 0;
 }
 
@@ -521,6 +631,12 @@ idpf_dev_close(struct rte_eth_dev *dev)
 
 	idpf_vc_destroy_vport(vport);
 
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+
 	rte_free(vport->recv_vectors);
 	vport->recv_vectors = NULL;
 
drivers/net/idpf/idpf_ethdev.h +26 -0
index 811240c386..8d0804f603 100644
@@ -48,6 +48,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)
+
 #define IDPF_ADAPTER_NAME_LEN	(PCI_PRI_STR_SIZE + 1)
 
 /* Message type read in virtual channel from PF */
@@ -90,11 +104,20 @@ struct idpf_vport {
 	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;
@@ -200,6 +223,9 @@ int idpf_get_pkt_type(struct idpf_adapter *adapter);
 int idpf_vc_get_caps(struct idpf_adapter *adapter);
 int idpf_vc_create_vport(struct idpf_adapter *adapter);
 int idpf_vc_destroy_vport(struct idpf_vport *vport);
+int idpf_vc_set_rss_key(struct idpf_vport *vport);
+int idpf_vc_set_rss_lut(struct idpf_vport *vport);
+int idpf_vc_set_rss_hash(struct idpf_vport *vport);
 int idpf_vc_config_rxqs(struct idpf_vport *vport);
 int idpf_vc_config_rxq(struct idpf_vport *vport, uint16_t rxq_id);
 int idpf_vc_config_txqs(struct idpf_vport *vport);
drivers/net/idpf/idpf_vchnl.c +97 -0

109 lines not on this page · raw message

Signature · 1 line
2.34.1
#222 lore raw

PATCH v13 15/18 net/idpf: add support for Rx offloading

In reply to Junfeng Guo

Add Rx offloading support:
- support CHKSUM and RSS offload for split queue model
- support CHKSUM offload for single queue model

---
 doc/guides/nics/features/idpf.ini |   5 ++
 drivers/net/idpf/idpf_ethdev.c    |   6 ++
 drivers/net/idpf/idpf_rxtx.c      | 123 ++++++++++++++++++++++++++++++
 3 files changed, 134 insertions(+)
doc/guides/nics/features/idpf.ini +5 -0
index c8f4a0d6ed..6eefac9529 100644
@@ -3,9 +3,14 @@
 ;
 ; Refer to default.ini for the full list of available PMD features.
 ;
+; A feature with "P" indicates only be supported when non-vector path
+; is selected.
+;
 [Features]
 Queue start/stop     = Y
 MTU update           = Y
+L3 checksum offload  = P
+L4 checksum offload  = P
 Linux                = Y
 x86-32               = Y
 x86-64               = Y
drivers/net/idpf/idpf_ethdev.c +6 -0
index ea7d3bfd7e..88f3db3267 100644
@@ -89,6 +89,12 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->flow_type_rss_offloads = IDPF_RSS_OFFLOAD_ALL;
 	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
 
+	dev_info->rx_offload_capa =
+		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;
+
 	dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
 	dev_info->default_txconf = (struct rte_eth_txconf) {
drivers/net/idpf/idpf_rxtx.c +123 -0

171 lines not on this page · raw message

Signature · 1 line
2.34.1
#223 lore raw

PATCH v13 16/18 net/idpf: add support for Tx offloading

In reply to Junfeng Guo

Add Tx offloading support:
- support TSO

---
 doc/guides/nics/features/idpf.ini |   1 +
 drivers/net/idpf/idpf_ethdev.c    |   4 +-
 drivers/net/idpf/idpf_rxtx.c      | 128 +++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_rxtx.h      |  22 +++++
 4 files changed, 152 insertions(+), 3 deletions(-)
doc/guides/nics/features/idpf.ini +1 -0
index 6eefac9529..86c182021f 100644
@@ -9,6 +9,7 @@
 [Features]
 Queue start/stop     = Y
 MTU update           = Y
+TSO                  = P
 L3 checksum offload  = P
 L4 checksum offload  = P
 Linux                = Y
drivers/net/idpf/idpf_ethdev.c +3 -1
index 88f3db3267..868f28d003 100644
@@ -95,7 +95,9 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		RTE_ETH_RX_OFFLOAD_TCP_CKSUM            |
 		RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
 
-	dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+	dev_info->tx_offload_capa =
+		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
 	dev_info->default_txconf = (struct rte_eth_txconf) {
 		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
drivers/net/idpf/idpf_rxtx.c +126 -2

199 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +22 -0
index 3853ed55c9..54d297aac6 100644
@@ -23,6 +23,16 @@
 
 #define IDPF_TX_MAX_MTU_SEG	10
 
+#define IDPF_MIN_TSO_MSS	88
+#define IDPF_MAX_TSO_MSS	9728
+#define IDPF_MAX_TSO_FRAME_SIZE	262143
+#define IDPF_TX_MAX_MTU_SEG     10
+
+#define IDPF_TX_OFFLOAD_MASK RTE_MBUF_F_TX_TCP_SEG
+
+#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])))
@@ -115,6 +125,18 @@ struct idpf_tx_queue {
 	struct idpf_tx_queue *complq;
 };
 
+/* Offload features */
+union idpf_tx_offload {
+	uint64_t data;
+	struct {
+		uint64_t l2_len:7; /* L2 (MAC) Header Length. */
+		uint64_t l3_len:9; /* L3 (IP) Header Length. */
+		uint64_t l4_len:8; /* L4 Header Length. */
+		uint64_t tso_segsz:16; /* TCP TSO segment size */
+		/* uint64_t unused : 24; */
+	};
+};
+
 struct idpf_rxq_ops {
 	void (*release_mbufs)(struct idpf_rx_queue *rxq);
 };
Signature · 1 line
2.34.1
#224 lore raw

PATCH v13 17/18 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.

---
 doc/guides/nics/idpf.rst                |  19 +
 drivers/net/idpf/idpf_ethdev.c          |   3 +-
 drivers/net/idpf/idpf_ethdev.h          |   5 +
 drivers/net/idpf/idpf_rxtx.c            | 145 ++++
 drivers/net/idpf/idpf_rxtx.h            |  21 +
 drivers/net/idpf/idpf_rxtx_vec_avx512.c | 871 ++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx_vec_common.h | 100 +++
 drivers/net/idpf/meson.build            |  28 +
 8 files changed, 1191 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
doc/guides/nics/idpf.rst +19 -0
index c1001d5d0c..3039c61748 100644
@@ -64,3 +64,22 @@ Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and
 for details.
 
 
+Features
+--------
+
+Vector PMD
+~~~~~~~~~~
+
+Vector path for RX and TX path are selected automatically. The paths
+are chosen based on 2 conditions.
+
+- ``CPU``
+  On the X86 platform, the driver checks if the CPU supports AVX512.
+  If the CPU supports AVX512 and EAL argument ``--force-max-simd-bitwidth``
+  is set to 512, AVX512 paths will be chosen.
+
+- ``Offload features``
+  The supported HW offload features are described in the document idpf.ini,
+  A value "P" means the offload feature is not supported by vector path.
+  If any not supported features are used, idpf vector PMD is disabled and the
+  scalar paths are chosen.
drivers/net/idpf/idpf_ethdev.c +2 -1
index 868f28d003..62b13b602e 100644
@@ -97,7 +97,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->tx_offload_capa =
 		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
-		RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS		|
+		RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
 	dev_info->default_txconf = (struct rte_eth_txconf) {
 		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
drivers/net/idpf/idpf_ethdev.h +5 -0
index 8d0804f603..7d54e5db60 100644
@@ -162,6 +162,11 @@ struct idpf_adapter {
 	uint32_t max_txq_per_msg;
 
 	uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned;
+
+	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 +145 -0

185 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +21 -0
index 54d297aac6..506bf8a57d 100644
@@ -18,6 +18,12 @@
 #define IDPF_RX_MAX_BURST		32
 #define IDPF_DEFAULT_RX_FREE_THRESH	32
 
+/* used for Vector PMD */
+#define IDPF_VPMD_RX_MAX_BURST	32
+#define IDPF_VPMD_TX_MAX_BURST	32
+#define IDPF_VPMD_DESCS_PER_LOOP	4
+#define IDPF_RXQ_REARM_THRESH	64
+
 #define IDPF_DEFAULT_TX_RS_THRESH	32
 #define IDPF_DEFAULT_TX_FREE_THRESH	32
 
@@ -54,6 +60,11 @@ struct idpf_rx_queue {
 	struct rte_mbuf *pkt_last_seg;  /* last segment of current packet */
 	struct rte_mbuf fake_mbuf;      /* dummy mbuf */
 
+	/* used for VPMD */
+	uint16_t rxrearm_nb;       /* number of remaining to be re-armed */
+	uint16_t rxrearm_start;    /* the idx we start the re-arming from */
+	uint64_t mbuf_initializer; /* value to init mbufs */
+
 	uint16_t rx_nb_avail;
 	uint16_t rx_next_avail;
 
@@ -84,6 +95,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 */
@@ -149,6 +164,7 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_rxconf *rx_conf,
 			struct rte_mempool *mp);
+int idpf_singleq_tx_vec_setup_avx512(struct idpf_tx_queue *txq);
 int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
@@ -157,16 +173,21 @@ void idpf_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
+int idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq);
 int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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_singleq_recv_pkts_avx512(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_singleq_xmit_pkts_avx512(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,
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +871 -0

871 lines not on this page · raw message

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

100 lines not on this page · raw message

drivers/net/idpf/meson.build +28 -0
index b632b76656..da99c098ab 100644
@@ -14,3 +14,31 @@ sources = files(
     'idpf_rxtx.c',
     '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_common_idpf, 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
Signature · 1 line
2.34.1
#225 lore raw

PATCH v13 18/18 net/idpf: add support for timestamp offload

In reply to Junfeng Guo

Add support for timestamp offload.

---
 doc/guides/nics/features/idpf.ini |  1 +
 drivers/net/idpf/idpf_ethdev.c    |  5 +-
 drivers/net/idpf/idpf_ethdev.h    |  3 ++
 drivers/net/idpf/idpf_rxtx.c      | 65 ++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h      | 90 +++++++++++++++++++++++++++++++
 5 files changed, 163 insertions(+), 1 deletion(-)
doc/guides/nics/features/idpf.ini +1 -0
index 86c182021f..5fbad9600c 100644
@@ -12,6 +12,7 @@ MTU update           = Y
 TSO                  = P
 L3 checksum offload  = P
 L4 checksum offload  = P
+Timestamp offload    = P
 Linux                = Y
 x86-32               = Y
 x86-64               = Y
drivers/net/idpf/idpf_ethdev.c +4 -1
index 62b13b602e..84e7421d76 100644
@@ -22,6 +22,8 @@ rte_spinlock_t idpf_adapter_lock;
 struct idpf_adapter_list idpf_adapter_list;
 bool idpf_adapter_list_init;
 
+uint64_t idpf_timestamp_dynflag;
+
 static const char * const idpf_valid_args[] = {
 	IDPF_TX_SINGLE_Q,
 	IDPF_RX_SINGLE_Q,
@@ -93,7 +95,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		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_OUTER_IPV4_CKSUM     |
+		RTE_ETH_RX_OFFLOAD_TIMESTAMP;
 
 	dev_info->tx_offload_capa =
 		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
drivers/net/idpf/idpf_ethdev.h +3 -0
index 7d54e5db60..ccdf4abe40 100644
@@ -167,6 +167,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 +65 -0

140 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +90 -0

106 lines not on this page · raw message

Signature · 1 line
2.34.1
#226 lore raw

PATCH v12 2/18 net/idpf: add support for device initialization

In reply to Junfeng Guo

Support device init and add the following dev ops:
- dev_configure
- dev_close
- dev_infos_get

---
 MAINTAINERS                            |   9 +
 doc/guides/nics/features/idpf.ini      |   9 +
 doc/guides/nics/idpf.rst               |  66 ++
 doc/guides/nics/index.rst              |   1 +
 doc/guides/rel_notes/release_22_11.rst |   6 +
 drivers/net/idpf/idpf_ethdev.c         | 886 +++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h         | 189 ++++++
 drivers/net/idpf/idpf_logs.h           |  56 ++
 drivers/net/idpf/idpf_vchnl.c          | 468 +++++++++++++
 drivers/net/idpf/meson.build           |  15 +
 drivers/net/idpf/version.map           |   3 +
 drivers/net/meson.build                |   1 +
 12 files changed, 1709 insertions(+)
 create mode 100644 doc/guides/nics/features/idpf.ini
 create mode 100644 doc/guides/nics/idpf.rst
 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_vchnl.c
 create mode 100644 drivers/net/idpf/meson.build
 create mode 100644 drivers/net/idpf/version.map
MAINTAINERS +9 -0
index 92b381bc30..34f8b9cc61 100644
@@ -764,6 +764,15 @@ F: drivers/net/ice/
 F: doc/guides/nics/ice.rst
 F: doc/guides/nics/features/ice.ini
 
+Intel idpf
+M: Jingjing Wu <[email protected]>
+M: Beilei Xing <[email protected]>
+T: git://dpdk.org/next/dpdk-next-net-intel
+F: drivers/net/idpf/
+F: drivers/common/idpf/
+F: doc/guides/nics/idpf.rst
+F: doc/guides/nics/features/idpf.ini
+
 Intel igc
 M: Junfeng Guo <[email protected]>
 M: Simei Su <[email protected]>
doc/guides/nics/features/idpf.ini new file +9 -0
new file mode 100644
index 0000000000..46aab2eb61
@@ -0,0 +1,9 @@
+;
+; Supported features of the 'idpf' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-32               = Y
+x86-64               = Y
doc/guides/nics/idpf.rst new file +66 -0

66 lines not on this page · raw message

doc/guides/nics/index.rst +1 -0
index 32c7544968..b4dd5ea522 100644
@@ -33,6 +33,7 @@ Network Interface Controller Drivers
     hns3
     i40e
     ice
+    idpf
     igb
     igc
     ionic
doc/guides/rel_notes/release_22_11.rst +6 -0
index 1c3daf141d..4af790de37 100644
@@ -160,6 +160,12 @@ New Features
 
   * Added protocol based buffer split support in scalar path.
 
+* **Added IDPF PMD [*EXPERIMENTAL*].**
+
+  Added the new ``idpf`` net driver for Intel® Infrastructure Processing Unit
+  (Intel® IPU) E2000.
+  See the :doc:`../nics/idpf` NIC guide for more details on this new driver.
+
 * **Updated Marvell cnxk driver.**
 
   * Added support for flow action REPRESENTED_PORT.
drivers/net/idpf/idpf_ethdev.c new file +886 -0

886 lines not on this page · raw message

drivers/net/idpf/idpf_ethdev.h new file +189 -0

189 lines not on this page · raw message

drivers/net/idpf/idpf_logs.h new file +56 -0

56 lines not on this page · raw message

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

468 lines not on this page · raw message

drivers/net/idpf/meson.build new file +15 -0
new file mode 100644
index 0000000000..ecf73355c3
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
+deps += ['common_idpf']
+
+sources = files(
+    'idpf_ethdev.c',
+    'idpf_vchnl.c',
+)
drivers/net/idpf/version.map new file +3 -0
new file mode 100644
index 0000000000..78c3585d7c
@@ -0,0 +1,3 @@
+DPDK_23 {
+	local: *;
+};
drivers/net/meson.build +1 -0
index 35bfa78dee..4a951b95f2 100644
@@ -28,6 +28,7 @@ drivers = [
         'i40e',
         'iavf',
         'ice',
+        'idpf',
         'igc',
         'ionic',
         'ipn3ke',
Signature · 1 line
2.34.1
#227 lore raw

PATCH v12 3/18 net/idpf: add Tx queue setup

In reply to Junfeng Guo

Add support for tx_queue_setup ops.

In the single queue model, the same descriptor queue is used by SW to post buffer descriptors to HW and by HW to post completed descriptors to SW.

In the split queue model, "RX buffer queues" are used to pass descriptor buffers from SW to HW while Rx queues are used only to pass the descriptor completions, that is, descriptors that point to completed buffers, from HW to SW. This is contrary to the single queue model in which Rx queues are used for both purposes.

---
 drivers/net/idpf/idpf_ethdev.c |  13 ++
 drivers/net/idpf/idpf_rxtx.c   | 364 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  70 +++++++
 drivers/net/idpf/idpf_vchnl.c  |   2 -
 drivers/net/idpf/meson.build   |   1 +
 5 files changed, 448 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/idpf/idpf_rxtx.c
 create mode 100644 drivers/net/idpf/idpf_rxtx.h
drivers/net/idpf/idpf_ethdev.c +13 -0
index 112dccf5c9..11f8b4ba1c 100644
@@ -11,6 +11,7 @@
 #include <errno.h>
 
 #include "idpf_ethdev.h"
+#include "idpf_rxtx.h"
 
 #define IDPF_TX_SINGLE_Q	"tx_single"
 #define IDPF_RX_SINGLE_Q	"rx_single"
@@ -37,6 +38,7 @@ static void idpf_adapter_rel(struct idpf_adapter *adapter);
 static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_configure			= idpf_dev_configure,
 	.dev_close			= idpf_dev_close,
+	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
 };
 
@@ -56,6 +58,17 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
 
+	dev_info->default_txconf = (struct rte_eth_txconf) {
+		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
+		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
+	};
+
+	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;
 }
 
drivers/net/idpf/idpf_rxtx.c new file +364 -0

364 lines not on this page · raw message

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

70 lines not on this page · raw message

drivers/net/idpf/idpf_vchnl.c +0 -2
index 9392711b61..4dae1a0b36 100644
@@ -22,8 +22,6 @@
 
 #include "idpf_ethdev.h"
 
-#define IDPF_CTLQ_LEN	64
-
 static int
 idpf_vc_clean(struct idpf_adapter *adapter)
 {
drivers/net/idpf/meson.build +1 -0
index ecf73355c3..b632b76656 100644
@@ -11,5 +11,6 @@ deps += ['common_idpf']
 
 sources = files(
     'idpf_ethdev.c',
+    'idpf_rxtx.c',
     'idpf_vchnl.c',
 )
Signature · 1 line
2.34.1
#228 lore raw

PATCH v12 4/18 net/idpf: add Rx queue setup

In reply to Junfeng Guo

Add support for rx_queue_setup ops.

---
 drivers/net/idpf/idpf_ethdev.c |  11 +
 drivers/net/idpf/idpf_rxtx.c   | 400 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  46 ++++
 3 files changed, 457 insertions(+)
drivers/net/idpf/idpf_ethdev.c +11 -0
index 11f8b4ba1c..0585153f69 100644
@@ -38,6 +38,7 @@ static void idpf_adapter_rel(struct idpf_adapter *adapter);
 static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_configure			= idpf_dev_configure,
 	.dev_close			= idpf_dev_close,
+	.rx_queue_setup			= idpf_rx_queue_setup,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
 };
@@ -63,12 +64,22 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
 	};
 
+	dev_info->default_rxconf = (struct rte_eth_rxconf) {
+		.rx_free_thresh = IDPF_DEFAULT_RX_FREE_THRESH,
+	};
+
 	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->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,
+	};
+
 	return 0;
 }
 
drivers/net/idpf/idpf_rxtx.c +400 -0

418 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +46 -0

61 lines not on this page · raw message

Signature · 1 line
2.34.1
#229 lore raw

PATCH v12 5/18 net/idpf: add support for device start and stop

In reply to Junfeng Guo

Add dev ops dev_start, dev_stop and link_update.

---
 drivers/net/idpf/idpf_ethdev.c | 51 ++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
drivers/net/idpf/idpf_ethdev.c +51 -0
index 0585153f69..e1db7ccb4f 100644
@@ -30,17 +30,38 @@ static const char * const idpf_valid_args[] = {
 };
 
 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 void idpf_adapter_rel(struct idpf_adapter *adapter);
 
+static int
+idpf_dev_link_update(struct rte_eth_dev *dev,
+		     __rte_unused int wait_to_complete)
+{
+	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_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_configure			= idpf_dev_configure,
+	.dev_start			= idpf_dev_start,
+	.dev_stop			= idpf_dev_stop,
 	.dev_close			= idpf_dev_close,
 	.rx_queue_setup			= idpf_rx_queue_setup,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
+	.link_update			= idpf_dev_link_update,
 };
 
 static int
@@ -284,6 +305,36 @@ idpf_dev_configure(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;
+
+	if (dev->data->mtu > vport->max_mtu) {
+		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
+		return -1;
+	}
+
+	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
+
+	if (idpf_vc_ena_dis_vport(vport, true) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to enable vport");
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+idpf_dev_stop(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+
+	idpf_vc_ena_dis_vport(vport, false);
+
+	return 0;
+}
+
 static int
 idpf_dev_close(struct rte_eth_dev *dev)
 {
Signature · 1 line
2.34.1
#230 lore raw

PATCH v12 6/18 net/idpf: add support for queue start

In reply to Junfeng Guo

Add support for these device ops:
- rx_queue_start
- tx_queue_start

---
 drivers/net/idpf/idpf_ethdev.c |  40 +++
 drivers/net/idpf/idpf_ethdev.h |   9 +
 drivers/net/idpf/idpf_rxtx.c   | 218 ++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |   6 +
 drivers/net/idpf/idpf_vchnl.c  | 447 +++++++++++++++++++++++++++++++++
 5 files changed, 720 insertions(+)
drivers/net/idpf/idpf_ethdev.c +40 -0
index e1db7ccb4f..29bac29bc3 100644
@@ -58,6 +58,8 @@ 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,
+	.tx_queue_start			= idpf_tx_queue_start,
 	.rx_queue_setup			= idpf_rx_queue_setup,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
@@ -305,6 +307,39 @@ idpf_dev_configure(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 == NULL || txq->tx_deferred_start)
+			continue;
+		err = idpf_tx_queue_start(dev, i);
+		if (err != 0) {
+			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 == NULL || rxq->rx_deferred_start)
+			continue;
+		err = idpf_rx_queue_start(dev, i);
+		if (err != 0) {
+			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)
 {
@@ -317,6 +352,11 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
 
+	if (idpf_start_queues(dev) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to start queues");
+		return -1;
+	}
+
 	if (idpf_vc_ena_dis_vport(vport, true) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
 		return -1;
drivers/net/idpf/idpf_ethdev.h +9 -0
index 84ae6641e2..96c22009e9 100644
@@ -24,7 +24,9 @@
 #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
@@ -182,6 +184,13 @@ int idpf_vc_check_api_version(struct idpf_adapter *adapter);
 int idpf_vc_get_caps(struct idpf_adapter *adapter);
 int idpf_vc_create_vport(struct idpf_adapter *adapter);
 int idpf_vc_destroy_vport(struct idpf_vport *vport);
+int idpf_vc_config_rxqs(struct idpf_vport *vport);
+int idpf_vc_config_rxq(struct idpf_vport *vport, uint16_t rxq_id);
+int idpf_vc_config_txqs(struct idpf_vport *vport);
+int idpf_vc_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_vc_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_vc_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 +218 -0

245 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +6 -0
index 3f3932c3eb..ab9b3830fd 100644
@@ -50,6 +50,7 @@ struct idpf_rx_queue {
 
 	bool q_set;             /* if rx queue has been configured */
 	bool q_started;         /* if rx queue has been started */
+	bool rx_deferred_start; /* don't start this queue in dev start */
 
 	/* only valid for split queue mode */
 	uint8_t expected_gen_id;
@@ -95,6 +96,7 @@ struct idpf_tx_queue {
 
 	bool q_set;		/* if tx queue has been configured */
 	bool q_started;		/* if tx queue has been started */
+	bool tx_deferred_start; /* don't start this queue in dev start */
 
 	/* only valid for split queue mode */
 	uint16_t sw_nb_desc;
@@ -109,8 +111,12 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_rxconf *rx_conf,
 			struct rte_mempool *mp);
+int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
+int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
+int idpf_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 
 #endif /* _IDPF_RXTX_H_ */
drivers/net/idpf/idpf_vchnl.c +447 -0

465 lines not on this page · raw message

Signature · 1 line
2.34.1
#231 lore raw

PATCH v12 7/18 net/idpf: add support for queue stop

In reply to Junfeng Guo

Add support for these device ops:
- rx_queue_stop
- tx_queue_stop

---
 doc/guides/nics/features/idpf.ini |   1 +
 drivers/net/idpf/idpf_ethdev.c    |  14 ++-
 drivers/net/idpf/idpf_rxtx.c      | 148 ++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h      |  13 +++
 drivers/net/idpf/idpf_vchnl.c     |  69 ++++++++++++++
 5 files changed, 242 insertions(+), 3 deletions(-)
doc/guides/nics/features/idpf.ini +1 -0
index 46aab2eb61..c25fa5de3f 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Queue start/stop     = Y
 Linux                = Y
 x86-32               = Y
 x86-64               = Y
drivers/net/idpf/idpf_ethdev.c +11 -3
index 29bac29bc3..05f087a03c 100644
@@ -59,7 +59,9 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.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,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
@@ -347,22 +349,26 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	if (dev->data->mtu > vport->max_mtu) {
 		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
-		return -1;
+		goto err_mtu;
 	}
 
 	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
 
 	if (idpf_start_queues(dev) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
-		return -1;
+		goto err_mtu;
 	}
 
 	if (idpf_vc_ena_dis_vport(vport, true) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
-		return -1;
+		goto err_vport;
 	}
 
 	return 0;
+err_vport:
+	idpf_stop_queues(dev);
+err_mtu:
+	return -1;
 }
 
 static int
@@ -372,6 +378,8 @@ idpf_dev_stop(struct rte_eth_dev *dev)
 
 	idpf_vc_ena_dis_vport(vport, false);
 
+	idpf_stop_queues(dev);
+
 	return 0;
 }
 
drivers/net/idpf/idpf_rxtx.c +148 -0

187 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +13 -0
index ab9b3830fd..b959638489 100644
@@ -51,6 +51,7 @@ struct idpf_rx_queue {
 	bool q_set;             /* if rx queue has been configured */
 	bool q_started;         /* if rx queue has been started */
 	bool rx_deferred_start; /* don't start this queue in dev start */
+	const struct idpf_rxq_ops *ops;
 
 	/* only valid for split queue mode */
 	uint8_t expected_gen_id;
@@ -97,6 +98,7 @@ struct idpf_tx_queue {
 	bool q_set;		/* if tx queue has been configured */
 	bool q_started;		/* if tx queue has been started */
 	bool tx_deferred_start; /* don't start this queue in dev start */
+	const struct idpf_txq_ops *ops;
 
 	/* only valid for split queue mode */
 	uint16_t sw_nb_desc;
@@ -107,16 +109,27 @@ struct idpf_tx_queue {
 	struct idpf_tx_queue *complq;
 };
 
+struct idpf_rxq_ops {
+	void (*release_mbufs)(struct idpf_rx_queue *rxq);
+};
+
+struct idpf_txq_ops {
+	void (*release_mbufs)(struct idpf_tx_queue *txq);
+};
+
 int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_rxconf *rx_conf,
 			struct rte_mempool *mp);
 int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int idpf_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
 int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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_stop_queues(struct rte_eth_dev *dev);
 #endif /* _IDPF_RXTX_H_ */
drivers/net/idpf/idpf_vchnl.c +69 -0

75 lines not on this page · raw message

Signature · 1 line
2.34.1
#232 lore raw

PATCH v12 8/18 net/idpf: add queue release

In reply to Junfeng Guo

Add support for queue operations:
- rx_queue_release
- tx_queue_release

---
 drivers/net/idpf/idpf_ethdev.c |  2 +
 drivers/net/idpf/idpf_rxtx.c   | 81 ++++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  3 ++
 3 files changed, 86 insertions(+)
drivers/net/idpf/idpf_ethdev.c +2 -0
index 05f087a03c..dee1e03d43 100644
@@ -63,7 +63,9 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.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,
 	.dev_infos_get			= idpf_dev_info_get,
 	.link_update			= idpf_dev_link_update,
 };
drivers/net/idpf/idpf_rxtx.c +81 -0

117 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +3 -0
index b959638489..37944edcac 100644
@@ -124,12 +124,15 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+void idpf_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
+
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
 int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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);
 
 void idpf_stop_queues(struct rte_eth_dev *dev);
 #endif /* _IDPF_RXTX_H_ */
Signature · 1 line
2.34.1
#233 lore raw

PATCH v12 9/18 net/idpf: add support for MTU configuration

In reply to Junfeng Guo

Add dev ops mtu_set.

---
 doc/guides/nics/features/idpf.ini |  1 +
 drivers/net/idpf/idpf_ethdev.c    | 14 ++++++++++++++
 2 files changed, 15 insertions(+)
doc/guides/nics/features/idpf.ini +1 -0
index c25fa5de3f..c8f4a0d6ed 100644
@@ -5,6 +5,7 @@
 ;
 [Features]
 Queue start/stop     = Y
+MTU update           = Y
 Linux                = Y
 x86-32               = Y
 x86-64               = Y
drivers/net/idpf/idpf_ethdev.c +14 -0
index dee1e03d43..94f4671057 100644
@@ -35,6 +35,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);
 static void idpf_adapter_rel(struct idpf_adapter *adapter);
 
 static int
@@ -68,6 +69,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
@@ -110,6 +112,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)
 {
Signature · 1 line
2.34.1
#234 lore raw

PATCH v12 10/18 net/idpf: add support for basic Rx datapath

In reply to Junfeng Guo

Add basic Rx support in split queue mode and single queue mode.

---
 drivers/net/idpf/idpf_ethdev.c |   2 +
 drivers/net/idpf/idpf_rxtx.c   | 273 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |   7 +-
 3 files changed, 281 insertions(+), 1 deletion(-)
drivers/net/idpf/idpf_ethdev.c +2 -0
index 94f4671057..df2a760673 100644
@@ -375,6 +375,8 @@ idpf_dev_start(struct rte_eth_dev *dev)
 		goto err_mtu;
 	}
 
+	idpf_set_rx_function(dev);
+
 	if (idpf_vc_ena_dis_vport(vport, true) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
 		goto err_vport;
drivers/net/idpf/idpf_rxtx.c +273 -0

276 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +6 -1
index 37944edcac..650c6c1c3a 100644
@@ -133,6 +133,11 @@ int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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);
 void idpf_stop_queues(struct rte_eth_dev *dev);
+
+void idpf_set_rx_function(struct rte_eth_dev *dev);
 #endif /* _IDPF_RXTX_H_ */
Signature · 1 line
2.34.1
#235 lore raw

PATCH v12 11/18 net/idpf: add support for basic Tx datapath

In reply to Junfeng Guo

Add basic Tx support in split queue mode and single queue mode.

---
 drivers/net/idpf/idpf_ethdev.c |   3 +
 drivers/net/idpf/idpf_ethdev.h |   1 +
 drivers/net/idpf/idpf_rxtx.c   | 357 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  10 +
 4 files changed, 371 insertions(+)
drivers/net/idpf/idpf_ethdev.c +3 -0
index df2a760673..6fb56e584d 100644
@@ -88,6 +88,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
 
+	dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+
 	dev_info->default_txconf = (struct rte_eth_txconf) {
 		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
 		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
@@ -376,6 +378,7 @@ idpf_dev_start(struct rte_eth_dev *dev)
 	}
 
 	idpf_set_rx_function(dev);
+	idpf_set_tx_function(dev);
 
 	if (idpf_vc_ena_dis_vport(vport, true) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
drivers/net/idpf/idpf_ethdev.h +1 -0
index 96c22009e9..af0a8e2970 100644
@@ -35,6 +35,7 @@
 
 #define IDPF_MIN_BUF_SIZE	1024
 #define IDPF_MAX_FRAME_SIZE	9728
+#define IDPF_MIN_FRAME_SIZE	14
 
 #define IDPF_NUM_MACADDR_MAX	64
 
drivers/net/idpf/idpf_rxtx.c +357 -0

372 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +10 -0
index 650c6c1c3a..30dc94b3dd 100644
@@ -21,6 +21,8 @@
 #define IDPF_DEFAULT_TX_RS_THRESH	32
 #define IDPF_DEFAULT_TX_FREE_THRESH	32
 
+#define IDPF_TX_MAX_MTU_SEG	10
+
 struct idpf_rx_queue {
 	struct idpf_adapter *adapter;   /* the adapter this queue belongs to */
 	struct rte_mempool *mp;         /* mbuf pool to populate Rx ring */
@@ -137,7 +139,15 @@ 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);
 #endif /* _IDPF_RXTX_H_ */
Signature · 1 line
2.34.1
#236 lore raw

PATCH v12 12/18 net/idpf: support packet type get

In reply to Junfeng Guo

Get packet type during receiving packets.

---
 drivers/net/idpf/idpf_ethdev.c |   6 +
 drivers/net/idpf/idpf_ethdev.h |   6 +
 drivers/net/idpf/idpf_rxtx.c   |  11 ++
 drivers/net/idpf/idpf_rxtx.h   |   5 +
 drivers/net/idpf/idpf_vchnl.c  | 240 +++++++++++++++++++++++++++++++++
 5 files changed, 268 insertions(+)
drivers/net/idpf/idpf_ethdev.c +6 -0
index 6fb56e584d..630bdabcd4 100644
@@ -709,6 +709,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 != 0) {
+		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 == NULL) {
drivers/net/idpf/idpf_ethdev.h +6 -0
index af0a8e2970..db9af58f72 100644
@@ -39,6 +39,8 @@
 
 #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)
@@ -125,6 +127,8 @@ struct idpf_adapter {
 	/* 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;
 };
 
 TAILQ_HEAD(idpf_adapter_list, idpf_adapter);
@@ -182,6 +186,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_vc_check_api_version(struct idpf_adapter *adapter);
+int idpf_get_pkt_type(struct idpf_adapter *adapter);
 int idpf_vc_get_caps(struct idpf_adapter *adapter);
 int idpf_vc_create_vport(struct idpf_adapter *adapter);
 int idpf_vc_destroy_vport(struct idpf_vport *vport);
@@ -193,6 +198,7 @@ int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,
 		      bool rx, bool on);
 int idpf_vc_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_vc_ena_dis_vport(struct idpf_vport *vport, bool enable);
+int idpf_vc_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 +11 -0
index 86942b2b5f..f9f751a6ad 100644
@@ -1282,6 +1282,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	volatile struct virtchnl2_rx_flex_desc_adv_nic_3 *rx_desc;
 	uint16_t pktlen_gen_bufq_id;
 	struct idpf_rx_queue *rxq;
+	const uint32_t *ptype_tbl;
 	struct rte_mbuf *rxm;
 	uint16_t rx_id_bufq1;
 	uint16_t rx_id_bufq2;
@@ -1301,6 +1302,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	rx_id_bufq1 = rxq->bufq1->rx_next_avail;
 	rx_id_bufq2 = rxq->bufq2->rx_next_avail;
 	rx_desc_ring = rxq->rx_ring;
+	ptype_tbl = rxq->adapter->ptype_tbl;
 
 	while (nb_rx < nb_pkts) {
 		rx_desc = &rx_desc_ring[rx_id];
@@ -1348,6 +1350,10 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		rxm->next = NULL;
 		rxm->nb_segs = 1;
 		rxm->port = rxq->port_id;
+		rxm->packet_type =
+			ptype_tbl[(rte_le_to_cpu_16(rx_desc->ptype_err_fflags0) &
+				   VIRTCHNL2_RX_FLEX_DESC_ADV_PTYPE_M) >>
+				  VIRTCHNL2_RX_FLEX_DESC_ADV_PTYPE_S];
 
 		rx_pkts[nb_rx++] = rxm;
 	}
@@ -1534,6 +1540,7 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	volatile union virtchnl2_rx_desc *rxdp;
 	union virtchnl2_rx_desc rxd;
 	struct idpf_rx_queue *rxq;
+	const uint32_t *ptype_tbl;
 	uint16_t rx_id, nb_hold;
 	struct rte_eth_dev *dev;
 	uint16_t rx_packet_len;
@@ -1552,6 +1559,7 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 
 	rx_id = rxq->rx_tail;
 	rx_ring = rxq->rx_ring;
+	ptype_tbl = rxq->adapter->ptype_tbl;
 
 	while (nb_rx < nb_pkts) {
 		rxdp = &rx_ring[rx_id];
@@ -1604,6 +1612,9 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		rxm->pkt_len = rx_packet_len;
 		rxm->data_len = rx_packet_len;
 		rxm->port = rxq->port_id;
+		rxm->packet_type =
+			ptype_tbl[(uint8_t)(rte_cpu_to_le_16(rxd.flex_nic_wb.ptype_flex_flags0) &
+					    VIRTCHNL2_RX_FLEX_DESC_PTYPE_M)];
 
 		rx_pkts[nb_rx++] = rxm;
 	}
drivers/net/idpf/idpf_rxtx.h +5 -0
index 30dc94b3dd..3853ed55c9 100644
@@ -23,6 +23,10 @@
 
 #define IDPF_TX_MAX_MTU_SEG	10
 
+#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 */
@@ -150,4 +154,5 @@ 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);
+
 #endif /* _IDPF_RXTX_H_ */
drivers/net/idpf/idpf_vchnl.c +240 -0

255 lines not on this page · raw message

Signature · 1 line
2.34.1
#237 lore raw

PATCH v12 13/18 net/idpf: add support for write back based on ITR expire

In reply to Junfeng Guo

Enable write back on ITR expire, then packets can be received one by one.

---
 drivers/net/idpf/idpf_ethdev.c | 116 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h |  13 ++++
 drivers/net/idpf/idpf_vchnl.c  | 111 +++++++++++++++++++++++++++++++
 3 files changed, 240 insertions(+)
drivers/net/idpf/idpf_ethdev.c +116 -0
index 630bdabcd4..8045073780 100644
@@ -327,6 +327,90 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
+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 idpf_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 == NULL) {
+		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 != 0) {
+		dynctl_reg_start =
+			vport->recv_vectors->vchunks.vchunks->dynctl_reg_start;
+		itrn_reg_start =
+			vport->recv_vectors->vchunks.vchunks->itrn_reg_start;
+		dynctl_val = IDPF_READ_REG(hw, dynctl_reg_start);
+		PMD_DRV_LOG(DEBUG, "Value of dynctl_reg_start is 0x%x",
+			    dynctl_val);
+		itrn_val = IDPF_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 written back based on ITR expiration irrespective
+		 * of INTENA setting.
+		 */
+		/* TBD: need to tune INTERVAL value for better performance. */
+		if (itrn_val != 0)
+			IDPF_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
+			IDPF_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_vc_config_irq_map_unmap(vport, true) != 0) {
+		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)
 {
@@ -364,6 +448,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;
 
 	if (dev->data->mtu > vport->max_mtu) {
 		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
@@ -372,6 +460,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_vc_alloc_vectors(vport, req_vecs_num) != 0) {
+		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) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to configure irqs");
+		goto err_mtu;
+	}
+
 	if (idpf_start_queues(dev) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
 		goto err_mtu;
@@ -401,6 +506,10 @@ idpf_dev_stop(struct rte_eth_dev *dev)
 
 	idpf_stop_queues(dev);
 
+	idpf_vc_config_irq_map_unmap(vport, false);
+
+	idpf_vc_dealloc_vectors(vport);
+
 	return 0;
 }
 
@@ -412,6 +521,11 @@ idpf_dev_close(struct rte_eth_dev *dev)
 
 	idpf_vc_destroy_vport(vport);
 
+	rte_free(vport->recv_vectors);
+	vport->recv_vectors = NULL;
+
+	rte_free(vport->qv_map);
+	vport->qv_map = NULL;
 
 	adapter->cur_vports &= ~RTE_BIT32(vport->devarg_id);
 
@@ -766,6 +880,8 @@ idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
 	adapter->cur_vports = 0;
 	adapter->cur_vport_nb = 0;
 
+	adapter->used_vecs_num = 0;
+
 	return ret;
 
 err_vports:
drivers/net/idpf/idpf_ethdev.h +13 -0
index db9af58f72..811240c386 100644
@@ -33,6 +33,9 @@
 #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_MIN_BUF_SIZE	1024
 #define IDPF_MAX_FRAME_SIZE	9728
 #define IDPF_MIN_FRAME_SIZE	14
@@ -92,6 +95,11 @@ struct idpf_vport {
 	struct rte_eth_dev_data *dev_data; /* Pointer to the device data */
 	uint16_t max_pkt_len; /* Maximum packet length */
 
+	/* 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;
 
@@ -124,6 +132,8 @@ struct idpf_adapter {
 	uint16_t cur_vport_nb;
 	uint16_t cur_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;
@@ -198,6 +208,9 @@ int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,
 		      bool rx, bool on);
 int idpf_vc_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_vc_ena_dis_vport(struct idpf_vport *vport, bool enable);
+int idpf_vc_config_irq_map_unmap(struct idpf_vport *vport, bool map);
+int idpf_vc_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors);
+int idpf_vc_dealloc_vectors(struct idpf_vport *vport);
 int idpf_vc_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 +111 -0

123 lines not on this page · raw message

Signature · 1 line
2.34.1
#238 lore raw

PATCH v12 14/18 net/idpf: add support for RSS

In reply to Junfeng Guo

Add RSS support.

---
 drivers/net/idpf/idpf_ethdev.c | 116 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h |  26 ++++++++
 drivers/net/idpf/idpf_vchnl.c  |  97 +++++++++++++++++++++++++++
 3 files changed, 239 insertions(+)
drivers/net/idpf/idpf_ethdev.c +116 -0
index 8045073780..ea7d3bfd7e 100644
@@ -86,6 +86,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->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
@@ -198,6 +199,8 @@ idpf_parse_devarg_id(char *name)
 	return val;
 }
 
+#define IDPF_RSS_KEY_LEN 52
+
 static int
 idpf_init_vport(struct rte_eth_dev *dev)
 {
@@ -218,6 +221,10 @@ idpf_init_vport(struct rte_eth_dev *dev)
 	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++) {
@@ -275,10 +282,102 @@ idpf_init_vport(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+idpf_config_rss(struct idpf_vport *vport)
+{
+	int ret;
+
+	ret = idpf_vc_set_rss_key(vport);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS key");
+		return ret;
+	}
+
+	ret = idpf_vc_set_rss_lut(vport);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS lut");
+		return ret;
+	}
+
+	ret = idpf_vc_set_rss_hash(vport);
+	if (ret != 0) {
+		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 = rte_zmalloc("rss_key",
+				     vport->rss_key_size, 0);
+	if (vport->rss_key == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS key");
+		ret = -ENOMEM;
+		goto err_alloc_key;
+	}
+
+	lut_size = vport->rss_lut_size;
+	vport->rss_lut = rte_zmalloc("rss_lut",
+				     sizeof(uint32_t) * lut_size, 0);
+	if (vport->rss_lut == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS lut");
+		ret = -ENOMEM;
+		goto err_alloc_lut;
+	}
+
+	if (rss_conf->rss_key == NULL) {
+		for (i = 0; i < vport->rss_key_size; i++)
+			vport->rss_key[i] = (uint8_t)rte_rand();
+	} else if (rss_conf->rss_key_len != vport->rss_key_size) {
+		PMD_INIT_LOG(ERR, "Invalid RSS key length in RSS configuration, should be %d",
+			     vport->rss_key_size);
+		ret = -EINVAL;
+		goto err_cfg_key;
+	} else {
+		rte_memcpy(vport->rss_key, rss_conf->rss_key,
+			   vport->rss_key_size);
+	}
+
+	for (i = 0; i < lut_size; i++)
+		vport->rss_lut[i] = i % nb_q;
+
+	vport->rss_hf = IDPF_DEFAULT_RSS_HASH_EXPANDED;
+
+	ret = idpf_config_rss(vport);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS");
+		goto err_cfg_key;
+	}
+
+	return ret;
+
+err_cfg_key:
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+err_alloc_lut:
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+err_alloc_key:
+	return ret;
+}
+
 static int
 idpf_dev_configure(struct rte_eth_dev *dev)
 {
+	struct idpf_vport *vport = dev->data->dev_private;
 	struct rte_eth_conf *conf = &dev->data->dev_conf;
+	struct idpf_adapter *adapter = vport->adapter;
+	int ret;
 
 	if (conf->link_speeds & RTE_ETH_LINK_SPEED_FIXED) {
 		PMD_INIT_LOG(ERR, "Setting link speed is not supported");
@@ -324,6 +423,17 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 		return -1;
 	}
 
+	if (adapter->caps->rss_caps != 0 && dev->data->nb_rx_queues != 0) {
+		ret = idpf_init_rss(vport);
+		if (ret != 0) {
+			PMD_INIT_LOG(ERR, "Failed to init rss");
+			return ret;
+		}
+	} else {
+		PMD_INIT_LOG(ERR, "RSS is not supported.");
+		return -1;
+	}
+
 	return 0;
 }
 
@@ -521,6 +631,12 @@ idpf_dev_close(struct rte_eth_dev *dev)
 
 	idpf_vc_destroy_vport(vport);
 
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+
 	rte_free(vport->recv_vectors);
 	vport->recv_vectors = NULL;
 
drivers/net/idpf/idpf_ethdev.h +26 -0
index 811240c386..8d0804f603 100644
@@ -48,6 +48,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)
+
 #define IDPF_ADAPTER_NAME_LEN	(PCI_PRI_STR_SIZE + 1)
 
 /* Message type read in virtual channel from PF */
@@ -90,11 +104,20 @@ struct idpf_vport {
 	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;
@@ -200,6 +223,9 @@ int idpf_get_pkt_type(struct idpf_adapter *adapter);
 int idpf_vc_get_caps(struct idpf_adapter *adapter);
 int idpf_vc_create_vport(struct idpf_adapter *adapter);
 int idpf_vc_destroy_vport(struct idpf_vport *vport);
+int idpf_vc_set_rss_key(struct idpf_vport *vport);
+int idpf_vc_set_rss_lut(struct idpf_vport *vport);
+int idpf_vc_set_rss_hash(struct idpf_vport *vport);
 int idpf_vc_config_rxqs(struct idpf_vport *vport);
 int idpf_vc_config_rxq(struct idpf_vport *vport, uint16_t rxq_id);
 int idpf_vc_config_txqs(struct idpf_vport *vport);
drivers/net/idpf/idpf_vchnl.c +97 -0

109 lines not on this page · raw message

Signature · 1 line
2.34.1
#239 lore raw

PATCH v12 15/18 net/idpf: add support for Rx offloading

In reply to Junfeng Guo

Add Rx offloading support:
- support CHKSUM and RSS offload for split queue model
- support CHKSUM offload for single queue model

---
 doc/guides/nics/features/idpf.ini |   5 ++
 drivers/net/idpf/idpf_ethdev.c    |   6 ++
 drivers/net/idpf/idpf_rxtx.c      | 122 ++++++++++++++++++++++++++++++
 3 files changed, 133 insertions(+)
doc/guides/nics/features/idpf.ini +5 -0
index c8f4a0d6ed..6eefac9529 100644
@@ -3,9 +3,14 @@
 ;
 ; Refer to default.ini for the full list of available PMD features.
 ;
+; A feature with "P" indicates only be supported when non-vector path
+; is selected.
+;
 [Features]
 Queue start/stop     = Y
 MTU update           = Y
+L3 checksum offload  = P
+L4 checksum offload  = P
 Linux                = Y
 x86-32               = Y
 x86-64               = Y
drivers/net/idpf/idpf_ethdev.c +6 -0
index ea7d3bfd7e..88f3db3267 100644
@@ -89,6 +89,12 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->flow_type_rss_offloads = IDPF_RSS_OFFLOAD_ALL;
 	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
 
+	dev_info->rx_offload_capa =
+		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;
+
 	dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
 	dev_info->default_txconf = (struct rte_eth_txconf) {
drivers/net/idpf/idpf_rxtx.c +122 -0

170 lines not on this page · raw message

Signature · 1 line
2.34.1
#240 lore raw

PATCH v12 16/18 net/idpf: add support for Tx offloading

In reply to Junfeng Guo

Add Tx offloading support:
- support TSO

---
 doc/guides/nics/features/idpf.ini |   1 +
 drivers/net/idpf/idpf_ethdev.c    |   4 +-
 drivers/net/idpf/idpf_rxtx.c      | 125 +++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_rxtx.h      |  22 ++++++
 4 files changed, 149 insertions(+), 3 deletions(-)
doc/guides/nics/features/idpf.ini +1 -0
index 6eefac9529..86c182021f 100644
@@ -9,6 +9,7 @@
 [Features]
 Queue start/stop     = Y
 MTU update           = Y
+TSO                  = P
 L3 checksum offload  = P
 L4 checksum offload  = P
 Linux                = Y
drivers/net/idpf/idpf_ethdev.c +3 -1
index 88f3db3267..868f28d003 100644
@@ -95,7 +95,9 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		RTE_ETH_RX_OFFLOAD_TCP_CKSUM            |
 		RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
 
-	dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+	dev_info->tx_offload_capa =
+		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
 	dev_info->default_txconf = (struct rte_eth_txconf) {
 		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
drivers/net/idpf/idpf_rxtx.c +123 -2

190 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +22 -0
index 3853ed55c9..54d297aac6 100644
@@ -23,6 +23,16 @@
 
 #define IDPF_TX_MAX_MTU_SEG	10
 
+#define IDPF_MIN_TSO_MSS	88
+#define IDPF_MAX_TSO_MSS	9728
+#define IDPF_MAX_TSO_FRAME_SIZE	262143
+#define IDPF_TX_MAX_MTU_SEG     10
+
+#define IDPF_TX_OFFLOAD_MASK RTE_MBUF_F_TX_TCP_SEG
+
+#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])))
@@ -115,6 +125,18 @@ struct idpf_tx_queue {
 	struct idpf_tx_queue *complq;
 };
 
+/* Offload features */
+union idpf_tx_offload {
+	uint64_t data;
+	struct {
+		uint64_t l2_len:7; /* L2 (MAC) Header Length. */
+		uint64_t l3_len:9; /* L3 (IP) Header Length. */
+		uint64_t l4_len:8; /* L4 Header Length. */
+		uint64_t tso_segsz:16; /* TCP TSO segment size */
+		/* uint64_t unused : 24; */
+	};
+};
+
 struct idpf_rxq_ops {
 	void (*release_mbufs)(struct idpf_rx_queue *rxq);
 };
Signature · 1 line
2.34.1
#241 lore raw

PATCH v12 17/18 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.

---
 doc/guides/nics/idpf.rst                |  19 +
 drivers/net/idpf/idpf_ethdev.c          |   3 +-
 drivers/net/idpf/idpf_ethdev.h          |   5 +
 drivers/net/idpf/idpf_rxtx.c            | 145 ++++
 drivers/net/idpf/idpf_rxtx.h            |  21 +
 drivers/net/idpf/idpf_rxtx_vec_avx512.c | 871 ++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx_vec_common.h | 100 +++
 drivers/net/idpf/meson.build            |  28 +
 8 files changed, 1191 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
doc/guides/nics/idpf.rst +19 -0
index c1001d5d0c..3039c61748 100644
@@ -64,3 +64,22 @@ Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and
 for details.
 
 
+Features
+--------
+
+Vector PMD
+~~~~~~~~~~
+
+Vector path for RX and TX path are selected automatically. The paths
+are chosen based on 2 conditions.
+
+- ``CPU``
+  On the X86 platform, the driver checks if the CPU supports AVX512.
+  If the CPU supports AVX512 and EAL argument ``--force-max-simd-bitwidth``
+  is set to 512, AVX512 paths will be chosen.
+
+- ``Offload features``
+  The supported HW offload features are described in the document idpf.ini,
+  A value "P" means the offload feature is not supported by vector path.
+  If any not supported features are used, idpf vector PMD is disabled and the
+  scalar paths are chosen.
drivers/net/idpf/idpf_ethdev.c +2 -1
index 868f28d003..62b13b602e 100644
@@ -97,7 +97,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->tx_offload_capa =
 		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
-		RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS		|
+		RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
 	dev_info->default_txconf = (struct rte_eth_txconf) {
 		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
drivers/net/idpf/idpf_ethdev.h +5 -0
index 8d0804f603..7d54e5db60 100644
@@ -162,6 +162,11 @@ struct idpf_adapter {
 	uint32_t max_txq_per_msg;
 
 	uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned;
+
+	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 +145 -0

185 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +21 -0
index 54d297aac6..506bf8a57d 100644
@@ -18,6 +18,12 @@
 #define IDPF_RX_MAX_BURST		32
 #define IDPF_DEFAULT_RX_FREE_THRESH	32
 
+/* used for Vector PMD */
+#define IDPF_VPMD_RX_MAX_BURST	32
+#define IDPF_VPMD_TX_MAX_BURST	32
+#define IDPF_VPMD_DESCS_PER_LOOP	4
+#define IDPF_RXQ_REARM_THRESH	64
+
 #define IDPF_DEFAULT_TX_RS_THRESH	32
 #define IDPF_DEFAULT_TX_FREE_THRESH	32
 
@@ -54,6 +60,11 @@ struct idpf_rx_queue {
 	struct rte_mbuf *pkt_last_seg;  /* last segment of current packet */
 	struct rte_mbuf fake_mbuf;      /* dummy mbuf */
 
+	/* used for VPMD */
+	uint16_t rxrearm_nb;       /* number of remaining to be re-armed */
+	uint16_t rxrearm_start;    /* the idx we start the re-arming from */
+	uint64_t mbuf_initializer; /* value to init mbufs */
+
 	uint16_t rx_nb_avail;
 	uint16_t rx_next_avail;
 
@@ -84,6 +95,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 */
@@ -149,6 +164,7 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_rxconf *rx_conf,
 			struct rte_mempool *mp);
+int idpf_singleq_tx_vec_setup_avx512(struct idpf_tx_queue *txq);
 int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
@@ -157,16 +173,21 @@ void idpf_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
+int idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq);
 int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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_singleq_recv_pkts_avx512(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_singleq_xmit_pkts_avx512(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,
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +871 -0

871 lines not on this page · raw message

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

100 lines not on this page · raw message

drivers/net/idpf/meson.build +28 -0
index b632b76656..da99c098ab 100644
@@ -14,3 +14,31 @@ sources = files(
     'idpf_rxtx.c',
     '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_common_idpf, 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
Signature · 1 line
2.34.1
#242 lore raw

PATCH v12 18/18 net/idpf: add support for timestamp offload

In reply to Junfeng Guo

Add support for timestamp offload.

---
 doc/guides/nics/features/idpf.ini |  1 +
 drivers/net/idpf/idpf_ethdev.c    |  5 +-
 drivers/net/idpf/idpf_ethdev.h    |  3 ++
 drivers/net/idpf/idpf_rxtx.c      | 65 ++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h      | 90 +++++++++++++++++++++++++++++++
 5 files changed, 163 insertions(+), 1 deletion(-)
doc/guides/nics/features/idpf.ini +1 -0
index 86c182021f..5fbad9600c 100644
@@ -12,6 +12,7 @@ MTU update           = Y
 TSO                  = P
 L3 checksum offload  = P
 L4 checksum offload  = P
+Timestamp offload    = P
 Linux                = Y
 x86-32               = Y
 x86-64               = Y
drivers/net/idpf/idpf_ethdev.c +4 -1
index 62b13b602e..cd18d59fb7 100644
@@ -22,6 +22,8 @@ rte_spinlock_t idpf_adapter_lock;
 struct idpf_adapter_list idpf_adapter_list;
 bool idpf_adapter_list_init;
 
+uint64_t idpf_timestamp_dynflag;
+
 static const char * const idpf_valid_args[] = {
 	IDPF_TX_SINGLE_Q,
 	IDPF_RX_SINGLE_Q,
@@ -98,7 +100,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->tx_offload_capa =
 		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
 		RTE_ETH_TX_OFFLOAD_MULTI_SEGS		|
-		RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
+		RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE	|
+		RTE_ETH_RX_OFFLOAD_TIMESTAMP;
 
 	dev_info->default_txconf = (struct rte_eth_txconf) {
 		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
drivers/net/idpf/idpf_ethdev.h +3 -0
index 7d54e5db60..ccdf4abe40 100644
@@ -167,6 +167,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 +65 -0

140 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +90 -0

106 lines not on this page · raw message

Signature · 1 line
2.34.1
#243 lore raw

PATCH v11 2/18 net/idpf: add support for device initialization

In reply to Junfeng Guo

Support device init and add the following dev ops:
- dev_configure
- dev_close
- dev_infos_get

---
 MAINTAINERS                            |   9 +
 doc/guides/nics/features/idpf.ini      |  10 +
 doc/guides/nics/idpf.rst               |  66 ++
 doc/guides/nics/index.rst              |   1 +
 doc/guides/rel_notes/release_22_11.rst |   6 +
 drivers/net/idpf/idpf_ethdev.c         | 825 +++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h         | 207 +++++++
 drivers/net/idpf/idpf_logs.h           |  56 ++
 drivers/net/idpf/idpf_vchnl.c          | 470 ++++++++++++++
 drivers/net/idpf/meson.build           |  15 +
 drivers/net/idpf/version.map           |   3 +
 drivers/net/meson.build                |   1 +
 12 files changed, 1669 insertions(+)
 create mode 100644 doc/guides/nics/features/idpf.ini
 create mode 100644 doc/guides/nics/idpf.rst
 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_vchnl.c
 create mode 100644 drivers/net/idpf/meson.build
 create mode 100644 drivers/net/idpf/version.map
MAINTAINERS +9 -0
index 92b381bc30..34f8b9cc61 100644
@@ -764,6 +764,15 @@ F: drivers/net/ice/
 F: doc/guides/nics/ice.rst
 F: doc/guides/nics/features/ice.ini
 
+Intel idpf
+M: Jingjing Wu <[email protected]>
+M: Beilei Xing <[email protected]>
+T: git://dpdk.org/next/dpdk-next-net-intel
+F: drivers/net/idpf/
+F: drivers/common/idpf/
+F: doc/guides/nics/idpf.rst
+F: doc/guides/nics/features/idpf.ini
+
 Intel igc
 M: Junfeng Guo <[email protected]>
 M: Simei Su <[email protected]>
doc/guides/nics/features/idpf.ini new file +10 -0
new file mode 100644
index 0000000000..7a44b8b5e4
@@ -0,0 +1,10 @@
+;
+; Supported features of the 'idpf' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+; A feature with "P" indicates only be supported when non-vector path
+; is selected.
+;
+[Features]
+Linux                = Y
doc/guides/nics/idpf.rst new file +66 -0

66 lines not on this page · raw message

doc/guides/nics/index.rst +1 -0
index 32c7544968..b4dd5ea522 100644
@@ -33,6 +33,7 @@ Network Interface Controller Drivers
     hns3
     i40e
     ice
+    idpf
     igb
     igc
     ionic
doc/guides/rel_notes/release_22_11.rst +6 -0
index 1c3daf141d..4af790de37 100644
@@ -160,6 +160,12 @@ New Features
 
   * Added protocol based buffer split support in scalar path.
 
+* **Added IDPF PMD [*EXPERIMENTAL*].**
+
+  Added the new ``idpf`` net driver for Intel® Infrastructure Processing Unit
+  (Intel® IPU) E2000.
+  See the :doc:`../nics/idpf` NIC guide for more details on this new driver.
+
 * **Updated Marvell cnxk driver.**
 
   * Added support for flow action REPRESENTED_PORT.
drivers/net/idpf/idpf_ethdev.c new file +825 -0

825 lines not on this page · raw message

drivers/net/idpf/idpf_ethdev.h new file +207 -0

207 lines not on this page · raw message

drivers/net/idpf/idpf_logs.h new file +56 -0

56 lines not on this page · raw message

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

470 lines not on this page · raw message

drivers/net/idpf/meson.build new file +15 -0
new file mode 100644
index 0000000000..ecf73355c3
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
+deps += ['common_idpf']
+
+sources = files(
+    'idpf_ethdev.c',
+    'idpf_vchnl.c',
+)
drivers/net/idpf/version.map new file +3 -0
new file mode 100644
index 0000000000..78c3585d7c
@@ -0,0 +1,3 @@
+DPDK_23 {
+	local: *;
+};
drivers/net/meson.build +1 -0
index 35bfa78dee..4a951b95f2 100644
@@ -28,6 +28,7 @@ drivers = [
         'i40e',
         'iavf',
         'ice',
+        'idpf',
         'igc',
         'ionic',
         'ipn3ke',
Signature · 1 line
2.34.1
#244 lore raw

Re: [PATCH v11 02/18] net/idpf: add support for device initialization

Quoted 9 lines · Junfeng Guo

Support device init and add the following dev ops:
- dev_configure
- dev_close
- dev_infos_get

[snip]

doc/guides/nics/features/idpf.ini line 7

Quoted 13 lines
doc/guides/nics/features/idpf.ini new file +7 -0
new file mode 100644
index 0000000000..7a44b8b5e4
@@ -0,0 +1,10 @@
+;
+; Supported features of the 'idpf' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+; A feature with "P" indicates only be supported when non-vector path
+; is selected.

The statement should be added when the first P appears.

doc/guides/nics/features/idpf.ini line 10

Quoted 3 lines
doc/guides/nics/features/idpf.ini new file +3 -0
+;
+[Features]
+Linux                = Y

I think you should add at least one architecture. I guess it should be x86_64 since otherwise it is unclear where to build...

Quoted 56 lines
drivers/net/idpf/idpf_ethdev.c new file +50 -0
new file mode 100644
index 0000000000..75695085f8
@@ -0,0 +1,825 @@
+/* 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_TX_SINGLE_Q	"tx_single"
+#define IDPF_RX_SINGLE_Q	"rx_single"
+#define IDPF_VPORT		"vport"
+
+rte_spinlock_t idpf_adapter_lock;
+/* A list for all adapters, one adapter matches one PCI device */
+struct idpf_adapter_list idpf_adapter_list;
+bool idpf_adapter_list_init;
+
+static const char * const idpf_valid_args[] = {
+	IDPF_TX_SINGLE_Q,
+	IDPF_RX_SINGLE_Q,
+	IDPF_VPORT,
+	NULL
+};
+
+static int idpf_dev_configure(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 void idpf_adapter_rel(struct idpf_adapter *adapter);
+
+static const struct eth_dev_ops idpf_eth_dev_ops = {
+	.dev_configure			= idpf_dev_configure,
+	.dev_close			= idpf_dev_close,
+	.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;

drivers/net/idpf/idpf_ethdev.c line 60

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c new file +10 -0
+	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 = 0;
+	dev_info->rx_offload_capa = 0;
+
+	dev_info->tx_offload_capa = 0;

You don't need above zeros since the structure is memset to 0 in ethdev layer before driver callback invocation.

Quoted 58 lines
drivers/net/idpf/idpf_ethdev.c new file +58 -0
+
+	return 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->cur_vport_idx;
+
+	if (idx == IDPF_INVALID_VPORT_IDX) {
+		PMD_INIT_LOG(ERR, "Invalid vport index.");
+		return -1;
+	}
+
+	if (adapter->vport_req_info[idx] == NULL) {
+		adapter->vport_req_info[idx] = rte_zmalloc(NULL,
+				sizeof(struct virtchnl2_create_vport), 0);
+		if (adapter->vport_req_info[idx] == NULL) {
+			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 == 0) {
+		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 == 0) {
+		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;
+}
+

drivers/net/idpf/idpf_ethdev.c line 128

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c new file +10 -0
+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);

There is a potential segfault here if there is no vport_ in the name.

drivers/net/idpf/idpf_ethdev.c line 133

Quoted 5 lines
drivers/net/idpf/idpf_ethdev.c new file +5 -0
+
+	return val;
+}
+
+#define IDPF_RSS_KEY_LEN 52

The define is not used. It must be a part of the RSS support patch and it should be use to set key size in device information.

Quoted 15 lines
drivers/net/idpf/idpf_ethdev.c new file +15 -0
+
+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->cur_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;

drivers/net/idpf/idpf_ethdev.c line 158

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c new file +10 -0
+	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;
+	rte_memcpy(vport->default_mac_addr,
+		   vport_info->default_mac_addr, ETH_ALEN);
+	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) {

switch/case will be more readable here

Quoted 35 lines
drivers/net/idpf/idpf_ethdev.c new file +35 -0
+			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;
+		}
+	}
+
+	vport->devarg_id = idpf_parse_devarg_id(dev->data->name);
+	vport->dev_data = dev->data;

drivers/net/idpf/idpf_ethdev.c line 203

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c new file +10 -0
+
+	adapter->vports[idx] = vport;
+
+	return 0;
+}
+static int
+idpf_dev_configure(struct rte_eth_dev *dev)
+{
+	if ((dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) != 0)
+		PMD_INIT_LOG(ERR, "RSS is not supported.");

Do you think it is really enought?
You ignore:
- link_speeds
- rxmode in the case of DCB-only and/or with VMDq
- txmode in DCB and VMQq cases
- txmode: pvid, hw_vlan*
- lpbk_mode
- dcb_capability_en
- intr_conf

Quoted 65 lines
drivers/net/idpf/idpf_ethdev.c new file +65 -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;
+
+	idpf_vc_destroy_vport(vport);
+
+
+	adapter->cur_vports &= ~RTE_BIT32(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) != 0)
+			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) != 0)
+				return NULL;
+		}
+	} else {

drivers/net/idpf/idpf_ethdev.c line 278

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c new file +10 -0
+		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;

type cast from void * is not required in C

Quoted 41 lines
drivers/net/idpf/idpf_ethdev.c new file +41 -0
+	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 & RTE_BIT32(adapter->req_vports[i])) == 0) {
+			adapter->cur_vports |= RTE_BIT32(adapter->req_vports[i]);
+			adapter->cur_vport_nb++;
+		} else {
+			PMD_INIT_LOG(ERR, "Vport %d has been created",
+				     adapter->req_vports[i]);
+			return -1;

drivers/net/idpf/idpf_ethdev.c line 329

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c new file +10 -0
+		}
+	}
+
+	return 0;
+}
+
+static int
+parse_bool(const char *key, const char *value, void *args)
+{
+	int *i = (int *)args;

type cast from void * is not required in C

drivers/net/idpf/idpf_ethdev.c line 333

Quoted 4 lines
drivers/net/idpf/idpf_ethdev.c new file +4 -0
+	char *end;
+	int num;
+
+	num = strtoul(value, &end, 10);

man strtoul:
The implementation may also set errno to EINVAL in case no conversion was performed (no digits seen, and 0 returned).

drivers/net/idpf/idpf_ethdev.c line 335

Quoted 2 lines
drivers/net/idpf/idpf_ethdev.c new file +2 -0
+
+	if (num != 0 && num != 1) {

So, 0 may be returned in the case of failure, but you treat it as OK here.

Quoted 313 lines
drivers/net/idpf/idpf_ethdev.c new file +313 -0
+		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)
+{
+	struct rte_devargs *devargs = pci_dev->device.devargs;
+	struct rte_kvargs *kvlist;
+	int ret;
+
+	if (devargs == NULL)
+		return 0;
+
+	kvlist = rte_kvargs_parse(devargs->args, idpf_valid_args);
+	if (kvlist == NULL) {
+		PMD_INIT_LOG(ERR, "invalid kvargs key");
+		return -EINVAL;
+	}
+
+	ret = rte_kvargs_process(kvlist, IDPF_VPORT, &parse_vport,
+				 adapter);
+	if (ret != 0)
+		goto bail;
+
+	ret = rte_kvargs_process(kvlist, IDPF_TX_SINGLE_Q, &parse_bool,
+				 &adapter->txq_model);
+	if (ret != 0)
+		goto bail;
+
+	ret = rte_kvargs_process(kvlist, IDPF_RX_SINGLE_Q, &parse_bool,
+				 &adapter->rxq_model);
+	if (ret != 0)
+		goto bail;
+
+bail:
+	rte_kvargs_free(kvlist);
+	return ret;
+}
+
+static void
+idpf_reset_pf(struct idpf_hw *hw)
+{
+	uint32_t reg;
+
+	reg = IDPF_READ_REG(hw, PFGEN_CTRL);
+	IDPF_WRITE_REG(hw, PFGEN_CTRL, (reg | PFGEN_CTRL_PFSWR));
+}
+
+#define IDPF_RESET_WAIT_CNT 100
+static int
+idpf_check_pf_reset_done(struct idpf_hw *hw)
+{
+	uint32_t reg;
+	int i;
+
+	for (i = 0; i < IDPF_RESET_WAIT_CNT; i++) {
+		reg = IDPF_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 idpf_hw *hw)
+{
+	struct idpf_ctlq_create_info ctlq_info[CTLQ_NUM] = {
+		{
+			.type = IDPF_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 = IDPF_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 idpf_ctlq_info *ctlq;
+	int ret;
+
+	ret = idpf_ctlq_init(hw, CTLQ_NUM, ctlq_info);
+	if (ret != 0)
+		return ret;
+
+	LIST_FOR_EACH_ENTRY_SAFE(ctlq, NULL, &hw->cq_list_head,
+				 struct idpf_ctlq_info, cq_list) {
+		if (ctlq->q_id == IDPF_CTLQ_ID &&
+		    ctlq->cq_type == IDPF_CTLQ_TYPE_MAILBOX_TX)
+			hw->asq = ctlq;
+		if (ctlq->q_id == IDPF_CTLQ_ID &&
+		    ctlq->cq_type == IDPF_CTLQ_TYPE_MAILBOX_RX)
+			hw->arq = ctlq;
+	}
+
+	if (hw->asq == NULL || hw->arq == NULL) {
+		idpf_ctlq_deinit(hw);
+		ret = -ENOENT;
+	}
+
+	return ret;
+}
+
+static int
+idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
+{
+	struct idpf_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 != 0) {
+		PMD_INIT_LOG(ERR, "IDPF is still resetting");
+		goto err;
+	}
+
+	ret = idpf_init_mbx(hw);
+	if (ret != 0) {
+		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 == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate idpf_adapter_mbx_resp memory");
+		goto err_mbx;
+	}
+
+	if (idpf_vc_check_api_version(adapter) != 0) {
+		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 == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate idpf_caps memory");
+		goto err_api;
+	}
+
+	if (idpf_vc_get_caps(adapter) != 0) {
+		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 == NULL) {
+		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 == NULL) {
+		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 == NULL) {
+		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;
+
+	return ret;
+
+err_vports:
+	rte_free(adapter->vport_recv_info);
+	adapter->vport_recv_info = 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:
+	idpf_ctlq_deinit(hw);
+err:
+	return -1;
+}
+
+static uint16_t
+idpf_get_vport_idx(struct idpf_vport **vports, uint16_t max_vport_nb)
+{
+	uint16_t vport_idx;
+	uint16_t i;
+
+	for (i = 0; i < max_vport_nb; i++) {
+		if (vports[i] == NULL)
+			break;
+	}
+
+	if (i == max_vport_nb)
+		vport_idx = IDPF_INVALID_VPORT_IDX;
+	else
+		vport_idx = i;
+
+	return vport_idx;
+}
+
+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;
+
+	dev->dev_ops = &idpf_eth_dev_ops;
+	vport->adapter = adapter;
+
+	ret = idpf_init_vport_req_info(dev);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init vport req_info.");
+		goto err;
+	}
+
+	ret = idpf_vc_create_vport(adapter);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to create vport.");
+		goto err_create_vport;
+	}
+
+	ret = idpf_init_vport(dev);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init vports.");
+		goto err_init_vport;
+	}
+
+	adapter->cur_vport_idx = idpf_get_vport_idx(adapter->vports,
+						    adapter->max_vport_nb);
+
+	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_vc_destroy_vport(vport);
+err_create_vport:
+	rte_free(vport->adapter->vport_req_info[vport->adapter->cur_vport_idx]);
+err:

drivers/net/idpf/idpf_ethdev.c line 658

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c new file +10 -0
+	return ret;
+}
+
+static const struct rte_pci_id pci_id_idpf_map[] = {
+	{ RTE_PCI_DEVICE(IDPF_INTEL_VENDOR_ID, IDPF_DEV_ID_PF) },
+	{ .vendor_id = 0, /* sentinel */ },
+};
+
+struct idpf_adapter *
+idpf_find_adapter(struct rte_pci_device *pci_dev)

It looks like the function requires corresponding lock to be held. If yes, it should be documented and code fixed. If no, it should be explaiend why.

Quoted 173 lines
drivers/net/idpf/idpf_ethdev.c new file +167 -0
+{
+	struct idpf_adapter *adapter;
+
+	TAILQ_FOREACH(adapter, &idpf_adapter_list, next) {
+		if (strncmp(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE) == 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;
+	bool first_probe = false;
+
+	if (!idpf_adapter_list_init) {
+		rte_spinlock_init(&idpf_adapter_lock);
+		TAILQ_INIT(&idpf_adapter_list);
+		idpf_adapter_list_init = true;
+	}
+
+	adapter = idpf_find_adapter(pci_dev);
+	if (adapter == NULL) {
+		first_probe = true;
+		adapter = (struct idpf_adapter *)rte_zmalloc("idpf_adapter",
+						sizeof(struct idpf_adapter), 0);
+		if (adapter == NULL) {
+			PMD_INIT_LOG(ERR, "Failed to allocate adapter.");
+			return -1;
+		}
+
+		retval = idpf_adapter_init(pci_dev, adapter);
+		if (retval != 0) {
+			PMD_INIT_LOG(ERR, "Failed to init adapter.");
+			return retval;
+		}
+
+		rte_spinlock_lock(&idpf_adapter_lock);
+		TAILQ_INSERT_TAIL(&idpf_adapter_list, adapter, next);
+		rte_spinlock_unlock(&idpf_adapter_lock);
+	}
+
+	retval = idpf_parse_devargs(pci_dev, adapter);
+	if (retval != 0) {
+		PMD_INIT_LOG(ERR, "Failed to parse private devargs");
+		goto err;
+	}
+
+	if (adapter->req_vport_nb == 0) {
+		/* If no vport devarg, create vport 0 by default. */
+		snprintf(name, sizeof(name), "idpf_%s_vport_0",
+			 pci_dev->device.name);
+		retval = rte_eth_dev_create(&pci_dev->device, name,
+					    sizeof(struct idpf_vport),
+					    NULL, NULL, idpf_dev_init,
+					    adapter);
+		if (retval != 0)
+			PMD_DRV_LOG(ERR, "Failed to create default vport 0");
+		adapter->cur_vports |= RTE_BIT32(0);
+		adapter->cur_vport_nb++;
+	} else {
+		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 != 0)
+				PMD_DRV_LOG(ERR, "Failed to create vport %d",
+					    adapter->req_vports[i]);
+		}
+	}
+
+	return 0;
+
+err:
+	if (first_probe) {
+		rte_spinlock_lock(&idpf_adapter_lock);
+		TAILQ_REMOVE(&idpf_adapter_list, adapter, next);
+		rte_spinlock_unlock(&idpf_adapter_lock);
+		idpf_adapter_rel(adapter);
+		rte_free(adapter);
+	}
+	return retval;
+}
+
+static void
+idpf_adapter_rel(struct idpf_adapter *adapter)
+{
+	struct idpf_hw *hw = &adapter->hw;
+	int i;
+
+	idpf_ctlq_deinit(hw);
+
+	rte_free(adapter->caps);
+	adapter->caps = NULL;
+
+	rte_free(adapter->mbx_resp);
+	adapter->mbx_resp = NULL;
+
+	if (adapter->vport_req_info != NULL) {
+		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 != NULL) {
+		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->vport_recv_info);
+		adapter->vport_recv_info = 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);
+	uint16_t port_id;
+
+	/* Ethdev created can be found RTE_ETH_FOREACH_DEV_OF through rte_device */
+	RTE_ETH_FOREACH_DEV_OF(port_id, &pci_dev->device) {
+			rte_eth_dev_close(port_id);
+	}
+
+	rte_spinlock_lock(&idpf_adapter_lock);
+	TAILQ_REMOVE(&idpf_adapter_list, adapter, next);
+	rte_spinlock_unlock(&idpf_adapter_lock);
+	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 +0 -0
new file mode 100644
index 0000000000..c0ae801fd5

drivers/net/idpf/idpf_ethdev.h line 9

Quoted 9 lines
drivers/net/idpf/idpf_ethdev.h new file +9 -0
@@ -0,0 +1,207 @@
+/* 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>

seems to be unused

drivers/net/idpf/idpf_ethdev.h line 10

Quoted 1 line
drivers/net/idpf/idpf_ethdev.h new file +1 -0
+#include <rte_mempool.h>

seems to be unused

Quoted 8 lines
drivers/net/idpf/idpf_ethdev.h new file +8 -0
+#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 "idpf_logs.h"

drivers/net/idpf/idpf_ethdev.h line 28

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.h new file +10 -0
+
+#include <base/idpf_osdep.h>
+#include <base/idpf_type.h>
+#include <base/idpf_devids.h>
+#include <base/idpf_prototype.h>
+#include <base/idpf_lan_txrx.h>
+#include <base/idpf_lan_pf_regs.h>
+#include <base/virtchnl.h>
+#include <base/virtchnl2.h>
+#include <base/virtchnl2_lan_desc.h>

Are you sure that everything above used in the
patch?

drivers/net/idpf/idpf_ethdev.h line 36

Quoted 8 lines
drivers/net/idpf/idpf_ethdev.h new file +8 -0
+
+#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

unused

drivers/net/idpf/idpf_ethdev.h line 38

Quoted 2 lines
drivers/net/idpf/idpf_ethdev.h new file +2 -0
+#define IDPF_TX_COMPLQ_PER_GRP	1
+#define IDPF_RXQ_PER_GRP	1

unused

Quoted 8 lines
drivers/net/idpf/idpf_ethdev.h new file +8 -0
+#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_MIN_BUF_SIZE	1024
+#define IDPF_MAX_FRAME_SIZE	9728

drivers/net/idpf/idpf_ethdev.h line 56

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.h new file +10 -0
+
+#define IDPF_NUM_MACADDR_MAX	64
+
+#define IDPF_VLAN_TAG_SIZE	4
+#define IDPF_ETH_OVERHEAD \
+	(RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + IDPF_VLAN_TAG_SIZE * 2)
+
+#ifndef ETH_ADDR_LEN
+#define ETH_ADDR_LEN		6
+#endif

Why do you need it?

Quoted 24 lines
drivers/net/idpf/idpf_ethdev.h new file +24 -0
+
+#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;

drivers/net/idpf/idpf_ethdev.h line 90

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.h new file +10 -0
+	uint64_t rx_buf_qtail_start;
+	uint32_t rx_buf_qtail_spacing;
+};
+
+struct idpf_vport {
+	struct idpf_adapter *adapter; /* Backreference to associated adapter */
+	uint16_t vport_id;
+	uint32_t txq_model;
+	uint32_t rxq_model;
+	uint16_t num_tx_q;

Shouldn't it be set as the result of configure? data->nb_tx_queues which is the result of the configure is not used in the patch?

drivers/net/idpf/idpf_ethdev.h line 93

Quoted 3 lines
drivers/net/idpf/idpf_ethdev.h new file +3 -0
+	/* valid only if txq_model is split Q */
+	uint16_t num_tx_complq;
+	uint16_t num_rx_q;

same here.

drivers/net/idpf/idpf_ethdev.h line 97

Quoted 4 lines
drivers/net/idpf/idpf_ethdev.h new file +4 -0
+	/* valid only if rxq_model is split Q */
+	uint16_t num_rx_bufq;
+
+	uint16_t max_mtu;

unused

Quoted 9 lines
drivers/net/idpf/idpf_ethdev.h new file +9 -0
+	uint8_t default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
+
+	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 */
+
+	/* Chunk info */
+	struct idpf_chunks_info chunks_info;

drivers/net/idpf/idpf_ethdev.h line 116

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.h new file +10 -0
+
+	uint16_t devarg_id;
+};
+
+struct idpf_adapter {
+	TAILQ_ENTRY(idpf_adapter) next;
+	struct idpf_hw hw;
+	char name[IDPF_ADAPTER_NAME_LEN];
+
+	struct virtchnl_version_info virtchnl_version;

unused. I'm stopping unused check here. Please, do it yourself carefully after each patch to avoid more review iterations.

Quoted 19 lines
drivers/net/idpf/idpf_ethdev.h new file +19 -0
+	struct virtchnl2_get_capabilities *caps;
+
+	volatile enum virtchnl_ops pend_cmd; /* pending command not finished */
+	uint32_t cmd_retval; /* return value of the cmd response from ipf */
+	uint8_t *mbx_resp; /* buffer to store the mailbox response from ipf */
+
+	uint32_t txq_model; /* 0 - split queue model, non-0 - single queue model */
+	uint32_t rxq_model; /* 0 - split queue model, non-0 - single queue 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 cur_vport_idx;

drivers/net/idpf/idpf_ethdev.h line 145

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.h new file +10 -0
+
+	/* Max config queue number per VC message */
+	uint32_t max_rxq_per_msg;
+	uint32_t max_txq_per_msg;
+
+	bool stopped;
+};
+
+TAILQ_HEAD(idpf_adapter_list, idpf_adapter);
+extern struct idpf_adapter_list adapter_list;

there is no adapter_list variable.

[snip]

Quoted 5 lines
drivers/net/idpf/idpf_vchnl.c new file +0 -0
new file mode 100644
index 0000000000..ec72a8bba7

[snip]

Quoted 4 lines
drivers/net/idpf/idpf_vchnl.c new file +4 -0
+static int
+idpf_send_vc_msg(struct idpf_adapter *adapter, enum virtchnl_ops op,
+		 uint16_t msg_size, uint8_t *msg)
+{

drivers/net/idpf/idpf_vchnl.c line 71

Quoted 10 lines
drivers/net/idpf/idpf_vchnl.c new file +10 -0
+	struct idpf_ctlq_msg *ctlq_msg;
+	struct idpf_dma_mem *dma_mem;
+	int err;
+
+	err = idpf_vc_clean(adapter);
+	if (err != 0)
+		goto err;
+
+	ctlq_msg = (struct idpf_ctlq_msg *)rte_zmalloc(NULL,
+				sizeof(struct idpf_ctlq_msg), 0);

Type cast from void * is not required in C. Fix it everywhere, please.

[snip]

Quoted 64 lines
drivers/net/idpf/idpf_vchnl.c new file +64 -0
+int
+idpf_vc_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 =

drivers/net/idpf/idpf_vchnl.c line 357

Quoted 10 lines
drivers/net/idpf/idpf_vchnl.c new file +10 -0
+		 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;

I'm wondering why all above capabilities are mentioned in the patch? What does the API do? Do it is request it? Negotiage?

Quoted 18 lines
drivers/net/idpf/idpf_vchnl.c new file +18 -0
+
+	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 != 0) {
+		PMD_DRV_LOG(ERR,
+			    "Failed to execute command of VIRTCHNL2_OP_GET_CAPS");
+		return err;
+	}
+
+	rte_memcpy(adapter->caps, args.out_buffer, sizeof(caps_msg));
+
+	return 0;
+}
#245 lore raw

RE: [PATCH v11 02/18] net/idpf: add support for device initialization

Quoted 25 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Tuesday, October 25, 2022 4:57 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]>
Subject: Re: [PATCH v11 02/18] net/idpf: add support for device initialization

Quoted 9 lines · Junfeng Guo

Support device init and add the following dev ops:
- dev_configure
- dev_close
- dev_infos_get

[snip]

Quoted 16 lines
Quoted 7 lines
doc/guides/nics/features/idpf.ini new file +0 -0
new file mode 100644
index 0000000000..7a44b8b5e4

doc/guides/nics/features/idpf.ini line 7

Quoted 7 lines
doc/guides/nics/features/idpf.ini new file +7 -0
@@ -0,0 +1,10 @@
+;
+; Supported features of the 'idpf' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+; A feature with "P" indicates only be supported when non-vector path
+; is selected.

The statement should be added when the first P appears.

Thanks for the comments, all the comments are addressed in next version except the below one.

[snip]

Quoted 5 lines

doc/guides/nics/features/idpf.ini

Quoted 4 lines
doc/guides/nics/features/idpf.ini new file +4 -0
+};
+
+struct idpf_vport {
+	struct idpf_adapter *adapter; /* Backreference to associated adapter

*/

Quoted 8 lines

doc/guides/nics/features/idpf.ini

Quoted 4 lines
doc/guides/nics/features/idpf.ini new file +4 -0
+	uint16_t vport_id;
+	uint32_t txq_model;
+	uint32_t rxq_model;
+	uint16_t num_tx_q;

Shouldn't it be set as the result of configure? data->nb_tx_queues which is the result of the configure is not used in the patch?

The num_tx_q here is different from data->nb_tx_queues.
The idpf PMD requires fixed txqs and rxqs when the idpf PMD requires creating a vport. The num_tx_q and the num_rxq_q are the values returned by backend.
But there'll be only data->nb_tx_queues txqs configured during dev_start.

#246 lore raw

Re: [PATCH v11 02/18] net/idpf: add support for device initialization

In reply to Andrew Rybchenko
Quoted 10 lines · Andrew Rybchenko
Quoted 9 lines · Junfeng Guo

Support device init and add the following dev ops:
  - dev_configure
  - dev_close
  - dev_infos_get

[snip]

Quoted 6 lines

drivers/net/idpf/idpf_ethdev.c line 658

Quoted 2 lines
drivers/net/idpf/idpf_ethdev.c new file +2 -0
+struct idpf_adapter *
+idpf_find_adapter(struct rte_pci_device *pci_dev)

It looks like the function requires corresponding lock to be held. If yes, it should be documented and code fixed. If no, it should be explaiend why.

I still don't understand it is a new patch. It is hardly safe to return a pointer to an element list when you drop lock.

Quoted 6 lines
Quoted 4 lines

+    /* valid only if rxq_model is split Q */ +    uint16_t num_rx_bufq;
+
+    uint16_t max_mtu;

unused

Comments? It is still in place in a new version.

Quoted 69 lines
Quoted 69 lines
drivers/net/idpf/idpf_vchnl.c new file +69 -0
+int
+idpf_vc_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        |
Quoted 8 lines
Quoted 5 lines

+         VIRTCHNL2_CAP_CRC            |
+         VIRTCHNL2_CAP_WB_ON_ITR        | +         VIRTCHNL2_CAP_PROMISC            | +         VIRTCHNL2_CAP_LINK_SPEED        | +         VIRTCHNL2_CAP_VLAN;

I'm wondering why all above capabilities are mentioned in the patch? What does the API do? Do it is request it? Negotiage?

Can I have answer on my question?

#247 lore raw

RE: [PATCH v11 02/18] net/idpf: add support for device initialization

Quoted 33 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Friday, October 28, 2022 11:14 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]>
Subject: Re: [PATCH v11 02/18] net/idpf: add support for device initialization

Quoted 10 lines · Andrew Rybchenko
Quoted 9 lines · Junfeng Guo

Support device init and add the following dev ops:
  - dev_configure
  - dev_close
  - dev_infos_get

[snip]

Quoted 6 lines

drivers/net/idpf/idpf_ethdev.c line 658

Quoted 2 lines
drivers/net/idpf/idpf_ethdev.c new file +2 -0
+struct idpf_adapter *
+idpf_find_adapter(struct rte_pci_device *pci_dev)

It looks like the function requires corresponding lock to be held. If yes, it should be documented and code fixed. If no, it should be explaiend why.

Quoted 2 lines

I still don't understand it is a new patch. It is hardly safe to return a pointer to an element list when you drop lock.

Sorry I misunderstood your last comment, I thought you meant lock for adapter_list. I don't think we need a lock for adapter, one adapter here doesn't map one ethdev, but one PCI device, we can create some vports for one adapter, and one vport maps one ethdev.

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines

+    /* valid only if rxq_model is split Q */ +    uint16_t num_rx_bufq;
+
+    uint16_t max_mtu;

unused

Comments? It is still in place in a new version.

All the above info is returned by backend when creating a vport, so save it after creating vport.

Quoted 79 lines
Quoted 70 lines
Quoted 70 lines
drivers/net/idpf/idpf_vchnl.c new file +69 -0
+int
+idpf_vc_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        |
Quoted 8 lines
Quoted 5 lines

+         VIRTCHNL2_CAP_CRC            |
+         VIRTCHNL2_CAP_WB_ON_ITR        | +         VIRTCHNL2_CAP_PROMISC            | +         VIRTCHNL2_CAP_LINK_SPEED        | +         VIRTCHNL2_CAP_VLAN;

I'm wondering why all above capabilities are mentioned in the patch? What does the API do? Do it is request it? Negotiage?

Quoted 1 line

Can I have answer on my question?

I removed some caps in v14, and I think it makes sense adding one cap when enable the offload.

#248 lore raw

PATCH v11 3/18 net/idpf: add Tx queue setup

In reply to Junfeng Guo

Add support for tx_queue_setup ops.

In the single queue model, the same descriptor queue is used by SW to post buffer descriptors to HW and by HW to post completed descriptors to SW.

In the split queue model, "RX buffer queues" are used to pass descriptor buffers from SW to HW while Rx queues are used only to pass the descriptor completions, that is, descriptors that point to completed buffers, from HW to SW. This is contrary to the single queue model in which Rx queues are used for both purposes.

---
 drivers/net/idpf/idpf_ethdev.c |  18 +-
 drivers/net/idpf/idpf_rxtx.c   | 371 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  76 +++++++
 drivers/net/idpf/meson.build   |   1 +
 4 files changed, 464 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/idpf/idpf_rxtx.c
 create mode 100644 drivers/net/idpf/idpf_rxtx.h
drivers/net/idpf/idpf_ethdev.c +16 -2
index 75695085f8..c0307128be 100644
@@ -10,6 +10,7 @@
 #include <rte_dev.h>
 
 #include "idpf_ethdev.h"
+#include "idpf_rxtx.h"
 
 #define IDPF_TX_SINGLE_Q	"tx_single"
 #define IDPF_RX_SINGLE_Q	"rx_single"
@@ -36,6 +37,7 @@ static void idpf_adapter_rel(struct idpf_adapter *adapter);
 static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_configure			= idpf_dev_configure,
 	.dev_close			= idpf_dev_close,
+	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
 };
 
@@ -54,11 +56,23 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
 
 	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
-	dev_info->dev_capa = 0;
+	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
 	dev_info->rx_offload_capa = 0;
-
 	dev_info->tx_offload_capa = 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->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;
 }
 
drivers/net/idpf/idpf_rxtx.c new file +371 -0

371 lines not on this page · raw message

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

76 lines not on this page · raw message

drivers/net/idpf/meson.build +1 -0
index ecf73355c3..b632b76656 100644
@@ -11,5 +11,6 @@ deps += ['common_idpf']
 
 sources = files(
     'idpf_ethdev.c',
+    'idpf_rxtx.c',
     'idpf_vchnl.c',
 )
Signature · 1 line
2.34.1
#249 lore raw

Re: [PATCH v11 03/18] net/idpf: add Tx queue setup

Quoted 15 lines · Junfeng Guo

Add support for tx_queue_setup ops.

In the single queue model, the same descriptor queue is used by SW to post buffer descriptors to HW and by HW to post completed descriptors to SW.

In the split queue model, "RX buffer queues" are used to pass descriptor buffers from SW to HW while Rx queues are used only to pass the descriptor completions, that is, descriptors that point to completed buffers, from HW to SW. This is contrary to the single queue model in which Rx queues are used for both purposes.

[snip]

Quoted 21 lines
drivers/net/idpf/idpf_ethdev.c +2 -0
index 75695085f8..c0307128be 100644
@@ -10,6 +10,7 @@
  #include <rte_dev.h>
 
  #include "idpf_ethdev.h"
+#include "idpf_rxtx.h"
 
  #define IDPF_TX_SINGLE_Q	"tx_single"
  #define IDPF_RX_SINGLE_Q	"rx_single"
@@ -36,6 +37,7 @@ static void idpf_adapter_rel(struct idpf_adapter *adapter);
  static const struct eth_dev_ops idpf_eth_dev_ops = {
  	.dev_configure			= idpf_dev_configure,
  	.dev_close			= idpf_dev_close,
+	.tx_queue_setup			= idpf_tx_queue_setup,
  	.dev_infos_get			= idpf_dev_info_get,
  };
 

drivers/net/idpf/idpf_ethdev.c idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) · line 59

Quoted 5 lines
drivers/net/idpf/idpf_ethdev.c +1 -1
@@ -54,11 +56,23 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
  	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
 
  	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
-	dev_info->dev_capa = 0;
+	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;

I've played with two Intel PMDs: i40e and ice and both have bugs in runtime queue setup. That's why I'm trying to review it carefully in a new driver. So, I'd like to repeat once
again: the feature does not make sense without device start support since corresponding code cann't be in-place and cannot be reviewed here.

drivers/net/idpf/idpf_ethdev.c idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) · line 59

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

Unrlated change

drivers/net/idpf/idpf_ethdev.c idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) · line 66

Quoted 6 lines
drivers/net/idpf/idpf_ethdev.c +4 -0
  	dev_info->tx_offload_capa = 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,

There is no necessity to initialize to zero explicitly since the compiler does it for you implicitly.

Quoted 19 lines
drivers/net/idpf/idpf_ethdev.c +9 -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,
+	};
+
+
  	return 0;
  }
 
drivers/net/idpf/idpf_rxtx.c new file +1 -0
new file mode 100644
index 0000000000..df0ed772c1
@@ -0,0 +1,371 @@
+/* SPDX-License-Identifier: BSD-3-Clause

drivers/net/idpf/idpf_rxtx.c line 11

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c new file +10 -0
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#include <ethdev_driver.h>
+#include <rte_net.h>
+
+#include "idpf_ethdev.h"
+#include "idpf_rxtx.h"
+
+static inline int

There is no point to make it inline. It is a control path. Please, keep it to the compiler to do its job.

Quoted 2 lines
drivers/net/idpf/idpf_rxtx.c new file +2 -0
+check_tx_thresh(uint16_t nb_desc, uint16_t tx_rs_thresh,
+		uint16_t tx_free_thresh)

[snip]

drivers/net/idpf/idpf_rxtx.c line 60

Quoted 2 lines
drivers/net/idpf/idpf_rxtx.c new file +2 -0
+static inline void
+reset_split_tx_descq(struct idpf_tx_queue *txq)

same here since it looks like control path as well.

[snip]

drivers/net/idpf/idpf_rxtx.c line 73

Quoted 13 lines
drivers/net/idpf/idpf_rxtx.c new file +13 -0
+{
+	struct idpf_tx_entry *txe;
+	uint32_t i, size;
+	uint16_t prev;
+
+	if (txq == NULL) {
+		PMD_DRV_LOG(DEBUG, "Pointer to txq is NULL");
+		return;
+	}
+
+	size = sizeof(struct idpf_flex_tx_sched_desc) * txq->nb_tx_desc;
+	for (i = 0; i < size; i++)
+		((volatile char *)txq->desc_ring)[i] = 0;

Please, add a comment which explains why volatile is required here.

Quoted 11 lines
drivers/net/idpf/idpf_rxtx.c new file +11 -0
+
+	txe = txq->sw_ring;
+	prev = (uint16_t)(txq->sw_nb_desc - 1);
+	for (i = 0; i < txq->sw_nb_desc; i++) {
+		txe[i].mbuf = NULL;
+		txe[i].last_id = i;
+		txe[prev].next_id = i;
+		prev = i;
+	}
+
+	txq->tx_tail = 0;

drivers/net/idpf/idpf_rxtx.c line 94

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c new file +10 -0
+	txq->nb_used = 0;
+
+	/* Use this as next to clean for split desc queue */
+	txq->last_desc_cleaned = 0;
+	txq->sw_tail = 0;
+	txq->nb_free = txq->nb_tx_desc - 1;
+}
+
+static inline void
+reset_split_tx_complq(struct idpf_tx_queue *cq)

same here

drivers/net/idpf/idpf_rxtx.c line 105

Quoted 11 lines
drivers/net/idpf/idpf_rxtx.c new file +11 -0
+{
+	uint32_t i, size;
+
+	if (cq == NULL) {
+		PMD_DRV_LOG(DEBUG, "Pointer to complq is NULL");
+		return;
+	}
+
+	size = sizeof(struct idpf_splitq_tx_compl_desc) * cq->nb_tx_desc;
+	for (i = 0; i < size; i++)
+		((volatile char *)cq->compl_ring)[i] = 0;

same ehre

drivers/net/idpf/idpf_rxtx.c line 112

Quoted 7 lines
drivers/net/idpf/idpf_rxtx.c new file +7 -0
+
+	cq->tx_tail = 0;
+	cq->expected_gen_id = 1;
+}
+
+static inline void
+reset_single_tx_queue(struct idpf_tx_queue *txq)

same here

Quoted 4 lines
drivers/net/idpf/idpf_rxtx.c new file +4 -0
+{
+	struct idpf_tx_entry *txe;
+	uint32_t i, size;
+	uint16_t prev;

drivers/net/idpf/idpf_rxtx.c line 126

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c new file +10 -0
+
+	if (txq == NULL) {
+		PMD_DRV_LOG(DEBUG, "Pointer to txq is NULL");
+		return;
+	}
+
+	txe = txq->sw_ring;
+	size = sizeof(struct idpf_flex_tx_desc) * txq->nb_tx_desc;
+	for (i = 0; i < size; i++)
+		((volatile char *)txq->tx_ring)[i] = 0;

same here

Quoted 34 lines
drivers/net/idpf/idpf_rxtx.c new file +34 -0
+
+	prev = (uint16_t)(txq->nb_tx_desc - 1);
+	for (i = 0; i < txq->nb_tx_desc; i++) {
+		txq->tx_ring[i].qw1.cmd_dtype =
+			rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE);
+		txe[i].mbuf =  NULL;
+		txe[i].last_id = i;
+		txe[prev].next_id = i;
+		prev = i;
+	}
+
+	txq->tx_tail = 0;
+	txq->nb_used = 0;
+
+	txq->last_desc_cleaned = txq->nb_tx_desc - 1;
+	txq->nb_free = txq->nb_tx_desc - 1;
+
+	txq->next_dd = txq->rs_thresh - 1;
+	txq->next_rs = txq->rs_thresh - 1;
+}
+
+static int
+idpf_tx_split_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
+			  uint16_t nb_desc, unsigned int socket_id,
+			  const struct rte_eth_txconf *tx_conf)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	uint16_t tx_rs_thresh, tx_free_thresh;
+	struct idpf_hw *hw = &adapter->hw;
+	struct idpf_tx_queue *txq, *cq;
+	const struct rte_memzone *mz;
+	uint32_t ring_size;
+	uint64_t offloads;

drivers/net/idpf/idpf_rxtx.c line 170

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c new file +10 -0
+
+	offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
+
+	if (nb_desc % IDPF_ALIGN_RING_DESC != 0 ||
+	    nb_desc > IDPF_MAX_RING_DESC ||
+	    nb_desc < IDPF_MIN_RING_DESC) {
+		PMD_INIT_LOG(ERR, "Number (%u) of transmit descriptors is invalid",
+			     nb_desc);
+		return -EINVAL;
+	}

You don't need to check it here, since ethdev does it for you before driver operation invocation.

drivers/net/idpf/idpf_rxtx.c

Quoted 2 lines
drivers/net/idpf/idpf_rxtx.c new file +2 -0
+
+	tx_rs_thresh = (uint16_t)((tx_conf->tx_rs_thresh) ?

compare vs 0 explicitly

drivers/net/idpf/idpf_rxtx.c

Quoted 2 lines
drivers/net/idpf/idpf_rxtx.c new file +2 -0
+		tx_conf->tx_rs_thresh : IDPF_DEFAULT_TX_RS_THRESH);
+	tx_free_thresh = (uint16_t)((tx_conf->tx_free_thresh) ?

compare vs 0 explicitly

Quoted 11 lines
drivers/net/idpf/idpf_rxtx.c new file +11 -0
+		tx_conf->tx_free_thresh : IDPF_DEFAULT_TX_FREE_THRESH);
+	if (check_tx_thresh(nb_desc, tx_rs_thresh, tx_free_thresh) != 0)
+		return -EINVAL;
+
+	/* Allocate the TX queue data structure. */
+	txq = rte_zmalloc_socket("idpf split txq",
+				 sizeof(struct idpf_tx_queue),
+				 RTE_CACHE_LINE_SIZE,
+				 socket_id);
+	if (txq == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate memory for tx queue structure");

drivers/net/idpf/idpf_rxtx.c line 195

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c new file +10 -0
+		return -ENOMEM;
+	}
+
+	txq->nb_tx_desc = nb_desc;
+	txq->rs_thresh = tx_rs_thresh;
+	txq->free_thresh = tx_free_thresh;
+	txq->queue_id = vport->chunks_info.tx_start_qid + queue_idx;
+	txq->port_id = dev->data->port_id;
+	txq->offloads = offloads;
+	txq->tx_deferred_start = tx_conf->tx_deferred_start;

Deferred start is not supported at this point and request with deferred start on should be rejected.

Quoted 33 lines
drivers/net/idpf/idpf_rxtx.c new file +33 -0
+
+	/* Allocate software ring */
+	txq->sw_nb_desc = 2 * nb_desc;
+	txq->sw_ring =
+		rte_zmalloc_socket("idpf split tx sw ring",
+				   sizeof(struct idpf_tx_entry) *
+				   txq->sw_nb_desc,
+				   RTE_CACHE_LINE_SIZE,
+				   socket_id);
+	if (txq->sw_ring == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate memory for SW TX ring");
+		rte_free(txq);
+		return -ENOMEM;
+	}
+
+	/* Allocate TX hardware ring descriptors. */
+	ring_size = sizeof(struct idpf_flex_tx_sched_desc) * txq->nb_tx_desc;
+	ring_size = RTE_ALIGN(ring_size, IDPF_DMA_MEM_ALIGN);
+	mz = rte_eth_dma_zone_reserve(dev, "split_tx_ring", queue_idx,
+				      ring_size, IDPF_RING_BASE_ALIGN,
+				      socket_id);
+	if (mz == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for TX");
+		rte_free(txq->sw_ring);
+		rte_free(txq);
+		return -ENOMEM;
+	}
+	txq->tx_ring_phys_addr = mz->iova;
+	txq->desc_ring = (struct idpf_flex_tx_sched_desc *)mz->addr;
+
+	txq->mz = mz;
+	reset_split_tx_descq(txq);
+	txq->qtx_tail = hw->hw_addr + (vport->chunks_info.tx_qtail_start +

drivers/net/idpf/idpf_rxtx.c line 238

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c new file +10 -0
+			queue_idx * vport->chunks_info.tx_qtail_spacing);
+
+	/* Allocate the TX completion queue data structure. */
+	txq->complq = rte_zmalloc_socket("idpf splitq cq",
+					 sizeof(struct idpf_tx_queue),
+					 RTE_CACHE_LINE_SIZE,
+					 socket_id);
+	cq = txq->complq;
+	if (cq == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate memory for tx queue structure");

Free previously allocated resources including txq->complq. However, I'd recomment to use goto style to do cleanup in this case.

Quoted 7 lines
drivers/net/idpf/idpf_rxtx.c new file +7 -0
+		return -ENOMEM;
+	}
+	cq->nb_tx_desc = 2 * nb_desc;
+	cq->queue_id = vport->chunks_info.tx_compl_start_qid + queue_idx;
+	cq->port_id = dev->data->port_id;
+	cq->txqs = dev->data->tx_queues;
+	cq->tx_start_qid = vport->chunks_info.tx_start_qid;

drivers/net/idpf/idpf_rxtx.c line 255

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c new file +10 -0
+
+	ring_size = sizeof(struct idpf_splitq_tx_compl_desc) * cq->nb_tx_desc;
+	ring_size = RTE_ALIGN(ring_size, IDPF_DMA_MEM_ALIGN);
+	mz = rte_eth_dma_zone_reserve(dev, "tx_split_compl_ring", queue_idx,
+				      ring_size, IDPF_RING_BASE_ALIGN,
+				      socket_id);
+	if (mz == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for TX completion queue");
+		rte_free(txq->sw_ring);
+		rte_free(txq);

Free txq->complq and txq->mz

Quoted 26 lines
drivers/net/idpf/idpf_rxtx.c new file +26 -0
+		return -ENOMEM;
+	}
+	cq->tx_ring_phys_addr = mz->iova;
+	cq->compl_ring = (struct idpf_splitq_tx_compl_desc *)mz->addr;
+	cq->mz = mz;
+	reset_split_tx_complq(cq);
+
+	txq->q_set = true;
+	dev->data->tx_queues[queue_idx] = txq;
+
+	return 0;
+}
+
+static int
+idpf_tx_single_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
+			   uint16_t nb_desc, unsigned int socket_id,
+			   const struct rte_eth_txconf *tx_conf)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	uint16_t tx_rs_thresh, tx_free_thresh;
+	struct idpf_hw *hw = &adapter->hw;
+	const struct rte_memzone *mz;
+	struct idpf_tx_queue *txq;
+	uint32_t ring_size;
+	uint64_t offloads;

drivers/net/idpf/idpf_rxtx.c line 291

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c new file +10 -0
+
+	offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
+
+	if (nb_desc % IDPF_ALIGN_RING_DESC != 0 ||
+	    nb_desc > IDPF_MAX_RING_DESC ||
+	    nb_desc < IDPF_MIN_RING_DESC) {
+		PMD_INIT_LOG(ERR, "Number (%u) of transmit descriptors is invalid",
+			     nb_desc);
+		return -EINVAL;
+	}

You don't need to check it here, since ethdev does it for you before driver operation invocation.

Quoted 17 lines
drivers/net/idpf/idpf_rxtx.c new file +17 -0
+
+	tx_rs_thresh = (uint16_t)((tx_conf->tx_rs_thresh) ?
+		tx_conf->tx_rs_thresh : IDPF_DEFAULT_TX_RS_THRESH);
+	tx_free_thresh = (uint16_t)((tx_conf->tx_free_thresh) ?
+		tx_conf->tx_free_thresh : IDPF_DEFAULT_TX_FREE_THRESH);
+	if (check_tx_thresh(nb_desc, tx_rs_thresh, tx_free_thresh) != 0)
+		return -EINVAL;
+
+	/* Allocate the TX queue data structure. */
+	txq = rte_zmalloc_socket("idpf txq",
+				 sizeof(struct idpf_tx_queue),
+				 RTE_CACHE_LINE_SIZE,
+				 socket_id);
+	if (txq == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate memory for tx queue structure");
+		return -ENOMEM;
+	}

drivers/net/idpf/idpf_rxtx.c line 318

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c new file +10 -0
+
+	/* TODO: vlan offload */
+
+	txq->nb_tx_desc = nb_desc;
+	txq->rs_thresh = tx_rs_thresh;
+	txq->free_thresh = tx_free_thresh;
+	txq->queue_id = vport->chunks_info.tx_start_qid + queue_idx;
+	txq->port_id = dev->data->port_id;
+	txq->offloads = offloads;
+	txq->tx_deferred_start = tx_conf->tx_deferred_start;

same here

Quoted 25 lines
drivers/net/idpf/idpf_rxtx.c new file +25 -0
+
+	/* Allocate software ring */
+	txq->sw_ring =
+		rte_zmalloc_socket("idpf tx sw ring",
+				   sizeof(struct idpf_tx_entry) * nb_desc,
+				   RTE_CACHE_LINE_SIZE,
+				   socket_id);
+	if (txq->sw_ring == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate memory for SW TX ring");
+		rte_free(txq);
+		return -ENOMEM;
+	}
+
+	/* Allocate TX hardware ring descriptors. */
+	ring_size = sizeof(struct idpf_flex_tx_desc) * nb_desc;
+	ring_size = RTE_ALIGN(ring_size, IDPF_DMA_MEM_ALIGN);
+	mz = rte_eth_dma_zone_reserve(dev, "tx_ring", queue_idx,
+				      ring_size, IDPF_RING_BASE_ALIGN,
+				      socket_id);
+	if (mz == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for TX");
+		rte_free(txq->sw_ring);
+		rte_free(txq);
+		return -ENOMEM;
+	}

drivers/net/idpf/idpf_rxtx.c line 353

Quoted 10 lines
drivers/net/idpf/idpf_rxtx.c new file +10 -0
+
+	txq->tx_ring_phys_addr = mz->iova;
+	txq->tx_ring = (struct idpf_flex_tx_desc *)mz->addr;
+
+	txq->mz = mz;
+	reset_single_tx_queue(txq);
+	txq->q_set = true;
+	dev->data->tx_queues[queue_idx] = txq;
+	txq->qtx_tail = hw->hw_addr + (vport->chunks_info.tx_qtail_start +
+			queue_idx * vport->chunks_info.tx_qtail_spacing);

I'm sorry, but it looks like too much code is duplicated. I guess it could be a shared function to avoid it.

Quoted 18 lines
drivers/net/idpf/idpf_rxtx.c new file +18 -0
+
+	return 0;
+}
+
+int
+idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
+		    uint16_t nb_desc, unsigned int socket_id,
+		    const struct rte_eth_txconf *tx_conf)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+
+	if (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SINGLE)
+		return idpf_tx_single_queue_setup(dev, queue_idx, nb_desc,
+						  socket_id, tx_conf);
+	else
+		return idpf_tx_split_queue_setup(dev, queue_idx, nb_desc,
+						 socket_id, tx_conf);
+}

[snip]

#250 lore raw

RE: [PATCH v11 03/18] net/idpf: add Tx queue setup

Quoted 28 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Tuesday, October 25, 2022 5:40 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]>
Subject: Re: [PATCH v11 03/18] net/idpf: add Tx queue setup

Quoted 15 lines · Junfeng Guo

Add support for tx_queue_setup ops.

In the single queue model, the same descriptor queue is used by SW to post buffer descriptors to HW and by HW to post completed descriptors to SW.

In the split queue model, "RX buffer queues" are used to pass descriptor buffers from SW to HW while Rx queues are used only to pass the descriptor completions, that is, descriptors that point to completed buffers, from HW to SW. This is contrary to the single queue model in which Rx queues are used for both purposes.

Quoted 6 lines

drivers/net/idpf/idpf_rxtx.c line 73

Quoted 4 lines
drivers/net/idpf/idpf_rxtx.c new file +4 -0
+
+	size = sizeof(struct idpf_flex_tx_sched_desc) * txq->nb_tx_desc;
+	for (i = 0; i < size; i++)
+		((volatile char *)txq->desc_ring)[i] = 0;

Please, add a comment which explains why volatile is required here.

Volatile is used here to make sure the memory write through when touch desc. It follows Intel PMD's coding style.

Quoted 14 lines

drivers/net/idpf/idpf_rxtx.c line 353

Quoted 11 lines
drivers/net/idpf/idpf_rxtx.c new file +10 -0
+
+	txq->tx_ring_phys_addr = mz->iova;
+	txq->tx_ring = (struct idpf_flex_tx_desc *)mz->addr;
+
+	txq->mz = mz;
+	reset_single_tx_queue(txq);
+	txq->q_set = true;
+	dev->data->tx_queues[queue_idx] = txq;
+	txq->qtx_tail = hw->hw_addr + (vport->chunks_info.tx_qtail_start +
+			queue_idx * vport->chunks_info.tx_qtail_spacing);

I'm sorry, but it looks like too much code is duplicated. I guess it could be a shared function to avoid it.

It makes sense to optimize the queue setup, but can we improve it in next release due to the RC2 deadline?
And this part should be common module shared by idpf PMD and a new PMD, It should be in driver/common/idpf folder in DPDK 23.03.

Quoted 20 lines
Quoted 18 lines
drivers/net/idpf/idpf_rxtx.c new file +17 -0
+
+	return 0;
+}
+
+int
+idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
+		    uint16_t nb_desc, unsigned int socket_id,
+		    const struct rte_eth_txconf *tx_conf) {
+	struct idpf_vport *vport = dev->data->dev_private;
+
+	if (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SINGLE)
+		return idpf_tx_single_queue_setup(dev, queue_idx, nb_desc,
+						  socket_id, tx_conf);
+	else
+		return idpf_tx_split_queue_setup(dev, queue_idx, nb_desc,
+						 socket_id, tx_conf);
+}

[snip]

#251 lore raw

PATCH v11 4/18 net/idpf: add Rx queue setup

In reply to Junfeng Guo

Add support for rx_queue_setup ops.

---
 drivers/net/idpf/idpf_ethdev.c |  16 +-
 drivers/net/idpf/idpf_rxtx.c   | 427 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  46 ++++
 3 files changed, 488 insertions(+), 1 deletion(-)
drivers/net/idpf/idpf_ethdev.c +15 -1
index c0307128be..1d2075f466 100644
@@ -37,6 +37,7 @@ static void idpf_adapter_rel(struct idpf_adapter *adapter);
 static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.dev_configure			= idpf_dev_configure,
 	.dev_close			= idpf_dev_close,
+	.rx_queue_setup			= idpf_rx_queue_setup,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
 };
@@ -56,16 +57,29 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	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_TX_QUEUE_SETUP;
+	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 = 0;
 	dev_info->tx_offload_capa = 0;
 
+	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,
drivers/net/idpf/idpf_rxtx.c +427 -0

445 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +46 -0

63 lines not on this page · raw message

Signature · 1 line
2.34.1
#252 lore raw

PATCH v11 5/18 net/idpf: add support for device start and stop

In reply to Junfeng Guo

Add dev ops dev_start, dev_stop and link_update.

---
 drivers/net/idpf/idpf_ethdev.c | 89 ++++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h |  5 ++
 2 files changed, 94 insertions(+)
drivers/net/idpf/idpf_ethdev.c +89 -0
index 1d2075f466..4c7a2d0748 100644
@@ -29,17 +29,42 @@ static const char * const idpf_valid_args[] = {
 };
 
 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 void idpf_adapter_rel(struct idpf_adapter *adapter);
 
+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_configure			= idpf_dev_configure,
+	.dev_start			= idpf_dev_start,
+	.dev_stop			= idpf_dev_stop,
 	.dev_close			= idpf_dev_close,
 	.rx_queue_setup			= idpf_rx_queue_setup,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
+	.link_update			= idpf_dev_link_update,
 };
 
 static int
@@ -233,6 +258,70 @@ idpf_dev_configure(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 == NULL || txq->tx_deferred_start)
+			continue;
+
+		PMD_DRV_LOG(ERR, "Start Tx queues not supported yet");
+		return -ENOTSUP;
+	}
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		rxq = dev->data->rx_queues[i];
+		if (rxq == NULL || rxq->rx_deferred_start)
+			continue;
+
+		PMD_DRV_LOG(ERR, "Start Rx queues not supported yet");
+		return -ENOTSUP;
+	}
+
+	return err;
+}
+
+static int
+idpf_dev_start(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+
+	if (dev->data->mtu > vport->max_mtu) {
+		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
+		return -1;
+	}
+
+	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
+
+	if (idpf_start_queues(dev) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to start queues");
+		return -1;
+	}
+
+	if (idpf_vc_ena_dis_vport(vport, true) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to enable vport");
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+idpf_dev_stop(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+
+	idpf_vc_ena_dis_vport(vport, false);
+
+	return 0;
+}
+
 static int
 idpf_dev_close(struct rte_eth_dev *dev)
 {
drivers/net/idpf/idpf_ethdev.h +5 -0
index c0ae801fd5..070531cc48 100644
@@ -105,6 +105,9 @@ struct idpf_vport {
 	/* Chunk info */
 	struct idpf_chunks_info chunks_info;
 
+	/* Event from ipf */
+	bool link_up;
+
 	uint16_t devarg_id;
 };
 
@@ -195,6 +198,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_vc_check_api_version(struct idpf_adapter *adapter);
 int idpf_vc_get_caps(struct idpf_adapter *adapter);
Signature · 1 line
2.34.1
#253 lore raw

Re: [PATCH v11 05/18] net/idpf: add support for device start and stop

Quoted 18 lines · Junfeng Guo

Add dev ops dev_start, dev_stop and link_update.

---
  drivers/net/idpf/idpf_ethdev.c | 89 ++++++++++++++++++++++++++++++++++
  drivers/net/idpf/idpf_ethdev.h |  5 ++
  2 files changed, 94 insertions(+)
drivers/net/idpf/idpf_ethdev.c +0 -0
index 1d2075f466..4c7a2d0748 100644
@@ -29,17 +29,42 @@ static const char * const idpf_valid_args[] = {
  };
 
  static int idpf_dev_configure(struct rte_eth_dev *dev);

drivers/net/idpf/idpf_ethdev.c static const char * const idpf_valid_args[] = { · line 41

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +5 -0
+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 void idpf_adapter_rel(struct idpf_adapter *adapter);
 
+int
+idpf_dev_link_update(struct rte_eth_dev *dev,
+		     __rte_unused int wait_to_complete)

Why is it global? IMHO it should be static now and should be made global later if you really need it.

Quoted 71 lines
drivers/net/idpf/idpf_ethdev.c +58 -0
+{
+	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_configure			= idpf_dev_configure,
+	.dev_start			= idpf_dev_start,
+	.dev_stop			= idpf_dev_stop,
  	.dev_close			= idpf_dev_close,
  	.rx_queue_setup			= idpf_rx_queue_setup,
  	.tx_queue_setup			= idpf_tx_queue_setup,
  	.dev_infos_get			= idpf_dev_info_get,
+	.link_update			= idpf_dev_link_update,
  };
 
  static int
@@ -233,6 +258,70 @@ idpf_dev_configure(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 == NULL || txq->tx_deferred_start)
+			continue;
+
+		PMD_DRV_LOG(ERR, "Start Tx queues not supported yet");
+		return -ENOTSUP;
+	}
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		rxq = dev->data->rx_queues[i];
+		if (rxq == NULL || rxq->rx_deferred_start)
+			continue;
+
+		PMD_DRV_LOG(ERR, "Start Rx queues not supported yet");
+		return -ENOTSUP;
+	}
+
+	return err;
+}
+
+static int
+idpf_dev_start(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+
+	if (dev->data->mtu > vport->max_mtu) {
+		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
+		return -1;
+	}

drivers/net/idpf/idpf_ethdev.c idpf_dev_configure(struct rte_eth_dev *dev) · line 308

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +10 -0
+
+	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
+
+	if (idpf_start_queues(dev) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to start queues");
+		return -1;
+	}
+
+	if (idpf_vc_ena_dis_vport(vport, true) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to enable vport");

Don't you need to stop queues here?

drivers/net/idpf/idpf_ethdev.c idpf_dev_configure(struct rte_eth_dev *dev) · line 318

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +10 -0
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+idpf_dev_stop(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;

Stop queues?

Quoted 14 lines
drivers/net/idpf/idpf_ethdev.c +6 -0
+
+	idpf_vc_ena_dis_vport(vport, false);
+
+	return 0;
+}
+
  static int
  idpf_dev_close(struct rte_eth_dev *dev)
  {
drivers/net/idpf/idpf_ethdev.h +0 -0
index c0ae801fd5..070531cc48 100644

drivers/net/idpf/idpf_ethdev.h struct idpf_vport { · line 110

Quoted 6 lines
drivers/net/idpf/idpf_ethdev.h +3 -0
@@ -105,6 +105,9 @@ struct idpf_vport {
  	/* Chunk info */
  	struct idpf_chunks_info chunks_info;
 
+	/* Event from ipf */
+	bool link_up;
+

It is a dead code. Since it is read, but never written in the patch.

Quoted 12 lines
drivers/net/idpf/idpf_ethdev.h +2 -0
  	uint16_t devarg_id;
  };
 
@@ -195,6 +198,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_vc_check_api_version(struct idpf_adapter *adapter);
  int idpf_vc_get_caps(struct idpf_adapter *adapter);
#254 lore raw

RE: [PATCH v11 05/18] net/idpf: add support for device start and stop

Quoted 71 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Tuesday, October 25, 2022 5:50 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]>
Subject: Re: [PATCH v11 05/18] net/idpf: add support for device start and stop

Quoted 7 lines · Junfeng Guo

Add dev ops dev_start, dev_stop and link_update.

---
  drivers/net/idpf/idpf_ethdev.c | 89

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

Quoted 50 lines
  drivers/net/idpf/idpf_ethdev.h |  5 ++
  2 files changed, 94 insertions(+)
(quoted diff) +0 -0

b/drivers/net/idpf/idpf_ethdev.c index 1d2075f466..4c7a2d0748 100644

drivers/net/idpf/idpf_ethdev.c +40 -0
@@ -29,17 +29,42 @@ static const char * const idpf_valid_args[] = {
  };
+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 == NULL || txq->tx_deferred_start)
+			continue;
+
+		PMD_DRV_LOG(ERR, "Start Tx queues not supported yet");
+		return -ENOTSUP;
+	}
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		rxq = dev->data->rx_queues[i];
+		if (rxq == NULL || rxq->rx_deferred_start)
+			continue;
+
+		PMD_DRV_LOG(ERR, "Start Rx queues not supported yet");
+		return -ENOTSUP;
+	}
+
+	return err;
+}
+
+static int
+idpf_dev_start(struct rte_eth_dev *dev) {
+	struct idpf_vport *vport = dev->data->dev_private;
+
+	if (dev->data->mtu > vport->max_mtu) {
+		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport-
 max_mtu);
+		return -1;
+	}
+
+	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
+
+	if (idpf_start_queues(dev) != 0) {
Quoted 8 lines

drivers/net/idpf/idpf_ethdev.c idpf_dev_configure(struct rte_eth_dev *dev) · line 308

Quoted 6 lines
drivers/net/idpf/idpf_ethdev.c +6 -0
+		PMD_DRV_LOG(ERR, "Failed to start queues");
+		return -1;
+	}
+
+	if (idpf_vc_ena_dis_vport(vport, true) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to enable vport");

Don't you need to stop queues here?

In this patch, we didn't implement start HW queues, so I will remove start queues here And add start_queues/stop_queues once the APIs are finished.

Quoted 12 lines

drivers/net/idpf/idpf_ethdev.c idpf_dev_configure(struct rte_eth_dev *dev) · line 318

Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +9 -0
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+idpf_dev_stop(struct rte_eth_dev *dev) {
+	struct idpf_vport *vport = dev->data->dev_private;

Stop queues?

Same.

Quoted 10 lines
Quoted 10 lines
drivers/net/idpf/idpf_ethdev.c +6 -0
+
+	idpf_vc_ena_dis_vport(vport, false);
+
+	return 0;
+}
+
  static int
  idpf_dev_close(struct rte_eth_dev *dev)
  {
#255 lore raw

PATCH v11 6/18 net/idpf: add support for queue start

In reply to Junfeng Guo

Add support for these device ops:
- rx_queue_start
- tx_queue_start

---
 drivers/net/idpf/idpf_ethdev.c |  18 +-
 drivers/net/idpf/idpf_ethdev.h |   7 +
 drivers/net/idpf/idpf_rxtx.c   | 214 ++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |   4 +
 drivers/net/idpf/idpf_vchnl.c  | 447 +++++++++++++++++++++++++++++++++
 5 files changed, 684 insertions(+), 6 deletions(-)
drivers/net/idpf/idpf_ethdev.c +12 -6
index 4c7a2d0748..954bd0bf4b 100644
@@ -61,6 +61,8 @@ 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,
+	.tx_queue_start			= idpf_tx_queue_start,
 	.rx_queue_setup			= idpf_rx_queue_setup,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
@@ -270,18 +272,22 @@ idpf_start_queues(struct rte_eth_dev *dev)
 		txq = dev->data->tx_queues[i];
 		if (txq == NULL || txq->tx_deferred_start)
 			continue;
-
-		PMD_DRV_LOG(ERR, "Start Tx queues not supported yet");
-		return -ENOTSUP;
+		err = idpf_tx_queue_start(dev, i);
+		if (err != 0) {
+			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 == NULL || rxq->rx_deferred_start)
 			continue;
-
-		PMD_DRV_LOG(ERR, "Start Rx queues not supported yet");
-		return -ENOTSUP;
+		err = idpf_rx_queue_start(dev, i);
+		if (err != 0) {
+			PMD_DRV_LOG(ERR, "Fail to start Rx queue %u", i);
+			return err;
+		}
 	}
 
 	return err;
drivers/net/idpf/idpf_ethdev.h +7 -0
index 070531cc48..094f123be1 100644
@@ -205,6 +205,13 @@ int idpf_vc_check_api_version(struct idpf_adapter *adapter);
 int idpf_vc_get_caps(struct idpf_adapter *adapter);
 int idpf_vc_create_vport(struct idpf_adapter *adapter);
 int idpf_vc_destroy_vport(struct idpf_vport *vport);
+int idpf_vc_config_rxqs(struct idpf_vport *vport);
+int idpf_vc_config_rxq(struct idpf_vport *vport, uint16_t rxq_id);
+int idpf_vc_config_txqs(struct idpf_vport *vport);
+int idpf_vc_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_vc_ena_dis_queues(struct idpf_vport *vport, bool enable);
 int idpf_vc_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 +214 -0

217 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +4 -0
index a79e9a0b26..d076903e3c 100644
@@ -115,8 +115,12 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_rxconf *rx_conf,
 			struct rte_mempool *mp);
+int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
+int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
+int idpf_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 
 #endif /* _IDPF_RXTX_H_ */
drivers/net/idpf/idpf_vchnl.c +447 -0

465 lines not on this page · raw message

Signature · 1 line
2.34.1
#256 lore raw

PATCH v11 7/18 net/idpf: add support for queue stop

In reply to Junfeng Guo

Add support for these device ops:
- rx_queue_stop
- tx_queue_stop

---
 doc/guides/nics/features/idpf.ini |   1 +
 drivers/net/idpf/idpf_ethdev.c    |  14 ++-
 drivers/net/idpf/idpf_rxtx.c      | 140 ++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h      |  11 +++
 drivers/net/idpf/idpf_vchnl.c     |  69 +++++++++++++++
 5 files changed, 232 insertions(+), 3 deletions(-)
doc/guides/nics/features/idpf.ini +1 -0
index 7a44b8b5e4..30e1c0831e 100644
@@ -7,4 +7,5 @@
 ; is selected.
 ;
 [Features]
+Queue start/stop     = Y
 Linux                = Y
drivers/net/idpf/idpf_ethdev.c +11 -3
index 954bd0bf4b..6040050dd9 100644
@@ -62,7 +62,9 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.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,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.dev_infos_get			= idpf_dev_info_get,
@@ -300,22 +302,26 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	if (dev->data->mtu > vport->max_mtu) {
 		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
-		return -1;
+		goto err_mtu;
 	}
 
 	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
 
 	if (idpf_start_queues(dev) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
-		return -1;
+		goto err_mtu;
 	}
 
 	if (idpf_vc_ena_dis_vport(vport, true) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
-		return -1;
+		goto err_vport;
 	}
 
 	return 0;
+err_vport:
+	idpf_stop_queues(dev);
+err_mtu:
+	return -1;
 }
 
 static int
@@ -325,6 +331,8 @@ idpf_dev_stop(struct rte_eth_dev *dev)
 
 	idpf_vc_ena_dis_vport(vport, false);
 
+	idpf_stop_queues(dev);
+
 	return 0;
 }
 
drivers/net/idpf/idpf_rxtx.c +140 -0

173 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +11 -0
index d076903e3c..e1de436a4a 100644
@@ -111,16 +111,27 @@ struct idpf_tx_queue {
 	struct idpf_tx_queue *complq;
 };
 
+struct idpf_rxq_ops {
+	void (*release_mbufs)(struct idpf_rx_queue *rxq);
+};
+
+struct idpf_txq_ops {
+	void (*release_mbufs)(struct idpf_tx_queue *txq);
+};
+
 int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_rxconf *rx_conf,
 			struct rte_mempool *mp);
 int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int idpf_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
 int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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_stop_queues(struct rte_eth_dev *dev);
 #endif /* _IDPF_RXTX_H_ */
drivers/net/idpf/idpf_vchnl.c +69 -0

75 lines not on this page · raw message

Signature · 1 line
2.34.1
#257 lore raw

PATCH v11 8/18 net/idpf: add queue release

In reply to Junfeng Guo

Add support for queue operations:
- rx_queue_release
- tx_queue_release

---
 drivers/net/idpf/idpf_ethdev.c |  2 +
 drivers/net/idpf/idpf_rxtx.c   | 81 ++++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  3 ++
 3 files changed, 86 insertions(+)
drivers/net/idpf/idpf_ethdev.c +2 -0
index 6040050dd9..4c058660b4 100644
@@ -66,7 +66,9 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.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,
 	.dev_infos_get			= idpf_dev_info_get,
 	.link_update			= idpf_dev_link_update,
 };
drivers/net/idpf/idpf_rxtx.c +81 -0

117 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +3 -0
index e1de436a4a..9f767079b2 100644
@@ -126,12 +126,15 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 int idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int idpf_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+void idpf_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
+
 int idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			uint16_t nb_desc, unsigned int socket_id,
 			const struct rte_eth_txconf *tx_conf);
 int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 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);
 
 void idpf_stop_queues(struct rte_eth_dev *dev);
 #endif /* _IDPF_RXTX_H_ */
Signature · 1 line
2.34.1