On Mon, 12 Aug 2024 15:31:24 +0800 Yong Zhang <zhang.yon...@zte.com.cn> wrote:
> diff --git a/doc/guides/rawdevs/zxdh.rst b/doc/guides/rawdevs/zxdh.rst > new file mode 100644 > index 0000000000..fa7ada1004 > --- /dev/null > +++ b/doc/guides/rawdevs/zxdh.rst > @@ -0,0 +1,30 @@ > +.. SPDX-License-Identifier: BSD-3-Clause > + Copyright 2024 ZTE Corporation > + > +ZXDH Rawdev Driver > +====================== > + > +The ``zxdh`` rawdev driver is an implementation of the rawdev API, > +that provides communication between two separate hosts. > +This is achieved via using the GDMA controller of Dinghai SoC, > +which can be configured through exposed MPF devices. This is awkward use of passive voice and could be simplified and shortened. > + > +Device Setup > +------------- > + > +It is recommended to bind the ZXDH MPF kernel driver for MPF devices (Not > mandatory). > +The kernel drivers can be downloaded at `ZTE Official Website > +<https://enterprise.zte.com.cn/>`_. What is works (and what doesn't) without the kernel driver. Has this driver been submitted to upstream kernel.org? DPDK does not want to be requiring or using 3rd party kernel drivers with non GPLv2 licenses. > + > +Initialization > +-------------- > + > +The ``zxdh`` rawdev driver needs to work in IOVA PA mode. > +Consider using ``--iova-mode=pa`` in the EAL options. > + > +Platform Requirement > +~~~~~~~~~~~~~~~~~~~~ > + > +This PMD is only supported on ZTE Neo Platforms: > +- Neo X510/X512 > + Adding blank line at end of file causes git to complain when merging > diff --git a/drivers/raw/meson.build b/drivers/raw/meson.build > index 05cad143fe..237d1bdd80 100644 > --- a/drivers/raw/meson.build > +++ b/drivers/raw/meson.build > @@ -12,5 +12,6 @@ drivers = [ > 'ifpga', > 'ntb', > 'skeleton', > + 'zxdh', > ] > std_deps = ['rawdev'] > diff --git a/drivers/raw/zxdh/meson.build b/drivers/raw/zxdh/meson.build > new file mode 100644 > index 0000000000..266d3db6d8 > --- /dev/null > +++ b/drivers/raw/zxdh/meson.build > @@ -0,0 +1,5 @@ > +#SPDX-License-Identifier: BSD-3-Clause > +#Copyright 2024 ZTE Corporation > + > +deps += ['rawdev', 'kvargs', 'mbuf', 'bus_pci'] > +sources = files('zxdh_rawdev.c') > diff --git a/drivers/raw/zxdh/zxdh_rawdev.c b/drivers/raw/zxdh/zxdh_rawdev.c > new file mode 100644 > index 0000000000..269c4f92e0 > --- /dev/null > +++ b/drivers/raw/zxdh/zxdh_rawdev.c > @@ -0,0 +1,220 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright 2024 ZTE Corporation > + */ > + > +#include <assert.h> > +#include <stdio.h> > +#include <stdbool.h> > +#include <errno.h> > +#include <stdint.h> > +#include <inttypes.h> > +#include <string.h> > +#include <sys/types.h> > +#include <unistd.h> > +#include <fcntl.h> > + > +#include <rte_byteorder.h> > +#include <rte_errno.h> > +#include <rte_common.h> > +#include <rte_debug.h> > +#include <rte_dev.h> > +#include <rte_eal.h> > +#include <rte_kvargs.h> > +#include <rte_log.h> > +#include <rte_malloc.h> > +#include <rte_memory.h> > +#include <rte_memcpy.h> > +#include <rte_lcore.h> > +#include <rte_cycles.h> > +#include <rte_memzone.h> > +#include <rte_atomic.h> > +#include <rte_rawdev.h> > +#include <rte_rawdev_pmd.h> > +#include <rte_pci.h> > +#include <bus_pci_driver.h> > +#include <rte_eal_paging.h> This is a large set of include and looks like it was a copy paste from elsewhere. For example: you are including rte_kvargs.h but never use kvargs in the driver. If I run iwyu on the driver it produces. $ iwyu -I lib/eal/include -I drivers/bus/pci drivers/raw/zxdh/zxdh_rawdev.c drivers/raw/zxdh/zxdh_rawdev.h should add these lines: #include <generic/rte_spinlock.h> // for rte_spinlock_t #include <rte_log.h> // for RTE_LOG_COMMA, RTE_LOG_LINE_PREFIX #include <stdint.h> // for uint32_t, uint16_t, uint8_t, uint64_t #include "rte_common.h" // for rte_iova_t drivers/raw/zxdh/zxdh_rawdev.h should remove these lines: - #include <rte_spinlock.h> // lines 13-13 The full include-list for drivers/raw/zxdh/zxdh_rawdev.h: #include <generic/rte_spinlock.h> // for rte_spinlock_t #include <rte_log.h> // for RTE_LOG_COMMA, RTE_LOG_LINE_PREFIX #include <rte_rawdev.h> // for rte_rawdev #include <stdint.h> // for uint32_t, uint16_t, uint8_t, uint64_t #include "rte_common.h" // for rte_iova_t --- drivers/raw/zxdh/zxdh_rawdev.c should add these lines: #include <limits.h> // for PATH_MAX #include <rte_spinlock.h> // for rte_spinlock_lock, rte_spinlock_u... #include "rte_branch_prediction.h" // for unlikely drivers/raw/zxdh/zxdh_rawdev.c should remove these lines: - #include <assert.h> // lines 5-5 - #include <rte_byteorder.h> // lines 16-16 - #include <rte_cycles.h> // lines 28-28 - #include <rte_debug.h> // lines 19-19 - #include <rte_eal.h> // lines 21-21 - #include <rte_kvargs.h> // lines 22-22 - #include <rte_memcpy.h> // lines 26-26 - #include <rte_memory.h> // lines 25-25 - #include <stdbool.h> // lines 7-7 - #include <stdint.h> // lines 9-9 - #include <sys/types.h> // lines 12-12 The full include-list for drivers/raw/zxdh/zxdh_rawdev.c: #include "zxdh_rawdev.h" #include <bus_pci_driver.h> // for rte_pci_device, rte_pci_get_sysfs... #include <errno.h> // for EINVAL, ENOMEM, EEXIST, errno #include <fcntl.h> // for open, O_RDWR #include <inttypes.h> // for uint16_t, uint32_t, uint8_t, uint... #include <limits.h> // for PATH_MAX #include <rte_atomic.h> // for rte_wmb #include <rte_common.h> // for __rte_unused, RTE_PRIORITY_LAST #include <rte_dev.h> // for rte_mem_resource, RTE_PMD_REGISTE... #include <rte_eal_paging.h> // for rte_mem_map, rte_mem_prot, rte_me... #include <rte_errno.h> // for rte_strerror, per_lcore__rte_errno #include <rte_lcore.h> // for rte_socket_id #include <rte_log.h> // for RTE_LOG_ERR, RTE_LOG_DEBUG, RTE_L... #include <rte_malloc.h> // for rte_free, rte_zmalloc #include <rte_memzone.h> // for rte_memzone, rte_memzone::(anonym... #include <rte_pci.h> // for rte_pci_addr, PCI_PRI_FMT, rte_pc... #include <rte_rawdev.h> // for rte_rawdev_obj_t, rte_rawdev, RTE... #include <rte_rawdev_pmd.h> // for rte_rawdev_pmd_allocate, rte_rawd... #include <rte_spinlock.h> // for rte_spinlock_lock, rte_spinlock_u... #include <stdio.h> // for NULL, size_t, snprintf #include <string.h> // for memset, strerror #include <unistd.h> // for close #include "rte_branch_prediction.h" // for unlikely