dpdk.git
2 years agonet: fix L2TPv2 common header
Jie Wang [Wed, 9 Feb 2022 09:38:53 +0000 (17:38 +0800)]
net: fix L2TPv2 common header

The fields of L2TPv2 common header were reversed in big endian and
little endian.

This patch fixes this error to ensure L2TPv2 can be parsed correctly.

For L2TP reference:
https://datatracker.ietf.org/doc/html/rfc2661#section-3.1

Fixes: 3a929df1f286 ("ethdev: support L2TPv2 and PPP procotol")
Cc: stable@dpdk.org
Signed-off-by: Jie Wang <jie1x.wang@intel.com>
Acked-by: Ori Kam <orika@nvidia.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
2 years agoethdev: add L2TPv2 RSS offload type
Jie Wang [Wed, 9 Feb 2022 09:38:52 +0000 (17:38 +0800)]
ethdev: add L2TPv2 RSS offload type

This patch defines new RSS offload type for L2TPv2, which
is required when users want to distribute packets based on
the L2TPv2 session ID field.

Signed-off-by: Jie Wang <jie1x.wang@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
2 years agonet/memif: remove pointer deference before null check
Weiguo Li [Wed, 9 Feb 2022 07:39:34 +0000 (15:39 +0800)]
net/memif: remove pointer deference before null check

There are duplicates of assignment here, the one before null check
may cause a null pointer deference, so remove the previous one.

Fixes: 09c7e63a71f9 ("net/memif: introduce memory interface PMD")
Cc: stable@dpdk.org
Signed-off-by: Weiguo Li <liwg06@foxmail.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
2 years agoconfig: align mempool elements to 128 bytes on CN10K
Pavan Nikhilesh [Mon, 13 Dec 2021 11:06:14 +0000 (16:36 +0530)]
config: align mempool elements to 128 bytes on CN10K

Mempool elements are by default aligned to CACHELINE_SIZE.
In CN10K cacheline size is 64B but the RoC requires buffers to be
aligned to 128B.
Set RTE_MEMPOOL_ALIGN to 128 to force mempool buffers to be aligned
128 bytes.

Fixes: 1b4c86a721c9 ("config/arm: add Marvell CN10K")
Cc: stable@dpdk.org
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
2 years agoeal: ignore gcc-compat warning in clang-only macro
Michael Barker [Mon, 31 Jan 2022 00:05:16 +0000 (13:05 +1300)]
eal: ignore gcc-compat warning in clang-only macro

When compiling with clang using -Wpedantic (or -Wgcc-compat) the use of
diagnose_if kicks up a warning:

