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

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

PATCH v5 2/14 net/idpf: add support for device initialization

In reply to Junfeng Guo

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

---
 MAINTAINERS                            |   9 +
 doc/guides/nics/features/idpf.ini      |  15 +
 doc/guides/nics/idpf.rst               |  52 ++
 doc/guides/nics/index.rst              |   1 +
 doc/guides/rel_notes/release_22_11.rst |   5 +
 drivers/net/idpf/idpf_ethdev.c         | 774 +++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h         | 204 +++++++
 drivers/net/idpf/idpf_logs.h           |  42 ++
 drivers/net/idpf/idpf_vchnl.c          | 495 ++++++++++++++++
 drivers/net/idpf/meson.build           |  16 +
 drivers/net/idpf/version.map           |   3 +
 drivers/net/meson.build                |   1 +
 12 files changed, 1617 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 2bd4a55f1b..e2d9c2ac50 100644
@@ -758,6 +758,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 +15 -0
new file mode 100644
index 0000000000..f029a279b3
@@ -0,0 +1,15 @@
+;
+; 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]
+Multiprocess aware   = Y
+FreeBSD              = Y
+Linux                = Y
+Windows              = Y
+x86-32               = Y
+x86-64               = Y
doc/guides/nics/idpf.rst new file +52 -0

52 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 +5 -0
index 2da8bc9661..6697b61848 100644
@@ -236,6 +236,11 @@ New Features
 
      strings $dpdk_binary_or_driver | sed -n 's/^PMD_INFO_STRING= //p'
 
+* **Added IDPF PMD [*EXPERIMENTAL*].**
+
+  Added the new ``idpf`` net driver for Intel® IPU Ethernet ES2000 Series.
+  See the :doc:`../nics/idpf` NIC guide for more details on this new driver.
+
 
 Removed Items
 -------------
drivers/net/idpf/idpf_ethdev.c new file +774 -0

774 lines not on this page · raw message

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

204 lines not on this page · raw message

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

42 lines not on this page · raw message

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

495 lines not on this page · raw message

drivers/net/idpf/meson.build new file +16 -0
new file mode 100644
index 0000000000..bf8bf58ef5
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
+includes += include_directories('../../common/idpf')
+deps += ['common_idpf', 'security', 'cryptodev']
+
+sources = files(
+    'idpf_ethdev.c',
+    'idpf_vchnl.c',
+)
drivers/net/idpf/version.map new file +3 -0
new file mode 100644
index 0000000000..c2e0723b4c
@@ -0,0 +1,3 @@
+DPDK_22 {
+	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
#337 lore raw

PATCH v5 3/14 net/idpf: add queue setup and release in single queue model

In reply to Junfeng Guo

Add support for queue operations in single queue model:
- rx_queue_setup
- rx_queue_release
- tx_queue_setup
- tx_queue_release

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.

---
 doc/guides/nics/features/idpf.ini |   2 +
 doc/guides/nics/idpf.rst          |  22 ++
 drivers/net/idpf/idpf_ethdev.c    |  58 ++++
 drivers/net/idpf/idpf_ethdev.h    |   9 +
 drivers/net/idpf/idpf_rxtx.c      | 465 ++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h      | 186 ++++++++++++
 drivers/net/idpf/idpf_vchnl.c     | 249 ++++++++++++++++
 drivers/net/idpf/meson.build      |   1 +
 8 files changed, 992 insertions(+)
 create mode 100644 drivers/net/idpf/idpf_rxtx.c
 create mode 100644 drivers/net/idpf/idpf_rxtx.h
doc/guides/nics/features/idpf.ini +2 -0
index f029a279b3..681a908194 100644
@@ -7,6 +7,8 @@
 ; is selected.
 ;
 [Features]
+Runtime Rx queue setup = Y
+Runtime Tx queue setup = Y
 Multiprocess aware   = Y
 FreeBSD              = Y
 Linux                = Y
doc/guides/nics/idpf.rst +22 -0
index cc56db6e70..84b21e7be0 100644
@@ -45,6 +45,28 @@ Runtime Config Options
   Then idpf PMD will create 3 vports (ethdevs) for device ca:00.0.
   NOTE: This parameter is MUST, otherwise there'll be no any ethdev created.
 
+- ``rx_single`` (default ``0``)
+
+  There're two queue modes supported by Intel® IPU Ethernet ES2000 Series, single queue
+  mode and split queue mode for Rx queue. User can choose Rx queue mode by the ``devargs``
+  parameter ``rx_single``.
+
+    -a ca:00.0,rx_single=1
+
+  Then idpf PMD will configure Rx queue with single queue mode. Otherwise, split queue
+  mode is chosen by default.
+
+- ``tx_single`` (default ``0``)
+
+  There're two queue modes supported by Intel® IPU Ethernet ES2000 Series, single queue
+  mode and split queue mode for Tx queue. User can choose Tx queue mode by the ``devargs``
+  parameter ``tx_single``.
+
+    -a ca:00.0,tx_single=1
+
+  Then idpf PMD will configure Tx queue with single queue mode. Otherwise, split queue
+  mode is chosen by default.
+
 Driver compilation and testing
 ------------------------------
 
drivers/net/idpf/idpf_ethdev.c +58 -0

107 lines not on this page · raw message

drivers/net/idpf/idpf_ethdev.h +9 -0
index 77824d5f7f..8b7170f49e 100644
@@ -83,6 +83,8 @@ struct idpf_chunks_info {
 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;
 	uint16_t num_rx_q;
 
@@ -118,6 +120,9 @@ struct idpf_adapter {
 	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;
+	uint32_t rxq_model;
+
 	/* Vport info */
 	uint8_t **vport_req_info;
 	uint8_t **vport_recv_info;
@@ -197,6 +202,10 @@ 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 rte_eth_dev *dev);
 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_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 new file +465 -0

465 lines not on this page · raw message

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

186 lines not on this page · raw message

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

261 lines not on this page · raw message

drivers/net/idpf/meson.build +1 -0
index bf8bf58ef5..832f887296 100644
@@ -12,5 +12,6 @@ deps += ['common_idpf', 'security', 'cryptodev']
 
 sources = files(
     'idpf_ethdev.c',
+    'idpf_rxtx.c',
     'idpf_vchnl.c',
 )
Signature · 1 line
2.34.1
#338 lore raw

PATCH v5 4/14 net/idpf: add queue setup and release in split queue model

In reply to Junfeng Guo

Add support for queue operations in split queue model:
- rx_queue_setup
- rx_queue_release
- tx_queue_setup
- tx_queue_release

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 |  34 ++-
 drivers/net/idpf/idpf_ethdev.h |  11 +
 drivers/net/idpf/idpf_rxtx.c   | 483 ++++++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_vchnl.c  | 127 ++++++++-
 4 files changed, 642 insertions(+), 13 deletions(-)
drivers/net/idpf/idpf_ethdev.c +32 -2
index 96af54f47b..f9717cd5ff 100644
@@ -90,13 +90,25 @@ idpf_init_vport_req_info(struct rte_eth_dev *dev)
 		(struct virtchnl2_create_vport *)adapter->vport_req_info[idx];
 
 	vport_info->vport_type = rte_cpu_to_le_16(VIRTCHNL2_VPORT_TYPE_DEFAULT);
-	if (adapter->txq_model) {
+	if (!adapter->txq_model) {
+		vport_info->txq_model =
+			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SPLIT);
+		vport_info->num_tx_q = IDPF_DEFAULT_TXQ_NUM;
+		vport_info->num_tx_complq =
+			IDPF_DEFAULT_TXQ_NUM * IDPF_TX_COMPLQ_PER_GRP;
+	} else {
 		vport_info->txq_model =
 			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SINGLE);
 		vport_info->num_tx_q = IDPF_DEFAULT_TXQ_NUM;
 		vport_info->num_tx_complq = 0;
 	}
-	if (adapter->rxq_model) {
+	if (!adapter->rxq_model) {
+		vport_info->rxq_model =
+			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SPLIT);
+		vport_info->num_rx_q = IDPF_DEFAULT_RXQ_NUM;
+		vport_info->num_rx_bufq =
+			IDPF_DEFAULT_RXQ_NUM * IDPF_RX_BUFQ_PER_GRP;
+	} else {
 		vport_info->rxq_model =
 			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SINGLE);
 		vport_info->num_rx_q = IDPF_DEFAULT_RXQ_NUM;
@@ -134,7 +146,9 @@ idpf_init_vport(struct rte_eth_dev *dev)
 	vport->txq_model = vport_info->txq_model;
 	vport->rxq_model = vport_info->rxq_model;
 	vport->num_tx_q = vport_info->num_tx_q;
+	vport->num_tx_complq = vport_info->num_tx_complq;
 	vport->num_rx_q = vport_info->num_rx_q;
+	vport->num_rx_bufq = vport_info->num_rx_bufq;
 	vport->max_mtu = vport_info->max_mtu;
 	rte_memcpy(vport->default_mac_addr,
 		   vport_info->default_mac_addr, ETH_ALEN);
@@ -157,6 +171,22 @@ idpf_init_vport(struct rte_eth_dev *dev)
 				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;
 		}
 	}
 
drivers/net/idpf/idpf_ethdev.h +11 -0
index 8b7170f49e..270ab7b6de 100644
@@ -73,11 +73,18 @@ enum idpf_vc_result {
 struct idpf_chunks_info {
 	uint32_t tx_start_qid;
 	uint32_t rx_start_qid;
+	/* Valid only if split queue model */
+	uint32_t tx_compl_start_qid;
+	uint32_t rx_buf_start_qid;
 
 	uint64_t tx_qtail_start;
 	uint32_t tx_qtail_spacing;
 	uint64_t rx_qtail_start;
 	uint32_t rx_qtail_spacing;
+	uint64_t tx_compl_qtail_start;
+	uint32_t tx_compl_qtail_spacing;
+	uint64_t rx_buf_qtail_start;
+	uint32_t rx_buf_qtail_spacing;
 };
 
 struct idpf_vport {
@@ -86,7 +93,11 @@ struct idpf_vport {
 	uint32_t txq_model;
 	uint32_t rxq_model;
 	uint16_t num_tx_q;
+	/* valid only if txq_model is split Q */
+	uint16_t num_tx_complq;
 	uint16_t num_rx_q;
+	/* valid only if rxq_model is split Q */
+	uint16_t num_rx_bufq;
 
 	uint16_t max_mtu;
 	uint8_t default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
drivers/net/idpf/idpf_rxtx.c +480 -3

525 lines not on this page · raw message

drivers/net/idpf/idpf_vchnl.c +119 -8

171 lines not on this page · raw message

Signature · 1 line
2.34.1
#339 lore raw

PATCH v5 5/14 net/idpf: add support for queue start and stop

In reply to Junfeng Guo

Add support for queue operations:
- rx_queue_start
- rx_queue_stop
- tx_queue_start
- tx_queue_stop

---
 doc/guides/nics/features/idpf.ini |   1 +
 drivers/net/idpf/idpf_ethdev.c    |  46 +++++
 drivers/net/idpf/idpf_ethdev.h    |   3 +
 drivers/net/idpf/idpf_rxtx.c      | 309 ++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h      |   6 +
 drivers/net/idpf/idpf_vchnl.c     | 150 +++++++++++++++
 6 files changed, 515 insertions(+)
doc/guides/nics/features/idpf.ini +1 -0
index 681a908194..597beec5d9 100644
@@ -7,6 +7,7 @@
 ; is selected.
 ;
 [Features]
+Queue start/stop     = Y
 Runtime Rx queue setup = Y
 Runtime Tx queue setup = Y
 Multiprocess aware   = Y
drivers/net/idpf/idpf_ethdev.c +46 -0

76 lines not on this page · raw message

drivers/net/idpf/idpf_ethdev.h +3 -0
index 270ab7b6de..b625868ceb 100644
@@ -217,6 +217,9 @@ 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 +309 -0

318 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +6 -0
index 69a1fa6348..f0427b96c5 100644
@@ -175,12 +175,18 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			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);
 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_ */
drivers/net/idpf/idpf_vchnl.c +150 -0

156 lines not on this page · raw message

Signature · 1 line
2.34.1
#340 lore raw

PATCH v5 6/14 net/idpf: add support for device information get

In reply to Junfeng Guo

Add dev ops dev_infos_get.

---
 drivers/net/idpf/idpf_ethdev.c | 50 ++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
drivers/net/idpf/idpf_ethdev.c +50 -0
index c25f222c5e..d1b6797d4a 100644
@@ -30,6 +30,8 @@ static int idpf_dev_configure(struct rte_eth_dev *dev);
 static int idpf_dev_start(struct rte_eth_dev *dev);
 static int idpf_dev_stop(struct rte_eth_dev *dev);
 static int idpf_dev_close(struct rte_eth_dev *dev);
+static int idpf_dev_info_get(struct rte_eth_dev *dev,
+			     struct rte_eth_dev_info *dev_info);
 static void idpf_adapter_rel(struct idpf_adapter *adapter);
 
 int
@@ -65,9 +67,57 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.rx_queue_release		= idpf_dev_rx_queue_release,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.tx_queue_release		= idpf_dev_tx_queue_release,
+	.dev_infos_get			= idpf_dev_info_get,
 	.link_update			= idpf_dev_link_update,
 };
 
+static int
+idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+
+	dev_info->max_rx_queues = adapter->caps->max_rx_q;
+	dev_info->max_tx_queues = adapter->caps->max_tx_q;
+	dev_info->min_rx_bufsize = IDPF_MIN_BUF_SIZE;
+	dev_info->max_rx_pktlen = IDPF_MAX_FRAME_SIZE;
+
+	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
+	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
+		RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
+
+	dev_info->default_rxconf = (struct rte_eth_rxconf) {
+		.rx_free_thresh = IDPF_DEFAULT_RX_FREE_THRESH,
+		.rx_drop_en = 0,
+		.offloads = 0,
+	};
+
+	dev_info->default_txconf = (struct rte_eth_txconf) {
+		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
+		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
+		.offloads = 0,
+	};
+
+	dev_info->rx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = IDPF_MAX_RING_DESC,
+		.nb_min = IDPF_MIN_RING_DESC,
+		.nb_align = IDPF_ALIGN_RING_DESC,
+	};
+
+	dev_info->tx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = IDPF_MAX_RING_DESC,
+		.nb_min = IDPF_MIN_RING_DESC,
+		.nb_align = IDPF_ALIGN_RING_DESC,
+	};
+
+	dev_info->default_rxportconf.burst_size = IDPF_RX_MAX_BURST;
+	dev_info->default_txportconf.burst_size = IDPF_TX_MAX_BURST;
+	dev_info->default_rxportconf.nb_queues = 1;
+	dev_info->default_txportconf.nb_queues = 1;
+
+	return 0;
+}
+
 static int
 idpf_init_vport_req_info(struct rte_eth_dev *dev)
 {
Signature · 1 line
2.34.1
#341 lore raw

PATCH v5 7/14 net/idpf: add support for packet type get

In reply to Junfeng Guo

Add dev ops dev_supported_ptypes_get.

---
 doc/guides/nics/features/idpf.ini |   1 +
 drivers/net/idpf/idpf_ethdev.c    |   7 +
 drivers/net/idpf/idpf_ethdev.h    |   2 +
 drivers/net/idpf/idpf_rxtx.c      |  19 +++
 drivers/net/idpf/idpf_rxtx.h      |   6 +
 drivers/net/idpf/idpf_vchnl.c     | 235 ++++++++++++++++++++++++++++++
 6 files changed, 270 insertions(+)
doc/guides/nics/features/idpf.ini +1 -0
index 597beec5d9..79ffafc0d4 100644
@@ -10,6 +10,7 @@
 Queue start/stop     = Y
 Runtime Rx queue setup = Y
 Runtime Tx queue setup = Y
+Packet type parsing  = Y
 Multiprocess aware   = Y
 FreeBSD              = Y
 Linux                = Y
drivers/net/idpf/idpf_ethdev.c +7 -0
index d1b6797d4a..20f0f39640 100644
@@ -55,6 +55,7 @@ idpf_dev_link_update(struct rte_eth_dev *dev,
 }
 
 static const struct eth_dev_ops idpf_eth_dev_ops = {
+	.dev_supported_ptypes_get	= idpf_dev_supported_ptypes_get,
 	.dev_configure			= idpf_dev_configure,
 	.dev_start			= idpf_dev_start,
 	.dev_stop			= idpf_dev_stop,
@@ -652,6 +653,12 @@ idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
 		goto err_api;
 	}
 
+	ret = idpf_get_pkt_type(adapter);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to set ptype table");
+		goto err_api;
+	}
+
 	adapter->caps = rte_zmalloc("idpf_caps",
 				sizeof(struct virtchnl2_get_capabilities), 0);
 	if (!adapter->caps) {
drivers/net/idpf/idpf_ethdev.h +2 -0
index b625868ceb..863d163330 100644
@@ -210,6 +210,7 @@ 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_get_pkt_type(struct idpf_adapter *adapter);
 int idpf_vc_get_caps(struct idpf_adapter *adapter);
 int idpf_vc_create_vport(struct rte_eth_dev *dev);
 int idpf_vc_destroy_vport(struct idpf_vport *vport);
@@ -221,6 +222,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 +19 -0
index 95193713c4..e92ea09c3b 100644
@@ -8,6 +8,25 @@
 #include "idpf_ethdev.h"
 #include "idpf_rxtx.h"
 
+const uint32_t *
+idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)
+{
+	static const uint32_t ptypes[] = {
+		RTE_PTYPE_L2_ETHER,
+		RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
+		RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
+		RTE_PTYPE_L4_FRAG,
+		RTE_PTYPE_L4_NONFRAG,
+		RTE_PTYPE_L4_UDP,
+		RTE_PTYPE_L4_TCP,
+		RTE_PTYPE_L4_SCTP,
+		RTE_PTYPE_L4_ICMP,
+		RTE_PTYPE_UNKNOWN
+	};
+
+	return ptypes;
+}
+
 static inline int
 check_rx_thresh(uint16_t nb_desc, uint16_t thresh)
 {
drivers/net/idpf/idpf_rxtx.h +6 -0
index f0427b96c5..cd1dda4688 100644
@@ -47,6 +47,10 @@
 #define IDPF_TX_OFFLOAD_NOTSUP_MASK \
 		(RTE_MBUF_F_TX_OFFLOAD_MASK ^ IDPF_TX_OFFLOAD_MASK)
 
+#define IDPF_GET_PTYPE_SIZE(p) \
+	(sizeof(struct virtchnl2_ptype) + \
+	(((p)->proto_id_count ? ((p)->proto_id_count - 1) : 0) * sizeof((p)->proto_id[0])))
+
 struct idpf_rx_queue {
 	struct idpf_adapter *adapter;	/* the adapter this queue belongs to */
 	struct rte_mempool *mp;		/* mbuf pool to populate Rx ring */
@@ -189,4 +193,6 @@ void idpf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 
 void idpf_stop_queues(struct rte_eth_dev *dev);
 
+const uint32_t *idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev);
+
 #endif /* _IDPF_RXTX_H_ */
drivers/net/idpf/idpf_vchnl.c +235 -0

244 lines not on this page · raw message

Signature · 1 line
2.34.1
#342 lore raw

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

In reply to Junfeng Guo

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

---
 drivers/net/idpf/idpf_ethdev.c |   8 +-
 drivers/net/idpf/idpf_rxtx.c   | 667 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  16 +-
 3 files changed, 687 insertions(+), 4 deletions(-)
drivers/net/idpf/idpf_ethdev.c +7 -1
index 20f0f39640..c6d6c87274 100644
@@ -313,6 +313,9 @@ idpf_dev_start(struct rte_eth_dev *dev)
 		goto err_mtu;
 	}
 
