Skip to contentSkip to conversation

Virtual PMD using sze2 layer for COMBO cards

PATCH In review Matej Vido 5 participants 36 messages Jun 19, 2015 – Mar 24, 2016 Network drivers

lore
Share & tools
lore

Matej Vido

author
#0 lore raw

cover Virtual PMD using sze2 layer for COMBO cards

This is virtual PMD which communicates with COMBO-80G and COMBO-100G cards through sze2 layer. Communication with COMBO card is managed through interface provided by libsze2 library and kernel modules (combov3, szedata2_cv3).

To compile and use PMD, it is necessary to have libsze2 library installed and kernel modules (combov3, szedata2_cv3) loaded.
Therefore in default configuration PMD compilation is disabled. To compile szedata2 PMD, it is necessary to enable CONFIG_RTE_LIBRTE_PMD_SZEDATA2=y.

We have done performance measurement. Results are available in pdf file:
https://www.liberouter.org/wp-content/uploads/2015/06/pmd_szedata2_dpdk_measurement.pdf

Measurement was not done with final version of firmware. Performance will be increased soon with new firmware version.

Matej Vido (2):
szedata2: new poll mode driver
doc: added documentation for szedata2 PMD

 config/common_bsdapp                              |    5 +
 config/common_linuxapp                            |    5 +
 doc/guides/nics/index.rst                         |    1 +
 doc/guides/nics/szedata2.rst                      |  105 ++
 doc/guides/prog_guide/source_org.rst              |    1 +
 drivers/net/Makefile                              |    1 +
 drivers/net/szedata2/Makefile                     |   62 ++
 drivers/net/szedata2/rte_eth_szedata2.c           | 1120 +++++++++++++++++++++
 drivers/net/szedata2/rte_eth_szedata2.h           |   96 ++
 drivers/net/szedata2/rte_pmd_szedata2_version.map |    4 +
 mk/rte.app.mk                                     |    3 +
 11 files changed, 1403 insertions(+)
 create mode 100644 doc/guides/nics/szedata2.rst
 create mode 100644 drivers/net/szedata2/Makefile
 create mode 100644 drivers/net/szedata2/rte_eth_szedata2.c
 create mode 100644 drivers/net/szedata2/rte_eth_szedata2.h
 create mode 100644 drivers/net/szedata2/rte_pmd_szedata2_version.map
Signature · 3 lines
Matej Vido
Software Developer
CESNET, a. l. e.
author
#1 lore raw

PATCH 1/2 szedata2: new poll mode driver

Added virtual PMD which communicates with COMBO cards through sze2 layer using libsze2 library.

---
 config/common_bsdapp                              |    5 +
 config/common_linuxapp                            |    5 +
 drivers/net/Makefile                              |    1 +
 drivers/net/szedata2/Makefile                     |   62 ++
 drivers/net/szedata2/rte_eth_szedata2.c           | 1120 +++++++++++++++++++++
 drivers/net/szedata2/rte_eth_szedata2.h           |   96 ++
 drivers/net/szedata2/rte_pmd_szedata2_version.map |    4 +
 mk/rte.app.mk                                     |    3 +
 8 files changed, 1296 insertions(+)
 create mode 100644 drivers/net/szedata2/Makefile
 create mode 100644 drivers/net/szedata2/rte_eth_szedata2.c
 create mode 100644 drivers/net/szedata2/rte_eth_szedata2.h
 create mode 100644 drivers/net/szedata2/rte_pmd_szedata2_version.map
config/common_bsdapp +5 -0
index 0b169c8..d5f5970 100644
@@ -249,6 +249,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=y
 
 #
+# Compile software PMD backed by SZEDATA2 device
+#
+CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
+
+#
 # Compile link bonding PMD library
 #
 CONFIG_RTE_LIBRTE_PMD_BOND=y
config/common_linuxapp +5 -0
index 5deb55a..3bec728 100644
@@ -246,6 +246,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=n
 
 #
+# Compile software PMD backed by SZEDATA2 device
+#
+CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
+
+#
 # Compile link bonding PMD library
 #
 CONFIG_RTE_LIBRTE_PMD_BOND=y
drivers/net/Makefile +1 -0
index 1e6648a..3312b13 100644
@@ -45,6 +45,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += ring
 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += xenvirt
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2) += szedata2
 
 include $(RTE_SDK)/mk/rte.sharelib.mk
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/net/szedata2/Makefile new file +62 -0

62 lines not on this page · raw message

drivers/net/szedata2/rte_eth_szedata2.c new file +1120 -0

1,120 lines not on this page · raw message

drivers/net/szedata2/rte_eth_szedata2.h new file +96 -0

96 lines not on this page · raw message

drivers/net/szedata2/rte_pmd_szedata2_version.map new file +4 -0
new file mode 100644
index 0000000..ef35398
@@ -0,0 +1,4 @@
+DPDK_2.0 {
+
+	local: *;
+};
mk/rte.app.mk +3 -0
index 1a2043a..f9ef4b1 100644
@@ -92,6 +92,8 @@ endif # ! CONFIG_RTE_BUILD_COMBINE_LIBS
 
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP)       += -lpcap
 
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lsze2
+
 ifeq ($(CONFIG_RTE_LIBRTE_VHOST_USER),n)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST)          += -lfuse
 endif
@@ -132,6 +134,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_RING)       += -lrte_pmd_ring
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP)       += -lrte_pmd_pcap
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AF_PACKET)  += -lrte_pmd_af_packet
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL)       += -lrte_pmd_null
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lrte_pmd_szedata2
 
 endif # ! $(CONFIG_RTE_BUILD_SHARED_LIB)
 
Signature · 3 lines
Matej Vido
Software Developer
CESNET, a. l. e.
#2 lore raw

Re: [PATCH 1/2] szedata2: new poll mode driver

Quoted 3 lines · On Fri, 19 Jun 2015 10:25:00 +0200 Matej Vido <[email protected]> wrote:
drivers/net/szedata2/rte_eth_szedata2.c new file +3 -0
+static struct ether_addr eth_addr = {
+	.addr_bytes = { 0, 0, 0, 0x1, 0x2, 0x3 }
+};

...

Quoted 3 lines

static int rte_szedata2_eth_dev_init(struct rte_eth_dev *dev) {

..

Quoted 11 lines
	/* Allocate space for one mac address */
	data->mac_addrs = rte_zmalloc(data->name, sizeof(struct ether_addr),
			RTE_CACHE_LINE_SIZE);
	if (data->mac_addrs == NULL) {
		RTE_LOG(ERR, PMD, "Could not alloc space for MAC address!\n");
		munmap(dev->pci_dev->mem_resource[PCI_RESOURCE_NUMBER].addr,
			dev->pci_dev->mem_resource[PCI_RESOURCE_NUMBER].len);
		return -EINVAL;
	}

	ether_addr_copy(&eth_addr, data->mac_addrs);

If your hardware has no permanent MAC address, then please use eth_random_addr() to make one on boot, rather than having a bogus static value.

author
#3 lore raw

Re: [PATCH 1/2] szedata2: new poll mode driver

Dňa 21.03.2016 o 18:45 Stephen Hemminger napísal(a):

Quoted 22 lines
Quoted 3 lines · On Fri, 19 Jun 2015 10:25:00 +0200 Matej Vido <[email protected]> wrote:
drivers/net/szedata2/rte_eth_szedata2.c new file +3 -0
+static struct ether_addr eth_addr = {
+	.addr_bytes = { 0, 0, 0, 0x1, 0x2, 0x3 }
+};

...

Quoted 3 lines

static int rte_szedata2_eth_dev_init(struct rte_eth_dev *dev) {

..

Quoted 10 lines
	/* Allocate space for one mac address */
	data->mac_addrs = rte_zmalloc(data->name, sizeof(struct ether_addr),
			RTE_CACHE_LINE_SIZE);
	if (data->mac_addrs == NULL) {
		RTE_LOG(ERR, PMD, "Could not alloc space for MAC address!\n");
		munmap(dev->pci_dev->mem_resource[PCI_RESOURCE_NUMBER].addr,
			dev->pci_dev->mem_resource[PCI_RESOURCE_NUMBER].len);
		return -EINVAL;
	}
Quoted 3 lines
Quoted 1 line
	ether_addr_copy(&eth_addr, data->mac_addrs);

If your hardware has no permanent MAC address, then please use eth_random_addr() to make one on boot, rather than having a bogus static value.

Hi,

I will use it.

Thanks,
Matej

author
#4 lore raw

PATCH 2/2 doc: added documentation for szedata2 PMD

In reply to Matej Vido
---
 doc/guides/nics/index.rst            |   1 +
 doc/guides/nics/szedata2.rst         | 105 +++++++++++++++++++++++++++++++++++
 doc/guides/prog_guide/source_org.rst |   1 +
 3 files changed, 107 insertions(+)
 create mode 100644 doc/guides/nics/szedata2.rst
doc/guides/nics/index.rst +1 -0
index 1ee67fa..4218f90 100644
@@ -44,6 +44,7 @@ Network Interface Controller Drivers
     ixgbe
     intel_vf
     mlx4
+    szedata2
     virtio
     vmxnet3
     pcap_ring
doc/guides/nics/szedata2.rst new file +105 -0

105 lines not on this page · raw message

doc/guides/prog_guide/source_org.rst +1 -0
index 4f6f489..e43d8c1 100644
@@ -106,6 +106,7 @@ The drivers directory has a net subdirectory which contains::
     +-- null               # NULL poll mode driver for testing
     +-- pcap               # PCAP poll mode driver
     +-- ring               # ring poll mode driver
+    +-- szedata2           # szedata2 poll mode driver
     +-- virtio             # virtio poll mode driver
     +-- vmxnet3            # VMXNET3 poll mode driver
     +-- xenvirt            # Xen virtio poll mode driver
Signature · 3 lines
Matej Vido
Software Developer
CESNET, a. l. e.
#5 lore raw

v2 cover Virtual PMD using sze2 layer for COMBO cards

In reply to Matej Vido

This is virtual PMD which communicates with COMBO-80G and COMBO-100G cards through sze2 layer. Communication with COMBO card is managed through interface provided by libsze2 library and kernel modules (combov3, szedata2_cv3).

To compile and use PMD, it is necessary to have libsze2 library installed and kernel modules (combov3, szedata2_cv3) loaded.
Therefore in default configuration PMD compilation is disabled. To compile szedata2 PMD, it is necessary to enable CONFIG_RTE_LIBRTE_PMD_SZEDATA2=y.

v2:
code cleanup
add handling scattered packets
update release notes

Matej Vido (5):
szedata2: add new poll mode driver
szedata2: add handling of scattered packets in RX
szedata2: add handling of scattered packets in TX
doc: add documentation for szedata2 PMD
doc: update 2.2 release notes

 config/common_bsdapp                              |    5 +
 config/common_linuxapp                            |    5 +
 doc/guides/nics/index.rst                         |    1 +
 doc/guides/nics/szedata2.rst                      |  105 ++
 doc/guides/prog_guide/source_org.rst              |    1 +
 doc/guides/rel_notes/release_2_2.rst              |    4 +
 drivers/net/Makefile                              |    1 +
 drivers/net/szedata2/Makefile                     |   62 +
 drivers/net/szedata2/rte_eth_szedata2.c           | 1638 +++++++++++++++++++++
 drivers/net/szedata2/rte_eth_szedata2.h           |   96 ++
 drivers/net/szedata2/rte_pmd_szedata2_version.map |    4 +
 mk/rte.app.mk                                     |    3 +
 12 files changed, 1925 insertions(+)
 create mode 100644 doc/guides/nics/szedata2.rst
 create mode 100644 drivers/net/szedata2/Makefile
 create mode 100644 drivers/net/szedata2/rte_eth_szedata2.c
 create mode 100644 drivers/net/szedata2/rte_eth_szedata2.h
 create mode 100644 drivers/net/szedata2/rte_pmd_szedata2_version.map
Signature · 1 line
1.9.1
#6 lore raw

PATCH v2 1/5 szedata2: add new poll mode driver

Add virtual PMD which communicates with COMBO cards through sze2 layer using libsze2 library.

Since link_speed is uint16_t, there can not be used number for 100G speed, therefore link_speed is set to ETH_LINK_SPEED_10G until the type of link_speed is solved.

v2:
Code cleanup.
Fix error handling by initialization of rx, tx dma channels. Add uninit function.

---
 config/common_bsdapp                              |    5 +
 config/common_linuxapp                            |    5 +
 drivers/net/Makefile                              |    1 +
 drivers/net/szedata2/Makefile                     |   62 ++
 drivers/net/szedata2/rte_eth_szedata2.c           | 1212 +++++++++++++++++++++
 drivers/net/szedata2/rte_eth_szedata2.h           |   96 ++
 drivers/net/szedata2/rte_pmd_szedata2_version.map |    4 +
 mk/rte.app.mk                                     |    3 +
 8 files changed, 1388 insertions(+)
 create mode 100644 drivers/net/szedata2/Makefile
 create mode 100644 drivers/net/szedata2/rte_eth_szedata2.c
 create mode 100644 drivers/net/szedata2/rte_eth_szedata2.h
 create mode 100644 drivers/net/szedata2/rte_pmd_szedata2_version.map
config/common_bsdapp +5 -0
index b37dcf4..d2b6f4f 100644
@@ -272,6 +272,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=y
 
 #
+# Compile software PMD backed by SZEDATA2 device
+#
+CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
+
+#
 # Compile link bonding PMD library
 #
 CONFIG_RTE_LIBRTE_PMD_BOND=y
config/common_linuxapp +5 -0
index 0de43d5..f5963e7 100644
@@ -270,6 +270,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=n
 
 #
+# Compile software PMD backed by SZEDATA2 device
+#
+CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
+
+#
 # Compile link bonding PMD library
 #
 CONFIG_RTE_LIBRTE_PMD_BOND=y
drivers/net/Makefile +1 -0
index 5ebf963..7499d1e 100644
@@ -48,6 +48,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += ring
 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += xenvirt
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2) += szedata2
 
 include $(RTE_SDK)/mk/rte.sharelib.mk
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/net/szedata2/Makefile new file +62 -0

62 lines not on this page · raw message

drivers/net/szedata2/rte_eth_szedata2.c new file +1212 -0

1,212 lines not on this page · raw message

drivers/net/szedata2/rte_eth_szedata2.h new file +96 -0

96 lines not on this page · raw message

drivers/net/szedata2/rte_pmd_szedata2_version.map new file +4 -0
new file mode 100644
index 0000000..bd8138a
@@ -0,0 +1,4 @@
+DPDK_2.1 {
+
+	local: *;
+};
mk/rte.app.mk +3 -0
index 9e1909e..f6d4a5c 100644
@@ -92,6 +92,8 @@ endif # ! CONFIG_RTE_BUILD_COMBINE_LIBS
 
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP)       += -lpcap
 
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lsze2
+
 ifeq ($(CONFIG_RTE_LIBRTE_VHOST_NUMA),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST)          += -lnuma
 endif