.../include/rte_interrupts.h:623:1: error: 'diagnose_if' is a clang
extension [-Werror,-Wgcc-compat]
__rte_internal
^
.../include/rte_compat.h:36:16: note: expanded from macro '__rte_internal'
__attribute__((diagnose_if(1, "Symbol is not public ABI", "error"), \

This change ignores the '-Wgcc-compat' warning in the specific location
where the warning occurs.  It is safe to do in this circumstance as the
specific macro is only defined when using the clang compiler.

Signed-off-by: Michael Barker <mikeb01@gmail.com>
2 years agobuildtools/chkincs: test headers for C++ compatibility
Bruce Richardson [Fri, 11 Feb 2022 11:36:41 +0000 (11:36 +0000)]
buildtools/chkincs: test headers for C++ compatibility

Add support for checking each of our headers for issues when included in
a C++ file.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2 years agobuildtools/chkincs: remove unnecessary linkage
Bruce Richardson [Fri, 11 Feb 2022 11:36:40 +0000 (11:36 +0000)]
buildtools/chkincs: remove unnecessary linkage

The chkincs binary does not actually call any functions in either libs
or drivers, so we can simplify the linkage of it to just using shared
linkage of the libraries (via meson dependencies). This means a slightly
faster link time as well as making the chkincs binary much, much
smaller.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2 years agoremove unnecessary null checks
Stephen Hemminger [Wed, 9 Feb 2022 19:17:15 +0000 (11:17 -0800)]
remove unnecessary null checks

Functions like free, rte_free, and rte_mempool_free
already handle NULL pointer so the checks here are not necessary.

Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2 years agodevtools: add script to fix unnecessary null checks
Stephen Hemminger [Wed, 9 Feb 2022 19:17:14 +0000 (11:17 -0800)]
devtools: add script to fix unnecessary null checks

This script is based on the idea of the nullfree script
in the Linux kernel. It finds cases where a check for null
pointer is done, but is unnecessary because the function
already handles NULL pointer.

Basic example:
       if (x->buf)
           rte_free(x->buf);
can be reduced to:
       rte_free(x->buf);

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2 years agolib: update documentation of some *_free functions
Stephen Hemminger [Wed, 9 Feb 2022 19:17:13 +0000 (11:17 -0800)]
lib: update documentation of some *_free functions

These functions all behave like libc free() and do
nothing if handed a NULL pointer. The code is already doing
this, this patch just documents the behavior.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2 years agomem: cleanup multiprocess resources
Stephen Hemminger [Sat, 13 Nov 2021 17:22:57 +0000 (09:22 -0800)]
mem: cleanup multiprocess resources

The mp action resources in malloc should be cleaned up via
rte_eal_cleanup.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
2 years agoeal: cleanup multiprocess hotplug resources
Stephen Hemminger [Sat, 13 Nov 2021 17:22:56 +0000 (09:22 -0800)]
eal: cleanup multiprocess hotplug resources

When rte_eal_cleanup is called, hotplug should unregister the
resources associated with the multi-process server.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2 years agovfio: cleanup the multiprocess sync handle
Stephen Hemminger [Sat, 13 Nov 2021 17:22:55 +0000 (09:22 -0800)]
vfio: cleanup the multiprocess sync handle

When rte_eal_cleanup is called the rte_mp_action for VFIO
should be freed.

Fixes: edf73dd33072 ("ipc: handle unsupported IPC in action register")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
2 years agoipc: end multiprocess thread during cleanup
Stephen Hemminger [Sat, 13 Nov 2021 17:22:54 +0000 (09:22 -0800)]
ipc: end multiprocess thread during cleanup

When rte_eal_cleanup is called, all control threads should exit.
For the mp thread, this best handled by closing the mp_socket
and letting the thread see that.

This also fixes potential problems where the mp_socket gets
another hard error, and the thread runs away repeating itself
by reading the same error.

Fixes: 85d6815fa6d0 ("eal: close multi-process socket during cleanup")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
2 years agolog: close in cleanup stage
Stephen Hemminger [Sat, 13 Nov 2021 17:22:53 +0000 (09:22 -0800)]
log: close in cleanup stage

When application calls rte_eal_cleanup on shutdown,
the DPDK log should be closed and cleaned up.

This helps reduce false reports from tools like ASAN
and valgrind that track memory leaks.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2 years agotest/mbuf: fix mbuf data content check
David Marchand [Thu, 3 Feb 2022 09:39:12 +0000 (10:39 +0100)]
test/mbuf: fix mbuf data content check

When allocating a mbuf, its data content is most of the time zero'd but
nothing ensures this. This is especially wrong when building with
RTE_MALLOC_DEBUG, where data is poisoned to 0x6b on free.

This test reserves MBUF_TEST_DATA_LEN2 bytes in the mbuf data segment,
and sets this data to 0xcc.
Calling strlen(), the test may try to read more than MBUF_TEST_DATA_LEN2
which has been noticed when memory had been poisoned.

The mbuf data content is checked right after, so we can simply remove
strlen().

Fixes: 7b295dceea07 ("test/mbuf: add unit test cases")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
2 years agoapp/fib: fix division by zero
Vladimir Medvedkin [Thu, 27 Jan 2022 18:08:53 +0000 (18:08 +0000)]
app/fib: fix division by zero

This patch fixes the division by 0, which occurs if the number of
routes is less than 10.
Can be triggered by passing -n argument with value < 10:

./dpdk-test-fib -- -n 9
...
Floating point exception (core dumped)

Fixes: 103809d032cd ("app/test-fib: add test application for FIB")
Cc: stable@dpdk.org
Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
2 years agomem: check allocation in dynamic hugepage init
Yunjian Wang [Tue, 14 Dec 2021 13:30:25 +0000 (21:30 +0800)]
mem: check allocation in dynamic hugepage init

The function malloc() could return NULL, the return value
need to be checked.

Fixes: 6f63858e55e6 ("mem: prevent preallocated pages from being freed")
Cc: stable@dpdk.org
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
2 years agoeal/arm: inline 128-bit atomic compare exchange with GCC
Pavan Nikhilesh [Fri, 5 Nov 2021 08:57:12 +0000 (14:27 +0530)]
eal/arm: inline 128-bit atomic compare exchange with GCC

GCC [1] now assigns even register pairs for CASP, the fix has also been
backported to all stable releases of older GCC versions.
Removing the manual register allocation allows GCC to inline the
functions and pick optimal registers for performing CASP.

1: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=563cc649beaf

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
2 years agovhost: fix C++ include
Bruce Richardson [Thu, 10 Feb 2022 15:42:38 +0000 (15:42 +0000)]
vhost: fix C++ include

The virtio kernel header includes are already noted as being
incompatible with C++. We can ensure that the header is safe for
inclusion in C++ code by not including those headers during C++ builds.
While not ideal, this does ensure that all DPDK headers can be included
in C++ code without errors.

Fixes: f8904d563691 ("vhost: fix header for strict compilation flags")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2 years agotable: fix C++ include
Bruce Richardson [Thu, 10 Feb 2022 15:42:37 +0000 (15:42 +0000)]
table: fix C++ include

Since C++ doesn't support automatic casting from void * to other types,
we need to explicitly add the casts to any header files in DPDK.

Fixes: ea7be0a0386e ("lib/librte_table: add hash function headers")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2 years agoipsec: fix C++ include
Bruce Richardson [Thu, 10 Feb 2022 15:42:36 +0000 (15:42 +0000)]
ipsec: fix C++ include

C++ does not have automatic casting to/from void pointers, so need
explicit cast if header is to be included in C++ code

Fixes: f901d9c82688 ("ipsec: add helpers to group completed crypto-ops")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
2 years agograph: fix C++ include
Bruce Richardson [Thu, 10 Feb 2022 15:42:35 +0000 (15:42 +0000)]
graph: fix C++ include

C++ does not have automatic casting to/from void pointers, so need
explicit cast if header is to be included in C++ code

Fixes: 40d4f51403ec ("graph: implement fastpath routines")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
2 years agoeventdev: fix C++ include
Bruce Richardson [Thu, 10 Feb 2022 15:42:34 +0000 (15:42 +0000)]
eventdev: fix C++ include

The eventdev headers had issues when used from C++

* Missing closing "}" for the extern "C" block
* No automatic casting to/from void *

Fixes: a6562f6d6f8e ("eventdev: introduce event timer adapter")
Fixes: 32e326869ed6 ("eventdev: add tracepoints")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
2 years agoeal: fix C++ include
Bruce Richardson [Thu, 10 Feb 2022 15:42:33 +0000 (15:42 +0000)]
eal: fix C++ include

C++ files could not include some headers because:

* "new" is a keyword in C++, so can't be a variable name
* there is no automatic casting to/from void *

Fixes: 184104fc6121 ("ticketlock: introduce fair ticket based locking")
Fixes: 032a7e5499a0 ("trace: implement provider payload")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2 years agoconfig/arm: add values for native armv7
Juraj Linkeš [Tue, 25 Jan 2022 10:08:28 +0000 (11:08 +0100)]
config/arm: add values for native armv7

Armv7 native build fails with this error:
../config/meson.build:364:1: ERROR: Problem encountered:
Number of CPU cores not specified.

This is because RTE_MAX_LCORE is not set. We also need to set
RTE_MAX_NUMA_NODES in armv7 native builds.

Fixes: 8ef09fdc506b ("build: add optional NUMA and CPU counts detection")
Cc: stable@dpdk.org
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
2 years agostack: fix stubs header export
David Marchand [Thu, 10 Feb 2022 08:55:43 +0000 (09:55 +0100)]
stack: fix stubs header export

The stubs header is included as part of rte_stack.h for architectures
other than x86_64 and aarch64 (i.e. x86 32 bits and ppc).

Note: chkincs won't catch this issue since it checks headers from within
the source directory.

Fixes: 7911ba0473e0 ("stack: enable lock-free implementation for aarch64")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
2 years agoregex/mlx5: fix memory allocation check
Weiguo Li [Tue, 25 Jan 2022 11:51:41 +0000 (19:51 +0800)]
regex/mlx5: fix memory allocation check

The wrong field was checked after allocation.

Fixes: e3dbbf718ebc ("regex/mlx5: support configuration")
Cc: stable@dpdk.org
Signed-off-by: Weiguo Li <liwg06@foxmail.com>
2 years agogpu/cuda: differentiate V100 32GB GPU IDs
Elena Agostini [Thu, 10 Feb 2022 01:58:51 +0000 (01:58 +0000)]
gpu/cuda: differentiate V100 32GB GPU IDs

Differentiate between GPU V100 32GB SMX2 device id
and V100 32GB PCIe device id.

Signed-off-by: Elena Agostini <eagostini@nvidia.com>
2 years agogpudev: expose GPU memory to CPU
Elena Agostini [Thu, 27 Jan 2022 03:50:28 +0000 (03:50 +0000)]
gpudev: expose GPU memory to CPU

Enable the possibility to expose a GPU memory area and make it
accessible from the CPU.

GPU memory has to be allocated via rte_gpu_mem_alloc().

This patch allows the gpudev library to map (and unmap),
through the GPU driver, a chunk of GPU memory and to return
a memory pointer usable by the CPU to access the GPU memory area.

Signed-off-by: Elena Agostini <eagostini@nvidia.com>
2 years agovhost: remove payload size limitation
Christophe Fontaine [Mon, 7 Feb 2022 10:21:29 +0000 (11:21 +0100)]
vhost: remove payload size limitation

FDs at the end of the VhostUserMessage structure limits the size
of the payload. Move them to an other englobing structure, before
the header & payload of a VhostUserMessage.
Also removes a reference to fds in the VHUMsg structure defined in
drivers/net/virtio/virtio_user/vhost_user.c

Signed-off-by: Christophe Fontaine <cfontain@redhat.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
2 years agonet/virtio: fix slots number when indirect feature on
Marvin Liu [Thu, 20 Jan 2022 12:22:18 +0000 (20:22 +0800)]
net/virtio: fix slots number when indirect feature on

Virtio driver only occupies one slot for enqueuing chained mbufs when
indirect feature is on. Required slots calculation should depend on
indirect feature status at the end.

Fixes: 0eaf7fc2fe8e ("net/virtio: separate AVX Rx/Tx")
Cc: stable@dpdk.org
Signed-off-by: Marvin Liu <yong.liu@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
2 years agovhost: fix guest to host physical address mapping
Yuan Wang [Mon, 17 Jan 2022 16:20:27 +0000 (16:20 +0000)]
vhost: fix guest to host physical address mapping

Async copy fails when looking up hpa in the gpa to hpa mapping table.
This happens because the gpa is matched exactly in the merged
mapping table, and the merge loses the mapping entries.
A new range comparison method is introduced to solve this issue.

Fixes: 6563cf92380a ("vhost: fix async copy on multi-page buffers")
Cc: stable@dpdk.org
Signed-off-by: Yuan Wang <yuanx.wang@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
2 years agodoc: update recommended IOVA mode for async vhost
Xuan Ding [Mon, 22 Nov 2021 08:49:48 +0000 (08:49 +0000)]
doc: update recommended IOVA mode for async vhost

DPDK 21.11 adds vfio support for DMA device in vhost. This patch
updates recommended IOVA mode in async datapath.

Signed-off-by: Xuan Ding <xuan.ding@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
2 years agoapp/testpmd: add queue based priority flow control command
Sunil Kumar Kori [Tue, 8 Feb 2022 08:50:49 +0000 (14:20 +0530)]
app/testpmd: add queue based priority flow control command

Patch adds command line options to configure queue based
priority flow control.

- Syntax command is given as below:

set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> \
tx <on|off> <rx_qid> <rx_tc> <pause_time>

- Example command to configure queue based priority flow control
  on rx and tx side for port 0, Rx queue 0, Tx queue 0 with pause
  time 2047

testpmd> set pfc_queue_ctrl 0 rx on 0 0 tx on 0 0 2047

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
2 years agoethdev: support queue-based priority flow control
Jerin Jacob [Tue, 8 Feb 2022 08:50:48 +0000 (14:20 +0530)]
ethdev: support queue-based priority flow control

Based on device support and use-case need, there are two different ways
to enable PFC. The first case is the port level PFC configuration, in
this case, rte_eth_dev_priority_flow_ctrl_set() API shall be used to
configure the PFC, and PFC frames will be generated using based on VLAN
TC value.

The second case is the queue level PFC configuration, in this
case, Any packet field content can be used to steer the packet to the
specific queue using rte_flow or RSS and then use
rte_eth_dev_priority_flow_ctrl_queue_configure() to configure the
TC mapping on each queue.
Based on congestion selected on the specific queue, configured TC
shall be used to generate PFC frames.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
2 years agonet/sfc: fix lock releases
Ivan Malov [Mon, 7 Feb 2022 11:15:59 +0000 (14:15 +0300)]
net/sfc: fix lock releases

Fixes: 155583abe63c ("net/sfc: implement representor queue setup and release")
Fixes: 75f080fdf74a ("net/sfc: implement port representor start and stop")
Cc: stable@dpdk.org
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
2 years agodrivers/net: use internal function to get ethdev struct
Kumara Parameshwaran [Thu, 3 Feb 2022 08:24:12 +0000 (13:54 +0530)]
drivers/net: use internal function to get ethdev struct

Make changes in PMDs to use the new function where
rte_eth_dev_get_port_by_name is used to get port_id
to access rte_eth_devices

Signed-off-by: Kumara Parameshwaran <kparameshwar@vmware.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
2 years agoapp/testpmd: add SW L4 checksum in multi-segments
Xiaoyun Li [Mon, 24 Jan 2022 12:28:57 +0000 (20:28 +0800)]
app/testpmd: add SW L4 checksum in multi-segments

Csum forwarding mode only supports software UDP/TCP csum calculation
for single segment packets when hardware offload is not enabled.
This patch enables software UDP/TCP csum calculation over multiple
segments.

Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Tested-by: Sunil Pai G <sunil.pai.g@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
2 years agonet: add UDP/TCP checksum in mbuf segments
Xiaoyun Li [Mon, 24 Jan 2022 12:28:56 +0000 (20:28 +0800)]
net: add UDP/TCP checksum in mbuf segments

Add functions to call rte_raw_cksum_mbuf() to calculate IPv4/6
UDP/TCP checksum in mbuf which can be over multi-segments.

Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Acked-by: Aman Singh <aman.deep.singh@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Tested-by: Sunil Pai G <sunil.pai.g@intel.com>
2 years agonet/mlx5: add C++ include guard to public header
Elena Agostini [Thu, 16 Dec 2021 23:38:40 +0000 (23:38 +0000)]
net/mlx5: add C++ include guard to public header

The support for linking rte_pmd_mlx5.h functions with
C++ applications was missing.

Signed-off-by: Elena Agostini <eagostini@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
2 years agoapp/testpmd: update raw flow to take hex input
Nipun Gupta [Tue, 11 Jan 2022 05:05:38 +0000 (10:35 +0530)]
app/testpmd: update raw flow to take hex input

This patch enables method to provide key and mask for raw rules
to be provided as hexadecimal values. There is new parameter
pattern_mask added to support this.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
2 years agoapp/testpmd: fix stack overflow for EEPROM display
Steve Yang [Thu, 20 Jan 2022 02:59:31 +0000 (02:59 +0000)]
app/testpmd: fix stack overflow for EEPROM display

When the size of EEPROM exceeds the default thread stack size(8MB),
e.g.: 10MB size, it will crash due to stack overflow.

Allocate the data of EPPROM information on the heap.

Fixes: 6b67721dee2a ("app/testpmd: add EEPROM command")
Cc: stable@dpdk.org
Signed-off-by: Steve Yang <stevex.yang@intel.com>
Acked-by: Aman Singh <aman.deep.singh@intel.com>
Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>
2 years agonet/axgbe: disable CDR workaround for Yellow Carp device
Selwin Sebastian [Mon, 31 Jan 2022 05:39:20 +0000 (11:09 +0530)]
net/axgbe: disable CDR workaround for Yellow Carp device

Yellow Carp ethernet devices (V3xxx) do not require
autonegotiation CDR workaround, hence disable the same.

Signed-off-by: Selwin Sebastian <selwin.sebastian@amd.com>
Acked-by: Chandubabu Namburu <chandu@amd.com>
2 years agonet/axgbe: support Yellow Carp device
Selwin Sebastian [Mon, 31 Jan 2022 05:39:19 +0000 (11:09 +0530)]
net/axgbe: support Yellow Carp device

Yellow Carp ethernet devices (V3xxx) use the existing PCI ID but
the window settings for the indirect PCS access have been
altered. Add the check for Yellow Carp Ethernet devices to
use the new register values.

Signed-off-by: Selwin Sebastian <selwin.sebastian@amd.com>
Acked-by: Chandubabu Namburu <chandu@amd.com>
2 years agonet/sfc: use even spread mode in flow action RSS
Ivan Malov [Tue, 1 Feb 2022 08:50:02 +0000 (11:50 +0300)]
net/sfc: use even spread mode in flow action RSS

If the user provides contiguous ascending queue IDs,
use the even spread mode to avoid wasting resources
which are needed to serve indirection table entries.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
2 years agocommon/sfc_efx/base: support even spread RSS mode
Ivan Malov [Tue, 1 Feb 2022 08:50:01 +0000 (11:50 +0300)]
common/sfc_efx/base: support even spread RSS mode

Riverhead boards support spreading traffic across the
specified number of queues without using indirections.
This mode is provided by a dedicated RSS context type.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
2 years agonet/sfc: use adaptive table entry count in flow action RSS
Ivan Malov [Tue, 1 Feb 2022 08:50:00 +0000 (11:50 +0300)]
net/sfc: use adaptive table entry count in flow action RSS

Currently, every RSS context uses 128 indirection entries in
the hardware. That is not always optimal because the entries
come from a pool shared among all PCI functions of the board,
while the format of action RSS allows to pass less queue IDs.

With EF100 boards, it is possible to decide how many entries
to allocate for the indirection table of a context. Make use
of that in order to optimise resource usage in RSS scenarios.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
2 years agocommon/sfc_efx/base: support selecting RSS table entry count
Ivan Malov [Tue, 1 Feb 2022 08:49:59 +0000 (11:49 +0300)]
common/sfc_efx/base: support selecting RSS table entry count

On Riverhead boards, the client can control how many entries
to have in the indirection table of an exclusive RSS context.

Provide the new parameter to clients and indicate its bounds.
Extend the API for writing the table to have the flexibility.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
2 years agocommon/sfc_efx/base: refactor RSS table entry count name
Ivan Malov [Tue, 1 Feb 2022 08:49:58 +0000 (11:49 +0300)]
common/sfc_efx/base: refactor RSS table entry count name

In the existing code, "n" is hardly a clear name for that.
Use a clearer name to help future maintainers of the code.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
2 years agonet/sfc: use non-static queue span limit in flow action RSS
Ivan Malov [Tue, 1 Feb 2022 08:49:57 +0000 (11:49 +0300)]
net/sfc: use non-static queue span limit in flow action RSS

On EF10 boards, the limit on how many queues an RSS context
can address is 64. On EF100 boards, this parameter may vary.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
2 years agocommon/sfc_efx/base: query RSS queue span limit on Riverhead
Ivan Malov [Tue, 1 Feb 2022 08:49:56 +0000 (11:49 +0300)]
common/sfc_efx/base: query RSS queue span limit on Riverhead

On Riverhead boards, clients can query the limit on how many
queues an RSS context may address. Put the capability to use.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
2 years agonet/sfc: rework flow action RSS support
Ivan Malov [Tue, 1 Feb 2022 08:49:55 +0000 (11:49 +0300)]
net/sfc: rework flow action RSS support

Currently, the driver always allocates a dedicated NIC RSS context
for every separate flow rule with action RSS, which is not optimal.

First of all, multiple rules which have the same RSS specification
can share a context since filters in the hardware operate this way.

Secondly, entries in a context's indirection table are not precise
queue IDs but offsets with regard to the base queue ID of a filter.
This way, for example, queue arrays "0, 1, 2" and "3, 4, 5" in two
otherwise identical RSS specifications allow the driver to use the
same context since they both yield the same table of queue offsets.

Rework flow action RSS support in order to use these optimisations.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
2 years agonet/tap: fix to populate FDs in secondary process
Kumara Parameshwaran [Mon, 31 Jan 2022 14:32:34 +0000 (20:02 +0530)]
net/tap: fix to populate FDs in secondary process

When a tap device is hotplugged to primary process which in turn
adds the device to all secondary process, the secondary process
does a tap_mp_attach_queues, but the fds are not populated in
the primary during the probe they are populated during the queue_setup,
added a fix to sync the queues during rte_eth_dev_start

Fixes: 4852aa8f6e21 ("drivers/net: enable hotplug on secondary process")
Cc: stable@dpdk.org
Signed-off-by: Kumara Parameshwaran <kparameshwar@vmware.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
2 years agoethdev: add internal function to device struct from name
Kumara Parameshwaran [Mon, 31 Jan 2022 14:32:33 +0000 (20:02 +0530)]
ethdev: add internal function to device struct from name

The PMDs would need a function to access the rte_eth_devices
without accessing the global rte_eth_device array.

Cc: stable@dpdk.org
Signed-off-by: Kumara Parameshwaran <kparameshwar@vmware.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
2 years agonet/af_xdp: use libxdp if available
Ciara Loftus [Fri, 28 Jan 2022 09:50:29 +0000 (09:50 +0000)]
net/af_xdp: use libxdp if available

AF_XDP support is deprecated in libbpf since v0.7.0 [1]. The libxdp library
now provides the functionality which once was in libbpf and which the
AF_XDP PMD relies on. This commit updates the AF_XDP meson build to use the
libxdp library if a version >= v1.2.2 is available. If it is not available,
only versions of libbpf prior to v0.7.0 are allowed, as they still contain
the required AF_XDP functionality.

libbpf still remains a dependency even if libxdp is present, as we use
libbpf APIs for program loading.

The minimum required kernel version for libxdp for use with AF_XDP is v5.3.
For the library to be fully-featured, a kernel v5.10 or newer is
recommended. The full compatibility information can be found in the libxdp
README.

v1.2.2 of libxdp includes an important fix required for linking with DPDK
which is why this version or greater is required. Meson uses pkg-config to
verify the version of libxdp on the system, so it is necessary that the
library is discoverable using pkg-config in order for the PMD to use it. To
verify this, you can run: pkg-config --modversion libxdp

[1] https://github.com/libbpf/libbpf/commit/277846bc6c15

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
2 years agoapp/testpmd: fix bonding mode set
Min Hu (Connor) [Fri, 28 Jan 2022 02:35:19 +0000 (10:35 +0800)]
app/testpmd: fix bonding mode set

when start testpmd, and type command like this, it will lead to
Segmentation fault, like:

testpmd> create bonded device 4 0
testpmd> add bonding slave 0 2
testpmd> add bonding slave 1 2
testpmd> port start 2
testpmd> set bonding mode 0 2
testpmd> quit
Stopping port 0...
Stopping ports...
...
Bye...
Segmentation fault

The reason to the bug is that rte timer do not be cancelled when quit.
That is, in 'bond_ethdev_start', resources are allocated according to
different bonding mode. In 'bond_ethdev_stop', resources are free by
the corresponding mode.

For example, 'bond_ethdev_start' start bond_mode_8023ad_ext_periodic_cb
timer for bonding mode 4. and 'bond_ethdev_stop' cancel the timer only
when the current bonding mode is 4. If the bonding mode is changed,
and directly quit the process, the timer will still on, and freed memory
will be accessed, then segmentation fault.

'bonding mode' changed means resources changed, reallocate resources for
different mode should be done, that is, device should be restarted.

Fixes: 2950a769315e ("bond: testpmd support")
Cc: stable@dpdk.org
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>
2 years agonet/bonding: fix reference count on mbufs
Min Hu (Connor) [Fri, 28 Jan 2022 02:25:33 +0000 (10:25 +0800)]
net/bonding: fix reference count on mbufs

In bonding Tx broadcast mode, Packets should be sent by every slave,
but only one mbuf exits. The solution is to increment reference count
on mbufs, but it ignores multi segments.

This patch fixed it by adding reference for every segment in multi
segments Tx scenario.

Fixes: 2efb58cbab6e ("bond: new link bonding library")
Cc: stable@dpdk.org
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2 years agonet/bonding: fix promiscuous and allmulticast state
Min Hu (Connor) [Fri, 28 Jan 2022 02:25:32 +0000 (10:25 +0800)]
net/bonding: fix promiscuous and allmulticast state

Currently, promiscuous or allmulticast state of bonding port will not be
passed to the new primary slave when active/standby switch-over. It
causes bugs in some scenario.

For example, promiscuous state of bonding port is off now, primary slave
(called A) is off but secondary slave(called B) is on.
Then active/standby switch-over, promiscuous state of the bonding port
is off, but the new primary slave turns to be B and its promiscuous
state is still on.
It is not consistent with bonding port. And this patch will fix it.

Fixes: 2efb58cbab6e ("bond: new link bonding library")
Fixes: 68218b87c184 ("net/bonding: prefer allmulti to promiscuous for LACP")
Cc: stable@dpdk.org
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2 years agonet/ixgbe: check filter init failure
Yunjian Wang [Fri, 24 Dec 2021 11:26:38 +0000 (19:26 +0800)]
net/ixgbe: check filter init failure

The function ixgbe_fdir_filter_init() and ixgbe_l2_tn_filter_init()
could return errors, the return value need to be checked and returned.

Fixes: 080e3c0ee989 ("net/ixgbe: store flow director filter")
Fixes: d0c0c416ef1f ("net/ixgbe: store L2 tunnel filter")
Cc: stable@dpdk.org
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Acked-by: Haiyue Wang <haiyue.wang@intel.com>
2 years agonet/hns3: delete duplicated RSS type
Chengwen Feng [Fri, 28 Jan 2022 02:07:08 +0000 (10:07 +0800)]
net/hns3: delete duplicated RSS type

The hns3_set_rss_types hold two IPV4_TCP items, this patch deletes
duplicate item.

Fixes: 806f1d5ab0e3 ("net/hns3: set RSS hash type input configuration")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2 years agonet/hns3: fix operating queue when TCAM table is invalid
Huisong Li [Fri, 28 Jan 2022 02:07:07 +0000 (10:07 +0800)]
net/hns3: fix operating queue when TCAM table is invalid

Reset queues will query the TCAM table. The table is cleared after global
or imp reset. Currently, PF driver first resets Rx/Tx queues and then
restore the table during the reset recovery process, which will fail to
query the table and trigger a RAS error.

Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2 years agonet/hns3: fix double decrement of secondary count
Huisong Li [Fri, 28 Jan 2022 02:07:06 +0000 (10:07 +0800)]
net/hns3: fix double decrement of secondary count

The "secondary_cnt" indicates the number of secondary processes on an
Ethernet device. But the variable is double subtracted when detach the
device in secondary processes.

Fixes: ff6dc76e40b8 ("net/hns3: refactor multi-process initialization")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2 years agonet/hns3: fix insecure way to query MAC statistics
Huisong Li [Fri, 28 Jan 2022 02:07:05 +0000 (10:07 +0800)]
net/hns3: fix insecure way to query MAC statistics

The query way of MAC statistics in HNS3 PF driver is as following:
1) get MAC statistics register number and calculate descriptor number.
2) use above descriptor number to send command to firmware to query all
   MAC statistics and copy to hns3_mac_stats struct in driver.

