Skip to contentSkip to conversation

OCTEON TX2 DMA driver

PATCH In review [email protected] 3 participants 23 messages Jun 1, 2019 – Jul 5, 2019 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover OCTEON TX2 DMA driver

From: Jerin Jacob <[email protected]>

This patchset adds support for OCTEON TX2 DMA driver as DPDK rawdevice.

This patch set is depended on "OCTEON TX2 common and mempool driver" series.
http://mails.dpdk.org/archives/dev/2019-June/133329.html

This patches series also available at https://github.com/jerinjacobk/dpdk-dma
including the dependency patches for quick download and review.

Satha Rao (9):
raw/octeontx2_dma: add build infra and device probe raw/octeontx2_dma: update probe function raw/octeontx2_dma: add device configuration raw/octeontx2_dma: add device close operation raw/octeontx2_dma: add enqueue operation raw/octeontx2_dma: add dequeue and device control operations raw/octeontx2_dma: add driver self test
usertools: add octeontx2 DMA device raw/octeontx2_dma: add documentation

 MAINTAINERS                                   |   6 +
 config/common_base                            |   5 +
 doc/guides/platform/octeontx2.rst             |   5 +
 doc/guides/rawdevs/index.rst                  |   1 +
 doc/guides/rawdevs/octeontx2_dma.rst          | 114 +++++
 drivers/raw/Makefile                          |   1 +
 drivers/raw/meson.build                       |   2 +-
 drivers/raw/octeontx2_dma/Makefile            |  30 ++
 drivers/raw/octeontx2_dma/meson.build         |  18 +
 drivers/raw/octeontx2_dma/otx2_dpi_msg.c      | 105 +++++
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c   | 438 ++++++++++++++++++
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h   | 196 ++++++++
 drivers/raw/octeontx2_dma/otx2_dpi_test.c     | 216 +++++++++
 .../rte_pmd_octeontx2_dma_version.map         |   4 +
 mk/rte.app.mk                                 |   1 +
 usertools/dpdk-devbind.py                     |   8 +
 16 files changed, 1149 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/rawdevs/octeontx2_dma.rst
 create mode 100644 drivers/raw/octeontx2_dma/Makefile
 create mode 100644 drivers/raw/octeontx2_dma/meson.build
 create mode 100644 drivers/raw/octeontx2_dma/otx2_dpi_msg.c
 create mode 100644 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c
 create mode 100644 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h
 create mode 100644 drivers/raw/octeontx2_dma/otx2_dpi_test.c
 create mode 100644 drivers/raw/octeontx2_dma/rte_pmd_octeontx2_dma_version.map
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/9 raw/octeontx2_dma: add build infra and device probe

From: Satha Rao <[email protected]>

Add the make and meson based build infrastructure along with the DMA device probe.

---
 config/common_base                            |   5 +
 drivers/raw/Makefile                          |   1 +
 drivers/raw/meson.build                       |   2 +-
 drivers/raw/octeontx2_dma/Makefile            |  31 ++++++
 drivers/raw/octeontx2_dma/meson.build         |  18 ++++
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c   | 102 ++++++++++++++++++
 .../rte_pmd_octeontx2_dma_version.map         |   4 +
 mk/rte.app.mk                                 |   1 +
 8 files changed, 163 insertions(+), 1 deletion(-)
 create mode 100644 drivers/raw/octeontx2_dma/Makefile
 create mode 100644 drivers/raw/octeontx2_dma/meson.build
 create mode 100644 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c
 create mode 100644 drivers/raw/octeontx2_dma/rte_pmd_octeontx2_dma_version.map
config/common_base +5 -0
index 4a3de0360..62e4cda01 100644
@@ -741,6 +741,11 @@ CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV=n
 #
 CONFIG_RTE_LIBRTE_PMD_IFPGA_RAWDEV=y
 
+#
+# Compile PMD for octeontx2 DMA device
+#
+CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV=y
+
 #
 # Compile librte_ring
 #
drivers/raw/Makefile +1 -0
index 8e29b4a56..6af639ba2 100644
@@ -10,5 +10,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV) += dpaa2_cmdif
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV) += dpaa2_qdma
 endif
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_IFPGA_RAWDEV) += ifpga_rawdev
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += octeontx2_dma
 
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/meson.build +1 -1
index a61cdccef..00475d651 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright 2018 NXP
 
-drivers = ['skeleton_rawdev', 'dpaa2_cmdif', 'dpaa2_qdma', 'ifpga_rawdev']
+drivers = ['skeleton_rawdev', 'dpaa2_cmdif', 'dpaa2_qdma', 'ifpga_rawdev', 'octeontx2_dma']
 std_deps = ['rawdev']
 config_flag_fmt = 'RTE_LIBRTE_PMD_@0@_RAWDEV'
 driver_name_fmt = 'rte_pmd_@0@'
drivers/raw/octeontx2_dma/Makefile new file +31 -0
new file mode 100644
index 000000000..7335d0ffa
@@ -0,0 +1,31 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2019 Marvell International Ltd.
+#
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+# library name
+LIB = librte_pmd_octeontx2_dma.a
+
+CFLAGS += -DALLOW_EXPERIMENTAL_API -O3 $(WERROR_FLAGS)
+CFLAGS += -I$(RTE_SDK)/drivers/common/octeontx2/
+CFLAGS += -I$(RTE_SDK)/drivers/mempool/octeontx2/
+CFLAGS += -I$(RTE_SDK)/drivers/raw/octeontx2_dma/
+LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring -lrte_rawdev
+LDLIBS += -lrte_common_octeontx2 -lrte_kvargs -lrte_bus_pci
+
+ifneq ($(CONFIG_RTE_ARCH_64),y)
+CFLAGS += -Wno-int-to-pointer-cast
+CFLAGS += -Wno-pointer-to-int-cast
+endif
+
+EXPORT_MAP := rte_pmd_octeontx2_dma_version.map
+
+LIBABIVER := 1
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += otx2_dpi_rawdev.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/octeontx2_dma/meson.build new file +18 -0
new file mode 100644
index 000000000..1281268aa
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2019 Marvell International Ltd.
+#
+
+deps += ['rawdev', 'ring', 'kvargs', 'bus_pci', 'common_octeontx2', 'mempool_octeontx2']
+sources = files('otx2_dpi_rawdev.c')
+
+extra_flags = []
+# This integrated controller runs only on a arm64 machine, remove 32bit warnings
+if not dpdk_conf.get('RTE_ARCH_64')
+	extra_flags += ['-Wno-int-to-pointer-cast', '-Wno-pointer-to-int-cast']
+endif
+
+foreach flag: extra_flags
+	if cc.has_argument(flag)
+		cflags += flag
+	endif
+endforeach
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c new file +102 -0

102 lines not on this page · raw message

drivers/raw/octeontx2_dma/rte_pmd_octeontx2_dma_version.map new file +4 -0
new file mode 100644
index 000000000..fc8c95e91
@@ -0,0 +1,4 @@
+DPDK_19.05 {
+
+	local: *;
+};
mk/rte.app.mk +1 -0
index cd89ccfd5..152bd8b14 100644
@@ -309,6 +309,7 @@ ifeq ($(CONFIG_RTE_LIBRTE_IFPGA_BUS),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_IFPGA_RAWDEV)   += -lrte_pmd_ifpga_rawdev
 _LDLIBS-$(CONFIG_RTE_LIBRTE_IPN3KE_PMD)       += -lrte_pmd_ipn3ke
 endif # CONFIG_RTE_LIBRTE_IFPGA_BUS
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += -lrte_pmd_octeontx2_dma
 endif # CONFIG_RTE_LIBRTE_RAWDEV
 
 endif # !CONFIG_RTE_BUILD_SHARED_LIBS
Signature · 1 line
2.21.0
#2 lore raw

Re: [dpdk-dev] [PATCH v1 1/9] raw/octeontx2_dma: add build infra and device probe

Quoted 21 lines · On Sat, 2019-06-01 at 23:50 +0530, [email protected] wrote:
drivers/raw/octeontx2_dma/meson.build new file +5 -0
new file mode 100644
index 000000000..1281268aa
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2019 Marvell International Ltd.
+#
+
+deps += ['rawdev', 'ring', 'kvargs', 'bus_pci', 'common_octeontx2',

'mempool_octeontx2']

drivers/raw/octeontx2_dma/meson.build new file +4 -0
+sources = files('otx2_dpi_rawdev.c')
+
+extra_flags = []
+# This integrated controller runs only on a arm64 machine, remove

32bit warnings

drivers/raw/octeontx2_dma/meson.build new file +2 -0
+if not dpdk_conf.get('RTE_ARCH_64')
+       extra_flags += ['-Wno-int-to-pointer-cast', '-Wno-pointer-to-

int-cast']

drivers/raw/octeontx2_dma/meson.build line 18

Quoted 7 lines
drivers/raw/octeontx2_dma/meson.build new file +7 -0
+endif
+
+foreach flag: extra_flags
+       if cc.has_argument(flag)
+               cflags += flag
+       endif
+endforeach

If it only works on 64bit, shouldn't the build be disabled for 32bit targets?

Signature · 2 lines
Kind regards,
Luca Boccassi
#3 lore raw

Re: [dpdk-dev] [PATCH v1 1/9] raw/octeontx2_dma: add build infra and device probe

Quoted 32 lines

-----Original Message-----
From: Luca Boccassi <[email protected]>
Sent: Monday, June 3, 2019 4:48 PM
To: Jerin Jacob Kollanukkaran <[email protected]>; [email protected]
Cc: Satha Koteswara Rao Kottidi <[email protected]>; Vamsi Krishna Attunuru <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v1 1/9] raw/octeontx2_dma: add build infra and device probe