@@ -142,6 +144,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_RING)       += -lrte_pmd_ring
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP)       += -lrte_pmd_pcap
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AF_PACKET)  += -lrte_pmd_af_packet
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL)       += -lrte_pmd_null
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lrte_pmd_szedata2
 
 endif # ! $(CONFIG_RTE_BUILD_SHARED_LIB)
 
Signature · 1 line
1.9.1
#7 lore raw

Re: [PATCH v2 1/5] szedata2: add new poll mode driver

2015-09-18 10:32, Matej Vido:

Quoted 11 lines

Add virtual PMD which communicates with COMBO cards through sze2 layer using libsze2 library.

Since link_speed is uint16_t, there can not be used number for 100G speed, therefore link_speed is set to ETH_LINK_SPEED_10G until the type of link_speed is solved.

v2:
Code cleanup.
Fix error handling by initialization of rx, tx dma channels. Add uninit function.

There are some warnings raised by checkpatch.pl. Please check.

When sending a new version, it would be appreciated to introduce Rx/Tx in another patch.

Thanks

#8 lore raw

PATCH v2 2/5 szedata2: add handling of scattered packets in RX

In reply to Matej Vido

Add new RX function for handling scattered packets.

---
 drivers/net/szedata2/rte_eth_szedata2.c | 356 +++++++++++++++++++++++++++++++-
 1 file changed, 354 insertions(+), 2 deletions(-)
drivers/net/szedata2/rte_eth_szedata2.c +354 -2
index 4db1287..ddb45e4 100644
@@ -362,6 +362,343 @@ eth_szedata2_rx(void *queue,
 }
 
 static uint16_t
+eth_szedata2_rx_scattered(void *queue,
+		struct rte_mbuf **bufs,
+		uint16_t nb_pkts)
+{
+	unsigned int i;
+	struct rte_mbuf *mbuf;
+	struct szedata2_rx_queue *sze_q = queue;
+	struct rte_pktmbuf_pool_private *mbp_priv;
+	uint16_t num_rx = 0;
+	uint16_t buf_size;
+	uint16_t sg_size;
+	uint16_t hw_size;
+	uint16_t packet_size;
+	uint64_t num_bytes = 0;
+	struct szedata * sze = sze_q->sze;
+	uint8_t * header_ptr = NULL; /* header of packet */
+	uint8_t * packet_ptr1 = NULL;
+	uint8_t * packet_ptr2 = NULL;
+	uint16_t packet_len1 = 0;
+	uint16_t packet_len2 = 0;
+	uint16_t hw_data_align;
+
+	if (unlikely(sze_q->sze == NULL || nb_pkts == 0)) {
+		return 0;
+	}
+
+	/*
+	 * Reads the given number of packets from szedata2 channel given
+	 * by queue and copies the packet data into a newly allocated mbuf
+	 * to return.
+	 */
+	for (i = 0; i < nb_pkts; i++) {
+		const struct szedata_lock * ct_rx_lck_backup;
+		unsigned int ct_rx_rem_bytes_backup;
+		unsigned char * ct_rx_cur_ptr_backup;
+
+		/* get the next sze packet */
+		if (sze->ct_rx_lck != NULL && !sze->ct_rx_rem_bytes &&
+				sze->ct_rx_lck->next == NULL) {
+			/* unlock old data */
+			szedata_rx_unlock_data(sze_q->sze, sze->ct_rx_lck_orig);
+			sze->ct_rx_lck_orig = NULL;
+			sze->ct_rx_lck = NULL;
+		}
+
+		/*
+		 * Store items from sze structure which can be changed
+		 * before mbuf allocating. Use these items in case of mbuf
+		 * allocating failure.
+		 */
+		ct_rx_lck_backup = sze->ct_rx_lck;
+		ct_rx_rem_bytes_backup = sze->ct_rx_rem_bytes;
+		ct_rx_cur_ptr_backup = sze->ct_rx_cur_ptr;
+
+		if (!sze->ct_rx_rem_bytes && sze->ct_rx_lck_orig == NULL) {
+			/* nothing to read, lock new data */
+			sze->ct_rx_lck_orig = sze->ct_rx_lck =
+				szedata_rx_lock_data(sze_q->sze, ~0U);
+
+			/*
+			 * Backup items from sze structure must be updated
+			 * after locking to contain pointers to new locks.
+			 */
+			ct_rx_lck_backup = sze->ct_rx_lck;
+			ct_rx_rem_bytes_backup = sze->ct_rx_rem_bytes;
+			ct_rx_cur_ptr_backup = sze->ct_rx_cur_ptr;
+
+			if (sze->ct_rx_lck == NULL) {
+				/* nothing to lock */
+				break;
+			}
+
+			sze->ct_rx_cur_ptr = sze->ct_rx_lck->start;
+			sze->ct_rx_rem_bytes = sze->ct_rx_lck->len;
+
+			if (!sze->ct_rx_rem_bytes) {
+				break;
+			}
+		}
+
+		if (sze->ct_rx_rem_bytes < RTE_SZE2_PACKET_HEADER_SIZE) {
+			/*
+			 * cut in header - copy parts of header to merge buffer
+			 */
+			if (sze->ct_rx_lck->next == NULL) {
+				break;
+			}
+
+			/* copy first part of header */
+			rte_memcpy(sze->ct_rx_buffer, sze->ct_rx_cur_ptr,
+					sze->ct_rx_rem_bytes);
+
+			/* copy second part of header */
+			sze->ct_rx_lck = sze->ct_rx_lck->next;
+			sze->ct_rx_cur_ptr = sze->ct_rx_lck->start;
+			rte_memcpy(sze->ct_rx_buffer + sze->ct_rx_rem_bytes,
+				sze->ct_rx_cur_ptr,
+				RTE_SZE2_PACKET_HEADER_SIZE -
+				sze->ct_rx_rem_bytes);
+
+			sze->ct_rx_cur_ptr += RTE_SZE2_PACKET_HEADER_SIZE -
+				sze->ct_rx_rem_bytes;
+			sze->ct_rx_rem_bytes = sze->ct_rx_lck->len -
+				RTE_SZE2_PACKET_HEADER_SIZE +
+				sze->ct_rx_rem_bytes;
+
+			header_ptr = (uint8_t *) sze->ct_rx_buffer;
+		} else {
+			/* not cut */
+			header_ptr = (uint8_t *) sze->ct_rx_cur_ptr;
+			sze->ct_rx_cur_ptr += RTE_SZE2_PACKET_HEADER_SIZE;
+			sze->ct_rx_rem_bytes -= RTE_SZE2_PACKET_HEADER_SIZE;
+		}
+
+		sg_size = le16toh(*((uint16_t *)header_ptr));
+		hw_size = le16toh(*(((uint16_t *)header_ptr)+1));
+		packet_size = sg_size -
+			RTE_SZE2_ALIGN8(RTE_SZE2_PACKET_HEADER_SIZE + hw_size);
+
+
+		/* checks if packet all right */
+		if (!sg_size) {
+			errx(5, "Zero segsize");
+		}
+
+		/* check sg_size and hwsize */
+		if (hw_size > sg_size - RTE_SZE2_PACKET_HEADER_SIZE) {
+			errx(10, "Hwsize bigger than expected. Segsize: %d, "
+					"hwsize: %d", sg_size, hw_size);
+		}
+
+		hw_data_align =
+			RTE_SZE2_ALIGN8((RTE_SZE2_PACKET_HEADER_SIZE +
+			hw_size)) - RTE_SZE2_PACKET_HEADER_SIZE;
+
+		if (sze->ct_rx_rem_bytes >=
+				(uint16_t)(sg_size -
+				RTE_SZE2_PACKET_HEADER_SIZE)) {
+			/* no cut */
+			/* one packet ready - go to another */
+			packet_ptr1 = sze->ct_rx_cur_ptr + hw_data_align;
+			packet_len1 = packet_size;
+			packet_ptr2 = NULL;
+			packet_len2 = 0;
+
+			sze->ct_rx_cur_ptr += RTE_SZE2_ALIGN8(sg_size) -
+				RTE_SZE2_PACKET_HEADER_SIZE;
+			sze->ct_rx_rem_bytes -= RTE_SZE2_ALIGN8(sg_size) -
+				RTE_SZE2_PACKET_HEADER_SIZE;
+		} else {
+			/* cut in data */
+			if (sze->ct_rx_lck->next == NULL) {
+				errx(6, "Need \"next\" lock, but it is "
+					"missing: %u", sze->ct_rx_rem_bytes);
+			}
+
+			/* skip hw data */
+			if (sze->ct_rx_rem_bytes <= hw_data_align) {
+				uint16_t rem_size = hw_data_align -
+					sze->ct_rx_rem_bytes;
+
+				/* MOVE to next lock */
+				sze->ct_rx_lck = sze->ct_rx_lck->next;
+				sze->ct_rx_cur_ptr =
+					(void *) (((uint8_t *)
+					(sze->ct_rx_lck->start)) + rem_size);
+
+				packet_ptr1 = sze->ct_rx_cur_ptr;
+				packet_len1 = packet_size;
+				packet_ptr2 = NULL;
+				packet_len2 = 0;
+
+				sze->ct_rx_cur_ptr +=
+					RTE_SZE2_ALIGN8(packet_size);
+				sze->ct_rx_rem_bytes = sze->ct_rx_lck->len -
+					rem_size - RTE_SZE2_ALIGN8(packet_size);
+			} else {
+				/* get pointer and length from first part */
+				packet_ptr1 = sze->ct_rx_cur_ptr +
+					hw_data_align;
+				packet_len1 = sze->ct_rx_rem_bytes -
+					hw_data_align;
+
+				/* MOVE to next lock */
+				sze->ct_rx_lck = sze->ct_rx_lck->next;
+				sze->ct_rx_cur_ptr = sze->ct_rx_lck->start;
+
+				/* get pointer and length from second part */
+				packet_ptr2 = sze->ct_rx_cur_ptr;
+				packet_len2 = packet_size - packet_len1;
+
+				sze->ct_rx_cur_ptr +=
+					RTE_SZE2_ALIGN8(packet_size) -
+					packet_len1;
+				sze->ct_rx_rem_bytes = sze->ct_rx_lck->len -
+					(RTE_SZE2_ALIGN8(packet_size) -
+					 packet_len1);
+			}
+		}
+
+		if (unlikely(packet_ptr1 == NULL)) {
+			break;
+		}
+
+		mbuf = rte_pktmbuf_alloc(sze_q->mb_pool);
+
+		if (unlikely(mbuf == NULL)) {
+			/*
+			 * Restore items from sze structure to state after
+			 * unlocking (eventually locking).
+			 */
+			sze->ct_rx_lck = ct_rx_lck_backup;
+			sze->ct_rx_rem_bytes = ct_rx_rem_bytes_backup;
+			sze->ct_rx_cur_ptr = ct_rx_cur_ptr_backup;
+			break;
+		}
+
+		/* get the space available for data in the mbuf */
+		mbp_priv = rte_mempool_get_priv(sze_q->mb_pool);
+		buf_size = (uint16_t) (mbp_priv->mbuf_data_room_size -
+				RTE_PKTMBUF_HEADROOM);
+
+		if (packet_size <= buf_size) {
+			/* sze packet will fit in one mbuf, go ahead and copy */
+			rte_memcpy(rte_pktmbuf_mtod(mbuf, void *),
+					packet_ptr1, packet_len1);
+			if (packet_ptr2 != NULL) {
+				rte_memcpy((void *)
+					(rte_pktmbuf_mtod(mbuf, uint8_t *) +
+					packet_len1), packet_ptr2, packet_len2);
+			}
+			mbuf->data_len = (uint16_t)packet_size;
+		} else {
+			/*
+			 * sze packet will not fit in one mbuf,
+			 * scatter packet into more mbufs
+			 */
+			struct rte_mbuf * m = mbuf;
+			uint16_t len = rte_pktmbuf_tailroom(mbuf);
+
+			/* copy first part of packet */
+			/* fill first mbuf */
+			rte_memcpy(rte_pktmbuf_append(mbuf, len), packet_ptr1,
+				len);
+			packet_len1 -= len;
+			packet_ptr1 = ((uint8_t *)packet_ptr1) + len;
+
+			while (packet_len1 > 0) {
+				/* fill new mbufs */
+				m->next = rte_pktmbuf_alloc(sze_q->mb_pool);
+
+				if (unlikely(m->next == NULL)) {
+					rte_pktmbuf_free(mbuf);
+					/*
+					 * Restore items from sze structure
+					 * to state after unlocking (eventually
+					 * locking).
+					 */
+					sze->ct_rx_lck = ct_rx_lck_backup;
+					sze->ct_rx_rem_bytes =
+						ct_rx_rem_bytes_backup;
+					sze->ct_rx_cur_ptr =
+						ct_rx_cur_ptr_backup;
+					goto finish;
+				}
+
+				m = m->next;
+
+				len = RTE_MIN(rte_pktmbuf_tailroom(m),
+					packet_len1);
+				rte_memcpy(rte_pktmbuf_append(mbuf, len),
+					packet_ptr1, len);
+
+				(mbuf->nb_segs)++;
+				packet_len1 -= len;
+				packet_ptr1 = ((uint8_t *)packet_ptr1) + len;
+			}
+
+			if (packet_ptr2 != NULL) {
+				/* copy second part of packet, if exists */
+				/* fill the rest of currently last mbuf */
+				len = rte_pktmbuf_tailroom(m);
+				rte_memcpy(rte_pktmbuf_append(mbuf, len),
+					packet_ptr2, len);
+				packet_len2 -= len;
+				packet_ptr2 = ((uint8_t *)packet_ptr2) + len;
+
+				while (packet_len2 > 0) {
+					/* fill new mbufs */
+					m->next = rte_pktmbuf_alloc(
+							sze_q->mb_pool);
+
+					if (unlikely(m->next == NULL)) {
+						rte_pktmbuf_free(mbuf);
+						/*
+						 * Restore items from sze
+						 * structure to state after
+						 * unlocking (eventually
+						 * locking).
+						 */
+						sze->ct_rx_lck =
+							ct_rx_lck_backup;
+						sze->ct_rx_rem_bytes =
+							ct_rx_rem_bytes_backup;
+						sze->ct_rx_cur_ptr =
+							ct_rx_cur_ptr_backup;
+						goto finish;
+					}
+
+					m = m->next;
+
+					len = RTE_MIN(rte_pktmbuf_tailroom(m),
+						packet_len2);
+					rte_memcpy(rte_pktmbuf_append(mbuf,len),
+							packet_ptr2, len);
+
+					(mbuf->nb_segs)++;
+					packet_len2 -= len;
+					packet_ptr2 = ((uint8_t *)packet_ptr2) +
+						len;
+				}
+			}
+		}
+		mbuf->pkt_len = packet_size;
+		mbuf->port = sze_q->in_port;
+		bufs[num_rx] = mbuf;
+		num_rx++;
+		num_bytes += packet_size;
+	}
+
+finish:
+	sze_q->rx_pkts += num_rx;
+	sze_q->rx_bytes += num_bytes;
+	return num_rx;
+}
+
+static uint16_t
 eth_szedata2_tx(void *queue,
 		struct rte_mbuf **bufs,
 		uint16_t nb_pkts)