The preceding way does not verify the validity of the number of obtained
register, which may cause memory out-of-bounds.

Fixes: 8839c5e202f3 ("net/hns3: support device stats")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2 years agonet/hns3: fix RSS key with null
Lijun Ou [Fri, 28 Jan 2022 02:07:04 +0000 (10:07 +0800)]
net/hns3: fix RSS key with null

Since the patch '1848b117' has initialized the variable 'key' in
'struct rte_flow_action_rss' with 'NULL', the PMD will use the
default RSS key when create the first RSS rule with NULL RSS key.
Then, if create a repeated RSS rule with the above, it will not
identify duplicate rules and return an error message.

To solve the preceding problem, determine whether the current RSS keys
are the same based on whether the length of key_len of rss is 0.

Fixes: 1848b117cca1 ("app/testpmd: fix RSS key for flow API RSS rule")
Cc: stable@dpdk.org
Signed-off-by: Lijun Ou <oulijun@huawei.com>
2 years agonet/hns3: fix max packet size rollback in PF
Huisong Li [Fri, 28 Jan 2022 02:07:03 +0000 (10:07 +0800)]
net/hns3: fix max packet size rollback in PF

HNS3 PF driver use the hns->pf.mps to restore the MTU when a reset
occurs.
If user fails to configure the MTU, the MPS of PF may not be restored to
the original value.