+	idpf_set_rx_function(dev);
+	idpf_set_tx_function(dev);
+
 	if (idpf_vc_ena_dis_vport(vport, true)) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
 		goto err_vport;
@@ -764,8 +767,11 @@ idpf_dev_init(struct rte_eth_dev *dev, void *init_params)
 	/* for secondary processes, we don't initialise any further as primary
 	 * has already done this work.
 	 */
-	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		idpf_set_rx_function(dev);
+		idpf_set_tx_function(dev);
 		return ret;
+	}
 
 	dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
 
drivers/net/idpf/idpf_rxtx.c +667 -0

670 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +13 -3
index cd1dda4688..bd3ebe2f50 100644
@@ -44,9 +44,6 @@
 #define IDPF_MAX_TSO_FRAME_SIZE	262143
 #define IDPF_TX_MAX_MTU_SEG     10
 
-#define IDPF_TX_OFFLOAD_NOTSUP_MASK \
-		(RTE_MBUF_F_TX_OFFLOAD_MASK ^ IDPF_TX_OFFLOAD_MASK)
-
 #define IDPF_GET_PTYPE_SIZE(p) \
 	(sizeof(struct virtchnl2_ptype) + \
 	(((p)->proto_id_count ? ((p)->proto_id_count - 1) : 0) * sizeof((p)->proto_id[0])))
@@ -191,8 +188,21 @@ int idpf_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 int idpf_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 void idpf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 
+uint16_t idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+				uint16_t nb_pkts);
+uint16_t idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+			       uint16_t nb_pkts);
+uint16_t idpf_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+				uint16_t nb_pkts);
+uint16_t idpf_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+			       uint16_t nb_pkts);
+uint16_t idpf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+			uint16_t nb_pkts);
 void idpf_stop_queues(struct rte_eth_dev *dev);
 
+void idpf_set_rx_function(struct rte_eth_dev *dev);
+void idpf_set_tx_function(struct rte_eth_dev *dev);
+
 const uint32_t *idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
 #endif /* _IDPF_RXTX_H_ */
Signature · 1 line
2.34.1
#343 lore raw

PATCH v5 9/14 net/idpf: add support for Rx/Tx offloading

In reply to Junfeng Guo

Add Rx/Tx offloading support, including TSO and CHKSUM.

---
 doc/guides/nics/features/idpf.ini |   3 +
 drivers/net/idpf/idpf_ethdev.c    |  10 ++
 drivers/net/idpf/idpf_rxtx.c      | 237 +++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_rxtx.h      |  19 +++
 4 files changed, 267 insertions(+), 2 deletions(-)
doc/guides/nics/features/idpf.ini +3 -0
index 79ffafc0d4..36dec39b9f 100644
@@ -10,6 +10,9 @@
 Queue start/stop     = Y
 Runtime Rx queue setup = Y
 Runtime Tx queue setup = Y
+TSO                  = P
+L3 checksum offload  = P
+L4 checksum offload  = P
 Packet type parsing  = Y
 Multiprocess aware   = Y
 FreeBSD              = Y
drivers/net/idpf/idpf_ethdev.c +10 -0
index c6d6c87274..ffde2ce7d1 100644
@@ -86,6 +86,16 @@ 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->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
 		RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
+	dev_info->rx_offload_capa =
+		RTE_ETH_RX_OFFLOAD_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_TCP_TSO		|
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS		|
+		RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
 	dev_info->default_rxconf = (struct rte_eth_rxconf) {
 		.rx_free_thresh = IDPF_DEFAULT_RX_FREE_THRESH,
drivers/net/idpf/idpf_rxtx.c +235 -2

357 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +19 -0
index bd3ebe2f50..a2394ffa2c 100644
@@ -44,6 +44,25 @@
 #define IDPF_MAX_TSO_FRAME_SIZE	262143
 #define IDPF_TX_MAX_MTU_SEG     10
 
+#define IDPF_TX_CKSUM_OFFLOAD_MASK (		\
+		RTE_MBUF_F_TX_IP_CKSUM |	\
+		RTE_MBUF_F_TX_L4_MASK |		\
+		RTE_MBUF_F_TX_TCP_SEG)
+
+#define IDPF_TX_OFFLOAD_MASK (			\
+		RTE_MBUF_F_TX_OUTER_IPV6 |	\
+		RTE_MBUF_F_TX_OUTER_IPV4 |	\
+		RTE_MBUF_F_TX_IPV6 |		\
+		RTE_MBUF_F_TX_IPV4 |		\
+		RTE_MBUF_F_TX_VLAN |		\
+		RTE_MBUF_F_TX_IP_CKSUM |	\
+		RTE_MBUF_F_TX_L4_MASK |		\
+		RTE_MBUF_F_TX_TCP_SEG |		\
+		RTE_ETH_TX_OFFLOAD_SECURITY)
+
+#define IDPF_TX_OFFLOAD_NOTSUP_MASK \
+		(RTE_MBUF_F_TX_OFFLOAD_MASK ^ IDPF_TX_OFFLOAD_MASK)
+
 #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])))
Signature · 1 line
2.34.1
#344 lore raw

PATCH v5 10/14 net/idpf: add support for RSS

In reply to Junfeng Guo

Add RSS support.

---
 drivers/net/idpf/idpf_ethdev.c | 123 ++++++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_ethdev.h |  26 +++++++
 drivers/net/idpf/idpf_rxtx.c   |  27 ++++++++
 drivers/net/idpf/idpf_vchnl.c  |  96 +++++++++++++++++++++++++
 4 files changed, 269 insertions(+), 3 deletions(-)
drivers/net/idpf/idpf_ethdev.c +120 -3
index ffde2ce7d1..cc1cfe402b 100644
@@ -83,6 +83,7 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->min_rx_bufsize = IDPF_MIN_BUF_SIZE;
 	dev_info->max_rx_pktlen = IDPF_MAX_FRAME_SIZE;
 
+	dev_info->flow_type_rss_offloads = IDPF_RSS_OFFLOAD_ALL;
 	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
 	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
 		RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
@@ -90,7 +91,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_RSS_HASH;
 
 	dev_info->tx_offload_capa =
 		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
@@ -197,6 +199,10 @@ idpf_parse_devarg_id(char *name)
 	return val;
 }
 
+#ifndef IDPF_RSS_KEY_LEN
+#define IDPF_RSS_KEY_LEN 52
+#endif
+
 static int
 idpf_init_vport(struct rte_eth_dev *dev)
 {
@@ -217,6 +223,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++) {
@@ -265,15 +275,116 @@ idpf_init_vport(struct rte_eth_dev *dev)
 }
 
 static int
-idpf_dev_configure(__rte_unused struct rte_eth_dev *dev)
+idpf_config_rss(struct idpf_vport *vport)
+{
+	int ret;
+
+	ret = idpf_vc_set_rss_key(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS key");
+		return ret;
+	}
+
+	ret = idpf_vc_set_rss_lut(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS lut");
+		return ret;
+	}
+
+	ret = idpf_vc_set_rss_hash(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS hash");
+		return ret;
+	}
+
+	return ret;
+}
+
+static int
+idpf_init_rss(struct idpf_vport *vport)
+{
+	struct rte_eth_rss_conf *rss_conf;
+	uint16_t i, nb_q, lut_size;
+	int ret = 0;
+
+	rss_conf = &vport->dev_data->dev_conf.rx_adv_conf.rss_conf;
+	nb_q = vport->dev_data->nb_rx_queues;
+
+	vport->rss_key = (uint8_t *)rte_zmalloc("rss_key",
+					     vport->rss_key_size, 0);
+	if (!vport->rss_key) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS key");
+		ret = -ENOMEM;
+		goto err_key;
+	}
+
+	lut_size = vport->rss_lut_size;
+	vport->rss_lut = (uint32_t *)rte_zmalloc("rss_lut",
+					      sizeof(uint32_t) * lut_size, 0);
+	if (!vport->rss_lut) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS lut");
+		ret = -ENOMEM;
+		goto err_lut;
+	}
+
+	if (!rss_conf->rss_key) {
+		for (i = 0; i < vport->rss_key_size; i++)
+			vport->rss_key[i] = (uint8_t)rte_rand();
+	} else {
+		rte_memcpy(vport->rss_key, rss_conf->rss_key,
+			   RTE_MIN(rss_conf->rss_key_len,
+				   vport->rss_key_size));
+	}
+
+	for (i = 0; i < lut_size; i++)
+		vport->rss_lut[i] = i % nb_q;
+
+	vport->rss_hf = IDPF_DEFAULT_RSS_HASH_EXPANDED;
+
+	ret = idpf_config_rss(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS");
+		goto err_cfg;
+	}
+
+	return ret;
+
+err_cfg:
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+err_lut:
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+err_key:
+	return ret;
+}
+
+static int
+idpf_dev_configure(struct rte_eth_dev *dev)
 {
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	int ret = 0;
+
 	if (dev->data->nb_tx_queues > IDPF_DEFAULT_TXQ_NUM ||
 	    dev->data->nb_rx_queues > IDPF_DEFAULT_RXQ_NUM) {
 		PMD_INIT_LOG(ERR, "Invalid queue number.");
 		return -EINVAL;
 	}
 
-	return 0;
+	if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+		dev->data->dev_conf.rxmode.offloads |=
+			RTE_ETH_RX_OFFLOAD_RSS_HASH;
+
+	if (adapter->caps->rss_caps) {
+		ret = idpf_init_rss(vport);
+		if (ret) {
+			PMD_INIT_LOG(ERR, "Failed to init rss");
+			return ret;
+		}
+	}
+
+	return ret;
 }
 
 static int
@@ -372,6 +483,12 @@ idpf_dev_close(struct rte_eth_dev *dev)
 	idpf_dev_stop(dev);
 	idpf_vc_destroy_vport(vport);
 
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+
 	adapter->cur_vports &= ~BIT(vport->devarg_id);
 
 	rte_free(vport);
drivers/net/idpf/idpf_ethdev.h +26 -0
index 863d163330..bba8223cc4 100644
@@ -56,6 +56,20 @@
 #define IDPF_ETH_OVERHEAD \
 	(RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + IDPF_VLAN_TAG_SIZE * 2)
 
+#define IDPF_RSS_OFFLOAD_ALL ( \
+	RTE_ETH_RSS_IPV4		| \
+	RTE_ETH_RSS_FRAG_IPV4		| \
+	RTE_ETH_RSS_NONFRAG_IPV4_TCP	| \
+	RTE_ETH_RSS_NONFRAG_IPV4_UDP	| \
+	RTE_ETH_RSS_NONFRAG_IPV4_SCTP	| \
+	RTE_ETH_RSS_NONFRAG_IPV4_OTHER	| \
+	RTE_ETH_RSS_IPV6		| \
+	RTE_ETH_RSS_FRAG_IPV6		| \
+	RTE_ETH_RSS_NONFRAG_IPV6_TCP	| \
+	RTE_ETH_RSS_NONFRAG_IPV6_UDP	| \
+	RTE_ETH_RSS_NONFRAG_IPV6_SCTP	| \
+	RTE_ETH_RSS_NONFRAG_IPV6_OTHER)
+
 #ifndef ETH_ADDR_LEN
 #define ETH_ADDR_LEN		6
 #endif
@@ -102,11 +116,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;
+
 	/* Chunk info */
 	struct idpf_chunks_info chunks_info;
 
@@ -214,6 +237,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 rte_eth_dev *dev);
 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_rxtx.c +27 -0
index a56db1950f..88389250be 100644
@@ -1310,6 +1310,32 @@ idpf_splitq_rx_csum_offload(uint8_t err)
 	return flags;
 }
 