Quoted 22 lines · On Sat, 2019-06-01 at 23:50 +0530, [email protected] wrote:
drivers/raw/octeontx2_dma/meson.build new file +5 -0
new file mode 100644
index 000000000..1281268aa
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(C) 2019 Marvell
+International Ltd.
+#
+
+deps += ['rawdev', 'ring', 'kvargs', 'bus_pci', 'common_octeontx2',

'mempool_octeontx2']

drivers/raw/octeontx2_dma/meson.build new file +4 -0
+sources = files('otx2_dpi_rawdev.c')
+
+extra_flags = []
+# This integrated controller runs only on a arm64 machine, remove

32bit warnings

drivers/raw/octeontx2_dma/meson.build new file +2 -0
+if not dpdk_conf.get('RTE_ARCH_64')
+       extra_flags += ['-Wno-int-to-pointer-cast', '-Wno-pointer-to-

int-cast']
+endif

Quoted 8 lines

drivers/raw/octeontx2_dma/meson.build line 18

Quoted 6 lines
drivers/raw/octeontx2_dma/meson.build new file +6 -0
+
+foreach flag: extra_flags
+       if cc.has_argument(flag)
+               cflags += flag
+       endif
+endforeach

If it only works on 64bit, shouldn't the build be disabled for 32bit targets?

We just thought of enabling it for 32bit to _detect_ build regression for 32bit so that in future we can run with ILP32 if required.

If you have strong option on this then we can disable it if required.

Quoted 4 lines

--
Kind regards,
Luca Boccassi

#4 lore raw

Re: [dpdk-dev] [PATCH v1 1/9] raw/octeontx2_dma: add build infra and device probe

Quoted 59 lines · Jerin Jacob Kollanukkaran
Quoted 50 lines

-----Original Message-----
From: Luca Boccassi <
[email protected]

Quoted 1 line

Sent: Monday, June 3, 2019 4:48 PM
To: Jerin Jacob Kollanukkaran <
[email protected]

Quoted 1 line

;

[email protected]

Cc: Satha Koteswara Rao Kottidi <
[email protected]

Quoted 1 line

; Vamsi Krishna

Attunuru <
[email protected]

Quoted 1 line

Subject: Re: [dpdk-dev] [PATCH v1 1/9] raw/octeontx2_dma: add build infra
and device probe

Quoted 27 lines · On Sat, 2019-06-01 at 23:50 +0530, [email protected] wrote:
drivers/raw/octeontx2_dma/meson.build new file +1 -0
new file mode 100644
index 000000000..1281268aa
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(C) 2019

Marvell

drivers/raw/octeontx2_dma/meson.build new file +4 -0
+International Ltd.
+#
+
+deps += ['rawdev', 'ring', 'kvargs', 'bus_pci',

'common_octeontx2',
'mempool_octeontx2']

drivers/raw/octeontx2_dma/meson.build new file +4 -0
+sources = files('otx2_dpi_rawdev.c')
+
+extra_flags = []
+# This integrated controller runs only on a arm64 machine,

remove
32bit warnings

drivers/raw/octeontx2_dma/meson.build new file +2 -0
+if not dpdk_conf.get('RTE_ARCH_64')
+       extra_flags += ['-Wno-int-to-pointer-cast', '-Wno-

pointer-to-
int-cast']

drivers/raw/octeontx2_dma/meson.build new file +2 -0
+endif
+
Quoted 8 lines

drivers/raw/octeontx2_dma/meson.build line 18

Quoted 5 lines
drivers/raw/octeontx2_dma/meson.build new file +5 -0
+foreach flag: extra_flags
+       if cc.has_argument(flag)
+               cflags += flag
+       endif
+endforeach

If it only works on 64bit, shouldn't the build be disabled for 32bit targets?

Quoted 5 lines

We just thought of enabling it for 32bit to _detect_ build regression for 32bit so
that in future we can run with ILP32 if required.

If you have strong option on this then we can disable it if required.

No it's fine, it was just an observation.

Signature · 2 lines
Kind regards,
Luca Boccassi
#5 lore raw

PATCH 2/9 raw/octeontx2_dma: update probe function

In reply to [email protected]

From: Satha Rao <[email protected]>

Probe function enhanced to allocate and initialise PMD private data.

---
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c | 25 +++++++--
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h | 59 +++++++++++++++++++++
 2 files changed, 80 insertions(+), 4 deletions(-)
 create mode 100644 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c +21 -4
index 01422c299..f9560abcc 100644
@@ -17,7 +17,7 @@
 #include <rte_rawdev.h>
 #include <rte_rawdev_pmd.h>
 
-#include <otx2_mempool.h>
+#include "otx2_dpi_rawdev.h"
 
 static const struct rte_pci_id pci_dma_map[] = {
 	{
@@ -34,11 +34,13 @@ otx2_dpi_rawdev_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		      struct rte_pci_device *pci_dev)
 {
 	char name[RTE_RAWDEV_NAME_MAX_LEN];
+	struct dpi_vf_s *dpivf = NULL;
 	struct rte_rawdev *rawdev;
+	uint16_t vf_id;
 
 	/* For secondary processes, the primary has done all the work */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-		return 0;
+		return DPI_DMA_QUEUE_SUCCESS;
 
 	if (pci_dev->mem_resource[0].addr == NULL) {
 		otx2_dpi_dbg("Empty bars %p %p", pci_dev->mem_resource[0].addr,
@@ -52,7 +54,8 @@ otx2_dpi_rawdev_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		 pci_dev->addr.function);
 
 	/* Allocate device structure */
-	rawdev = rte_rawdev_pmd_allocate(name, 0, rte_socket_id());
+	rawdev = rte_rawdev_pmd_allocate(name, sizeof(struct dpi_vf_s),
+					 rte_socket_id());
 	if (rawdev == NULL) {
 		otx2_err("Rawdev allocation failed");
 		return -EINVAL;
@@ -61,7 +64,21 @@ otx2_dpi_rawdev_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	rawdev->device = &pci_dev->device;
 	rawdev->driver_name = pci_dev->driver->driver.name;
 
-	return 0;
+	dpivf = rawdev->dev_private;
+	if (dpivf->state != DPI_QUEUE_STOP) {
+		otx2_dpi_dbg("Device already started!!!");
+		return -ENODEV;
+	}
+
+	vf_id = ((pci_dev->addr.devid & 0x1F) << 3) |
+		 (pci_dev->addr.function & 0x7);
+	vf_id -= 1;
+	dpivf->state = DPI_QUEUE_START;
+	dpivf->vf_id = vf_id;
+	dpivf->vf_bar0 = (uintptr_t)pci_dev->mem_resource[0].addr;
+	dpivf->vf_bar2 = (uintptr_t)pci_dev->mem_resource[2].addr;
+
+	return DPI_DMA_QUEUE_SUCCESS;
 }
 
 static int
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
2.21.0
#6 lore raw

PATCH 3/9 raw/octeontx2_dma: add device configuration

In reply to [email protected]

From: Satha Rao <[email protected]>

Register dev_configure API to configure DPI PCI devices. After successful initialisation send message to PF to open corresponding DPI DMA queue. At present hardware doesn't support mail box for DPI, so PMD to PF communication uses prebuild kernel devfs.

---
 drivers/raw/octeontx2_dma/Makefile          |   5 +-
 drivers/raw/octeontx2_dma/meson.build       |   2 +-
 drivers/raw/octeontx2_dma/otx2_dpi_msg.c    | 105 ++++++++++++++++++++
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c |  54 ++++++++++
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h |   3 +
 5 files changed, 165 insertions(+), 4 deletions(-)
 create mode 100644 drivers/raw/octeontx2_dma/otx2_dpi_msg.c
drivers/raw/octeontx2_dma/Makefile +2 -3
index 7335d0ffa..6a9a380b1 100644
@@ -7,10 +7,9 @@ include $(RTE_SDK)/mk/rte.vars.mk
 # library name
 LIB = librte_pmd_octeontx2_dma.a
 
-CFLAGS += -DALLOW_EXPERIMENTAL_API -O3 $(WERROR_FLAGS)
+CFLAGS += -O3 $(WERROR_FLAGS)
 CFLAGS += -I$(RTE_SDK)/drivers/common/octeontx2/
 CFLAGS += -I$(RTE_SDK)/drivers/mempool/octeontx2/
-CFLAGS += -I$(RTE_SDK)/drivers/raw/octeontx2_dma/
 LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring -lrte_rawdev
 LDLIBS += -lrte_common_octeontx2 -lrte_kvargs -lrte_bus_pci
 
@@ -26,6 +25,6 @@ LIBABIVER := 1
 #
 # all source are stored in SRCS-y
 #
-SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += otx2_dpi_rawdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += otx2_dpi_rawdev.c otx2_dpi_msg.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/octeontx2_dma/meson.build +1 -1
index 1281268aa..751d099d2 100644
@@ -3,7 +3,7 @@
 #
 
 deps += ['rawdev', 'ring', 'kvargs', 'bus_pci', 'common_octeontx2', 'mempool_octeontx2']
-sources = files('otx2_dpi_rawdev.c')
+sources = files('otx2_dpi_rawdev.c', 'otx2_dpi_msg.c')
 
 extra_flags = []
 # This integrated controller runs only on a arm64 machine, remove 32bit warnings
drivers/raw/octeontx2_dma/otx2_dpi_msg.c new file +105 -0

105 lines not on this page · raw message

drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c +54 -0

66 lines not on this page · raw message

drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h +3 -0
index 33fd95c33..918ae725a 100644
@@ -56,4 +56,7 @@ enum dpi_dma_queue_result_e {
 	DPI_DMA_QUEUE_INVALID_PARAM = -2,
 };
 
+int otx2_dpi_queue_open(uint16_t vf_id, uint32_t size, uint32_t gaura);
+int otx2_dpi_queue_close(uint16_t vf_id);
+
 #endif /* _DPI_RAWDEV_H_ */
Signature · 1 line
2.21.0
#7 lore raw

PATCH 4/9 raw/octeontx2_dma: add device close operation

In reply to [email protected]

From: Satha Rao <[email protected]>

Send message to PF to stop DMA queue when device close is called from application.
Defined the required data structures to support enqueue and dequeue APIs.

---
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c |  33 +++++
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h | 133 ++++++++++++++++++++
 2 files changed, 166 insertions(+)
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c +33 -0
index b418dc5bb..e7e30825f 100644
@@ -41,6 +41,34 @@ dma_engine_enb_dis(struct dpi_vf_s *dpivf, const bool enb)
 	return DPI_DMA_QUEUE_SUCCESS;
 }
 
+/* Free DMA Queue instruction buffers, and send close notification to PF */
+static inline int
+dma_queue_finish(struct dpi_vf_s *dpivf)
+{
+	uint32_t timeout = 0, sleep = 1;
+	uint64_t reg = 0ULL;
+
+	/* Wait for SADDR to become idle */
+	reg = otx2_read64(dpivf->vf_bar0 + DPI_VDMA_SADDR);
+	while (!(reg & BIT_ULL(DPI_VDMA_SADDR_REQ_IDLE))) {
+		rte_delay_ms(sleep);
+		timeout++;
+		if (timeout >= DPI_QFINISH_TIMEOUT) {
+			otx2_dpi_dbg("Timeout!!! Closing Forcibly");
+			break;
+		}
+		reg = otx2_read64(dpivf->vf_bar0 + DPI_VDMA_SADDR);
+	}
+
+	if (otx2_dpi_queue_close(dpivf->vf_id) < 0)
+		return -EACCES;
+
+	rte_mempool_put(dpivf->chunk_pool, dpivf->base_ptr);
+	dpivf->vf_bar0 = (uintptr_t)NULL;
+
+	return DPI_DMA_QUEUE_SUCCESS;
+}
+
 static int
 otx2_dpi_rawdev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config)
 {
@@ -140,6 +168,7 @@ otx2_dpi_rawdev_remove(struct rte_pci_device *pci_dev)
 {
 	char name[RTE_RAWDEV_NAME_MAX_LEN];
 	struct rte_rawdev *rawdev;
+	struct dpi_vf_s *dpivf;
 
 	if (pci_dev == NULL) {
 		otx2_dpi_dbg("Invalid pci_dev of the device!");
@@ -157,6 +186,10 @@ otx2_dpi_rawdev_remove(struct rte_pci_device *pci_dev)
 		return -EINVAL;
 	}
 
+	dpivf = (struct dpi_vf_s *)rawdev->dev_private;
+	dma_engine_enb_dis(dpivf, false);
+	dma_queue_finish(dpivf);
+
 	/* rte_rawdev_close is called by pmd_release */
 	return rte_rawdev_pmd_release(rawdev);
 }
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h +133 -0

145 lines not on this page · raw message

Signature · 1 line
2.21.0
#8 lore raw

PATCH 5/9 raw/octeontx2_dma: add enqueue operation

In reply to [email protected]

From: Satha Rao <[email protected]>

Add enqueue operation.

---
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c | 166 ++++++++++++++++++++
 1 file changed, 166 insertions(+)
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c +166 -0
index e7e30825f..bfc95657b 100644
@@ -69,6 +69,171 @@ dma_queue_finish(struct dpi_vf_s *dpivf)
 	return DPI_DMA_QUEUE_SUCCESS;
 }
 
+/* Write an arbitrary number of command words to a command queue */
+static __rte_always_inline enum dpi_dma_queue_result_e
+dma_queue_write(struct dpi_vf_s *dpi, uint16_t cmd_count, uint64_t *cmds)
+{
+	if ((cmd_count < 1) || (cmd_count > 64))
+		return DPI_DMA_QUEUE_INVALID_PARAM;
+
+	if (cmds == NULL)
+		return DPI_DMA_QUEUE_INVALID_PARAM;
+
+	/* Room available in the current buffer for the command */
+	if (dpi->index + cmd_count < dpi->pool_size_m1) {
+		uint64_t *ptr = dpi->base_ptr;
+
+		ptr += dpi->index;
+		dpi->index += cmd_count;
+		while (cmd_count--)
+			*ptr++ = *cmds++;
+	} else {
+		void *new_buffer;
+		uint64_t *ptr;
+		int count;
+
+		/* Allocate new command buffer, return if failed */
+		if (rte_mempool_get(dpi->chunk_pool, &new_buffer) ||
+		    new_buffer == NULL) {
+			return DPI_DMA_QUEUE_NO_MEMORY;
+		}
+		ptr = dpi->base_ptr;
+		/* Figure out how many command words will fit in this buffer.
+		 * One location will be needed for the next buffer pointer.
+		 **/
+		count = dpi->pool_size_m1 - dpi->index;
+		ptr += dpi->index;
+		cmd_count -= count;
+		while (count--)
+			*ptr++ = *cmds++;
+		/* Chunk next ptr is 2DWORDs, second DWORD is reserved. */
+		*ptr++ = (uint64_t)new_buffer;
+		*ptr   = 0;
+		/* The current buffer is full and has a link to the next buffer.
+		 * Time to write the rest of the commands into the new buffer.
+		 **/
+		dpi->base_ptr = new_buffer;
+		dpi->index = cmd_count;
+		ptr = new_buffer;
+		while (cmd_count--)
+			*ptr++ = *cmds++;
+		/* queue index may greater than pool size */
+		if (dpi->index >= dpi->pool_size_m1) {
+			if (rte_mempool_get(dpi->chunk_pool, &new_buffer) ||
+			    new_buffer == NULL) {
+				return DPI_DMA_QUEUE_NO_MEMORY;
+			}
+			/* Write next buffer address */
+			*ptr = (uint64_t)new_buffer;
+			dpi->base_ptr = new_buffer;
+			dpi->index = 0;
+		}
+	}
+	return DPI_DMA_QUEUE_SUCCESS;
+}
+
+/* Submit a DMA command to the DMA queues. */
+static __rte_always_inline int
+dma_queue_submit(struct rte_rawdev *dev, uint16_t cmd_count, uint64_t *cmds)
+{
+	struct dpi_vf_s *dpivf = dev->dev_private;
+	enum dpi_dma_queue_result_e result;
+
+	result = dma_queue_write(dpivf, cmd_count, cmds);
+	rte_wmb();
+	if (likely(result == DPI_DMA_QUEUE_SUCCESS))
+		otx2_write64((uint64_t)cmd_count,
+			     dpivf->vf_bar0 + DPI_VDMA_DBELL);
+
+	return result;
+}
+
+/* Enqueue buffers to DMA queue
+ * returns number of buffers enqueued successfully
+ */
+static int
+otx2_dpi_rawdev_enqueue_bufs(struct rte_rawdev *dev,
+			     struct rte_rawdev_buf **buffers,
+			     unsigned int count, rte_rawdev_obj_t context)
+{
+	struct dpi_dma_queue_ctx_s *ctx = (struct dpi_dma_queue_ctx_s *)context;
+	struct dpi_dma_buf_ptr_s *cmd;
+	uint32_t c = 0;
+
+	for (c = 0; c < count; c++) {
+		uint64_t dpi_cmd[DPI_DMA_CMD_SIZE] = {0};
+		union dpi_dma_instr_hdr_u *hdr;
+		uint16_t index = 0, i;
+
+		hdr = (union dpi_dma_instr_hdr_u *)&dpi_cmd[0];
+		cmd = (struct dpi_dma_buf_ptr_s *)buffers[c]->buf_addr;
+
+		hdr->s.xtype = ctx->xtype & DPI_XTYPE_MASK;
+		hdr->s.pt = ctx->pt & DPI_HDR_PT_MASK;
+		/* Request initiated with byte write completion, but completion
+		 * pointer not provided
+		 */
+		if ((hdr->s.pt == DPI_HDR_PT_ZBW_CA ||
+		     hdr->s.pt == DPI_HDR_PT_ZBW_NC) && cmd->comp_ptr == NULL)
+			return c;
+
+		cmd->comp_ptr->cdata = DPI_REQ_CDATA;
+		hdr->s.ptr = (uint64_t)cmd->comp_ptr;
+		hdr->s.deallocv = ctx->deallocv;
+		hdr->s.tt = ctx->tt & DPI_W0_TT_MASK;
+		hdr->s.grp = ctx->grp & DPI_W0_GRP_MASK;
+
+		/* If caller provides completion ring details, then only queue
+		 * completion address for later polling.
+		 */
+		if (ctx->c_ring) {
+			ctx->c_ring->compl_data[ctx->c_ring->tail] =
+								 cmd->comp_ptr;
+			STRM_INC(ctx->c_ring);
+		}
+
+		if (hdr->s.deallocv)
+			hdr->s.pvfe = 1;
+
+		if (hdr->s.pt == DPI_HDR_PT_WQP)
+			hdr->s.ptr = hdr->s.ptr | DPI_HDR_PT_WQP_STATUSNC;
+
+		index += 4;
+		hdr->s.fport = 0;
+		hdr->s.lport = 0;
+
+		/* For inbound case, src pointers are last pointers.
+		 * For all other cases, src pointers are first pointers.
+		 */
+		if (ctx->xtype ==  DPI_XTYPE_INBOUND) {
+			hdr->s.nfst = cmd->wptr_cnt & DPI_MAX_POINTER;
+			hdr->s.nlst = cmd->rptr_cnt & DPI_MAX_POINTER;
+			for (i = 0; i < hdr->s.nfst; i++) {
+				dpi_cmd[index++] = cmd->wptr[i]->u[0];
+				dpi_cmd[index++] = cmd->wptr[i]->u[1];
+			}
+			for (i = 0; i < hdr->s.nlst; i++) {
+				dpi_cmd[index++] = cmd->rptr[i]->u[0];
+				dpi_cmd[index++] = cmd->rptr[i]->u[1];
+			}
+		} else {
+			hdr->s.nfst = cmd->rptr_cnt & DPI_MAX_POINTER;
+			hdr->s.nlst = cmd->wptr_cnt & DPI_MAX_POINTER;
+			for (i = 0; i < hdr->s.nfst; i++) {
+				dpi_cmd[index++] = cmd->rptr[i]->u[0];
+				dpi_cmd[index++] = cmd->rptr[i]->u[1];
+			}
+			for (i = 0; i < hdr->s.nlst; i++) {
+				dpi_cmd[index++] = cmd->wptr[i]->u[0];
+				dpi_cmd[index++] = cmd->wptr[i]->u[1];
+			}
+		}
+		if (dma_queue_submit(dev, index, dpi_cmd))
+			return c;
+	}
+	return c;
+}
+
 static int
 otx2_dpi_rawdev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config)
 {
@@ -108,6 +273,7 @@ otx2_dpi_rawdev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config)
 
 static const struct rte_rawdev_ops dpi_rawdev_ops = {
 	.dev_configure = otx2_dpi_rawdev_configure,
+	.enqueue_bufs = otx2_dpi_rawdev_enqueue_bufs,
 };
 
 static int
Signature · 1 line
2.21.0
#9 lore raw

PATCH 6/9 raw/octeontx2_dma: add dequeue and device control operations

In reply to [email protected]

From: Satha Rao <[email protected]>

Add dequeue, device start, stop, close and reset operations.

---
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c | 64 +++++++++++++++++++++
 1 file changed, 64 insertions(+)
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c +64 -0
index bfc95657b..f8f0c4af6 100644
@@ -234,6 +234,65 @@ otx2_dpi_rawdev_enqueue_bufs(struct rte_rawdev *dev,
 	return c;
 }
 
+/* Check for command completion, returns number of commands completed */
+static int
+otx2_dpi_rawdev_dequeue_bufs(struct rte_rawdev *dev __rte_unused,
+			     struct rte_rawdev_buf **buffers,
+			     unsigned int count, rte_rawdev_obj_t context)
+{
+	struct dpi_dma_queue_ctx_s *ctx = (struct dpi_dma_queue_ctx_s *)context;
+	unsigned int i = 0, headp;
+
+	/* No completion ring to poll */
+	if (ctx->c_ring == NULL)
+		return 0;
+
+	headp = ctx->c_ring->head;
+	for (i = 0; i < count && (headp != ctx->c_ring->tail); i++) {
+		struct dpi_dma_req_compl_s *comp_ptr =
+					 ctx->c_ring->compl_data[headp];
+
+		if (comp_ptr->cdata)
+			break;
+
+		/* Request Completed */
+		buffers[i] = (void *)comp_ptr;
+		headp = (headp + 1) % ctx->c_ring->max_cnt;
+	}
+	ctx->c_ring->head = headp;
+
+	return i;
+}
+
+static int
+otx2_dpi_rawdev_start(struct rte_rawdev *dev)
+{
+	dev->started = DPI_QUEUE_START;
+
+	return DPI_DMA_QUEUE_SUCCESS;
+}
+
+static void
+otx2_dpi_rawdev_stop(struct rte_rawdev *dev)
+{
+	dev->started = DPI_QUEUE_STOP;
+}
+
+static int
+otx2_dpi_rawdev_close(struct rte_rawdev *dev)
+{
+	dma_engine_enb_dis(dev->dev_private, false);
+	dma_queue_finish(dev->dev_private);
+
+	return DPI_DMA_QUEUE_SUCCESS;
+}
+
+static int
+otx2_dpi_rawdev_reset(struct rte_rawdev *dev)
+{
+	return dev ? DPI_QUEUE_STOP : DPI_QUEUE_START;
+}
+
 static int
 otx2_dpi_rawdev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config)
 {
@@ -273,7 +332,12 @@ otx2_dpi_rawdev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config)
 
 static const struct rte_rawdev_ops dpi_rawdev_ops = {
 	.dev_configure = otx2_dpi_rawdev_configure,
+	.dev_start = otx2_dpi_rawdev_start,
+	.dev_stop = otx2_dpi_rawdev_stop,
+	.dev_close = otx2_dpi_rawdev_close,
+	.dev_reset = otx2_dpi_rawdev_reset,
 	.enqueue_bufs = otx2_dpi_rawdev_enqueue_bufs,
+	.dequeue_bufs = otx2_dpi_rawdev_dequeue_bufs,
 };
 
 static int
Signature · 1 line
2.21.0
#10 lore raw

PATCH 7/9 raw/octeontx2_dma: add driver self test

In reply to [email protected]

From: Satha Rao <[email protected]>

Sample test to verify DMA functionality, this test covers internal transfer mode.

---
 drivers/raw/octeontx2_dma/Makefile          |   2 +-
 drivers/raw/octeontx2_dma/meson.build       |   2 +-
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c |   2 +
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h |   1 +
 drivers/raw/octeontx2_dma/otx2_dpi_test.c   | 216 ++++++++++++++++++++
 5 files changed, 221 insertions(+), 2 deletions(-)
 create mode 100644 drivers/raw/octeontx2_dma/otx2_dpi_test.c
drivers/raw/octeontx2_dma/Makefile +1 -1
index 6a9a380b1..8135fba6a 100644
@@ -25,6 +25,6 @@ LIBABIVER := 1
 #
 # all source are stored in SRCS-y
 #
-SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += otx2_dpi_rawdev.c otx2_dpi_msg.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += otx2_dpi_rawdev.c otx2_dpi_msg.c otx2_dpi_test.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/octeontx2_dma/meson.build +1 -1
index 751d099d2..f1afff2a9 100644
@@ -3,7 +3,7 @@
 #
 
 deps += ['rawdev', 'ring', 'kvargs', 'bus_pci', 'common_octeontx2', 'mempool_octeontx2']
-sources = files('otx2_dpi_rawdev.c', 'otx2_dpi_msg.c')
+sources = files('otx2_dpi_rawdev.c', 'otx2_dpi_msg.c', 'otx2_dpi_test.c')
 
 extra_flags = []
 # This integrated controller runs only on a arm64 machine, remove 32bit warnings
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c +2 -0
index f8f0c4af6..0922555bc 100644
@@ -338,6 +338,8 @@ static const struct rte_rawdev_ops dpi_rawdev_ops = {
 	.dev_reset = otx2_dpi_rawdev_reset,
 	.enqueue_bufs = otx2_dpi_rawdev_enqueue_bufs,
 	.dequeue_bufs = otx2_dpi_rawdev_dequeue_bufs,
+
+	.dev_selftest = test_otx2_dma_rawdev,
 };
 
 static int
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h +1 -0
index f59bab97f..ff03431d0 100644
@@ -191,5 +191,6 @@ union dpi_dma_instr_hdr_u {
 
 int otx2_dpi_queue_open(uint16_t vf_id, uint32_t size, uint32_t gaura);
 int otx2_dpi_queue_close(uint16_t vf_id);
+int test_otx2_dma_rawdev(void);
 
 #endif /* _DPI_RAWDEV_H_ */
drivers/raw/octeontx2_dma/otx2_dpi_test.c new file +216 -0

216 lines not on this page · raw message

Signature · 1 line
2.21.0
#11 lore raw

PATCH 8/9 usertools: add octeontx2 DMA device

In reply to [email protected]

From: Satha Rao <[email protected]>

Update the devbind script with new section of DMA devices, also added OCTEONTX2 DMA device ID to DMA device list

---
 usertools/dpdk-devbind.py | 8 ++++++++
 1 file changed, 8 insertions(+)
usertools/dpdk-devbind.py +8 -0
index 9e79f0d28..99bbfc5d3 100755
@@ -35,12 +35,15 @@
               'SVendor': None, 'SDevice': None}
 octeontx2_npa = {'Class': '08', 'Vendor': '177d', 'Device': 'a0fb,a0fc',
               'SVendor': None, 'SDevice': None}
+octeontx2_dma = {'Class': '08', 'Vendor': '177d', 'Device': 'a081',
+              'SVendor': None, 'SDevice': None}
 
 network_devices = [network_class, cavium_pkx, avp_vnic, ifpga_class]
 crypto_devices = [encryption_class, intel_processor_class]
 eventdev_devices = [cavium_sso, cavium_tim, octeontx2_sso]
 mempool_devices = [cavium_fpa, octeontx2_npa]
 compress_devices = [cavium_zip]
+dma_devices = [octeontx2_dma]
 
 # global dict ethernet devices present. Dictionary indexed by PCI address.
 # Each device within this is itself a dictionary of device properties
@@ -595,6 +598,9 @@ def show_status():
     if status_dev == "compress" or status_dev == "all":
         show_device_status(compress_devices , "Compress")
 
+    if status_dev == "dma" or status_dev == "all":
+        show_device_status(dma_devices , "DMA")
+
 
 def parse_args():
     '''Parses the command-line arguments given by the user and takes the
@@ -670,6 +676,7 @@ def do_arg_actions():
             get_device_details(eventdev_devices)
             get_device_details(mempool_devices)
             get_device_details(compress_devices)
+            get_device_details(dma_devices)
         show_status()
 
 
@@ -690,6 +697,7 @@ def main():
     get_device_details(eventdev_devices)
     get_device_details(mempool_devices)
     get_device_details(compress_devices)
+    get_device_details(dma_devices)
     do_arg_actions()
 
 if __name__ == "__main__":
Signature · 1 line
2.21.0
#12 lore raw

PATCH 9/9 raw/octeontx2_dma: add documentation

In reply to [email protected]

From: Satha Rao <[email protected]>

Add documentation and update MAINTAINERS file.

Cc John McNamara <[email protected]>
Cc Thomas Monjalon <[email protected]>
---
 MAINTAINERS                          |   6 ++
 doc/guides/platform/octeontx2.rst    |   5 ++
 doc/guides/rawdevs/index.rst         |   1 +
 doc/guides/rawdevs/octeontx2_dma.rst | 114 +++++++++++++++++++++++++++
 4 files changed, 126 insertions(+)
 create mode 100644 doc/guides/rawdevs/octeontx2_dma.rst
MAINTAINERS +6 -0
index 74ac6d41f..2434fc18c 100644
@@ -1062,6 +1062,12 @@ M: Nipun Gupta <[email protected]>
 F: drivers/raw/dpaa2_cmdif/
 F: doc/guides/rawdevs/dpaa2_cmdif.rst
 
+Marvell OCTEON TX2 DMA
+M: Satha Rao <[email protected]>
+M: Vamsi Attunuru <[email protected]>
+F: drivers/raw/octeontx2_dma/
+F: doc/guides/rawdevs/octeontx2_dma.rst
+
 
 Packet processing
 -----------------
doc/guides/platform/octeontx2.rst +5 -0
index c9ea45647..e6bfa2052 100644
@@ -101,6 +101,9 @@ This section lists dataplane H/W block(s) available in OCTEON TX2 SoC.
 #. **Mempool Driver**
    See :doc:`../mempool/octeontx2` for NPA mempool driver information.
 
+#. **DMA Rawdev Driver**
+   See :doc:`../rawdevs/octeontx2_dma` for DMA driver information.
+
 Procedure to Setup Platform
 ---------------------------
 
@@ -143,6 +146,8 @@ compatible board:
         # Enable if netdev VF driver required
         CONFIG_OCTEONTX2_VF=y
         CONFIG_CRYPTO_DEV_OCTEONTX2_CPT=y
+        # Enable if OCTEONTX2 DMA PF driver required
+        CONFIG_OCTEONTX2_DPI_PF=n
 
 2. **ARM64 Linux Tool Chain**
 
doc/guides/rawdevs/index.rst +1 -0
index 7c3bd9586..1351d14e4 100644
@@ -14,3 +14,4 @@ application through rawdev API.
     dpaa2_cmdif
     dpaa2_qdma
     ifpga_rawdev
+    octeontx2_dma
doc/guides/rawdevs/octeontx2_dma.rst new file +114 -0

114 lines not on this page · raw message

Signature · 1 line
2.21.0
#13 lore raw

v2 cover OCTEON TX2 DMA driver

In reply to [email protected]

From: Jerin Jacob <[email protected]>

This patchset adds support for OCTEON TX2 DMA driver as DPDK rawdevice.

v2:

# Moved maintainers file to the first patch

# removed reference to to v19.05
# Makefile/Meson CFLAGS moved to specific patches
# Squshed Documentation updates to specific patches
# Sync with Bruce's usertools/dpdk-devbind.py script change where
octeontx2 dma will be classified as Misc device.
# Update to latest dpdk.org master (as of 5-July)

Jerin Jacob (2):
raw/octeontx2_dma: add build infra and device probe
usertools: add octeontx2 DMA device binding

Satha Rao (6):
raw/octeontx2_dma: update probe function raw/octeontx2_dma: add device configuration raw/octeontx2_dma: add device close operation raw/octeontx2_dma: add enqueue operation raw/octeontx2_dma: add dequeue and device control operations raw/octeontx2_dma: add driver self test

 MAINTAINERS                                   |   6 +
 config/common_base                            |   5 +
 doc/guides/platform/octeontx2.rst             |   5 +
 doc/guides/rawdevs/index.rst                  |   1 +
 doc/guides/rawdevs/octeontx2_dma.rst          | 115 +++++
 drivers/raw/Makefile                          |   1 +
 drivers/raw/meson.build                       |   1 +
 drivers/raw/octeontx2_dma/Makefile            |  36 ++
 drivers/raw/octeontx2_dma/meson.build         |  18 +
 drivers/raw/octeontx2_dma/otx2_dpi_msg.c      | 105 +++++
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c   | 437 ++++++++++++++++++
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h   | 196 ++++++++
 drivers/raw/octeontx2_dma/otx2_dpi_test.c     | 217 +++++++++
 .../rte_pmd_octeontx2_dma_version.map         |   4 +
 mk/rte.app.mk                                 |   2 +
 usertools/dpdk-devbind.py                     |   4 +-
 16 files changed, 1152 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/rawdevs/octeontx2_dma.rst
 create mode 100644 drivers/raw/octeontx2_dma/Makefile
 create mode 100644 drivers/raw/octeontx2_dma/meson.build
 create mode 100644 drivers/raw/octeontx2_dma/otx2_dpi_msg.c
 create mode 100644 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c
 create mode 100644 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h
 create mode 100644 drivers/raw/octeontx2_dma/otx2_dpi_test.c
 create mode 100644 drivers/raw/octeontx2_dma/rte_pmd_octeontx2_dma_version.map
Signature · 1 line
2.22.0
#14 lore raw

PATCH v2 1/8 raw/octeontx2_dma: add build infra and device probe

From: Jerin Jacob <[email protected]>

Add the make and meson based build infrastructure along with the DMA device probe with documentation infrastructure.

---
 MAINTAINERS                                   |  6 ++
 config/common_base                            |  5 +
 doc/guides/platform/octeontx2.rst             |  5 +
 doc/guides/rawdevs/index.rst                  |  1 +
 doc/guides/rawdevs/octeontx2_dma.rst          | 64 ++++++++++++
 drivers/raw/Makefile                          |  1 +
 drivers/raw/meson.build                       |  1 +
 drivers/raw/octeontx2_dma/Makefile            | 25 +++++
 drivers/raw/octeontx2_dma/meson.build         |  6 ++
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c   | 99 +++++++++++++++++++
 .../rte_pmd_octeontx2_dma_version.map         |  4 +
 mk/rte.app.mk                                 |  2 +
 12 files changed, 219 insertions(+)
 create mode 100644 doc/guides/rawdevs/octeontx2_dma.rst
 create mode 100644 drivers/raw/octeontx2_dma/Makefile
 create mode 100644 drivers/raw/octeontx2_dma/meson.build
 create mode 100644 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c
 create mode 100644 drivers/raw/octeontx2_dma/rte_pmd_octeontx2_dma_version.map
MAINTAINERS +6 -0
index 605422077..e35cc9a7a 100644
@@ -1105,6 +1105,12 @@ M: Nipun Gupta <[email protected]>
 F: drivers/raw/dpaa2_cmdif/
 F: doc/guides/rawdevs/dpaa2_cmdif.rst
 
+Marvell OCTEON TX2 DMA
+M: Satha Rao <[email protected]>
+M: Vamsi Attunuru <[email protected]>
+F: drivers/raw/octeontx2_dma/
+F: doc/guides/rawdevs/octeontx2_dma.rst
+
 
 Packet processing
 -----------------
config/common_base +5 -0
index f68107e7a..9ace50758 100644
@@ -762,6 +762,11 @@ CONFIG_RTE_LIBRTE_PMD_IFPGA_RAWDEV=y
 #
 CONFIG_RTE_LIBRTE_PMD_IOAT_RAWDEV=y
 
+#
+# Compile PMD for octeontx2 DMA raw device
+#
+CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV=y
+
 #
 # Compile librte_ring
 #
doc/guides/platform/octeontx2.rst +5 -0
index fbf1193e7..b2a4c030c 100644
@@ -104,6 +104,9 @@ This section lists dataplane H/W block(s) available in OCTEON TX2 SoC.
 #. **Event Device Driver**
    See :doc:`../eventdevs/octeontx2` for SSO event device driver information.
 
+#. **DMA Rawdev Driver**
+   See :doc:`../rawdevs/octeontx2_dma` for DMA driver information.
+
 Procedure to Setup Platform
 ---------------------------
 
@@ -146,6 +149,8 @@ compatible board:
         # Enable if netdev VF driver required
         CONFIG_OCTEONTX2_VF=y
         CONFIG_CRYPTO_DEV_OCTEONTX2_CPT=y
+        # Enable if OCTEONTX2 DMA PF driver required
+        CONFIG_OCTEONTX2_DPI_PF=n
 
 2. **ARM64 Linux Tool Chain**
 
doc/guides/rawdevs/index.rst +1 -0
index 0a21989e4..413c54323 100644
@@ -15,3 +15,4 @@ application through rawdev API.
     dpaa2_qdma
     ifpga_rawdev
     ioat_rawdev
+    octeontx2_dma
doc/guides/rawdevs/octeontx2_dma.rst new file +64 -0

64 lines not on this page · raw message

drivers/raw/Makefile +1 -0
index c1b85c8c7..5be58057a 100644
@@ -11,5 +11,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV) += dpaa2_qdma
 endif
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_IFPGA_RAWDEV) += ifpga_rawdev
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_IOAT_RAWDEV) += ioat
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += octeontx2_dma
 
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/meson.build +1 -0
index 2af8a70d4..64db94456 100644
@@ -3,6 +3,7 @@
 
 drivers = ['dpaa2_cmdif', 'dpaa2_qdma',
 	'ifpga_rawdev', 'ioat',
+	'octeontx2_dma',
 	'skeleton_rawdev']
 std_deps = ['rawdev']
 config_flag_fmt = 'RTE_LIBRTE_PMD_@0@_RAWDEV'
drivers/raw/octeontx2_dma/Makefile new file +25 -0
new file mode 100644
index 000000000..1892c1e27
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2019 Marvell International Ltd.
+#
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+# library name
+LIB = librte_pmd_octeontx2_dma.a
+
+CFLAGS += -O3 $(WERROR_FLAGS)
+CFLAGS += -I$(RTE_SDK)/drivers/common/octeontx2/
+CFLAGS += -I$(RTE_SDK)/drivers/raw/octeontx2_dma/
+LDLIBS += -lrte_eal -lrte_rawdev -lrte_bus_pci
+LDLIBS += -lrte_common_octeontx2
+
+EXPORT_MAP := rte_pmd_octeontx2_dma_version.map
+
+LIBABIVER := 1
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += otx2_dpi_rawdev.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/octeontx2_dma/meson.build new file +6 -0
new file mode 100644
index 000000000..76a7b1645
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2019 Marvell International Ltd.
+#
+
+deps += ['bus_pci', 'common_octeontx2', 'rawdev']
+sources = files('otx2_dpi_rawdev.c')
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c new file +99 -0

99 lines not on this page · raw message

drivers/raw/octeontx2_dma/rte_pmd_octeontx2_dma_version.map new file +4 -0
new file mode 100644
index 000000000..9a61188cd
@@ -0,0 +1,4 @@
+DPDK_19.08 {
+
+	local: *;
+};
mk/rte.app.mk +2 -0
index 30f9a12da..15a6f7421 100644
@@ -110,6 +110,7 @@ _LDLIBS-y += -lrte_common_octeontx
 endif
 OCTEONTX2-y := $(CONFIG_RTE_LIBRTE_OCTEONTX2_MEMPOOL)
 OCTEONTX2-y += $(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EVENTDEV)
+OCTEONTX2-y += $(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV)
 ifeq ($(findstring y,$(OCTEONTX2-y)),y)
 _LDLIBS-y += -lrte_common_octeontx2
 endif
@@ -310,6 +311,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_IFPGA_RAWDEV)   += -lrte_pmd_ifpga_rawdev
 _LDLIBS-$(CONFIG_RTE_LIBRTE_IPN3KE_PMD)       += -lrte_pmd_ipn3ke
 endif # CONFIG_RTE_LIBRTE_IFPGA_BUS
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_IOAT_RAWDEV)   += -lrte_pmd_ioat_rawdev
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += -lrte_pmd_octeontx2_dma
 endif # CONFIG_RTE_LIBRTE_RAWDEV
 
 endif # !CONFIG_RTE_BUILD_SHARED_LIBS
Signature · 1 line
2.22.0
#15 lore raw

PATCH v2 2/8 raw/octeontx2_dma: update probe function

In reply to [email protected]

From: Satha Rao <[email protected]>

Probe function enhanced to allocate and initialize PMD private data.

---
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c | 25 +++++++--
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h | 56 +++++++++++++++++++++
 2 files changed, 78 insertions(+), 3 deletions(-)
 create mode 100644 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c +22 -3
index c363bf44d..175177224 100644
@@ -16,6 +16,8 @@
 
 #include <otx2_common.h>
 
+#include "otx2_dpi_rawdev.h"
+
 static const struct rte_pci_id pci_dma_map[] = {
 	{
 		RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM,
@@ -31,11 +33,13 @@ otx2_dpi_rawdev_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		      struct rte_pci_device *pci_dev)
 {
 	char name[RTE_RAWDEV_NAME_MAX_LEN];
+	struct dpi_vf_s *dpivf = NULL;
 	struct rte_rawdev *rawdev;
+	uint16_t vf_id;
 
 	/* For secondary processes, the primary has done all the work */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-		return 0;
+		return DPI_DMA_QUEUE_SUCCESS;
 
 	if (pci_dev->mem_resource[0].addr == NULL) {
 		otx2_dpi_dbg("Empty bars %p %p", pci_dev->mem_resource[0].addr,
@@ -49,7 +53,8 @@ otx2_dpi_rawdev_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		 pci_dev->addr.function);
 
 	/* Allocate device structure */
-	rawdev = rte_rawdev_pmd_allocate(name, 0, rte_socket_id());
+	rawdev = rte_rawdev_pmd_allocate(name, sizeof(struct dpi_vf_s),
+					 rte_socket_id());
 	if (rawdev == NULL) {
 		otx2_err("Rawdev allocation failed");
 		return -EINVAL;
@@ -58,7 +63,21 @@ otx2_dpi_rawdev_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	rawdev->device = &pci_dev->device;
 	rawdev->driver_name = pci_dev->driver->driver.name;
 
-	return 0;
+	dpivf = rawdev->dev_private;
+	if (dpivf->state != DPI_QUEUE_STOP) {
+		otx2_dpi_dbg("Device already started!!!");
+		return -ENODEV;
+	}
+
+	vf_id = ((pci_dev->addr.devid & 0x1F) << 3) |
+		 (pci_dev->addr.function & 0x7);
+	vf_id -= 1;
+	dpivf->state = DPI_QUEUE_START;
+	dpivf->vf_id = vf_id;
+	dpivf->vf_bar0 = (uintptr_t)pci_dev->mem_resource[0].addr;
+	dpivf->vf_bar2 = (uintptr_t)pci_dev->mem_resource[2].addr;
+
+	return DPI_DMA_QUEUE_SUCCESS;
 }
 
 static int
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h new file +56 -0

56 lines not on this page · raw message

Signature · 1 line
2.22.0
#16 lore raw

PATCH v2 3/8 raw/octeontx2_dma: add device configuration

In reply to [email protected]

From: Satha Rao <[email protected]>

Register dev_configure API to configure DPI PCI devices. After successful initialization send message to PF to open corresponding DPI DMA queue. At present hardware doesn't support mail box for DPI, so PMD to PF communication uses pre build kernel devfs.

---
 doc/guides/rawdevs/octeontx2_dma.rst        |  20 ++++
 drivers/raw/octeontx2_dma/Makefile          |  12 ++-
 drivers/raw/octeontx2_dma/meson.build       |  14 ++-
 drivers/raw/octeontx2_dma/otx2_dpi_msg.c    | 105 ++++++++++++++++++++
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c |  55 ++++++++++
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h |   6 ++
 6 files changed, 210 insertions(+), 2 deletions(-)
 create mode 100644 drivers/raw/octeontx2_dma/otx2_dpi_msg.c
doc/guides/rawdevs/octeontx2_dma.rst +20 -0
index 34807bde4..5e926d10d 100644
@@ -62,3 +62,23 @@ entry, `sriov_numvfs` for the corresponding PF driver.
 
 Once the required VFs are enabled, to be accessible from DPDK, VFs need to be
 bound to vfio-pci driver.
+
+Device Configuration
+--------------------
+
+Configuring DMA rawdev device is done using the ``rte_rawdev_configure()``
+API, which takes the mempool as parameter. PMD uses this pool to submit DMA
+commands to HW.
+
+The following code shows how the device is configured
+
+.. code-block:: c
+
+   struct dpi_rawdev_conf_s conf = {0};
+   struct rte_rawdev_info rdev_info = {.dev_private = &conf};
+
+   conf.chunk_pool = (void *)rte_mempool_create_empty(...);
+   rte_mempool_set_ops_byname(conf.chunk_pool, rte_mbuf_platform_mempool_ops(), NULL);
+   rte_mempool_populate_default(conf.chunk_pool);
+
+   rte_rawdev_configure(dev_id, (rte_rawdev_obj_t)&rdev_info);
drivers/raw/octeontx2_dma/Makefile +11 -1
index 1892c1e27..e1993fe04 100644
@@ -9,9 +9,18 @@ LIB = librte_pmd_octeontx2_dma.a
 
 CFLAGS += -O3 $(WERROR_FLAGS)
 CFLAGS += -I$(RTE_SDK)/drivers/common/octeontx2/
+CFLAGS += -I$(RTE_SDK)/drivers/mempool/octeontx2/
 CFLAGS += -I$(RTE_SDK)/drivers/raw/octeontx2_dma/
 LDLIBS += -lrte_eal -lrte_rawdev -lrte_bus_pci
-LDLIBS += -lrte_common_octeontx2
+LDLIBS += -lrte_common_octeontx2 -lrte_mempool
+
+ifneq ($(CONFIG_RTE_ARCH_64),y)
+CFLAGS += -Wno-int-to-pointer-cast
+CFLAGS += -Wno-pointer-to-int-cast
+ifeq ($(CONFIG_RTE_TOOLCHAIN_ICC),y)
+CFLAGS += -diag-disable 2259
+endif
+endif
 
 EXPORT_MAP := rte_pmd_octeontx2_dma_version.map
 
@@ -21,5 +30,6 @@ LIBABIVER := 1
 # all source are stored in SRCS-y
 #
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += otx2_dpi_rawdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += otx2_dpi_msg.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/octeontx2_dma/meson.build +13 -1
index 76a7b1645..8ea182812 100644
@@ -3,4 +3,16 @@
 #
 
 deps += ['bus_pci', 'common_octeontx2', 'rawdev']
-sources = files('otx2_dpi_rawdev.c')
+sources = files('otx2_dpi_rawdev.c', 'otx2_dpi_msg.c')
+
+extra_flags = []
+# This integrated controller runs only on a arm64 machine, remove 32bit warnings
+if not dpdk_conf.get('RTE_ARCH_64')
+	extra_flags += ['-Wno-int-to-pointer-cast', '-Wno-pointer-to-int-cast']
+endif
+
+foreach flag: extra_flags
+	if cc.has_argument(flag)
+		cflags += flag
+	endif
+endforeach
drivers/raw/octeontx2_dma/otx2_dpi_msg.c new file +105 -0

105 lines not on this page · raw message

drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c +55 -0

73 lines not on this page · raw message

drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h +6 -0
index 8a672d0a6..918ae725a 100644
@@ -5,6 +5,9 @@
 #ifndef _DPI_RAWDEV_H_
 #define _DPI_RAWDEV_H_
 
+#include "otx2_common.h"
+#include "otx2_mempool.h"
+
 #define DPI_QUEUE_OPEN	0x1
 #define DPI_QUEUE_CLOSE	0x2
 
@@ -53,4 +56,7 @@ enum dpi_dma_queue_result_e {
 	DPI_DMA_QUEUE_INVALID_PARAM = -2,
 };
 
+int otx2_dpi_queue_open(uint16_t vf_id, uint32_t size, uint32_t gaura);
+int otx2_dpi_queue_close(uint16_t vf_id);
+
 #endif /* _DPI_RAWDEV_H_ */
Signature · 1 line
2.22.0
#17 lore raw

PATCH v2 4/8 raw/octeontx2_dma: add device close operation

In reply to [email protected]

From: Satha Rao <[email protected]>

Send message to PF to stop DMA queue when device close is called from application.
Defined the required data structures to support enqueue and dequeue APIs.

---
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c |  33 +++++
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h | 133 ++++++++++++++++++++
 2 files changed, 166 insertions(+)
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c +33 -0
index 224c5e5c3..f9c330d69 100644
@@ -41,6 +41,34 @@ dma_engine_enb_dis(struct dpi_vf_s *dpivf, const bool enb)
 	return DPI_DMA_QUEUE_SUCCESS;
 }
 
+/* Free DMA Queue instruction buffers, and send close notification to PF */
+static inline int
+dma_queue_finish(struct dpi_vf_s *dpivf)
+{
+	uint32_t timeout = 0, sleep = 1;
+	uint64_t reg = 0ULL;
+
+	/* Wait for SADDR to become idle */
+	reg = otx2_read64(dpivf->vf_bar0 + DPI_VDMA_SADDR);
+	while (!(reg & BIT_ULL(DPI_VDMA_SADDR_REQ_IDLE))) {
+		rte_delay_ms(sleep);
+		timeout++;
+		if (timeout >= DPI_QFINISH_TIMEOUT) {
+			otx2_dpi_dbg("Timeout!!! Closing Forcibly");
+			break;
+		}
+		reg = otx2_read64(dpivf->vf_bar0 + DPI_VDMA_SADDR);
+	}
+
+	if (otx2_dpi_queue_close(dpivf->vf_id) < 0)
+		return -EACCES;
+
+	rte_mempool_put(dpivf->chunk_pool, dpivf->base_ptr);
+	dpivf->vf_bar0 = (uintptr_t)NULL;
+
+	return DPI_DMA_QUEUE_SUCCESS;
+}
+
 static int
 otx2_dpi_rawdev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config)
 {
@@ -140,6 +168,7 @@ otx2_dpi_rawdev_remove(struct rte_pci_device *pci_dev)
 {
 	char name[RTE_RAWDEV_NAME_MAX_LEN];
 	struct rte_rawdev *rawdev;
+	struct dpi_vf_s *dpivf;
 
 	if (pci_dev == NULL) {
 		otx2_dpi_dbg("Invalid pci_dev of the device!");
@@ -157,6 +186,10 @@ otx2_dpi_rawdev_remove(struct rte_pci_device *pci_dev)
 		return -EINVAL;
 	}
 
+	dpivf = (struct dpi_vf_s *)rawdev->dev_private;
+	dma_engine_enb_dis(dpivf, false);
+	dma_queue_finish(dpivf);
+
 	/* rte_rawdev_close is called by pmd_release */
 	return rte_rawdev_pmd_release(rawdev);
 }
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h +133 -0

145 lines not on this page · raw message

Signature · 1 line
2.22.0
#18 lore raw

PATCH v2 5/8 raw/octeontx2_dma: add enqueue operation

In reply to [email protected]

From: Satha Rao <[email protected]>

Add enqueue operation.

---
 doc/guides/rawdevs/octeontx2_dma.rst        |   6 +
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c | 166 ++++++++++++++++++++
 2 files changed, 172 insertions(+)
doc/guides/rawdevs/octeontx2_dma.rst +6 -0
index 5e926d10d..748f4dbd4 100644
@@ -82,3 +82,9 @@ The following code shows how the device is configured
    rte_mempool_populate_default(conf.chunk_pool);
 
    rte_rawdev_configure(dev_id, (rte_rawdev_obj_t)&rdev_info);
+
+Performing Data Transfer
+------------------------
+
+To perform data transfer using OCTEON TX2 DMA rawdev devices use standard
+``rte_rawdev_enqueue_buffers()`` and ``rte_rawdev_dequeue_buffers()`` APIs.
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c +166 -0

178 lines not on this page · raw message

Signature · 1 line
2.22.0
#19 lore raw

PATCH v2 6/8 raw/octeontx2_dma: add dequeue and device control operations

In reply to [email protected]

From: Satha Rao <[email protected]>

Add dequeue, device start, stop, close and reset operations.

---
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c | 64 +++++++++++++++++++++
 1 file changed, 64 insertions(+)
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c +64 -0
index a1d679f83..6ce218ec3 100644
@@ -234,6 +234,65 @@ otx2_dpi_rawdev_enqueue_bufs(struct rte_rawdev *dev,
 	return c;
 }
 
+/* Check for command completion, returns number of commands completed */
+static int
+otx2_dpi_rawdev_dequeue_bufs(struct rte_rawdev *dev __rte_unused,
+			     struct rte_rawdev_buf **buffers,
+			     unsigned int count, rte_rawdev_obj_t context)
+{
+	struct dpi_dma_queue_ctx_s *ctx = (struct dpi_dma_queue_ctx_s *)context;
+	unsigned int i = 0, headp;
+
+	/* No completion ring to poll */
+	if (ctx->c_ring == NULL)
+		return 0;
+
+	headp = ctx->c_ring->head;
+	for (i = 0; i < count && (headp != ctx->c_ring->tail); i++) {
+		struct dpi_dma_req_compl_s *comp_ptr =
+					 ctx->c_ring->compl_data[headp];
+
+		if (comp_ptr->cdata)
+			break;
+
+		/* Request Completed */
+		buffers[i] = (void *)comp_ptr;
+		headp = (headp + 1) % ctx->c_ring->max_cnt;
+	}
+	ctx->c_ring->head = headp;
+
+	return i;
+}
+
+static int
+otx2_dpi_rawdev_start(struct rte_rawdev *dev)
+{
+	dev->started = DPI_QUEUE_START;
+
+	return DPI_DMA_QUEUE_SUCCESS;
+}
+
+static void
+otx2_dpi_rawdev_stop(struct rte_rawdev *dev)
+{
+	dev->started = DPI_QUEUE_STOP;
+}
+
+static int
+otx2_dpi_rawdev_close(struct rte_rawdev *dev)
+{
+	dma_engine_enb_dis(dev->dev_private, false);
+	dma_queue_finish(dev->dev_private);
+
+	return DPI_DMA_QUEUE_SUCCESS;
+}
+
+static int
+otx2_dpi_rawdev_reset(struct rte_rawdev *dev)
+{
+	return dev ? DPI_QUEUE_STOP : DPI_QUEUE_START;
+}
+
 static int
 otx2_dpi_rawdev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config)
 {
@@ -273,7 +332,12 @@ otx2_dpi_rawdev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config)
 
 static const struct rte_rawdev_ops dpi_rawdev_ops = {
 	.dev_configure = otx2_dpi_rawdev_configure,
+	.dev_start = otx2_dpi_rawdev_start,
+	.dev_stop = otx2_dpi_rawdev_stop,
+	.dev_close = otx2_dpi_rawdev_close,
+	.dev_reset = otx2_dpi_rawdev_reset,
 	.enqueue_bufs = otx2_dpi_rawdev_enqueue_bufs,
+	.dequeue_bufs = otx2_dpi_rawdev_dequeue_bufs,
 };
 
 static int
Signature · 1 line
2.22.0
#20 lore raw

PATCH v2 7/8 raw/octeontx2_dma: add driver self test

In reply to [email protected]

From: Satha Rao <[email protected]>

Sample test to verify DMA functionality, this test covers internal transfer mode.

---
 doc/guides/rawdevs/octeontx2_dma.rst        |  14 ++
 drivers/raw/octeontx2_dma/Makefile          |   3 +-
 drivers/raw/octeontx2_dma/meson.build       |   2 +-
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c |   1 +
 drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h |   1 +
 drivers/raw/octeontx2_dma/otx2_dpi_test.c   | 217 ++++++++++++++++++++
 6 files changed, 236 insertions(+), 2 deletions(-)
 create mode 100644 drivers/raw/octeontx2_dma/otx2_dpi_test.c
doc/guides/rawdevs/octeontx2_dma.rst +14 -0
index 748f4dbd4..579c70c5e 100644
@@ -88,3 +88,17 @@ Performing Data Transfer
 
 To perform data transfer using OCTEON TX2 DMA rawdev devices use standard
 ``rte_rawdev_enqueue_buffers()`` and ``rte_rawdev_dequeue_buffers()`` APIs.
+
+Self test
+---------
+
+On EAL initialization, dma devices will be probed and populated into the
+raw devices. The rawdev ID of the device can be obtained using
+
+* Invoke ``rte_rawdev_get_dev_id("DPI:x")`` from the application
+  where x is the VF device's bus id specified in "bus:device.func" format. Use this
+  index for further rawdev function calls.
+
+* This PMD supports driver self test, to test DMA internal mode from test
+  application one can directly calls
+  ``rte_rawdev_selftest(rte_rawdev_get_dev_id("DPI:x"))``
drivers/raw/octeontx2_dma/Makefile +2 -1
index e1993fe04..96f782eb6 100644
@@ -11,7 +11,7 @@ CFLAGS += -O3 $(WERROR_FLAGS)
 CFLAGS += -I$(RTE_SDK)/drivers/common/octeontx2/
 CFLAGS += -I$(RTE_SDK)/drivers/mempool/octeontx2/
 CFLAGS += -I$(RTE_SDK)/drivers/raw/octeontx2_dma/
-LDLIBS += -lrte_eal -lrte_rawdev -lrte_bus_pci
+LDLIBS += -lrte_eal -lrte_rawdev -lrte_bus_pci -lrte_mbuf
 LDLIBS += -lrte_common_octeontx2 -lrte_mempool
 
 ifneq ($(CONFIG_RTE_ARCH_64),y)
@@ -31,5 +31,6 @@ LIBABIVER := 1
 #
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += otx2_dpi_rawdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += otx2_dpi_msg.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += otx2_dpi_test.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/octeontx2_dma/meson.build +1 -1
index 8ea182812..11f74680a 100644
@@ -3,7 +3,7 @@
 #
 
 deps += ['bus_pci', 'common_octeontx2', 'rawdev']
-sources = files('otx2_dpi_rawdev.c', 'otx2_dpi_msg.c')
+sources = files('otx2_dpi_rawdev.c', 'otx2_dpi_msg.c', 'otx2_dpi_test.c')
 
 extra_flags = []
 # This integrated controller runs only on a arm64 machine, remove 32bit warnings
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.c +1 -0
index 6ce218ec3..6a1b43678 100644
@@ -338,6 +338,7 @@ static const struct rte_rawdev_ops dpi_rawdev_ops = {
 	.dev_reset = otx2_dpi_rawdev_reset,
 	.enqueue_bufs = otx2_dpi_rawdev_enqueue_bufs,
 	.dequeue_bufs = otx2_dpi_rawdev_dequeue_bufs,
+	.dev_selftest = test_otx2_dma_rawdev,
 };
 
 static int
drivers/raw/octeontx2_dma/otx2_dpi_rawdev.h +1 -0
index f59bab97f..9ebb25988 100644
@@ -191,5 +191,6 @@ union dpi_dma_instr_hdr_u {
 
 int otx2_dpi_queue_open(uint16_t vf_id, uint32_t size, uint32_t gaura);
 int otx2_dpi_queue_close(uint16_t vf_id);
+int test_otx2_dma_rawdev(uint16_t val);
 
 #endif /* _DPI_RAWDEV_H_ */
drivers/raw/octeontx2_dma/otx2_dpi_test.c new file +217 -0

217 lines not on this page · raw message

Signature · 1 line
2.22.0
#21 lore raw

PATCH v2 8/8 usertools: add octeontx2 DMA device binding

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Update the devbind script with new section of DMA devices, also added OCTEONTX2 DMA device ID to DMA device list

---
 doc/guides/rawdevs/octeontx2_dma.rst | 11 +++++++++++
 usertools/dpdk-devbind.py            |  4 +++-
 2 files changed, 14 insertions(+), 1 deletion(-)
doc/guides/rawdevs/octeontx2_dma.rst +11 -0
index 579c70c5e..1e1dfbe93 100644
@@ -63,6 +63,17 @@ entry, `sriov_numvfs` for the corresponding PF driver.
 Once the required VFs are enabled, to be accessible from DPDK, VFs need to be
 bound to vfio-pci driver.
 
+Device Setup
+-------------
+
+The OCTEON TX2 DPI DMA HW devices will need to be bound to a
+user-space IO driver for use. The script ``dpdk-devbind.py`` script
+included with DPDK can be used to view the state of the devices and to bind
+them to a suitable DPDK-supported kernel driver. When querying the status
+of the devices, they will appear under the category of "Misc (rawdev)
+devices", i.e. the command ``dpdk-devbind.py --status-dev misc`` can be
+used to see the state of those devices alone.
+
 Device Configuration
 --------------------
 
usertools/dpdk-devbind.py +3 -1
index 7f02948d7..27b54326f 100755
@@ -37,6 +37,8 @@
               'SVendor': None, 'SDevice': None}
 octeontx2_npa = {'Class': '08', 'Vendor': '177d', 'Device': 'a0fb,a0fc',
               'SVendor': None, 'SDevice': None}
+octeontx2_dma = {'Class': '08', 'Vendor': '177d', 'Device': 'a081',
+              'SVendor': None, 'SDevice': None}
 
 intel_ioat_bdw = {'Class': '08', 'Vendor': '8086', 'Device': '6f20,6f21,6f22,6f23,6f24,6f25,6f26,6f27,6f2e,6f2f',
               'SVendor': None, 'SDevice': None}
@@ -49,7 +51,7 @@
 eventdev_devices = [cavium_sso, cavium_tim, octeontx2_sso]
 mempool_devices = [cavium_fpa, octeontx2_npa]
 compress_devices = [cavium_zip]
-misc_devices = [intel_ioat_bdw, intel_ioat_skx]
+misc_devices = [intel_ioat_bdw, intel_ioat_skx, octeontx2_dma]
 
 # global dict ethernet devices present. Dictionary indexed by PCI address.
 # Each device within this is itself a dictionary of device properties
Signature · 1 line
2.22.0
#22 lore raw
In reply to [email protected]

05/07/2019 10:37, [email protected]:

Quoted 11 lines

Jerin Jacob (2):
raw/octeontx2_dma: add build infra and device probe
usertools: add octeontx2 DMA device binding

Satha Rao (6):
raw/octeontx2_dma: update probe function raw/octeontx2_dma: add device configuration raw/octeontx2_dma: add device close operation raw/octeontx2_dma: add enqueue operation raw/octeontx2_dma: add dequeue and device control operations raw/octeontx2_dma: add driver self test

Well done
Applied, thanks