Fixes: 25fb790f7868 ("net/hns3: fix HW buffer size on MTU update")
Fixes: 1f5ca0b460cd ("net/hns3: support some device operations")
Fixes: d51867db65c1 ("net/hns3: add initialization")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2 years agonet/enic: support max descriptors allowed by adapter
John Daley [Fri, 28 Jan 2022 17:58:13 +0000 (09:58 -0800)]
net/enic: support max descriptors allowed by adapter

Newer VIC adapters have the max number of supported RX and TX
descriptors in their configuration. Use these values as the
maximums.

Signed-off-by: John Daley <johndale@cisco.com>
Reviewed-by: Hyong Youb Kim <hyonkim@cisco.com>
2 years agonet/enic: update VIC firmware interface
John Daley [Fri, 28 Jan 2022 17:58:12 +0000 (09:58 -0800)]
net/enic: update VIC firmware interface

Update the configuration structure used between the adapter and
driver. The structure is compatible with all Cisco VIC adapters.

Signed-off-by: John Daley <johndale@cisco.com>
Reviewed-by: Hyong Youb Kim <hyonkim@cisco.com>
2 years agonet/enic: support eCPRI matching
John Daley [Fri, 28 Jan 2022 17:58:11 +0000 (09:58 -0800)]
net/enic: support eCPRI matching