@@ -787,8 +1124,16 @@ eth_dev_stop(struct rte_eth_dev *dev)
 }
 
 static int
-eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
+eth_dev_configure(struct rte_eth_dev *dev)
 {
+	struct rte_eth_dev_data * data = dev->data;
+	if (data->dev_conf.rxmode.enable_scatter == 1) {
+		dev->rx_pkt_burst = eth_szedata2_rx_scattered;
+		data->scattered_rx = 1;
+	} else {
+		dev->rx_pkt_burst = eth_szedata2_rx;
+		data->scattered_rx = 0;
+	}
 	return 0;
 }
 
@@ -1108,7 +1453,14 @@ rte_eth_from_szedata2(const char *name,
 		return -1;
 	}
 
-	eth_dev->rx_pkt_burst = eth_szedata2_rx;
+	if (data->dev_conf.rxmode.enable_scatter == 1 ||
+		data->scattered_rx == 1) {
+		eth_dev->rx_pkt_burst = eth_szedata2_rx_scattered;
+		data->scattered_rx = 1;
+	} else {
+		eth_dev->rx_pkt_burst = eth_szedata2_rx;
+		data->scattered_rx = 0;
+	}
 	eth_dev->tx_pkt_burst = eth_szedata2_tx;
 
 	return 0;
Signature · 1 line
1.9.1
#9 lore raw

PATCH v2 3/5 szedata2: add handling of scattered packets in TX

In reply to Matej Vido

TX function modified to handle chained mbufs.

---
 drivers/net/szedata2/rte_eth_szedata2.c | 108 +++++++++++++++++++++++++++-----
 1 file changed, 91 insertions(+), 17 deletions(-)