+#define IDPF_RX_FLEX_DESC_ADV_HASH1_S	0
+#define IDPF_RX_FLEX_DESC_ADV_HASH2_S	16
+#define IDPF_RX_FLEX_DESC_ADV_HASH3_S	24
+
+static inline uint64_t
+idpf_splitq_rx_rss_offload(struct rte_mbuf *mb,
+			   volatile struct virtchnl2_rx_flex_desc_adv_nic_3 *rx_desc)
+{
+	uint8_t status_err0_qw0;
+	uint64_t flags = 0;
+
+	status_err0_qw0 = rx_desc->status_err0_qw0;
+
+	if (status_err0_qw0 & BIT(VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_RSS_VALID_S)) {
+		flags |= RTE_MBUF_F_RX_RSS_HASH;
+		mb->hash.rss = (rte_le_to_cpu_16(rx_desc->hash1) <<
+				IDPF_RX_FLEX_DESC_ADV_HASH1_S) |
+				((uint32_t)(rx_desc->ff2_mirrid_hash2.hash2) <<
+				IDPF_RX_FLEX_DESC_ADV_HASH2_S) |
+				((uint32_t)(rx_desc->hash3) <<
+				IDPF_RX_FLEX_DESC_ADV_HASH3_S);
+	}
+
+	return flags;
+}
+
 static void
 idpf_split_rx_bufq_refill(struct idpf_rx_queue *rx_bufq)
 {
@@ -1465,6 +1491,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 
 		status_err0_qw1 = rx_desc->status_err0_qw1;
 		pkt_flags = idpf_splitq_rx_csum_offload(status_err0_qw1);
+		pkt_flags |= idpf_splitq_rx_rss_offload(rxm, rx_desc);
 
 		rxm->ol_flags |= pkt_flags;
 
drivers/net/idpf/idpf_vchnl.c +96 -0

102 lines not on this page · raw message

Signature · 1 line
2.34.1
#345 lore raw

PATCH v5 11/14 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    | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)
doc/guides/nics/features/idpf.ini +1 -0
index 36dec39b9f..ee3f6e7c6f 100644
@@ -10,6 +10,7 @@
 Queue start/stop     = Y
 Runtime Rx queue setup = Y
 Runtime Tx queue setup = Y
+MTU update           = Y
 TSO                  = P
 L3 checksum offload  = P
 L4 checksum offload  = P
drivers/net/idpf/idpf_ethdev.c +24 -0
index cc1cfe402b..803c0d7e12 100644
@@ -32,6 +32,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);
 
 int
@@ -70,6 +71,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
@@ -83,6 +85,9 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->min_rx_bufsize = IDPF_MIN_BUF_SIZE;
 	dev_info->max_rx_pktlen = IDPF_MAX_FRAME_SIZE;
 
+	dev_info->max_mtu = dev_info->max_rx_pktlen - IDPF_ETH_OVERHEAD;
+	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
+
 	dev_info->flow_type_rss_offloads = IDPF_RSS_OFFLOAD_ALL;
 	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
 	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
@@ -131,6 +136,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)
 {
@@ -429,6 +446,13 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	vport->stopped = 0;
 
+	if (dev->data->mtu > vport->max_mtu) {
+		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
+		goto err_mtu;
+	}
+
+	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
+
 	if (idpf_start_queues(dev)) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
 		goto err_mtu;
Signature · 1 line
2.34.1
#346 lore raw

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

In reply to Junfeng Guo

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

---
 drivers/net/idpf/idpf_ethdev.c | 119 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h |   8 +++
 drivers/net/idpf/idpf_vchnl.c  | 107 +++++++++++++++++++++++++++++
 3 files changed, 234 insertions(+)
drivers/net/idpf/idpf_ethdev.c +119 -0
index 803c0d7e12..ac70c029b0 100644
@@ -404,6 +404,90 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static int
+idpf_config_rx_queues_irqs(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	struct virtchnl2_queue_vector *qv_map;
+	struct 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) {
+		PMD_DRV_LOG(ERR, "Failed to allocate %d queue-vector map",
+			    dev->data->nb_rx_queues);
+		goto qv_map_alloc_err;
+	}
+
+	/* Rx interrupt disabled, Map interrupt only for writeback */
+
+	/* The capability flags adapter->caps->other_caps here should be
+	 * compared with bit VIRTCHNL2_CAP_WB_ON_ITR. The if condition should
+	 * be updated when the FW can return correct flag bits.
+	 */
+	if (adapter->caps->other_caps) {
+		dynctl_reg_start =
+			vport->recv_vectors->vchunks.vchunks->dynctl_reg_start;
+		itrn_reg_start =
+			vport->recv_vectors->vchunks.vchunks->itrn_reg_start;
+		dynctl_val = 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)
+			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)) {
+		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)
 {
@@ -441,6 +525,10 @@ static int
 idpf_dev_start(struct rte_eth_dev *dev)
 {
 	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	uint16_t num_allocated_vectors =
+		adapter->caps->num_allocated_vectors;
+	uint16_t req_vecs_num;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -453,6 +541,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)) {
+		PMD_DRV_LOG(ERR, "Failed to allocate interrupt vectors");
+		goto err_mtu;
+	}
+	adapter->used_vecs_num += req_vecs_num;
+
+	if (idpf_config_rx_queues_irqs(dev)) {
+		PMD_DRV_LOG(ERR, "Failed to configure irqs");
+		goto err_mtu;
+	}
+
 	if (idpf_start_queues(dev)) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
 		goto err_mtu;
@@ -489,6 +594,12 @@ idpf_dev_stop(struct rte_eth_dev *dev)
 
 	idpf_stop_queues(dev);
 
+	if (idpf_vc_config_irq_map_unmap(vport, false))
+		PMD_DRV_LOG(ERR, "config interrupt unmapping failed");
+
+	if (idpf_vc_dealloc_vectors(vport))
+		PMD_DRV_LOG(ERR, "deallocate interrupt vectors failed");
+
 	vport->stopped = 1;
 	dev->data->dev_started = 0;
 
@@ -513,6 +624,12 @@ idpf_dev_close(struct rte_eth_dev *dev)
 	rte_free(vport->rss_key);
 	vport->rss_key = NULL;
 
+	rte_free(vport->recv_vectors);
+	vport->recv_vectors = NULL;
+
+	rte_free(vport->qv_map);
+	vport->qv_map = NULL;
+
 	adapter->cur_vports &= ~BIT(vport->devarg_id);
 
 	rte_free(vport);
