OCTEON TX2 End Point Driver
cover OCTEON TX2 End Point Driver
This patchset adds support for OCTEON TX2 end point mode of operation. The driver implementation uses DPDK rawdevice sub-system.
Mahipal Challa (6):
raw/octeontx2_ep: add build infra and device probe raw/octeontx2_ep: add device configuration raw/octeontx2_ep: add device uninitialization raw/octeontx2_ep: add enqueue operation raw/octeontx2_ep: add dequeue operation raw/octeontx2_ep: add driver self test
MAINTAINERS | 5 + config/common_base | 5 + doc/guides/rawdevs/index.rst | 1 + doc/guides/rawdevs/octeontx2_ep.rst | 89 +++ drivers/common/octeontx2/hw/otx2_sdp.h | 184 +++++ drivers/common/octeontx2/otx2_common.c | 9 + drivers/common/octeontx2/otx2_common.h | 4 + .../octeontx2/rte_common_octeontx2_version.map | 6 + drivers/raw/Makefile | 1 + drivers/raw/meson.build | 1 + drivers/raw/octeontx2_ep/Makefile | 44 ++ drivers/raw/octeontx2_ep/meson.build | 9 + drivers/raw/octeontx2_ep/otx2_ep_enqdeq.c | 846 +++++++++++++++++++++ drivers/raw/octeontx2_ep/otx2_ep_enqdeq.h | 52 ++ drivers/raw/octeontx2_ep/otx2_ep_rawdev.c | 361 +++++++++ drivers/raw/octeontx2_ep/otx2_ep_rawdev.h | 499 ++++++++++++ drivers/raw/octeontx2_ep/otx2_ep_test.c | 164 ++++ drivers/raw/octeontx2_ep/otx2_ep_vf.c | 476 ++++++++++++ drivers/raw/octeontx2_ep/otx2_ep_vf.h | 10 + .../rte_rawdev_octeontx2_ep_version.map | 4 + mk/rte.app.mk | 2 + 21 files changed, 2772 insertions(+) create mode 100644 doc/guides/rawdevs/octeontx2_ep.rst create mode 100644 drivers/common/octeontx2/hw/otx2_sdp.h create mode 100644 drivers/raw/octeontx2_ep/Makefile create mode 100644 drivers/raw/octeontx2_ep/meson.build create mode 100644 drivers/raw/octeontx2_ep/otx2_ep_enqdeq.c create mode 100644 drivers/raw/octeontx2_ep/otx2_ep_enqdeq.h create mode 100644 drivers/raw/octeontx2_ep/otx2_ep_rawdev.c create mode 100644 drivers/raw/octeontx2_ep/otx2_ep_rawdev.h create mode 100644 drivers/raw/octeontx2_ep/otx2_ep_test.c create mode 100644 drivers/raw/octeontx2_ep/otx2_ep_vf.c create mode 100644 drivers/raw/octeontx2_ep/otx2_ep_vf.h create mode 100644 drivers/raw/octeontx2_ep/rte_rawdev_octeontx2_ep_version.map
Signature · 1 line
1.8.3.1
PATCH 1/6 raw/octeontx2_ep: add build infra and device probe
Add the OCTEON TX2 SDP EP device probe along with the build infrastructure for Make and meson builds.
--- MAINTAINERS | 5 + config/common_base | 5 + doc/guides/rawdevs/index.rst | 1 + doc/guides/rawdevs/octeontx2_ep.rst | 41 +++++++ drivers/raw/Makefile | 1 + drivers/raw/meson.build | 1 + drivers/raw/octeontx2_ep/Makefile | 40 +++++++ drivers/raw/octeontx2_ep/meson.build | 6 + drivers/raw/octeontx2_ep/otx2_ep_rawdev.c | 132 +++++++++++++++++++++ drivers/raw/octeontx2_ep/otx2_ep_rawdev.h | 21 ++++ .../rte_rawdev_octeontx2_ep_version.map | 4 + mk/rte.app.mk | 2 + 12 files changed, 259 insertions(+)
MAINTAINERS +5 -0
@@ -1173,6 +1173,11 @@ M: Vamsi Attunuru <[email protected]> F: drivers/raw/octeontx2_dma/ F: doc/guides/rawdevs/octeontx2_dma.rst +Marvell OCTEON TX2 EP +M: Mahipal Challa <[email protected]> +F: drivers/raw/octeontx2_ep/ +F: doc/guides/rawdevs/octeontx2_ep.rst + NTB M: Xiaoyun Li <[email protected]> M: Jingjing Wu <[email protected]>
config/common_base +5 -0
@@ -796,6 +796,11 @@ CONFIG_RTE_LIBRTE_PMD_IOAT_RAWDEV=y CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV=y # +# Compile PMD for octeontx2 EP raw device +# +CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EP_RAWDEV=y + +# # Compile PMD for NTB raw device # CONFIG_RTE_LIBRTE_PMD_NTB_RAWDEV=y
doc/guides/rawdevs/index.rst +1 -0
@@ -17,3 +17,4 @@ application through rawdev API. ioat ntb octeontx2_dma + octeontx2_ep
doc/guides/rawdevs/octeontx2_ep.rst new file +41 -0
41 lines not on this page · raw message
drivers/raw/Makefile +1 -0
@@ -13,5 +13,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_IFPGA_RAWDEV) += ifpga DIRS-$(CONFIG_RTE_LIBRTE_PMD_IOAT_RAWDEV) += ioat DIRS-$(CONFIG_RTE_LIBRTE_PMD_NTB_RAWDEV) += ntb DIRS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += octeontx2_dma +DIRS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EP_RAWDEV) += octeontx2_ep include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/meson.build +1 -0
@@ -4,6 +4,7 @@ drivers = ['dpaa2_cmdif', 'dpaa2_qdma', 'ifpga', 'ioat', 'ntb', 'octeontx2_dma', + 'octeontx2_ep', 'skeleton'] std_deps = ['rawdev'] config_flag_fmt = 'RTE_LIBRTE_PMD_@0@_RAWDEV'
drivers/raw/octeontx2_ep/Makefile new file +40 -0
@@ -0,0 +1,40 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(C) 2019 Marvell International Ltd. +# + +include $(RTE_SDK)/mk/rte.vars.mk + +# Library name +LIB = librte_rawdev_octeontx2_ep.a + +# Build flags +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) + +CFLAGS += -I$(RTE_SDK)/drivers/common/octeontx2/ +CFLAGS += -I$(RTE_SDK)/drivers/raw/octeontx2_ep/ + +LDLIBS += -lrte_eal +LDLIBS += -lrte_rawdev +LDLIBS += -lrte_bus_pci +LDLIBS += -lrte_mempool +LDLIBS += -lrte_common_octeontx2 + +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_rawdev_octeontx2_ep_version.map + +LIBABIVER := 1 + +# +# All source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EP_RAWDEV) += otx2_ep_rawdev.c + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/octeontx2_ep/meson.build new file +6 -0
@@ -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_ep_rawdev.c')
drivers/raw/octeontx2_ep/otx2_ep_rawdev.c new file +132 -0
132 lines not on this page · raw message
drivers/raw/octeontx2_ep/otx2_ep_rawdev.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2019 Marvell International Ltd. +*/ + +#ifndef _OTX2_EP_RAWDEV_H_ +#define _OTX2_EP_RAWDEV_H_ + +#define PCI_DEVID_OCTEONTX2_EP_VF 0xB203/* OCTEON TX2 EP mode */ + +/* SDP EP VF device */ +struct sdp_device { +/* PCI device pointer */ +struct rte_pci_device *pci_dev; +uint16_t vf_num; + +/* Memory mapped h/w address */ +uint8_t *hw_addr; + +}; + +#endif /* _OTX2_EP_RAWDEV_H_ */
drivers/raw/octeontx2_ep/rte_rawdev_octeontx2_ep_version.map new file +4 -0
@@ -0,0 +1,4 @@ +DPDK_20.02 { + + local: *; +};
mk/rte.app.mk +2 -0
@@ -116,6 +116,7 @@ OCTEONTX2-y := $(CONFIG_RTE_LIBRTE_OCTEONTX2_MEMPOOL) OCTEONTX2-y += $(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO) OCTEONTX2-y += $(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EVENTDEV) OCTEONTX2-y += $(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) +OCTEONTX2-y += $(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EP_RAWDEV) OCTEONTX2-y += $(CONFIG_RTE_LIBRTE_OCTEONTX2_PMD) ifeq ($(findstring y,$(OCTEONTX2-y)),y) _LDLIBS-y += -lrte_common_octeontx2
@@ -336,6 +337,7 @@ endif # CONFIG_RTE_LIBRTE_IFPGA_BUS _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_IOAT_RAWDEV) += -lrte_rawdev_ioat _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NTB_RAWDEV) += -lrte_rawdev_ntb _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_DMA_RAWDEV) += -lrte_rawdev_octeontx2_dma +_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EP_RAWDEV) += -lrte_rawdev_octeontx2_ep endif # CONFIG_RTE_LIBRTE_RAWDEV endif # !CONFIG_RTE_BUILD_SHARED_LIBS
Signature · 1 line
1.8.3.1
PATCH 2/6 raw/octeontx2_ep: add device configuration
In reply to Mahipal ChallaRegister "dev_configure" API to configure/initialize the SDP VF PCIe devices.
--- doc/guides/rawdevs/octeontx2_ep.rst | 29 ++ drivers/common/octeontx2/hw/otx2_sdp.h | 184 +++++++++ drivers/common/octeontx2/otx2_common.c | 9 + drivers/common/octeontx2/otx2_common.h | 4 + .../octeontx2/rte_common_octeontx2_version.map | 6 + drivers/raw/octeontx2_ep/Makefile | 3 + drivers/raw/octeontx2_ep/meson.build | 4 +- drivers/raw/octeontx2_ep/otx2_ep_enqdeq.c | 294 ++++++++++++++ drivers/raw/octeontx2_ep/otx2_ep_enqdeq.h | 11 + drivers/raw/octeontx2_ep/otx2_ep_rawdev.c | 148 +++++++ drivers/raw/octeontx2_ep/otx2_ep_rawdev.h | 434 ++++++++++++++++++++- drivers/raw/octeontx2_ep/otx2_ep_vf.c | 408 +++++++++++++++++++ drivers/raw/octeontx2_ep/otx2_ep_vf.h | 10 + 13 files changed, 1542 insertions(+), 2 deletions(-)
doc/guides/rawdevs/octeontx2_ep.rst +29 -0
@@ -39,3 +39,32 @@ 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 SDP End Point VF 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 +-------------------- + +Configuring SDP EP rawdev device is done using the ``rte_rawdev_configure()`` +API, which takes the mempool as parameter. PMD uses this pool to send/receive +packets to/from the HW. + +The following code shows how the device is configured + +.. code-block:: c + + struct sdp_rawdev_info config = {0}; + struct rte_rawdev_info rdev_info = {.dev_private = &config}; + config.enqdeq_mpool = (void *)rte_mempool_create(...); + + rte_rawdev_configure(dev_id, (rte_rawdev_obj_t)&rdev_info); +
drivers/common/octeontx2/hw/otx2_sdp.h new file +184 -0
184 lines not on this page · raw message
drivers/common/octeontx2/otx2_common.c +9 -0
@@ -205,6 +205,10 @@ int otx2_npa_lf_obj_ref(void)* @internal */ int otx2_logtype_dpi; +/** +* @internal +*/ +int otx2_logtype_ep;RTE_INIT (otx2_log_init); static void
@@ -245,4 +249,9 @@ int otx2_npa_lf_obj_ref(void) otx2_logtype_dpi =rte_log_register ("pmd.raw.octeontx2.dpi" );if (otx2_logtype_dpi >=0 )rte_log_set_level (otx2_logtype_dpi,RTE_LOG_NOTICE ); + + otx2_logtype_ep =rte_log_register ("pmd.raw.octeontx2.ep" ); +if (otx2_logtype_ep >=0 ) +rte_log_set_level (otx2_logtype_ep,RTE_LOG_NOTICE ); + }
drivers/common/octeontx2/otx2_common.h +4 -0
@@ -16,6 +16,7 @@#include "hw/otx2_nix.h" #include "hw/otx2_npc.h" #include "hw/otx2_npa.h" +#include "hw/otx2_sdp.h" #include "hw/otx2_sso.h" #include "hw/otx2_ssow.h" #include "hw/otx2_tim.h"
@@ -85,6 +86,7 @@ struct otx2_idev_cfg {extern int otx2_logtype_tm;extern int otx2_logtype_tim;extern int otx2_logtype_dpi; +extern int otx2_logtype_ep; #define otx2_err(fmt, args...) \ RTE_LOG(ERR, PMD, "%s():%u " fmt "\n", \
@@ -107,6 +109,7 @@ struct otx2_idev_cfg {#define otx2_tm_dbg (fmt, ...) otx2_dbg(tm, fmt, ##__VA_ARGS__)#define otx2_tim_dbg (fmt, ...) otx2_dbg(tim, fmt, ##__VA_ARGS__)#define otx2_dpi_dbg (fmt, ...) otx2_dbg(dpi, fmt, ##__VA_ARGS__) +#define otx2_sdp_dbg (fmt, ...) otx2_dbg(ep, fmt, ##__VA_ARGS__)/* PCI IDs */ #define PCI_VENDOR_ID_CAVIUM 0x177D
@@ -121,6 +124,7 @@ struct otx2_idev_cfg {#define PCI_DEVID_OCTEONTX2_RVU_CPT_VF 0xA0FE#define PCI_DEVID_OCTEONTX2_RVU_AF_VF 0xA0f8#define PCI_DEVID_OCTEONTX2_DPI_VF 0xA081 +#define PCI_DEVID_OCTEONTX2_EP_VF 0xB203/* OCTEON TX2 EP mode */ #define PCI_DEVID_OCTEONTX2_RVU_SDP_PF 0xA0f6#define PCI_DEVID_OCTEONTX2_RVU_SDP_VF 0xA0f7
drivers/common/octeontx2/rte_common_octeontx2_version.map +6 -0
@@ -33,3 +33,9 @@ DPDK_20.0 { local: *; }; + +EXPERIMENTAL { + global: + + otx2_logtype_ep; +};
drivers/raw/octeontx2_ep/Makefile +3 -0
@@ -36,5 +36,8 @@ LIBABIVER := 1 # All source are stored in SRCS-y # SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EP_RAWDEV) += otx2_ep_rawdev.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EP_RAWDEV) += otx2_ep_enqdeq.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EP_RAWDEV) += otx2_ep_vf.c + include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/octeontx2_ep/meson.build +3 -1
@@ -3,4 +3,6 @@ # deps += ['bus_pci', 'common_octeontx2', 'rawdev'] -sources = files('otx2_ep_rawdev.c') +sources = files('otx2_ep_rawdev.c', + 'otx2_ep_enqdeq.c', + 'otx2_ep_vf.c')
drivers/raw/octeontx2_ep/otx2_ep_enqdeq.c new file +294 -0
294 lines not on this page · raw message
drivers/raw/octeontx2_ep/otx2_ep_enqdeq.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2019 Marvell International Ltd. +*/ + +#ifndef _OTX2_EP_ENQDEQ_H_ +#define _OTX2_EP_ENQDEQ_H_ + +#include <rte_byteorder.h> +#include "otx2_ep_rawdev.h" + +#endif /* _OTX2_EP_ENQDEQ_H_ */
drivers/raw/octeontx2_ep/otx2_ep_rawdev.c +148 -0
166 lines not on this page · raw message
drivers/raw/octeontx2_ep/otx2_ep_rawdev.h +433 -1
450 lines not on this page · raw message
drivers/raw/octeontx2_ep/otx2_ep_vf.c new file +408 -0
408 lines not on this page · raw message
drivers/raw/octeontx2_ep/otx2_ep_vf.h new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2019 Marvell International Ltd. +*/ +#ifndef _OTX2_EP_VF_H_ +#define _OTX2_EP_VF_H_ +int +sdp_vf_setup_device (struct sdp_device *sdpvf); + +#endif /*_OTX2_EP_VF_H_ */ +
Signature · 1 line
1.8.3.1
PATCH 3/6 raw/octeontx2_ep: add device uninitialization
In reply to Mahipal ChallaAdd rawdev close/uninitialize operation for SDP
VF devices.
--- drivers/raw/octeontx2_ep/otx2_ep_enqdeq.c | 111 ++++++++++++++++++++++++++++++ drivers/raw/octeontx2_ep/otx2_ep_rawdev.c | 78 +++++++++++++++++++++ drivers/raw/octeontx2_ep/otx2_ep_rawdev.h | 8 +++ drivers/raw/octeontx2_ep/otx2_ep_vf.c | 44 ++++++++++++ 4 files changed, 241 insertions(+)
drivers/raw/octeontx2_ep/otx2_ep_enqdeq.c +111 -0
@@ -21,6 +21,59 @@#include "otx2_common.h" #include "otx2_ep_enqdeq.h" +static void +sdp_dmazone_free (const struct rte_memzone *mz) +{ +const struct rte_memzone *mz_tmp; +int ret =0 ; + +if (mz ==NULL ) { +otx2_err ("Memzone %s : NULL" , mz->name); +return ; + } + + mz_tmp =rte_memzone_lookup (mz->name); +if (mz_tmp ==NULL ) { +otx2_err ("Memzone %s Not Found" , mz->name); +return ; + } + + ret =rte_memzone_free (mz); +if (ret) +otx2_err ("Memzone free failed : ret = %d" , ret); + +} + +/* Free IQ resources */ +int +sdp_delete_iqs (struct sdp_device *sdpvf,uint32_t iq_no) +{ +struct sdp_instr_queue *iq; + + iq = sdpvf->instr_queue[iq_no]; +if (iq ==NULL ) { +otx2_err ("Invalid IQ[%d]\n" , iq_no); +return -ENOMEM ; + } + +rte_free (iq->req_list); + iq->req_list =NULL ; + +if (iq->iq_mz) { +sdp_dmazone_free (iq->iq_mz); + iq->iq_mz =NULL ; + } + +rte_free (sdpvf->instr_queue[iq_no]); + sdpvf->instr_queue[iq_no] =NULL ; + + sdpvf->num_iqs--; + +otx2_info ("IQ[%d] is deleted" , iq_no); + +return 0 ; +} +/* IQ initialization */ static int sdp_init_instr_queue (struct sdp_device *sdpvf,int iq_no)
@@ -126,6 +179,7 @@return 0 ; delete_IQ: +sdp_delete_iqs (sdpvf, iq_no);return -ENOMEM ; }
@@ -139,6 +193,61 @@rte_atomic64_set (&droq->pkts_pending,0 ); } +static void +sdp_droq_destroy_ring_buffers (struct sdp_device *sdpvf, +struct sdp_droq *droq) +{ +uint32_t idx; + +for (idx =0 ; idx < droq->nb_desc; idx++) { +if (droq->recv_buf_list[idx].buffer) { +rte_mempool_put (sdpvf->enqdeq_mpool, + droq->recv_buf_list[idx].buffer); + + droq->recv_buf_list[idx].buffer =NULL ; + } + } + +sdp_droq_reset_indices (droq); +} + +/* Free OQs resources */ +int +sdp_delete_oqs (struct sdp_device *sdpvf,uint32_t oq_no) +{ +struct sdp_droq *droq; + + droq = sdpvf->droq[oq_no]; +if (droq ==NULL ) { +otx2_err ("Invalid droq[%d]" , oq_no); +return -ENOMEM ; + } + +sdp_droq_destroy_ring_buffers (sdpvf, droq); +rte_free (droq->recv_buf_list); + droq->recv_buf_list =NULL ; + +if (droq->info_mz) { +sdp_dmazone_free (droq->info_mz); + droq->info_mz =NULL ; + } + +if (droq->desc_ring_mz) { +sdp_dmazone_free (droq->desc_ring_mz); + droq->desc_ring_mz =NULL ; + } + +memset (droq,0 ,SDP_DROQ_SIZE ); + +rte_free (sdpvf->droq[oq_no]); + sdpvf->droq[oq_no] =NULL ; + + sdpvf->num_oqs--; + +otx2_info ("OQ[%d] is deleted" , oq_no); +return 0 ; +} +static int sdp_droq_setup_ring_buffers (struct sdp_device *sdpvf,struct sdp_droq *droq)
@@ -290,5 +399,7 @@return 0 ; delete_OQ: +sdp_delete_oqs (sdpvf, oq_no);return -ENOMEM ; } +
drivers/raw/octeontx2_ep/otx2_ep_rawdev.c +78 -0
103 lines not on this page · raw message
drivers/raw/octeontx2_ep/otx2_ep_rawdev.h +8 -0
@@ -378,10 +378,16 @@ struct sdp_config {struct sdp_fn_list {void (*setup_iq_regs)(struct sdp_device *sdpvf,uint32_t q_no);void (*setup_oq_regs)(struct sdp_device *sdpvf,uint32_t q_no); +int (*setup_device_regs)(struct sdp_device *sdpvf);void (*enable_io_queues)(struct sdp_device *sdpvf); +void (*disable_io_queues)(struct sdp_device *sdpvf); +void (*enable_iq)(struct sdp_device *sdpvf,uint32_t q_no); +void (*disable_iq)(struct sdp_device *sdpvf,uint32_t q_no); +void (*enable_oq)(struct sdp_device *sdpvf,uint32_t q_no); +void (*disable_oq)(struct sdp_device *sdpvf,uint32_t q_no); };/* SRIOV information */
@@ -447,7 +453,9 @@ struct sdp_device {const struct sdp_config *sdp_get_defconf (struct sdp_device *sdp_dev);int sdp_setup_iqs (struct sdp_device *sdpvf,uint32_t iq_no); +int sdp_delete_iqs (struct sdp_device *sdpvf,uint32_t iq_no);int sdp_setup_oqs (struct sdp_device *sdpvf,uint32_t oq_no); +int sdp_delete_oqs (struct sdp_device *sdpvf,uint32_t oq_no);#endif /* _OTX2_EP_RAWDEV_H_ */
drivers/raw/octeontx2_ep/otx2_ep_vf.c +44 -0
60 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 4/6 raw/octeontx2_ep: add enqueue operation
In reply to Mahipal ChallaAdd rawdev enqueue operation for SDP VF devices.
--- doc/guides/rawdevs/octeontx2_ep.rst | 6 + drivers/raw/octeontx2_ep/otx2_ep_enqdeq.c | 242 ++++++++++++++++++++++++++++++ drivers/raw/octeontx2_ep/otx2_ep_enqdeq.h | 39 +++++ drivers/raw/octeontx2_ep/otx2_ep_rawdev.c | 1 + drivers/raw/octeontx2_ep/otx2_ep_rawdev.h | 20 +++ drivers/raw/octeontx2_ep/otx2_ep_vf.c | 24 +++ 6 files changed, 332 insertions(+)
doc/guides/rawdevs/octeontx2_ep.rst +6 -0
@@ -68,3 +68,9 @@ The following code shows how the device is configured rte_rawdev_configure(dev_id, (rte_rawdev_obj_t)&rdev_info); +Performing Data Transfer +------------------------ + +To perform data transfer using SDP VF EP rawdev devices use standard +``rte_rawdev_enqueue_buffers()`` and ``rte_rawdev_dequeue_buffers()`` APIs. +
drivers/raw/octeontx2_ep/otx2_ep_enqdeq.c +242 -0
245 lines not on this page · raw message
drivers/raw/octeontx2_ep/otx2_ep_enqdeq.h +39 -0
@@ -8,4 +8,43 @@#include <rte_byteorder.h> #include "otx2_ep_rawdev.h" +#define SDP_IQ_SEND_FAILED (-1) +#define SDP_IQ_SEND_SUCCESS (0) + + +static inline uint64_t +sdp_endian_swap_8B (uint64_t _d) +{ +return ((((((uint64_t )(_d)) >>0 ) & (uint64_t )0xff ) <<56 ) | + (((((uint64_t )(_d)) >>8 ) & (uint64_t )0xff ) <<48 ) | + (((((uint64_t )(_d)) >>16 ) & (uint64_t )0xff ) <<40 ) | + (((((uint64_t )(_d)) >>24 ) & (uint64_t )0xff ) <<32 ) | + (((((uint64_t )(_d)) >>32 ) & (uint64_t )0xff ) <<24 ) | + (((((uint64_t )(_d)) >>40 ) & (uint64_t )0xff ) <<16 ) | + (((((uint64_t )(_d)) >>48 ) & (uint64_t )0xff ) <<8 ) | + (((((uint64_t )(_d)) >>56 ) & (uint64_t )0xff ) <<0 )); +} + +static inline void +sdp_swap_8B_data (uint64_t *data,uint32_t blocks) +{ +/* Swap 8B blocks */ +while (blocks) { + *data =sdp_endian_swap_8B (*data); + blocks--; + data++; + } +} + +static inline uint32_t +sdp_incr_index (uint32_t index,uint32_t count,uint32_t max) +{ +if ((index + count) >= max) + index = index + count - max; +else + index += count; + +return index; +} +#endif /* _OTX2_EP_ENQDEQ_H_ */
drivers/raw/octeontx2_ep/otx2_ep_rawdev.c +1 -0
@@ -251,6 +251,7 @@ .dev_start = sdp_rawdev_start, .dev_stop = sdp_rawdev_stop, .dev_close = sdp_rawdev_close, + .enqueue_bufs = sdp_rawdev_enqueue, }; static int
drivers/raw/octeontx2_ep/otx2_ep_rawdev.h +20 -0
@@ -8,6 +8,10 @@#include <rte_byteorder.h> #include <rte_spinlock.h> +/* IQ instruction req types */ +#define SDP_REQTYPE_NONE (0) +#define SDP_REQTYPE_NORESP (1) +#define SDP_REQTYPE_NORESP_GATHER (2)/* Input Request Header format */ struct sdp_instr_irh {
@@ -128,6 +132,13 @@ struct sdp_instr_list { };#define SDP_IQREQ_LIST_SIZE (sizeof(struct sdp_instr_list)) +/* Input Queue statistics. Each input queue has four stats fields. */ +struct sdp_iq_stats { +uint64_t instr_posted;/* Instructions posted to this queue. */ +uint64_t instr_processed;/* Instructions processed in this queue. */ +uint64_t instr_dropped;/* Instructions that could not be processed */ +}; +/* Structure to define the configuration attributes for each Input queue. */ struct sdp_iq_config {/* Max number of IQs available */
@@ -195,6 +206,9 @@ struct sdp_instr_queue {/* Number of instructions pending to be posted to OCTEON TX2. */ uint32_t fill_cnt; +/* Statistics for this input queue. */ +struct sdp_iq_stats stats; +/* DMA mapped base address of the input descriptor ring. */ uint64_t base_addr_dma;
@@ -380,6 +394,8 @@ struct sdp_fn_list {void (*setup_oq_regs)(struct sdp_device *sdpvf,uint32_t q_no);int (*setup_device_regs)(struct sdp_device *sdpvf); +uint32_t (*update_iq_read_idx)(struct sdp_instr_queue *iq); +void (*enable_io_queues)(struct sdp_device *sdpvf);void (*disable_io_queues)(struct sdp_device *sdpvf);
@@ -458,4 +474,8 @@ struct sdp_device {int sdp_setup_oqs (struct sdp_device *sdpvf,uint32_t oq_no);int sdp_delete_oqs (struct sdp_device *sdpvf,uint32_t oq_no); +int sdp_rawdev_enqueue (struct rte_rawdev *dev,struct rte_rawdev_buf **buffers, +unsigned int count,rte_rawdev_obj_t context); + +#endif /* _OTX2_EP_RAWDEV_H_ */
drivers/raw/octeontx2_ep/otx2_ep_vf.c +24 -0
@@ -409,6 +409,28 @@sdp_vf_disable_oq (sdpvf, q_no); } +static uint32_t +sdp_vf_update_read_index (struct sdp_instr_queue *iq) +{ +uint32_t new_idx =rte_read32 (iq->inst_cnt_reg); + +/* The new instr cnt reg is a 32-bit counter that can roll over. +* We have noted the counter's initial value at init time into +* reset_instr_cnt +*/ +if (iq->reset_instr_cnt < new_idx) + new_idx -= iq->reset_instr_cnt; +else + new_idx += (0xffffffff - iq->reset_instr_cnt) +1 ; + +/* Modulo of the new index with the IQ size will give us +* the new index. +*/ + new_idx %= iq->nb_desc; + +return new_idx; +} +int sdp_vf_setup_device (struct sdp_device *sdpvf) {
@@ -436,6 +458,8 @@ sdpvf->fn_list.setup_oq_regs = sdp_vf_setup_oq_regs; sdpvf->fn_list.setup_device_regs = sdp_vf_setup_device_regs; + sdpvf->fn_list.update_iq_read_idx = sdp_vf_update_read_index; + sdpvf->fn_list.enable_io_queues = sdp_vf_enable_io_queues; sdpvf->fn_list.disable_io_queues = sdp_vf_disable_io_queues;
Signature · 1 line
1.8.3.1
PATCH 5/6 raw/octeontx2_ep: add dequeue operation
In reply to Mahipal ChallaAdd rawdev dequeue operation for SDP VF devices.
--- drivers/raw/octeontx2_ep/otx2_ep_enqdeq.c | 199 ++++++++++++++++++++++++++++++ drivers/raw/octeontx2_ep/otx2_ep_enqdeq.h | 2 + drivers/raw/octeontx2_ep/otx2_ep_rawdev.c | 1 + drivers/raw/octeontx2_ep/otx2_ep_rawdev.h | 18 ++- 4 files changed, 219 insertions(+), 1 deletion(-)
drivers/raw/octeontx2_ep/otx2_ep_enqdeq.c +199 -0
@@ -260,6 +260,7 @@rte_mempool_get (sdpvf->enqdeq_mpool, &buf);if (buf ==NULL ) {otx2_err ("OQ buffer alloc failed" ); + droq->stats.rx_alloc_failure++;/* sdp_droq_destroy_ring_buffers(droq);*/ return -ENOMEM ; }
@@ -645,3 +646,201 @@return SDP_IQ_SEND_FAILED ; } +static uint32_t +sdp_droq_refill (struct sdp_device *sdpvf,struct sdp_droq *droq) +{ +struct sdp_droq_desc *desc_ring; +uint32_t desc_refilled =0 ; +void *buf =NULL ; + + desc_ring = droq->desc_ring; + +while (droq->refill_count && (desc_refilled < droq->nb_desc)) { +/* If a valid buffer exists (happens if there is no dispatch), +* reuse the buffer, else allocate. +*/ +if (droq->recv_buf_list[droq->refill_idx].buffer !=NULL ) +break ; + +rte_mempool_get (sdpvf->enqdeq_mpool, &buf); +/* If a buffer could not be allocated, no point in +* continuing +*/ +if (buf ==NULL ) { + droq->stats.rx_alloc_failure++; +break ; + } + + droq->recv_buf_list[droq->refill_idx].buffer = buf; + desc_ring[droq->refill_idx].buffer_ptr =rte_mem_virt2iova (buf); + +/* Reset any previous values in the length field. */ + droq->info_list[droq->refill_idx].length =0 ; + + droq->refill_idx =sdp_incr_index (droq->refill_idx,1 , + droq->nb_desc); + + desc_refilled++; + droq->refill_count--; + + } + +return desc_refilled; +} + +static int +sdp_droq_read_packet(struct sdp_device *sdpvf __rte_unused, +struct sdp_droq *droq, +struct sdp_droq_pkt *droq_pkt) +{ +struct sdp_droq_info *info; +uint32_t total_len =0 ; +uint32_t pkt_len =0 ; + + info = &droq->info_list[droq->read_idx]; +sdp_swap_8B_data ((uint64_t *)&info->length,1 ); +if (!info->length) { +otx2_err ("OQ info_list->length[%ld]" , (long )info->length); + goto oq_read_fail; + } + +/* Deduce the actual data size */ + info->length -=SDP_RH_SIZE ; + total_len += (uint32_t )info->length; + +otx2_sdp_dbg ("OQ: pkt_len[%ld], buffer_size %d" , + (long )info->length, droq->buffer_size); +if (info->length > droq->buffer_size) { +otx2_err ("This mode is not supported: pkt_len > buffer_size" ); + goto oq_read_fail; + } + +if (info->length <= droq->buffer_size) { + pkt_len = (uint32_t )info->length; + droq_pkt->data = droq->recv_buf_list[droq->read_idx].buffer; + droq_pkt->len = pkt_len; + + droq->recv_buf_list[droq->read_idx].buffer =NULL ; + droq->read_idx =sdp_incr_index (droq->read_idx,1 ,/* count */ + droq->nb_desc/* max rd idx */ ); + droq->refill_count++; + + } + + info->length =0 ; + +return SDP_OQ_RECV_SUCCESS ; + +oq_read_fail: +return SDP_OQ_RECV_FAILED ; +} + +static inline uint32_t +sdp_check_droq_pkts (struct sdp_droq *droq,uint32_t burst_size) +{ +uint32_t min_pkts =0 ; +uint32_t new_pkts; +uint32_t pkt_count; + +/* Latest available OQ packets */ + pkt_count =rte_read32 (droq->pkts_sent_reg); + +/* Newly arrived packets */ + new_pkts = pkt_count - droq->last_pkt_count; +otx2_sdp_dbg ("Recvd [%d] new OQ pkts" , new_pkts); + + min_pkts = (new_pkts > burst_size) ? burst_size : new_pkts; +if (min_pkts) { +rte_atomic64_add (&droq->pkts_pending, min_pkts); +/* Back up the aggregated packet count so far */ + droq->last_pkt_count += min_pkts; + } + +return min_pkts; +} + +/* Check for response arrival from OCTEON TX2 +* returns number of requests completed +*/ +int +sdp_rawdev_dequeue (struct rte_rawdev *rawdev, +struct rte_rawdev_buf **buffers,unsigned int count, + rte_rawdev_obj_t context __rte_unused) +{ +struct sdp_droq_pkt *oq_pkt; +struct sdp_device *sdpvf; +struct sdp_droq *droq; + +uint32_t q_no =0 , pkts; +uint32_t new_pkts; +uint32_t ret; + + sdpvf = (struct sdp_device *)rawdev->dev_private; + + droq = sdpvf->droq[q_no]; +if (!droq) { +otx2_err ("Invalid droq[%d]" , q_no); + goto deq_fail; + } + +/* Grab the lock */ +rte_spinlock_lock (&droq->lock); + + new_pkts =sdp_check_droq_pkts (droq, count); +if (!new_pkts) { +otx2_sdp_dbg ("Zero new_pkts:%d" , new_pkts); + goto deq_fail;/* No pkts at this moment */ + } + +otx2_sdp_dbg ("Received new_pkts = %d" , new_pkts); + +for (pkts =0 ; pkts < new_pkts; pkts++) { + +/* Push the received pkt to application */ + oq_pkt = (struct sdp_droq_pkt *)buffers[pkts]; + + ret =sdp_droq_read_packet (sdpvf, droq, oq_pkt); +if (ret) { +otx2_err ("DROQ read pakt failed." ); + goto deq_fail; + } + +/* Stats */ + droq->stats.pkts_received++; + droq->stats.bytes_received += oq_pkt->len; + } + +/* Ack the h/w with no# of pkts read by Host */ +rte_wmb (); +rte_write32 (pkts, droq->pkts_sent_reg); +rte_wmb (); + + droq->last_pkt_count -= pkts; + +otx2_sdp_dbg ("DROQ pkts[%d] pushed to application" , pkts); + +/* Refill DROQ buffers */ +if (droq->refill_count >=2 /* droq->refill_threshold */ ) { +int desc_refilled =sdp_droq_refill (sdpvf, droq); + +/* Flush the droq descriptor data to memory to be sure +* that when we update the credits the data in memory is +* accurate. +*/ +rte_wmb (); +rte_write32 (desc_refilled, droq->pkts_credit_reg); + +/* Ensure mmio write completes */ +rte_wmb (); +otx2_sdp_dbg ("Refilled count = %d" , desc_refilled); + } + +/* Release the spin lock */ +rte_spinlock_unlock (&droq->lock); + +return pkts; + +deq_fail: +rte_spinlock_unlock (&droq->lock); +return SDP_OQ_RECV_FAILED ; +}
drivers/raw/octeontx2_ep/otx2_ep_enqdeq.h +2 -0
@@ -11,6 +11,8 @@#define SDP_IQ_SEND_FAILED (-1)#define SDP_IQ_SEND_SUCCESS (0) +#define SDP_OQ_RECV_FAILED (-1) +#define SDP_OQ_RECV_SUCCESS (0)static inline uint64_t sdp_endian_swap_8B (uint64_t _d)
drivers/raw/octeontx2_ep/otx2_ep_rawdev.c +1 -0
@@ -252,6 +252,7 @@ .dev_stop = sdp_rawdev_stop, .dev_close = sdp_rawdev_close, .enqueue_bufs = sdp_rawdev_enqueue, + .dequeue_bufs = sdp_rawdev_dequeue, }; static int
drivers/raw/octeontx2_ep/otx2_ep_rawdev.h +17 -1
@@ -279,6 +279,18 @@ struct sdp_recv_buffer { };#define SDP_DROQ_RECVBUF_SIZE (sizeof(struct sdp_recv_buffer)) +/* DROQ statistics. Each output queue has four stats fields. */ +struct sdp_droq_stats { +/* Number of packets received in this queue. */ +uint64_t pkts_received; + +/* Bytes received by this queue. */ +uint64_t bytes_received; + +/* Num of failures of rte_pktmbuf_alloc() */ +uint64_t rx_alloc_failure; +}; +/* Structure to define the configuration attributes for each Output queue. */ struct sdp_oq_config {/* Max number of OQs available */
@@ -345,6 +357,9 @@ struct sdp_droq {*/ void *pkts_sent_reg; +/* Statistics for this DROQ. */ +struct sdp_droq_stats stats; +/* DMA mapped address of the DROQ descriptor ring. */ size_t desc_ring_dma;
@@ -476,6 +491,7 @@ struct sdp_device {int sdp_rawdev_enqueue (struct rte_rawdev *dev,struct rte_rawdev_buf **buffers,unsigned int count,rte_rawdev_obj_t context); - +int sdp_rawdev_dequeue (struct rte_rawdev *dev,struct rte_rawdev_buf **buffers, +unsigned int count,rte_rawdev_obj_t context);#endif /* _OTX2_EP_RAWDEV_H_ */
Signature · 1 line
1.8.3.1
PATCH 6/6 raw/octeontx2_ep: add driver self test
In reply to Mahipal ChallaAdd rawdev's selftest feature in SDP VF driver, which verifies the EP mode functionality test.
--- doc/guides/rawdevs/octeontx2_ep.rst | 13 +++ drivers/raw/octeontx2_ep/Makefile | 1 + drivers/raw/octeontx2_ep/meson.build | 1 + drivers/raw/octeontx2_ep/otx2_ep_rawdev.c | 1 + drivers/raw/octeontx2_ep/otx2_ep_rawdev.h | 2 + drivers/raw/octeontx2_ep/otx2_ep_test.c | 164 ++++++++++++++++++++++++++++++ 6 files changed, 182 insertions(+)
doc/guides/rawdevs/octeontx2_ep.rst +13 -0
@@ -74,3 +74,16 @@ Performing Data Transfer To perform data transfer using SDP VF EP rawdev devices use standard ``rte_rawdev_enqueue_buffers()`` and ``rte_rawdev_dequeue_buffers()`` APIs. +Self test +--------- + +On EAL initialization, SDP VF 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("SDPEP:x")`` from the test application + where x is the VF device's bus id specified in "bus:device.func"(BDF) + format. Use this index for further rawdev function calls. + +* The driver's selftest rawdev API can be used to verify the SDP EP mode + functional tests which can send/receive the raw data packets to/from the + EP device.
drivers/raw/octeontx2_ep/Makefile +1 -0
@@ -37,6 +37,7 @@ LIBABIVER := 1 # SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EP_RAWDEV) += otx2_ep_rawdev.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EP_RAWDEV) += otx2_ep_enqdeq.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EP_RAWDEV) += otx2_ep_test.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_EP_RAWDEV) += otx2_ep_vf.c
drivers/raw/octeontx2_ep/meson.build +1 -0
@@ -5,4 +5,5 @@ deps += ['bus_pci', 'common_octeontx2', 'rawdev'] sources = files('otx2_ep_rawdev.c', 'otx2_ep_enqdeq.c', + 'otx2_ep_test.c', 'otx2_ep_vf.c')
drivers/raw/octeontx2_ep/otx2_ep_rawdev.c +1 -0
@@ -253,6 +253,7 @@ .dev_close = sdp_rawdev_close, .enqueue_bufs = sdp_rawdev_enqueue, .dequeue_bufs = sdp_rawdev_dequeue, + .dev_selftest = sdp_rawdev_selftest, }; static int
drivers/raw/octeontx2_ep/otx2_ep_rawdev.h +2 -0
@@ -494,4 +494,6 @@ int sdp_rawdev_enqueue(struct rte_rawdev *dev, struct rte_rawdev_buf **buffers,int sdp_rawdev_dequeue (struct rte_rawdev *dev,struct rte_rawdev_buf **buffers,unsigned int count,rte_rawdev_obj_t context); +int sdp_rawdev_selftest (uint16_t dev_id); +#endif /* _OTX2_EP_RAWDEV_H_ */
drivers/raw/octeontx2_ep/otx2_ep_test.c new file +164 -0
164 lines not on this page · raw message
Signature · 1 line
1.8.3.1