eCPRI message can be over Ethernet layer (.1Q supported also) or over
UDP layer. Message header formats are the same in these two variants.

Only up though the first packet header in the PDU can be matched.
RSS on the eCPRI payload is not supported.

Signed-off-by: John Daley <johndale@cisco.com>
Reviewed-by: Hyong Youb Kim <hyonkim@cisco.com>
2 years agonet/bonding: fix MTU set for slaves
Ferruh Yigit [Wed, 26 Jan 2022 13:10:37 +0000 (13:10 +0000)]
net/bonding: fix MTU set for slaves

ethdev requires device to be configured before setting MTU.

In bonding PMD, while configuring slaves, bonding first sets MTU later
configures them, which causes failure if slaves are not configured in
advance.

Fixing by changing the order in slave configure as requested in ethdev
layer, configure first and set MTU later.

Bugzilla ID: 864
Fixes: b26bee10ee37 ("ethdev: forbid MTU set before device configure")
Cc: stable@dpdk.org
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Tested-by: Yu Jiang <yux.jiang@intel.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
2 years agonet/dpaa2: fix null pointer dereference
Weiguo Li [Tue, 25 Jan 2022 14:23:48 +0000 (22:23 +0800)]
net/dpaa2: fix null pointer dereference

Check for memory allocation failure is added to avoid null
pointer dereference.