@@ -864,6 +981,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 +8 -0
index bba8223cc4..505b3f36e3 100644
@@ -130,6 +130,11 @@ struct idpf_vport {
 	uint8_t *rss_key;
 	uint64_t rss_hf;
 
+	/* MSIX info*/
+	struct virtchnl2_queue_vector *qv_map; /* queue vector mapping */
+	uint16_t max_vectors;
+	struct virtchnl2_alloc_vectors *recv_vectors;
+
 	/* Chunk info */
 	struct idpf_chunks_info chunks_info;
 
@@ -248,6 +253,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 +107 -0

113 lines not on this page · raw message

Signature · 1 line
2.34.1
#347 lore raw

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

In reply to Junfeng Guo

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

---
 doc/guides/nics/idpf.rst                |  20 +
 drivers/net/idpf/idpf_ethdev.h          |   5 +
 drivers/net/idpf/idpf_rxtx.c            | 146 ++++
 drivers/net/idpf/idpf_rxtx.h            |   7 +
 drivers/net/idpf/idpf_rxtx_vec_avx512.c | 871 ++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx_vec_common.h | 100 +++
 drivers/net/idpf/meson.build            |  28 +
 7 files changed, 1177 insertions(+)
 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 +20 -0
index 84b21e7be0..8f81894e27 100644
@@ -72,3 +72,23 @@ Driver compilation and testing
 
 Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and_test>`
 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.h +5 -0
index 505b3f36e3..9b0de772c9 100644
@@ -182,6 +182,11 @@ struct idpf_adapter {
 	uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned;
 
 	bool stopped;
+
+	bool rx_vec_allowed;
+	bool tx_vec_allowed;
+	bool rx_use_avx512;
+	bool tx_use_avx512;
 };
 
 TAILQ_HEAD(idpf_adapter_list, idpf_adapter);
drivers/net/idpf/idpf_rxtx.c +146 -0

181 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +7 -0
index a2394ffa2c..8f440557bd 100644
@@ -211,12 +211,19 @@ uint16_t idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 				uint16_t nb_pkts);
 uint16_t idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 			       uint16_t nb_pkts);
+uint16_t idpf_singleq_recv_pkts_avx512(void *rx_queue, struct rte_mbuf **rx_pkts,
+				       uint16_t nb_pkts);
 uint16_t idpf_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 				uint16_t nb_pkts);
 uint16_t idpf_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			       uint16_t nb_pkts);
+uint16_t idpf_singleq_xmit_pkts_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
+				       uint16_t nb_pkts);
+int idpf_singleq_tx_vec_setup_avx512(struct idpf_tx_queue *txq);
 uint16_t idpf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			uint16_t nb_pkts);
+int idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq);
+
 void idpf_stop_queues(struct rte_eth_dev *dev);
 
 void idpf_set_rx_function(struct rte_eth_dev *dev);
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +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 832f887296..c96e4bfcaa 100644
@@ -15,3 +15,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_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
#348 lore raw

PATCH v5 14/14 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      | 57 ++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h      | 90 +++++++++++++++++++++++++++++++
 5 files changed, 155 insertions(+), 1 deletion(-)
doc/guides/nics/features/idpf.ini +1 -0
index ee3f6e7c6f..145d995f51 100644
@@ -14,6 +14,7 @@ MTU update           = Y
 TSO                  = P
 L3 checksum offload  = P
 L4 checksum offload  = P
+Timestamp offload    = P
 Packet type parsing  = Y
 Multiprocess aware   = Y
 FreeBSD              = Y
drivers/net/idpf/idpf_ethdev.c +4 -1
index ac70c029b0..c3f628655c 100644
@@ -19,6 +19,8 @@
 struct idpf_adapter_list adapter_list;
 bool adapter_list_init;
 
+uint64_t idpf_timestamp_dynflag;
+
 static const char * const idpf_valid_args[] = {
 	IDPF_TX_SINGLE_Q,
 	IDPF_RX_SINGLE_Q,
@@ -97,7 +99,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		RTE_ETH_RX_OFFLOAD_UDP_CKSUM		|
 		RTE_ETH_RX_OFFLOAD_TCP_CKSUM		|
 		RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM	|
-		RTE_ETH_RX_OFFLOAD_RSS_HASH;
+		RTE_ETH_RX_OFFLOAD_RSS_HASH		|
+		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 9b0de772c9..49919e5c74 100644
@@ -187,6 +187,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 +57 -0

120 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
#349 lore raw

PATCH v4 2/14 net/idpf: add support for device initialization

In reply to Junfeng Guo

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

---
 MAINTAINERS                            |   9 +
 doc/guides/nics/features/idpf.ini      |  15 +
 doc/guides/nics/idpf.rst               |  52 ++
 doc/guides/nics/index.rst              |   1 +
 doc/guides/rel_notes/release_22_11.rst |   5 +
 drivers/net/idpf/idpf_ethdev.c         | 774 +++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h         | 204 +++++++
 drivers/net/idpf/idpf_logs.h           |  42 ++
 drivers/net/idpf/idpf_vchnl.c          | 495 ++++++++++++++++
 drivers/net/idpf/meson.build           |  16 +
 drivers/net/idpf/version.map           |   3 +
 drivers/net/meson.build                |   1 +
 12 files changed, 1617 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 2bd4a55f1b..e2d9c2ac50 100644
@@ -758,6 +758,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 +15 -0
new file mode 100644
index 0000000000..f029a279b3
@@ -0,0 +1,15 @@
+;
+; 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]
+Multiprocess aware   = Y
+FreeBSD              = Y
+Linux                = Y
+Windows              = Y
+x86-32               = Y
+x86-64               = Y
doc/guides/nics/idpf.rst new file +52 -0

52 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 +5 -0
index 2da8bc9661..6697b61848 100644
@@ -236,6 +236,11 @@ New Features
 
      strings $dpdk_binary_or_driver | sed -n 's/^PMD_INFO_STRING= //p'
 
+* **Added IDPF PMD [*EXPERIMENTAL*].**
+
+  Added the new ``idpf`` net driver for Intel® IPU Ethernet ES2000 Series.
+  See the :doc:`../nics/idpf` NIC guide for more details on this new driver.
+
 
 Removed Items
 -------------
drivers/net/idpf/idpf_ethdev.c new file +774 -0

774 lines not on this page · raw message

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

204 lines not on this page · raw message

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

42 lines not on this page · raw message

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

495 lines not on this page · raw message

drivers/net/idpf/meson.build new file +16 -0
new file mode 100644
index 0000000000..bf8bf58ef5
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
+includes += include_directories('../../common/idpf')
+deps += ['common_idpf', 'security', 'cryptodev']
+
+sources = files(
+    'idpf_ethdev.c',
+    'idpf_vchnl.c',
+)
drivers/net/idpf/version.map new file +3 -0
new file mode 100644
index 0000000000..c2e0723b4c
@@ -0,0 +1,3 @@
+DPDK_22 {
+	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
#350 lore raw

PATCH v4 3/14 net/idpf: add queue setup and release in single queue model

In reply to Junfeng Guo

Add support for queue operations in single queue model:
- rx_queue_setup
- rx_queue_release
- tx_queue_setup
- tx_queue_release

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.

---
 doc/guides/nics/features/idpf.ini |   2 +
 doc/guides/nics/idpf.rst          |  22 ++
 drivers/net/idpf/idpf_ethdev.c    |  58 ++++
 drivers/net/idpf/idpf_ethdev.h    |   9 +
 drivers/net/idpf/idpf_rxtx.c      | 465 ++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h      | 186 ++++++++++++
 drivers/net/idpf/idpf_vchnl.c     | 249 ++++++++++++++++
 drivers/net/idpf/meson.build      |   1 +
 8 files changed, 992 insertions(+)
 create mode 100644 drivers/net/idpf/idpf_rxtx.c
 create mode 100644 drivers/net/idpf/idpf_rxtx.h
doc/guides/nics/features/idpf.ini +2 -0
index f029a279b3..681a908194 100644
@@ -7,6 +7,8 @@
 ; is selected.
 ;
 [Features]
+Runtime Rx queue setup = Y
+Runtime Tx queue setup = Y
 Multiprocess aware   = Y
 FreeBSD              = Y
 Linux                = Y
doc/guides/nics/idpf.rst +22 -0
index cc56db6e70..84b21e7be0 100644
@@ -45,6 +45,28 @@ Runtime Config Options
   Then idpf PMD will create 3 vports (ethdevs) for device ca:00.0.
   NOTE: This parameter is MUST, otherwise there'll be no any ethdev created.
 
+- ``rx_single`` (default ``0``)
+
+  There're two queue modes supported by Intel® IPU Ethernet ES2000 Series, single queue
+  mode and split queue mode for Rx queue. User can choose Rx queue mode by the ``devargs``
+  parameter ``rx_single``.
+
+    -a ca:00.0,rx_single=1
+
+  Then idpf PMD will configure Rx queue with single queue mode. Otherwise, split queue
+  mode is chosen by default.
+
+- ``tx_single`` (default ``0``)
+
+  There're two queue modes supported by Intel® IPU Ethernet ES2000 Series, single queue
+  mode and split queue mode for Tx queue. User can choose Tx queue mode by the ``devargs``
+  parameter ``tx_single``.
+
+    -a ca:00.0,tx_single=1
+
+  Then idpf PMD will configure Tx queue with single queue mode. Otherwise, split queue
+  mode is chosen by default.
+
 Driver compilation and testing
 ------------------------------
 
drivers/net/idpf/idpf_ethdev.c +58 -0

107 lines not on this page · raw message

drivers/net/idpf/idpf_ethdev.h +9 -0
index 77824d5f7f..8b7170f49e 100644
@@ -83,6 +83,8 @@ struct idpf_chunks_info {
 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;
 	uint16_t num_rx_q;
 
@@ -118,6 +120,9 @@ struct idpf_adapter {
 	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;
+	uint32_t rxq_model;
+
 	/* Vport info */
 	uint8_t **vport_req_info;
 	uint8_t **vport_recv_info;
@@ -197,6 +202,10 @@ 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 rte_eth_dev *dev);
 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_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 new file +465 -0

465 lines not on this page · raw message

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

186 lines not on this page · raw message

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

261 lines not on this page · raw message

drivers/net/idpf/meson.build +1 -0
index bf8bf58ef5..832f887296 100644
@@ -12,5 +12,6 @@ deps += ['common_idpf', 'security', 'cryptodev']
 
 sources = files(
     'idpf_ethdev.c',
+    'idpf_rxtx.c',
     'idpf_vchnl.c',
 )
Signature · 1 line
2.34.1
#351 lore raw

PATCH v4 4/14 net/idpf: add queue setup and release in split queue model

In reply to Junfeng Guo

Add support for queue operations in split queue model:
- rx_queue_setup
- rx_queue_release
- tx_queue_setup
- tx_queue_release

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 |  34 ++-
 drivers/net/idpf/idpf_ethdev.h |  11 +
 drivers/net/idpf/idpf_rxtx.c   | 483 ++++++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_vchnl.c  | 127 ++++++++-
 4 files changed, 642 insertions(+), 13 deletions(-)
drivers/net/idpf/idpf_ethdev.c +32 -2
index 96af54f47b..f9717cd5ff 100644
@@ -90,13 +90,25 @@ idpf_init_vport_req_info(struct rte_eth_dev *dev)
 		(struct virtchnl2_create_vport *)adapter->vport_req_info[idx];
 
 	vport_info->vport_type = rte_cpu_to_le_16(VIRTCHNL2_VPORT_TYPE_DEFAULT);
-	if (adapter->txq_model) {
+	if (!adapter->txq_model) {
+		vport_info->txq_model =
+			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SPLIT);
+		vport_info->num_tx_q = IDPF_DEFAULT_TXQ_NUM;
+		vport_info->num_tx_complq =
+			IDPF_DEFAULT_TXQ_NUM * IDPF_TX_COMPLQ_PER_GRP;
+	} else {
 		vport_info->txq_model =
 			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SINGLE);
 		vport_info->num_tx_q = IDPF_DEFAULT_TXQ_NUM;
 		vport_info->num_tx_complq = 0;
 	}
-	if (adapter->rxq_model) {
+	if (!adapter->rxq_model) {
+		vport_info->rxq_model =
+			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SPLIT);
+		vport_info->num_rx_q = IDPF_DEFAULT_RXQ_NUM;
+		vport_info->num_rx_bufq =
+			IDPF_DEFAULT_RXQ_NUM * IDPF_RX_BUFQ_PER_GRP;
+	} else {
 		vport_info->rxq_model =
 			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SINGLE);
 		vport_info->num_rx_q = IDPF_DEFAULT_RXQ_NUM;
@@ -134,7 +146,9 @@ idpf_init_vport(struct rte_eth_dev *dev)
 	vport->txq_model = vport_info->txq_model;
 	vport->rxq_model = vport_info->rxq_model;
 	vport->num_tx_q = vport_info->num_tx_q;
+	vport->num_tx_complq = vport_info->num_tx_complq;
 	vport->num_rx_q = vport_info->num_rx_q;
+	vport->num_rx_bufq = vport_info->num_rx_bufq;
 	vport->max_mtu = vport_info->max_mtu;
 	rte_memcpy(vport->default_mac_addr,
 		   vport_info->default_mac_addr, ETH_ALEN);
@@ -157,6 +171,22 @@ idpf_init_vport(struct rte_eth_dev *dev)
 				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;
 		}
 	}
 
drivers/net/idpf/idpf_ethdev.h +11 -0
index 8b7170f49e..270ab7b6de 100644
@@ -73,11 +73,18 @@ enum idpf_vc_result {
 struct idpf_chunks_info {
 	uint32_t tx_start_qid;
 	uint32_t rx_start_qid;
+	/* Valid only if split queue model */
+	uint32_t tx_compl_start_qid;
+	uint32_t rx_buf_start_qid;
 
 	uint64_t tx_qtail_start;
 	uint32_t tx_qtail_spacing;
 	uint64_t rx_qtail_start;
 	uint32_t rx_qtail_spacing;
+	uint64_t tx_compl_qtail_start;
+	uint32_t tx_compl_qtail_spacing;
+	uint64_t rx_buf_qtail_start;
+	uint32_t rx_buf_qtail_spacing;
 };
 
 struct idpf_vport {
@@ -86,7 +93,11 @@ struct idpf_vport {
 	uint32_t txq_model;
 	uint32_t rxq_model;
 	uint16_t num_tx_q;
+	/* valid only if txq_model is split Q */
+	uint16_t num_tx_complq;
 	uint16_t num_rx_q;
+	/* valid only if rxq_model is split Q */
+	uint16_t num_rx_bufq;
 
 	uint16_t max_mtu;
 	uint8_t default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
drivers/net/idpf/idpf_rxtx.c +480 -3

525 lines not on this page · raw message

drivers/net/idpf/idpf_vchnl.c +119 -8

171 lines not on this page · raw message

Signature · 1 line
2.34.1
#352 lore raw

PATCH v4 5/14 net/idpf: add support for queue start and stop

In reply to Junfeng Guo

Add support for queue operations:
- rx_queue_start
- rx_queue_stop
- tx_queue_start
- tx_queue_stop

---
 doc/guides/nics/features/idpf.ini |   1 +
 drivers/net/idpf/idpf_ethdev.c    |  46 +++++
 drivers/net/idpf/idpf_ethdev.h    |   3 +
 drivers/net/idpf/idpf_rxtx.c      | 309 ++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h      |   6 +
 drivers/net/idpf/idpf_vchnl.c     | 150 +++++++++++++++
 6 files changed, 515 insertions(+)
doc/guides/nics/features/idpf.ini +1 -0
index 681a908194..597beec5d9 100644
@@ -7,6 +7,7 @@
 ; is selected.
 ;
 [Features]
+Queue start/stop     = Y
 Runtime Rx queue setup = Y
 Runtime Tx queue setup = Y
 Multiprocess aware   = Y
drivers/net/idpf/idpf_ethdev.c +46 -0

76 lines not on this page · raw message

drivers/net/idpf/idpf_ethdev.h +3 -0
index 270ab7b6de..b625868ceb 100644
@@ -217,6 +217,9 @@ 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 +309 -0

318 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +6 -0
index 69a1fa6348..f0427b96c5 100644
@@ -175,12 +175,18 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			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);
 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_ */
drivers/net/idpf/idpf_vchnl.c +150 -0

156 lines not on this page · raw message

Signature · 1 line
2.34.1
#353 lore raw

PATCH v4 6/14 net/idpf: add support for device information get

In reply to Junfeng Guo

Add dev ops dev_infos_get.

---
 drivers/net/idpf/idpf_ethdev.c | 50 ++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
drivers/net/idpf/idpf_ethdev.c +50 -0
index c25f222c5e..d1b6797d4a 100644
@@ -30,6 +30,8 @@ static int idpf_dev_configure(struct rte_eth_dev *dev);
 static int idpf_dev_start(struct rte_eth_dev *dev);
 static int idpf_dev_stop(struct rte_eth_dev *dev);
 static int idpf_dev_close(struct rte_eth_dev *dev);
+static int idpf_dev_info_get(struct rte_eth_dev *dev,
+			     struct rte_eth_dev_info *dev_info);
 static void idpf_adapter_rel(struct idpf_adapter *adapter);
 
 int
@@ -65,9 +67,57 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.rx_queue_release		= idpf_dev_rx_queue_release,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.tx_queue_release		= idpf_dev_tx_queue_release,
+	.dev_infos_get			= idpf_dev_info_get,
 	.link_update			= idpf_dev_link_update,
 };
 
+static int
+idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+
+	dev_info->max_rx_queues = adapter->caps->max_rx_q;
+	dev_info->max_tx_queues = adapter->caps->max_tx_q;
+	dev_info->min_rx_bufsize = IDPF_MIN_BUF_SIZE;
+	dev_info->max_rx_pktlen = IDPF_MAX_FRAME_SIZE;
+
+	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
+	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
+		RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
+
+	dev_info->default_rxconf = (struct rte_eth_rxconf) {
+		.rx_free_thresh = IDPF_DEFAULT_RX_FREE_THRESH,
+		.rx_drop_en = 0,
+		.offloads = 0,
+	};
+
+	dev_info->default_txconf = (struct rte_eth_txconf) {
+		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
+		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
+		.offloads = 0,
+	};
+
+	dev_info->rx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = IDPF_MAX_RING_DESC,
+		.nb_min = IDPF_MIN_RING_DESC,
+		.nb_align = IDPF_ALIGN_RING_DESC,
+	};
+
+	dev_info->tx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = IDPF_MAX_RING_DESC,
+		.nb_min = IDPF_MIN_RING_DESC,
+		.nb_align = IDPF_ALIGN_RING_DESC,
+	};
+
+	dev_info->default_rxportconf.burst_size = IDPF_RX_MAX_BURST;
+	dev_info->default_txportconf.burst_size = IDPF_TX_MAX_BURST;
+	dev_info->default_rxportconf.nb_queues = 1;
+	dev_info->default_txportconf.nb_queues = 1;
+
+	return 0;
+}
+
 static int
 idpf_init_vport_req_info(struct rte_eth_dev *dev)
 {
Signature · 1 line
2.34.1
#354 lore raw

PATCH v4 7/14 net/idpf: add support for packet type get

In reply to Junfeng Guo

Add dev ops dev_supported_ptypes_get.

---
 doc/guides/nics/features/idpf.ini |   1 +
 drivers/net/idpf/idpf_ethdev.c    |   7 +
 drivers/net/idpf/idpf_ethdev.h    |   2 +
 drivers/net/idpf/idpf_rxtx.c      |  19 +++
 drivers/net/idpf/idpf_rxtx.h      |   6 +
 drivers/net/idpf/idpf_vchnl.c     | 235 ++++++++++++++++++++++++++++++
 6 files changed, 270 insertions(+)
doc/guides/nics/features/idpf.ini +1 -0
index 597beec5d9..79ffafc0d4 100644
@@ -10,6 +10,7 @@
 Queue start/stop     = Y
 Runtime Rx queue setup = Y
 Runtime Tx queue setup = Y
+Packet type parsing  = Y
 Multiprocess aware   = Y
 FreeBSD              = Y
 Linux                = Y
drivers/net/idpf/idpf_ethdev.c +7 -0
index d1b6797d4a..20f0f39640 100644
@@ -55,6 +55,7 @@ idpf_dev_link_update(struct rte_eth_dev *dev,
 }
 
 static const struct eth_dev_ops idpf_eth_dev_ops = {
+	.dev_supported_ptypes_get	= idpf_dev_supported_ptypes_get,
 	.dev_configure			= idpf_dev_configure,
 	.dev_start			= idpf_dev_start,
 	.dev_stop			= idpf_dev_stop,
@@ -652,6 +653,12 @@ idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
 		goto err_api;
 	}
 
+	ret = idpf_get_pkt_type(adapter);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to set ptype table");
+		goto err_api;
+	}
+
 	adapter->caps = rte_zmalloc("idpf_caps",
 				sizeof(struct virtchnl2_get_capabilities), 0);
 	if (!adapter->caps) {
drivers/net/idpf/idpf_ethdev.h +2 -0
index b625868ceb..863d163330 100644
@@ -210,6 +210,7 @@ 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_get_pkt_type(struct idpf_adapter *adapter);
 int idpf_vc_get_caps(struct idpf_adapter *adapter);
 int idpf_vc_create_vport(struct rte_eth_dev *dev);
 int idpf_vc_destroy_vport(struct idpf_vport *vport);
@@ -221,6 +222,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 +19 -0
index 95193713c4..e92ea09c3b 100644
@@ -8,6 +8,25 @@
 #include "idpf_ethdev.h"
 #include "idpf_rxtx.h"
 
+const uint32_t *
+idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)
+{
+	static const uint32_t ptypes[] = {
+		RTE_PTYPE_L2_ETHER,
+		RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
+		RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
+		RTE_PTYPE_L4_FRAG,
+		RTE_PTYPE_L4_NONFRAG,
+		RTE_PTYPE_L4_UDP,
+		RTE_PTYPE_L4_TCP,
+		RTE_PTYPE_L4_SCTP,
+		RTE_PTYPE_L4_ICMP,
+		RTE_PTYPE_UNKNOWN
+	};
+
+	return ptypes;
+}
+
 static inline int
 check_rx_thresh(uint16_t nb_desc, uint16_t thresh)
 {
drivers/net/idpf/idpf_rxtx.h +6 -0
index f0427b96c5..cd1dda4688 100644
@@ -47,6 +47,10 @@
 #define IDPF_TX_OFFLOAD_NOTSUP_MASK \
 		(RTE_MBUF_F_TX_OFFLOAD_MASK ^ IDPF_TX_OFFLOAD_MASK)
 
+#define IDPF_GET_PTYPE_SIZE(p) \
+	(sizeof(struct virtchnl2_ptype) + \
+	(((p)->proto_id_count ? ((p)->proto_id_count - 1) : 0) * sizeof((p)->proto_id[0])))
+
 struct idpf_rx_queue {
 	struct idpf_adapter *adapter;	/* the adapter this queue belongs to */
 	struct rte_mempool *mp;		/* mbuf pool to populate Rx ring */
@@ -189,4 +193,6 @@ void idpf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 
 void idpf_stop_queues(struct rte_eth_dev *dev);
 
+const uint32_t *idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev);
+
 #endif /* _IDPF_RXTX_H_ */
drivers/net/idpf/idpf_vchnl.c +235 -0

244 lines not on this page · raw message

Signature · 1 line
2.34.1
#355 lore raw

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

In reply to Junfeng Guo

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

---
 drivers/net/idpf/idpf_ethdev.c |   8 +-
 drivers/net/idpf/idpf_rxtx.c   | 667 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  16 +-
 3 files changed, 687 insertions(+), 4 deletions(-)
drivers/net/idpf/idpf_ethdev.c +7 -1
index 20f0f39640..c6d6c87274 100644
@@ -313,6 +313,9 @@ idpf_dev_start(struct rte_eth_dev *dev)
 		goto err_mtu;
 	}
 
+	idpf_set_rx_function(dev);
+	idpf_set_tx_function(dev);
+
 	if (idpf_vc_ena_dis_vport(vport, true)) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
 		goto err_vport;
@@ -764,8 +767,11 @@ idpf_dev_init(struct rte_eth_dev *dev, void *init_params)
 	/* for secondary processes, we don't initialise any further as primary
 	 * has already done this work.
 	 */
-	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		idpf_set_rx_function(dev);
+		idpf_set_tx_function(dev);
 		return ret;
+	}
 
 	dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
 
drivers/net/idpf/idpf_rxtx.c +667 -0

670 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +13 -3
index cd1dda4688..bd3ebe2f50 100644
@@ -44,9 +44,6 @@
 #define IDPF_MAX_TSO_FRAME_SIZE	262143
 #define IDPF_TX_MAX_MTU_SEG     10
 
-#define IDPF_TX_OFFLOAD_NOTSUP_MASK \
-		(RTE_MBUF_F_TX_OFFLOAD_MASK ^ IDPF_TX_OFFLOAD_MASK)
-
 #define IDPF_GET_PTYPE_SIZE(p) \
 	(sizeof(struct virtchnl2_ptype) + \
 	(((p)->proto_id_count ? ((p)->proto_id_count - 1) : 0) * sizeof((p)->proto_id[0])))
@@ -191,8 +188,21 @@ int idpf_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 int idpf_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 void idpf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 
+uint16_t idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+				uint16_t nb_pkts);
+uint16_t idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+			       uint16_t nb_pkts);
+uint16_t idpf_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+				uint16_t nb_pkts);
+uint16_t idpf_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+			       uint16_t nb_pkts);
+uint16_t idpf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+			uint16_t nb_pkts);
 void idpf_stop_queues(struct rte_eth_dev *dev);
 
+void idpf_set_rx_function(struct rte_eth_dev *dev);
+void idpf_set_tx_function(struct rte_eth_dev *dev);
+
 const uint32_t *idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
 #endif /* _IDPF_RXTX_H_ */
Signature · 1 line
2.34.1
#356 lore raw

PATCH v4 9/14 net/idpf: add support for Rx/Tx offloading

In reply to Junfeng Guo

Add Rx/Tx offloading support, including TSO and CHKSUM.

---
 doc/guides/nics/features/idpf.ini |   3 +
 drivers/net/idpf/idpf_ethdev.c    |  10 ++
 drivers/net/idpf/idpf_rxtx.c      | 237 +++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_rxtx.h      |  19 +++
 4 files changed, 267 insertions(+), 2 deletions(-)
doc/guides/nics/features/idpf.ini +3 -0
index 79ffafc0d4..36dec39b9f 100644
@@ -10,6 +10,9 @@
 Queue start/stop     = Y
 Runtime Rx queue setup = Y
 Runtime Tx queue setup = Y
+TSO                  = P
+L3 checksum offload  = P
+L4 checksum offload  = P
 Packet type parsing  = Y
 Multiprocess aware   = Y
 FreeBSD              = Y
drivers/net/idpf/idpf_ethdev.c +10 -0
index c6d6c87274..ffde2ce7d1 100644
@@ -86,6 +86,16 @@ 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->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
 		RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
+	dev_info->rx_offload_capa =
+		RTE_ETH_RX_OFFLOAD_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_TCP_TSO		|
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS		|
+		RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
 	dev_info->default_rxconf = (struct rte_eth_rxconf) {
 		.rx_free_thresh = IDPF_DEFAULT_RX_FREE_THRESH,
drivers/net/idpf/idpf_rxtx.c +235 -2

357 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +19 -0
index bd3ebe2f50..a2394ffa2c 100644
@@ -44,6 +44,25 @@
 #define IDPF_MAX_TSO_FRAME_SIZE	262143
 #define IDPF_TX_MAX_MTU_SEG     10
 
+#define IDPF_TX_CKSUM_OFFLOAD_MASK (		\
+		RTE_MBUF_F_TX_IP_CKSUM |	\
+		RTE_MBUF_F_TX_L4_MASK |		\
+		RTE_MBUF_F_TX_TCP_SEG)
+
+#define IDPF_TX_OFFLOAD_MASK (			\
+		RTE_MBUF_F_TX_OUTER_IPV6 |	\
+		RTE_MBUF_F_TX_OUTER_IPV4 |	\
+		RTE_MBUF_F_TX_IPV6 |		\
+		RTE_MBUF_F_TX_IPV4 |		\
+		RTE_MBUF_F_TX_VLAN |		\
+		RTE_MBUF_F_TX_IP_CKSUM |	\
+		RTE_MBUF_F_TX_L4_MASK |		\
+		RTE_MBUF_F_TX_TCP_SEG |		\
+		RTE_ETH_TX_OFFLOAD_SECURITY)
+
+#define IDPF_TX_OFFLOAD_NOTSUP_MASK \
+		(RTE_MBUF_F_TX_OFFLOAD_MASK ^ IDPF_TX_OFFLOAD_MASK)
+
 #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])))
Signature · 1 line
2.34.1
#357 lore raw

PATCH v4 10/14 net/idpf: add support for RSS

In reply to Junfeng Guo

Add RSS support.

---
 drivers/net/idpf/idpf_ethdev.c | 123 ++++++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_ethdev.h |  26 +++++++
 drivers/net/idpf/idpf_rxtx.c   |  27 ++++++++
 drivers/net/idpf/idpf_vchnl.c  |  96 +++++++++++++++++++++++++
 4 files changed, 269 insertions(+), 3 deletions(-)
drivers/net/idpf/idpf_ethdev.c +120 -3
index ffde2ce7d1..cc1cfe402b 100644
@@ -83,6 +83,7 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->min_rx_bufsize = IDPF_MIN_BUF_SIZE;
 	dev_info->max_rx_pktlen = IDPF_MAX_FRAME_SIZE;
 
+	dev_info->flow_type_rss_offloads = IDPF_RSS_OFFLOAD_ALL;
 	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
 	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
 		RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
@@ -90,7 +91,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_RSS_HASH;
 
 	dev_info->tx_offload_capa =
 		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
@@ -197,6 +199,10 @@ idpf_parse_devarg_id(char *name)
 	return val;
 }
 
+#ifndef IDPF_RSS_KEY_LEN
+#define IDPF_RSS_KEY_LEN 52
+#endif
+
 static int
 idpf_init_vport(struct rte_eth_dev *dev)
 {
@@ -217,6 +223,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++) {
@@ -265,15 +275,116 @@ idpf_init_vport(struct rte_eth_dev *dev)
 }
 
 static int
-idpf_dev_configure(__rte_unused struct rte_eth_dev *dev)
+idpf_config_rss(struct idpf_vport *vport)
+{
+	int ret;
+
+	ret = idpf_vc_set_rss_key(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS key");
+		return ret;
+	}
+
+	ret = idpf_vc_set_rss_lut(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS lut");
+		return ret;
+	}
+
+	ret = idpf_vc_set_rss_hash(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS hash");
+		return ret;
+	}
+
+	return ret;
+}
+
+static int
+idpf_init_rss(struct idpf_vport *vport)
+{
+	struct rte_eth_rss_conf *rss_conf;
+	uint16_t i, nb_q, lut_size;
+	int ret = 0;
+
+	rss_conf = &vport->dev_data->dev_conf.rx_adv_conf.rss_conf;
+	nb_q = vport->dev_data->nb_rx_queues;
+
+	vport->rss_key = (uint8_t *)rte_zmalloc("rss_key",
+					     vport->rss_key_size, 0);
+	if (!vport->rss_key) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS key");
+		ret = -ENOMEM;
+		goto err_key;
+	}
+
+	lut_size = vport->rss_lut_size;
+	vport->rss_lut = (uint32_t *)rte_zmalloc("rss_lut",
+					      sizeof(uint32_t) * lut_size, 0);
+	if (!vport->rss_lut) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS lut");
+		ret = -ENOMEM;
+		goto err_lut;
+	}
+
+	if (!rss_conf->rss_key) {
+		for (i = 0; i < vport->rss_key_size; i++)
+			vport->rss_key[i] = (uint8_t)rte_rand();
+	} else {
+		rte_memcpy(vport->rss_key, rss_conf->rss_key,
+			   RTE_MIN(rss_conf->rss_key_len,
+				   vport->rss_key_size));
+	}
+
+	for (i = 0; i < lut_size; i++)
+		vport->rss_lut[i] = i % nb_q;
+
+	vport->rss_hf = IDPF_DEFAULT_RSS_HASH_EXPANDED;
+
+	ret = idpf_config_rss(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS");
+		goto err_cfg;
+	}
+
+	return ret;
+
+err_cfg:
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+err_lut:
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+err_key:
+	return ret;
+}
+
+static int
+idpf_dev_configure(struct rte_eth_dev *dev)
 {
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	int ret = 0;
+
 	if (dev->data->nb_tx_queues > IDPF_DEFAULT_TXQ_NUM ||
 	    dev->data->nb_rx_queues > IDPF_DEFAULT_RXQ_NUM) {
 		PMD_INIT_LOG(ERR, "Invalid queue number.");
 		return -EINVAL;
 	}
 
-	return 0;
+	if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+		dev->data->dev_conf.rxmode.offloads |=
+			RTE_ETH_RX_OFFLOAD_RSS_HASH;
+
+	if (adapter->caps->rss_caps) {
+		ret = idpf_init_rss(vport);
+		if (ret) {
+			PMD_INIT_LOG(ERR, "Failed to init rss");
+			return ret;
+		}
+	}
+
+	return ret;
 }
 
 static int
@@ -372,6 +483,12 @@ idpf_dev_close(struct rte_eth_dev *dev)
 	idpf_dev_stop(dev);
 	idpf_vc_destroy_vport(vport);
 
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+
 	adapter->cur_vports &= ~BIT(vport->devarg_id);
 
 	rte_free(vport);
drivers/net/idpf/idpf_ethdev.h +26 -0
index 863d163330..bba8223cc4 100644
@@ -56,6 +56,20 @@
 #define IDPF_ETH_OVERHEAD \
 	(RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + IDPF_VLAN_TAG_SIZE * 2)
 
+#define IDPF_RSS_OFFLOAD_ALL ( \
+	RTE_ETH_RSS_IPV4		| \
+	RTE_ETH_RSS_FRAG_IPV4		| \
+	RTE_ETH_RSS_NONFRAG_IPV4_TCP	| \
+	RTE_ETH_RSS_NONFRAG_IPV4_UDP	| \
+	RTE_ETH_RSS_NONFRAG_IPV4_SCTP	| \
+	RTE_ETH_RSS_NONFRAG_IPV4_OTHER	| \
+	RTE_ETH_RSS_IPV6		| \
+	RTE_ETH_RSS_FRAG_IPV6		| \
+	RTE_ETH_RSS_NONFRAG_IPV6_TCP	| \
+	RTE_ETH_RSS_NONFRAG_IPV6_UDP	| \
+	RTE_ETH_RSS_NONFRAG_IPV6_SCTP	| \
+	RTE_ETH_RSS_NONFRAG_IPV6_OTHER)
+
 #ifndef ETH_ADDR_LEN
 #define ETH_ADDR_LEN		6
 #endif
@@ -102,11 +116,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;
+
 	/* Chunk info */
 	struct idpf_chunks_info chunks_info;
 
@@ -214,6 +237,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 rte_eth_dev *dev);
 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_rxtx.c +27 -0
index a56db1950f..88389250be 100644
@@ -1310,6 +1310,32 @@ idpf_splitq_rx_csum_offload(uint8_t err)
 	return flags;
 }
 
+#define IDPF_RX_FLEX_DESC_ADV_HASH1_S	0
+#define IDPF_RX_FLEX_DESC_ADV_HASH2_S	16
+#define IDPF_RX_FLEX_DESC_ADV_HASH3_S	24
+
+static inline uint64_t
+idpf_splitq_rx_rss_offload(struct rte_mbuf *mb,
+			   volatile struct virtchnl2_rx_flex_desc_adv_nic_3 *rx_desc)
+{
+	uint8_t status_err0_qw0;
+	uint64_t flags = 0;
+
+	status_err0_qw0 = rx_desc->status_err0_qw0;
+
+	if (status_err0_qw0 & BIT(VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_RSS_VALID_S)) {
+		flags |= RTE_MBUF_F_RX_RSS_HASH;
+		mb->hash.rss = (rte_le_to_cpu_16(rx_desc->hash1) <<
+				IDPF_RX_FLEX_DESC_ADV_HASH1_S) |
+				((uint32_t)(rx_desc->ff2_mirrid_hash2.hash2) <<
+				IDPF_RX_FLEX_DESC_ADV_HASH2_S) |
+				((uint32_t)(rx_desc->hash3) <<
+				IDPF_RX_FLEX_DESC_ADV_HASH3_S);
+	}
+
+	return flags;
+}
+
 static void
 idpf_split_rx_bufq_refill(struct idpf_rx_queue *rx_bufq)
 {
@@ -1465,6 +1491,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 
 		status_err0_qw1 = rx_desc->status_err0_qw1;
 		pkt_flags = idpf_splitq_rx_csum_offload(status_err0_qw1);
+		pkt_flags |= idpf_splitq_rx_rss_offload(rxm, rx_desc);
 
 		rxm->ol_flags |= pkt_flags;
 
drivers/net/idpf/idpf_vchnl.c +96 -0

102 lines not on this page · raw message

Signature · 1 line
2.34.1
#358 lore raw

PATCH v4 11/14 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    | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)
doc/guides/nics/features/idpf.ini +1 -0
index 36dec39b9f..ee3f6e7c6f 100644
@@ -10,6 +10,7 @@
 Queue start/stop     = Y
 Runtime Rx queue setup = Y
 Runtime Tx queue setup = Y
+MTU update           = Y
 TSO                  = P
 L3 checksum offload  = P
 L4 checksum offload  = P
drivers/net/idpf/idpf_ethdev.c +24 -0
index cc1cfe402b..803c0d7e12 100644
@@ -32,6 +32,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);
 
 int
@@ -70,6 +71,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
@@ -83,6 +85,9 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->min_rx_bufsize = IDPF_MIN_BUF_SIZE;
 	dev_info->max_rx_pktlen = IDPF_MAX_FRAME_SIZE;
 
+	dev_info->max_mtu = dev_info->max_rx_pktlen - IDPF_ETH_OVERHEAD;
+	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
+
 	dev_info->flow_type_rss_offloads = IDPF_RSS_OFFLOAD_ALL;
 	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
 	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
@@ -131,6 +136,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)
 {
@@ -429,6 +446,13 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	vport->stopped = 0;
 
+	if (dev->data->mtu > vport->max_mtu) {
+		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
+		goto err_mtu;
+	}
+
+	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
+
 	if (idpf_start_queues(dev)) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
 		goto err_mtu;
Signature · 1 line
2.34.1
#359 lore raw

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

In reply to Junfeng Guo

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

---
 drivers/net/idpf/idpf_ethdev.c | 119 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h |   8 +++
 drivers/net/idpf/idpf_vchnl.c  | 107 +++++++++++++++++++++++++++++
 3 files changed, 234 insertions(+)
drivers/net/idpf/idpf_ethdev.c +119 -0
index 803c0d7e12..ac70c029b0 100644
@@ -404,6 +404,90 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static int
+idpf_config_rx_queues_irqs(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	struct virtchnl2_queue_vector *qv_map;
+	struct 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) {
+		PMD_DRV_LOG(ERR, "Failed to allocate %d queue-vector map",
+			    dev->data->nb_rx_queues);
+		goto qv_map_alloc_err;
+	}
+
+	/* Rx interrupt disabled, Map interrupt only for writeback */
+
+	/* The capability flags adapter->caps->other_caps here should be
+	 * compared with bit VIRTCHNL2_CAP_WB_ON_ITR. The if condition should
+	 * be updated when the FW can return correct flag bits.
+	 */
+	if (adapter->caps->other_caps) {
+		dynctl_reg_start =
+			vport->recv_vectors->vchunks.vchunks->dynctl_reg_start;
+		itrn_reg_start =
+			vport->recv_vectors->vchunks.vchunks->itrn_reg_start;
+		dynctl_val = 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)
+			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)) {
+		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)
 {
@@ -441,6 +525,10 @@ static int
 idpf_dev_start(struct rte_eth_dev *dev)
 {
 	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	uint16_t num_allocated_vectors =
+		adapter->caps->num_allocated_vectors;
+	uint16_t req_vecs_num;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -453,6 +541,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)) {
+		PMD_DRV_LOG(ERR, "Failed to allocate interrupt vectors");
+		goto err_mtu;
+	}
+	adapter->used_vecs_num += req_vecs_num;
+
+	if (idpf_config_rx_queues_irqs(dev)) {
+		PMD_DRV_LOG(ERR, "Failed to configure irqs");
+		goto err_mtu;
+	}
+
 	if (idpf_start_queues(dev)) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
 		goto err_mtu;
@@ -489,6 +594,12 @@ idpf_dev_stop(struct rte_eth_dev *dev)
 
 	idpf_stop_queues(dev);
 
+	if (idpf_vc_config_irq_map_unmap(vport, false))
+		PMD_DRV_LOG(ERR, "config interrupt unmapping failed");
+
+	if (idpf_vc_dealloc_vectors(vport))
+		PMD_DRV_LOG(ERR, "deallocate interrupt vectors failed");
+
 	vport->stopped = 1;
 	dev->data->dev_started = 0;
 
@@ -513,6 +624,12 @@ idpf_dev_close(struct rte_eth_dev *dev)
 	rte_free(vport->rss_key);
 	vport->rss_key = NULL;
 
+	rte_free(vport->recv_vectors);
+	vport->recv_vectors = NULL;
+
+	rte_free(vport->qv_map);
+	vport->qv_map = NULL;
+
 	adapter->cur_vports &= ~BIT(vport->devarg_id);
 
 	rte_free(vport);
@@ -864,6 +981,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 +8 -0
index bba8223cc4..505b3f36e3 100644
@@ -130,6 +130,11 @@ struct idpf_vport {
 	uint8_t *rss_key;
 	uint64_t rss_hf;
 
+	/* MSIX info*/
+	struct virtchnl2_queue_vector *qv_map; /* queue vector mapping */
+	uint16_t max_vectors;
+	struct virtchnl2_alloc_vectors *recv_vectors;
+
 	/* Chunk info */
 	struct idpf_chunks_info chunks_info;
 
@@ -248,6 +253,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 +107 -0

113 lines not on this page · raw message

Signature · 1 line
2.34.1
#360 lore raw

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

In reply to Junfeng Guo

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

---
 doc/guides/nics/idpf.rst                |  20 +
 drivers/net/idpf/idpf_ethdev.h          |   5 +
 drivers/net/idpf/idpf_rxtx.c            | 144 ++++
 drivers/net/idpf/idpf_rxtx.h            |   7 +
 drivers/net/idpf/idpf_rxtx_vec_avx512.c | 871 ++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx_vec_common.h | 100 +++
 drivers/net/idpf/meson.build            |  28 +
 7 files changed, 1175 insertions(+)
 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 +20 -0
index 84b21e7be0..8f81894e27 100644
@@ -72,3 +72,23 @@ Driver compilation and testing
 
 Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and_test>`
 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.h +5 -0
index 505b3f36e3..9b0de772c9 100644
@@ -182,6 +182,11 @@ struct idpf_adapter {
 	uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned;
 
 	bool stopped;
+
+	bool rx_vec_allowed;
+	bool tx_vec_allowed;
+	bool rx_use_avx512;
+	bool tx_use_avx512;
 };
 
 TAILQ_HEAD(idpf_adapter_list, idpf_adapter);
drivers/net/idpf/idpf_rxtx.c +144 -0

179 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +7 -0
index a2394ffa2c..8f440557bd 100644
@@ -211,12 +211,19 @@ uint16_t idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 				uint16_t nb_pkts);
 uint16_t idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 			       uint16_t nb_pkts);