drivers/net/szedata2/rte_eth_szedata2.c +91 -17
index ddb45e4..e2d6501 100644
@@ -737,7 +737,7 @@ eth_szedata2_tx(void *queue,
 next_packet:
 		mbuf = bufs[nb_pkts - pkt_left];
 
-		pkt_len = mbuf->data_len;
+		pkt_len = mbuf->pkt_len;
 		mbuf_segs = mbuf->nb_segs;
 
 		hwpkt_len = RTE_SZE2_PACKET_HEADER_SIZE_ALIGNED +
@@ -764,9 +764,28 @@ next_packet:
 			/* copy packet from mbuf */
 			tmp_dst = ((uint8_t *)(dst)) +
 				RTE_SZE2_PACKET_HEADER_SIZE_ALIGNED;
-			rte_memcpy(tmp_dst,
-				rte_pktmbuf_mtod(mbuf, const void *),
-				pkt_len);
+			if (likely(mbuf_segs == 1)) {
+				/*
+				 * non-scattered packet,
+				 * transmit from one mbuf
+				 */
+				rte_memcpy(tmp_dst,
+					rte_pktmbuf_mtod(mbuf, const void *),
+					pkt_len);
+			} else {
+				/* scattered packet, transmit from more mbufs */
+				struct rte_mbuf * m = mbuf;
+				while (m) {
+					rte_memcpy(tmp_dst,
+						rte_pktmbuf_mtod(m,
+						const void *),
+						m->data_len);
+					tmp_dst = ((uint8_t *)(tmp_dst)) +
+						m->data_len;
+					m = m->next;
+				}
+			}
+
 
 			dst = ((uint8_t *)dst) + hwpkt_len;
 			unlock_size += hwpkt_len;
@@ -805,19 +824,74 @@ next_packet:
 
 			tmp_dst = ((uint8_t *)(dst)) +
 				RTE_SZE2_PACKET_HEADER_SIZE_ALIGNED;
-			/* copy part of packet to first area */
-			rte_memcpy(tmp_dst,
-				rte_pktmbuf_mtod(mbuf, const void *),
-				write_len);
-
-			if (lck->next)
-				dst = lck->next->start;
-
-			/* copy part of packet to second area */
-			rte_memcpy(dst,
-				(const void *) (rte_pktmbuf_mtod(mbuf,
-						const uint8_t *) +
-				write_len), pkt_len - write_len);
+			if (likely(mbuf_segs == 1)) {
+				/*
+				 * non-scattered packet,
+				 * transmit from one mbuf
+				 */
+				/* copy part of packet to first area */
+				rte_memcpy(tmp_dst,
+					rte_pktmbuf_mtod(mbuf, const void *),
+					write_len);
+
+				if (lck->next)
+					dst = lck->next->start;
+
+				/* copy part of packet to second area */
+				rte_memcpy(dst,
+					(const void *) (rte_pktmbuf_mtod(mbuf,
+							const uint8_t *) +
+					write_len), pkt_len - write_len);
+			} else {
+				/* scattered packet, transmit from more mbufs */
+				struct rte_mbuf * m = mbuf;
+				uint16_t written = 0;
+				uint16_t to_write = 0;
+				bool new_mbuf = true;
+				uint16_t write_off = 0;
+
+				/* copy part of packet to first area */
+				while (m && written < write_len) {
+					to_write = RTE_MIN(m->data_len,
+							write_len - written);
+					rte_memcpy(tmp_dst,
+						rte_pktmbuf_mtod(m,
+							const void *),
+						to_write);
+
+					tmp_dst = ((uint8_t *)(tmp_dst)) +
+						to_write;
+					if (m->data_len <= write_len -
+							written) {
+						m = m->next;
+						new_mbuf = true;
+					} else {
+						new_mbuf = false;
+					}
+					written += to_write;
+				}
+
+				if (lck->next)
+					dst = lck->next->start;
+
+				tmp_dst = dst;
+				written = 0;
+				write_off = new_mbuf ? 0 : to_write;
+
+				/* copy part of packet to second area */
+				while (m && written < pkt_len - write_len) {
+					rte_memcpy(tmp_dst, (const void *)
+						(rte_pktmbuf_mtod(m,
+						uint8_t *) + write_off),
+						m->data_len - write_off);
+
+					tmp_dst = ((uint8_t *)(tmp_dst)) +
+						(m->data_len - write_off);
+					written += m->data_len - write_off;
+					m = m->next;
+					write_off = 0;
+				}
+			}
 
 			dst = ((uint8_t *)dst) + rem_len;
 			unlock_size += hwpkt_len;
Signature · 1 line
1.9.1
#10 lore raw

Re: [PATCH v2 3/5] szedata2: add handling of scattered packets in TX

Hi Matej,

2015-09-18 10:32, Matej Vido:

drivers/net/szedata2/rte_eth_szedata2.c next_packet: · line 774

Quoted 11 lines
drivers/net/szedata2/rte_eth_szedata2.c +8 -3
-			rte_memcpy(tmp_dst,
-				rte_pktmbuf_mtod(mbuf, const void *),
-				pkt_len);
+			if (likely(mbuf_segs == 1)) {
+				/*
+				 * non-scattered packet,
+				 * transmit from one mbuf
+				 */
+				rte_memcpy(tmp_dst,
+					rte_pktmbuf_mtod(mbuf, const void *),
+					pkt_len);

You could avoid this change by keeping "if (likely(mbuf_segs == 1))" in the first patch.
By the way, it seems to be an abusive use of "likely".

#11 lore raw

Re: [PATCH v2 3/5] szedata2: add handling of scattered packets in TX

Hi Thomas,

2015-10-26 15:55 GMT+01:00 Thomas Monjalon <[email protected]>:

Quoted 13 lines

Hi Matej,

2015-09-18 10:32, Matej Vido:

drivers/net/szedata2/rte_eth_szedata2.c next_packet:

Quoted 10 lines
drivers/net/szedata2/rte_eth_szedata2.c +7 -3
-                     rte_memcpy(tmp_dst,
-                             rte_pktmbuf_mtod(mbuf, const void *),
-                             pkt_len);
+                     if (likely(mbuf_segs == 1)) {
+                             /*
+                              * non-scattered packet,
+                              * transmit from one mbuf
+                              */
+                             rte_memcpy(tmp_dst,
+                                     rte_pktmbuf_mtod(mbuf, const void
Quoted 8 lines

*),

Quoted 1 line

+ pkt_len);

You could avoid this change by keeping "if (likely(mbuf_segs == 1))" in the first patch.
By the way, it seems to be an abusive use of "likely".

I will edit it in v3. Thanks.

Best regards,
Matej Vido

#12 lore raw

PATCH v2 4/5 doc: add documentation for szedata2 PMD

In reply to Matej Vido
---
 doc/guides/nics/index.rst            |   1 +
 doc/guides/nics/szedata2.rst         | 105 +++++++++++++++++++++++++++++++++++
 doc/guides/prog_guide/source_org.rst |   1 +
 3 files changed, 107 insertions(+)
 create mode 100644 doc/guides/nics/szedata2.rst
doc/guides/nics/index.rst +1 -0
index d1a92f8..fcbf8dd 100644
@@ -45,6 +45,7 @@ Network Interface Controller Drivers
     ixgbe
     intel_vf
     mlx4
+    szedata2
     virtio
     vmxnet3
     pcap_ring
doc/guides/nics/szedata2.rst new file +105 -0

105 lines not on this page · raw message

doc/guides/prog_guide/source_org.rst +1 -0
index ae11b3b..2393002 100644
@@ -106,6 +106,7 @@ The drivers directory has a *net* subdirectory which contains::
     +-- null               # NULL poll mode driver for testing
     +-- pcap               # PCAP poll mode driver
     +-- ring               # Ring poll mode driver
+    +-- szedata2           # szedata2 poll mode driver
     +-- virtio             # Virtio poll mode driver
     +-- vmxnet3            # VMXNET3 poll mode driver
     +-- xenvirt            # Xen virtio poll mode driver
Signature · 1 line
1.9.1
#14 lore raw

Re: [PATCH v2 4/5] doc: add documentation for szedata2 PMD

In reply to Matej Vido

Hi Matej,

Thanks for providing a documentation.
I'm sorry to give a late feedback and I would like that other contributors have reviewed it. There are a lot of PMD developers around. Please help.

2015-09-18 10:32, Matej Vido:

doc/guides/nics/szedata2.rst line 54

Quoted 4 lines

+- **libsze2**

doc/guides/nics/szedata2.rst new file +3 -0
+
+  This library provides API for initialization of sze2 transfers, receiving and
+  transmitting data segments.

Please provide more information to help installing the dependencies.

doc/guides/nics/szedata2.rst line 72

Quoted 6 lines
doc/guides/nics/szedata2.rst new file +6 -0
+SZEDATA2 PMD can be created by passing --vdev= option to EAL in the following
+format:
+
+.. code-block:: console
+
+    --vdev 'DEVICE_NAME,dev_path=PATH_TO_SZEDATA2_DEVICE,rx_ifaces=RX_MASK,tx_ifaces=TX_MASK'

SZEDATA2 is not a vdev. Is it possible to probe it as a standard PCI device?

#15 lore raw

Re: [PATCH v2 4/5] doc: add documentation for szedata2 PMD

Hi Thomas,

thank you for feedback.

2015-10-26 16:09 GMT+01:00 Thomas Monjalon <[email protected]>:

Quoted 7 lines

Hi Matej,

Thanks for providing a documentation.
I'm sorry to give a late feedback and I would like that other contributors have reviewed it. There are a lot of PMD developers around. Please help.

Quoted 9 lines

2015-09-18 10:32, Matej Vido:

Review

Quoted 3 lines

+- **libsze2**

(quoted diff) +2 -0
+
+  This library provides API for initialization of sze2 transfers,

receiving and

Quoted 1 line

+ transmitting data segments.

Please provide more information to help installing the dependencies.

Dependencies can be installed from RPM packages. I will add those information in new patch version.

Quoted 10 lines
Quoted 2 lines

+SZEDATA2 PMD can be created by passing --vdev= option to EAL in the

following

doc/guides/nics/szedata2.rst

Quoted 5 lines
doc/guides/nics/szedata2.rst new file +5 -0
+format:
+
+.. code-block:: console
+
+    --vdev

'DEVICE_NAME,dev_path=PATH_TO_SZEDATA2_DEVICE,rx_ifaces=RX_MASK,tx_ifaces=TX_MASK'

Quoted 4 lines

SZEDATA2 is not a vdev. Is it possible to probe it as a standard PCI device?

It would be possible to probe it as a standard PCI device, but as this
szedata2 driver uses libsze2 library it needs to pass some parameters to the library and we thought that using vdev would be the easiest solution. Is there a way how to provide parameters to pdev driver?
We also work on a new PMD which will eliminate dependencies on kernel modules and libsze2, and using this PMD COMBO card will be probed as a standard PCI device.

Best regards,
Matej Vido

#16 lore raw

Re: [PATCH v2 4/5] doc: add documentation for szedata2 PMD

2015-10-27 18:33, Matej Vido:

Quoted 8 lines

2015-10-26 16:09 GMT+01:00 Thomas Monjalon <[email protected]>:

Quoted 3 lines

SZEDATA2 is not a vdev. Is it possible to probe it as a standard PCI device?

It would be possible to probe it as a standard PCI device, but as this szedata2 driver uses libsze2 library it needs to pass some parameters to the library and we thought that using vdev would be the easiest solution. Is there a way how to provide parameters to pdev driver?

No, but it could be added by working on unifying pdev and vdev.

Quoted 3 lines

We also work on a new PMD which will eliminate dependencies on kernel modules and libsze2, and using this PMD COMBO card will be probed as a standard PCI device.

I think it's better to wait for your new implementation. It would be nice to have it in the release 2.2. Do you think it could be submitted in the coming weeks?

#17 lore raw

Re: [PATCH v2 4/5] doc: add documentation for szedata2 PMD

Hi Thomas,

2015-10-27 19:00 GMT+01:00 Thomas Monjalon <[email protected]>:

Quoted 12 lines

2015-10-27 18:33, Matej Vido:

Quoted 8 lines

2015-10-26 16:09 GMT+01:00 Thomas Monjalon <[email protected]>:

Quoted 3 lines

SZEDATA2 is not a vdev. Is it possible to probe it as a standard PCI device?

It would be possible to probe it as a standard PCI device, but as this szedata2 driver uses libsze2 library it needs to pass some parameters to the library and we thought that using vdev would be the easiest solution. Is there a way how to provide parameters to pdev driver?

No, but it could be added by working on unifying pdev and vdev.

Quoted 8 lines
Quoted 3 lines

We also work on a new PMD which will eliminate dependencies on kernel modules and libsze2, and using this PMD COMBO card will be probed as a standard PCI device.

I think it's better to wait for your new implementation. It would be nice to have it in the release 2.2. Do you think it could be submitted in the coming weeks?

We will not manage to submit the new driver implementation in the release 2.2. Any chance to get this virtual driver into 2.2?

Matej Vido

#18 lore raw

Re: [PATCH v2 4/5] doc: add documentation for szedata2 PMD

In reply to Matej Vido
Quoted 8 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Matej Vido
Sent: Friday, September 18, 2015 9:33 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH v2 4/5] doc: add documentation for szedata2 PMD

Hi,

Thanks for the new PMD and the documentation.

The DPDJ documentation guidelines provide some guidance on how to format and build the DPDK documentation:

http://dpdk.org/doc/guides/contributing/documentation.html

In terms of documentation for a PMD the Mellanox MLX4 docs are a good example:

http://dpdk.org/doc/guides/nics/mlx4.html

Some other comments below:

Quoted 2 lines

+SZEDATA2 PMD
+============

No need for an acronym in the title. Follow the MLX4 example and use something like " SZEDATA2 poll mode driver library".

Quoted 3 lines
(quoted diff) +2 -0
+SZEDATA2 PMD is virtual PMD which uses sze2 layer to communicate with
+COMBO cards (COMBO-80G, COMBO-100G) using interface provided by libsze2

library.

The introduction can be brief but should include enough information to explain the PMD for someone encountering it for the first time.

Some links would help with this. See the MLX4 doc as an example:

Quoted 7 lines
doc/guides/nics/szedata2.rst new file +4 -0
+
+.. note::
+
+   This driver has external dependencies. Therefore it is disabled in

default
+ configuration files. It can be enabled by setting
CONFIG_RTE_LIBRTE_PMD_SZEDATA2=y

Format configuration items as verbatim text with double backquotes:`` CONFIG_RTE_LIBRTE_PMD_SZEDATA2=y ``

doc/guides/nics/szedata2.rst line 65

Quoted 3 lines
doc/guides/nics/szedata2.rst new file +3 -0
+
+Using PMD
+---------

Better: Using the Szedata PMD

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+SZEDATA2 PMD can be created by passing --vdev= option to EAL in the

Again format --vdev as ``--vdev``. Also apply to other similar cases.

Quoted 7 lines
doc/guides/nics/szedata2.rst new file +5 -0
+following format:
+
+.. code-block:: console
+
+    --vdev

'DEVICE_NAME,dev_path=PATH_TO_SZEDATA2_DEVICE,rx_ifaces=RX_MASK,tx_ifaces= TX_MASK'

This code line exceeds 80 chars and will exceed the page width in the PDF docs. If possible see if it can be shortened. Maybe use DEVICE instead of DEVICE_NAME and PATH instead of PATH_TO. The next section has an explanation anyway.

Review

Quoted 3 lines
(quoted diff) +3 -0
+
+DEVICE_NAME and options dev_path, rx_ifaces, tx_ifaces are mandatory
+and must be separated by commas.

Use the ```` quotes again.

doc/guides/nics/szedata2.rst line 83

Quoted 9 lines
(quoted diff) +2 -0
+
+*   DEVICE_NAME: contains prefix eth_szedata2 followed by numbers or

letters,

doc/guides/nics/szedata2.rst new file +6 -0
+    must be unique for each virtual device
+
+*   dev_path: Defines path to szedata2 device.
+    Value is valid path to szedata2 device.
+
+        dev_path=/dev/szedataII0

Code blocks should be prefixed by :: to render them correctly. See the guidelines and also view the output from "make doc-guides-html".

Same for the other items below.

doc/guides/nics/szedata2.rst line 98

Quoted 3 lines
doc/guides/nics/szedata2.rst new file +3 -0
+
+Example of usage
+^^^^^^^^^^^^^^^^

The convention is to use ~~~~~ for third level headings (see the guidelines). However, this could probably be a second level heading.

Review

Quoted 9 lines
(quoted diff) +9 -0
+
+Read packets from 0. and 1. receive channel and write them to 0. and 1.
+transmit channel
+
+.. code-block:: console
+
+    $RTE_TARGET/app/testpmd -c 0xf -n 2 --vdev
+ 'eth_szedata20,dev_path=/dev/szedataII0,rx_ifaces=0x3,tx_ifaces=0x3'
+ -- --port-topology=chained --rxq=2 --txq=2 --nb-cores=2

Again this code line is >80 chars and won't look good in the PDF. I'd suggest the following:

testpmd -c 0xf -n 2 \
--vdev 'eth_szedata20,dev_path=/dev/szedataII0,rx_ifaces=3,tx_ifaces=3' \
-- --port-topology=chained --rxq=2 --txq=2 --nb-cores=2

Quoted 7 lines
doc/guides/prog_guide/source_org.rst +0 -0
index ae11b3b..2393002 100644
@@ -106,6 +106,7 @@ The drivers directory has a *net* subdirectory which

contains::

Quoted 7 lines
     +-- null               # NULL poll mode driver for testing
     +-- pcap               # PCAP poll mode driver
     +-- ring               # Ring poll mode driver
+    +-- szedata2           # szedata2 poll mode driver
     +-- virtio             # Virtio poll mode driver
     +-- vmxnet3            # VMXNET3 poll mode driver
     +-- xenvirt            # Xen virtio poll mode driver

It isn't necessary to update this section. It is meant to be representative rather than comprehensive (at least to me). However if you leave it in then captilize the name like the others.

Thanks,

John

#19 lore raw

Re: [PATCH v2 4/5] doc: add documentation for szedata2 PMD

Hi John,

Thank you for your comments and advice. I will follow them in the new version.

Regards,
Matej Vido

2015-10-30 13:16 GMT+01:00 Mcnamara, John <[email protected]>:

Quoted 164 lines
Quoted 5 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Matej Vido
Sent: Friday, September 18, 2015 9:33 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH v2 4/5] doc: add documentation for szedata2

PMD

Quoted 3 lines

Hi,

Thanks for the new PMD and the documentation.

The DPDJ documentation guidelines provide some guidance on how to format and build the DPDK documentation:

http://dpdk.org/doc/guides/contributing/documentation.html

In terms of documentation for a PMD the Mellanox MLX4 docs are a good example:

http://dpdk.org/doc/guides/nics/mlx4.html

Some other comments below:

Quoted 2 lines

+SZEDATA2 PMD
+============

No need for an acronym in the title. Follow the MLX4 example and use something like " SZEDATA2 poll mode driver library".

Quoted 3 lines
(quoted diff) +2 -0
+SZEDATA2 PMD is virtual PMD which uses sze2 layer to communicate with
+COMBO cards (COMBO-80G, COMBO-100G) using interface provided by libsze2

library.

The introduction can be brief but should include enough information to explain the PMD for someone encountering it for the first time.

Some links would help with this. See the MLX4 doc as an example:

Quoted 7 lines
doc/guides/nics/szedata2.rst new file +4 -0
+
+.. note::
+
+   This driver has external dependencies. Therefore it is disabled in

default
+ configuration files. It can be enabled by setting
CONFIG_RTE_LIBRTE_PMD_SZEDATA2=y

Format configuration items as verbatim text with double backquotes:`` CONFIG_RTE_LIBRTE_PMD_SZEDATA2=y ``

doc/guides/nics/szedata2.rst line 65

Quoted 3 lines
doc/guides/nics/szedata2.rst new file +3 -0
+
+Using PMD
+---------

Better: Using the Szedata PMD

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+SZEDATA2 PMD can be created by passing --vdev= option to EAL in the

Again format --vdev as ``--vdev``. Also apply to other similar cases.

doc/guides/nics/szedata2.rst

Quoted 6 lines
doc/guides/nics/szedata2.rst new file +5 -0
+following format:
+
+.. code-block:: console
+
+    --vdev

'DEVICE_NAME,dev_path=PATH_TO_SZEDATA2_DEVICE,rx_ifaces=RX_MASK,tx_ifaces=

Quoted 1 line

TX_MASK'

This code line exceeds 80 chars and will exceed the page width in the PDF docs. If possible see if it can be shortened. Maybe use DEVICE instead of DEVICE_NAME and PATH instead of PATH_TO. The next section has an explanation anyway.

Review

Quoted 3 lines
(quoted diff) +3 -0
+
+DEVICE_NAME and options dev_path, rx_ifaces, tx_ifaces are mandatory
+and must be separated by commas.

Use the ```` quotes again.

doc/guides/nics/szedata2.rst line 83

Quoted 9 lines
(quoted diff) +2 -0
+
+*   DEVICE_NAME: contains prefix eth_szedata2 followed by numbers or

letters,

doc/guides/nics/szedata2.rst new file +6 -0
+    must be unique for each virtual device
+
+*   dev_path: Defines path to szedata2 device.
+    Value is valid path to szedata2 device.
+
+        dev_path=/dev/szedataII0

Code blocks should be prefixed by :: to render them correctly. See the guidelines and also view the output from "make doc-guides-html".

Same for the other items below.

doc/guides/nics/szedata2.rst line 98

Quoted 3 lines
doc/guides/nics/szedata2.rst new file +3 -0
+
+Example of usage
+^^^^^^^^^^^^^^^^

The convention is to use ~~~~~ for third level headings (see the guidelines). However, this could probably be a second level heading.

Review

Quoted 9 lines
(quoted diff) +9 -0
+
+Read packets from 0. and 1. receive channel and write them to 0. and 1.
+transmit channel
+
+.. code-block:: console
+
+    $RTE_TARGET/app/testpmd -c 0xf -n 2 --vdev
+ 'eth_szedata20,dev_path=/dev/szedataII0,rx_ifaces=0x3,tx_ifaces=0x3'
+ -- --port-topology=chained --rxq=2 --txq=2 --nb-cores=2

Again this code line is >80 chars and won't look good in the PDF. I'd suggest the following:

testpmd -c 0xf -n 2 \
--vdev 'eth_szedata20,dev_path=/dev/szedataII0,rx_ifaces=3,tx_ifaces=3' \
-- --port-topology=chained --rxq=2 --txq=2 --nb-cores=2

Quoted 7 lines
doc/guides/prog_guide/source_org.rst +0 -0
index ae11b3b..2393002 100644
@@ -106,6 +106,7 @@ The drivers directory has a *net* subdirectory which

contains::

Quoted 7 lines
     +-- null               # NULL poll mode driver for testing
     +-- pcap               # PCAP poll mode driver
     +-- ring               # Ring poll mode driver
+    +-- szedata2           # szedata2 poll mode driver
     +-- virtio             # Virtio poll mode driver
     +-- vmxnet3            # VMXNET3 poll mode driver
     +-- xenvirt            # Xen virtio poll mode driver

It isn't necessary to update this section. It is meant to be representative rather than comprehensive (at least to me). However if you leave it in then captilize the name like the others.

Thanks,

John

#20 lore raw

PATCH v2 5/5 doc: update 2.2 release notes

In reply to Matej Vido

Add szedata2 PMD to 2.2 release notes.

---
 doc/guides/rel_notes/release_2_2.rst | 4 ++++
 1 file changed, 4 insertions(+)
doc/guides/rel_notes/release_2_2.rst +4 -0
index 682f468..c78f94d 100644
@@ -4,6 +4,10 @@ DPDK Release 2.2
 New Features
 ------------
 
+* **Added virtual szedata2 driver for COMBO cards.**
+
+  Added virtual PMD for COMBO-100G and COMBO-80G cards.
+  PMD is disabled in default configuration.
 
 Resolved Issues
 ---------------
Signature · 1 line
1.9.1
#21 lore raw

PATCH v2 1/1 doc: update the dpdk 2.2 release notes

Update the DPDK 2.2 release notes with recent fixes:

7e01e3 i40e: fix base driver allocation when not using first numa node 5e73f4 ixgbe: remove burst size restriction of vector Rx 7fcd13 ixgbe: fix X550 DCB
d49e0f hash: fix memory allocation of cuckoo key table 9db649 eal/linux: fix epoll timeout

---

V2
* Added section headers to Resolved Issues.

 doc/guides/rel_notes/release_2_2.rst | 47 ++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
doc/guides/rel_notes/release_2_2.rst +47 -0
index 682f468..547c071 100644
@@ -8,6 +8,53 @@ New Features
 Resolved Issues
 ---------------
 
+EAL
+~~~
+
+* **eal/linux: Fixed epoll timeout.**
+
+  Fixed issue where the ``rte_epoll_wait()`` function didn't return when the
+  underlying call to ``epoll_wait()`` timed out.
+
+
+Libraries
+~~~~~~~~~
+
+* **hash: Fixed memory allocation of Cuckoo Hash key table.**
+
+  Fixed issue where an incorrect Cuckoo Hash key table size could be
+  calculated limiting the size to 4GB.
+
+  Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation")
+
+
+Drivers
+~~~~~~~
+
+* **i40e: Fixed base driver allocation when not using first numa node.**
+
+  Fixed i40e issue that occurred when a DPDK application didn't initialize
+  ports if memory wasn't available on socket 0.
+
+
+* **ixgbe: Fixed issue with X550 DCB.**
+
+  Fixed a DCB issue with x550 where for 8 TCs (Traffic Classes), if a packet
+  with user priority 6 or 7 was injected to the NIC, then the NIC would only
+  put 3 packets into the queue. There was also a similar issue for 4 TCs.
+
+* **ixgbe: Removed burst size restriction of vector RX.**
+
+  Fixed issue where a burst size less than 32 didn't receive anything.
+
+
+Examples
+~~~~~~~~
+
+
+Other
+~~~~~
+
 
 Known Issues
 ------------
Signature · 1 line
1.8.1.4
#22 lore raw

Re: [PATCH v2] doc: update the dpdk 2.2 release notes

2015-09-24 17:23, John McNamara:

Quoted 9 lines

Update the DPDK 2.2 release notes with recent fixes:

7e01e3 i40e: fix base driver allocation when not using first numa node 5e73f4 ixgbe: remove burst size restriction of vector Rx 7fcd13 ixgbe: fix X550 DCB
d49e0f hash: fix memory allocation of cuckoo key table 9db649 eal/linux: fix epoll timeout

Applied with small changes and one more recent fix.

I think we should not include Fixes: tags in the release notes. It looks better to keep it small with focus on what was fixed.

#23 lore raw

v3 cover Virtual PMD using sze2 layer for COMBO cards

In reply to Matej Vido

This is virtual PMD which communicates with COMBO-80G and COMBO-100G cards through sze2 layer. Communication with COMBO card is managed through interface provided by libsze2 library and kernel modules (combov3, szedata2_cv3).

To compile and use PMD, it is necessary to have libsze2 library installed and kernel modules (combov3, szedata2_cv3) loaded.
Therefore in default configuration PMD compilation is disabled. To compile szedata2 PMD, it is necessary to enable CONFIG_RTE_LIBRTE_PMD_SZEDATA2=y.

v3:
Fix checkpatch.pl issues.
Edit documentation.
Introduce RX and TX in separate patches.

v2:
code cleanup
add handling scattered packets
update release notes

Matej Vido (6):
szedata2: add new poll mode driver
szedata2: add non-scattered RX function
szedata2: add TX function
szedata2: add support for scattered packets in RX
doc: add documentation for szedata2 PMD
doc: update 2.2 release notes

 config/common_bsdapp                              |    5 +
 config/common_linuxapp                            |    5 +
 doc/guides/nics/index.rst                         |    1 +
 doc/guides/nics/szedata2.rst                      |  127 ++
 doc/guides/prog_guide/source_org.rst              |    1 +
 doc/guides/rel_notes/release_2_2.rst              |    4 +
 drivers/net/Makefile                              |    1 +
 drivers/net/szedata2/Makefile                     |   62 +
 drivers/net/szedata2/rte_eth_szedata2.c           | 1624 +++++++++++++++++++++
 drivers/net/szedata2/rte_eth_szedata2.h           |  102 ++
 drivers/net/szedata2/rte_pmd_szedata2_version.map |    3 +
 mk/rte.app.mk                                     |    3 +
 12 files changed, 1938 insertions(+)
 create mode 100644 doc/guides/nics/szedata2.rst
 create mode 100644 drivers/net/szedata2/Makefile
 create mode 100644 drivers/net/szedata2/rte_eth_szedata2.c
 create mode 100644 drivers/net/szedata2/rte_eth_szedata2.h
 create mode 100644 drivers/net/szedata2/rte_pmd_szedata2_version.map
Signature · 1 line
1.9.1
#24 lore raw

PATCH v3 1/6 szedata2: add new poll mode driver

Add virtual PMD which communicates with COMBO cards through sze2 layer using libsze2 library.

Since link_speed is uint16_t, there can not be used number for 100G speed, therefore link_speed is set to ETH_LINK_SPEED_10G until the type of link_speed is solved.

v3:
Fix checkpatch.pl issues.
Move RX, TX functions to separate patches.

v2:
Code cleanup.
Fix error handling by initialization of rx, tx dma channels. Add uninit function.

---
 config/common_bsdapp                              |   5 +
 config/common_linuxapp                            |   5 +
 drivers/net/Makefile                              |   1 +
 drivers/net/szedata2/Makefile                     |  62 ++
 drivers/net/szedata2/rte_eth_szedata2.c           | 830 ++++++++++++++++++++++
 drivers/net/szedata2/rte_eth_szedata2.h           | 102 +++
 drivers/net/szedata2/rte_pmd_szedata2_version.map |   3 +
 mk/rte.app.mk                                     |   3 +
 8 files changed, 1011 insertions(+)
 create mode 100644 drivers/net/szedata2/Makefile
 create mode 100644 drivers/net/szedata2/rte_eth_szedata2.c
 create mode 100644 drivers/net/szedata2/rte_eth_szedata2.h
 create mode 100644 drivers/net/szedata2/rte_pmd_szedata2_version.map
config/common_bsdapp +5 -0
index fba29e5..cd856ad 100644
@@ -284,6 +284,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=y
 
 #
+# Compile software PMD backed by SZEDATA2 device
+#
+CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
+
+#
 # Compile link bonding PMD library
 #
 CONFIG_RTE_LIBRTE_PMD_BOND=y
config/common_linuxapp +5 -0
index 7248262..fef5bde 100644
@@ -282,6 +282,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=n
 
 #
+# Compile software PMD backed by SZEDATA2 device
+#
+CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
+
+#
 # Compile link bonding PMD library
 #
 CONFIG_RTE_LIBRTE_PMD_BOND=y
drivers/net/Makefile +1 -0
index 6da1ce2..e05d2e5 100644
@@ -49,6 +49,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += ring
 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += xenvirt
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2) += szedata2
 
 include $(RTE_SDK)/mk/rte.sharelib.mk
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/net/szedata2/Makefile new file +62 -0