Fixes: 4690a6114ff6 ("net/dpaa2: enable error queues optionally")
Cc: stable@dpdk.org
Signed-off-by: Weiguo Li <liwg06@foxmail.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
2 years agonet/enic: fix dereference before null check
Weiguo Li [Tue, 25 Jan 2022 12:00:49 +0000 (20:00 +0800)]
net/enic: fix dereference before null check

Move memcpy to 'ah->key' after 'ah' null check

Fixes: bb66d562aefc ("net/enic: share flow actions with same signature")
Cc: stable@dpdk.org
Signed-off-by: Weiguo Li <liwg06@foxmail.com>
Reviewed-by: John Daley <johndale@cisco.com>
2 years agoeal: move Unix filesystem functions into one file
Stephen Hemminger [Wed, 9 Feb 2022 06:54:03 +0000 (22:54 -0800)]
eal: move Unix filesystem functions into one file

Both Linux and FreeBSD have same code for creating runtime
directory and reading sysfs files. Put them in the new lib/eal/unix
subdirectory.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2 years agosupport systemd service convention for runtime directory
Stephen Hemminger [Wed, 9 Feb 2022 06:54:02 +0000 (22:54 -0800)]
support systemd service convention for runtime directory

Systemd.exec supports configuring the runtime directory of a service
via RuntimeDirectory=. This creates the directory with the necessary
permissions which actual service may not have if running in container.

The change to DPDK is to look for the environment RUNTIME_DIRECTORY
first and use that in preference to the fallback alternatives.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
2 years agoeal: remove size for setting runtime directory
Stephen Hemminger [Wed, 9 Feb 2022 06:54:01 +0000 (22:54 -0800)]
eal: remove size for setting runtime directory

The size argument to eal_set_runtime_dir is useless and was
being used incorrectly in strlcpy. It worked only because
all callers passed PATH_MAX which is same as sizeof the destination
runtime_dir.

Note: this is an internal API so no user exposed change.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2 years agoeal: add internal function to get base address
Srikanth Yalavarthi [Tue, 18 Jan 2022 13:33:40 +0000 (05:33 -0800)]
eal: add internal function to get base address

Added an internal helper to get OS-specific EAL mapping base address

This helper can be used by the drivers to program offload / accelerator
devices, where the base address can be used as a reference address by
the accelerator to access the host memory

An address can also be represented as an offset relative to the base
address using smaller data types

Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
2 years agoeal: extend --huge-unlink for hugepage file reuse
Dmitry Kozlyuk [Thu, 3 Feb 2022 18:13:36 +0000 (20:13 +0200)]
eal: extend --huge-unlink for hugepage file reuse

Expose Linux EAL ability to reuse existing hugepage files
via --huge-unlink=never switch.
Default behavior is unchanged, it can also be specified
using --huge-unlink=existing for consistency.
Old --huge-unlink switch is kept,
it is an alias for --huge-unlink=always.
Add a test case for the --huge-unlink=never mode.

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
2 years agoeal/linux: allow hugepage file reuse
Dmitry Kozlyuk [Thu, 3 Feb 2022 18:13:35 +0000 (20:13 +0200)]
eal/linux: allow hugepage file reuse