+uint16_t idpf_singleq_recv_pkts_avx512(void *rx_queue, struct rte_mbuf **rx_pkts,
+				       uint16_t nb_pkts);
 uint16_t idpf_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 				uint16_t nb_pkts);
 uint16_t idpf_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			       uint16_t nb_pkts);
+uint16_t idpf_singleq_xmit_pkts_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
+				       uint16_t nb_pkts);
+int idpf_singleq_tx_vec_setup_avx512(struct idpf_tx_queue *txq);
 uint16_t idpf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			uint16_t nb_pkts);
+int idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq);
+
 void idpf_stop_queues(struct rte_eth_dev *dev);
 
 void idpf_set_rx_function(struct rte_eth_dev *dev);
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +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 832f887296..c96e4bfcaa 100644
@@ -15,3 +15,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_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
#361 lore raw

PATCH v4 14/14 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      | 57 ++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h      | 90 +++++++++++++++++++++++++++++++
 5 files changed, 155 insertions(+), 1 deletion(-)
doc/guides/nics/features/idpf.ini +1 -0
index ee3f6e7c6f..145d995f51 100644
@@ -14,6 +14,7 @@ MTU update           = Y
 TSO                  = P
 L3 checksum offload  = P
 L4 checksum offload  = P
+Timestamp offload    = P
 Packet type parsing  = Y
 Multiprocess aware   = Y
 FreeBSD              = Y