62 lines not on this page · raw message

drivers/net/szedata2/rte_eth_szedata2.c new file +830 -0

830 lines not on this page · raw message

drivers/net/szedata2/rte_eth_szedata2.h new file +102 -0

102 lines not on this page · raw message

drivers/net/szedata2/rte_pmd_szedata2_version.map new file +3 -0
new file mode 100644
index 0000000..ad607bb
@@ -0,0 +1,3 @@
+DPDK_2.2 {
+	local: *;
+};
mk/rte.app.mk +3 -0
index 724efa7..0bac99b 100644
@@ -92,6 +92,8 @@ endif # ! CONFIG_RTE_BUILD_COMBINE_LIBS
 
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP)       += -lpcap
 
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lsze2
+
 ifeq ($(CONFIG_RTE_LIBRTE_VHOST_NUMA),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST)          += -lnuma
 endif
@@ -147,6 +149,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_RING)       += -lrte_pmd_ring
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP)       += -lrte_pmd_pcap
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AF_PACKET)  += -lrte_pmd_af_packet
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL)       += -lrte_pmd_null
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lrte_pmd_szedata2
 
 endif # ! $(CONFIG_RTE_BUILD_SHARED_LIB)
 
Signature · 1 line
1.9.1
#25 lore raw

Re: [PATCH v3 1/6] szedata2: add new poll mode driver

Hi,

I'm doing some last checks before merging.

The libsze2 depends on libcommlbr so it would be better to list it on
https://www.liberouter.org/technologies/netcope/access-to-libsze2-library

A patch is needed in mk/ to allow linking these dependencies from a non-standard directory: http://dpdk.org/dev/patchwork/patch/9023

As only 64-bit versions of the libraries are provided, I guess we could mention it is currently supported only on x86-64.

2015-11-10 15:18, Matej Vido:

drivers/net/szedata2/rte_eth_szedata2.c line 439