Linux EAL ensured that mapped hugepages are clean
by always mapping from newly created files:
existing hugepage backing files were always removed.
In this case, the kernel clears the page to prevent data leaks,
because the mapped memory may contain leftover data
from the previous process that was using this memory.
Clearing takes the bulk of the time spent in mmap(2),
increasing EAL initialization time.

Introduce a mode to keep existing files and reuse them
in order to speed up initial memory allocation in EAL.
Hugepages mapped from such files may contain data
left by the previous process that used this memory,
so RTE_MEMSEG_FLAG_DIRTY is set for their segments.
If multiple hugepages are mapped from the same file:
1. When fallocate(2) is used, all memory mapped from this file
   is considered dirty, because it is unknown
   which parts of the file are holes.
2. When ftruncate(3) is used, memory mapped from this file
   is considered dirty unless the file is extended
   to create a new mapping, which implies clean memory.

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
2 years agoeal: refactor --huge-unlink storage
Dmitry Kozlyuk [Thu, 3 Feb 2022 18:13:34 +0000 (20:13 +0200)]
eal: refactor --huge-unlink storage

In preparation to extend --huge-unlink option semantics
refactor how it is stored in the internal configuration.
It makes future changes more isolated.

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
2 years agomem: add dirty malloc element support
Dmitry Kozlyuk [Thu, 3 Feb 2022 18:13:33 +0000 (20:13 +0200)]
mem: add dirty malloc element support

EAL malloc layer assumed all free elements content
is filled with zeros ("clean"), as opposed to uninitialized ("dirty").
This assumption was ensured in two ways:
1. EAL memalloc layer always returned clean memory.
2. Freed memory was cleared before returning into the heap.

Clearing the memory can be as slow as around 14 GiB/s.
To save doing so, memalloc layer is allowed to return dirty memory.
Such segments being marked with RTE_MEMSEG_FLAG_DIRTY.
The allocator tracks elements that contain dirty memory
using the new flag in the element header.
When clean memory is requested via rte_zmalloc*()
and the suitable element is dirty, it is cleared on allocation.
When memory is deallocated, the freed element is joined
with adjacent free elements, and the dirty flag is updated:

a) If the joint element contains dirty parts, it is dirty:

    dirty + freed + dirty = dirty  =>  no need to clean
            freed + dirty = dirty      the freed memory

   Dirty parts may be large (e.g. initial allocation),
   so clearing them could create unpredictable slowdown.

b) If the only dirty part of the joint element
   is the freed memory, the joint element can be made clean:

    clean + freed + clean = clean  =>  freed memory
    clean + freed         = clean      must be cleared
            freed + clean = clean
            freed         = clean

   This logic naturally reproduces the old behavior
   and always applies in modes when EAL memalloc layer
   returns only clean segments.

As a result, memory is either cleared on free, as before,
or it will be cleared on allocation if need be, but never twice.

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
2 years agoapp/test: add allocator performance benchmark
Dmitry Kozlyuk [Thu, 3 Feb 2022 18:13:32 +0000 (20:13 +0200)]
app/test: add allocator performance benchmark

Memory allocator performance is crucial to applications that deal
with large amount of memory or allocate frequently. DPDK allocator
performance is affected by EAL options, API used and, at least,
allocation size. New autotest is intended to be run with different
EAL options. It measures performance with a range of sizes
for dirrerent APIs: rte_malloc, rte_zmalloc, and rte_memzone_reserve.

Work distribution between allocation and deallocation depends on EAL
options. The test prints both times and total time to ease comparison.

Memory can be filled with zeroes at different points of allocation path,
but it always takes considerable fraction of overall timing. This is why
the test measures filling speed and prints how long clearing takes
for each size as a reference (for rte_memzone_reserve estimations
are printed).

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Reviewed-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Acked-by: Aaron Conole <aconole@redhat.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
2 years agodoc: add hugepage mapping details
Dmitry Kozlyuk [Thu, 3 Feb 2022 18:13:31 +0000 (20:13 +0200)]
doc: add hugepage mapping details

Hugepage mapping is a layer of EAL malloc builds upon.
There were implicit references to its details,
like mentions of segment file descriptors,
but no explicit description of its modes and operation.
Add an overview of mechanics used on ech supported OS.
Convert memory management subsections from list items
to level 4 headers: they are big and important enough.

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
2 years agoeventdev: remove useless C++ include guard
Weiguo Li [Mon, 7 Feb 2022 12:37:01 +0000 (20:37 +0800)]
eventdev: remove useless C++ include guard

This private header contains an incomplete cplusplus guard,
just remove it.

Fixes: d35e61322de52 ("eventdev: move inline APIs into separate structure")

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
2 years agoeal/windows: remove useless C++ include guard
Weiguo Li [Mon, 7 Feb 2022 12:37:00 +0000 (20:37 +0800)]
eal/windows: remove useless C++ include guard

Remove the incomplete cplusplus guard in internal header.

Fixes: 6e1ed4cbbe99 ("eal/windows: add dirent implementation")

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Acked-by: Pallavi Kadam <pallavi.kadam@intel.com>
2 years agonet/dpaa2: remove useless C++ include guard
Weiguo Li [Mon, 7 Feb 2022 12:36:59 +0000 (20:36 +0800)]
net/dpaa2: remove useless C++ include guard

Remove the incomplete cplusplus guard in internal headers.

Fixes: 72ec7a678e70 ("net/dpaa2: add soft parser driver")

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
2 years agonet/cxgbe: remove useless C++ include guard
Weiguo Li [Mon, 7 Feb 2022 12:36:58 +0000 (20:36 +0800)]
net/cxgbe: remove useless C++ include guard

Remove the incomplete cplusplus guard in internal header.

Fixes: 3bd122eef2cc ("cxgbe/base: add hardware API for Chelsio T5 series adapters")

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
2 years agocommon/mlx5: remove useless C++ include guard
Weiguo Li [Mon, 7 Feb 2022 12:36:57 +0000 (20:36 +0800)]
common/mlx5: remove useless C++ include guard

Remove the incomplete cplusplus guard in internal headers.

Fixes: 7525ebd8ebb0 ("common/mlx5: add glue functions on Windows")

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
2 years agobus/dpaa: fix C++ include guard
Weiguo Li [Mon, 7 Feb 2022 12:36:56 +0000 (20:36 +0800)]
bus/dpaa: fix C++ include guard