drivers/net/idpf/idpf_ethdev.c +4 -1
index ac70c029b0..c3f628655c 100644
@@ -19,6 +19,8 @@
 struct idpf_adapter_list adapter_list;
 bool adapter_list_init;
 
+uint64_t idpf_timestamp_dynflag;
+
 static const char * const idpf_valid_args[] = {
 	IDPF_TX_SINGLE_Q,
 	IDPF_RX_SINGLE_Q,
@@ -97,7 +99,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		RTE_ETH_RX_OFFLOAD_UDP_CKSUM		|
 		RTE_ETH_RX_OFFLOAD_TCP_CKSUM		|
 		RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM	|
-		RTE_ETH_RX_OFFLOAD_RSS_HASH;
+		RTE_ETH_RX_OFFLOAD_RSS_HASH		|
+		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 9b0de772c9..49919e5c74 100644
@@ -187,6 +187,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 +57 -0

120 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
#362 lore raw

PATCH v3 2/15 net/idpf: add support for device initialization

In reply to Junfeng Guo

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

---
 MAINTAINERS                            |   9 +
 doc/guides/nics/features/idpf.ini      |  15 +
 doc/guides/nics/idpf.rst               |  52 ++
 doc/guides/nics/index.rst              |   1 +
 doc/guides/rel_notes/release_22_11.rst |   5 +
 drivers/net/idpf/idpf_ethdev.c         | 753 +++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h         | 198 +++++++
 drivers/net/idpf/idpf_logs.h           |  42 ++
 drivers/net/idpf/idpf_vchnl.c          | 495 ++++++++++++++++
 drivers/net/idpf/meson.build           |  16 +
 drivers/net/idpf/version.map           |   3 +
 drivers/net/meson.build                |   1 +
 12 files changed, 1590 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 2bd4a55f1b..e2d9c2ac50 100644
@@ -758,6 +758,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 +15 -0
new file mode 100644
index 0000000000..9900e23364
@@ -0,0 +1,15 @@
+;
+; 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]
+Multiprocess aware   = Y
+FreeBSD              = Y
+Linux                = Y
+Windows              = Y
+x86-32               = Y
+x86-64               = Y
\ No newline at end of file
doc/guides/nics/idpf.rst new file +52 -0

52 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 +5 -0
index 2da8bc9661..16e7f39ce9 100644
@@ -236,6 +236,11 @@ New Features
 
      strings $dpdk_binary_or_driver | sed -n 's/^PMD_INFO_STRING= //p'
 
+* **Added IDPF PMD.**
+
+  Added the new ``idpf`` net driver for Intel® IPU Ethernet ES2000 Series.
+  See the :doc:`../nics/idpf` NIC guide for more details on this new driver.
+
 
 Removed Items
 -------------
drivers/net/idpf/idpf_ethdev.c new file +753 -0

753 lines not on this page · raw message

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

198 lines not on this page · raw message

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

42 lines not on this page · raw message

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

495 lines not on this page · raw message

drivers/net/idpf/meson.build new file +16 -0
new file mode 100644
index 0000000000..bf8bf58ef5
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
+includes += include_directories('../../common/idpf')
+deps += ['common_idpf', 'security', 'cryptodev']
+
+sources = files(
+    'idpf_ethdev.c',
+    'idpf_vchnl.c',
+)
drivers/net/idpf/version.map new file +3 -0
new file mode 100644
index 0000000000..c2e0723b4c
@@ -0,0 +1,3 @@
+DPDK_22 {
+	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
#363 lore raw

PATCH v3 3/15 net/idpf: add queue setup and release in single queue model

In reply to Junfeng Guo

Add support for queue operations in single queue model:
- rx_queue_setup
- rx_queue_release
- tx_queue_setup
- tx_queue_release

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.

---
 doc/guides/nics/features/idpf.ini |   2 +
 doc/guides/nics/idpf.rst          |  22 ++
 drivers/net/idpf/idpf_ethdev.c    |  58 ++++
 drivers/net/idpf/idpf_ethdev.h    |   9 +
 drivers/net/idpf/idpf_rxtx.c      | 463 ++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h      | 186 ++++++++++++
 drivers/net/idpf/idpf_vchnl.c     | 249 ++++++++++++++++
 drivers/net/idpf/meson.build      |   1 +
 8 files changed, 990 insertions(+)
 create mode 100644 drivers/net/idpf/idpf_rxtx.c
 create mode 100644 drivers/net/idpf/idpf_rxtx.h
doc/guides/nics/features/idpf.ini +2 -0
index 9900e23364..7cfcb60bd0 100644
@@ -7,6 +7,8 @@
 ; is selected.
 ;
 [Features]
+Runtime Rx queue setup = Y
+Runtime Tx queue setup = Y
 Multiprocess aware   = Y
 FreeBSD              = Y
 Linux                = Y
doc/guides/nics/idpf.rst +22 -0
index 417d6b690e..af7810834a 100644
@@ -45,6 +45,28 @@ Runtime Config Options
   Then idpf PMD will create 3 vports (ethdevs) for device ca:00.0.
   NOTE: This parameter is MUST, otherwise there'll be no any ethdev created.
 
+- ``rx_single`` (defalut ``0``)
+
+  There're two queue modes supported by Intel® IPU Ethernet ES2000 Series, single queue
+  mode and split queue mode for Rx queue. User can choose Rx queue mode by the ``devargs``
+  parameter ``rx_single``.
+
+    -a ca:00.0,rx_single=1
+
+  Then idpf PMD will configure Rx queue with single queue mode. Otherwise, split queue
+  mode is chosen by default.
+
+- ``tx_single`` (defalut ``0``)
+
+  There're two queue modes supported by Intel® IPU Ethernet ES2000 Series, single queue
+  mode and split queue mode for Tx queue. User can choose Tx queue mode by the ``devargs``
+  parameter ``tx_single``.
+
+    -a ca:00.0,tx_single=1
+
+  Then idpf PMD will configure Tx queue with single queue mode. Otherwise, split queue
+  mode is chosen by default.
+
 Driver compilation and testing
 ------------------------------
 
drivers/net/idpf/idpf_ethdev.c +58 -0

107 lines not on this page · raw message

drivers/net/idpf/idpf_ethdev.h +9 -0
index d00ee12364..d90bcfa63a 100644
@@ -83,6 +83,8 @@ struct idpf_chunks_info {
 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;
 	uint16_t num_rx_q;
 
@@ -114,6 +116,9 @@ struct idpf_adapter {
 	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;
+	uint32_t rxq_model;
+
 	/* Vport info */
 	uint8_t **vport_req_info;
 	uint8_t **vport_recv_info;
@@ -191,6 +196,10 @@ 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 rte_eth_dev *dev);
 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_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 new file +463 -0

463 lines not on this page · raw message

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

186 lines not on this page · raw message

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

261 lines not on this page · raw message

drivers/net/idpf/meson.build +1 -0
index bf8bf58ef5..832f887296 100644
@@ -12,5 +12,6 @@ deps += ['common_idpf', 'security', 'cryptodev']
 
 sources = files(
     'idpf_ethdev.c',
+    'idpf_rxtx.c',
     'idpf_vchnl.c',
 )
Signature · 1 line
2.34.1
#364 lore raw

PATCH v3 4/15 net/idpf: add queue setup and release in split queue model

In reply to Junfeng Guo

Add support for queue operations in split queue model:
- rx_queue_setup
- rx_queue_release
- tx_queue_setup
- tx_queue_release

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 |  34 ++-
 drivers/net/idpf/idpf_ethdev.h |  11 +
 drivers/net/idpf/idpf_rxtx.c   | 485 ++++++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_vchnl.c  | 127 ++++++++-
 4 files changed, 644 insertions(+), 13 deletions(-)
drivers/net/idpf/idpf_ethdev.c +32 -2
index c0a6b3e90d..21520fa648 100644
@@ -69,13 +69,25 @@ idpf_init_vport_req_info(struct rte_eth_dev *dev)
 		(struct virtchnl2_create_vport *)adapter->vport_req_info[idx];
 
 	vport_info->vport_type = rte_cpu_to_le_16(VIRTCHNL2_VPORT_TYPE_DEFAULT);
-	if (adapter->txq_model) {
+	if (!adapter->txq_model) {
+		vport_info->txq_model =
+			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SPLIT);
+		vport_info->num_tx_q = IDPF_DEFAULT_TXQ_NUM;
+		vport_info->num_tx_complq =
+			IDPF_DEFAULT_TXQ_NUM * IDPF_TX_COMPLQ_PER_GRP;
+	} else {
 		vport_info->txq_model =
 			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SINGLE);
 		vport_info->num_tx_q = IDPF_DEFAULT_TXQ_NUM;
 		vport_info->num_tx_complq = 0;
 	}
-	if (adapter->rxq_model) {
+	if (!adapter->rxq_model) {
+		vport_info->rxq_model =
+			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SPLIT);
+		vport_info->num_rx_q = IDPF_DEFAULT_RXQ_NUM;
+		vport_info->num_rx_bufq =
+			IDPF_DEFAULT_RXQ_NUM * IDPF_RX_BUFQ_PER_GRP;
+	} else {
 		vport_info->rxq_model =
 			rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SINGLE);
 		vport_info->num_rx_q = IDPF_DEFAULT_RXQ_NUM;
@@ -113,7 +125,9 @@ idpf_init_vport(struct rte_eth_dev *dev)
 	vport->txq_model = vport_info->txq_model;
 	vport->rxq_model = vport_info->rxq_model;
 	vport->num_tx_q = vport_info->num_tx_q;
+	vport->num_tx_complq = vport_info->num_tx_complq;
 	vport->num_rx_q = vport_info->num_rx_q;
+	vport->num_rx_bufq = vport_info->num_rx_bufq;
 	vport->max_mtu = vport_info->max_mtu;
 	rte_memcpy(vport->default_mac_addr,
 		   vport_info->default_mac_addr, ETH_ALEN);
@@ -136,6 +150,22 @@ idpf_init_vport(struct rte_eth_dev *dev)
 				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;
 		}
 	}
 