Quoted 4 lines
drivers/net/szedata2/rte_eth_szedata2.c new file +4 -0
+static void
+eth_stats_get(struct rte_eth_dev *dev,
+		struct rte_eth_stats *igb_stats)
+{

igb_stats is a name inherited from old times. It is related to the first DPDK driver (igb).
I will rename it to "stats".

[...]

drivers/net/szedata2/rte_eth_szedata2.c line 586

Quoted 4 lines
drivers/net/szedata2/rte_eth_szedata2.c new file +4 -0
+       long int value;
+
+       value = strtol(mask_str, &endptr, 0);
+       if (*endptr != '\0' || value > UINT32_MAX || value < 0)

This check would not compile in 32-bit environment (which is not supported).

[...]

drivers/net/szedata2/rte_eth_szedata2.c line 697

Quoted 8 lines
drivers/net/szedata2/rte_eth_szedata2.c new file +8 -0
+static int
+rte_eth_from_szedata2(const char *name,
+               struct rxtx_szedata2 *szedata2,
+               const unsigned numa_node)
+{
+       struct pmd_internals *internals = NULL;
+       struct rte_eth_dev *eth_dev = NULL;
+       struct rte_eth_dev_data *data = NULL;

This data variable is not used before the patch 4/6. I will move it.

#26 lore raw

Re: [PATCH v3 1/6] szedata2: add new poll mode driver

Hi,

2015-11-20 16:04 GMT+01:00 Thomas Monjalon <[email protected]>:

Quoted 6 lines

Hi,

I'm doing some last checks before merging.

The libsze2 depends on libcommlbr so it would be better to list it on
https://www.liberouter.org/technologies/netcope/access-to-libsze2-library

Thank you for reminding, I will edit it.

Quoted 8 lines

A patch is needed in mk/ to allow linking these dependencies from a non-standard directory: http://dpdk.org/dev/patchwork/patch/9023

As only 64-bit versions of the libraries are provided, I guess we could mention it is currently supported only on x86-64.

I agree. Should I update the documentation and send a patch?

Quoted 22 lines

2015-11-10 15:18, Matej Vido:

drivers/net/szedata2/rte_eth_szedata2.c line 439

Quoted 4 lines
drivers/net/szedata2/rte_eth_szedata2.c new file +4 -0
+static void
+eth_stats_get(struct rte_eth_dev *dev,
+             struct rte_eth_stats *igb_stats)
+{

igb_stats is a name inherited from old times. It is related to the first DPDK driver (igb).
I will rename it to "stats".

[...]

drivers/net/szedata2/rte_eth_szedata2.c line 586

Quoted 4 lines
drivers/net/szedata2/rte_eth_szedata2.c new file +4 -0
+       long int value;
+
+       value = strtol(mask_str, &endptr, 0);
+       if (*endptr != '\0' || value > UINT32_MAX || value < 0)

This check would not compile in 32-bit environment (which is not supported).

[...]

Quoted 12 lines

drivers/net/szedata2/rte_eth_szedata2.c line 697

Quoted 8 lines
drivers/net/szedata2/rte_eth_szedata2.c new file +8 -0
+static int
+rte_eth_from_szedata2(const char *name,
+               struct rxtx_szedata2 *szedata2,
+               const unsigned numa_node)
+{
+       struct pmd_internals *internals = NULL;
+       struct rte_eth_dev *eth_dev = NULL;
+       struct rte_eth_dev_data *data = NULL;

This data variable is not used before the patch 4/6. I will move it.

Thanks for handling these changes.

Regards,
Matej

#27 lore raw

Re: [PATCH v3 1/6] szedata2: add new poll mode driver

2015-11-20 20:25, Matej Vido:

Quoted 4 lines
Quoted 2 lines

As only 64-bit versions of the libraries are provided, I guess we could mention it is currently supported only on x86-64.

I agree. Should I update the documentation and send a patch?

Yes please.

Another note: I use -rpath= in EXTRA_LDFLAGS to find the dependency of the dependency ;)

#28 lore raw

PATCH v3 2/6 szedata2: add non-scattered RX function

In reply to Matej Vido
---
 drivers/net/szedata2/rte_eth_szedata2.c | 235 +++++++++++++++++++++++++++++++-
 1 file changed, 234 insertions(+), 1 deletion(-)
drivers/net/szedata2/rte_eth_szedata2.c +234 -1
index 7edaefc..785ac88 100644
@@ -125,6 +125,239 @@ count_ones(uint32_t num)
 	return (((num + (num >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24; /* count */
 }
 
+static uint16_t
+eth_szedata2_rx(void *queue,
+		struct rte_mbuf **bufs,
+		uint16_t nb_pkts)
+{
+	unsigned int i;
+	struct rte_mbuf *mbuf;
+	struct szedata2_rx_queue *sze_q = queue;
+	struct rte_pktmbuf_pool_private *mbp_priv;
+	uint16_t num_rx = 0;
+	uint16_t buf_size;
+	uint16_t sg_size;
+	uint16_t hw_size;
+	uint16_t packet_size;
+	uint64_t num_bytes = 0;
+	struct szedata *sze = sze_q->sze;
+	uint8_t *header_ptr = NULL; /* header of packet */
+	uint8_t *packet_ptr1 = NULL;
+	uint8_t *packet_ptr2 = NULL;
+	uint16_t packet_len1 = 0;
+	uint16_t packet_len2 = 0;
+	uint16_t hw_data_align;
+
+	if (unlikely(sze_q->sze == NULL || nb_pkts == 0))
+		return 0;
+
+	/*
+	 * Reads the given number of packets from szedata2 channel given
+	 * by queue and copies the packet data into a newly allocated mbuf
+	 * to return.
+	 */
+	for (i = 0; i < nb_pkts; i++) {
+		mbuf = rte_pktmbuf_alloc(sze_q->mb_pool);
+
+		if (unlikely(mbuf == NULL))
+			break;
+
+		/* get the next sze packet */
+		if (sze->ct_rx_lck != NULL && !sze->ct_rx_rem_bytes &&
+				sze->ct_rx_lck->next == NULL) {
+			/* unlock old data */
+			szedata_rx_unlock_data(sze_q->sze, sze->ct_rx_lck_orig);
+			sze->ct_rx_lck_orig = NULL;
+			sze->ct_rx_lck = NULL;
+		}
+
+		if (!sze->ct_rx_rem_bytes && sze->ct_rx_lck_orig == NULL) {
+			/* nothing to read, lock new data */
+			sze->ct_rx_lck = szedata_rx_lock_data(sze_q->sze, ~0U);
+			sze->ct_rx_lck_orig = sze->ct_rx_lck;
+
+			if (sze->ct_rx_lck == NULL) {
+				/* nothing to lock */
+				rte_pktmbuf_free(mbuf);
+				break;
+			}
+
+			sze->ct_rx_cur_ptr = sze->ct_rx_lck->start;
+			sze->ct_rx_rem_bytes = sze->ct_rx_lck->len;
+
+			if (!sze->ct_rx_rem_bytes) {
+				rte_pktmbuf_free(mbuf);
+				break;
+			}
+		}
+
+		if (sze->ct_rx_rem_bytes < RTE_SZE2_PACKET_HEADER_SIZE) {
+			/*
+			 * cut in header
+			 * copy parts of header to merge buffer
+			 */
+			if (sze->ct_rx_lck->next == NULL) {
+				rte_pktmbuf_free(mbuf);
+				break;
+			}
+
+			/* copy first part of header */
+			rte_memcpy(sze->ct_rx_buffer, sze->ct_rx_cur_ptr,
+					sze->ct_rx_rem_bytes);
+
+			/* copy second part of header */
+			sze->ct_rx_lck = sze->ct_rx_lck->next;
+			sze->ct_rx_cur_ptr = sze->ct_rx_lck->start;
+			rte_memcpy(sze->ct_rx_buffer + sze->ct_rx_rem_bytes,
+				sze->ct_rx_cur_ptr,
+				RTE_SZE2_PACKET_HEADER_SIZE -
+				sze->ct_rx_rem_bytes);
+
+			sze->ct_rx_cur_ptr += RTE_SZE2_PACKET_HEADER_SIZE -
+				sze->ct_rx_rem_bytes;
+			sze->ct_rx_rem_bytes = sze->ct_rx_lck->len -
+				RTE_SZE2_PACKET_HEADER_SIZE +
+				sze->ct_rx_rem_bytes;
+
+			header_ptr = (uint8_t *)sze->ct_rx_buffer;
+		} else {
+			/* not cut */
+			header_ptr = (uint8_t *)sze->ct_rx_cur_ptr;
+			sze->ct_rx_cur_ptr += RTE_SZE2_PACKET_HEADER_SIZE;
+			sze->ct_rx_rem_bytes -= RTE_SZE2_PACKET_HEADER_SIZE;
+		}
+
+		sg_size = le16toh(*((uint16_t *)header_ptr));
+		hw_size = le16toh(*(((uint16_t *)header_ptr) + 1));
+		packet_size = sg_size -
+			RTE_SZE2_ALIGN8(RTE_SZE2_PACKET_HEADER_SIZE + hw_size);
+
+
+		/* checks if packet all right */
+		if (!sg_size)
+			errx(5, "Zero segsize");
+
+		/* check sg_size and hwsize */
+		if (hw_size > sg_size - RTE_SZE2_PACKET_HEADER_SIZE) {
+			errx(10, "Hwsize bigger than expected. Segsize: %d, "
+				"hwsize: %d", sg_size, hw_size);
+		}
+
+		hw_data_align =
+			RTE_SZE2_ALIGN8(RTE_SZE2_PACKET_HEADER_SIZE + hw_size) -
+			RTE_SZE2_PACKET_HEADER_SIZE;
+
+		if (sze->ct_rx_rem_bytes >=
+				(uint16_t)(sg_size -
+				RTE_SZE2_PACKET_HEADER_SIZE)) {
+			/* no cut */
+			/* one packet ready - go to another */
+			packet_ptr1 = sze->ct_rx_cur_ptr + hw_data_align;
+			packet_len1 = packet_size;
+			packet_ptr2 = NULL;
+			packet_len2 = 0;
+
+			sze->ct_rx_cur_ptr += RTE_SZE2_ALIGN8(sg_size) -
+				RTE_SZE2_PACKET_HEADER_SIZE;
+			sze->ct_rx_rem_bytes -= RTE_SZE2_ALIGN8(sg_size) -
+				RTE_SZE2_PACKET_HEADER_SIZE;
+		} else {
+			/* cut in data */
+			if (sze->ct_rx_lck->next == NULL) {
+				errx(6, "Need \"next\" lock, "
+					"but it is missing: %u",
+					sze->ct_rx_rem_bytes);
+			}
+
+			/* skip hw data */
+			if (sze->ct_rx_rem_bytes <= hw_data_align) {
+				uint16_t rem_size = hw_data_align -
+					sze->ct_rx_rem_bytes;
+
+				/* MOVE to next lock */
+				sze->ct_rx_lck = sze->ct_rx_lck->next;
+				sze->ct_rx_cur_ptr =
+					(void *)(((uint8_t *)
+					(sze->ct_rx_lck->start)) + rem_size);
+
+				packet_ptr1 = sze->ct_rx_cur_ptr;
+				packet_len1 = packet_size;
+				packet_ptr2 = NULL;
+				packet_len2 = 0;
+
+				sze->ct_rx_cur_ptr +=
+					RTE_SZE2_ALIGN8(packet_size);
+				sze->ct_rx_rem_bytes = sze->ct_rx_lck->len -
+					rem_size - RTE_SZE2_ALIGN8(packet_size);
+			} else {
+				/* get pointer and length from first part */
+				packet_ptr1 = sze->ct_rx_cur_ptr +
+					hw_data_align;
+				packet_len1 = sze->ct_rx_rem_bytes -
+					hw_data_align;
+
+				/* MOVE to next lock */
+				sze->ct_rx_lck = sze->ct_rx_lck->next;
+				sze->ct_rx_cur_ptr = sze->ct_rx_lck->start;
+
+				/* get pointer and length from second part */
+				packet_ptr2 = sze->ct_rx_cur_ptr;
+				packet_len2 = packet_size - packet_len1;
+
+				sze->ct_rx_cur_ptr +=
+					RTE_SZE2_ALIGN8(packet_size) -
+					packet_len1;
+				sze->ct_rx_rem_bytes = sze->ct_rx_lck->len -
+					(RTE_SZE2_ALIGN8(packet_size) -
+					 packet_len1);
+			}
+		}
+
+		if (unlikely(packet_ptr1 == NULL)) {
+			rte_pktmbuf_free(mbuf);
+			break;
+		}
+
+		/* get the space available for data in the mbuf */
+		mbp_priv = rte_mempool_get_priv(sze_q->mb_pool);
+		buf_size = (uint16_t)(mbp_priv->mbuf_data_room_size -
+				RTE_PKTMBUF_HEADROOM);
+
+		if (packet_size <= buf_size) {
+			/* sze packet will fit in one mbuf, go ahead and copy */
+			rte_memcpy(rte_pktmbuf_mtod(mbuf, void *),
+					packet_ptr1, packet_len1);
+			if (packet_ptr2 != NULL) {
+				rte_memcpy((void *)(rte_pktmbuf_mtod(mbuf,
+					uint8_t *) + packet_len1),
+					packet_ptr2, packet_len2);
+			}
+			mbuf->data_len = (uint16_t)packet_size;
+
+			mbuf->pkt_len = packet_size;
+			mbuf->port = sze_q->in_port;
+			bufs[num_rx] = mbuf;
+			num_rx++;
+			num_bytes += packet_size;
+		} else {
+			/*
+			 * sze packet will not fit in one mbuf,
+			 * scattered mode is not enabled, drop packet
+			 */
+			RTE_LOG(ERR, PMD,
+				"SZE segment %d bytes will not fit in one mbuf "
+				"(%d bytes), scattered mode is not enabled, "
+				"drop packet!!\n",
+				packet_size, buf_size);
+			rte_pktmbuf_free(mbuf);
+		}
+	}
+
+	sze_q->rx_pkts += num_rx;
+	sze_q->rx_bytes += num_bytes;
+	return num_rx;
+}
+
 static int
 init_rx_channels(struct rte_eth_dev *dev, int v)
 {
@@ -727,7 +960,7 @@ rte_eth_from_szedata2(const char *name,
 		return -1;
 	}
 
-	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->rx_pkt_burst = eth_szedata2_rx;
 	eth_dev->tx_pkt_burst = NULL;
 
 	return 0;
Signature · 1 line
1.9.1
#29 lore raw

PATCH v3 3/6 szedata2: add TX function

In reply to Matej Vido

TX function handles scattered and non-scattered packets.

---
 drivers/net/szedata2/rte_eth_szedata2.c | 216 +++++++++++++++++++++++++++++++-
 1 file changed, 215 insertions(+), 1 deletion(-)
drivers/net/szedata2/rte_eth_szedata2.c +215 -1
index 785ac88..3213a20 100644
@@ -358,6 +358,220 @@ eth_szedata2_rx(void *queue,
 	return num_rx;
 }
 
+static uint16_t
+eth_szedata2_tx(void *queue,
+		struct rte_mbuf **bufs,
+		uint16_t nb_pkts)
+{
+	struct rte_mbuf *mbuf;
+	struct szedata2_tx_queue *sze_q = queue;
+	uint16_t num_tx = 0;
+	uint64_t num_bytes = 0;
+
+	const struct szedata_lock *lck;
+	uint32_t lock_size;
+	uint32_t lock_size2;
+	void *dst;
+	uint32_t pkt_len;
+	uint32_t hwpkt_len;
+	uint32_t unlock_size;
+	uint32_t rem_len;
+	uint8_t mbuf_segs;
+	uint16_t pkt_left = nb_pkts;
+
+	if (sze_q->sze == NULL || nb_pkts == 0)
+		return 0;
+
+	while (pkt_left > 0) {
+		unlock_size = 0;
+		lck = szedata_tx_lock_data(sze_q->sze,
+			RTE_ETH_SZEDATA2_TX_LOCK_SIZE,
+			sze_q->tx_channel);
+		if (lck == NULL)
+			continue;
+
+		dst = lck->start;
+		lock_size = lck->len;
+		lock_size2 = lck->next ? lck->next->len : 0;
+
+next_packet:
+		mbuf = bufs[nb_pkts - pkt_left];
+
+		pkt_len = mbuf->pkt_len;
+		mbuf_segs = mbuf->nb_segs;
+
+		hwpkt_len = RTE_SZE2_PACKET_HEADER_SIZE_ALIGNED +
+			RTE_SZE2_ALIGN8(pkt_len);
+
+		if (lock_size + lock_size2 < hwpkt_len) {
+			szedata_tx_unlock_data(sze_q->sze, lck, unlock_size);
+			continue;
+		}
+
+		num_bytes += pkt_len;
+
+		if (lock_size > hwpkt_len) {
+			void *tmp_dst;
+
+			rem_len = 0;
+
+			/* write packet length at first 2 bytes in 8B header */
+			*((uint16_t *)dst) = htole16(
+					RTE_SZE2_PACKET_HEADER_SIZE_ALIGNED +
+					pkt_len);
+			*(((uint16_t *)dst) + 1) = htole16(0);
+
+			/* copy packet from mbuf */
+			tmp_dst = ((uint8_t *)(dst)) +
+				RTE_SZE2_PACKET_HEADER_SIZE_ALIGNED;
+			if (mbuf_segs == 1) {
+				/*
+				 * non-scattered packet,
+				 * transmit from one mbuf
+				 */
+				rte_memcpy(tmp_dst,
+					rte_pktmbuf_mtod(mbuf, const void *),
+					pkt_len);
+			} else {
+				/* scattered packet, transmit from more mbufs */
+				struct rte_mbuf *m = mbuf;
+				while (m) {
+					rte_memcpy(tmp_dst,
+						rte_pktmbuf_mtod(m,
+						const void *),
+						m->data_len);
+					tmp_dst = ((uint8_t *)(tmp_dst)) +
+						m->data_len;
+					m = m->next;
+				}
+			}
+
+
+			dst = ((uint8_t *)dst) + hwpkt_len;
+			unlock_size += hwpkt_len;
+			lock_size -= hwpkt_len;
+
+			rte_pktmbuf_free(mbuf);
+			num_tx++;
+			pkt_left--;
+			if (pkt_left == 0) {
+				szedata_tx_unlock_data(sze_q->sze, lck,
+					unlock_size);
+				break;
+			}
+			goto next_packet;
+		} else if (lock_size + lock_size2 >= hwpkt_len) {
+			void *tmp_dst;
+			uint16_t write_len;
+
+			/* write packet length at first 2 bytes in 8B header */
+			*((uint16_t *)dst) =
+				htole16(RTE_SZE2_PACKET_HEADER_SIZE_ALIGNED +
+					pkt_len);
+			*(((uint16_t *)dst) + 1) = htole16(0);
+
+			/*
+			 * If the raw packet (pkt_len) is smaller than lock_size
+			 * get the correct length for memcpy
+			 */
+			write_len =
+				pkt_len < lock_size -
+				RTE_SZE2_PACKET_HEADER_SIZE_ALIGNED ?
+				pkt_len :
+				lock_size - RTE_SZE2_PACKET_HEADER_SIZE_ALIGNED;
+
+			rem_len = hwpkt_len - lock_size;
+
+			tmp_dst = ((uint8_t *)(dst)) +
+				RTE_SZE2_PACKET_HEADER_SIZE_ALIGNED;
+			if (mbuf_segs == 1) {
+				/*
+				 * non-scattered packet,
+				 * transmit from one mbuf
+				 */
+				/* copy part of packet to first area */
+				rte_memcpy(tmp_dst,
+					rte_pktmbuf_mtod(mbuf, const void *),
+					write_len);
+
+				if (lck->next)
+					dst = lck->next->start;
+
+				/* copy part of packet to second area */
+				rte_memcpy(dst,
+					(const void *)(rte_pktmbuf_mtod(mbuf,
+							const uint8_t *) +
+					write_len), pkt_len - write_len);
+			} else {
+				/* scattered packet, transmit from more mbufs */
+				struct rte_mbuf *m = mbuf;
+				uint16_t written = 0;
+				uint16_t to_write = 0;
+				bool new_mbuf = true;
+				uint16_t write_off = 0;
+
+				/* copy part of packet to first area */
+				while (m && written < write_len) {
+					to_write = RTE_MIN(m->data_len,
+							write_len - written);
+					rte_memcpy(tmp_dst,
+						rte_pktmbuf_mtod(m,
+							const void *),
+						to_write);
+
+					tmp_dst = ((uint8_t *)(tmp_dst)) +
+						to_write;
+					if (m->data_len <= write_len -
+							written) {
+						m = m->next;
+						new_mbuf = true;
+					} else {
+						new_mbuf = false;
+					}
+					written += to_write;
+				}
+
+				if (lck->next)
+					dst = lck->next->start;
+
+				tmp_dst = dst;
+				written = 0;
+				write_off = new_mbuf ? 0 : to_write;
+
+				/* copy part of packet to second area */
+				while (m && written < pkt_len - write_len) {
+					rte_memcpy(tmp_dst, (const void *)
+						(rte_pktmbuf_mtod(m,
+						uint8_t *) + write_off),
+						m->data_len - write_off);
+
+					tmp_dst = ((uint8_t *)(tmp_dst)) +
+						(m->data_len - write_off);
+					written += m->data_len - write_off;
+					m = m->next;
+					write_off = 0;
+				}
+			}
+
+			dst = ((uint8_t *)dst) + rem_len;
+			unlock_size += hwpkt_len;
+			lock_size = lock_size2 - rem_len;
+			lock_size2 = 0;
+
+			rte_pktmbuf_free(mbuf);
+			num_tx++;
+		}
+
+		szedata_tx_unlock_data(sze_q->sze, lck, unlock_size);
+		pkt_left--;
+	}
+
+	sze_q->tx_pkts += num_tx;
+	sze_q->err_pkts += nb_pkts - num_tx;
+	sze_q->tx_bytes += num_bytes;
+	return num_tx;
+}
+
 static int
 init_rx_channels(struct rte_eth_dev *dev, int v)
 {
@@ -961,7 +1175,7 @@ rte_eth_from_szedata2(const char *name,
 	}
 
 	eth_dev->rx_pkt_burst = eth_szedata2_rx;
-	eth_dev->tx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = eth_szedata2_tx;
 
 	return 0;
 }
Signature · 1 line
1.9.1
#30 lore raw

PATCH v3 4/6 szedata2: add support for scattered packets in RX

In reply to Matej Vido

Add new RX function for handling scattered packets.

---
 drivers/net/szedata2/rte_eth_szedata2.c | 351 +++++++++++++++++++++++++++++++-
 1 file changed, 349 insertions(+), 2 deletions(-)
drivers/net/szedata2/rte_eth_szedata2.c +349 -2
index 3213a20..22c99e4 100644
@@ -359,6 +359,338 @@ eth_szedata2_rx(void *queue,
 }
 
 static uint16_t
+eth_szedata2_rx_scattered(void *queue,
+		struct rte_mbuf **bufs,
+		uint16_t nb_pkts)
+{
+	unsigned int i;
+	struct rte_mbuf *mbuf;
+	struct szedata2_rx_queue *sze_q = queue;
+	struct rte_pktmbuf_pool_private *mbp_priv;
+	uint16_t num_rx = 0;
+	uint16_t buf_size;
+	uint16_t sg_size;
+	uint16_t hw_size;
+	uint16_t packet_size;
+	uint64_t num_bytes = 0;
+	struct szedata *sze = sze_q->sze;
+	uint8_t *header_ptr = NULL; /* header of packet */
+	uint8_t *packet_ptr1 = NULL;
+	uint8_t *packet_ptr2 = NULL;
+	uint16_t packet_len1 = 0;
+	uint16_t packet_len2 = 0;
+	uint16_t hw_data_align;
+
+	if (unlikely(sze_q->sze == NULL || nb_pkts == 0))
+		return 0;
+
+	/*
+	 * Reads the given number of packets from szedata2 channel given
+	 * by queue and copies the packet data into a newly allocated mbuf
+	 * to return.
+	 */
+	for (i = 0; i < nb_pkts; i++) {
+		const struct szedata_lock *ct_rx_lck_backup;
+		unsigned int ct_rx_rem_bytes_backup;
+		unsigned char *ct_rx_cur_ptr_backup;
+
+		/* get the next sze packet */
+		if (sze->ct_rx_lck != NULL && !sze->ct_rx_rem_bytes &&
+				sze->ct_rx_lck->next == NULL) {
+			/* unlock old data */
+			szedata_rx_unlock_data(sze_q->sze, sze->ct_rx_lck_orig);
+			sze->ct_rx_lck_orig = NULL;
+			sze->ct_rx_lck = NULL;
+		}
+
+		/*
+		 * Store items from sze structure which can be changed
+		 * before mbuf allocating. Use these items in case of mbuf
+		 * allocating failure.
+		 */
+		ct_rx_lck_backup = sze->ct_rx_lck;
+		ct_rx_rem_bytes_backup = sze->ct_rx_rem_bytes;
+		ct_rx_cur_ptr_backup = sze->ct_rx_cur_ptr;
+
+		if (!sze->ct_rx_rem_bytes && sze->ct_rx_lck_orig == NULL) {
+			/* nothing to read, lock new data */
+			sze->ct_rx_lck = szedata_rx_lock_data(sze_q->sze, ~0U);
+			sze->ct_rx_lck_orig = sze->ct_rx_lck;
+
+			/*
+			 * Backup items from sze structure must be updated
+			 * after locking to contain pointers to new locks.
+			 */
+			ct_rx_lck_backup = sze->ct_rx_lck;
+			ct_rx_rem_bytes_backup = sze->ct_rx_rem_bytes;
+			ct_rx_cur_ptr_backup = sze->ct_rx_cur_ptr;
+
+			if (sze->ct_rx_lck == NULL)
+				/* nothing to lock */
+				break;
+
+			sze->ct_rx_cur_ptr = sze->ct_rx_lck->start;
+			sze->ct_rx_rem_bytes = sze->ct_rx_lck->len;
+
+			if (!sze->ct_rx_rem_bytes)
+				break;
+		}
+
+		if (sze->ct_rx_rem_bytes < RTE_SZE2_PACKET_HEADER_SIZE) {
+			/*
+			 * cut in header - copy parts of header to merge buffer
+			 */
+			if (sze->ct_rx_lck->next == NULL)
+				break;
+
+			/* copy first part of header */
+			rte_memcpy(sze->ct_rx_buffer, sze->ct_rx_cur_ptr,
+					sze->ct_rx_rem_bytes);
+
+			/* copy second part of header */
+			sze->ct_rx_lck = sze->ct_rx_lck->next;
+			sze->ct_rx_cur_ptr = sze->ct_rx_lck->start;
+			rte_memcpy(sze->ct_rx_buffer + sze->ct_rx_rem_bytes,
+				sze->ct_rx_cur_ptr,
+				RTE_SZE2_PACKET_HEADER_SIZE -
+				sze->ct_rx_rem_bytes);
+
+			sze->ct_rx_cur_ptr += RTE_SZE2_PACKET_HEADER_SIZE -
+				sze->ct_rx_rem_bytes;
+			sze->ct_rx_rem_bytes = sze->ct_rx_lck->len -
+				RTE_SZE2_PACKET_HEADER_SIZE +
+				sze->ct_rx_rem_bytes;
+
+			header_ptr = (uint8_t *)sze->ct_rx_buffer;
+		} else {
+			/* not cut */
+			header_ptr = (uint8_t *)sze->ct_rx_cur_ptr;
+			sze->ct_rx_cur_ptr += RTE_SZE2_PACKET_HEADER_SIZE;
+			sze->ct_rx_rem_bytes -= RTE_SZE2_PACKET_HEADER_SIZE;
+		}
+
+		sg_size = le16toh(*((uint16_t *)header_ptr));
+		hw_size = le16toh(*(((uint16_t *)header_ptr) + 1));
+		packet_size = sg_size -
+			RTE_SZE2_ALIGN8(RTE_SZE2_PACKET_HEADER_SIZE + hw_size);
+
+
+		/* checks if packet all right */
+		if (!sg_size)
+			errx(5, "Zero segsize");
+
+		/* check sg_size and hwsize */
+		if (hw_size > sg_size - RTE_SZE2_PACKET_HEADER_SIZE) {
+			errx(10, "Hwsize bigger than expected. Segsize: %d, "
+					"hwsize: %d", sg_size, hw_size);
+		}
+
+		hw_data_align =
+			RTE_SZE2_ALIGN8((RTE_SZE2_PACKET_HEADER_SIZE +
+			hw_size)) - RTE_SZE2_PACKET_HEADER_SIZE;
+
+		if (sze->ct_rx_rem_bytes >=
+				(uint16_t)(sg_size -
+				RTE_SZE2_PACKET_HEADER_SIZE)) {
+			/* no cut */
+			/* one packet ready - go to another */
+			packet_ptr1 = sze->ct_rx_cur_ptr + hw_data_align;
+			packet_len1 = packet_size;
+			packet_ptr2 = NULL;
+			packet_len2 = 0;
+
+			sze->ct_rx_cur_ptr += RTE_SZE2_ALIGN8(sg_size) -
+				RTE_SZE2_PACKET_HEADER_SIZE;
+			sze->ct_rx_rem_bytes -= RTE_SZE2_ALIGN8(sg_size) -
+				RTE_SZE2_PACKET_HEADER_SIZE;
+		} else {
+			/* cut in data */
+			if (sze->ct_rx_lck->next == NULL) {
+				errx(6, "Need \"next\" lock, but it is "
+					"missing: %u", sze->ct_rx_rem_bytes);
+			}
+
+			/* skip hw data */
+			if (sze->ct_rx_rem_bytes <= hw_data_align) {
+				uint16_t rem_size = hw_data_align -
+					sze->ct_rx_rem_bytes;
+
+				/* MOVE to next lock */
+				sze->ct_rx_lck = sze->ct_rx_lck->next;
+				sze->ct_rx_cur_ptr =
+					(void *)(((uint8_t *)
+					(sze->ct_rx_lck->start)) + rem_size);
+
+				packet_ptr1 = sze->ct_rx_cur_ptr;
+				packet_len1 = packet_size;
+				packet_ptr2 = NULL;
+				packet_len2 = 0;
+
+				sze->ct_rx_cur_ptr +=
+					RTE_SZE2_ALIGN8(packet_size);
+				sze->ct_rx_rem_bytes = sze->ct_rx_lck->len -
+					rem_size - RTE_SZE2_ALIGN8(packet_size);
+			} else {
+				/* get pointer and length from first part */
+				packet_ptr1 = sze->ct_rx_cur_ptr +
+					hw_data_align;
+				packet_len1 = sze->ct_rx_rem_bytes -
+					hw_data_align;
+
+				/* MOVE to next lock */
+				sze->ct_rx_lck = sze->ct_rx_lck->next;
+				sze->ct_rx_cur_ptr = sze->ct_rx_lck->start;
+
+				/* get pointer and length from second part */
+				packet_ptr2 = sze->ct_rx_cur_ptr;
+				packet_len2 = packet_size - packet_len1;
+
+				sze->ct_rx_cur_ptr +=
+					RTE_SZE2_ALIGN8(packet_size) -
+					packet_len1;
+				sze->ct_rx_rem_bytes = sze->ct_rx_lck->len -
+					(RTE_SZE2_ALIGN8(packet_size) -
+					 packet_len1);
+			}
+		}
+
+		if (unlikely(packet_ptr1 == NULL))
+			break;
+
+		mbuf = rte_pktmbuf_alloc(sze_q->mb_pool);
+
+		if (unlikely(mbuf == NULL)) {
+			/*
+			 * Restore items from sze structure to state after
+			 * unlocking (eventually locking).
+			 */
+			sze->ct_rx_lck = ct_rx_lck_backup;
+			sze->ct_rx_rem_bytes = ct_rx_rem_bytes_backup;
+			sze->ct_rx_cur_ptr = ct_rx_cur_ptr_backup;
+			break;
+		}
+
+		/* get the space available for data in the mbuf */
+		mbp_priv = rte_mempool_get_priv(sze_q->mb_pool);
+		buf_size = (uint16_t)(mbp_priv->mbuf_data_room_size -
+				RTE_PKTMBUF_HEADROOM);
+
+		if (packet_size <= buf_size) {
+			/* sze packet will fit in one mbuf, go ahead and copy */
+			rte_memcpy(rte_pktmbuf_mtod(mbuf, void *),
+					packet_ptr1, packet_len1);
+			if (packet_ptr2 != NULL) {
+				rte_memcpy((void *)
+					(rte_pktmbuf_mtod(mbuf, uint8_t *) +
+					packet_len1), packet_ptr2, packet_len2);
+			}
+			mbuf->data_len = (uint16_t)packet_size;
+		} else {
+			/*
+			 * sze packet will not fit in one mbuf,
+			 * scatter packet into more mbufs
+			 */
+			struct rte_mbuf *m = mbuf;
+			uint16_t len = rte_pktmbuf_tailroom(mbuf);
+
+			/* copy first part of packet */
+			/* fill first mbuf */
+			rte_memcpy(rte_pktmbuf_append(mbuf, len), packet_ptr1,
+				len);
+			packet_len1 -= len;
+			packet_ptr1 = ((uint8_t *)packet_ptr1) + len;
+
+			while (packet_len1 > 0) {
+				/* fill new mbufs */
+				m->next = rte_pktmbuf_alloc(sze_q->mb_pool);
+
+				if (unlikely(m->next == NULL)) {
+					rte_pktmbuf_free(mbuf);
+					/*
+					 * Restore items from sze structure
+					 * to state after unlocking (eventually
+					 * locking).
+					 */
+					sze->ct_rx_lck = ct_rx_lck_backup;
+					sze->ct_rx_rem_bytes =
+						ct_rx_rem_bytes_backup;
+					sze->ct_rx_cur_ptr =
+						ct_rx_cur_ptr_backup;
+					goto finish;
+				}
+
+				m = m->next;
+
+				len = RTE_MIN(rte_pktmbuf_tailroom(m),
+					packet_len1);
+				rte_memcpy(rte_pktmbuf_append(mbuf, len),
+					packet_ptr1, len);
+
+				(mbuf->nb_segs)++;
+				packet_len1 -= len;
+				packet_ptr1 = ((uint8_t *)packet_ptr1) + len;
+			}
+
+			if (packet_ptr2 != NULL) {
+				/* copy second part of packet, if exists */
+				/* fill the rest of currently last mbuf */
+				len = rte_pktmbuf_tailroom(m);
+				rte_memcpy(rte_pktmbuf_append(mbuf, len),
+					packet_ptr2, len);
+				packet_len2 -= len;
+				packet_ptr2 = ((uint8_t *)packet_ptr2) + len;
+
+				while (packet_len2 > 0) {
+					/* fill new mbufs */
+					m->next = rte_pktmbuf_alloc(
+							sze_q->mb_pool);
+
+					if (unlikely(m->next == NULL)) {
+						rte_pktmbuf_free(mbuf);
+						/*
+						 * Restore items from sze
+						 * structure to state after
+						 * unlocking (eventually
+						 * locking).
+						 */
+						sze->ct_rx_lck =
+							ct_rx_lck_backup;
+						sze->ct_rx_rem_bytes =
+							ct_rx_rem_bytes_backup;
+						sze->ct_rx_cur_ptr =
+							ct_rx_cur_ptr_backup;
+						goto finish;
+					}
+
+					m = m->next;
+
+					len = RTE_MIN(rte_pktmbuf_tailroom(m),
+						packet_len2);
+					rte_memcpy(
+						rte_pktmbuf_append(mbuf, len),
+						packet_ptr2, len);
+
+					(mbuf->nb_segs)++;
+					packet_len2 -= len;
+					packet_ptr2 = ((uint8_t *)packet_ptr2) +
+						len;
+				}
+			}
+		}
+		mbuf->pkt_len = packet_size;
+		mbuf->port = sze_q->in_port;
+		bufs[num_rx] = mbuf;
+		num_rx++;
+		num_bytes += packet_size;
+	}
+
+finish:
+	sze_q->rx_pkts += num_rx;
+	sze_q->rx_bytes += num_bytes;
+	return num_rx;
+}
+
+static uint16_t
 eth_szedata2_tx(void *queue,
 		struct rte_mbuf **bufs,
 		uint16_t nb_pkts)
@@ -860,8 +1192,16 @@ eth_dev_stop(struct rte_eth_dev *dev)
 }
 
 static int
-eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
+eth_dev_configure(struct rte_eth_dev *dev)
 {
+	struct rte_eth_dev_data *data = dev->data;
+	if (data->dev_conf.rxmode.enable_scatter == 1) {
+		dev->rx_pkt_burst = eth_szedata2_rx_scattered;
+		data->scattered_rx = 1;
+	} else {
+		dev->rx_pkt_burst = eth_szedata2_rx;
+		data->scattered_rx = 0;
+	}
 	return 0;
 }
 
@@ -1174,7 +1514,14 @@ rte_eth_from_szedata2(const char *name,
 		return -1;
 	}
 
-	eth_dev->rx_pkt_burst = eth_szedata2_rx;
+	if (data->dev_conf.rxmode.enable_scatter == 1 ||
+		data->scattered_rx == 1) {
+		eth_dev->rx_pkt_burst = eth_szedata2_rx_scattered;
+		data->scattered_rx = 1;
+	} else {
+		eth_dev->rx_pkt_burst = eth_szedata2_rx;
+		data->scattered_rx = 0;
+	}
 	eth_dev->tx_pkt_burst = eth_szedata2_tx;
 
 	return 0;
Signature · 1 line
1.9.1
#31 lore raw

PATCH v3 5/6 doc: add documentation for szedata2 PMD

In reply to Matej Vido

v3:
Edit formatting.
Add links.

---
 doc/guides/nics/index.rst            |   1 +
 doc/guides/nics/szedata2.rst         | 127 +++++++++++++++++++++++++++++++++++
 doc/guides/prog_guide/source_org.rst |   1 +
 3 files changed, 129 insertions(+)
 create mode 100644 doc/guides/nics/szedata2.rst
doc/guides/nics/index.rst +1 -0
index 2d4936d..0a0b724 100644
@@ -46,6 +46,7 @@ Network Interface Controller Drivers
     intel_vf
     mlx4
     mlx5
+    szedata2
     virtio
     vmxnet3
     pcap_ring
doc/guides/nics/szedata2.rst new file +127 -0

127 lines not on this page · raw message

doc/guides/prog_guide/source_org.rst +1 -0
index ae11b3b..0c06d47 100644
@@ -106,6 +106,7 @@ The drivers directory has a *net* subdirectory which contains::
     +-- null               # NULL poll mode driver for testing
     +-- pcap               # PCAP poll mode driver
     +-- ring               # Ring poll mode driver
+    +-- szedata2           # SZEDATA2 poll mode driver
     +-- virtio             # Virtio poll mode driver
     +-- vmxnet3            # VMXNET3 poll mode driver
     +-- xenvirt            # Xen virtio poll mode driver
Signature · 1 line
1.9.1
#33 lore raw

PATCH v3 6/6 doc: update 2.2 release notes

In reply to Matej Vido

Add szedata2 PMD to 2.2 release notes.

---
 doc/guides/rel_notes/release_2_2.rst | 4 ++++
 1 file changed, 4 insertions(+)
doc/guides/rel_notes/release_2_2.rst +4 -0
index ca8471b..2ae9ba3 100644
@@ -90,6 +90,10 @@ New Features
 
 * **Added port hotplug support to xenvirt.**
 
+* **Added virtual szedata2 driver for COMBO cards.**
+
+  Added virtual PMD for COMBO-100G and COMBO-80G cards.
+  PMD is disabled in default configuration.
 
 Resolved Issues
 ---------------
Signature · 1 line
1.9.1
#35 lore raw
In reply to Matej Vido

2015-11-10 15:18, Matej Vido:

Quoted 9 lines

This is virtual PMD which communicates with COMBO-80G and COMBO-100G cards through sze2 layer. Communication with COMBO card is managed through interface provided by libsze2 library and kernel modules (combov3, szedata2_cv3).

To compile and use PMD, it is necessary to have libsze2 library installed and kernel modules (combov3, szedata2_cv3) loaded.
Therefore in default configuration PMD compilation is disabled. To compile szedata2 PMD, it is necessary to enable CONFIG_RTE_LIBRTE_PMD_SZEDATA2=y.

Applied with few cleanups, thanks