Supplement the missing half of braces for the extern "C" block,
or remove the incomplete guard in internal header.

Fixes: 6d6b4f49a155 ("bus/dpaa: add FMAN hardware operations")
Fixes: 919eeaccb2ba ("bus/dpaa: introduce NXP DPAA bus driver skeleton")

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
2 years agotest: enable subset of tests on Windows
Jie Zhou [Wed, 26 Jan 2022 05:10:44 +0000 (21:10 -0800)]
test: enable subset of tests on Windows

Enable a subset of unit tests for Windows CI

- For driver tests, driver owners should enable corresponding tests when
  enabling driver for Windows.
- For dump tests, currently the tests hang on Windows which require
  further investigation.
- For telemetry tests, it has POSIX socket specific codes which require
  replacement for Windows. Will investigate and work on a separate patch.

Signed-off-by: Jie Zhou <jizh@linux.microsoft.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2 years agotest: replace shell script with Python
Jie Zhou [Wed, 26 Jan 2022 05:10:43 +0000 (21:10 -0800)]
test: replace shell script with Python

- Add python script to check if system supports hugepages
- Remove corresponding .sh script
- Replace calling of .sh with corresponding .py in meson.build

Signed-off-by: Jie Zhou <jizh@linux.microsoft.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
2 years agotest: skip unsupported tests on Windows
Jie Zhou [Wed, 26 Jan 2022 05:10:42 +0000 (21:10 -0800)]
test: skip unsupported tests on Windows

Skip tests which are not yet supported for Windows:
- The libraries that tests depend on are not enabled on Windows yet
- The tests can compile but with issue still under investigation
    * test_func_reentrancy:
      Windows EAL has no protection against repeated calls.
    * test_lcores:
      Execution enters an infinite loops, requires investigation.
    * test_rcu_qsbr_perf:
      Execution hangs on Windows, requires investigation.

Signed-off-by: Jie Zhou <jizh@linux.microsoft.com>
Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
2 years agotest: resolve name collision on Windows
Jie Zhou [Wed, 26 Jan 2022 05:10:41 +0000 (21:10 -0800)]
test: resolve name collision on Windows

Add prefix to resolve name collision on Windows.

Signed-off-by: Jie Zhou <jizh@linux.microsoft.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
2 years agotest/alarm: disable bad time cases on Windows
Jie Zhou [Wed, 26 Jan 2022 05:10:40 +0000 (21:10 -0800)]
test/alarm: disable bad time cases on Windows

Remove two alarm_autotest test cases which do bogus range check
on Windows.

Signed-off-by: Jie Zhou <jizh@linux.microsoft.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
2 years agoeal: differentiate strerror message on Windows
Jie Zhou [Wed, 26 Jan 2022 05:10:39 +0000 (21:10 -0800)]
eal: differentiate strerror message on Windows

On Windows, strerror returns just "Unknown error" for errnum greater
than MAX_ERRNO, while linux and freebsd returns "Unknown error <num>",
which is the current expectation for errno_autotest. Differentiate
the error string on Windows to remove a "duplicate error code" failure.

Signed-off-by: Jie Zhou <jizh@linux.microsoft.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
2 years agotest/log: skip regex on Windows
Jie Zhou [Wed, 26 Jan 2022 05:10:38 +0000 (21:10 -0800)]
test/log: skip regex on Windows

DPDK logs_autotest on Windows failed at "dynamic log types" tests.
The failures are on 2 test cases for rte_log_set_level_regexp API,
due to regular expression is not supported on Windows in DPDK yet
and regcomp/regexec are just stubs on Windows (in regex.h).

In app/test/test_logs.c, ifndef these two test cases, and for the
rte_log_set_level_pattern validation case following these two cases,
differentiate the expected log level passed into macro CHECK_LEVELS

Now logs_autotest completes for all dynamic log types and static log types.

Signed-off-by: Jie Zhou <jizh@linux.microsoft.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
2 years agotest/interrupts: skip on Windows
Jie Zhou [Wed, 26 Jan 2022 05:10:37 +0000 (21:10 -0800)]
test/interrupts: skip on Windows

Even though test_interrupts.c can compile on Windows, skip interrupt
tests for now since majority of eal_interrupt on Windows are stubs.
Will remove the skip after interrupt being fully enabled on Windows.

Signed-off-by: Jie Zhou <jizh@linux.microsoft.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
2 years agotest/mem: fix error check
Jie Zhou [Wed, 26 Jan 2022 05:10:36 +0000 (21:10 -0800)]
test/mem: fix error check

Fix incorrect errno variable used in memory autotest.
Use rte_errno instead.

Fixes: 086d426406bd ("test/mem: fix memory autotests on FreeBSD")
Cc: stable@dpdk.org
Signed-off-by: Jie Zhou <jizh@linux.microsoft.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
2 years agotest: remove POSIX-specific code
Jie Zhou [Wed, 26 Jan 2022 05:10:35 +0000 (21:10 -0800)]
test: remove POSIX-specific code

- Replace POSIX-specific code with DPDK equivalents or
  conditionally disable it on Windows
- Use NUL on Windows as /dev/null for Unix
- Exclude tests not supported on Windows yet
  * multi-process
  * PMD performance statistics display on signal

Signed-off-by: Jie Zhou <jizh@linux.microsoft.com>
Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
2 years agoeal/windows: fix error code for not supported API
Jie Zhou [Wed, 26 Jan 2022 05:10:34 +0000 (21:10 -0800)]
eal/windows: fix error code for not supported API

UT memory_autotest on Windows has 2 failed cases on EAL APIs
eal_memalloc_get_seg_fd and eal_memalloc_get_seg_fd_offset. These 2
APIs are not supported on Windows yet. Should return ENOTSUP such that
in test_memory.c these 2 ENOTSUP cases will not be marked as failures,
same as other ENOTSUP cases.

Fixes: 2a5d547a4a9b ("eal/windows: implement basic memory management")
Cc: stable@dpdk.org
Signed-off-by: Jie Zhou <jizh@linux.microsoft.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
2 years agoring: fix overflow in memory size calculation
Zhihong Wang [Tue, 14 Dec 2021 03:30:16 +0000 (11:30 +0800)]
ring: fix overflow in memory size calculation

Parameters count and esize are both unsigned int, and their product can
legaly exceed unsigned int and lead to runtime access violation.

Fixes: cc4b218790f6 ("ring: support configurable element size")
Cc: stable@dpdk.org
Signed-off-by: Zhihong Wang <wangzhihong.wzh@bytedance.com>
Reviewed-by: Liang Ma <liangma@liangbit.com>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>