drivers/net/idpf/idpf_ethdev.h +11 -0
index d90bcfa63a..9f8fcba4ca 100644
@@ -73,11 +73,18 @@ enum idpf_vc_result {
 struct idpf_chunks_info {
 	uint32_t tx_start_qid;
 	uint32_t rx_start_qid;
+	/* Valid only if split queue model */
+	uint32_t tx_compl_start_qid;
+	uint32_t rx_buf_start_qid;
 
 	uint64_t tx_qtail_start;
 	uint32_t tx_qtail_spacing;
 	uint64_t rx_qtail_start;
 	uint32_t rx_qtail_spacing;
+	uint64_t tx_compl_qtail_start;
+	uint32_t tx_compl_qtail_spacing;
+	uint64_t rx_buf_qtail_start;
+	uint32_t rx_buf_qtail_spacing;
 };
 
 struct idpf_vport {
@@ -86,7 +93,11 @@ struct idpf_vport {
 	uint32_t txq_model;
 	uint32_t rxq_model;
 	uint16_t num_tx_q;
+	/* valid only if txq_model is split Q */
+	uint16_t num_tx_complq;
 	uint16_t num_rx_q;
+	/* valid only if rxq_model is split Q */
+	uint16_t num_rx_bufq;
 
 	uint16_t max_mtu;
 	uint8_t default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
drivers/net/idpf/idpf_rxtx.c +482 -3

527 lines not on this page · raw message

drivers/net/idpf/idpf_vchnl.c +119 -8

171 lines not on this page · raw message

Signature · 1 line
2.34.1
#365 lore raw

PATCH v3 5/15 net/idpf: add support for queue start and stop

In reply to Junfeng Guo

Add support for queue operations:
- rx_queue_start
- rx_queue_stop
- tx_queue_start
- tx_queue_stop

---
 doc/guides/nics/features/idpf.ini |   1 +
 drivers/net/idpf/idpf_ethdev.c    |  46 +++++
 drivers/net/idpf/idpf_ethdev.h    |   3 +
 drivers/net/idpf/idpf_rxtx.c      | 309 ++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h      |   6 +
 drivers/net/idpf/idpf_vchnl.c     | 150 +++++++++++++++
 6 files changed, 515 insertions(+)
doc/guides/nics/features/idpf.ini +1 -0
index 7cfcb60bd0..ffcb7caa0f 100644
@@ -7,6 +7,7 @@
 ; is selected.
 ;
 [Features]
+Queue start/stop     = Y
 Runtime Rx queue setup = Y
 Runtime Tx queue setup = Y
 Multiprocess aware   = Y
drivers/net/idpf/idpf_ethdev.c +46 -0

76 lines not on this page · raw message

drivers/net/idpf/idpf_ethdev.h +3 -0
index 9f8fcba4ca..c03b051f87 100644
@@ -211,6 +211,9 @@ 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 +309 -0

318 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +6 -0
index 69a1fa6348..f0427b96c5 100644
@@ -175,12 +175,18 @@ int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 			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);
 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_ */
drivers/net/idpf/idpf_vchnl.c +150 -0

156 lines not on this page · raw message

Signature · 1 line
2.34.1
#366 lore raw

PATCH v3 6/15 net/idpf: add support for device information get

In reply to Junfeng Guo

Add dev ops dev_infos_get.

---
 drivers/net/idpf/idpf_ethdev.c | 50 ++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
drivers/net/idpf/idpf_ethdev.c +50 -0
index b4923faa5f..7ae52a68b2 100644
@@ -30,6 +30,8 @@ static int idpf_dev_configure(struct rte_eth_dev *dev);
 static int idpf_dev_start(struct rte_eth_dev *dev);
 static int idpf_dev_stop(struct rte_eth_dev *dev);
 static int idpf_dev_close(struct rte_eth_dev *dev);
+static int idpf_dev_info_get(struct rte_eth_dev *dev,
+			     struct rte_eth_dev_info *dev_info);
 static void idpf_adapter_rel(struct idpf_adapter *adapter);
 
 static const struct eth_dev_ops idpf_eth_dev_ops = {
@@ -45,8 +47,56 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.rx_queue_release		= idpf_dev_rx_queue_release,
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.tx_queue_release		= idpf_dev_tx_queue_release,
+	.dev_infos_get			= idpf_dev_info_get,
 };
 
+static int
+idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+
+	dev_info->max_rx_queues = adapter->caps->max_rx_q;
+	dev_info->max_tx_queues = adapter->caps->max_tx_q;
+	dev_info->min_rx_bufsize = IDPF_MIN_BUF_SIZE;
+	dev_info->max_rx_pktlen = IDPF_MAX_FRAME_SIZE;
+
+	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
+	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
+		RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
+
+	dev_info->default_rxconf = (struct rte_eth_rxconf) {
+		.rx_free_thresh = IDPF_DEFAULT_RX_FREE_THRESH,
+		.rx_drop_en = 0,
+		.offloads = 0,
+	};
+
+	dev_info->default_txconf = (struct rte_eth_txconf) {
+		.tx_free_thresh = IDPF_DEFAULT_TX_FREE_THRESH,
+		.tx_rs_thresh = IDPF_DEFAULT_TX_RS_THRESH,
+		.offloads = 0,
+	};
+
+	dev_info->rx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = IDPF_MAX_RING_DESC,
+		.nb_min = IDPF_MIN_RING_DESC,
+		.nb_align = IDPF_ALIGN_RING_DESC,
+	};
+
+	dev_info->tx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = IDPF_MAX_RING_DESC,
+		.nb_min = IDPF_MIN_RING_DESC,
+		.nb_align = IDPF_ALIGN_RING_DESC,
+	};
+
+	dev_info->default_rxportconf.burst_size = IDPF_RX_MAX_BURST;
+	dev_info->default_txportconf.burst_size = IDPF_TX_MAX_BURST;
+	dev_info->default_rxportconf.nb_queues = 1;
+	dev_info->default_txportconf.nb_queues = 1;
+
+	return 0;
+}
+
 static int
 idpf_init_vport_req_info(struct rte_eth_dev *dev)
 {
Signature · 1 line
2.34.1
#367 lore raw

PATCH v3 7/15 net/idpf: add support for packet type get

In reply to Junfeng Guo

Add dev ops dev_supported_ptypes_get.

---
 doc/guides/nics/features/idpf.ini |   1 +
 drivers/net/idpf/idpf_ethdev.c    |   7 +
 drivers/net/idpf/idpf_ethdev.h    |   2 +
 drivers/net/idpf/idpf_rxtx.c      |  19 +++
 drivers/net/idpf/idpf_rxtx.h      |   6 +
 drivers/net/idpf/idpf_vchnl.c     | 235 ++++++++++++++++++++++++++++++
 6 files changed, 270 insertions(+)
doc/guides/nics/features/idpf.ini +1 -0
index ffcb7caa0f..f1849cd821 100644
@@ -10,6 +10,7 @@
 Queue start/stop     = Y
 Runtime Rx queue setup = Y
 Runtime Tx queue setup = Y
+Packet type parsing  = Y
 Multiprocess aware   = Y
 FreeBSD              = Y
 Linux                = Y
drivers/net/idpf/idpf_ethdev.c +7 -0
index 7ae52a68b2..10ae5f14f1 100644
@@ -35,6 +35,7 @@ static int idpf_dev_info_get(struct rte_eth_dev *dev,
 static void idpf_adapter_rel(struct idpf_adapter *adapter);
 
 static const struct eth_dev_ops idpf_eth_dev_ops = {
+	.dev_supported_ptypes_get	= idpf_dev_supported_ptypes_get,
 	.dev_configure			= idpf_dev_configure,
 	.dev_start			= idpf_dev_start,
 	.dev_stop			= idpf_dev_stop,
@@ -631,6 +632,12 @@ idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter *adapter)
 		goto err_api;
 	}
 
+	ret = idpf_get_pkt_type(adapter);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to set ptype table");
+		goto err_api;
+	}
+
 	adapter->caps = rte_zmalloc("idpf_caps",
 				sizeof(struct virtchnl2_get_capabilities), 0);
 	if (!adapter->caps) {
drivers/net/idpf/idpf_ethdev.h +2 -0
index c03b051f87..64da6fd2a5 100644
@@ -204,6 +204,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 rte_eth_dev *dev);
 int idpf_vc_destroy_vport(struct idpf_vport *vport);
@@ -215,6 +216,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 +19 -0
index c525e9b4c9..846e1cdfc6 100644
@@ -8,6 +8,25 @@
 #include "idpf_ethdev.h"
 #include "idpf_rxtx.h"
 
+const uint32_t *
+idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)
+{
+	static const uint32_t ptypes[] = {
+		RTE_PTYPE_L2_ETHER,
+		RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
+		RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
+		RTE_PTYPE_L4_FRAG,
+		RTE_PTYPE_L4_NONFRAG,
+		RTE_PTYPE_L4_UDP,
+		RTE_PTYPE_L4_TCP,
+		RTE_PTYPE_L4_SCTP,
+		RTE_PTYPE_L4_ICMP,
+		RTE_PTYPE_UNKNOWN
+	};
+
+	return ptypes;
+}
+
 static inline int
 check_rx_thresh(uint16_t nb_desc, uint16_t thresh)
 {
drivers/net/idpf/idpf_rxtx.h +6 -0
index f0427b96c5..cd1dda4688 100644
@@ -47,6 +47,10 @@
 #define IDPF_TX_OFFLOAD_NOTSUP_MASK \
 		(RTE_MBUF_F_TX_OFFLOAD_MASK ^ IDPF_TX_OFFLOAD_MASK)
 
+#define IDPF_GET_PTYPE_SIZE(p) \
+	(sizeof(struct virtchnl2_ptype) + \
+	(((p)->proto_id_count ? ((p)->proto_id_count - 1) : 0) * sizeof((p)->proto_id[0])))
+
 struct idpf_rx_queue {
 	struct idpf_adapter *adapter;	/* the adapter this queue belongs to */
 	struct rte_mempool *mp;		/* mbuf pool to populate Rx ring */
@@ -189,4 +193,6 @@ void idpf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 
 void idpf_stop_queues(struct rte_eth_dev *dev);
 
+const uint32_t *idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev);
+
 #endif /* _IDPF_RXTX_H_ */
drivers/net/idpf/idpf_vchnl.c +235 -0

244 lines not on this page · raw message

Signature · 1 line
2.34.1
#368 lore raw

PATCH v3 8/15 net/idpf: add support for link status update

In reply to Junfeng Guo

Add dev ops link_update.

---
 drivers/net/idpf/idpf_ethdev.c | 21 +++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h |  6 ++++++
 2 files changed, 27 insertions(+)
drivers/net/idpf/idpf_ethdev.c +21 -0
index 10ae5f14f1..ff0833b462 100644
@@ -34,6 +34,26 @@ 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_supported_ptypes_get	= idpf_dev_supported_ptypes_get,
 	.dev_configure			= idpf_dev_configure,
@@ -49,6 +69,7 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
 	.tx_queue_setup			= idpf_tx_queue_setup,
 	.tx_queue_release		= idpf_dev_tx_queue_release,
 	.dev_infos_get			= idpf_dev_info_get,
+	.link_update			= idpf_dev_link_update,
 };
 
 static int
drivers/net/idpf/idpf_ethdev.h +6 -0
index 64da6fd2a5..863d163330 100644
@@ -110,6 +110,10 @@ struct idpf_vport {
 	/* Chunk info */
 	struct idpf_chunks_info chunks_info;
 
+	/* Event from ipf */
+	bool link_up;
+	uint32_t link_speed;
+
 	uint16_t devarg_id;
 	bool stopped;
 	struct virtchnl2_vport_stats eth_stats_offset;
@@ -202,6 +206,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_get_pkt_type(struct idpf_adapter *adapter);
Signature · 1 line
2.34.1
#369 lore raw

PATCH v3 9/15 net/idpf: add support for basic Rx/Tx datapath

In reply to Junfeng Guo

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

---
 drivers/net/idpf/idpf_ethdev.c |   8 +-
 drivers/net/idpf/idpf_rxtx.c   | 671 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  16 +-
 3 files changed, 691 insertions(+), 4 deletions(-)
drivers/net/idpf/idpf_ethdev.c +7 -1
index ff0833b462..c6a2c85f17 100644
@@ -313,6 +313,9 @@ idpf_dev_start(struct rte_eth_dev *dev)
 		goto err_mtu;
 	}
 
+	idpf_set_rx_function(dev);
+	idpf_set_tx_function(dev);
+
 	if (idpf_vc_ena_dis_vport(vport, true)) {
 		PMD_DRV_LOG(ERR, "Failed to enable vport");
 		goto err_vport;
@@ -764,8 +767,11 @@ idpf_dev_init(struct rte_eth_dev *dev, void *init_params)
 	/* for secondary processes, we don't initialise any further as primary
 	 * has already done this work.
 	 */
-	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		idpf_set_rx_function(dev);
+		idpf_set_tx_function(dev);
 		return ret;
+	}
 
 	dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
 
drivers/net/idpf/idpf_rxtx.c +671 -0

674 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +13 -3
index cd1dda4688..bd3ebe2f50 100644
@@ -44,9 +44,6 @@
 #define IDPF_MAX_TSO_FRAME_SIZE	262143
 #define IDPF_TX_MAX_MTU_SEG     10
 
-#define IDPF_TX_OFFLOAD_NOTSUP_MASK \
-		(RTE_MBUF_F_TX_OFFLOAD_MASK ^ IDPF_TX_OFFLOAD_MASK)
-
 #define IDPF_GET_PTYPE_SIZE(p) \
 	(sizeof(struct virtchnl2_ptype) + \
 	(((p)->proto_id_count ? ((p)->proto_id_count - 1) : 0) * sizeof((p)->proto_id[0])))
@@ -191,8 +188,21 @@ int idpf_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 int idpf_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 void idpf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 
+uint16_t idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+				uint16_t nb_pkts);
+uint16_t idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+			       uint16_t nb_pkts);
+uint16_t idpf_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+				uint16_t nb_pkts);
+uint16_t idpf_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+			       uint16_t nb_pkts);
+uint16_t idpf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+			uint16_t nb_pkts);
 void idpf_stop_queues(struct rte_eth_dev *dev);
 
+void idpf_set_rx_function(struct rte_eth_dev *dev);
+void idpf_set_tx_function(struct rte_eth_dev *dev);
+
 const uint32_t *idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
 #endif /* _IDPF_RXTX_H_ */
Signature · 1 line
2.34.1
#370 lore raw

PATCH v3 10/15 net/idpf: add support for Rx/Tx offloading

In reply to Junfeng Guo

Add Rx/Tx offloading support, including TSO and CHKSUM.

---
 doc/guides/nics/features/idpf.ini |   3 +
 drivers/net/idpf/idpf_ethdev.c    |  10 ++
 drivers/net/idpf/idpf_rxtx.c      | 237 +++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_rxtx.h      |  19 +++
 4 files changed, 267 insertions(+), 2 deletions(-)
doc/guides/nics/features/idpf.ini +3 -0
index f1849cd821..23953c384d 100644
@@ -10,6 +10,9 @@
 Queue start/stop     = Y
 Runtime Rx queue setup = Y
 Runtime Tx queue setup = Y
+TSO                  = P
+L3 checksum offload  = P
+L4 checksum offload  = P
 Packet type parsing  = Y
 Multiprocess aware   = Y
 FreeBSD              = Y
drivers/net/idpf/idpf_ethdev.c +10 -0
index c6a2c85f17..d09de4075c 100644
@@ -86,6 +86,16 @@ 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->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
 		RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
+	dev_info->rx_offload_capa =
+		RTE_ETH_RX_OFFLOAD_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_TCP_TSO		|
+		RTE_ETH_TX_OFFLOAD_MULTI_SEGS		|
+		RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
 	dev_info->default_rxconf = (struct rte_eth_rxconf) {
 		.rx_free_thresh = IDPF_DEFAULT_RX_FREE_THRESH,
drivers/net/idpf/idpf_rxtx.c +235 -2

357 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +19 -0
index bd3ebe2f50..a2394ffa2c 100644
@@ -44,6 +44,25 @@
 #define IDPF_MAX_TSO_FRAME_SIZE	262143
 #define IDPF_TX_MAX_MTU_SEG     10
 
+#define IDPF_TX_CKSUM_OFFLOAD_MASK (		\
+		RTE_MBUF_F_TX_IP_CKSUM |	\
+		RTE_MBUF_F_TX_L4_MASK |		\
+		RTE_MBUF_F_TX_TCP_SEG)
+
+#define IDPF_TX_OFFLOAD_MASK (			\
+		RTE_MBUF_F_TX_OUTER_IPV6 |	\
+		RTE_MBUF_F_TX_OUTER_IPV4 |	\
+		RTE_MBUF_F_TX_IPV6 |		\
+		RTE_MBUF_F_TX_IPV4 |		\
+		RTE_MBUF_F_TX_VLAN |		\
+		RTE_MBUF_F_TX_IP_CKSUM |	\
+		RTE_MBUF_F_TX_L4_MASK |		\
+		RTE_MBUF_F_TX_TCP_SEG |		\
+		RTE_ETH_TX_OFFLOAD_SECURITY)
+
+#define IDPF_TX_OFFLOAD_NOTSUP_MASK \
+		(RTE_MBUF_F_TX_OFFLOAD_MASK ^ IDPF_TX_OFFLOAD_MASK)
+
 #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])))
Signature · 1 line
2.34.1
#371 lore raw

PATCH v3 11/15 net/idpf: add support for RSS

In reply to Junfeng Guo

Add RSS support.

---
 drivers/net/idpf/idpf_ethdev.c | 123 ++++++++++++++++++++++++++++++++-
 drivers/net/idpf/idpf_ethdev.h |  26 +++++++
 drivers/net/idpf/idpf_rxtx.c   |  27 ++++++++
 drivers/net/idpf/idpf_vchnl.c  |  96 +++++++++++++++++++++++++
 4 files changed, 269 insertions(+), 3 deletions(-)
drivers/net/idpf/idpf_ethdev.c +120 -3
index d09de4075c..d89a3f2312 100644
@@ -83,6 +83,7 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->min_rx_bufsize = IDPF_MIN_BUF_SIZE;
 	dev_info->max_rx_pktlen = IDPF_MAX_FRAME_SIZE;
 
+	dev_info->flow_type_rss_offloads = IDPF_RSS_OFFLOAD_ALL;
 	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
 	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
 		RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
@@ -90,7 +91,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_RSS_HASH;
 
 	dev_info->tx_offload_capa =
 		RTE_ETH_TX_OFFLOAD_TCP_TSO		|
@@ -197,6 +199,10 @@ idpf_parse_devarg_id(char *name)
 	return val;
 }
 
+#ifndef IDPF_RSS_KEY_LEN
+#define IDPF_RSS_KEY_LEN 52
+#endif
+
 static int
 idpf_init_vport(struct rte_eth_dev *dev)
 {
@@ -217,6 +223,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++) {
@@ -265,15 +275,116 @@ idpf_init_vport(struct rte_eth_dev *dev)
 }
 
 static int
-idpf_dev_configure(__rte_unused struct rte_eth_dev *dev)
+idpf_config_rss(struct idpf_vport *vport)
+{
+	int ret;
+
+	ret = idpf_vc_set_rss_key(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS key");
+		return ret;
+	}
+
+	ret = idpf_vc_set_rss_lut(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS lut");
+		return ret;
+	}
+
+	ret = idpf_vc_set_rss_hash(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS hash");
+		return ret;
+	}
+
+	return ret;
+}
+
+static int
+idpf_init_rss(struct idpf_vport *vport)
+{
+	struct rte_eth_rss_conf *rss_conf;
+	uint16_t i, nb_q, lut_size;
+	int ret = 0;
+
+	rss_conf = &vport->dev_data->dev_conf.rx_adv_conf.rss_conf;
+	nb_q = vport->dev_data->nb_rx_queues;
+
+	vport->rss_key = (uint8_t *)rte_zmalloc("rss_key",
+					     vport->rss_key_size, 0);
+	if (!vport->rss_key) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS key");
+		ret = -ENOMEM;
+		goto err_key;
+	}
+
+	lut_size = vport->rss_lut_size;
+	vport->rss_lut = (uint32_t *)rte_zmalloc("rss_lut",
+					      sizeof(uint32_t) * lut_size, 0);
+	if (!vport->rss_lut) {
+		PMD_INIT_LOG(ERR, "Failed to allocate RSS lut");
+		ret = -ENOMEM;
+		goto err_lut;
+	}
+
+	if (!rss_conf->rss_key) {
+		for (i = 0; i < vport->rss_key_size; i++)
+			vport->rss_key[i] = (uint8_t)rte_rand();
+	} else {
+		rte_memcpy(vport->rss_key, rss_conf->rss_key,
+			   RTE_MIN(rss_conf->rss_key_len,
+				   vport->rss_key_size));
+	}
+
+	for (i = 0; i < lut_size; i++)
+		vport->rss_lut[i] = i % nb_q;
+
+	vport->rss_hf = IDPF_DEFAULT_RSS_HASH_EXPANDED;
+
+	ret = idpf_config_rss(vport);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to configure RSS");
+		goto err_cfg;
+	}
+
+	return ret;
+
+err_cfg:
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+err_lut:
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+err_key:
+	return ret;
+}
+
+static int
+idpf_dev_configure(struct rte_eth_dev *dev)
 {
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	int ret = 0;
+
 	if (dev->data->nb_tx_queues > IDPF_DEFAULT_TXQ_NUM ||
 	    dev->data->nb_rx_queues > IDPF_DEFAULT_RXQ_NUM) {
 		PMD_INIT_LOG(ERR, "Invalid queue number.");
 		return -EINVAL;
 	}
 
-	return 0;
+	if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+		dev->data->dev_conf.rxmode.offloads |=
+			RTE_ETH_RX_OFFLOAD_RSS_HASH;
+
+	if (adapter->caps->rss_caps) {
+		ret = idpf_init_rss(vport);
+		if (ret) {
+			PMD_INIT_LOG(ERR, "Failed to init rss");
+			return ret;
+		}
+	}
+
+	return ret;
 }
 
 static int
@@ -372,6 +483,12 @@ idpf_dev_close(struct rte_eth_dev *dev)
 	idpf_dev_stop(dev);
 	idpf_vc_destroy_vport(vport);
 
+	rte_free(vport->rss_lut);
+	vport->rss_lut = NULL;
+
+	rte_free(vport->rss_key);
+	vport->rss_key = NULL;
+
 	adapter->cur_vports &= ~BIT(vport->devarg_id);
 
 	rte_free(vport);
drivers/net/idpf/idpf_ethdev.h +26 -0
index 863d163330..bba8223cc4 100644
@@ -56,6 +56,20 @@
 #define IDPF_ETH_OVERHEAD \
 	(RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + IDPF_VLAN_TAG_SIZE * 2)
 
+#define IDPF_RSS_OFFLOAD_ALL ( \
+	RTE_ETH_RSS_IPV4		| \
+	RTE_ETH_RSS_FRAG_IPV4		| \
+	RTE_ETH_RSS_NONFRAG_IPV4_TCP	| \
+	RTE_ETH_RSS_NONFRAG_IPV4_UDP	| \
+	RTE_ETH_RSS_NONFRAG_IPV4_SCTP	| \
+	RTE_ETH_RSS_NONFRAG_IPV4_OTHER	| \
+	RTE_ETH_RSS_IPV6		| \
+	RTE_ETH_RSS_FRAG_IPV6		| \
+	RTE_ETH_RSS_NONFRAG_IPV6_TCP	| \
+	RTE_ETH_RSS_NONFRAG_IPV6_UDP	| \
+	RTE_ETH_RSS_NONFRAG_IPV6_SCTP	| \
+	RTE_ETH_RSS_NONFRAG_IPV6_OTHER)
+
 #ifndef ETH_ADDR_LEN
 #define ETH_ADDR_LEN		6
 #endif
@@ -102,11 +116,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;
+
 	/* Chunk info */
 	struct idpf_chunks_info chunks_info;
 
@@ -214,6 +237,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 rte_eth_dev *dev);
 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_rxtx.c +27 -0
index ff3b710f4d..00d941b3ba 100644
@@ -1310,6 +1310,32 @@ idpf_splitq_rx_csum_offload(uint8_t err)
 	return flags;
 }
 
+#define IDPF_RX_FLEX_DESC_ADV_HASH1_S	0
+#define IDPF_RX_FLEX_DESC_ADV_HASH2_S	16
+#define IDPF_RX_FLEX_DESC_ADV_HASH3_S	24
+
+static inline uint64_t
+idpf_splitq_rx_rss_offload(struct rte_mbuf *mb,
+			   volatile struct virtchnl2_rx_flex_desc_adv_nic_3 *rx_desc)
+{
+	uint8_t status_err0_qw0;
+	uint64_t flags = 0;
+
+	status_err0_qw0 = rx_desc->status_err0_qw0;
+
+	if (status_err0_qw0 & BIT(VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_RSS_VALID_S)) {
+		flags |= RTE_MBUF_F_RX_RSS_HASH;
+		mb->hash.rss = (rte_le_to_cpu_16(rx_desc->hash1) <<
+				IDPF_RX_FLEX_DESC_ADV_HASH1_S) |
+				((uint32_t)(rx_desc->ff2_mirrid_hash2.hash2) <<
+			 	IDPF_RX_FLEX_DESC_ADV_HASH2_S) |
+				((uint32_t)(rx_desc->hash3) <<
+			 	IDPF_RX_FLEX_DESC_ADV_HASH3_S);
+	}
+
+	return flags;
+}
+
 static void
 idpf_split_rx_bufq_refill(struct idpf_rx_queue *rx_bufq)
 {
@@ -1464,6 +1490,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 
 		status_err0_qw1 = rx_desc->status_err0_qw1;
 		pkt_flags = idpf_splitq_rx_csum_offload(status_err0_qw1);
+		pkt_flags |= idpf_splitq_rx_rss_offload(rxm, rx_desc);
 
 		rxm->ol_flags |= pkt_flags;
 
drivers/net/idpf/idpf_vchnl.c +96 -0

102 lines not on this page · raw message

Signature · 1 line
2.34.1
#372 lore raw

PATCH v3 12/15 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    | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)
doc/guides/nics/features/idpf.ini +1 -0
index 23953c384d..0123865fd3 100644
@@ -10,6 +10,7 @@
 Queue start/stop     = Y
 Runtime Rx queue setup = Y
 Runtime Tx queue setup = Y
+MTU update           = Y
 TSO                  = P
 L3 checksum offload  = P
 L4 checksum offload  = P
drivers/net/idpf/idpf_ethdev.c +24 -0
index d89a3f2312..cb6051be9c 100644
@@ -32,6 +32,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);
 
 int
@@ -70,6 +71,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
@@ -83,6 +85,9 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->min_rx_bufsize = IDPF_MIN_BUF_SIZE;
 	dev_info->max_rx_pktlen = IDPF_MAX_FRAME_SIZE;
 
+	dev_info->max_mtu = dev_info->max_rx_pktlen - IDPF_ETH_OVERHEAD;
+	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
+
 	dev_info->flow_type_rss_offloads = IDPF_RSS_OFFLOAD_ALL;
 	dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
 	dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
@@ -131,6 +136,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)
 {
@@ -429,6 +446,13 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	vport->stopped = 0;
 
+	if (dev->data->mtu > vport->max_mtu) {
+		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
+		goto err_mtu;
+	}
+
+	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
+
 	if (idpf_start_queues(dev)) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
 		goto err_mtu;
Signature · 1 line
2.34.1
#373 lore raw

PATCH v3 13/15 net/idpf: add support for write back based on ITR expire

In reply to Junfeng Guo

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

---
 drivers/net/idpf/idpf_ethdev.c | 119 +++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.h |   8 +++
 drivers/net/idpf/idpf_vchnl.c  | 107 +++++++++++++++++++++++++++++
 3 files changed, 234 insertions(+)
drivers/net/idpf/idpf_ethdev.c +119 -0
index cb6051be9c..4fe442135c 100644
@@ -404,6 +404,90 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static int
+idpf_config_rx_queues_irqs(struct rte_eth_dev *dev)
+{
+	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	struct virtchnl2_queue_vector *qv_map;
+	struct 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) {
+		PMD_DRV_LOG(ERR, "Failed to allocate %d queue-vector map",
+			    dev->data->nb_rx_queues);
+		goto qv_map_alloc_err;
+	}
+
+	/* Rx interrupt disabled, Map interrupt only for writeback */
+
+	/* The capability flags adapter->caps->other_caps here should be
+	 * compared with bit VIRTCHNL2_CAP_WB_ON_ITR. The if condition should
+	 * be updated when the FW can return correct flag bits.
+	 */
+	if (adapter->caps->other_caps) {
+		dynctl_reg_start =
+			vport->recv_vectors->vchunks.vchunks->dynctl_reg_start;
+		itrn_reg_start =
+			vport->recv_vectors->vchunks.vchunks->itrn_reg_start;
+		dynctl_val = 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 writen back based on ITR expiration irrespective
+		 * of INTENA setting.
+		 */
+		/* TBD: need to tune INTERVAL value for better performance. */
+		if (itrn_val)
+			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)) {
+		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)
 {
@@ -441,6 +525,10 @@ static int
 idpf_dev_start(struct rte_eth_dev *dev)
 {
 	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *adapter = vport->adapter;
+	uint16_t num_allocated_vectors =
+		adapter->caps->num_allocated_vectors;
+	uint16_t req_vecs_num;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -453,6 +541,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)) {
+		PMD_DRV_LOG(ERR, "Failed to allocate interrupt vectors");
+		goto err_mtu;
+	}
+	adapter->used_vecs_num += req_vecs_num;
+
+	if (idpf_config_rx_queues_irqs(dev)) {
+		PMD_DRV_LOG(ERR, "Failed to configure irqs");
+		goto err_mtu;
+	}
+
 	if (idpf_start_queues(dev)) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
 		goto err_mtu;
@@ -489,6 +594,12 @@ idpf_dev_stop(struct rte_eth_dev *dev)
 
 	idpf_stop_queues(dev);
 
+	if (idpf_vc_config_irq_map_unmap(vport, false))
+		PMD_DRV_LOG(ERR, "config interrupt unmapping failed");
+
+	if (idpf_vc_dealloc_vectors(vport))
+		PMD_DRV_LOG(ERR, "deallocate interrupt vectors failed");
+
 	vport->stopped = 1;
 	dev->data->dev_started = 0;
 
@@ -513,6 +624,12 @@ idpf_dev_close(struct rte_eth_dev *dev)
 	rte_free(vport->rss_key);
 	vport->rss_key = NULL;
 
+	rte_free(vport->recv_vectors);
+	vport->recv_vectors = NULL;
+
+	rte_free(vport->qv_map);
+	vport->qv_map = NULL;
+
 	adapter->cur_vports &= ~BIT(vport->devarg_id);
 
 	rte_free(vport);
@@ -864,6 +981,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 +8 -0
index bba8223cc4..505b3f36e3 100644
@@ -130,6 +130,11 @@ struct idpf_vport {
 	uint8_t *rss_key;
 	uint64_t rss_hf;
 
+	/* MSIX info*/
+	struct virtchnl2_queue_vector *qv_map; /* queue vector mapping */
+	uint16_t max_vectors;
+	struct virtchnl2_alloc_vectors *recv_vectors;
+
 	/* Chunk info */
 	struct idpf_chunks_info chunks_info;
 
@@ -248,6 +253,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 +107 -0

113 lines not on this page · raw message

Signature · 1 line
2.34.1
#374 lore raw

PATCH v3 14/15 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                |  20 +
 drivers/net/idpf/idpf_ethdev.h          |   5 +
 drivers/net/idpf/idpf_rxtx.c            | 139 ++++
 drivers/net/idpf/idpf_rxtx.h            |   7 +
 drivers/net/idpf/idpf_rxtx_vec_avx512.c | 870 ++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx_vec_common.h | 100 +++
 drivers/net/idpf/meson.build            |  28 +
 7 files changed, 1169 insertions(+)
 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 +20 -0
index af7810834a..2e9628a2d0 100644
@@ -72,3 +72,23 @@ Driver compilation and testing
 
 Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and_test>`
 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.h +5 -0
index 505b3f36e3..9b0de772c9 100644
@@ -182,6 +182,11 @@ struct idpf_adapter {
 	uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned;
 
 	bool stopped;
+
+	bool rx_vec_allowed;
+	bool tx_vec_allowed;
+	bool rx_use_avx512;
+	bool tx_use_avx512;
 };
 
 TAILQ_HEAD(idpf_adapter_list, idpf_adapter);
drivers/net/idpf/idpf_rxtx.c +139 -0

175 lines not on this page · raw message

drivers/net/idpf/idpf_rxtx.h +7 -0
index a2394ffa2c..8f440557bd 100644
@@ -211,12 +211,19 @@ uint16_t idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 				uint16_t nb_pkts);
 uint16_t idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 			       uint16_t nb_pkts);
+uint16_t idpf_singleq_recv_pkts_avx512(void *rx_queue, struct rte_mbuf **rx_pkts,
+				       uint16_t nb_pkts);
 uint16_t idpf_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 				uint16_t nb_pkts);
 uint16_t idpf_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			       uint16_t nb_pkts);
+uint16_t idpf_singleq_xmit_pkts_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
+				       uint16_t nb_pkts);
+int idpf_singleq_tx_vec_setup_avx512(struct idpf_tx_queue *txq);
 uint16_t idpf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			uint16_t nb_pkts);
+int idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq);
+
 void idpf_stop_queues(struct rte_eth_dev *dev);
 
 void idpf_set_rx_function(struct rte_eth_dev *dev);
drivers/net/idpf/idpf_rxtx_vec_avx512.c new file +870 -0

870 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 832f887296..c96e4bfcaa 100644
@@ -15,3 +15,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_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
#375 lore raw

PATCH v3 15/15 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      | 58 ++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h      | 90 +++++++++++++++++++++++++++++++
 5 files changed, 156 insertions(+), 1 deletion(-)
doc/guides/nics/features/idpf.ini +1 -0
index 0123865fd3..37f02c6781 100644
@@ -14,6 +14,7 @@ MTU update           = Y
 TSO                  = P
 L3 checksum offload  = P
 L4 checksum offload  = P
+Timestamp offload    = P
 Packet type parsing  = Y
 Multiprocess aware   = Y
 FreeBSD              = Y
drivers/net/idpf/idpf_ethdev.c +4 -1
index 4fe442135c..10c95d8754 100644
@@ -19,6 +19,8 @@
 struct idpf_adapter_list adapter_list;
 bool adapter_list_init;
 
+uint64_t idpf_timestamp_dynflag;
+
 static const char * const idpf_valid_args[] = {
 	IDPF_TX_SINGLE_Q,
 	IDPF_RX_SINGLE_Q,
@@ -97,7 +99,8 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		RTE_ETH_RX_OFFLOAD_UDP_CKSUM		|
 		RTE_ETH_RX_OFFLOAD_TCP_CKSUM		|
 		RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM	|
-		RTE_ETH_RX_OFFLOAD_RSS_HASH;
+		RTE_ETH_RX_OFFLOAD_RSS_HASH		|
+		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 9b0de772c9..49919e5c74 100644
@@ -187,6 +187,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 +58 -0

121 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