Introduce support for RISC-V architecture
Subsystems (4)
cover Introduce support for RISC-V architecture
This patchset adds support for building and running DPDK on 64bit RISC-V architecture. The initial support targets rv64gc (rv64imafdc) ISA and was tested on SiFive Unmatched development board with the Freedom U740 SoC running Linux (freedom-u-sdk based kernel).
I have tested this codebase using DPDK unit and perf tests as well as test-pmd, l2fwd and l3fwd examples.
The NIC attached to the DUT was Intel X520-DA2 which uses ixgbe PMD. On the UIO side, since U740 does not have an IOMMU, I've used igb_uio, uio_pci_generic and vfio-pci noiommu drivers.
Commits 1-2 fix small issues which are encountered if a given platform
does not support any vector operations (which is the case with U740).
Commit 3 introduces EAL and build system support for RISC-V architecture
as well as documentation updates.
Commits 4-7 add missing defines and stubs to enable RISC-V operation in
non-EAL parts.
Commit 8 adds RISC-V specific cpuflags test.
Commit 9 works around a bug in the current GCC in test_ring compiled
with -O0 or -Og.
Commit 10 adds RISC-V testing to test-meson-builds.sh automatically
iterating over cross-compile config files (currently present for generic rv64gc and SiFive U740).
Commit 11 extends hash r/w perf test by displaying both HTM and non-HTM
measurements. This is an extraneous commit which is not directly needed for RISC-V support but was noticed when we have started gathering test results. If needed, I can submit it separately.
I appreciate Your comments and feedback.
Best Regards,
Stanislaw Kardach
NOTE: This work was sponsored by StarFive and SiFive which is signified by
"Sponsored-by:" sign-offs in each commit message. After discussing it with Thomas Monjalon it seemed a better choice than "Suggested-by" which does not fully convey the nature of involvement. However it makes Linux checkpatch unhappy so I'm not sure if I shouldn't change the sign-offs.
NOTE2: I have added maintainers for each commit based on MAINTAINERS file.
However some modules (l3fwd, net/tap and cpuflags unit tests) do not have any maintainers assigned, hence I've targeted [email protected] mailing list as if it was a commit adding new files.
Michal Mazurek (3):
lpm: add a scalar version of lookupx4 function
eal: add initial support for RISC-V architecture test/cpuflags: add test for RISC-V cpu flag
Stanislaw Kardach (8):
examples/l3fwd: fix scalar LPM compilation net/ixgbe: enable vector stubs for RISC-V net/memif: set memfd syscall ID on RISC-V net/tap: set BPF syscall ID for RISC-V examples/l3fwd: enable RISC-V operation test/ring: disable problematic tests for RISC-V
devtools: add RISC-V to test-meson-builds.sh test/hash: report non HTM numbers for single r/w
MAINTAINERS | 6 + app/test/test_cpuflags.c | 81 ++++++++++ app/test/test_hash_readwrite.c | 8 +- app/test/test_ring.c | 8 + app/test/test_xmmt_ops.h | 16 ++ config/meson.build | 2 + config/riscv/meson.build | 148 ++++++++++++++++++ config/riscv/riscv64_linux_gcc | 17 ++ config/riscv/riscv64_sifive_u740_linux_gcc | 19 +++ devtools/test-meson-builds.sh | 6 + doc/guides/contributing/design.rst | 2 +- .../linux_gsg/cross_build_dpdk_for_riscv.rst | 125 +++++++++++++++ doc/guides/linux_gsg/index.rst | 1 + doc/guides/nics/features.rst | 5 + doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/ixgbe.ini | 1 + doc/guides/rel_notes/release_22_07.rst | 29 ++++ drivers/net/i40e/meson.build | 6 + drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- drivers/net/memif/rte_eth_memif.h | 2 + drivers/net/tap/tap_bpf.h | 2 + examples/l3fwd/l3fwd_em.c | 8 + examples/l3fwd/l3fwd_fib.c | 2 + examples/l3fwd/l3fwd_lpm.c | 2 +- lib/eal/riscv/include/meson.build | 23 +++ lib/eal/riscv/include/rte_atomic.h | 52 ++++++ lib/eal/riscv/include/rte_byteorder.h | 44 ++++++ lib/eal/riscv/include/rte_cpuflags.h | 55 +++++++ lib/eal/riscv/include/rte_cycles.h | 103 ++++++++++++ lib/eal/riscv/include/rte_io.h | 21 +++ lib/eal/riscv/include/rte_mcslock.h | 18 +++ lib/eal/riscv/include/rte_memcpy.h | 63 ++++++++ lib/eal/riscv/include/rte_pause.h | 31 ++++ lib/eal/riscv/include/rte_pflock.h | 17 ++ lib/eal/riscv/include/rte_power_intrinsics.h | 22 +++ lib/eal/riscv/include/rte_prefetch.h | 50 ++++++ lib/eal/riscv/include/rte_rwlock.h | 44 ++++++ lib/eal/riscv/include/rte_spinlock.h | 67 ++++++++ lib/eal/riscv/include/rte_ticketlock.h | 21 +++ lib/eal/riscv/include/rte_vect.h | 55 +++++++ lib/eal/riscv/meson.build | 11 ++ lib/eal/riscv/rte_cpuflags.c | 122 +++++++++++++++ lib/eal/riscv/rte_cycles.c | 77 +++++++++ lib/eal/riscv/rte_hypervisor.c | 13 ++ lib/eal/riscv/rte_power_intrinsics.c | 56 +++++++ lib/lpm/meson.build | 1 + lib/lpm/rte_lpm.h | 4 +- lib/lpm/rte_lpm_scalar.h | 122 +++++++++++++++ meson.build | 2 + 49 files changed, 1588 insertions(+), 7 deletions(-) create mode 100644 config/riscv/meson.build create mode 100644 config/riscv/riscv64_linux_gcc create mode 100644 config/riscv/riscv64_sifive_u740_linux_gcc create mode 100644 doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst create mode 100644 lib/eal/riscv/include/meson.build create mode 100644 lib/eal/riscv/include/rte_atomic.h create mode 100644 lib/eal/riscv/include/rte_byteorder.h create mode 100644 lib/eal/riscv/include/rte_cpuflags.h create mode 100644 lib/eal/riscv/include/rte_cycles.h create mode 100644 lib/eal/riscv/include/rte_io.h create mode 100644 lib/eal/riscv/include/rte_mcslock.h create mode 100644 lib/eal/riscv/include/rte_memcpy.h create mode 100644 lib/eal/riscv/include/rte_pause.h create mode 100644 lib/eal/riscv/include/rte_pflock.h create mode 100644 lib/eal/riscv/include/rte_power_intrinsics.h create mode 100644 lib/eal/riscv/include/rte_prefetch.h create mode 100644 lib/eal/riscv/include/rte_rwlock.h create mode 100644 lib/eal/riscv/include/rte_spinlock.h create mode 100644 lib/eal/riscv/include/rte_ticketlock.h create mode 100644 lib/eal/riscv/include/rte_vect.h create mode 100644 lib/eal/riscv/meson.build create mode 100644 lib/eal/riscv/rte_cpuflags.c create mode 100644 lib/eal/riscv/rte_cycles.c create mode 100644 lib/eal/riscv/rte_hypervisor.c create mode 100644 lib/eal/riscv/rte_power_intrinsics.c create mode 100644 lib/lpm/rte_lpm_scalar.h
Signature · 1 line
2.30.2
PATCH 1/11 lpm: add a scalar version of lookupx4 function
From: Michal Mazurek <[email protected]>
Add an implementation of the rte_lpm_lookupx4() function for platforms without support for vector operations.
--- doc/guides/rel_notes/release_22_07.rst | 5 + lib/lpm/meson.build | 1 + lib/lpm/rte_lpm.h | 4 +- lib/lpm/rte_lpm_scalar.h | 122 +++++++++++++++++++++++++ 4 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 lib/lpm/rte_lpm_scalar.h
doc/guides/rel_notes/release_22_07.rst +5 -0
@@ -65,6 +65,11 @@ New Features * Added support for promiscuous mode on Windows. * Added support for MTU on Windows. +* **Added scalar version of the LPM library.** + + * Added scalar implementation of ``rte_lpm_lookupx4``. This is a fall-back + implementation for platforms that don't support vector operations. + Removed Items -------------
lib/lpm/meson.build +1 -0
@@ -14,6 +14,7 @@ headers = files('rte_lpm.h', 'rte_lpm6.h') indirect_headers += files( 'rte_lpm_altivec.h', 'rte_lpm_neon.h', + 'rte_lpm_scalar.h', 'rte_lpm_sse.h', 'rte_lpm_sve.h', )
lib/lpm/rte_lpm.h +3 -1
@@ -405,8 +405,10 @@ rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4],#endif #elif defined(RTE_ARCH_PPC_64 )#include "rte_lpm_altivec.h" -#else +#elif defined(RTE_ARCH_X86 )#include "rte_lpm_sse.h" +#else +#include "rte_lpm_scalar.h" #endif #ifdef __cplusplus
lib/lpm/rte_lpm_scalar.h new file +122 -0
122 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH 2/11 examples/l3fwd: fix scalar LPM compilation
In reply to Stanislaw KardachThe lpm_process_event_pkt() can either process a packet using an architecture specific (defined for X86/SSE, ARM/Neon and PPC64/Altivec) path or a scalar one. The choice is however done using an ifdef pre-processor macro. Because of that the scalar version was apparently not widely excersized/compiled.
Due to some copy/paste errors, the scalar logic in lpm_process_event_pkt() retained a "continue" statement where a BAD_PORT should be returned after refactoring of the LPM logic in the l3fwd example.
--- examples/l3fwd/l3fwd_lpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
examples/l3fwd/l3fwd_lpm.c +1 -1
@@ -248,7 +248,7 @@ lpm_process_event_pkt(const struct lcore_conf *lconf, struct rte_mbuf *mbuf)if (is_valid_ipv4_pkt (ipv4_hdr, mbuf->pkt_len) <0 ) { mbuf->port =BAD_PORT ; -continue ; +return mbuf->port; }/* Update time to live and header checksum */ --(ipv4_hdr->time_to_live);
Signature · 1 line
2.30.2
Re: [PATCH 02/11] examples/l3fwd: fix scalar LPM compilation
Quoted 10 lines · On Thu, 5 May 2022 19:29:54 +0200 Stanislaw Kardach <[email protected]> wrote:
The
lpm_process_event_pkt()can either process a packet using an architecture specific (defined for X86/SSE, ARM/Neon and PPC64/Altivec) path or a scalar one. The choice is however done using an ifdef pre-processor macro. Because of that the scalar version was apparently not widely excersized/compiled.
Due to some copy/paste errors, the scalar logic inlpm_process_event_pkt()retained a "continue" statement where aBAD_PORTshould be returned after refactoring of the LPM logic in the l3fwd example.
Quoted 6 lines
Fixes 99fc91d18082 ("examples/l3fwd: add event lpm main loop")Signed-off-by Stanislaw Kardach <[email protected]>Sponsored-by Frank Zhao <[email protected]>Sponsored-by Sam Grove <[email protected]>
Would be easier to get merged if bug fixes came as separate patch submission.
Also have not seen Sponsored-by before; what do you expect it to mean? Never used in DPDK or kernel git tree.
Re: [PATCH 02/11] examples/l3fwd: fix scalar LPM compilation
Quoted 16 lines · Stephen Hemminger
Quoted 13 lines · On Thu, 5 May 2022 19:29:54 +0200 Stanislaw Kardach <[email protected]> wrote:
The
lpm_process_event_pkt()can either process a packet using an architecture specific (defined for X86/SSE, ARM/Neon and PPC64/Altivec) path or a scalar one. The choice is however done using an ifdef pre-processor macro. Because of that the scalar version was apparently not widely excersized/compiled.
Due to some copy/paste errors, the scalar logic inlpm_process_event_pkt()retained a "continue" statement where aBAD_PORTshould be returned after refactoring of the LPM logic in the l3fwd example.Fixes 99fc91d18082 ("examples/l3fwd: add event lpm main loop")
Quoted 7 lines
Quoted 3 lines
Signed-off-by Stanislaw Kardach <[email protected]>Sponsored-by Frank Zhao <[email protected]>Sponsored-by Sam Grove <[email protected]>Would be easier to get merged if bug fixes came as separate patch submission.
Sure, I can post this separately. The reason for posting this along with RISC-V patches is that those depend on this one. So I could add "depends-on" but wanted be on the safe side.
Quoted 4 lines
Also have not seen Sponsored-by before; what do you expect it to mean? Never used in DPDK or kernel git tree.
The idea is that this work was sponsored by the companies mentioned in the sign-off. It is used i.e. in FreeBSD though admittedly never in Linux or DPDK.
Alternative, which makes checkpatch happy and was previously used is "Suggested-by". However suggestion, doesn't necessary mean sponsorship. I had a talk about this with Thomas Monjalon and he has also leaned towards "Sponsored-by".
I'm open to suggestions as I admit, I'm not sure which route is better.
Re: [PATCH 02/11] examples/l3fwd: fix scalar LPM compilation
Quoted 34 lines · On Thu, 5 May 2022 19:49:28 +0200 Stanisław Kardach <[email protected]> wrote:
Quoted 16 lines · Stephen Hemminger
Quoted 13 lines · On Thu, 5 May 2022 19:29:54 +0200 Stanislaw Kardach <[email protected]> wrote:
The
lpm_process_event_pkt()can either process a packet using an architecture specific (defined for X86/SSE, ARM/Neon and PPC64/Altivec) path or a scalar one. The choice is however done using an ifdef pre-processor macro. Because of that the scalar version was apparently not widely excersized/compiled.
Due to some copy/paste errors, the scalar logic inlpm_process_event_pkt()retained a "continue" statement where aBAD_PORTshould be returned after refactoring of the LPM logic in the l3fwd example.Fixes 99fc91d18082 ("examples/l3fwd: add event lpm main loop")Quoted 7 lines
Quoted 3 lines
Signed-off-by Stanislaw Kardach <[email protected]>Sponsored-by Frank Zhao <[email protected]>Sponsored-by Sam Grove <[email protected]>Would be easier to get merged if bug fixes came as separate patch submission.
Sure, I can post this separately. The reason for posting this along with RISC-V patches is that those depend on this one. So I could add "depends-on" but wanted be on the safe side.
Quoted 4 lines
Also have not seen Sponsored-by before; what do you expect it to mean? Never used in DPDK or kernel git tree.
Quoted 8 lines
The idea is that this work was sponsored by the companies mentioned in the sign-off. It is used i.e. in FreeBSD though admittedly never in Linux or DPDK.
Alternative, which makes checkpatch happy and was previously used is "Suggested-by". However suggestion, doesn't necessary mean sponsorship. I had a talk about this with Thomas Monjalon and he has also leaned towards "Sponsored-by".
I'm open to suggestions as I admit, I'm not sure which route is better.
So it is just advertising.
I did notice slightly different syntax in the kernel. Could we follow that precedent?
Example:
commit 0301bcd599e552c38adf6771c25ff99680b9c4ee
Author: Bjoern A. Zeeb <[email protected]> Date: Fri Jan 28 15:34:26 2022 +0200
iwlwifi: de-const properly where needed
In order to de-const variables simply casting through (void *) is not enough: "cast from 'const .. *' to 'void *' drops const qualifier". Cast through (uintptr_t) as well [1] to make this compile on systems with more strict requirements.
In addition passing const void *data to dma_map_single() also drops the (const) qualifier. De-constify on variable on assignment which may be overwritten later. In either case the (void *) cast to dma_map_single() is not needed (anymore) either.
[1] See __DECONST() in sys/sys/cdefs.h in FreeBSD
Sponsored by: The FreeBSD Foundation
PATCH 3/11 eal: add initial support for RISC-V architecture
In reply to Stanislaw KardachFrom: Michal Mazurek <[email protected]>
Add all necessary elements for DPDK to compile and run EAL on SiFive Freedom U740 SoC which is based on SiFive U74-MC (ISA: rv64imafdc) core complex.
This includes:
- EAL library implementation for rv64imafdc ISA.
- meson build structure for 'riscv' architecture. RTE_ARCH_RISCV define is added for architecture identification.
- xmm_t structure operation stubs as there is no vector support in the U74 core.
Compilation was tested on Ubuntu and Arch Linux using riscv64 toolchain.
Two rte_rdtsc() schemes are provided: stable low-resolution using rdtime (default) and unstable high-resolution using rdcycle. User can override the scheme by defining RTE_RISCV_RDTSC_USE_HPM=1 during compile time of both DPDK and the application. The reasoning for this is as follows. The RISC-V ISA mandates that clock read by rdtime has to be of constant period and synchronized between all hardware threads within 1 tick (chapter 10.1 in version 20191213 of RISC-V spec).
However this clock may not be of high-enough frequency for dataplane uses. I.e. on HiFive Unmatched (FU740) it is 1MHz.
There is a high-resolution alternative in form of rdcycle which is clocked at the core clock frequency. The drawbacks are that it may be disabled during sleep (WFI) and its frequency might change due to DVFS.
The platform is currently marked as linux-only because rte_cycles implementation uses the timebase-frequency device-tree node read through the proc file system. Such approach was chosen because Linux kernel depends on the presence of this device-tree node.
The compilation of following modules has been disabled by this commit and will be re-enabled in later commits as fixes are introduced:
net/ixgbe, net/memif, net/tap, example/l3fwd.
Known checkpatch errors/warnings:
- ERROR:COMPLEX_MACRO in rte_atomic.h and rte_cycles.h due to inline assembly declarations.
- vector_size compiler attribute used in rte_vect.h directly.
- rte_*mb() used directly in rte_atomic.h to reduce code duplication.
- __atomic_thread_fence() used to implement rte_atomic_thread_fence().
--- MAINTAINERS | 6 + app/test/test_xmmt_ops.h | 16 ++ config/meson.build | 2 + config/riscv/meson.build | 143 ++++++++++++++++++ config/riscv/riscv64_linux_gcc | 17 +++ config/riscv/riscv64_sifive_u740_linux_gcc | 19 +++ doc/guides/contributing/design.rst | 2 +- .../linux_gsg/cross_build_dpdk_for_riscv.rst | 125 +++++++++++++++ doc/guides/linux_gsg/index.rst | 1 + doc/guides/nics/features.rst | 5 + doc/guides/nics/features/default.ini | 1 + doc/guides/rel_notes/release_22_07.rst | 23 +++ drivers/net/i40e/meson.build | 6 + drivers/net/ixgbe/meson.build | 6 + drivers/net/memif/meson.build | 5 + drivers/net/tap/meson.build | 5 + examples/l3fwd/meson.build | 6 + lib/eal/riscv/include/meson.build | 23 +++ lib/eal/riscv/include/rte_atomic.h | 52 +++++++ lib/eal/riscv/include/rte_byteorder.h | 44 ++++++ lib/eal/riscv/include/rte_cpuflags.h | 55 +++++++ lib/eal/riscv/include/rte_cycles.h | 103 +++++++++++++ lib/eal/riscv/include/rte_io.h | 21 +++ lib/eal/riscv/include/rte_mcslock.h | 18 +++ lib/eal/riscv/include/rte_memcpy.h | 63 ++++++++ lib/eal/riscv/include/rte_pause.h | 31 ++++ lib/eal/riscv/include/rte_pflock.h | 17 +++ lib/eal/riscv/include/rte_power_intrinsics.h | 22 +++ lib/eal/riscv/include/rte_prefetch.h | 50 ++++++ lib/eal/riscv/include/rte_rwlock.h | 44 ++++++ lib/eal/riscv/include/rte_spinlock.h | 67 ++++++++ lib/eal/riscv/include/rte_ticketlock.h | 21 +++ lib/eal/riscv/include/rte_vect.h | 55 +++++++ lib/eal/riscv/meson.build | 11 ++ lib/eal/riscv/rte_cpuflags.c | 122 +++++++++++++++ lib/eal/riscv/rte_cycles.c | 77 ++++++++++ lib/eal/riscv/rte_hypervisor.c | 13 ++ lib/eal/riscv/rte_power_intrinsics.c | 56 +++++++ meson.build | 2 + 39 files changed, 1354 insertions(+), 1 deletion(-) create mode 100644 config/riscv/meson.build create mode 100644 config/riscv/riscv64_linux_gcc create mode 100644 config/riscv/riscv64_sifive_u740_linux_gcc create mode 100644 doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst create mode 100644 lib/eal/riscv/include/meson.build create mode 100644 lib/eal/riscv/include/rte_atomic.h create mode 100644 lib/eal/riscv/include/rte_byteorder.h create mode 100644 lib/eal/riscv/include/rte_cpuflags.h create mode 100644 lib/eal/riscv/include/rte_cycles.h create mode 100644 lib/eal/riscv/include/rte_io.h create mode 100644 lib/eal/riscv/include/rte_mcslock.h create mode 100644 lib/eal/riscv/include/rte_memcpy.h create mode 100644 lib/eal/riscv/include/rte_pause.h create mode 100644 lib/eal/riscv/include/rte_pflock.h create mode 100644 lib/eal/riscv/include/rte_power_intrinsics.h create mode 100644 lib/eal/riscv/include/rte_prefetch.h create mode 100644 lib/eal/riscv/include/rte_rwlock.h create mode 100644 lib/eal/riscv/include/rte_spinlock.h create mode 100644 lib/eal/riscv/include/rte_ticketlock.h create mode 100644 lib/eal/riscv/include/rte_vect.h create mode 100644 lib/eal/riscv/meson.build create mode 100644 lib/eal/riscv/rte_cpuflags.c create mode 100644 lib/eal/riscv/rte_cycles.c create mode 100644 lib/eal/riscv/rte_hypervisor.c create mode 100644 lib/eal/riscv/rte_power_intrinsics.c
MAINTAINERS +6 -0
@@ -296,6 +296,12 @@ F: drivers/*/*/*_altivec.* F: app/*/*_altivec.* F: examples/*/*_altivec.* +RISC-V +M: Stanislaw Kardach <[email protected]> +F: config/riscv/ +F: doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst +F: lib/eal/riscv/ + Intel x86 M: Bruce Richardson <[email protected]> M: Konstantin Ananyev <[email protected]>
app/test/test_xmmt_ops.h +16 -0
@@ -1,5 +1,8 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2015 Cavium, Inc +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf */ #ifndef _TEST_XMMT_OPS_H_
@@ -49,6 +52,19 @@ vect_set_epi32(int i3, int i2, int i1, int i0)return data; } +#elif defined(RTE_ARCH_RISCV ) + +#define vect_loadu_sil128 (p) vect_load_128(p) + +/* sets the 4 signed 32-bit integer values and returns the xmm_t variable */ +static __rte_always_inline xmm_t +vect_set_epi32 (int i3,int i2,int i1,int i0) +{ +xmm_t data = (xmm_t ){i0, i1, i2, i3}; + +return data; +} +#endif #endif /* _TEST_XMMT_OPS_H_ */
config/meson.build +2 -0
@@ -121,6 +121,8 @@ if cpu_instruction_set == 'generic' cpu_instruction_set = 'generic' elif host_machine.cpu_family().startswith('ppc') cpu_instruction_set = 'power8' + elif host_machine.cpu_family().startswith('riscv') + cpu_instruction_set = 'riscv' endif endif
config/riscv/meson.build new file +143 -0
143 lines not on this page · raw message
config/riscv/riscv64_linux_gcc new file +17 -0
@@ -0,0 +1,17 @@ +[binaries] +c = 'riscv64-linux-gnu-gcc' +cpp = 'riscv64-linux-gnu-g++' +ar = 'riscv64-linux-gnu-ar' +strip = 'riscv64-linux-gnu-strip' +pcap-config = '' +pkgconfig = 'riscv64-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'riscv64' +cpu = 'rv64gc' +endian = 'little' + +[properties] +vendor_id = 'generic' +arch_id = 'generic'
config/riscv/riscv64_sifive_u740_linux_gcc new file +19 -0
@@ -0,0 +1,19 @@ +[binaries] +c = 'riscv64-unknown-linux-gnu-gcc' +cpp = 'riscv64-unknown-linux-gnu-g++' +ar = 'riscv64-unknown-linux-gnu-ar' +strip = 'riscv64-unknown-linux-gnu-strip' +pcap-config = '' +pkgconfig = 'riscv64-unknown-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'riscv64' +cpu = 'rv64gc' +endian = 'little' + +[properties] +vendor_id = '0x489' +arch_id = '0x8000000000000007' +max_lcores = 4 +max_numa_nodes = 1
doc/guides/contributing/design.rst +1 -1
@@ -42,7 +42,7 @@ Per Architecture Sources The following macro options can be used: * ``RTE_ARCH`` is a string that contains the name of the architecture. -* ``RTE_ARCH_I686``, ``RTE_ARCH_X86_64``, ``RTE_ARCH_X86_X32``, ``RTE_ARCH_PPC_64``, ``RTE_ARCH_ARM``, ``RTE_ARCH_ARMv7`` or ``RTE_ARCH_ARM64`` are defined only if we are building for those architectures. +* ``RTE_ARCH_I686``, ``RTE_ARCH_X86_64``, ``RTE_ARCH_X86_X32``, ``RTE_ARCH_PPC_64``, ``RTE_ARCH_RISCV``, ``RTE_ARCH_ARM``, ``RTE_ARCH_ARMv7`` or ``RTE_ARCH_ARM64`` are defined only if we are building for those architectures. Per Execution Environment Sources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +125 -0
125 lines not on this page · raw message
doc/guides/linux_gsg/index.rst +1 -0
@@ -14,6 +14,7 @@ Getting Started Guide for Linux sys_reqs build_dpdk cross_build_dpdk_for_arm64 + cross_build_dpdk_for_riscv linux_drivers build_sample_apps linux_eal_parameters
doc/guides/nics/features.rst +5 -0
@@ -855,6 +855,11 @@ x86-64 Support 64bits x86 architecture. +rv64 +---- + +Support 64-bit RISC-V architecture. + .. _nic_features_usage_doc:
doc/guides/nics/features/default.ini +1 -0
@@ -74,6 +74,7 @@ ARMv8 = Power8 = x86-32 = x86-64 = +rv64 = Usage doc = Design doc = Perf doc =
doc/guides/rel_notes/release_22_07.rst +23 -0
@@ -55,6 +55,29 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added initial RISC-V architecture support.*** + + Added EAL implementation for RISC-V architecture. The initial device the + porting was tested on is a HiFive Unmatched development board based on the + SiFive Freedom U740 SoC. In theory this implementation should work with any + ``rv64gc`` ISA compatible implementation with MMU supporting a reasonable + address space size (U740 uses sv39 MMU). + + * Verified with meson tests. ``fast-tests`` suite passing with default config. + * Verified PMD operation with Intel x520-DA2 NIC (``ixgbe``) and ``test-pmd`` + application. Packet transfer checked using all UIO drivers available for + non-IOMMU platforms: ``uio_pci_generic``, ``vfio-pci noiommu`` and + ``igb_uio``. + * The ``i40e`` PMD driver is disabled on RISC-V as ``rv64gc`` ISA has no + vector operations. + * RISCV support is currently limited to Linux. + * Clang compilation currently not supported due to issues with relocation + relaxation. + * Debug build of ``app/test/dpdk-test`` fails currently on RISC-V due to + seemingly invalid loop and goto jump code generation by GCC in + ``test_ring.c`` where extensive inlining increases the code size beyond the + capability of the generated instruction (JAL: +/-1MB PC-relative). + * **Updated Intel iavf driver.** * Added Tx QoS queue rate limitation support.
drivers/net/i40e/meson.build +6 -0
@@ -1,6 +1,12 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +if arch_subdir == 'riscv' + build = false + reason = 'riscv arch not supported' + subdir_done() +endif + cflags += ['-DPF_DRIVER', '-DVF_DRIVER', '-DINTEGRATED_VF',
drivers/net/ixgbe/meson.build +6 -0
@@ -1,6 +1,12 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +if arch_subdir == 'riscv' + build = false + reason = 'riscv arch not supported' + subdir_done() +endif + cflags += ['-DRTE_LIBRTE_IXGBE_BYPASS'] subdir('base')
drivers/net/memif/meson.build +5 -0
@@ -5,6 +5,11 @@ if not is_linux build = false reason = 'only supported on Linux' endif +if arch_subdir == 'riscv' + build = false + reason = 'riscv arch not supported' + subdir_done() +endif sources = files( 'memif_socket.c',
drivers/net/tap/meson.build +5 -0
@@ -5,6 +5,11 @@ if not is_linux build = false reason = 'only supported on Linux' endif +if arch_subdir == 'riscv' + build = false + reason = 'riscv arch not supported' + subdir_done() +endif sources = files( 'rte_eth_tap.c', 'tap_bpf_api.c',
examples/l3fwd/meson.build +6 -0
@@ -6,6 +6,12 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' +if dpdk_conf.has('RTE_ARCH_RISCV') + build = false + reason = 'riscv arch not supported' + subdir_done() +endif + allow_experimental_apis = true deps += ['hash', 'lpm', 'fib', 'eventdev'] sources = files(
lib/eal/riscv/include/meson.build new file +23 -0
@@ -0,0 +1,23 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2022 StarFive +# Copyright(c) 2022 SiFive +# Copyright(c) 2022 Semihalf + +arch_headers = files( + 'rte_atomic.h', + 'rte_byteorder.h', + 'rte_cpuflags.h', + 'rte_cycles.h', + 'rte_io.h', + 'rte_mcslock.h', + 'rte_memcpy.h', + 'rte_pause.h', + 'rte_pflock.h', + 'rte_power_intrinsics.h', + 'rte_prefetch.h', + 'rte_rwlock.h', + 'rte_spinlock.h', + 'rte_ticketlock.h', + 'rte_vect.h' +) +install_headers(arch_headers, subdir: get_option('include_subdir_arch'))
lib/eal/riscv/include/rte_atomic.h new file +52 -0
52 lines not on this page · raw message
lib/eal/riscv/include/rte_byteorder.h new file +44 -0
44 lines not on this page · raw message
lib/eal/riscv/include/rte_cpuflags.h new file +55 -0
55 lines not on this page · raw message
lib/eal/riscv/include/rte_cycles.h new file +103 -0
103 lines not on this page · raw message
lib/eal/riscv/include/rte_io.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2016 Cavium, Inc +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_IO_RISCV_H +#define RTE_IO_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_io.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_IO_RISCV_H */
lib/eal/riscv/include/rte_mcslock.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef RTE_MCSLOCK_RISCV_H +#define RTE_MCSLOCK_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_mcslock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_MCSLOCK_RISCV_H */
lib/eal/riscv/include/rte_memcpy.h new file +63 -0
63 lines not on this page · raw message
lib/eal/riscv/include/rte_pause.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_PAUSE_RISCV_H +#define RTE_PAUSE_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "rte_atomic.h" + +#include "generic/rte_pause.h" + +static inline void rte_pause (void ) +{ +/* Insert pause hint directly to be compatible with old compilers. +* This will work even on platforms without Zihintpause extension +* because this is a FENCE hint instruction which evaluates to NOP then. +*/ + asmvolatile (".int 0x0100000F" :::"memory" ); +} + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_PAUSE_RISCV_H */
lib/eal/riscv/include/rte_pflock.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2021 Microsoft Corporation +*/ +#ifndef RTE_PFLOCK_RISCV_H +#define RTE_PFLOCK_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_pflock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_PFLOCK_RISCV_H */
lib/eal/riscv/include/rte_power_intrinsics.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_POWER_INTRINSIC_RISCV_H +#define RTE_POWER_INTRINSIC_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rte_common.h> + +#include "generic/rte_power_intrinsics.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_POWER_INTRINSIC_RISCV_H */
lib/eal/riscv/include/rte_prefetch.h new file +50 -0
50 lines not on this page · raw message
lib/eal/riscv/include/rte_rwlock.h new file +44 -0
44 lines not on this page · raw message
lib/eal/riscv/include/rte_spinlock.h new file +67 -0
67 lines not on this page · raw message
lib/eal/riscv/include/rte_ticketlock.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_TICKETLOCK_RISCV_H +#define RTE_TICKETLOCK_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_ticketlock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_TICKETLOCK_RISCV_H */
lib/eal/riscv/include/rte_vect.h new file +55 -0
55 lines not on this page · raw message
lib/eal/riscv/meson.build new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation. + +subdir('include') + +sources += files( + 'rte_cpuflags.c', + 'rte_cycles.c', + 'rte_hypervisor.c', + 'rte_power_intrinsics.c', +)
lib/eal/riscv/rte_cpuflags.c new file +122 -0
122 lines not on this page · raw message
lib/eal/riscv/rte_cycles.c new file +77 -0
77 lines not on this page · raw message
lib/eal/riscv/rte_hypervisor.c new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#include "rte_hypervisor.h" + +enum rte_hypervisor +rte_hypervisor_get (void ) +{ +return RTE_HYPERVISOR_UNKNOWN ; +}
lib/eal/riscv/rte_power_intrinsics.c new file +56 -0
56 lines not on this page · raw message
meson.build +2 -0
@@ -50,6 +50,8 @@ elif host_machine.cpu_family().startswith('arm') or host_machine.cpu_family().st arch_subdir = 'arm' elif host_machine.cpu_family().startswith('ppc') arch_subdir = 'ppc' +elif host_machine.cpu_family().startswith('riscv') + arch_subdir = 'riscv' endif # configure the build, and make sure configs here and in config folder are
Signature · 1 line
2.30.2
PATCH 4/11 net/ixgbe: enable vector stubs for RISC-V
In reply to Stanislaw KardachRe-use vector processing stubs in ixgbe PMD defined for PPC for RISC-V. This enables ixgbe PMD usage in scalar mode on this architecture.
The ixgbe PMD driver was validated with Intel X520-DA2 NIC and the test-pmd application. Packet transfer checked using all UIO drivers available for non-IOMMU platforms: uio_pci_generic, vfio-pci noiommu and igb_uio.
--- doc/guides/nics/features/ixgbe.ini | 1 + drivers/net/ixgbe/ixgbe_rxtx.c | 4 ++-- drivers/net/ixgbe/meson.build | 6 ------ 3 files changed, 3 insertions(+), 8 deletions(-)
doc/guides/nics/features/ixgbe.ini +1 -0
@@ -54,6 +54,7 @@ Windows = Y ARMv8 = Y x86-32 = Y x86-64 = Y +rv64 = Y [rte_flow items] eth = Y
drivers/net/ixgbe/ixgbe_rxtx.c +2 -2
@@ -5957,8 +5957,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev,return 0 ; } -/* Stubs needed for linkage when RTE_ARCH_PPC_64 is set */ -#if defined(RTE_ARCH_PPC_64 ) +/* Stubs needed for linkage when RTE_ARCH_PPC_64 or RTE_ARCH_RISCV is set */ +#if defined(RTE_ARCH_PPC_64 ) || defined(RTE_ARCH_RISCV )int ixgbe_rx_vec_dev_conf_condition_check(struct rte_eth_dev __rte_unused *dev) {
drivers/net/ixgbe/meson.build +0 -6
@@ -1,12 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -if arch_subdir == 'riscv' - build = false - reason = 'riscv arch not supported' - subdir_done() -endif - cflags += ['-DRTE_LIBRTE_IXGBE_BYPASS'] subdir('base')
Signature · 1 line
2.30.2
PATCH 5/11 net/memif: set memfd syscall ID on RISC-V
In reply to Stanislaw KardachDefine the missing __NR_memfd_create syscall id to enable the memif PMD.
--- drivers/net/memif/meson.build | 5 ----- drivers/net/memif/rte_eth_memif.h | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/memif/meson.build +0 -5
@@ -5,11 +5,6 @@ if not is_linux build = false reason = 'only supported on Linux' endif -if arch_subdir == 'riscv' - build = false - reason = 'riscv arch not supported' - subdir_done() -endif sources = files( 'memif_socket.c',
drivers/net/memif/rte_eth_memif.h +2 -0
@@ -180,6 +180,8 @@ const char *memif_version(void);#define __NR_memfd_create 360#elif defined __i386__#define __NR_memfd_create 356 +#elif defined __riscv +#define __NR_memfd_create 279#else #error "__NR_memfd_create unknown for this architecture"#endif
Signature · 1 line
2.30.2
PATCH 6/11 net/tap: set BPF syscall ID for RISC-V
In reply to Stanislaw KardachDefine the missing __NR_bpf syscall id to enable the tap PMD.
--- drivers/net/tap/meson.build | 5 ----- drivers/net/tap/tap_bpf.h | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/tap/meson.build +0 -5
@@ -5,11 +5,6 @@ if not is_linux build = false reason = 'only supported on Linux' endif -if arch_subdir == 'riscv' - build = false - reason = 'riscv arch not supported' - subdir_done() -endif sources = files( 'rte_eth_tap.c', 'tap_bpf_api.c',
drivers/net/tap/tap_bpf.h +2 -0
@@ -101,6 +101,8 @@ union bpf_attr {# define __NR_bpf 351# elif defined(__powerpc__)# define __NR_bpf 361 +# elif defined(__riscv) +# define __NR_bpf 280# else # error __NR_bpf not defined# endif
Signature · 1 line
2.30.2
PATCH 7/11 examples/l3fwd: enable RISC-V operation
In reply to Stanislaw KardachAdd missing em_mask_key() implementation and fix l3fwd_common.h inclusion in FIB lookup functions to enable the l3fwd to be run on RISC-V.
--- examples/l3fwd/l3fwd_em.c | 8 ++++++++ examples/l3fwd/l3fwd_fib.c | 2 ++ examples/l3fwd/meson.build | 6 ------ 3 files changed, 10 insertions(+), 6 deletions(-)
examples/l3fwd/l3fwd_em.c +8 -0
@@ -239,6 +239,14 @@ em_mask_key(void *key, xmm_t mask) return vec_and(data, mask); } +#elif defined(RTE_ARCH_RISCV) +static inline xmm_t +em_mask_key (void *key,xmm_t mask) +{ +xmm_t data =vect_load_128 (key); + +return vect_and (data, mask); +}#else #error No vector engine (SSE, NEON, ALTIVEC) available, check your toolchain#endif
examples/l3fwd/l3fwd_fib.c +2 -0
@@ -18,6 +18,8 @@#include "l3fwd_neon.h" #elif definedRTE_ARCH_PPC_64 #include "l3fwd_altivec.h" +#else +#include "l3fwd_common.h" #endif #include "l3fwd_event.h" #include "l3fwd_route.h"
examples/l3fwd/meson.build +0 -6
@@ -6,12 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -if dpdk_conf.has('RTE_ARCH_RISCV') - build = false - reason = 'riscv arch not supported' - subdir_done() -endif - allow_experimental_apis = true deps += ['hash', 'lpm', 'fib', 'eventdev'] sources = files(
Signature · 1 line
2.30.2
PATCH 8/11 test/cpuflags: add test for RISC-V cpu flag
In reply to Stanislaw KardachFrom: Michal Mazurek <[email protected]>
Add checks for all flag values defined in the RISC-V misa CSR register.
--- app/test/test_cpuflags.c | 81 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)
app/test/test_cpuflags.c +81 -0
@@ -200,6 +200,87 @@ test_cpuflags(void)CHECK_FOR_FLAG (RTE_CPUFLAG_INVTSC );#endif +#if defined(RTE_ARCH_RISCV ) + +printf ("Check for RISCV_ISA_A:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_A ); + +printf ("Check for RISCV_ISA_B:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_B ); + +printf ("Check for RISCV_ISA_C:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_C ); + +printf ("Check for RISCV_ISA_D:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_D ); + +printf ("Check for RISCV_ISA_E:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_E ); + +printf ("Check for RISCV_ISA_F:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_F ); + +printf ("Check for RISCV_ISA_G:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_G ); + +printf ("Check for RISCV_ISA_H:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_H ); + +printf ("Check for RISCV_ISA_I:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_I ); + +printf ("Check for RISCV_ISA_J:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_J ); + +printf ("Check for RISCV_ISA_K:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_K ); + +printf ("Check for RISCV_ISA_L:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_L ); + +printf ("Check for RISCV_ISA_M:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_M ); + +printf ("Check for RISCV_ISA_N:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_N ); + +printf ("Check for RISCV_ISA_O:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_O ); + +printf ("Check for RISCV_ISA_P:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_P ); + +printf ("Check for RISCV_ISA_Q:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_Q ); + +printf ("Check for RISCV_ISA_R:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_R ); + +printf ("Check for RISCV_ISA_S:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_S ); + +printf ("Check for RISCV_ISA_T:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_T ); + +printf ("Check for RISCV_ISA_U:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_U ); + +printf ("Check for RISCV_ISA_V:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_V ); + +printf ("Check for RISCV_ISA_W:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_W ); + +printf ("Check for RISCV_ISA_X:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_X ); + +printf ("Check for RISCV_ISA_Y:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_Y ); + +printf ("Check for RISCV_ISA_Z:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_Z ); +#endif +/* * Check if invalid data is handled properly */
Signature · 1 line
2.30.2
PATCH 9/11 test/ring: disable problematic tests for RISC-V
In reply to Stanislaw KardachWhen compiling for RISC-V in debug mode the large amount of inlining in test_ring_basic_ex() and test_ring_with_exact_size() (in test_ring.c) leads to large loop bodies. This causes 'goto' and 'for' loop PC-relative jumps generated by the compiler to go beyond the architecture limitation of +/-1MB offset (the 'j <offset>' instruction). This instruction should not be generated by the compiler since C language does not limit the maximum distance for 'goto' or 'for' loop jumps.
This only happens in the unit test for ring which tries to perform long loops with ring enqueue/dequeue and it seems to be caused by excessive __rte_always_inline usage. ring perf test compiles just fine under debug.
To work around this, disable the offending tests in debug mode.
--- app/test/test_ring.c | 8 ++++++++ config/riscv/meson.build | 5 +++++ doc/guides/rel_notes/release_22_07.rst | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-)
app/test/test_ring.c +8 -0
@@ -955,6 +955,7 @@ test_ring_burst_bulk_tests4(unsigned int test_idx)return -1 ; } +#if !defined(RTE_RISCV_WO_DISABLE_RING_TESTS )/* * Test default, single element, bulk and burst APIs */
@@ -1189,6 +1190,7 @@ test_ring_with_exact_size(void)rte_ring_free (exact_sz_r); return -1; } +#endif static int test_ring (void )
@@ -1200,12 +1202,18 @@ test_ring(void)if (test_ring_negative_tests () <0 ) goto test_fail; +/* Disable the following tests on RISC-V in debug mode. This is a work-around +* GCC bug for RISC-V which fails to generate proper jumps for loops with large +* bodies. +*/ +#if !defined(RTE_RISCV_WO_DISABLE_RING_TESTS )/* Some basic operations */ if (test_ring_basic_ex () <0 ) goto test_fail;if (test_ring_with_exact_size () <0 ) goto test_fail; +#endif /* Burst and bulk operations with sp/sc, mp/mc and default. * The test cases are split into smaller test cases to
config/riscv/meson.build +5 -0
@@ -141,3 +141,8 @@ foreach flag: dpdk_flags endforeach message('Using machine args: @0@'.format(machine_args)) +# Enable work-around for ring unit tests in debug mode which fail to link +# properly due to bad code generation by GCC. +if get_option('optimization') == '0' or get_option('optimization') == 'g' + add_project_arguments('-DRTE_RISCV_WO_DISABLE_RING_TESTS', language: 'c') +endif
doc/guides/rel_notes/release_22_07.rst +2 -1
@@ -76,7 +76,8 @@ New Features * Debug build of ``app/test/dpdk-test`` fails currently on RISC-V due to seemingly invalid loop and goto jump code generation by GCC in ``test_ring.c`` where extensive inlining increases the code size beyond the - capability of the generated instruction (JAL: +/-1MB PC-relative). + capability of the generated instruction (JAL: +/-1MB PC-relative). The + workaround is to disable ``test_ring_basic_ex()`` and ``test_ring_with_exact_size()`` on RISC-V on ``-O0`` or ``-Og``. * **Updated Intel iavf driver.**
Signature · 1 line
2.30.2
Re: [PATCH 09/11] test/ring: disable problematic tests for RISC-V
Quoted 13 lines · On Thu, 5 May 2022 19:30:01 +0200 Stanislaw Kardach <[email protected]> wrote:
When compiling for RISC-V in debug mode the large amount of inlining in
test_ring_basic_ex()andtest_ring_with_exact_size()(intest_ring.c) leads to large loop bodies. This causes 'goto' and 'for' loop PC-relative jumps generated by the compiler to go beyond the architecture limitation of +/-1MB offset (the 'j <offset>' instruction). This instruction should not be generated by the compiler since C language does not limit the maximum distance for 'goto' or 'for' loop jumps.This only happens in the unit test for ring which tries to perform long loops with ring enqueue/dequeue and it seems to be caused by excessive
__rte_always_inlineusage. ring perf test compiles just fine under debug.
Quoted 6 lines
To work around this, disable the offending tests in debug mode.
Signed-off-by Stanislaw Kardach <[email protected]>Sponsored-by Frank Zhao <[email protected]>Sponsored-by Sam Grove <[email protected]>---
It seems to me that fixing the excessive inlining in the ring code could benefit all architectures, rather than neutering the tests on RISCV.
Re: [PATCH 09/11] test/ring: disable problematic tests for RISC-V
Quoted 18 lines · Stephen Hemminger
Quoted 15 lines · On Thu, 5 May 2022 19:30:01 +0200 Stanislaw Kardach <[email protected]> wrote:
When compiling for RISC-V in debug mode the large amount of inlining in
test_ring_basic_ex()andtest_ring_with_exact_size()(intest_ring.c) leads to large loop bodies. This causes 'goto' and 'for' loop PC-relative jumps generated by the compiler to go beyond the architecture limitation of +/-1MB offset (the 'j <offset>' instruction). This instruction should not be generated by the compiler since C language does not limit the maximum distance for 'goto' or 'for' loop jumps.This only happens in the unit test for ring which tries to perform long loops with ring enqueue/dequeue and it seems to be caused by excessive
__rte_always_inlineusage. ring perf test compiles just fine under debug.To work around this, disable the offending tests in debug mode.
Quoted 9 lines
Quoted 4 lines
Signed-off-by Stanislaw Kardach <[email protected]>Sponsored-by Frank Zhao <[email protected]>Sponsored-by Sam Grove <[email protected]>---
It seems to me that fixing the excessive inlining in the ring code could benefit all architectures, rather than neutering the tests on RISCV.
True. Since this only happened in the tests that I've mentioned, my other
approach was to introduce a "slow" wrapper over test_ring_dequeue|enqueue() which did not force inlining via __rte_always_inline and use it in functional test functions. However after talking with Thomas Monjalon we've decided to guard the debug build of RISC-V only.
Another thing is that this is a clear bug in the compiler, the relaxation of the jump should not be done since RISC-V has long jump construct for arbitrary jumps (auipc+jalr).
Re: [PATCH 09/11] test/ring: disable problematic tests for RISC-V
Quoted 30 lines · On Thu, 5 May 2022 19:43:43 +0200 Stanisław Kardach <[email protected]> wrote:
Quoted 18 lines · Stephen Hemminger
Quoted 15 lines · On Thu, 5 May 2022 19:30:01 +0200 Stanislaw Kardach <[email protected]> wrote:
When compiling for RISC-V in debug mode the large amount of inlining in
test_ring_basic_ex()andtest_ring_with_exact_size()(intest_ring.c) leads to large loop bodies. This causes 'goto' and 'for' loop PC-relative jumps generated by the compiler to go beyond the architecture limitation of +/-1MB offset (the 'j <offset>' instruction). This instruction should not be generated by the compiler since C language does not limit the maximum distance for 'goto' or 'for' loop jumps.This only happens in the unit test for ring which tries to perform long loops with ring enqueue/dequeue and it seems to be caused by excessive
__rte_always_inlineusage. ring perf test compiles just fine under debug.To work around this, disable the offending tests in debug mode.
Quoted 9 lines
Quoted 4 lines
Signed-off-by Stanislaw Kardach <[email protected]>Sponsored-by Frank Zhao <[email protected]>Sponsored-by Sam Grove <[email protected]>---
It seems to me that fixing the excessive inlining in the ring code could benefit all architectures, rather than neutering the tests on RISCV.
Quoted 8 lines
True. Since this only happened in the tests that I've mentioned, my other
approach was to introduce a "slow" wrapper over test_ring_dequeue|enqueue() which did not force inlining via__rte_always_inlineand use it in functional test functions. However after talking with Thomas Monjalon we've decided to guard the debug build of RISC-V only.
Another thing is that this is a clear bug in the compiler, the relaxation of the jump should not be done since RISC-V has long jump construct for arbitrary jumps (auipc+jalr).
There is no good reason the __rte_always_inline should be in the ring code. The purpose of always inline should be only for code that would break if not inlined.
RE: [PATCH 09/11] test/ring: disable problematic tests for RISC-V
In reply to Stanislaw Kardach<snip>
Quoted 9 lines
When compiling for RISC-V in debug mode the large amount of inlining in
test_ring_basic_ex()andtest_ring_with_exact_size()(intest_ring.c) leads to large loop bodies. This causes 'goto' and 'for' loop PC-relative jumps generated by the compiler to go beyond the architecture limitation of +/-1MB offset (the 'j <offset>' instruction). This instruction should not be generated by the compiler since C language does not limit the maximum distance for 'goto' or 'for' loop jumps.
Quoted 5 lines
This only happens in the unit test for ring which tries to perform long loops with ring enqueue/dequeue and it seems to be caused by excessive
__rte_always_inlineusage. ring perf test compiles just fine under debug.To work around this, disable the offending tests in debug mode.
Is this still required given you have submitted [1]
[1] http://patches.dpdk.org/project/dpdk/patch/[email protected]/
Quoted 81 lines
Signed-off-by Stanislaw Kardach <[email protected]>Sponsored-by Frank Zhao <[email protected]>Sponsored-by Sam Grove <[email protected]>--- app/test/test_ring.c | 8 ++++++++ config/riscv/meson.build | 5 +++++ doc/guides/rel_notes/release_22_07.rst | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-)app/test/test_ring.c index renamed from app/test/test_ring.c +0
-0
bde33ab4a1..7d809c147b100644app/test/test_ring.c +10
-0@@ -955,6 +955,7 @@ test_ring_burst_bulk_tests4(unsigned int test_idx)return -1 ; } +#if !defined(RTE_RISCV_WO_DISABLE_RING_TESTS )/* * Test default, single element, bulk and burst APIs */ @@ -1189,6 +1190,7 @@ test_ring_with_exact_size(void)rte_ring_free (exact_sz_r); return -1; } +#endif static int test_ring (void )@@ -1200,12 +1202,18 @@ test_ring(void)if (test_ring_negative_tests () <0 ) goto test_fail; +/* Disable the following tests on RISC-V in debug mode. This is a +work-around +* GCC bug for RISC-V which fails to generate proper jumps for loops +with large +* bodies. +*/ +#if !defined(RTE_RISCV_WO_DISABLE_RING_TESTS )/* Some basic operations */ if (test_ring_basic_ex () <0 ) goto test_fail;if (test_ring_with_exact_size () <0 ) goto test_fail; +#endif /* Burst and bulk operations with sp/sc, mp/mc and default. * The test cases are split into smaller test cases to diff --git a/config/riscv/meson.build b/config/riscv/meson.build index
0c16c31fc2..50d0b513bf100644config/riscv/meson.build +5
-0@@ -141,3 +141,8 @@ foreach flag: dpdk_flags endforeach message('Using machine args: @0@'.format(machine_args)) +# Enable work-around for ring unit tests in debug mode which fail to +link # properly due to bad code generation by GCC. +if get_option('optimization') == '0' or get_option('optimization') == 'g' + add_project_arguments('-DRTE_RISCV_WO_DISABLE_RING_TESTS', +language: 'c') endifdoc/guides/rel_notes/release_22_07.rst +2
-1@@ -76,7 +76,8 @@ New Features * Debug build of ``app/test/dpdk-test`` fails currently on RISC-V due to seemingly invalid loop and goto jump code generation by GCC in ``test_ring.c`` where extensive inlining increases the code size beyond the - capability of the generated instruction (JAL: +/-1MB PC-relative). + capability of the generated instruction (JAL: +/-1MB PC-relative). The + workaround is to disable ``test_ring_basic_ex()`` and``test_ring_with_exact_size()`` on RISC-V on ``-O0`` or ``-Og``.
* **Updated Intel iavf driver.**
--
2.30.2
Re: [PATCH 09/11] test/ring: disable problematic tests for RISC-V
Quoted 12 lines · Honnappa Nagarahalli
<snip>
Quoted 9 lines
When compiling for RISC-V in debug mode the large amount of inlining in
test_ring_basic_ex()andtest_ring_with_exact_size()(intest_ring.c) leads to large loop bodies. This causes 'goto' and 'for' loop PC-relative jumps generated by the compiler to go beyond the architecture limitation of +/-1MB offset (the 'j <offset>' instruction). This instruction should not be generated by the compiler since C language does not limit the maximum distance for 'goto' or 'for' loop jumps.
Quoted 8 lines
Quoted 5 lines
This only happens in the unit test for ring which tries to perform long loops with ring enqueue/dequeue and it seems to be caused by excessive
__rte_always_inlineusage. ring perf test compiles just fine under debug.To work around this, disable the offending tests in debug mode.
Is this still required given you have submitted [1]
[1] http://patches.dpdk.org/project/dpdk/patch/[email protected]/
Correct, this patch is no longer necessary and marked as superseded in patchwork. I did send v2 and v3 series without it. Thank you for taking a look.
Quoted 83 lines
Quoted 82 lines
Signed-off-by Stanislaw Kardach <[email protected]>Sponsored-by Frank Zhao <[email protected]>Sponsored-by Sam Grove <[email protected]>--- app/test/test_ring.c | 8 ++++++++ config/riscv/meson.build | 5 +++++ doc/guides/rel_notes/release_22_07.rst | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-)app/test/test_ring.c index renamed from app/test/test_ring.c +0
-0
bde33ab4a1..7d809c147b100644app/test/test_ring.c +10
-0@@ -955,6 +955,7 @@ test_ring_burst_bulk_tests4(unsigned int test_idx)return -1 ; } +#if !defined(RTE_RISCV_WO_DISABLE_RING_TESTS )/* * Test default, single element, bulk and burst APIs */ @@ -1189,6 +1190,7 @@ test_ring_with_exact_size(void)rte_ring_free (exact_sz_r); return -1; } +#endif static int test_ring (void )@@ -1200,12 +1202,18 @@ test_ring(void)if (test_ring_negative_tests () <0 ) goto test_fail; +/* Disable the following tests on RISC-V in debug mode. This is a +work-around +* GCC bug for RISC-V which fails to generate proper jumps for loops +with large +* bodies. +*/ +#if !defined(RTE_RISCV_WO_DISABLE_RING_TESTS )/* Some basic operations */ if (test_ring_basic_ex () <0 ) goto test_fail;if (test_ring_with_exact_size () <0 ) goto test_fail; +#endif /* Burst and bulk operations with sp/sc, mp/mc and default. * The test cases are split into smaller test cases to diff --git a/config/riscv/meson.build b/config/riscv/meson.build index
0c16c31fc2..50d0b513bf100644config/riscv/meson.build +5
-0@@ -141,3 +141,8 @@ foreach flag: dpdk_flags endforeach message('Using machine args: @0@'.format(machine_args)) +# Enable work-around for ring unit tests in debug mode which fail to +link # properly due to bad code generation by GCC. +if get_option('optimization') == '0' or get_option('optimization') == 'g' + add_project_arguments('-DRTE_RISCV_WO_DISABLE_RING_TESTS', +language: 'c') endifdoc/guides/rel_notes/release_22_07.rst +2
-1@@ -76,7 +76,8 @@ New Features * Debug build of ``app/test/dpdk-test`` fails currently on RISC-V due to seemingly invalid loop and goto jump code generation by GCC in ``test_ring.c`` where extensive inlining increases the code size beyond the - capability of the generated instruction (JAL: +/-1MB PC-relative). + capability of the generated instruction (JAL: +/-1MB PC-relative). The + workaround is to disable ``test_ring_basic_ex()`` and``test_ring_with_exact_size()`` on RISC-V on ``-O0`` or ``-Og``.
* **Updated Intel iavf driver.**
--
2.30.2
PATCH 10/11 devtools: add RISC-V to test-meson-builds.sh
In reply to Stanislaw KardachValidate RISC-V compilation when test-meson-builds.sh is called. The check will be only performed if appropriate toolchain is present on the system (same as with other architectures).
--- devtools/test-meson-builds.sh | 6 ++++++ 1 file changed, 6 insertions(+)
devtools/test-meson-builds.sh +6 -0
@@ -275,6 +275,12 @@ for f in $srcdir/config/ppc/ppc* ; do build $targetdir $f ABI $use_shared done +# RISC-V configurations +for f in $srcdir/config/riscv/riscv* ; do + targetdir=build-$(basename $f | tr '_' '-' | cut -d'-' -f-2) + build $targetdir $f ABI $use_shared +done + # Test installation of the x86-generic target, to be used for checking # the sample apps build using the pkg-config file for cflags and libs load_env cc
Signature · 1 line
2.30.2
PATCH 11/11 test/hash: report non HTM numbers for single r/w
In reply to Stanislaw KardachIn hash_readwrite_perf_autotest a single read and write operation is benchmarked for both HTM and non HTM cases. However the result summary only shows the HTM value. Therefore add the non HTM value for completeness.
--- app/test/test_hash_readwrite.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
app/test/test_hash_readwrite.c +6 -2
@@ -664,8 +664,12 @@ test_hash_rw_perf_main(void)printf ("Results summary:\n" );printf ("================\n" ); -printf ("single read: %u\n" , htm_results.single_read); -printf ("single write: %u\n" , htm_results.single_write); +printf ("HTM:\n" ); +printf (" single read: %u\n" , htm_results.single_read); +printf (" single write: %u\n" , htm_results.single_write); +printf ("non HTM:\n" ); +printf (" single read: %u\n" , non_htm_results.single_read); +printf (" single write: %u\n" , non_htm_results.single_write);for (i =0 ; i <NUM_TEST ; i++) {printf ("+++ core_cnt: %u +++\n" , core_cnt[i]);printf ("HTM:\n" );
Signature · 1 line
2.30.2
Quoted 28 lines · Stanislaw Kardach
This patchset adds support for building and running DPDK on 64bit RISC-V architecture. The initial support targets rv64gc (rv64imafdc) ISA and was tested on SiFive Unmatched development board with the Freedom U740 SoC running Linux (freedom-u-sdk based kernel).
I have tested this codebase using DPDK unit and perf tests as well as test-pmd, l2fwd and l3fwd examples.
The NIC attached to the DUT was Intel X520-DA2 which uses ixgbe PMD. On the UIO side, since U740 does not have an IOMMU, I've usedigb_uio,uio_pci_genericand vfio-pci noiommu drivers.Commits 1-2 fix small issues which are encountered if a given platform
does not support any vector operations (which is the case with U740).
Commit 3 introduces EAL and build system support for RISC-V architecture
as well as documentation updates.
Commits 4-7 add missing defines and stubs to enable RISC-V operation in
non-EAL parts.
Commit 8 adds RISC-V specific cpuflags test.
Commit 9 works around a bug in the current GCC intest_ringcompiled
with -O0 or -Og.
Commit 10 adds RISC-V testing totest-meson-builds.shautomatically
iterating over cross-compile config files (currently present for generic rv64gc and SiFive U740).
Commit 11 extends hash r/w perf test by displaying both HTM and non-HTM
measurements. This is an extraneous commit which is not directly needed for RISC-V support but was noticed when we have started gathering test results. If needed, I can submit it separately.
Quoted 1 line
I appreciate Your comments and feedback.
Thanks for working on this!
Please add a cross compilation job to GHA, something like:
https://github.com/david-marchand/dpdk/commit/4023e28f9050b85fb138eba14068bfe882036f01
Which looks to run fine:
https://github.com/david-marchand/dpdk/runs/6319625002?check_suite_focus=true
Testing all riscv configs in test-meson-buils.sh seems too much to me. Is there a real value to test both current targets?
About the new "Sponsored-by" tag, it should not raise warnings in the CI if we agree on its addition.
devtools/check-meson.py caught coding style issues.
In general, please avoid letting arch specific headers leak internal/non rte_ prefixed helpers out of them.
For example, I noticed a RV64_CSRR macro that can be undefined after usage.
Patch 3 is huge, not sure it is easy to split, did you consider doing so?
The release notes update is verbose and some parts could be dropped, like the list of verifications that are fine in a series cover letter.
Please resubmit fixes separately from this series so that we can merge them sooner than this series.
Signature · 1 line
David Marchand
Quoted 29 lines · David Marchand
Quoted 28 lines · Stanislaw Kardach
This patchset adds support for building and running DPDK on 64bit RISC-V architecture. The initial support targets rv64gc (rv64imafdc) ISA and was tested on SiFive Unmatched development board with the Freedom U740 SoC running Linux (freedom-u-sdk based kernel).
I have tested this codebase using DPDK unit and perf tests as well as test-pmd, l2fwd and l3fwd examples.
The NIC attached to the DUT was Intel X520-DA2 which uses ixgbe PMD. On the UIO side, since U740 does not have an IOMMU, I've usedigb_uio,uio_pci_genericand vfio-pci noiommu drivers.Commits 1-2 fix small issues which are encountered if a given platform
does not support any vector operations (which is the case with U740).
Commit 3 introduces EAL and build system support for RISC-V architecture
as well as documentation updates.
Commits 4-7 add missing defines and stubs to enable RISC-V operation in
non-EAL parts.
Commit 8 adds RISC-V specific cpuflags test.
Commit 9 works around a bug in the current GCC intest_ringcompiled
with -O0 or -Og.
Commit 10 adds RISC-V testing totest-meson-builds.shautomatically
iterating over cross-compile config files (currently present for generic rv64gc and SiFive U740).
Commit 11 extends hash r/w perf test by displaying both HTM and non-HTM
measurements. This is an extraneous commit which is not directly needed for RISC-V support but was noticed when we have started gathering test results. If needed, I can submit it separately.
Quoted 4 lines
Quoted 1 line
I appreciate Your comments and feedback.
Thanks for working on this!
Thanks for your review!
Quoted 7 lines
Please add a cross compilation job to GHA, something like:
https://github.com/david-marchand/dpdk/commit/4023e28f9050b85fb138eba14068bfe882036f01
Which looks to run fine:https://github.com/david-marchand/dpdk/runs/6319625002?check_suite_focus=true
Will do in V2.
Quoted 5 lines
Testing all riscv configs in
test-meson-buils.shseems too much to me. Is there a real value to test both current targets?
It's for sanity and compilation coverage testing. I.e. SiFive variant has a specific build config which does not require extra barriers when reading time and cycle registers for rte_rdtsc_precise(). I want to make sure that if anyone changes some code based on configuration flags, it gets at least compile-checked.
I believe similar thing is done for Aarch64 builds.
Quoted 4 lines
About the new "Sponsored-by" tag, it should not raise warnings in the CI if we agree on its addition.
I'll modify it in V2 to be in form of:
Sponsored by: StarFive Technology
...
Signed-off-by: ...
This was suggested by Stephen Hemminger as having a precedent in Linux kernel. Interestingly enough first use of this tag in kernel source was this year in January.
Quoted 3 lines
devtools/check-meson.pycaught coding style issues.
Will fix in V2.
Quoted 5 lines
In general, please avoid letting arch specific headers leak internal/non
rte_prefixed helpers out of them.
For example, I noticed aRV64_CSRRmacro that can be undefined after usage.
Thanks for noticing. I'l fix this one in V2.
There are 2 other symbols that leak but on purpose (out of a better idea): vect_load_128() and vect_and(). Both are used in l3fwd_em to simulate vector operations. Other platforms reference their intrinsics straight in the l3fwd_em.c. As I don't have support for vector ops and I wanted to indicate that xmm_t should be an isolated API, I've put both in rte_vect.h. That said I'm not happy with this solution and am open to suggestions on how to solve it neatly.
Quoted 3 lines
Patch 3 is huge, not sure it is easy to split, did you consider doing so?
It seems to me the nature of a new EAL implementation, I have to include all symbols, otherwise DPDK won't compile.
Alternatively I could have a huge initial patch with empty stubs that would be filled in later commits. Downside of this approach is that it's hard to verify each commit separately as tests will fail until all implementation is there, so the division is only visual.
Quoted 4 lines
The release notes update is verbose and some parts could be dropped, like the list of verifications that are fine in a series cover letter.
Will do. I'll move listed items to the cover letter.
Quoted 4 lines
Please resubmit fixes separately from this series so that we can merge them sooner than this series.
Will do. Since at least 2 fixes are required for the RISC-V EAL to work or compile, I'll put Depends-on tag in the EAL commit.
Quoted 6 lines
--
David Marchand
09/05/2022 14:24, Stanisław Kardach:
Quoted 7 lines
Quoted 3 lines · David Marchand
About the new "Sponsored-by" tag, it should not raise warnings in the CI if we agree on its addition.
I'll modify it in V2 to be in form of:
Sponsored by: StarFive Technology
You mean removing the hyphen?
I think it is better to keep it so all tags have the same format.
Quoted 6 lines
...
Signed-off-by: ...This was suggested by Stephen Hemminger as having a precedent in Linux kernel. Interestingly enough first use of this tag in kernel source was this year in January.
The precedent is not strong enough to be copied in my opinion.
Quoted 8 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, 9 May 2022 14.3109/05/2022 14:24, Stanisław Kardach:
Quoted 1 line
On Fri, May 6, 2022 at 11:13 AM David Marchand
Quoted 2 lines
Quoted 1 line · wrote:
About the new "Sponsored-by" tag, it should not raise warnings in
Quoted 8 lines
the
Quoted 4 lines
Quoted 2 lines
CI if we agree on its addition.
I'll modify it in V2 to be in form of:
Sponsored by: StarFive TechnologyYou mean removing the hyphen?
I think it is better to keep it so all tags have the same format.
I agree with Thomas. Please keep the hyphen.
Quoted 9 lines
Quoted 5 lines
...
Signed-off-by: ...This was suggested by Stephen Hemminger as having a precedent in
Linux
Quoted 1 line
kernel. Interestingly enough first use of this tag in kernel source
was
Quoted 1 line
this year in January.
I don't get it! Should employees start adding Sponsored-by: <Employer name> to their commits, when doing it as part of their job? And how about contract developers, should they also add a Sponsored-by: <Company name> tag, since they are working under contract and getting paid by that company?
Can someone please provide a reference to the discussion about this on the LKML? I'm curious why they felt the need for such a tag.
Quoted 2 lines
The precedent is not strong enough to be copied in my opinion.
I agree. Also, if it is an acceptable signature tag, the checkpatch.pl script should be updated:
https://elixir.bootlin.com/linux/v5.18-rc6/source/scripts/checkpatch.pl#L607
Quoted 24 lines · Morten Brørup
Quoted 9 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, 9 May 2022 14.3109/05/2022 14:24, Stanisław Kardach:
Quoted 1 line
On Fri, May 6, 2022 at 11:13 AM David Marchand
Quoted 2 lines
Quoted 1 line · wrote:
About the new "Sponsored-by" tag, it should not raise warnings in
Quoted 8 lines
the
Quoted 4 lines
Quoted 2 lines
CI if we agree on its addition.
I'll modify it in V2 to be in form of:
Sponsored by: StarFive TechnologyYou mean removing the hyphen?
I think it is better to keep it so all tags have the same format.I agree with Thomas. Please keep the hyphen.
Quoted 4 lines
Quoted 4 lines
...
Signed-off-by: ...
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
This was suggested by Stephen Hemminger as having a precedent in
Linux
Quoted 1 line
kernel. Interestingly enough first use of this tag in kernel source
was
Quoted 1 line
this year in January.
I don't get it! Should employees start adding Sponsored-by: <Employer name> to their commits, when doing it as part of their job? And how about contract developers, should they also add a Sponsored-by: <Company name> tag, since they are working under contract and getting paid by that company?
If I understand correctly, the concern about the commit log staying technical and not introducing extra elements not beneficial to the project, correct?
In the scope of this particular patchset, the companies sponsoring the work are in copyrights for appropriate files, so I can remove the tags.
For my own curiosity, what would be a proper way for a contract developer to mark the company sponsoring the work? Some companies may not care, others will. Maybe it would be beneficial to add a comment on this into the contributing guide (or it's already there and I've missed it)?
Quoted 2 lines
Can someone please provide a reference to the discussion about this on the LKML? I'm curious why they felt the need for such a tag.
Actually I can't find any discussion on this. Perhaps it was missed
because: "Sponsored by" (without a hyphen) doesn't trigger checkpatch and only 2 patches (6 and 7) in whole patchset contain it. Patchset for reference:
https://www.spinics.net/lists/linux-wireless/msg220474.html
Quoted 9 lines
Quoted 3 lines
The precedent is not strong enough to be copied in my opinion.
I agree. Also, if it is an acceptable signature tag, the checkpatch.pl script should be updated:
https://elixir.bootlin.com/linux/v5.18-rc6/source/scripts/checkpatch.pl#L607
11/05/2022 12:28, Stanisław Kardach:
Quoted 22 lines · Morten Brørup
Quoted 21 lines
Quoted 11 lines
From: Thomas Monjalon [mailto:[email protected]] 09/05/2022 14:24, Stanisław Kardach:
Quoted 6 lines · David Marchand
Quoted 2 lines
About the new "Sponsored-by" tag, it should not raise warnings in the CI if we agree on its addition.
I'll modify it in V2 to be in form of:
Sponsored by: StarFive TechnologyYou mean removing the hyphen?
I think it is better to keep it so all tags have the same format.I agree with Thomas. Please keep the hyphen.
Quoted 6 lines
Quoted 6 lines
...
Signed-off-by: ...This was suggested by Stephen Hemminger as having a precedent in Linux kernel. Interestingly enough first use of this tag in kernel source was this year in January.
Quoted 6 lines
Quoted 6 lines
I don't get it! Should employees start adding
Sponsored-by: <Employer name> to their commits,
when doing it as part of their job?
And how about contract developers, should they also add a
Sponsored-by: <Company name> tag,
since they are working under contract and getting paid by that company?
Nothing is mandatory.
It is just a way to give visibility of the sponsorship if requested.
Quoted 11 lines
If I understand correctly, the concern about the commit log staying technical and not introducing extra elements not beneficial to the project, correct?
In the scope of this particular patchset, the companies sponsoring the work are in copyrights for appropriate files, so I can remove the tags.
For my own curiosity, what would be a proper way for a contract developer to mark the company sponsoring the work? Some companies may not care, others will. Maybe it would be beneficial to add a comment on this into the contributing guide (or it's already there and I've missed it)?
I don't know how to do it better.
Any other suggestions?
Quoted 5 lines · Stanisław Kardach
Quoted 2 lines
Testing all riscv configs in
test-meson-buils.shseems too much to me. Is there a real value to test both current targets?It's for sanity and compilation coverage testing. I.e. SiFive variant has a specific build config which does not require extra barriers when reading time and cycle registers for
rte_rdtsc_precise(). I want to make sure that if anyone changes some code based on configuration flags, it gets at least compile-checked. I believe similar thing is done for Aarch64 builds.
As far as I experienced, building all those aarch64 combinations never revealed any specific platform compilation issue.
It only consumes cpu, disk and our (maintainers) time.
I proposed to Thomas to shrink aarch64 builds list not so long ago :-).
The best would be for SiFive to provide a system for the CI to do those checks on their variant.
Quoted 8 lines
Quoted 2 lines
About the new "Sponsored-by" tag, it should not raise warnings in the CI if we agree on its addition.
I'll modify it in V2 to be in form of:
Sponsored by: StarFive Technology
...
Signed-off-by: ...
This was suggested by Stephen Hemminger as having a precedent in Linux kernel. Interestingly enough first use of this tag in kernel source was this year in January.
I don't have an opinion on the spelling.
At the moment, the checks raise a warning:
http://mails.dpdk.org/archives/test-report/2022-May/278580.html
My point is that for this new tag, either checkpatch.pl in kernel handles it (which I don't think it is the case) or we need to disable the signature check in checkpatch.pl and something is added in dpdk checkpatches.sh to accept all known tags.
Quoted 6 lines
Quoted 3 lines
In general, please avoid letting arch specific headers leak internal/non
rte_prefixed helpers out of them.
For example, I noticed aRV64_CSRRmacro that can be undefined after usage.Thanks for noticing. I'l fix this one in V2.
There are 2 other symbols that leak but on purpose (out of a better idea):vect_load_128()andvect_and(). Both are used inl3fwd_emto simulate vector operations. Other platforms reference their intrinsics straight in thel3fwd_em.c. As I don't have support for vector ops and I wanted to indicate thatxmm_tshould be an isolated API, I've put both inrte_vect.h. That said I'm not happy with this solution and am open to suggestions on how to solve it neatly.
I'll try to have a look in the next revision.
Quoted 6 lines
Quoted 3 lines
Patch 3 is huge, not sure it is easy to split, did you consider doing so?
It seems to me the nature of a new EAL implementation, I have to include all symbols, otherwise DPDK won't compile.
Alternatively I could have a huge initial patch with empty stubs that would be filled in later commits. Downside of this approach is that it's hard to verify each commit separately as tests will fail until all implementation is there, so the division is only visual.
If you are sure there is nothing that can be separated, let's keep it whole.
Signature · 1 line
David Marchand
Quoted 33 lines · David Marchand
Quoted 4 lines · Stanisław Kardach
Quoted 2 lines
Testing all riscv configs in
test-meson-buils.shseems too much to me. Is there a real value to test both current targets?It's for sanity and compilation coverage testing. I.e. SiFive variant
has a specific build config which does not require extra barriers when reading time and cycle registers for
rte_rdtsc_precise(). I want to make sure that if anyone changes some code based on configuration flags, it gets at least compile-checked.Quoted 1 line
I believe similar thing is done for Aarch64 builds.
As far as I experienced, building all those aarch64 combinations never revealed any specific platform compilation issue.
It only consumes cpu, disk and our (maintainers) time.
I proposed to Thomas to shrink aarch64 builds list not so long ago :-).The best would be for SiFive to provide a system for the CI to do those checks on their variant.
Quoted 8 lines
Quoted 2 lines
About the new "Sponsored-by" tag, it should not raise warnings in the CI if we agree on its addition.
I'll modify it in V2 to be in form of:
Sponsored by: StarFive Technology
...
Signed-off-by: ...
This was suggested by Stephen Hemminger as having a precedent in Linuxkernel. Interestingly enough first use of this tag in kernel source was this year in January.
I don't have an opinion on the spelling.
Quoted 8 lines
At the moment, the checks raise a warning:
http://mails.dpdk.org/archives/test-report/2022-May/278580.htmlMy point is that for this new tag, either checkpatch.pl in kernel handles it (which I don't think it is the case) or we need to disable the signature check in checkpatch.pl and something is added in dpdk
checkpatches.shto accept all known tags.
BAD_SIGN_OFF handles more than just tag names (in total there's 10 cases checked). I'm not sure replicating this to checkpatches.sh is worth the maintenance.
Alternatively I could ignore BAD_SIGN_OFF on initial checkpatch.pl run and then run it again with just the BAD_SIGN_OFF type and filter out the result. In that case, what would be the acceptable content of Sponsored-by tag? For line:
Sponsored-by: StarFive Technology
Current checkpatch.pl generates (used --terse for brevity):
0001-eal-add-initial-support-for-RISC-V-architecture.patch:55:
WARNING:BAD_SIGN_OFF: Non-standard signature: Sponsored-by:
0001-eal-add-initial-support-for-RISC-V-architecture.patch:55:
ERROR:BAD_SIGN_OFF: Unrecognized email address: 'StarFive Technology'
Using "Sponsored by:" does not trigger checks above (still feels like a hack).
Quoted 39 lines
Quoted 4 lines
Quoted 4 lines
In general, please avoid letting arch specific headers leak internal/non
rte_prefixed helpers out of them.
For example, I noticed aRV64_CSRRmacro that can be undefined afterusage.
Quoted 3 lines
Thanks for noticing. I'l fix this one in V2.
There are 2 other symbols that leak but on purpose (out of a betteridea):
vect_load_128()andvect_and(). Both are used inl3fwd_emto simulate vector operations. Other platforms reference their intrinsics straight in thel3fwd_em.c. As I don't have support for vector ops and I wanted to indicate thatxmm_tshould be an isolated API, I've put both inrte_vect.h. That said I'm not happy with this solution and am open to suggestions on how to solve it neatly.I'll try to have a look in the next revision.
Quoted 3 lines
Quoted 3 lines
Patch 3 is huge, not sure it is easy to split, did you consider doing
so?
Quoted 2 lines
It seems to me the nature of a new EAL implementation, I have to include
all symbols, otherwise DPDK won't compile.
Quoted 1 line
Alternatively I could have a huge initial patch with empty stubs that
would be filled in later commits. Downside of this approach is that it's hard to verify each commit separately as tests will fail until all implementation is there, so the division is only visual.
If you are sure there is nothing that can be separated, let's keep it whole.
--
David Marchand
10/05/2022 13:21, Stanisław Kardach:
Quoted 37 lines
Quoted 13 lines · David Marchand
Quoted 8 lines
Quoted 2 lines
About the new "Sponsored-by" tag, it should not raise warnings in the CI if we agree on its addition.
I'll modify it in V2 to be in form of:
Sponsored by: StarFive Technology
...
Signed-off-by: ...
This was suggested by Stephen Hemminger as having a precedent in Linuxkernel. Interestingly enough first use of this tag in kernel source was this year in January.
I don't have an opinion on the spelling.
Quoted 8 lines
At the moment, the checks raise a warning:
http://mails.dpdk.org/archives/test-report/2022-May/278580.htmlMy point is that for this new tag, either checkpatch.pl in kernel handles it (which I don't think it is the case) or we need to disable the signature check in checkpatch.pl and something is added in dpdk
checkpatches.shto accept all known tags.
BAD_SIGN_OFFhandles more than just tag names (in total there's 10 cases checked). I'm not sure replicating this tocheckpatches.shis worth the maintenance.
Alternatively I could ignoreBAD_SIGN_OFFon initial checkpatch.pl run and then run it again with just theBAD_SIGN_OFFtype and filter out the result. In that case, what would be the acceptable content of Sponsored-by tag? For line:
Sponsored-by: StarFive Technology
Current checkpatch.pl generates (used --terse for brevity):
0001-eal-add-initial-support-for-RISC-V-architecture.patch:55:
WARNING:BAD_SIGN_OFF: Non-standard signature: Sponsored-by:
0001-eal-add-initial-support-for-RISC-V-architecture.patch:55:
ERROR:BAD_SIGN_OFF: Unrecognized email address: 'StarFive Technology'
Quoted 2 lines
Using "Sponsored by:" does not trigger checks above (still feels like a hack).
Agree it is a hack,
and not having the hyphen breaks my Vim colouring :)
We can ignore this checkpatch warning, that's fine.
Quoted 11 lines · Thomas Monjalon
10/05/2022 13:21, Stanisław Kardach:
Quoted 3 lines
Using "Sponsored by:" does not trigger checks above (still feels like a hack).
Agree it is a hack,
and not having the hyphen breaks my Vim colouring :)We can ignore this checkpatch warning, that's fine.
Just to be sure before I post V2 - do you mean to ignore
BAD_SIGN_OFFin
checkpatches.sh or rather somewhere in CI configuration?
10/05/2022 16:00, Stanisław Kardach:
Quoted 7 lines · Thomas Monjalon
Quoted 6 lines
10/05/2022 13:21, Stanisław Kardach:
Quoted 3 lines
Using "Sponsored by:" does not trigger checks above (still feels like a hack).
Quoted 7 lines
Quoted 6 lines
Agree it is a hack,
and not having the hyphen breaks my Vim colouring :)We can ignore this checkpatch warning, that's fine.
Just to be sure before I post V2 - do you mean to ignore
BAD_SIGN_OFFin
checkpatches.shor rather somewhere in CI configuration?
Yes I mean CI will return BAD_SIGN_OFF, we'll take note, but it won't be a blocker to accept the patch.
The CI can return minor warnings, that's OK.
We prefer avoiding the warnings, because it is more work
to check all the warnings manually, but I don't see a better solution here.
v2 cover Introduce support for RISC-V architecture
In reply to Stanislaw KardachThis patchset adds support for building and running DPDK on 64bit RISC-V architecture. The initial support targets rv64gc (rv64imafdc) ISA and was tested on SiFive Unmatched development board with the Freedom U740 SoC running Linux (freedom-u-sdk based kernel).
I have tested this codebase using DPDK unit and perf tests as well as test-pmd, l2fwd and l3fwd examples.
The NIC attached to the DUT was Intel X520-DA2 which uses ixgbe PMD. On the UIO side, since U740 does not have an IOMMU, I've used igb_uio, uio_pci_generic and vfio-pci noiommu drivers.
Functional verification done using meson tests. fast-tests suite passing with the default config.
PMD verification done using a Intel x520-DA2 NIC (ixgbe) and the test-pmd application. Packet transfer checked using all UIO drivers available for non-IOMMU platforms: uio_pci_generic, vfio-pci noiommu and igb_uio.
The i40e PMD driver is disabled on RISC-V as the rv64gc ISA has no vector operations.
RISCV support is currently limited to Linux as the time measurement frequency discovery is tied to reading a device-tree node via procfs.
Clang compilation currently not supported due to issues with missing relocation relaxation.
Commit 1 introduces EAL and build system support for RISC-V architecture
as well as documentation updates.
Commits 2-5 add missing defines and stubs to enable RISC-V operation in
non-EAL parts.
Commit 6 adds RISC-V specific cpuflags test.
Commits 7-8 add RISC-V build testing to test-meson-builds.sh and github CI.
I appreciate Your comments and feedback.
Best Regards,
Stanislaw Kardach
v2:
- Separate bug-fixes into separate series.
- Prevent RV64_CSRR leak to API users.
- Limit test-meson-builds.sh testing to a generic rv64gc configuration.
- Clean-up release notes and fix style issues.
Michal Mazurek (2):
eal: add initial support for RISC-V architecture test/cpuflags: add test for RISC-V cpu flag
Stanislaw Kardach (6):
net/ixgbe: enable vector stubs for RISC-V
net/memif: set memfd syscall ID on RISC-V
net/tap: set BPF syscall ID for RISC-V
examples/l3fwd: enable RISC-V operation
devtools: add RISC-V to test-meson-builds.sh
ci: add RISCV64 cross compilation job
---
NOTE: I have added maintainers for each commit based on MAINTAINERS file.
However some modules (l3fwd, net/tap and cpuflags unit tests) do not have any maintainers assigned, hence I've targeted [email protected] mailing list as if it was a commit adding new files.
.ci/linux-build.sh | 4 + .github/workflows/build.yml | 11 +- MAINTAINERS | 6 + app/test/test_cpuflags.c | 81 ++++++++++ app/test/test_xmmt_ops.h | 16 ++ config/meson.build | 2 + config/riscv/meson.build | 143 ++++++++++++++++++ config/riscv/riscv64_linux_gcc | 17 +++ config/riscv/riscv64_sifive_u740_linux_gcc | 19 +++ devtools/test-meson-builds.sh | 6 + doc/guides/contributing/design.rst | 2 +- .../linux_gsg/cross_build_dpdk_for_riscv.rst | 125 +++++++++++++++ doc/guides/linux_gsg/index.rst | 1 + doc/guides/nics/features.rst | 5 + doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/ixgbe.ini | 1 + doc/guides/rel_notes/release_22_07.rst | 8 + drivers/net/i40e/meson.build | 6 + drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- drivers/net/memif/rte_eth_memif.h | 2 + drivers/net/tap/tap_bpf.h | 2 + examples/l3fwd/l3fwd_em.c | 8 + examples/l3fwd/l3fwd_fib.c | 2 + lib/eal/riscv/include/meson.build | 23 +++ lib/eal/riscv/include/rte_atomic.h | 52 +++++++ lib/eal/riscv/include/rte_byteorder.h | 44 ++++++ lib/eal/riscv/include/rte_cpuflags.h | 55 +++++++ lib/eal/riscv/include/rte_cycles.h | 105 +++++++++++++ lib/eal/riscv/include/rte_io.h | 21 +++ lib/eal/riscv/include/rte_mcslock.h | 18 +++ lib/eal/riscv/include/rte_memcpy.h | 63 ++++++++ lib/eal/riscv/include/rte_pause.h | 31 ++++ lib/eal/riscv/include/rte_pflock.h | 17 +++ lib/eal/riscv/include/rte_power_intrinsics.h | 22 +++ lib/eal/riscv/include/rte_prefetch.h | 50 ++++++ lib/eal/riscv/include/rte_rwlock.h | 44 ++++++ lib/eal/riscv/include/rte_spinlock.h | 67 ++++++++ lib/eal/riscv/include/rte_ticketlock.h | 21 +++ lib/eal/riscv/include/rte_vect.h | 55 +++++++ lib/eal/riscv/meson.build | 11 ++ lib/eal/riscv/rte_cpuflags.c | 122 +++++++++++++++ lib/eal/riscv/rte_cycles.c | 77 ++++++++++ lib/eal/riscv/rte_hypervisor.c | 13 ++ lib/eal/riscv/rte_power_intrinsics.c | 56 +++++++ meson.build | 2 + 45 files changed, 1437 insertions(+), 4 deletions(-) create mode 100644 config/riscv/meson.build create mode 100644 config/riscv/riscv64_linux_gcc create mode 100644 config/riscv/riscv64_sifive_u740_linux_gcc create mode 100644 doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst create mode 100644 lib/eal/riscv/include/meson.build create mode 100644 lib/eal/riscv/include/rte_atomic.h create mode 100644 lib/eal/riscv/include/rte_byteorder.h create mode 100644 lib/eal/riscv/include/rte_cpuflags.h create mode 100644 lib/eal/riscv/include/rte_cycles.h create mode 100644 lib/eal/riscv/include/rte_io.h create mode 100644 lib/eal/riscv/include/rte_mcslock.h create mode 100644 lib/eal/riscv/include/rte_memcpy.h create mode 100644 lib/eal/riscv/include/rte_pause.h create mode 100644 lib/eal/riscv/include/rte_pflock.h create mode 100644 lib/eal/riscv/include/rte_power_intrinsics.h create mode 100644 lib/eal/riscv/include/rte_prefetch.h create mode 100644 lib/eal/riscv/include/rte_rwlock.h create mode 100644 lib/eal/riscv/include/rte_spinlock.h create mode 100644 lib/eal/riscv/include/rte_ticketlock.h create mode 100644 lib/eal/riscv/include/rte_vect.h create mode 100644 lib/eal/riscv/meson.build create mode 100644 lib/eal/riscv/rte_cpuflags.c create mode 100644 lib/eal/riscv/rte_cycles.c create mode 100644 lib/eal/riscv/rte_hypervisor.c create mode 100644 lib/eal/riscv/rte_power_intrinsics.c
Signature · 1 line
2.30.2
PATCH v2 1/8 eal: add initial support for RISC-V architecture
From: Michal Mazurek <[email protected]>
Add all necessary elements for DPDK to compile and run EAL on SiFive Freedom U740 SoC which is based on SiFive U74-MC (ISA: rv64imafdc) core complex.
This includes:
- EAL library implementation for rv64imafdc ISA.
- meson build structure for 'riscv' architecture. RTE_ARCH_RISCV define is added for architecture identification.
- xmm_t structure operation stubs as there is no vector support in the U74 core.
Compilation was tested on Ubuntu and Arch Linux using riscv64 toolchain. Clang compilation currently not supported due to issues with missing relocation relaxation.
Two rte_rdtsc() schemes are provided: stable low-resolution using rdtime (default) and unstable high-resolution using rdcycle. User can override the scheme by defining RTE_RISCV_RDTSC_USE_HPM=1 during compile time of both DPDK and the application. The reasoning for this is as follows. The RISC-V ISA mandates that clock read by rdtime has to be of constant period and synchronized between all hardware threads within 1 tick (chapter 10.1 in version 20191213 of RISC-V spec).
However this clock may not be of high-enough frequency for dataplane uses. I.e. on HiFive Unmatched (FU740) it is 1MHz.
There is a high-resolution alternative in form of rdcycle which is clocked at the core clock frequency. The drawbacks are that it may be disabled during sleep (WFI) and its frequency might change due to DVFS.
The platform is currently marked as linux-only because rte_cycles implementation uses the timebase-frequency device-tree node read through the proc file system. Such approach was chosen because Linux kernel depends on the presence of this device-tree node.
The i40e PMD driver is disabled on RISC-V as the rv64gc ISA has no vector operations.
The compilation of following modules has been disabled by this commit and will be re-enabled in later commits as fixes are introduced:
net/ixgbe, net/memif, net/tap, example/l3fwd.
Known checkpatch errors/warnings:
- ERROR:COMPLEX_MACRO in rte_atomic.h and rte_cycles.h due to inline assembly declarations.
- vector_size compiler attribute used in rte_vect.h directly.
- rte_*mb() used directly in rte_atomic.h to reduce code duplication.
- __atomic_thread_fence() used to implement rte_atomic_thread_fence().
---
Depends-on: series-22867 ("test/ring: remove excessive inlining")
Depends-on: series-22868 ("lpm: add a scalar version of lookupx4 function")
Depends-on: series-22869 ("examples/l3fwd: fix scalar LPM compilation")
--- MAINTAINERS | 6 + app/test/test_xmmt_ops.h | 16 ++ config/meson.build | 2 + config/riscv/meson.build | 143 ++++++++++++++++++ config/riscv/riscv64_linux_gcc | 17 +++ config/riscv/riscv64_sifive_u740_linux_gcc | 19 +++ doc/guides/contributing/design.rst | 2 +- .../linux_gsg/cross_build_dpdk_for_riscv.rst | 125 +++++++++++++++ doc/guides/linux_gsg/index.rst | 1 + doc/guides/nics/features.rst | 5 + doc/guides/nics/features/default.ini | 1 + doc/guides/rel_notes/release_22_07.rst | 8 + drivers/net/i40e/meson.build | 6 + drivers/net/ixgbe/meson.build | 6 + drivers/net/memif/meson.build | 5 + drivers/net/tap/meson.build | 5 + examples/l3fwd/meson.build | 6 + lib/eal/riscv/include/meson.build | 23 +++ lib/eal/riscv/include/rte_atomic.h | 52 +++++++ lib/eal/riscv/include/rte_byteorder.h | 44 ++++++ lib/eal/riscv/include/rte_cpuflags.h | 55 +++++++ lib/eal/riscv/include/rte_cycles.h | 105 +++++++++++++ lib/eal/riscv/include/rte_io.h | 21 +++ lib/eal/riscv/include/rte_mcslock.h | 18 +++ lib/eal/riscv/include/rte_memcpy.h | 63 ++++++++ lib/eal/riscv/include/rte_pause.h | 31 ++++ lib/eal/riscv/include/rte_pflock.h | 17 +++ lib/eal/riscv/include/rte_power_intrinsics.h | 22 +++ lib/eal/riscv/include/rte_prefetch.h | 50 ++++++ lib/eal/riscv/include/rte_rwlock.h | 44 ++++++ lib/eal/riscv/include/rte_spinlock.h | 67 ++++++++ lib/eal/riscv/include/rte_ticketlock.h | 21 +++ lib/eal/riscv/include/rte_vect.h | 55 +++++++ lib/eal/riscv/meson.build | 11 ++ lib/eal/riscv/rte_cpuflags.c | 122 +++++++++++++++ lib/eal/riscv/rte_cycles.c | 77 ++++++++++ lib/eal/riscv/rte_hypervisor.c | 13 ++ lib/eal/riscv/rte_power_intrinsics.c | 56 +++++++ meson.build | 2 + 39 files changed, 1341 insertions(+), 1 deletion(-) create mode 100644 config/riscv/meson.build create mode 100644 config/riscv/riscv64_linux_gcc create mode 100644 config/riscv/riscv64_sifive_u740_linux_gcc create mode 100644 doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst create mode 100644 lib/eal/riscv/include/meson.build create mode 100644 lib/eal/riscv/include/rte_atomic.h create mode 100644 lib/eal/riscv/include/rte_byteorder.h create mode 100644 lib/eal/riscv/include/rte_cpuflags.h create mode 100644 lib/eal/riscv/include/rte_cycles.h create mode 100644 lib/eal/riscv/include/rte_io.h create mode 100644 lib/eal/riscv/include/rte_mcslock.h create mode 100644 lib/eal/riscv/include/rte_memcpy.h create mode 100644 lib/eal/riscv/include/rte_pause.h create mode 100644 lib/eal/riscv/include/rte_pflock.h create mode 100644 lib/eal/riscv/include/rte_power_intrinsics.h create mode 100644 lib/eal/riscv/include/rte_prefetch.h create mode 100644 lib/eal/riscv/include/rte_rwlock.h create mode 100644 lib/eal/riscv/include/rte_spinlock.h create mode 100644 lib/eal/riscv/include/rte_ticketlock.h create mode 100644 lib/eal/riscv/include/rte_vect.h create mode 100644 lib/eal/riscv/meson.build create mode 100644 lib/eal/riscv/rte_cpuflags.c create mode 100644 lib/eal/riscv/rte_cycles.c create mode 100644 lib/eal/riscv/rte_hypervisor.c create mode 100644 lib/eal/riscv/rte_power_intrinsics.c
MAINTAINERS +6 -0
@@ -296,6 +296,12 @@ F: drivers/*/*/*_altivec.* F: app/*/*_altivec.* F: examples/*/*_altivec.* +RISC-V +M: Stanislaw Kardach <[email protected]> +F: config/riscv/ +F: doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst +F: lib/eal/riscv/ + Intel x86 M: Bruce Richardson <[email protected]> M: Konstantin Ananyev <[email protected]>
app/test/test_xmmt_ops.h +16 -0
@@ -1,5 +1,8 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2015 Cavium, Inc +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf */ #ifndef _TEST_XMMT_OPS_H_
@@ -49,6 +52,19 @@ vect_set_epi32(int i3, int i2, int i1, int i0)return data; } +#elif defined(RTE_ARCH_RISCV ) + +#define vect_loadu_sil128 (p) vect_load_128(p) + +/* sets the 4 signed 32-bit integer values and returns the xmm_t variable */ +static __rte_always_inline xmm_t +vect_set_epi32 (int i3,int i2,int i1,int i0) +{ +xmm_t data = (xmm_t ){i0, i1, i2, i3}; + +return data; +} +#endif #endif /* _TEST_XMMT_OPS_H_ */
config/meson.build +2 -0
@@ -121,6 +121,8 @@ if cpu_instruction_set == 'generic' cpu_instruction_set = 'generic' elif host_machine.cpu_family().startswith('ppc') cpu_instruction_set = 'power8' + elif host_machine.cpu_family().startswith('riscv') + cpu_instruction_set = 'riscv' endif endif
config/riscv/meson.build new file +143 -0
143 lines not on this page · raw message
config/riscv/riscv64_linux_gcc new file +17 -0
@@ -0,0 +1,17 @@ +[binaries] +c = 'riscv64-linux-gnu-gcc' +cpp = 'riscv64-linux-gnu-g++' +ar = 'riscv64-linux-gnu-ar' +strip = 'riscv64-linux-gnu-strip' +pcap-config = '' +pkgconfig = 'riscv64-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'riscv64' +cpu = 'rv64gc' +endian = 'little' + +[properties] +vendor_id = 'generic' +arch_id = 'generic'
config/riscv/riscv64_sifive_u740_linux_gcc new file +19 -0
@@ -0,0 +1,19 @@ +[binaries] +c = 'riscv64-unknown-linux-gnu-gcc' +cpp = 'riscv64-unknown-linux-gnu-g++' +ar = 'riscv64-unknown-linux-gnu-ar' +strip = 'riscv64-unknown-linux-gnu-strip' +pcap-config = '' +pkgconfig = 'riscv64-unknown-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'riscv64' +cpu = 'rv64gc' +endian = 'little' + +[properties] +vendor_id = '0x489' +arch_id = '0x8000000000000007' +max_lcores = 4 +max_numa_nodes = 1
doc/guides/contributing/design.rst +1 -1
@@ -42,7 +42,7 @@ Per Architecture Sources The following macro options can be used: * ``RTE_ARCH`` is a string that contains the name of the architecture. -* ``RTE_ARCH_I686``, ``RTE_ARCH_X86_64``, ``RTE_ARCH_X86_X32``, ``RTE_ARCH_PPC_64``, ``RTE_ARCH_ARM``, ``RTE_ARCH_ARMv7`` or ``RTE_ARCH_ARM64`` are defined only if we are building for those architectures. +* ``RTE_ARCH_I686``, ``RTE_ARCH_X86_64``, ``RTE_ARCH_X86_X32``, ``RTE_ARCH_PPC_64``, ``RTE_ARCH_RISCV``, ``RTE_ARCH_ARM``, ``RTE_ARCH_ARMv7`` or ``RTE_ARCH_ARM64`` are defined only if we are building for those architectures. Per Execution Environment Sources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +125 -0
125 lines not on this page · raw message
doc/guides/linux_gsg/index.rst +1 -0
@@ -14,6 +14,7 @@ Getting Started Guide for Linux sys_reqs build_dpdk cross_build_dpdk_for_arm64 + cross_build_dpdk_for_riscv linux_drivers build_sample_apps linux_eal_parameters
doc/guides/nics/features.rst +5 -0
@@ -855,6 +855,11 @@ x86-64 Support 64bits x86 architecture. +rv64 +---- + +Support 64-bit RISC-V architecture. + .. _nic_features_usage_doc:
doc/guides/nics/features/default.ini +1 -0
@@ -74,6 +74,7 @@ ARMv8 = Power8 = x86-32 = x86-64 = +rv64 = Usage doc = Design doc = Perf doc =
doc/guides/rel_notes/release_22_07.rst +8 -0
@@ -55,6 +55,14 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added initial RISC-V architecture support.*** + + Added EAL implementation for RISC-V architecture. The initial device the + porting was tested on is a HiFive Unmatched development board based on the + SiFive Freedom U740 SoC. In theory this implementation should work with any + ``rv64gc`` ISA compatible implementation with MMU supporting a reasonable + address space size (U740 uses sv39 MMU). + * **Updated Intel iavf driver.** * Added Tx QoS queue rate limitation support.
drivers/net/i40e/meson.build +6 -0
@@ -1,6 +1,12 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +if arch_subdir == 'riscv' + build = false + reason = 'riscv arch not supported' + subdir_done() +endif + cflags += ['-DPF_DRIVER', '-DVF_DRIVER', '-DINTEGRATED_VF',
drivers/net/ixgbe/meson.build +6 -0
@@ -1,6 +1,12 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +if arch_subdir == 'riscv' + build = false + reason = 'riscv arch not supported' + subdir_done() +endif + cflags += ['-DRTE_LIBRTE_IXGBE_BYPASS'] subdir('base')
drivers/net/memif/meson.build +5 -0
@@ -5,6 +5,11 @@ if not is_linux build = false reason = 'only supported on Linux' endif +if arch_subdir == 'riscv' + build = false + reason = 'riscv arch not supported' + subdir_done() +endif sources = files( 'memif_socket.c',
drivers/net/tap/meson.build +5 -0
@@ -5,6 +5,11 @@ if not is_linux build = false reason = 'only supported on Linux' endif +if arch_subdir == 'riscv' + build = false + reason = 'riscv arch not supported' + subdir_done() +endif sources = files( 'rte_eth_tap.c', 'tap_bpf_api.c',
examples/l3fwd/meson.build +6 -0
@@ -6,6 +6,12 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' +if dpdk_conf.has('RTE_ARCH_RISCV') + build = false + reason = 'riscv arch not supported' + subdir_done() +endif + allow_experimental_apis = true deps += ['hash', 'lpm', 'fib', 'eventdev'] sources = files(
lib/eal/riscv/include/meson.build new file +23 -0
@@ -0,0 +1,23 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2022 StarFive +# Copyright(c) 2022 SiFive +# Copyright(c) 2022 Semihalf + +arch_headers = files( + 'rte_atomic.h', + 'rte_byteorder.h', + 'rte_cpuflags.h', + 'rte_cycles.h', + 'rte_io.h', + 'rte_mcslock.h', + 'rte_memcpy.h', + 'rte_pause.h', + 'rte_pflock.h', + 'rte_power_intrinsics.h', + 'rte_prefetch.h', + 'rte_rwlock.h', + 'rte_spinlock.h', + 'rte_ticketlock.h', + 'rte_vect.h', +) +install_headers(arch_headers, subdir: get_option('include_subdir_arch'))
lib/eal/riscv/include/rte_atomic.h new file +52 -0
52 lines not on this page · raw message
lib/eal/riscv/include/rte_byteorder.h new file +44 -0
44 lines not on this page · raw message
lib/eal/riscv/include/rte_cpuflags.h new file +55 -0
55 lines not on this page · raw message
lib/eal/riscv/include/rte_cycles.h new file +105 -0
105 lines not on this page · raw message
lib/eal/riscv/include/rte_io.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2016 Cavium, Inc +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_IO_RISCV_H +#define RTE_IO_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_io.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_IO_RISCV_H */
lib/eal/riscv/include/rte_mcslock.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef RTE_MCSLOCK_RISCV_H +#define RTE_MCSLOCK_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_mcslock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_MCSLOCK_RISCV_H */
lib/eal/riscv/include/rte_memcpy.h new file +63 -0
63 lines not on this page · raw message
lib/eal/riscv/include/rte_pause.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_PAUSE_RISCV_H +#define RTE_PAUSE_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "rte_atomic.h" + +#include "generic/rte_pause.h" + +static inline void rte_pause (void ) +{ +/* Insert pause hint directly to be compatible with old compilers. +* This will work even on platforms without Zihintpause extension +* because this is a FENCE hint instruction which evaluates to NOP then. +*/ + asmvolatile (".int 0x0100000F" :::"memory" ); +} + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_PAUSE_RISCV_H */
lib/eal/riscv/include/rte_pflock.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2021 Microsoft Corporation +*/ +#ifndef RTE_PFLOCK_RISCV_H +#define RTE_PFLOCK_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_pflock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_PFLOCK_RISCV_H */
lib/eal/riscv/include/rte_power_intrinsics.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_POWER_INTRINSIC_RISCV_H +#define RTE_POWER_INTRINSIC_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rte_common.h> + +#include "generic/rte_power_intrinsics.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_POWER_INTRINSIC_RISCV_H */
lib/eal/riscv/include/rte_prefetch.h new file +50 -0
50 lines not on this page · raw message
lib/eal/riscv/include/rte_rwlock.h new file +44 -0
44 lines not on this page · raw message
lib/eal/riscv/include/rte_spinlock.h new file +67 -0
67 lines not on this page · raw message
lib/eal/riscv/include/rte_ticketlock.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_TICKETLOCK_RISCV_H +#define RTE_TICKETLOCK_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_ticketlock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_TICKETLOCK_RISCV_H */
lib/eal/riscv/include/rte_vect.h new file +55 -0
55 lines not on this page · raw message
lib/eal/riscv/meson.build new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation. + +subdir('include') + +sources += files( + 'rte_cpuflags.c', + 'rte_cycles.c', + 'rte_hypervisor.c', + 'rte_power_intrinsics.c', +)
lib/eal/riscv/rte_cpuflags.c new file +122 -0
122 lines not on this page · raw message
lib/eal/riscv/rte_cycles.c new file +77 -0
77 lines not on this page · raw message
lib/eal/riscv/rte_hypervisor.c new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#include "rte_hypervisor.h" + +enum rte_hypervisor +rte_hypervisor_get (void ) +{ +return RTE_HYPERVISOR_UNKNOWN ; +}
lib/eal/riscv/rte_power_intrinsics.c new file +56 -0
56 lines not on this page · raw message
meson.build +2 -0
@@ -50,6 +50,8 @@ elif host_machine.cpu_family().startswith('arm') or host_machine.cpu_family().st arch_subdir = 'arm' elif host_machine.cpu_family().startswith('ppc') arch_subdir = 'ppc' +elif host_machine.cpu_family().startswith('riscv') + arch_subdir = 'riscv' endif # configure the build, and make sure configs here and in config folder are
Signature · 1 line
2.30.2
PATCH v2 2/8 net/ixgbe: enable vector stubs for RISC-V
In reply to Stanislaw KardachRe-use vector processing stubs in ixgbe PMD defined for PPC for RISC-V. This enables ixgbe PMD usage in scalar mode on this architecture.
The ixgbe PMD driver was validated with Intel X520-DA2 NIC and the test-pmd application. Packet transfer checked using all UIO drivers available for non-IOMMU platforms: uio_pci_generic, vfio-pci noiommu and igb_uio.
--- doc/guides/nics/features/ixgbe.ini | 1 + drivers/net/ixgbe/ixgbe_rxtx.c | 4 ++-- drivers/net/ixgbe/meson.build | 6 ------ 3 files changed, 3 insertions(+), 8 deletions(-)
doc/guides/nics/features/ixgbe.ini +1 -0
@@ -54,6 +54,7 @@ Windows = Y ARMv8 = Y x86-32 = Y x86-64 = Y +rv64 = Y [rte_flow items] eth = Y
drivers/net/ixgbe/ixgbe_rxtx.c +2 -2
@@ -5957,8 +5957,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev,return 0 ; } -/* Stubs needed for linkage when RTE_ARCH_PPC_64 is set */ -#if defined(RTE_ARCH_PPC_64 ) +/* Stubs needed for linkage when RTE_ARCH_PPC_64 or RTE_ARCH_RISCV is set */ +#if defined(RTE_ARCH_PPC_64 ) || defined(RTE_ARCH_RISCV )int ixgbe_rx_vec_dev_conf_condition_check(struct rte_eth_dev __rte_unused *dev) {
drivers/net/ixgbe/meson.build +0 -6
@@ -1,12 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -if arch_subdir == 'riscv' - build = false - reason = 'riscv arch not supported' - subdir_done() -endif - cflags += ['-DRTE_LIBRTE_IXGBE_BYPASS'] subdir('base')
Signature · 1 line
2.30.2
PATCH v2 3/8 net/memif: set memfd syscall ID on RISC-V
In reply to Stanislaw KardachDefine the missing __NR_memfd_create syscall id to enable the memif PMD.
--- drivers/net/memif/meson.build | 5 ----- drivers/net/memif/rte_eth_memif.h | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/memif/meson.build +0 -5
@@ -5,11 +5,6 @@ if not is_linux build = false reason = 'only supported on Linux' endif -if arch_subdir == 'riscv' - build = false - reason = 'riscv arch not supported' - subdir_done() -endif sources = files( 'memif_socket.c',
drivers/net/memif/rte_eth_memif.h +2 -0
@@ -180,6 +180,8 @@ const char *memif_version(void);#define __NR_memfd_create 360#elif defined __i386__#define __NR_memfd_create 356 +#elif defined __riscv +#define __NR_memfd_create 279#else #error "__NR_memfd_create unknown for this architecture"#endif
Signature · 1 line
2.30.2
PATCH v2 4/8 net/tap: set BPF syscall ID for RISC-V
In reply to Stanislaw KardachDefine the missing __NR_bpf syscall id to enable the tap PMD.
--- drivers/net/tap/meson.build | 5 ----- drivers/net/tap/tap_bpf.h | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/tap/meson.build +0 -5
@@ -5,11 +5,6 @@ if not is_linux build = false reason = 'only supported on Linux' endif -if arch_subdir == 'riscv' - build = false - reason = 'riscv arch not supported' - subdir_done() -endif sources = files( 'rte_eth_tap.c', 'tap_bpf_api.c',
drivers/net/tap/tap_bpf.h +2 -0
@@ -101,6 +101,8 @@ union bpf_attr {# define __NR_bpf 351# elif defined(__powerpc__)# define __NR_bpf 361 +# elif defined(__riscv) +# define __NR_bpf 280# else # error __NR_bpf not defined# endif
Signature · 1 line
2.30.2
PATCH v2 5/8 examples/l3fwd: enable RISC-V operation
In reply to Stanislaw KardachAdd missing em_mask_key() implementation and fix l3fwd_common.h inclusion in FIB lookup functions to enable the l3fwd to be run on RISC-V.
--- examples/l3fwd/l3fwd_em.c | 8 ++++++++ examples/l3fwd/l3fwd_fib.c | 2 ++ examples/l3fwd/meson.build | 6 ------ 3 files changed, 10 insertions(+), 6 deletions(-)
examples/l3fwd/l3fwd_em.c +8 -0
@@ -239,6 +239,14 @@ em_mask_key(void *key, xmm_t mask) return vec_and(data, mask); } +#elif defined(RTE_ARCH_RISCV) +static inline xmm_t +em_mask_key (void *key,xmm_t mask) +{ +xmm_t data =vect_load_128 (key); + +return vect_and (data, mask); +}#else #error No vector engine (SSE, NEON, ALTIVEC) available, check your toolchain#endif
examples/l3fwd/l3fwd_fib.c +2 -0
@@ -18,6 +18,8 @@#include "l3fwd_neon.h" #elif definedRTE_ARCH_PPC_64 #include "l3fwd_altivec.h" +#else +#include "l3fwd_common.h" #endif #include "l3fwd_event.h" #include "l3fwd_route.h"
examples/l3fwd/meson.build +0 -6
@@ -6,12 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -if dpdk_conf.has('RTE_ARCH_RISCV') - build = false - reason = 'riscv arch not supported' - subdir_done() -endif - allow_experimental_apis = true deps += ['hash', 'lpm', 'fib', 'eventdev'] sources = files(
Signature · 1 line
2.30.2
PATCH v2 6/8 test/cpuflags: add test for RISC-V cpu flag
In reply to Stanislaw KardachFrom: Michal Mazurek <[email protected]>
Add checks for all flag values defined in the RISC-V misa CSR register.
--- app/test/test_cpuflags.c | 81 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)
app/test/test_cpuflags.c +81 -0
@@ -200,6 +200,87 @@ test_cpuflags(void)CHECK_FOR_FLAG (RTE_CPUFLAG_INVTSC );#endif +#if defined(RTE_ARCH_RISCV ) + +printf ("Check for RISCV_ISA_A:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_A ); + +printf ("Check for RISCV_ISA_B:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_B ); + +printf ("Check for RISCV_ISA_C:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_C ); + +printf ("Check for RISCV_ISA_D:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_D ); + +printf ("Check for RISCV_ISA_E:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_E ); + +printf ("Check for RISCV_ISA_F:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_F ); + +printf ("Check for RISCV_ISA_G:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_G ); + +printf ("Check for RISCV_ISA_H:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_H ); + +printf ("Check for RISCV_ISA_I:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_I ); + +printf ("Check for RISCV_ISA_J:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_J ); + +printf ("Check for RISCV_ISA_K:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_K ); + +printf ("Check for RISCV_ISA_L:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_L ); + +printf ("Check for RISCV_ISA_M:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_M ); + +printf ("Check for RISCV_ISA_N:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_N ); + +printf ("Check for RISCV_ISA_O:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_O ); + +printf ("Check for RISCV_ISA_P:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_P ); + +printf ("Check for RISCV_ISA_Q:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_Q ); + +printf ("Check for RISCV_ISA_R:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_R ); + +printf ("Check for RISCV_ISA_S:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_S ); + +printf ("Check for RISCV_ISA_T:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_T ); + +printf ("Check for RISCV_ISA_U:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_U ); + +printf ("Check for RISCV_ISA_V:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_V ); + +printf ("Check for RISCV_ISA_W:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_W ); + +printf ("Check for RISCV_ISA_X:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_X ); + +printf ("Check for RISCV_ISA_Y:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_Y ); + +printf ("Check for RISCV_ISA_Z:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_Z ); +#endif +/* * Check if invalid data is handled properly */
Signature · 1 line
2.30.2
PATCH v2 7/8 devtools: add RISC-V to test-meson-builds.sh
In reply to Stanislaw KardachValidate RISC-V compilation when test-meson-builds.sh is called. The check will be only performed if appropriate toolchain is present on the system (same as with other architectures).
--- devtools/test-meson-builds.sh | 6 ++++++ 1 file changed, 6 insertions(+)
devtools/test-meson-builds.sh +6 -0
@@ -275,6 +275,12 @@ for f in $srcdir/config/ppc/ppc* ; do build $targetdir $f ABI $use_shared done +# RISC-V configurations +for f in $srcdir/config/riscv/riscv* ; do + targetdir=build-$(basename $f | tr '_' '-' | cut -d'-' -f-2) + build $targetdir $f ABI $use_shared +done + # Test installation of the x86-generic target, to be used for checking # the sample apps build using the pkg-config file for cflags and libs load_env cc
Signature · 1 line
2.30.2
Re: [PATCH v2 7/8] devtools: add RISC-V to test-meson-builds.sh
Quoted 16 lines · Stanislaw Kardach
Validate RISC-V compilation when
test-meson-builds.shis called. The check will be only performed if appropriate toolchain is present on the system (same as with other architectures).Sponsored-by Frank Zhao <[email protected]>Sponsored-by Sam Grove <[email protected]>Signed-off-by Stanislaw Kardach <[email protected]>--- devtools/test-meson-builds.sh | 6 ++++++ 1 file changed, 6 insertions(+)devtools/test-meson-builds.sh +0
-0
devtools/test-meson-builds.sh for f in $srcdir/config/ppc/ppc* ; do · line 284
Quoted 10 lines
devtools/test-meson-builds.sh +6
-0@@ -275,6 +275,12 @@ for f in $srcdir/config/ppc/ppc* ; do build $targetdir $f ABI $use_shared done +# RISC-V configurations +for f in $srcdir/config/riscv/riscv* ; do + targetdir=build-$(basename $f | tr '_' '-' | cut -d'-' -f-2) + build $targetdir $f ABI $use_shared +done +
This should not be an iteration but a single build command. I'll re-send as v3.
Quoted 6 lines
devtools/test-meson-builds.sh +0
-0# Test installation of the x86-generic target, to be used for checking # the sample apps build using the pkg-config file for cflags and libs
load_envcc
--
2.30.2
PATCH v2 8/8 ci: add RISCV64 cross compilation job
In reply to Stanislaw KardachChecks cross-compilation using Ubuntu 20.04 x86.
--- .ci/linux-build.sh | 4 ++++ .github/workflows/build.yml | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)
.ci/linux-build.sh +4 -0
@@ -74,6 +74,10 @@ if [ "$PPC64LE" = "true" ]; then cross_file=config/ppc/ppc64le-power8-linux-gcc-ubuntu fi +if [ "$RISCV64" = "true" ]; then + cross_file=config/riscv/riscv64_linux_gcc +fi + if [ -n "$cross_file" ]; then OPTS="$OPTS --cross-file $cross_file" fi
.github/workflows/build.yml +10 -1
@@ -25,6 +25,7 @@ jobs: MINI: ${{ matrix.config.mini != '' }} PPC64LE: ${{ matrix.config.cross == 'ppc64le' }} REF_GIT_TAG: v22.03 + RISCV64: ${{ matrix.config.cross == 'riscv64' }} RUN_TESTS: ${{ contains(matrix.config.checks, 'tests') }} strategy:
@@ -73,6 +74,10 @@ jobs: compiler: gcc library: shared cross: ppc64le + - os: ubuntu-20.04 + compiler: gcc + library: shared + cross: riscv64 steps: - name: Checkout sources
@@ -131,8 +136,12 @@ jobs: if: env.PPC64LE == 'true' run: sudo apt install -y gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross pkg-config-powerpc-linux-gnu + - name: Install riscv64 cross compiling packages + if: env.RISCV64 == 'true' + run: sudo apt install -y gcc-riscv64-linux-gnu libc6-dev-riscv64-cross + pkg-config-riscv64-linux-gnu - name: Install test tools packages - if: env.AARCH64 != 'true' || env.PPC64LE != 'true' || env.RUN_TESTS == 'true' + if: env.AARCH64 != 'true' || env.PPC64LE != 'true' || env.RISCV64 != 'true' || env.RUN_TESTS == 'true' run: sudo apt install -y gdb - name: Install doc generation packages if: env.BUILD_DOCS == 'true'
Signature · 1 line
2.30.2
v3 cover Introduce support for RISC-V architecture
In reply to Stanislaw KardachThis patchset adds support for building and running DPDK on 64bit RISC-V architecture. The initial support targets rv64gc (rv64imafdc) ISA and was tested on SiFive Unmatched development board with the Freedom U740 SoC running Linux (freedom-u-sdk based kernel).
I have tested this codebase using DPDK unit and perf tests as well as test-pmd, l2fwd and l3fwd examples.
The NIC attached to the DUT was Intel X520-DA2 which uses ixgbe PMD. On the UIO side, since U740 does not have an IOMMU, I've used igb_uio, uio_pci_generic and vfio-pci noiommu drivers.
Functional verification done using meson tests. fast-tests suite passing with the default config.
PMD verification done using a Intel x520-DA2 NIC (ixgbe) and the test-pmd application. Packet transfer checked using all UIO drivers available for non-IOMMU platforms: uio_pci_generic, vfio-pci noiommu and igb_uio.
The i40e PMD driver is disabled on RISC-V as the rv64gc ISA has no vector operations.
RISCV support is currently limited to Linux as the time measurement frequency discovery is tied to reading a device-tree node via procfs.
Clang compilation currently not supported due to issues with missing relocation relaxation.
Commit 1 introduces EAL and build system support for RISC-V architecture
as well as documentation updates.
Commits 2-5 add missing defines and stubs to enable RISC-V operation in
non-EAL parts.
Commit 6 adds RISC-V specific cpuflags test.
Commits 7-8 add RISC-V build testing to test-meson-builds.sh and github CI.
I appreciate Your comments and feedback.
Best Regards,
Stanislaw Kardach
v3:
- Limit test-meson-builds.sh testing to a generic rv64gc configuration. Previous version was missing this change by mistake.
v2:
- Separate bug-fixes into separate series.
- Prevent RV64_CSRR leak to API users.
- Limit test-meson-builds.sh testing to a generic rv64gc configuration.
- Clean-up release notes and fix style issues.
Michal Mazurek (2):
eal: add initial support for RISC-V architecture test/cpuflags: add test for RISC-V cpu flag
Stanislaw Kardach (6):
net/ixgbe: enable vector stubs for RISC-V
net/memif: set memfd syscall ID on RISC-V
net/tap: set BPF syscall ID for RISC-V
examples/l3fwd: enable RISC-V operation
devtools: add RISC-V to test-meson-builds.sh
ci: add RISCV64 cross compilation job
---
NOTE: I have added maintainers for each commit based on MAINTAINERS file.
However some modules (l3fwd, net/tap and cpuflags unit tests) do not have any maintainers assigned, hence I've targeted [email protected] mailing list as if it was a commit adding new files.
.ci/linux-build.sh | 4 + .github/workflows/build.yml | 11 +- MAINTAINERS | 6 + app/test/test_cpuflags.c | 81 ++++++++++ app/test/test_xmmt_ops.h | 16 ++ config/meson.build | 2 + config/riscv/meson.build | 143 ++++++++++++++++++ config/riscv/riscv64_linux_gcc | 17 +++ config/riscv/riscv64_sifive_u740_linux_gcc | 19 +++ devtools/test-meson-builds.sh | 4 + doc/guides/contributing/design.rst | 2 +- .../linux_gsg/cross_build_dpdk_for_riscv.rst | 125 +++++++++++++++ doc/guides/linux_gsg/index.rst | 1 + doc/guides/nics/features.rst | 5 + doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/ixgbe.ini | 1 + doc/guides/rel_notes/release_22_07.rst | 8 + drivers/net/i40e/meson.build | 6 + drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- drivers/net/memif/rte_eth_memif.h | 2 + drivers/net/tap/tap_bpf.h | 2 + examples/l3fwd/l3fwd_em.c | 8 + examples/l3fwd/l3fwd_fib.c | 2 + lib/eal/riscv/include/meson.build | 23 +++ lib/eal/riscv/include/rte_atomic.h | 52 +++++++ lib/eal/riscv/include/rte_byteorder.h | 44 ++++++ lib/eal/riscv/include/rte_cpuflags.h | 55 +++++++ lib/eal/riscv/include/rte_cycles.h | 105 +++++++++++++ lib/eal/riscv/include/rte_io.h | 21 +++ lib/eal/riscv/include/rte_mcslock.h | 18 +++ lib/eal/riscv/include/rte_memcpy.h | 63 ++++++++ lib/eal/riscv/include/rte_pause.h | 31 ++++ lib/eal/riscv/include/rte_pflock.h | 17 +++ lib/eal/riscv/include/rte_power_intrinsics.h | 22 +++ lib/eal/riscv/include/rte_prefetch.h | 50 ++++++ lib/eal/riscv/include/rte_rwlock.h | 44 ++++++ lib/eal/riscv/include/rte_spinlock.h | 67 ++++++++ lib/eal/riscv/include/rte_ticketlock.h | 21 +++ lib/eal/riscv/include/rte_vect.h | 55 +++++++ lib/eal/riscv/meson.build | 11 ++ lib/eal/riscv/rte_cpuflags.c | 122 +++++++++++++++ lib/eal/riscv/rte_cycles.c | 77 ++++++++++ lib/eal/riscv/rte_hypervisor.c | 13 ++ lib/eal/riscv/rte_power_intrinsics.c | 56 +++++++ meson.build | 2 + 45 files changed, 1435 insertions(+), 4 deletions(-) create mode 100644 config/riscv/meson.build create mode 100644 config/riscv/riscv64_linux_gcc create mode 100644 config/riscv/riscv64_sifive_u740_linux_gcc create mode 100644 doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst create mode 100644 lib/eal/riscv/include/meson.build create mode 100644 lib/eal/riscv/include/rte_atomic.h create mode 100644 lib/eal/riscv/include/rte_byteorder.h create mode 100644 lib/eal/riscv/include/rte_cpuflags.h create mode 100644 lib/eal/riscv/include/rte_cycles.h create mode 100644 lib/eal/riscv/include/rte_io.h create mode 100644 lib/eal/riscv/include/rte_mcslock.h create mode 100644 lib/eal/riscv/include/rte_memcpy.h create mode 100644 lib/eal/riscv/include/rte_pause.h create mode 100644 lib/eal/riscv/include/rte_pflock.h create mode 100644 lib/eal/riscv/include/rte_power_intrinsics.h create mode 100644 lib/eal/riscv/include/rte_prefetch.h create mode 100644 lib/eal/riscv/include/rte_rwlock.h create mode 100644 lib/eal/riscv/include/rte_spinlock.h create mode 100644 lib/eal/riscv/include/rte_ticketlock.h create mode 100644 lib/eal/riscv/include/rte_vect.h create mode 100644 lib/eal/riscv/meson.build create mode 100644 lib/eal/riscv/rte_cpuflags.c create mode 100644 lib/eal/riscv/rte_cycles.c create mode 100644 lib/eal/riscv/rte_hypervisor.c create mode 100644 lib/eal/riscv/rte_power_intrinsics.c
Signature · 1 line
2.30.2
PATCH v3 1/8 eal: add initial support for RISC-V architecture
From: Michal Mazurek <[email protected]>
Add all necessary elements for DPDK to compile and run EAL on SiFive Freedom U740 SoC which is based on SiFive U74-MC (ISA: rv64imafdc) core complex.
This includes:
- EAL library implementation for rv64imafdc ISA.
- meson build structure for 'riscv' architecture. RTE_ARCH_RISCV define is added for architecture identification.
- xmm_t structure operation stubs as there is no vector support in the U74 core.
Compilation was tested on Ubuntu and Arch Linux using riscv64 toolchain. Clang compilation currently not supported due to issues with missing relocation relaxation.
Two rte_rdtsc() schemes are provided: stable low-resolution using rdtime (default) and unstable high-resolution using rdcycle. User can override the scheme by defining RTE_RISCV_RDTSC_USE_HPM=1 during compile time of both DPDK and the application. The reasoning for this is as follows. The RISC-V ISA mandates that clock read by rdtime has to be of constant period and synchronized between all hardware threads within 1 tick (chapter 10.1 in version 20191213 of RISC-V spec).
However this clock may not be of high-enough frequency for dataplane uses. I.e. on HiFive Unmatched (FU740) it is 1MHz.
There is a high-resolution alternative in form of rdcycle which is clocked at the core clock frequency. The drawbacks are that it may be disabled during sleep (WFI) and its frequency might change due to DVFS.
The platform is currently marked as linux-only because rte_cycles implementation uses the timebase-frequency device-tree node read through the proc file system. Such approach was chosen because Linux kernel depends on the presence of this device-tree node.
The i40e PMD driver is disabled on RISC-V as the rv64gc ISA has no vector operations.
The compilation of following modules has been disabled by this commit and will be re-enabled in later commits as fixes are introduced:
net/ixgbe, net/memif, net/tap, example/l3fwd.
Known checkpatch errors/warnings:
- ERROR:COMPLEX_MACRO in rte_atomic.h and rte_cycles.h due to inline assembly declarations.
- vector_size compiler attribute used in rte_vect.h directly.
- rte_*mb() used directly in rte_atomic.h to reduce code duplication.
- __atomic_thread_fence() used to implement rte_atomic_thread_fence().
---
Depends-on: series-22867 ("test/ring: remove excessive inlining")
Depends-on: series-22868 ("lpm: add a scalar version of lookupx4 function")
Depends-on: series-22869 ("examples/l3fwd: fix scalar LPM compilation")
--- MAINTAINERS | 6 + app/test/test_xmmt_ops.h | 16 ++ config/meson.build | 2 + config/riscv/meson.build | 143 ++++++++++++++++++ config/riscv/riscv64_linux_gcc | 17 +++ config/riscv/riscv64_sifive_u740_linux_gcc | 19 +++ doc/guides/contributing/design.rst | 2 +- .../linux_gsg/cross_build_dpdk_for_riscv.rst | 125 +++++++++++++++ doc/guides/linux_gsg/index.rst | 1 + doc/guides/nics/features.rst | 5 + doc/guides/nics/features/default.ini | 1 + doc/guides/rel_notes/release_22_07.rst | 8 + drivers/net/i40e/meson.build | 6 + drivers/net/ixgbe/meson.build | 6 + drivers/net/memif/meson.build | 5 + drivers/net/tap/meson.build | 5 + examples/l3fwd/meson.build | 6 + lib/eal/riscv/include/meson.build | 23 +++ lib/eal/riscv/include/rte_atomic.h | 52 +++++++ lib/eal/riscv/include/rte_byteorder.h | 44 ++++++ lib/eal/riscv/include/rte_cpuflags.h | 55 +++++++ lib/eal/riscv/include/rte_cycles.h | 105 +++++++++++++ lib/eal/riscv/include/rte_io.h | 21 +++ lib/eal/riscv/include/rte_mcslock.h | 18 +++ lib/eal/riscv/include/rte_memcpy.h | 63 ++++++++ lib/eal/riscv/include/rte_pause.h | 31 ++++ lib/eal/riscv/include/rte_pflock.h | 17 +++ lib/eal/riscv/include/rte_power_intrinsics.h | 22 +++ lib/eal/riscv/include/rte_prefetch.h | 50 ++++++ lib/eal/riscv/include/rte_rwlock.h | 44 ++++++ lib/eal/riscv/include/rte_spinlock.h | 67 ++++++++ lib/eal/riscv/include/rte_ticketlock.h | 21 +++ lib/eal/riscv/include/rte_vect.h | 55 +++++++ lib/eal/riscv/meson.build | 11 ++ lib/eal/riscv/rte_cpuflags.c | 122 +++++++++++++++ lib/eal/riscv/rte_cycles.c | 77 ++++++++++ lib/eal/riscv/rte_hypervisor.c | 13 ++ lib/eal/riscv/rte_power_intrinsics.c | 56 +++++++ meson.build | 2 + 39 files changed, 1341 insertions(+), 1 deletion(-) create mode 100644 config/riscv/meson.build create mode 100644 config/riscv/riscv64_linux_gcc create mode 100644 config/riscv/riscv64_sifive_u740_linux_gcc create mode 100644 doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst create mode 100644 lib/eal/riscv/include/meson.build create mode 100644 lib/eal/riscv/include/rte_atomic.h create mode 100644 lib/eal/riscv/include/rte_byteorder.h create mode 100644 lib/eal/riscv/include/rte_cpuflags.h create mode 100644 lib/eal/riscv/include/rte_cycles.h create mode 100644 lib/eal/riscv/include/rte_io.h create mode 100644 lib/eal/riscv/include/rte_mcslock.h create mode 100644 lib/eal/riscv/include/rte_memcpy.h create mode 100644 lib/eal/riscv/include/rte_pause.h create mode 100644 lib/eal/riscv/include/rte_pflock.h create mode 100644 lib/eal/riscv/include/rte_power_intrinsics.h create mode 100644 lib/eal/riscv/include/rte_prefetch.h create mode 100644 lib/eal/riscv/include/rte_rwlock.h create mode 100644 lib/eal/riscv/include/rte_spinlock.h create mode 100644 lib/eal/riscv/include/rte_ticketlock.h create mode 100644 lib/eal/riscv/include/rte_vect.h create mode 100644 lib/eal/riscv/meson.build create mode 100644 lib/eal/riscv/rte_cpuflags.c create mode 100644 lib/eal/riscv/rte_cycles.c create mode 100644 lib/eal/riscv/rte_hypervisor.c create mode 100644 lib/eal/riscv/rte_power_intrinsics.c
MAINTAINERS +6 -0
@@ -296,6 +296,12 @@ F: drivers/*/*/*_altivec.* F: app/*/*_altivec.* F: examples/*/*_altivec.* +RISC-V +M: Stanislaw Kardach <[email protected]> +F: config/riscv/ +F: doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst +F: lib/eal/riscv/ + Intel x86 M: Bruce Richardson <[email protected]> M: Konstantin Ananyev <[email protected]>
app/test/test_xmmt_ops.h +16 -0
@@ -1,5 +1,8 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2015 Cavium, Inc +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf */ #ifndef _TEST_XMMT_OPS_H_
@@ -49,6 +52,19 @@ vect_set_epi32(int i3, int i2, int i1, int i0)return data; } +#elif defined(RTE_ARCH_RISCV ) + +#define vect_loadu_sil128 (p) vect_load_128(p) + +/* sets the 4 signed 32-bit integer values and returns the xmm_t variable */ +static __rte_always_inline xmm_t +vect_set_epi32 (int i3,int i2,int i1,int i0) +{ +xmm_t data = (xmm_t ){i0, i1, i2, i3}; + +return data; +} +#endif #endif /* _TEST_XMMT_OPS_H_ */
config/meson.build +2 -0
@@ -121,6 +121,8 @@ if cpu_instruction_set == 'generic' cpu_instruction_set = 'generic' elif host_machine.cpu_family().startswith('ppc') cpu_instruction_set = 'power8' + elif host_machine.cpu_family().startswith('riscv') + cpu_instruction_set = 'riscv' endif endif
config/riscv/meson.build new file +143 -0
143 lines not on this page · raw message
config/riscv/riscv64_linux_gcc new file +17 -0
@@ -0,0 +1,17 @@ +[binaries] +c = 'riscv64-linux-gnu-gcc' +cpp = 'riscv64-linux-gnu-g++' +ar = 'riscv64-linux-gnu-ar' +strip = 'riscv64-linux-gnu-strip' +pcap-config = '' +pkgconfig = 'riscv64-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'riscv64' +cpu = 'rv64gc' +endian = 'little' + +[properties] +vendor_id = 'generic' +arch_id = 'generic'
config/riscv/riscv64_sifive_u740_linux_gcc new file +19 -0
@@ -0,0 +1,19 @@ +[binaries] +c = 'riscv64-unknown-linux-gnu-gcc' +cpp = 'riscv64-unknown-linux-gnu-g++' +ar = 'riscv64-unknown-linux-gnu-ar' +strip = 'riscv64-unknown-linux-gnu-strip' +pcap-config = '' +pkgconfig = 'riscv64-unknown-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'riscv64' +cpu = 'rv64gc' +endian = 'little' + +[properties] +vendor_id = '0x489' +arch_id = '0x8000000000000007' +max_lcores = 4 +max_numa_nodes = 1
doc/guides/contributing/design.rst +1 -1
@@ -42,7 +42,7 @@ Per Architecture Sources The following macro options can be used: * ``RTE_ARCH`` is a string that contains the name of the architecture. -* ``RTE_ARCH_I686``, ``RTE_ARCH_X86_64``, ``RTE_ARCH_X86_X32``, ``RTE_ARCH_PPC_64``, ``RTE_ARCH_ARM``, ``RTE_ARCH_ARMv7`` or ``RTE_ARCH_ARM64`` are defined only if we are building for those architectures. +* ``RTE_ARCH_I686``, ``RTE_ARCH_X86_64``, ``RTE_ARCH_X86_X32``, ``RTE_ARCH_PPC_64``, ``RTE_ARCH_RISCV``, ``RTE_ARCH_ARM``, ``RTE_ARCH_ARMv7`` or ``RTE_ARCH_ARM64`` are defined only if we are building for those architectures. Per Execution Environment Sources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +125 -0
125 lines not on this page · raw message
doc/guides/linux_gsg/index.rst +1 -0
@@ -14,6 +14,7 @@ Getting Started Guide for Linux sys_reqs build_dpdk cross_build_dpdk_for_arm64 + cross_build_dpdk_for_riscv linux_drivers build_sample_apps linux_eal_parameters
doc/guides/nics/features.rst +5 -0
@@ -855,6 +855,11 @@ x86-64 Support 64bits x86 architecture. +rv64 +---- + +Support 64-bit RISC-V architecture. + .. _nic_features_usage_doc:
doc/guides/nics/features/default.ini +1 -0
@@ -74,6 +74,7 @@ ARMv8 = Power8 = x86-32 = x86-64 = +rv64 = Usage doc = Design doc = Perf doc =
doc/guides/rel_notes/release_22_07.rst +8 -0
@@ -55,6 +55,14 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added initial RISC-V architecture support.*** + + Added EAL implementation for RISC-V architecture. The initial device the + porting was tested on is a HiFive Unmatched development board based on the + SiFive Freedom U740 SoC. In theory this implementation should work with any + ``rv64gc`` ISA compatible implementation with MMU supporting a reasonable + address space size (U740 uses sv39 MMU). + * **Updated Intel iavf driver.** * Added Tx QoS queue rate limitation support.
drivers/net/i40e/meson.build +6 -0
@@ -1,6 +1,12 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +if arch_subdir == 'riscv' + build = false + reason = 'riscv arch not supported' + subdir_done() +endif + cflags += ['-DPF_DRIVER', '-DVF_DRIVER', '-DINTEGRATED_VF',
drivers/net/ixgbe/meson.build +6 -0
@@ -1,6 +1,12 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +if arch_subdir == 'riscv' + build = false + reason = 'riscv arch not supported' + subdir_done() +endif + cflags += ['-DRTE_LIBRTE_IXGBE_BYPASS'] subdir('base')
drivers/net/memif/meson.build +5 -0
@@ -5,6 +5,11 @@ if not is_linux build = false reason = 'only supported on Linux' endif +if arch_subdir == 'riscv' + build = false + reason = 'riscv arch not supported' + subdir_done() +endif sources = files( 'memif_socket.c',
drivers/net/tap/meson.build +5 -0
@@ -5,6 +5,11 @@ if not is_linux build = false reason = 'only supported on Linux' endif +if arch_subdir == 'riscv' + build = false + reason = 'riscv arch not supported' + subdir_done() +endif sources = files( 'rte_eth_tap.c', 'tap_bpf_api.c',
examples/l3fwd/meson.build +6 -0
@@ -6,6 +6,12 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' +if dpdk_conf.has('RTE_ARCH_RISCV') + build = false + reason = 'riscv arch not supported' + subdir_done() +endif + allow_experimental_apis = true deps += ['hash', 'lpm', 'fib', 'eventdev'] sources = files(
lib/eal/riscv/include/meson.build new file +23 -0
@@ -0,0 +1,23 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2022 StarFive +# Copyright(c) 2022 SiFive +# Copyright(c) 2022 Semihalf + +arch_headers = files( + 'rte_atomic.h', + 'rte_byteorder.h', + 'rte_cpuflags.h', + 'rte_cycles.h', + 'rte_io.h', + 'rte_mcslock.h', + 'rte_memcpy.h', + 'rte_pause.h', + 'rte_pflock.h', + 'rte_power_intrinsics.h', + 'rte_prefetch.h', + 'rte_rwlock.h', + 'rte_spinlock.h', + 'rte_ticketlock.h', + 'rte_vect.h', +) +install_headers(arch_headers, subdir: get_option('include_subdir_arch'))
lib/eal/riscv/include/rte_atomic.h new file +52 -0
52 lines not on this page · raw message
lib/eal/riscv/include/rte_byteorder.h new file +44 -0
44 lines not on this page · raw message
lib/eal/riscv/include/rte_cpuflags.h new file +55 -0
55 lines not on this page · raw message
lib/eal/riscv/include/rte_cycles.h new file +105 -0
105 lines not on this page · raw message
lib/eal/riscv/include/rte_io.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2016 Cavium, Inc +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_IO_RISCV_H +#define RTE_IO_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_io.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_IO_RISCV_H */
lib/eal/riscv/include/rte_mcslock.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef RTE_MCSLOCK_RISCV_H +#define RTE_MCSLOCK_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_mcslock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_MCSLOCK_RISCV_H */
lib/eal/riscv/include/rte_memcpy.h new file +63 -0
63 lines not on this page · raw message
lib/eal/riscv/include/rte_pause.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_PAUSE_RISCV_H +#define RTE_PAUSE_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "rte_atomic.h" + +#include "generic/rte_pause.h" + +static inline void rte_pause (void ) +{ +/* Insert pause hint directly to be compatible with old compilers. +* This will work even on platforms without Zihintpause extension +* because this is a FENCE hint instruction which evaluates to NOP then. +*/ + asmvolatile (".int 0x0100000F" :::"memory" ); +} + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_PAUSE_RISCV_H */
lib/eal/riscv/include/rte_pflock.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2021 Microsoft Corporation +*/ +#ifndef RTE_PFLOCK_RISCV_H +#define RTE_PFLOCK_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_pflock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_PFLOCK_RISCV_H */
lib/eal/riscv/include/rte_power_intrinsics.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_POWER_INTRINSIC_RISCV_H +#define RTE_POWER_INTRINSIC_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rte_common.h> + +#include "generic/rte_power_intrinsics.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_POWER_INTRINSIC_RISCV_H */
lib/eal/riscv/include/rte_prefetch.h new file +50 -0
50 lines not on this page · raw message
lib/eal/riscv/include/rte_rwlock.h new file +44 -0
44 lines not on this page · raw message
lib/eal/riscv/include/rte_spinlock.h new file +67 -0
67 lines not on this page · raw message
lib/eal/riscv/include/rte_ticketlock.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_TICKETLOCK_RISCV_H +#define RTE_TICKETLOCK_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_ticketlock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_TICKETLOCK_RISCV_H */
lib/eal/riscv/include/rte_vect.h new file +55 -0
55 lines not on this page · raw message
lib/eal/riscv/meson.build new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation. + +subdir('include') + +sources += files( + 'rte_cpuflags.c', + 'rte_cycles.c', + 'rte_hypervisor.c', + 'rte_power_intrinsics.c', +)
lib/eal/riscv/rte_cpuflags.c new file +122 -0
122 lines not on this page · raw message
lib/eal/riscv/rte_cycles.c new file +77 -0
77 lines not on this page · raw message
lib/eal/riscv/rte_hypervisor.c new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#include "rte_hypervisor.h" + +enum rte_hypervisor +rte_hypervisor_get (void ) +{ +return RTE_HYPERVISOR_UNKNOWN ; +}
lib/eal/riscv/rte_power_intrinsics.c new file +56 -0
56 lines not on this page · raw message
meson.build +2 -0
@@ -50,6 +50,8 @@ elif host_machine.cpu_family().startswith('arm') or host_machine.cpu_family().st arch_subdir = 'arm' elif host_machine.cpu_family().startswith('ppc') arch_subdir = 'ppc' +elif host_machine.cpu_family().startswith('riscv') + arch_subdir = 'riscv' endif # configure the build, and make sure configs here and in config folder are
Signature · 1 line
2.30.2
Re: [PATCH v3 1/8] eal: add initial support for RISC-V architecture
Quoted 425 lines · Stanislaw Kardach
From: Michal Mazurek <[email protected]>
Add all necessary elements for DPDK to compile and run EAL on SiFive Freedom U740 SoC which is based on SiFive U74-MC (ISA: rv64imafdc) core complex.
This includes:
- EAL library implementation for rv64imafdc ISA.
- meson build structure for 'riscv' architecture.RTE_ARCH_RISCVdefine is added for architecture identification.
-xmm_tstructure operation stubs as there is no vector support in the U74 core.Compilation was tested on Ubuntu and Arch Linux using riscv64 toolchain. Clang compilation currently not supported due to issues with missing relocation relaxation.
Two
rte_rdtsc()schemes are provided: stable low-resolution using rdtime (default) and unstable high-resolution using rdcycle. User can override the scheme by defining RTE_RISCV_RDTSC_USE_HPM=1 during compile time of both DPDK and the application. The reasoning for this is as follows. The RISC-V ISA mandates that clock read by rdtime has to be of constant period and synchronized between all hardware threads within 1 tick (chapter 10.1 in version 20191213 of RISC-V spec).
However this clock may not be of high-enough frequency for dataplane uses. I.e. on HiFive Unmatched (FU740) it is 1MHz.
There is a high-resolution alternative in form of rdcycle which is clocked at the core clock frequency. The drawbacks are that it may be disabled during sleep (WFI) and its frequency might change due to DVFS.The platform is currently marked as linux-only because
rte_cyclesimplementation uses the timebase-frequency device-tree node read through the proc file system. Such approach was chosen because Linux kernel depends on the presence of this device-tree node.The i40e PMD driver is disabled on RISC-V as the rv64gc ISA has no vector operations.
The compilation of following modules has been disabled by this commit and will be re-enabled in later commits as fixes are introduced:
net/ixgbe, net/memif, net/tap, example/l3fwd.Known checkpatch errors/warnings:
- ERROR:COMPLEX_MACRO in
rte_atomic.handrte_cycles.hdue to inline assembly declarations.
-vector_sizecompiler attribute used inrte_vect.hdirectly.
- rte_*mb() used directly inrte_atomic.hto reduce code duplication.
-__atomic_thread_fence()used to implementrte_atomic_thread_fence().Sponsored-by Frank Zhao <[email protected]>Sponsored-by Sam Grove <[email protected]>Signed-off-by Michal Mazurek <[email protected]>Signed-off-by Stanislaw Kardach <[email protected]>---
Depends-on: series-22867 ("test/ring: remove excessive inlining")
Depends-on: series-22868 ("lpm: add a scalar version of lookupx4 function")
Depends-on: series-22869 ("examples/l3fwd: fix scalar LPM compilation")--- MAINTAINERS | 6 + app/test/test_xmmt_ops.h | 16 ++ config/meson.build | 2 + config/riscv/meson.build | 143 ++++++++++++++++++ config/riscv/riscv64_linux_gcc | 17 +++ config/riscv/riscv64_sifive_u740_linux_gcc | 19 +++ doc/guides/contributing/design.rst | 2 +- .../linux_gsg/cross_build_dpdk_for_riscv.rst | 125 +++++++++++++++ doc/guides/linux_gsg/index.rst | 1 + doc/guides/nics/features.rst | 5 + doc/guides/nics/features/default.ini | 1 + doc/guides/rel_notes/release_22_07.rst | 8 + drivers/net/i40e/meson.build | 6 + drivers/net/ixgbe/meson.build | 6 + drivers/net/memif/meson.build | 5 + drivers/net/tap/meson.build | 5 + examples/l3fwd/meson.build | 6 + lib/eal/riscv/include/meson.build | 23 +++ lib/eal/riscv/include/rte_atomic.h | 52 +++++++ lib/eal/riscv/include/rte_byteorder.h | 44 ++++++ lib/eal/riscv/include/rte_cpuflags.h | 55 +++++++ lib/eal/riscv/include/rte_cycles.h | 105 +++++++++++++ lib/eal/riscv/include/rte_io.h | 21 +++ lib/eal/riscv/include/rte_mcslock.h | 18 +++ lib/eal/riscv/include/rte_memcpy.h | 63 ++++++++ lib/eal/riscv/include/rte_pause.h | 31 ++++ lib/eal/riscv/include/rte_pflock.h | 17 +++ lib/eal/riscv/include/rte_power_intrinsics.h | 22 +++ lib/eal/riscv/include/rte_prefetch.h | 50 ++++++ lib/eal/riscv/include/rte_rwlock.h | 44 ++++++ lib/eal/riscv/include/rte_spinlock.h | 67 ++++++++ lib/eal/riscv/include/rte_ticketlock.h | 21 +++ lib/eal/riscv/include/rte_vect.h | 55 +++++++ lib/eal/riscv/meson.build | 11 ++ lib/eal/riscv/rte_cpuflags.c | 122 +++++++++++++++ lib/eal/riscv/rte_cycles.c | 77 ++++++++++ lib/eal/riscv/rte_hypervisor.c | 13 ++ lib/eal/riscv/rte_power_intrinsics.c | 56 +++++++ meson.build | 2 + 39 files changed, 1341 insertions(+), 1 deletion(-)create mode 100644 config/riscv/meson.build
create mode 100644 config/riscv/riscv64_linux_gcc
create mode 100644 config/riscv/riscv64_sifive_u740_linux_gcc create mode 100644doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rstcreate mode 100644lib/eal/riscv/include/meson.buildcreate mode 100644lib/eal/riscv/include/rte_atomic.hcreate mode 100644lib/eal/riscv/include/rte_byteorder.hcreate mode 100644lib/eal/riscv/include/rte_cpuflags.hcreate mode 100644lib/eal/riscv/include/rte_cycles.hcreate mode 100644lib/eal/riscv/include/rte_io.h
create mode 100644lib/eal/riscv/include/rte_mcslock.hcreate mode 100644lib/eal/riscv/include/rte_memcpy.hcreate mode 100644lib/eal/riscv/include/rte_pause.hcreate mode 100644lib/eal/riscv/include/rte_pflock.hcreate mode 100644lib/eal/riscv/include/rte_power_intrinsics.hcreate mode 100644lib/eal/riscv/include/rte_prefetch.hcreate mode 100644lib/eal/riscv/include/rte_rwlock.hcreate mode 100644lib/eal/riscv/include/rte_spinlock.hcreate mode 100644lib/eal/riscv/include/rte_ticketlock.hcreate mode 100644lib/eal/riscv/include/rte_vect.h
create mode 100644lib/eal/riscv/meson.build
create mode 100644lib/eal/riscv/rte_cpuflags.c
create mode 100644lib/eal/riscv/rte_cycles.c
create mode 100644lib/eal/riscv/rte_hypervisor.c
create mode 100644lib/eal/riscv/rte_power_intrinsics.cMAINTAINERS +6
-0@@ -296,6 +296,12 @@ F: drivers/*/*/*_altivec.* F: app/*/*_altivec.* F: examples/*/*_altivec.* +RISC-V +M: Stanislaw Kardach <[email protected]> +F: config/riscv/ +F: doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst +F: lib/eal/riscv/ + Intel x86 M: Bruce Richardson <[email protected]> M: Konstantin Ananyev <[email protected]>app/test/test_xmmt_ops.h +16
-0@@ -1,5 +1,8 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2015 Cavium, Inc +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf */ #ifndef _TEST_XMMT_OPS_H_@@ -49,6 +52,19 @@ vect_set_epi32(int i3, int i2, int i1, int i0)return data; } +#elif defined(RTE_ARCH_RISCV ) + +#define vect_loadu_sil128 (p) vect_load_128(p) + +/* sets the 4 signed 32-bit integer values and returns the xmm_t variable */ +static __rte_always_inline xmm_t +vect_set_epi32 (int i3,int i2,int i1,int i0) +{ +xmm_t data = (xmm_t ){i0, i1, i2, i3}; + +return data; +} +#endif #endif /* _TEST_XMMT_OPS_H_ */ config/meson.build +2
-0@@ -121,6 +121,8 @@ if cpu_instruction_set == 'generic' cpu_instruction_set = 'generic' elif host_machine.cpu_family().startswith('ppc') cpu_instruction_set = 'power8' + elif host_machine.cpu_family().startswith('riscv') + cpu_instruction_set = 'riscv' endif endifconfig/riscv/meson.build new file +143
-0@@ -0,0 +1,143 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation. +# Copyright(c) 2017 Cavium, Inc +# Copyright(c) 2021 PANTHEON.tech s.r.o. +# Copyright(c) 2022 StarFive +# Copyright(c) 2022 SiFive +# Copyright(c) 2022 Semihalf + +if not is_linux + error('Only Linux is supported at this point in time.') +endif + +if not dpdk_conf.get('RTE_ARCH_64') + error('Only 64-bit compiles are supported for this platform type') +endif + +dpdk_conf.set('RTE_ARCH', 'riscv') +dpdk_conf.set('RTE_ARCH_RISCV', 1) +dpdk_conf.set('RTE_FORCE_INTRINSICS', 1) + +# common flags to all riscv builds, with lowest priority +flags_common = [ + ['RTE_ARCH_RISCV', true], + ['RTE_CACHE_LINE_SIZE', 64], + # Set this to true if target emulates U-mode TIME CSR via M or S mode trap. + # This allows to remove a FENCE on rte_rdtsc_precise() as trap effectively + # acts as one. + ['RTE_RISCV_EMU_UTIME', false], + # Set this to true if target emulates U-mode CYCLE CSR via M or S mode trap. + # This allows to remove a FENCE on rte_rdtsc_precise() as trap effectively + # acts as one. + ['RTE_RISCV_EMU_UCYCLE', false], + # Manually set wall time clock frequency for the target. If 0, then it is + # read from /proc/device-tree/cpus/timebase-frequency. This property is + # guaranteed on Linux, as riscv time_init() requires it. + ['RTE_RISCV_TIME_FREQ', 0], +] + +## SoC-specific options. +# The priority is like this: arch > vendor > common. +# +# Note that currently there's no way of getting vendor/microarchitecture id +# values in userspace which is why the logic of choosing the right flag +# combination is strictly based on the values passed from a cross-file. +vendor_generic = { + 'description': 'Generic RISC-V', + 'flags': [ + ['RTE_MACHINE', '"riscv"'], + ['RTE_USE_C11_MEM_MODEL', true], + ['RTE_MAX_LCORE', 128], + ['RTE_MAX_NUMA_NODES', 2] + ], + 'arch_config': { + 'generic': {'machine_args': ['-march=rv64gc']} + } +} + +arch_config_riscv = { + '0x8000000000000007': { + 'machine_args': ['-march=rv64gc', '-mtune=sifive-7-series'], + 'flags': [ + ['RTE_RISCV_EMU_UTIME', true], + ['RTE_RISCV_EMU_UCYCLE', true] + ] + }, +} + +vendor_sifive = { + 'description': 'SiFive', + 'flags': [ + ['RTE_MACHINE', '"riscv"'], + ['RTE_USE_C11_MEM_MODEL', true], + ['RTE_MAX_LCORE', 4], + ['RTE_MAX_NUMA_NODES', 1], + ], + 'arch_config': arch_config_riscv +} + +vendors = { + 'generic': vendor_generic, + '0x489': vendor_sifive +} + +# Native/cross vendor/arch detection +if not meson.is_cross_build() + if machine == 'default' + # default build + vendor_id = 'generic' + arch_id = 'generic' + message('generic RISC-V') + else + vendor_id = 'generic' + arch_id = 'generic' + warning('RISC-V arch discovery not available, using generic!') + endif +else + # cross build + vendor_id = meson.get_cross_property('vendor_id') + arch_id = meson.get_cross_property('arch_id') +endif + +if vendors.has_key(vendor_id) + vendor_config = vendors[vendor_id] +else + error('Unsupported RISC-V vendor: @0@. '.format(vendor_id) + + 'Please add support for it or use the generic ' + + '(-Dmachine=generic) build.') +endif + +message('RISC-V vendor: ' + vendor_config['description']) +message('RISC-V architecture id: ' + arch_id) + +arch_config = vendor_config['arch_config'] +if arch_config.has_key(arch_id) + # use the specified arch_id machine args if found + arch_config = arch_config[arch_id] +else + # unknown micro-architecture id + error('Unsupported architecture @0@ of vendor @1@. ' + .format(arch_id, vendor_id) + + 'Please add support for it or use the generic ' + + '(-Dmachine=generic) build.') +endif + +# Concatenate flags respecting priorities. +dpdk_flags = flags_common + vendor_config['flags'] + arch_config.get('flags', []) + +# apply supported machine args +machine_args = [] # Clear previous machine args +foreach flag: arch_config['machine_args'] + if cc.has_argument(flag) + machine_args += flag + endif +endforeach + +# apply flags +foreach flag: dpdk_flags + if flag.length() > 0 + dpdk_conf.set(flag[0], flag[1]) + endif +endforeach +message('Using machine args: @0@'.format(machine_args)) +config/riscv/riscv64_linux_gcc new file +17
-0@@ -0,0 +1,17 @@ +[binaries] +c = 'riscv64-linux-gnu-gcc' +cpp = 'riscv64-linux-gnu-g++' +ar = 'riscv64-linux-gnu-ar' +strip = 'riscv64-linux-gnu-strip' +pcap-config = '' +pkgconfig = 'riscv64-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'riscv64' +cpu = 'rv64gc' +endian = 'little' + +[properties] +vendor_id = 'generic' +arch_id = 'generic'config/riscv/riscv64_sifive_u740_linux_gcc new file +19
-0@@ -0,0 +1,19 @@ +[binaries] +c = 'riscv64-unknown-linux-gnu-gcc' +cpp = 'riscv64-unknown-linux-gnu-g++' +ar = 'riscv64-unknown-linux-gnu-ar' +strip = 'riscv64-unknown-linux-gnu-strip' +pcap-config = '' +pkgconfig = 'riscv64-unknown-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'riscv64' +cpu = 'rv64gc' +endian = 'little' + +[properties] +vendor_id = '0x489' +arch_id = '0x8000000000000007' +max_lcores = 4 +max_numa_nodes = 1doc/guides/contributing/design.rst +1
-1@@ -42,7 +42,7 @@ Per Architecture Sources The following macro options can be used: * ``RTE_ARCH`` is a string that contains the name of the architecture. -* ``RTE_ARCH_I686``, ``RTE_ARCH_X86_64``, ``RTE_ARCH_X86_X32``, ``RTE_ARCH_PPC_64``, ``RTE_ARCH_ARM``, ``RTE_ARCH_ARMv7`` or ``RTE_ARCH_ARM64`` are defined only if we are building for those architectures. +* ``RTE_ARCH_I686``, ``RTE_ARCH_X86_64``, ``RTE_ARCH_X86_X32``, ``RTE_ARCH_PPC_64``, ``RTE_ARCH_RISCV``, ``RTE_ARCH_ARM``, ``RTE_ARCH_ARMv7`` or ``RTE_ARCH_ARM64`` are defined only if we are building for those architectures. Per Execution Environment Sources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +20
-0@@ -0,0 +1,125 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2020 ARM Corporation. + Copyright(c) 2022 StarFive + Copyright(c) 2022 SiFive + Copyright(c) 2022 Semihalf + +Cross compiling DPDK for RISC-V +=============================== + +This chapter describes how to cross compile DPDK for RISC-V from x86 build +hosts. + +.. note:: + + While it's possible to compile DPDK natively on a RISC-V host, it is + currently recommended to cross-compile as Linux kernel does not offer any + way for userspace to discover the vendor and architecture identifiers of the + CPU and therefore any per-chip optimization options have to be chosen via + a cross-file or ``c_args``. +
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst line 30
Quoted 10 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +10
-0+ +Prerequisites +------------- + + +Linux kernel +~~~~~~~~~~~~ + +It is recommended to use Linux kernel built from +`SiFive Freedom Unleashed SDK <https://github.com/sifive/freedom-u-sdk>`_.
How would the Unleashed SDK help on a later board or a board from a different vendor?
Why wouldn't an upstream kernel work?
I suggest to eliminate this misleading section.
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst line 40
Quoted 10 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +10
-0+ + +Meson prerequisites +~~~~~~~~~~~~~~~~~~~ + +Meson depends on pkgconfig to find the dependencies. +The package ``pkg-config-riscv64-linux-gnu`` is required for RISC-V. +To install it in Ubuntu:: + + sudo apt install pkg-config-riscv64-linux-gnu
This package does not exist in the current Ubuntu LTS (22.04, Jammy).
Setting environment variables PKG_CONFIG_LIBDIR, PKG_CONFIG_PATH, PKG_CONFIG_SYSROOT_DIR properly should do the job with the normal pkg-config.
Quoted 20 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +20
-0+ + +GNU toolchain +------------- + + +Obtain the cross toolchain +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The build process was tested using: + +* Ubuntu toolchain (the ``crossbuild-essential-riscv64`` package). + +* Latest `RISC-V GNU toolchain + <https://github.com/riscv/riscv-gnu-toolchain/releases>`_ on Ubuntu or Arch + Linux. + +Alternatively the toolchain may be built straight from the source, to do that +follow the instructions on the riscv-gnu-toolchain github page. +
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst line 70
Quoted 10 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +10
-0+ +Unzip and add into the PATH +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This step is only required for the riscv-gnu-toolchain. The Ubuntu toolchain is +in the PATH already. + +.. code-block:: console + + tar -xvf riscv64-glibc-ubuntu-20.04-<version>.tar.gz
You can install the glibc package with apt-get after adding the architecture with sudo dpkg --add-architecture riscv64. See https://wiki.debian.org/CrossCompiling.
Quoted 41 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +41
-0+ export PATH=$PATH:<cross_install_dir>/riscv/bin + + +Cross Compiling DPDK with GNU toolchain using Meson +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To cross-compile DPDK for a desired target machine use the following command:: + + meson cross-build --cross-file <target_machine_configuration> + ninja -C cross-build + +For example if the target machine is a generic rv64gc RISC-V, use the following +command:: + + meson riscv64-build-gcc --cross-file config/riscv/riscv64_linux_gcc + ninja -C riscv64-build-gcc + +If riscv-gnu-toolchain is used, binary names should be updated to match. Update the following lines in the cross-file: + +.. code-block:: console + + [binaries] + c = 'riscv64-unknown-linux-gnu-gcc' + cpp = 'riscv64-unknown-linux-gnu-g++' + ar = 'riscv64-unknown-linux-gnu-ar' + strip = 'riscv64-unknown-linux-gnu-strip' + ... + +Some toolchains (such as freedom-u-sdk one) require also setting ``--sysroot``, +otherwise include paths might not be resolved. To do so, add the appropriate +paths to the cross-file: + +.. code-block:: console + + [properties] + ... + c_args = ['--sysroot', '<path/to/toolchain/sysroot>'] + cpp_args = c_args + c_link_args = ['--sysroot', '<path/to/toolchain/sysroot>'] + cpp_link_args = c_link_args + ...
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst line 121
Quoted 10 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +10
-0+ + +Supported cross-compilation targets +----------------------------------- + +Currently the following targets are supported: + +* Generic rv64gc ISA: ``config/riscv/riscv64_linux_gcc`` + +* SiFive U740 SoC: ``config/riscv/riscv64_sifive_u740_linux_gcc``
Why do we need a special config for the Unmatched board that is not sold anymore? Doesn't the Unmatched board work with the genenric config?
I assume a single configuriation file for the generic target is enough.
Best regards
Heinrich
Quoted 1,252 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +4
-0+ +To add a new target support, ``config/riscv/meson.build`` has to be modified by +adding a new vendor/architecture id and a corresponding cross-file has to be +added to ``config/riscv`` directory.doc/guides/linux_gsg/index.rst +1
-0@@ -14,6 +14,7 @@ Getting Started Guide for Linux sys_reqs build_dpdk cross_build_dpdk_for_arm64 + cross_build_dpdk_for_riscv linux_drivers build_sample_apps linux_eal_parametersdoc/guides/nics/features.rst +5
-0@@ -855,6 +855,11 @@ x86-64 Support 64bits x86 architecture. +rv64 +---- + +Support 64-bit RISC-V architecture. + .. _nic_features_usage_doc:doc/guides/nics/features/default.ini +1
-0@@ -74,6 +74,7 @@ ARMv8 = Power8 = x86-32 = x86-64 = +rv64 = Usage doc = Design doc = Perf doc =doc/guides/rel_notes/release_22_07.rst +8
-0@@ -55,6 +55,14 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added initial RISC-V architecture support.*** + + Added EAL implementation for RISC-V architecture. The initial device the + porting was tested on is a HiFive Unmatched development board based on the + SiFive Freedom U740 SoC. In theory this implementation should work with any + ``rv64gc`` ISA compatible implementation with MMU supporting a reasonable + address space size (U740 uses sv39 MMU). + * **Updated Intel iavf driver.** * Added Tx QoS queue rate limitation support.drivers/net/i40e/meson.build +6
-0@@ -1,6 +1,12 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +if arch_subdir == 'riscv' + build = false + reason = 'riscv arch not supported' + subdir_done() +endif + cflags += ['-DPF_DRIVER', '-DVF_DRIVER', '-DINTEGRATED_VF',drivers/net/ixgbe/meson.build +6
-0@@ -1,6 +1,12 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +if arch_subdir == 'riscv' + build = false + reason = 'riscv arch not supported' + subdir_done() +endif + cflags += ['-DRTE_LIBRTE_IXGBE_BYPASS'] subdir('base')drivers/net/memif/meson.build +5
-0@@ -5,6 +5,11 @@ if not is_linux build = false reason = 'only supported on Linux' endif +if arch_subdir == 'riscv' + build = false + reason = 'riscv arch not supported' + subdir_done() +endif sources = files( 'memif_socket.c',drivers/net/tap/meson.build +5
-0@@ -5,6 +5,11 @@ if not is_linux build = false reason = 'only supported on Linux' endif +if arch_subdir == 'riscv' + build = false + reason = 'riscv arch not supported' + subdir_done() +endif sources = files( 'rte_eth_tap.c', 'tap_bpf_api.c',examples/l3fwd/meson.build +6
-0@@ -6,6 +6,12 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' +if dpdk_conf.has('RTE_ARCH_RISCV') + build = false + reason = 'riscv arch not supported' + subdir_done() +endif + allow_experimental_apis = true deps += ['hash', 'lpm', 'fib', 'eventdev'] sources = files(lib/eal/riscv/include/meson.build new file +23
-0@@ -0,0 +1,23 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2022 StarFive +# Copyright(c) 2022 SiFive +# Copyright(c) 2022 Semihalf + +arch_headers = files( + 'rte_atomic.h', + 'rte_byteorder.h', + 'rte_cpuflags.h', + 'rte_cycles.h', + 'rte_io.h', + 'rte_mcslock.h', + 'rte_memcpy.h', + 'rte_pause.h', + 'rte_pflock.h', + 'rte_power_intrinsics.h', + 'rte_prefetch.h', + 'rte_rwlock.h', + 'rte_spinlock.h', + 'rte_ticketlock.h', + 'rte_vect.h', +) +install_headers(arch_headers, subdir: get_option('include_subdir_arch'))lib/eal/riscv/include/rte_atomic.h new file +52
-0@@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +* All rights reserved. +*/ + +#ifndef RTE_ATOMIC_RISCV_H +#define RTE_ATOMIC_RISCV_H + +#ifndef RTE_FORCE_INTRINSICS +# error Platform must be built with RTE_FORCE_INTRINSICS +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> +#include <rte_common.h> +#include <rte_config.h> +#include "generic/rte_atomic.h" + +#define rte_mb () asm volatile("fence rw, rw" : : : "memory") + +#define rte_wmb () asm volatile("fence w, w" : : : "memory") + +#define rte_rmb () asm volatile("fence r, r" : : : "memory") + +#define rte_smp_mb () rte_mb() + +#define rte_smp_wmb () rte_wmb() + +#define rte_smp_rmb () rte_rmb() + +#define rte_io_mb () asm volatile("fence iorw, iorw" : : : "memory") + +#define rte_io_wmb () asm volatile("fence orw, ow" : : : "memory") + +#define rte_io_rmb () asm volatile("fence ir, ir" : : : "memory") + +static __rte_always_inline void +rte_atomic_thread_fence (int memorder) +{ +__atomic_thread_fence (memorder); +} + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_ATOMIC_RISCV_H */ lib/eal/riscv/include/rte_byteorder.h new file +44
-0@@ -0,0 +1,44 @@ +/* +* SPDX-License-Identifier: BSD-3-Clause +* Inspired from FreeBSD src/sys/powerpc/include/endian.h +* Copyright(c) 1987, 1991, 1993 +* The Regents of the University of California. All rights reserved. +*/ + +#ifndef RTE_BYTEORDER_RISCV_H +#define RTE_BYTEORDER_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> +#include <rte_common.h> +#include "generic/rte_byteorder.h" + +#ifndef RTE_BYTE_ORDER +#define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN +#endif + +#define rte_cpu_to_le_16 (x) (x) +#define rte_cpu_to_le_32 (x) (x) +#define rte_cpu_to_le_64 (x) (x) + +#define rte_cpu_to_be_16 (x) rte_bswap16(x) +#define rte_cpu_to_be_32 (x) rte_bswap32(x) +#define rte_cpu_to_be_64 (x) rte_bswap64(x) + +#define rte_le_to_cpu_16 (x) (x) +#define rte_le_to_cpu_32 (x) (x) +#define rte_le_to_cpu_64 (x) (x) + +#define rte_be_to_cpu_16 (x) rte_bswap16(x) +#define rte_be_to_cpu_32 (x) rte_bswap32(x) +#define rte_be_to_cpu_64 (x) rte_bswap64(x) + + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_BYTEORDER_RISCV_H */ lib/eal/riscv/include/rte_cpuflags.h new file +55
-0@@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2014 IBM Corporation +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_CPUFLAGS_RISCV_H +#define RTE_CPUFLAGS_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Enumeration of all CPU features supported +*/ +enum rte_cpu_flag_t { +RTE_CPUFLAG_RISCV_ISA_A ,/* Atomic */ +RTE_CPUFLAG_RISCV_ISA_B ,/* Bit-Manipulation */ +RTE_CPUFLAG_RISCV_ISA_C ,/* Compressed instruction */ +RTE_CPUFLAG_RISCV_ISA_D ,/* Double precision floating-point */ +RTE_CPUFLAG_RISCV_ISA_E ,/* RV32E ISA */ +RTE_CPUFLAG_RISCV_ISA_F ,/* Single precision floating-point */ +RTE_CPUFLAG_RISCV_ISA_G ,/* Extension pack (IMAFD, Zicsr, Zifencei) */ +RTE_CPUFLAG_RISCV_ISA_H ,/* Hypervisor */ +RTE_CPUFLAG_RISCV_ISA_I ,/* RV32I/RV64I/IRV128I base ISA */ +RTE_CPUFLAG_RISCV_ISA_J ,/* Dynamic Translation Language */ +RTE_CPUFLAG_RISCV_ISA_K ,/* Reserved */ +RTE_CPUFLAG_RISCV_ISA_L ,/* Decimal Floating-Point */ +RTE_CPUFLAG_RISCV_ISA_M ,/* Integer Multiply/Divide */ +RTE_CPUFLAG_RISCV_ISA_N ,/* User-level interrupts */ +RTE_CPUFLAG_RISCV_ISA_O ,/* Reserved */ +RTE_CPUFLAG_RISCV_ISA_P ,/* Packed-SIMD */ +RTE_CPUFLAG_RISCV_ISA_Q ,/* Quad-precision floating-points */ +RTE_CPUFLAG_RISCV_ISA_R ,/* Reserved */ +RTE_CPUFLAG_RISCV_ISA_S ,/* Supervisor mode */ +RTE_CPUFLAG_RISCV_ISA_T ,/* Transactional memory */ +RTE_CPUFLAG_RISCV_ISA_U ,/* User mode */ +RTE_CPUFLAG_RISCV_ISA_V ,/* Vector */ +RTE_CPUFLAG_RISCV_ISA_W ,/* Reserved */ +RTE_CPUFLAG_RISCV_ISA_X ,/* Non-standard extension present */ +RTE_CPUFLAG_RISCV_ISA_Y ,/* Reserved */ +RTE_CPUFLAG_RISCV_ISA_Z ,/* Reserved */ +/* The last item */ +RTE_CPUFLAG_NUMFLAGS ,/**< This should always be the last! */ +}; + +#include "generic/rte_cpuflags.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_CPUFLAGS_RISCV_H */ lib/eal/riscv/include/rte_cycles.h new file +105
-0@@ -0,0 +1,105 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2015 Cavium, Inc +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_CYCLES_RISCV_H +#define RTE_CYCLES_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_cycles.h" + +#ifndef RTE_RISCV_RDTSC_USE_HPM +#define RTE_RISCV_RDTSC_USE_HPM 0 +#endif + +#define RV64_CSRR (reg, value) \ + asm volatile("csrr %0, " #reg : "=r" (value) : : "memory") + +/** Read wall time counter */ +static __rte_always_inline uint64_t +__rte_riscv_rdtime (void ) +{ +uint64_t tsc; +RV64_CSRR (time, tsc); +return tsc; +} + +/** Read wall time counter ensuring no re-ordering */ +static __rte_always_inline uint64_t +__rte_riscv_rdtime_precise (void ) +{ +#if !defined(RTE_RISCV_EMU_UTIME ) + asmvolatile ("fence" : : :"memory" ); +#endif +return __rte_riscv_rdtime (); +} + +/** Read hart cycle counter */ +static __rte_always_inline uint64_t +__rte_riscv_rdcycle (void ) +{ +uint64_t tsc; +RV64_CSRR (cycle, tsc); +return tsc; +} + +/** Read hart cycle counter ensuring no re-ordering */ +static __rte_always_inline uint64_t +__rte_riscv_rdcycle_precise (void ) +{ +#if !defined(RTE_RISCV_EMU_UCYCLE ) + asmvolatile ("fence" : : :"memory" ); +#endif +return __rte_riscv_rdcycle (); +} + +/** +* Read the time base register. +* +* @return +* The time base for this lcore. +*/ +static __rte_always_inline uint64_t +rte_rdtsc (void ) +{ +/** +* By default TIME userspace counter is used. Although it's frequency +* may not be enough for all applications. +*/ +if (!RTE_RISCV_RDTSC_USE_HPM ) +return __rte_riscv_rdtime (); +/** +* Alternatively HPM's CYCLE counter may be used. However this counter +* is not guaranteed by ISA to either be stable frequency or always +* enabled for userspace access (it may trap to kernel or firmware). +*/ +return __rte_riscv_rdcycle (); +} + +static inline uint64_t +rte_rdtsc_precise (void ) +{ +if (!RTE_RISCV_RDTSC_USE_HPM ) +return __rte_riscv_rdtime_precise (); +return __rte_riscv_rdcycle_precise (); +} + +static __rte_always_inline uint64_t +rte_get_tsc_cycles (void ) +{ +return rte_rdtsc (); +} + +#undef RV64_CSRR + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_CYCLES_RISCV_H */ lib/eal/riscv/include/rte_io.h new file +21
-0@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2016 Cavium, Inc +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_IO_RISCV_H +#define RTE_IO_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_io.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_IO_RISCV_H */ lib/eal/riscv/include/rte_mcslock.h new file +18
-0@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +*/ + +#ifndef RTE_MCSLOCK_RISCV_H +#define RTE_MCSLOCK_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_mcslock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_MCSLOCK_RISCV_H */ lib/eal/riscv/include/rte_memcpy.h new file +63
-0@@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_MEMCPY_RISCV_H +#define RTE_MEMCPY_RISCV_H + +#include <stdint.h> +#include <string.h> + +#include "rte_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_memcpy.h" + +static inline void +rte_mov16 (uint8_t *dst,const uint8_t *src) +{ +memcpy (dst, src,16 ); +} + +static inline void +rte_mov32 (uint8_t *dst,const uint8_t *src) +{ +memcpy (dst, src,32 ); +} + +static inline void +rte_mov48 (uint8_t *dst,const uint8_t *src) +{ +memcpy (dst, src,48 ); +} + +static inline void +rte_mov64 (uint8_t *dst,const uint8_t *src) +{ +memcpy (dst, src,64 ); +} + +static inline void +rte_mov128 (uint8_t *dst,const uint8_t *src) +{ +memcpy (dst, src,128 ); +} + +static inline void +rte_mov256 (uint8_t *dst,const uint8_t *src) +{ +memcpy (dst, src,256 ); +} + +#define rte_memcpy (d, s, n) memcpy((d), (s), (n)) + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_MEMCPY_RISCV_H */ lib/eal/riscv/include/rte_pause.h new file +31
-0@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_PAUSE_RISCV_H +#define RTE_PAUSE_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "rte_atomic.h" + +#include "generic/rte_pause.h" + +static inline void rte_pause (void ) +{ +/* Insert pause hint directly to be compatible with old compilers. +* This will work even on platforms without Zihintpause extension +* because this is a FENCE hint instruction which evaluates to NOP then. +*/ + asmvolatile (".int 0x0100000F" :::"memory" ); +} + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_PAUSE_RISCV_H */ lib/eal/riscv/include/rte_pflock.h new file +17
-0@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2021 Microsoft Corporation +*/ +#ifndef RTE_PFLOCK_RISCV_H +#define RTE_PFLOCK_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_pflock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_PFLOCK_RISCV_H */ lib/eal/riscv/include/rte_power_intrinsics.h new file +22
-0@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_POWER_INTRINSIC_RISCV_H +#define RTE_POWER_INTRINSIC_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rte_common.h> + +#include "generic/rte_power_intrinsics.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_POWER_INTRINSIC_RISCV_H */ lib/eal/riscv/include/rte_prefetch.h new file +50
-0@@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2014 IBM Corporation +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_PREFETCH_RISCV_H +#define RTE_PREFETCH_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rte_common.h> +#include "generic/rte_prefetch.h" + +static inline void rte_prefetch0 (const volatile void *p) +{ +RTE_SET_USED (p); +} + +static inline void rte_prefetch1 (const volatile void *p) +{ +RTE_SET_USED (p); +} + +static inline void rte_prefetch2 (const volatile void *p) +{ +RTE_SET_USED (p); +} + +static inline void rte_prefetch_non_temporal (const volatile void *p) +{ +/* non-temporal version not available, fallback to rte_prefetch0 */ +rte_prefetch0 (p); +} + +__rte_experimental +static inline void +rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_PREFETCH_RISCV_H */ lib/eal/riscv/include/rte_rwlock.h new file +44
-0@@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_RWLOCK_RISCV_H +#define RTE_RWLOCK_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_rwlock.h" + +static inline void +rte_rwlock_read_lock_tm (rte_rwlock_t *rwl) +{ +rte_rwlock_read_lock (rwl); +} + +static inline void +rte_rwlock_read_unlock_tm (rte_rwlock_t *rwl) +{ +rte_rwlock_read_unlock (rwl); +} + +static inline void +rte_rwlock_write_lock_tm (rte_rwlock_t *rwl) +{ +rte_rwlock_write_lock (rwl); +} + +static inline void +rte_rwlock_write_unlock_tm (rte_rwlock_t *rwl) +{ +rte_rwlock_write_unlock (rwl); +} + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_RWLOCK_RISCV_H */ lib/eal/riscv/include/rte_spinlock.h new file +67
-0@@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2015 RehiveTech. All rights reserved. +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_SPINLOCK_RISCV_H +#define RTE_SPINLOCK_RISCV_H + +#ifndef RTE_FORCE_INTRINSICS +# error Platform must be built with RTE_FORCE_INTRINSICS +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rte_common.h> +#include "generic/rte_spinlock.h" + +static inline int rte_tm_supported (void ) +{ +return 0 ; +} + +static inline void +rte_spinlock_lock_tm (rte_spinlock_t *sl) +{ +rte_spinlock_lock (sl);/* fall-back */ +} + +static inline int +rte_spinlock_trylock_tm (rte_spinlock_t *sl) +{ +return rte_spinlock_trylock (sl); +} + +static inline void +rte_spinlock_unlock_tm (rte_spinlock_t *sl) +{ +rte_spinlock_unlock (sl); +} + +static inline void +rte_spinlock_recursive_lock_tm (rte_spinlock_recursive_t *slr) +{ +rte_spinlock_recursive_lock (slr);/* fall-back */ +} + +static inline void +rte_spinlock_recursive_unlock_tm (rte_spinlock_recursive_t *slr) +{ +rte_spinlock_recursive_unlock (slr); +} + +static inline int +rte_spinlock_recursive_trylock_tm (rte_spinlock_recursive_t *slr) +{ +return rte_spinlock_recursive_trylock (slr); +} + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_SPINLOCK_RISCV_H */ lib/eal/riscv/include/rte_ticketlock.h new file +21
-0@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2019 Arm Limited +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_TICKETLOCK_RISCV_H +#define RTE_TICKETLOCK_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_ticketlock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_TICKETLOCK_RISCV_H */ lib/eal/riscv/include/rte_vect.h new file +55
-0@@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#ifndef RTE_VECT_RISCV_H +#define RTE_VECT_RISCV_H + +#include <stdint.h> +#include "generic/rte_vect.h" +#include "rte_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define RTE_VECT_DEFAULT_SIMD_BITWIDTH RTE_VECT_SIMD_DISABLED + +typedef int32_t xmm_t __attribute__((vector_size (16 ))); + +#define XMM_SIZE (sizeof(xmm_t)) +#define XMM_MASK (XMM_SIZE - 1) + +typedef union rte_xmm { +xmm_t x; +uint8_t u8[XMM_SIZE /sizeof (uint8_t )]; +uint16_t u16[XMM_SIZE /sizeof (uint16_t )]; +uint32_t u32[XMM_SIZE /sizeof (uint32_t )]; +uint64_t u64[XMM_SIZE /sizeof (uint64_t )]; +double pd[XMM_SIZE /sizeof (double )]; +} __rte_aligned(8) rte_xmm_t; + +static inline xmm_t +vect_load_128 (void *p) +{ +xmm_t ret = *((xmm_t *)p); +return ret; +} + +static inline xmm_t +vect_and (xmm_t data,xmm_t mask) +{ +rte_xmm_t ret = (rte_xmm_t )data; +rte_xmm_t m = (rte_xmm_t )mask; + ret.u64[0 ] &= m.u64[0 ]; + ret.u64[1 ] &= m.u64[1 ]; +return ret.x; +} + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_VECT_RISCV_H */ lib/eal/riscv/meson.build new file +11
-0@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation. + +subdir('include') + +sources += files( + 'rte_cpuflags.c', + 'rte_cycles.c', + 'rte_hypervisor.c', + 'rte_power_intrinsics.c', +)lib/eal/riscv/rte_cpuflags.c new file +122
-0@@ -0,0 +1,122 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#include "rte_cpuflags.h" + +#include <elf.h> +#include <fcntl.h> +#include <assert.h> +#include <unistd.h> +#include <string.h> + +#ifndef AT_HWCAP +#define AT_HWCAP 16 +#endif + +#ifndef AT_HWCAP2 +#define AT_HWCAP2 26 +#endif + +#ifndef AT_PLATFORM +#define AT_PLATFORM 15 +#endif + +enum cpu_register_t { +REG_NONE =0 , +REG_HWCAP , +REG_HWCAP2 , +REG_PLATFORM , +REG_MAX +}; + +typedef uint32_t hwcap_registers_t [REG_MAX ]; + +/** +* Struct to hold a processor feature entry +*/ +struct feature_entry { +uint32_t reg; +uint32_t bit; +#define CPU_FLAG_NAME_MAX_LEN 64 +char name[CPU_FLAG_NAME_MAX_LEN ]; +}; + +#define FEAT_DEF (name, reg, bit) \ + [RTE_CPUFLAG_##name] = {reg, bit, #name}, + +typedef Elf64_auxv_t _Elfx_auxv_t ; + +const struct feature_entry rte_cpu_feature_table[] = { + FEAT_DEF(RISCV_ISA_A, REG_HWCAP, 0) + FEAT_DEF(RISCV_ISA_B, REG_HWCAP, 1) + FEAT_DEF(RISCV_ISA_C, REG_HWCAP, 2) + FEAT_DEF(RISCV_ISA_D, REG_HWCAP, 3) + FEAT_DEF(RISCV_ISA_E, REG_HWCAP, 4) + FEAT_DEF(RISCV_ISA_F, REG_HWCAP, 5) + FEAT_DEF(RISCV_ISA_G, REG_HWCAP, 6) + FEAT_DEF(RISCV_ISA_H, REG_HWCAP, 7) + FEAT_DEF(RISCV_ISA_I, REG_HWCAP, 8) + FEAT_DEF(RISCV_ISA_J, REG_HWCAP, 9) + FEAT_DEF(RISCV_ISA_K, REG_HWCAP, 10) + FEAT_DEF(RISCV_ISA_L, REG_HWCAP, 11) + FEAT_DEF(RISCV_ISA_M, REG_HWCAP, 12) + FEAT_DEF(RISCV_ISA_N, REG_HWCAP, 13) + FEAT_DEF(RISCV_ISA_O, REG_HWCAP, 14) + FEAT_DEF(RISCV_ISA_P, REG_HWCAP, 15) + FEAT_DEF(RISCV_ISA_Q, REG_HWCAP, 16) + FEAT_DEF(RISCV_ISA_R, REG_HWCAP, 17) + FEAT_DEF(RISCV_ISA_S, REG_HWCAP, 18) + FEAT_DEF(RISCV_ISA_T, REG_HWCAP, 19) + FEAT_DEF(RISCV_ISA_U, REG_HWCAP, 20) + FEAT_DEF(RISCV_ISA_V, REG_HWCAP, 21) + FEAT_DEF(RISCV_ISA_W, REG_HWCAP, 22) + FEAT_DEF(RISCV_ISA_X, REG_HWCAP, 23) + FEAT_DEF(RISCV_ISA_Y, REG_HWCAP, 24) +FEAT_DEF (RISCV_ISA_Z ,REG_HWCAP ,25 ) +}; +/* +* Read AUXV software register and get cpu features for ARM +*/ +static void +rte_cpu_get_features (hwcap_registers_t out) +{ + out[REG_HWCAP ] =rte_cpu_getauxval (AT_HWCAP ); + out[REG_HWCAP2 ] =rte_cpu_getauxval (AT_HWCAP2 ); +} + +/* +* Checks if a particular flag is available on current machine. +*/ +int +rte_cpu_get_flag_enabled (enum rte_cpu_flag_t feature) +{ +const struct feature_entry *feat; +hwcap_registers_t regs = {0 }; + +if (feature >=RTE_CPUFLAG_NUMFLAGS ) +return -ENOENT ; + + feat = &rte_cpu_feature_table[feature]; +if (feat->reg ==REG_NONE ) +return -EFAULT ; + +rte_cpu_get_features (regs); +return (regs[feat->reg] >> feat->bit) &1 ; +} + +const char * +rte_cpu_get_flag_name (enum rte_cpu_flag_t feature) +{ +if (feature >=RTE_CPUFLAG_NUMFLAGS ) +return NULL ; +return rte_cpu_feature_table[feature].name; +} + +void +rte_cpu_get_intrinsics_support (struct rte_cpu_intrinsics *intrinsics) +{ +memset (intrinsics,0 ,sizeof (*intrinsics)); +}lib/eal/riscv/rte_cycles.c new file +77
-0@@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2015 Cavium, Inc +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#include <stdio.h> + +#include "eal_private.h" +#include "rte_byteorder.h" +#include "rte_cycles.h" +#include "rte_log.h" + +/** Read generic counter frequency */ +static uint64_t +__rte_riscv_timefrq (void ) +{ +#define TIMEBASE_FREQ_SIZE 8 +if (RTE_RISCV_TIME_FREQ >0 ) +return RTE_RISCV_TIME_FREQ ; +uint8_t buf[TIMEBASE_FREQ_SIZE ]; +ssize_t cnt; +FILE *file; + + file =fopen ("/proc/device-tree/cpus/timebase-frequency" ,"rb" ); +if (!file) + goto fail; + + cnt =fread (buf,1 ,TIMEBASE_FREQ_SIZE , file); +fclose (file); +switch (cnt) { +case 8 : +return rte_be_to_cpu_64 (*(uint64_t *)buf); +case 4 : +return rte_be_to_cpu_32 (*(uint32_t *)buf); +default : +break ; + } +fail: +RTE_LOG (WARNING ,EAL ,"Unable to read timebase-frequency from FDT.\n" ); +return 0 ; +} + +uint64_t +get_tsc_freq_arch (void ) +{ +RTE_LOG (NOTICE ,EAL ,"TSC using RISC-V %s.\n" , +RTE_RISCV_RDTSC_USE_HPM ?"rdcycle" :"rdtime" ); +if (!RTE_RISCV_RDTSC_USE_HPM ) +return __rte_riscv_timefrq (); +#define CYC_PER_1MHZ 1E6 +/* +* Use real time clock to estimate current cycle frequency +*/ +uint64_t ticks, frq; +uint64_t start_ticks, cur_ticks; +uint64_t start_cycle, end_cycle; + +/* Do not proceed unless clock frequency can be obtained. */ + frq =__rte_riscv_timefrq (); +if (!frq) +return 0 ; + +/* Number of ticks for 1/10 second */ + ticks = frq /10 ; + + start_ticks =__rte_riscv_rdtime_precise (); + start_cycle =rte_rdtsc_precise (); +do { + cur_ticks =__rte_riscv_rdtime (); + }while ((cur_ticks - start_ticks) < ticks); + end_cycle =rte_rdtsc_precise (); + +/* Adjust the cycles to next 1Mhz */ +return RTE_ALIGN_MUL_CEIL ((end_cycle - start_cycle) *10 ,CYC_PER_1MHZ ); +}lib/eal/riscv/rte_hypervisor.c new file +13
-0@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#include "rte_hypervisor.h" + +enum rte_hypervisor +rte_hypervisor_get (void ) +{ +return RTE_HYPERVISOR_UNKNOWN ; +}lib/eal/riscv/rte_power_intrinsics.c new file +56
-0@@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 StarFive +* Copyright(c) 2022 SiFive +* Copyright(c) 2022 Semihalf +*/ + +#include "rte_power_intrinsics.h" + +/** +* This function is not supported on RISC-V 64 +*/ +int +rte_power_monitor (const struct rte_power_monitor_cond *pmc, +const uint64_t tsc_timestamp) +{ +RTE_SET_USED (pmc); +RTE_SET_USED (tsc_timestamp); + +return -ENOTSUP ; +} + +/** +* This function is not supported on RISC-V 64 +*/ +int +rte_power_pause (const uint64_t tsc_timestamp) +{ +RTE_SET_USED (tsc_timestamp); + +return -ENOTSUP ; +} + +/** +* This function is not supported on RISC-V 64 +*/ +int +rte_power_monitor_wakeup (const unsigned int lcore_id) +{ +RTE_SET_USED (lcore_id); + +return -ENOTSUP ; +} + +/** +* This function is not supported on RISC-V 64 +*/ +int +rte_power_monitor_multi (const struct rte_power_monitor_cond pmc[], +const uint32_t num,const uint64_t tsc_timestamp) +{ +RTE_SET_USED (pmc); +RTE_SET_USED (num); +RTE_SET_USED (tsc_timestamp); + +return -ENOTSUP ; +}meson.build +2
-0@@ -50,6 +50,8 @@ elif host_machine.cpu_family().startswith('arm') or host_machine.cpu_family().st arch_subdir = 'arm' elif host_machine.cpu_family().startswith('ppc') arch_subdir = 'ppc' +elif host_machine.cpu_family().startswith('riscv') + arch_subdir = 'riscv' endif # configure the build, and make sure configs here and in config folder are
Re: [PATCH v3 1/8] eal: add initial support for RISC-V architecture
On Fri, May 13, 2022 at 8:50 AM Heinrich Schuchardt <[email protected]> wrote:
<snip>
Quoted 8 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst line 30
Quoted 5 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +5
-0+Linux kernel +~~~~~~~~~~~~ + +It is recommended to use Linux kernel built from +`SiFive Freedom Unleashed SDK <https://github.com/sifive/freedom-u-sdk>`_.How would the Unleashed SDK help on a later board or a board from a different vendor?
This SDK is for both Unleashed and Unmatched. The naming is a bit misleading.
Quoted 2 lines
Why wouldn't an upstream kernel work?
At the point of writing it was missing patches related to PCI resource mapping exposure to userspace. Right now it's there.
Quoted 2 lines
I suggest to eliminate this misleading section.
I'll re-test with the latest upstream kernel and rephrase that this should work with Linux kernel >= x.y.z.
Quoted 14 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst line 40
Quoted 11 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +10
-0+ + +Meson prerequisites +~~~~~~~~~~~~~~~~~~~ + +Meson depends on pkgconfig to find the dependencies. +The package ``pkg-config-riscv64-linux-gnu`` is required for RISC-V. +To install it in Ubuntu:: + + sudo apt install pkg-config-riscv64-linux-gnuThis package does not exist in the current Ubuntu LTS (22.04, Jammy).
Quoted 3 lines
Setting environment variables
PKG_CONFIG_LIBDIR,PKG_CONFIG_PATH,PKG_CONFIG_SYSROOT_DIRproperly should do the job with the normal pkg-config.
Do you happen to know why was this package removed?
Given that, is there a Ubuntu manual page or tool somewhere specifying the correct values to obtain for a given arch?
Quoted 27 lines
Quoted 27 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +26
-0+ + +GNU toolchain +------------- + + +Obtain the cross toolchain +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The build process was tested using: + +* Ubuntu toolchain (the ``crossbuild-essential-riscv64`` package). + +* Latest `RISC-V GNU toolchain + <https://github.com/riscv/riscv-gnu-toolchain/releases>`_ on Ubuntu or Arch + Linux. + +Alternatively the toolchain may be built straight from the source, to do that +follow the instructions on the riscv-gnu-toolchain github page. + + +Unzip and add into the PATH +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This step is only required for the riscv-gnu-toolchain. The Ubuntu toolchain is +in the PATH already.
Quoted 9 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst line 70
Quoted 4 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +4
-0+ +.. code-block:: console + + tar -xvf riscv64-glibc-ubuntu-20.04-<version>.tar.gzYou can install the glibc package with apt-get after adding the architecture with sudo dpkg --add-architecture riscv64. See
https://wiki.debian.org/CrossCompiling.
This guide is supposed to target also Arch where this toolchain should work properly. That's why in previous section I'm mentioning crossbuild-essential-riscv64 and RISC-V GNU toolchain from github separately.
Quoted 46 lines
Quoted 46 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +46
-0+ export PATH=$PATH:<cross_install_dir>/riscv/bin + + +Cross Compiling DPDK with GNU toolchain using Meson +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To cross-compile DPDK for a desired target machine use the following command:: + + meson cross-build --cross-file <target_machine_configuration> + ninja -C cross-build + +For example if the target machine is a generic rv64gc RISC-V, use the following +command:: + + meson riscv64-build-gcc --cross-file config/riscv/riscv64_linux_gcc + ninja -C riscv64-build-gcc + +If riscv-gnu-toolchain is used, binary names should be updated to match. Update the following lines in the cross-file: + +.. code-block:: console + + [binaries] + c = 'riscv64-unknown-linux-gnu-gcc' + cpp = 'riscv64-unknown-linux-gnu-g++' + ar = 'riscv64-unknown-linux-gnu-ar' + strip = 'riscv64-unknown-linux-gnu-strip' + ... + +Some toolchains (such as freedom-u-sdk one) require also setting ``--sysroot``, +otherwise include paths might not be resolved. To do so, add the appropriate +paths to the cross-file: + +.. code-block:: console + + [properties] + ... + c_args = ['--sysroot', '<path/to/toolchain/sysroot>'] + cpp_args = c_args + c_link_args = ['--sysroot', '<path/to/toolchain/sysroot>'] + cpp_link_args = c_link_args + ... + + +Supported cross-compilation targets +----------------------------------- +
Quoted 8 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst line 121
Quoted 5 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +5
-0+Currently the following targets are supported: + +* Generic rv64gc ISA: ``config/riscv/riscv64_linux_gcc`` + +* SiFive U740 SoC: ``config/riscv/riscv64_sifive_u740_linux_gcc``Why do we need a special config for the Unmatched board that is not sold anymore? Doesn't the Unmatched board work with the genenric config?
I wasn't aware that they did discontinue it. As far as I can see it's due to supply chain issues, maybe that means it'll get back? Generic config works just fine for the Unmatched. However config for Unmatched enables certain optimizations that are valid there. I.e. when reading RIME or CYCLE registers in a precise way, normally a fence should be inserted before reading it. However on Unmatched read to both counters is emulated through a call to firmware (SBI) in userspace, eliminating the need for the fence.
Quoted 7 lines
I assume a single configuriation file for the generic target is enough.
Best regards
Heinrich
Re: [PATCH v3 1/8] eal: add initial support for RISC-V architecture
Quoted 34 lines · Stanisław Kardach
On Fri, May 13, 2022 at 8:50 AM Heinrich Schuchardt <[email protected]> wrote:
<snip>Quoted 8 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst line 30
Quoted 5 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +5
-0+Linux kernel +~~~~~~~~~~~~ + +It is recommended to use Linux kernel built from +`SiFive Freedom Unleashed SDK <https://github.com/sifive/freedom-u-sdk>`_.How would the Unleashed SDK help on a later board or a board from a different vendor?
This SDK is for both Unleashed and Unmatched. The naming is a bit misleading.
Quoted 2 lines
Why wouldn't an upstream kernel work?
At the point of writing it was missing patches related to PCI resource mapping exposure to userspace. Right now it's there.
Quoted 2 lines
I suggest to eliminate this misleading section.
I'll re-test with the latest upstream kernel and rephrase that this should work with Linux kernel >= x.y.z.
Quoted 14 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst line 40
Quoted 11 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +10
-0+ + +Meson prerequisites +~~~~~~~~~~~~~~~~~~~ + +Meson depends on pkgconfig to find the dependencies. +The package ``pkg-config-riscv64-linux-gnu`` is required for RISC-V. +To install it in Ubuntu:: + + sudo apt install pkg-config-riscv64-linux-gnuThis package does not exist in the current Ubuntu LTS (22.04, Jammy).
Quoted 4 lines
Quoted 3 lines
Setting environment variables
PKG_CONFIG_LIBDIR,PKG_CONFIG_PATH,PKG_CONFIG_SYSROOT_DIRproperly should do the job with the normal pkg-config.Do you happen to know why was this package removed?
The Debian maintainer introduced this change in package gcc-defaults-ports. The change log does not give a reason.
Quoted 2 lines
Given that, is there a Ubuntu manual page or tool somewhere specifying the correct values to obtain for a given arch?
The values might depend on the Linux distribution.
In Ubuntu the .pc files are in
/usr/lib/riscv64-linux-gnu/pkgconfig/usr/lib/pkgconfig/usr/share/pkgconfig
Quoted 95 lines
Quoted 28 lines
Quoted 28 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +26
-0+ + +GNU toolchain +------------- + + +Obtain the cross toolchain +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The build process was tested using: + +* Ubuntu toolchain (the ``crossbuild-essential-riscv64`` package). + +* Latest `RISC-V GNU toolchain + <https://github.com/riscv/riscv-gnu-toolchain/releases>`_ on Ubuntu or Arch + Linux. + +Alternatively the toolchain may be built straight from the source, to do that +follow the instructions on the riscv-gnu-toolchain github page. + + +Unzip and add into the PATH +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This step is only required for the riscv-gnu-toolchain. The Ubuntu toolchain is +in the PATH already.Quoted 9 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst line 70
Quoted 4 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +4
-0+ +.. code-block:: console + + tar -xvf riscv64-glibc-ubuntu-20.04-<version>.tar.gzYou can install the glibc package with apt-get after adding the architecture with sudo dpkg --add-architecture riscv64. See
https://wiki.debian.org/CrossCompiling.This guide is supposed to target also Arch where this toolchain should work properly. That's why in previous section I'm mentioning crossbuild-essential-riscv64 and RISC-V GNU toolchain from github separately.
Quoted 46 lines
Quoted 46 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +46
-0+ export PATH=$PATH:<cross_install_dir>/riscv/bin + + +Cross Compiling DPDK with GNU toolchain using Meson +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To cross-compile DPDK for a desired target machine use the following command:: + + meson cross-build --cross-file <target_machine_configuration> + ninja -C cross-build + +For example if the target machine is a generic rv64gc RISC-V, use the following +command:: + + meson riscv64-build-gcc --cross-file config/riscv/riscv64_linux_gcc + ninja -C riscv64-build-gcc + +If riscv-gnu-toolchain is used, binary names should be updated to match. Update the following lines in the cross-file: + +.. code-block:: console + + [binaries] + c = 'riscv64-unknown-linux-gnu-gcc' + cpp = 'riscv64-unknown-linux-gnu-g++' + ar = 'riscv64-unknown-linux-gnu-ar' + strip = 'riscv64-unknown-linux-gnu-strip' + ... + +Some toolchains (such as freedom-u-sdk one) require also setting ``--sysroot``, +otherwise include paths might not be resolved. To do so, add the appropriate +paths to the cross-file: + +.. code-block:: console + + [properties] + ... + c_args = ['--sysroot', '<path/to/toolchain/sysroot>'] + cpp_args = c_args + c_link_args = ['--sysroot', '<path/to/toolchain/sysroot>'] + cpp_link_args = c_link_args + ... + + +Supported cross-compilation targets +----------------------------------- +Quoted 8 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst line 121
Quoted 5 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +5
-0+Currently the following targets are supported: + +* Generic rv64gc ISA: ``config/riscv/riscv64_linux_gcc`` + +* SiFive U740 SoC: ``config/riscv/riscv64_sifive_u740_linux_gcc``Why do we need a special config for the Unmatched board that is not sold anymore? Doesn't the Unmatched board work with the genenric config?
Quoted 2 lines
I wasn't aware that they did discontinue it. As far as I can see it's due to supply chain issues, maybe that means it'll get back? Generic
https://forums.sifive.com/t/sifive-update-on-hifive-unmatched-boards-in-2022/5569?s=09 :
"we’ve decided to focus on the next generation SiFive HiFive development systems rather than trying to put together another build of the HiFive Unmatched platform in 2022."
Quoted 6 lines
config works just fine for the Unmatched. However config for Unmatched enables certain optimizations that are valid there. I.e. when reading RIME or CYCLE registers in a precise way, normally a fence should be inserted before reading it. However on Unmatched read to both counters is emulated through a call to firmware (SBI) in userspace, eliminating the need for the fence.
Distributions like Ubuntu will only build a single configuration. It is preferable to read vendor_id and arch_id via an SBI call at runtime to switch code paths.
Isn't the saving gained by removing the fence irrelevant compared to the duration of an SBI call?
Best regards
Heinrich
Quoted 7 lines
Quoted 7 lines
I assume a single configuration file for the generic target is enough.
Best regards
Heinrich
Re: [PATCH v3 1/8] eal: add initial support for RISC-V architecture
Quoted 47 lines · Heinrich Schuchardt
Quoted 34 lines · Stanisław Kardach
On Fri, May 13, 2022 at 8:50 AM Heinrich Schuchardt <[email protected]> wrote:
<snip>Quoted 8 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst line 30
Quoted 5 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +5
-0+Linux kernel +~~~~~~~~~~~~ + +It is recommended to use Linux kernel built from +`SiFive Freedom Unleashed SDK <https://github.com/sifive/freedom-u-sdk>`_.How would the Unleashed SDK help on a later board or a board from a different vendor?
This SDK is for both Unleashed and Unmatched. The naming is a bit misleading.
Quoted 2 lines
Why wouldn't an upstream kernel work?
At the point of writing it was missing patches related to PCI resource mapping exposure to userspace. Right now it's there.
Quoted 2 lines
I suggest to eliminate this misleading section.
I'll re-test with the latest upstream kernel and rephrase that this should work with Linux kernel >= x.y.z.
Quoted 14 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst line 40
Quoted 11 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +10
-0+ + +Meson prerequisites +~~~~~~~~~~~~~~~~~~~ + +Meson depends on pkgconfig to find the dependencies. +The package ``pkg-config-riscv64-linux-gnu`` is required for RISC-V. +To install it in Ubuntu:: + + sudo apt install pkg-config-riscv64-linux-gnuThis package does not exist in the current Ubuntu LTS (22.04, Jammy).
Quoted 4 lines
Quoted 3 lines
Setting environment variables
PKG_CONFIG_LIBDIR,PKG_CONFIG_PATH,PKG_CONFIG_SYSROOT_DIRproperly should do the job with the normal pkg-config.Do you happen to know why was this package removed?
The Debian maintainer introduced this change in package gcc-defaults-ports. The change log does not give a reason.
Quoted 2 lines
Given that, is there a Ubuntu manual page or tool somewhere specifying the correct values to obtain for a given arch?
Quoted 7 lines
The values might depend on the Linux distribution.
In Ubuntu the .pc files are in
/usr/lib/riscv64-linux-gnu/pkgconfig/usr/lib/pkgconfig/usr/share/pkgconfig
OK, I'll describe those for Ubuntu path.
Quoted 99 lines
Quoted 96 lines
Quoted 29 lines
Quoted 29 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +26
-0+ + +GNU toolchain +------------- + + +Obtain the cross toolchain +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The build process was tested using: + +* Ubuntu toolchain (the ``crossbuild-essential-riscv64`` package). + +* Latest `RISC-V GNU toolchain + <https://github.com/riscv/riscv-gnu-toolchain/releases>`_ on Ubuntu or Arch + Linux. + +Alternatively the toolchain may be built straight from the source, to do that +follow the instructions on the riscv-gnu-toolchain github page. + + +Unzip and add into the PATH +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This step is only required for the riscv-gnu-toolchain. The Ubuntu toolchain is +in the PATH already.Quoted 9 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst line 70
Quoted 4 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +4
-0+ +.. code-block:: console + + tar -xvf riscv64-glibc-ubuntu-20.04-<version>.tar.gzYou can install the glibc package with apt-get after adding the architecture with sudo dpkg --add-architecture riscv64. See
https://wiki.debian.org/CrossCompiling.This guide is supposed to target also Arch where this toolchain should work properly. That's why in previous section I'm mentioning crossbuild-essential-riscv64 and RISC-V GNU toolchain from github separately.
Quoted 46 lines
Quoted 46 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +46
-0+ export PATH=$PATH:<cross_install_dir>/riscv/bin + + +Cross Compiling DPDK with GNU toolchain using Meson +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To cross-compile DPDK for a desired target machine use the following command:: + + meson cross-build --cross-file <target_machine_configuration> + ninja -C cross-build + +For example if the target machine is a generic rv64gc RISC-V, use the following +command:: + + meson riscv64-build-gcc --cross-file config/riscv/riscv64_linux_gcc + ninja -C riscv64-build-gcc + +If riscv-gnu-toolchain is used, binary names should be updated to match. Update the following lines in the cross-file: + +.. code-block:: console + + [binaries] + c = 'riscv64-unknown-linux-gnu-gcc' + cpp = 'riscv64-unknown-linux-gnu-g++' + ar = 'riscv64-unknown-linux-gnu-ar' + strip = 'riscv64-unknown-linux-gnu-strip' + ... + +Some toolchains (such as freedom-u-sdk one) require also setting ``--sysroot``, +otherwise include paths might not be resolved. To do so, add the appropriate +paths to the cross-file: + +.. code-block:: console + + [properties] + ... + c_args = ['--sysroot', '<path/to/toolchain/sysroot>'] + cpp_args = c_args + c_link_args = ['--sysroot', '<path/to/toolchain/sysroot>'] + cpp_link_args = c_link_args + ... + + +Supported cross-compilation targets +----------------------------------- +Quoted 8 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst line 121
Quoted 5 lines
doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rst new file +5
-0+Currently the following targets are supported: + +* Generic rv64gc ISA: ``config/riscv/riscv64_linux_gcc`` + +* SiFive U740 SoC: ``config/riscv/riscv64_sifive_u740_linux_gcc``Why do we need a special config for the Unmatched board that is not sold anymore? Doesn't the Unmatched board work with the genenric config?
Quoted 2 lines
I wasn't aware that they did discontinue it. As far as I can see it's due to supply chain issues, maybe that means it'll get back? Generic
Quoted 6 lines
https://forums.sifive.com/t/sifive-update-on-hifive-unmatched-boards-in-2022/5569?s=09
:"we’ve decided to focus on the next generation SiFive HiFive development systems rather than trying to put together another build of the HiFive Unmatched platform in 2022."
I did not know that, thank you.
Quoted 9 lines
Quoted 7 lines
config works just fine for the Unmatched. However config for Unmatched enables certain optimizations that are valid there. I.e. when reading RIME or CYCLE registers in a precise way, normally a fence should be inserted before reading it. However on Unmatched read to both counters is emulated through a call to firmware (SBI) in userspace, eliminating the need for the fence.
Distributions like Ubuntu will only build a single configuration.
I understand however there are also platform specific configs for Aarch64 here (Graviton, ThunderX, CnXk to name a few) so it's not that uncommon. Plus distro packages although useful for orchestration environments such as accelerating OpenStack Neutron (or other orchestrated networking packages), there will still be people compiling DPDK locally, be it via company-wide Yocto server to package for specific HW or just integrating DPDK statically in their projects (to not pay the cost of a dynamic lib call).
Quoted 2 lines
It is preferable to read
vendor_idandarch_idvia an SBI call at runtime to switch code paths.
Right, but SBI call can only be made from S-mode (so kernel), right? Issuing "ecall" from U-mode (userspace) will transfer control to kernel. AFAIK it is KVM that emulates or forwards SBI calls further but that's in qemu scope.
I was trying to figure out how to get this data from Linux to decide at build time but it's not in the /proc/cpuinfo (it only prints DTS's "compatible" for the CPU). Deciding at runtime is costly because you either need a functor call or self-modifying code (similar to how Linux handles Compare-And-Swap on Aarch64).
Quoted 3 lines
Isn't the saving gained by removing the fence irrelevant compared to the duration of an SBI call?
Yes, that is most likely but I was not able to measure it, because the access to the time source on Unmatched is emulated, so it's hard to reason.
Other thing that this config triggers (or more precisely the vendor_id and arch_id) is "-mtune" value which I believe still contains some compiler tweaks for the platform.
Given all that I can remove the current infrastructure in config/riscv/meson.build and the related sifive config but I'd prefer not to. I'm pretty sure it'll come in handy when a new RISC-V platform comes in (and serve as a reference for new developers). There is a warning in meson.build noting the lack of ability to detect the current platform. When someone implements it in Linux, that'll be a single place to change. Even then the configs won't become useless due to cross-compiling for a specific target.
Best Regards,
Stanislaw Kardach
Re: [PATCH v3 1/8] eal: add initial support for RISC-V architecture
In reply to Heinrich SchuchardtQuoted 19 lines · On Fri, 13 May 2022 08:50:34 +0200 Heinrich Schuchardt…
Quoted 18 lines · Stanislaw Kardach
From: Michal Mazurek <[email protected]>
Add all necessary elements for DPDK to compile and run EAL on SiFive Freedom U740 SoC which is based on SiFive U74-MC (ISA: rv64imafdc) core complex.
This includes:
- EAL library implementation for rv64imafdc ISA.
- meson build structure for 'riscv' architecture.RTE_ARCH_RISCVdefine is added for architecture identification.
-xmm_tstructure operation stubs as there is no vector support in the U74 core.Compilation was tested on Ubuntu and Arch Linux using riscv64 toolchain. Clang compilation currently not supported due to issues with missing relocation relaxation.
Quoted 12 lines
Quoted 4 lines
Two
rte_rdtsc()schemes are provided: stable low-resolution using rdtime (default) and unstable high-resolution using rdcycle. User can override the scheme by defining RTE_RISCV_RDTSC_USE_HPM=1 during compile time of both DPDK and the application. The reasoning for this is as follows.Quoted 8 lines
The RISC-V ISA mandates that clock read by rdtime has to be of constant period and synchronized between all hardware threads within 1 tick (chapter 10.1 in version 20191213 of RISC-V spec).
However this clock may not be of high-enough frequency for dataplane uses. I.e. on HiFive Unmatched (FU740) it is 1MHz.
There is a high-resolution alternative in form of rdcycle which is clocked at the core clock frequency. The drawbacks are that it may be disabled during sleep (WFI) and its frequency might change due to DVFS.
Choosing at compile time is ok for embedded but is undesireable for DPDK in a distribution. It sounds like the low-res is equivalent to hpet and the unstable is same as x86 TSC. Therefore why not follow that precedent and do the same thing?
Re: [PATCH v3 1/8] eal: add initial support for RISC-V architecture
Quoted 36 lines · Stephen Hemminger
Quoted 19 lines · On Fri, 13 May 2022 08:50:34 +0200 Heinrich Schuchardt…
Quoted 18 lines · Stanislaw Kardach
From: Michal Mazurek <[email protected]>
Add all necessary elements for DPDK to compile and run EAL on SiFive Freedom U740 SoC which is based on SiFive U74-MC (ISA: rv64imafdc) core complex.
This includes:
- EAL library implementation for rv64imafdc ISA.
- meson build structure for 'riscv' architecture.RTE_ARCH_RISCVdefine is added for architecture identification.
-xmm_tstructure operation stubs as there is no vector support in the U74 core.Compilation was tested on Ubuntu and Arch Linux using riscv64 toolchain. Clang compilation currently not supported due to issues with missing relocation relaxation.
Quoted 12 lines
Quoted 4 lines
Two
rte_rdtsc()schemes are provided: stable low-resolution using rdtime (default) and unstable high-resolution using rdcycle. User can override the scheme by defining RTE_RISCV_RDTSC_USE_HPM=1 during compile time of both DPDK and the application. The reasoning for this is as follows.Quoted 8 lines
The RISC-V ISA mandates that clock read by rdtime has to be of constant period and synchronized between all hardware threads within 1 tick (chapter 10.1 in version 20191213 of RISC-V spec).
However this clock may not be of high-enough frequency for dataplane uses. I.e. on HiFive Unmatched (FU740) it is 1MHz.
There is a high-resolution alternative in form of rdcycle which is clocked at the core clock frequency. The drawbacks are that it may be disabled during sleep (WFI) and its frequency might change due to DVFS.
Quoted 3 lines
Choosing at compile time is ok for embedded but is undesireable for DPDK in a distribution. It sounds like the low-res is equivalent to hpet and the unstable is same as x86 TSC.
AFAIK, TSC has constant frequency on newer processors (see [1] for a somewhat related Linux patch). To quote Intel
Software Developer’s Manual Volume 3, pt. 17.17.1:
The invariant TSC will run at a constant rate in all ACPI P-, C-. and T-states. This is the architectural behavior moving forward.
Quoted 3 lines
Therefore why not follow that
precedent and do the same thing?
Here the situation is more akin to ARMv8 with it's low-resolution CNTVCT and PMU based PMCCNTR. The former is always available in userspace (EL0) while access to the latter needs to be enabled via CSRs in kernel.
RDCYCLE on RISC-V is essentially the same as PMCCNTR, except that by default it's enabled (governed by OpenSBI firmware - see [2]). However it does not have the stable nature of TSC in RISC-V spec. AFAIK on ARM this has been dealt with similarly to x86, ARMv8.6-a forces a 1GHz frequency for CNTVCT.
So I based my implementation on the current ARM platform approach. Given that it seems RDCYCLE will remain enabled in userspace (see [2]), I can simplify this to use RDCYCLE if current ARM approach is not preferred.
[1] https://patchwork.kernel.org/project/kvm/patch/[email protected]/
[2] http://lists.infradead.org/pipermail/opensbi/2021-June/001219.html
PATCH v3 2/8 net/ixgbe: enable vector stubs for RISC-V
In reply to Stanislaw KardachRe-use vector processing stubs in ixgbe PMD defined for PPC for RISC-V. This enables ixgbe PMD usage in scalar mode on this architecture.
The ixgbe PMD driver was validated with Intel X520-DA2 NIC and the test-pmd application. Packet transfer checked using all UIO drivers available for non-IOMMU platforms: uio_pci_generic, vfio-pci noiommu and igb_uio.
--- doc/guides/nics/features/ixgbe.ini | 1 + drivers/net/ixgbe/ixgbe_rxtx.c | 4 ++-- drivers/net/ixgbe/meson.build | 6 ------ 3 files changed, 3 insertions(+), 8 deletions(-)
doc/guides/nics/features/ixgbe.ini +1 -0
@@ -54,6 +54,7 @@ Windows = Y ARMv8 = Y x86-32 = Y x86-64 = Y +rv64 = Y [rte_flow items] eth = Y
drivers/net/ixgbe/ixgbe_rxtx.c +2 -2
@@ -5957,8 +5957,8 @@ ixgbe_config_rss_filter(struct rte_eth_dev *dev,return 0 ; } -/* Stubs needed for linkage when RTE_ARCH_PPC_64 is set */ -#if defined(RTE_ARCH_PPC_64 ) +/* Stubs needed for linkage when RTE_ARCH_PPC_64 or RTE_ARCH_RISCV is set */ +#if defined(RTE_ARCH_PPC_64 ) || defined(RTE_ARCH_RISCV )int ixgbe_rx_vec_dev_conf_condition_check(struct rte_eth_dev __rte_unused *dev) {
drivers/net/ixgbe/meson.build +0 -6
@@ -1,12 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -if arch_subdir == 'riscv' - build = false - reason = 'riscv arch not supported' - subdir_done() -endif - cflags += ['-DRTE_LIBRTE_IXGBE_BYPASS'] subdir('base')
Signature · 1 line
2.30.2
PATCH v3 3/8 net/memif: set memfd syscall ID on RISC-V
In reply to Stanislaw KardachDefine the missing __NR_memfd_create syscall id to enable the memif PMD.
--- drivers/net/memif/meson.build | 5 ----- drivers/net/memif/rte_eth_memif.h | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/memif/meson.build +0 -5
@@ -5,11 +5,6 @@ if not is_linux build = false reason = 'only supported on Linux' endif -if arch_subdir == 'riscv' - build = false - reason = 'riscv arch not supported' - subdir_done() -endif sources = files( 'memif_socket.c',
drivers/net/memif/rte_eth_memif.h +2 -0
@@ -180,6 +180,8 @@ const char *memif_version(void);#define __NR_memfd_create 360#elif defined __i386__#define __NR_memfd_create 356 +#elif defined __riscv +#define __NR_memfd_create 279#else #error "__NR_memfd_create unknown for this architecture"#endif
Signature · 1 line
2.30.2
PATCH v3 4/8 net/tap: set BPF syscall ID for RISC-V
In reply to Stanislaw KardachDefine the missing __NR_bpf syscall id to enable the tap PMD.
--- drivers/net/tap/meson.build | 5 ----- drivers/net/tap/tap_bpf.h | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/tap/meson.build +0 -5
@@ -5,11 +5,6 @@ if not is_linux build = false reason = 'only supported on Linux' endif -if arch_subdir == 'riscv' - build = false - reason = 'riscv arch not supported' - subdir_done() -endif sources = files( 'rte_eth_tap.c', 'tap_bpf_api.c',
drivers/net/tap/tap_bpf.h +2 -0
@@ -101,6 +101,8 @@ union bpf_attr {# define __NR_bpf 351# elif defined(__powerpc__)# define __NR_bpf 361 +# elif defined(__riscv) +# define __NR_bpf 280# else # error __NR_bpf not defined# endif
Signature · 1 line
2.30.2
PATCH v3 5/8 examples/l3fwd: enable RISC-V operation
In reply to Stanislaw KardachAdd missing em_mask_key() implementation and fix l3fwd_common.h inclusion in FIB lookup functions to enable the l3fwd to be run on RISC-V.
--- examples/l3fwd/l3fwd_em.c | 8 ++++++++ examples/l3fwd/l3fwd_fib.c | 2 ++ examples/l3fwd/meson.build | 6 ------ 3 files changed, 10 insertions(+), 6 deletions(-)
examples/l3fwd/l3fwd_em.c +8 -0
@@ -239,6 +239,14 @@ em_mask_key(void *key, xmm_t mask) return vec_and(data, mask); } +#elif defined(RTE_ARCH_RISCV) +static inline xmm_t +em_mask_key (void *key,xmm_t mask) +{ +xmm_t data =vect_load_128 (key); + +return vect_and (data, mask); +}#else #error No vector engine (SSE, NEON, ALTIVEC) available, check your toolchain#endif
examples/l3fwd/l3fwd_fib.c +2 -0
@@ -18,6 +18,8 @@#include "l3fwd_neon.h" #elif definedRTE_ARCH_PPC_64 #include "l3fwd_altivec.h" +#else +#include "l3fwd_common.h" #endif #include "l3fwd_event.h" #include "l3fwd_route.h"
examples/l3fwd/meson.build +0 -6
@@ -6,12 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -if dpdk_conf.has('RTE_ARCH_RISCV') - build = false - reason = 'riscv arch not supported' - subdir_done() -endif - allow_experimental_apis = true deps += ['hash', 'lpm', 'fib', 'eventdev'] sources = files(
Signature · 1 line
2.30.2
PATCH v3 6/8 test/cpuflags: add test for RISC-V cpu flag
In reply to Stanislaw KardachFrom: Michal Mazurek <[email protected]>
Add checks for all flag values defined in the RISC-V misa CSR register.
--- app/test/test_cpuflags.c | 81 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)
app/test/test_cpuflags.c +81 -0
@@ -200,6 +200,87 @@ test_cpuflags(void)CHECK_FOR_FLAG (RTE_CPUFLAG_INVTSC );#endif +#if defined(RTE_ARCH_RISCV ) + +printf ("Check for RISCV_ISA_A:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_A ); + +printf ("Check for RISCV_ISA_B:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_B ); + +printf ("Check for RISCV_ISA_C:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_C ); + +printf ("Check for RISCV_ISA_D:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_D ); + +printf ("Check for RISCV_ISA_E:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_E ); + +printf ("Check for RISCV_ISA_F:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_F ); + +printf ("Check for RISCV_ISA_G:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_G ); + +printf ("Check for RISCV_ISA_H:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_H ); + +printf ("Check for RISCV_ISA_I:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_I ); + +printf ("Check for RISCV_ISA_J:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_J ); + +printf ("Check for RISCV_ISA_K:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_K ); + +printf ("Check for RISCV_ISA_L:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_L ); + +printf ("Check for RISCV_ISA_M:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_M ); + +printf ("Check for RISCV_ISA_N:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_N ); + +printf ("Check for RISCV_ISA_O:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_O ); + +printf ("Check for RISCV_ISA_P:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_P ); + +printf ("Check for RISCV_ISA_Q:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_Q ); + +printf ("Check for RISCV_ISA_R:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_R ); + +printf ("Check for RISCV_ISA_S:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_S ); + +printf ("Check for RISCV_ISA_T:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_T ); + +printf ("Check for RISCV_ISA_U:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_U ); + +printf ("Check for RISCV_ISA_V:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_V ); + +printf ("Check for RISCV_ISA_W:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_W ); + +printf ("Check for RISCV_ISA_X:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_X ); + +printf ("Check for RISCV_ISA_Y:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_Y ); + +printf ("Check for RISCV_ISA_Z:\t" ); +CHECK_FOR_FLAG (RTE_CPUFLAG_RISCV_ISA_Z ); +#endif +/* * Check if invalid data is handled properly */
Signature · 1 line
2.30.2
PATCH v3 7/8 devtools: add RISC-V to test-meson-builds.sh
In reply to Stanislaw KardachValidate RISC-V compilation when test-meson-builds.sh is called. The check will be only performed if appropriate toolchain is present on the system (same as with other architectures).
--- devtools/test-meson-builds.sh | 4 ++++ 1 file changed, 4 insertions(+)
devtools/test-meson-builds.sh +4 -0
@@ -275,6 +275,10 @@ for f in $srcdir/config/ppc/ppc* ; do build $targetdir $f ABI $use_shared done +# RISC-V configuration +build build-riscv64-linux-gcc $srcdir/config/riscv/riscv64_linux_gcc ABI \ + $use_shared + # Test installation of the x86-generic target, to be used for checking # the sample apps build using the pkg-config file for cflags and libs load_env cc
Signature · 1 line
2.30.2
PATCH v3 8/8 ci: add RISCV64 cross compilation job
In reply to Stanislaw KardachChecks cross-compilation using Ubuntu 20.04 x86.
--- .ci/linux-build.sh | 4 ++++ .github/workflows/build.yml | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)
.ci/linux-build.sh +4 -0
@@ -74,6 +74,10 @@ if [ "$PPC64LE" = "true" ]; then cross_file=config/ppc/ppc64le-power8-linux-gcc-ubuntu fi +if [ "$RISCV64" = "true" ]; then + cross_file=config/riscv/riscv64_linux_gcc +fi + if [ -n "$cross_file" ]; then OPTS="$OPTS --cross-file $cross_file" fi
.github/workflows/build.yml +10 -1
@@ -25,6 +25,7 @@ jobs: MINI: ${{ matrix.config.mini != '' }} PPC64LE: ${{ matrix.config.cross == 'ppc64le' }} REF_GIT_TAG: v22.03 + RISCV64: ${{ matrix.config.cross == 'riscv64' }} RUN_TESTS: ${{ contains(matrix.config.checks, 'tests') }} strategy:
@@ -73,6 +74,10 @@ jobs: compiler: gcc library: shared cross: ppc64le + - os: ubuntu-20.04 + compiler: gcc + library: shared + cross: riscv64 steps: - name: Checkout sources
@@ -131,8 +136,12 @@ jobs: if: env.PPC64LE == 'true' run: sudo apt install -y gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross pkg-config-powerpc-linux-gnu + - name: Install riscv64 cross compiling packages + if: env.RISCV64 == 'true' + run: sudo apt install -y gcc-riscv64-linux-gnu libc6-dev-riscv64-cross + pkg-config-riscv64-linux-gnu - name: Install test tools packages - if: env.AARCH64 != 'true' || env.PPC64LE != 'true' || env.RUN_TESTS == 'true' + if: env.AARCH64 != 'true' || env.PPC64LE != 'true' || env.RISCV64 != 'true' || env.RUN_TESTS == 'true' run: sudo apt install -y gdb - name: Install doc generation packages if: env.BUILD_DOCS == 'true'
Signature · 1 line
2.30.2
Re: [PATCH v3 8/8] ci: add RISCV64 cross compilation job
Quoted 8 lines · Stanislaw Kardach
Checks cross-compilation using Ubuntu 20.04 x86.
Signed-off-by David Marchand <[email protected]>Signed-off-by Stanislaw Kardach <[email protected]>--- .ci/linux-build.sh | 4 ++++ .github/workflows/build.yml | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)
Seems there is still a failure in this series - once that is resolved I think this can go in.
Quoted 52 lines
.ci/linux-build.sh +4
-0@@ -74,6 +74,10 @@ if [ "$PPC64LE" = "true" ]; then cross_file=config/ppc/ppc64le-power8-linux-gcc-ubuntu fi +if [ "$RISCV64" = "true" ]; then + cross_file=config/riscv/riscv64_linux_gcc +fi + if [ -n "$cross_file" ]; then OPTS="$OPTS --cross-file $cross_file" fi.github/workflows/build.yml +10
-1@@ -25,6 +25,7 @@ jobs: MINI: ${{ matrix.config.mini != '' }} PPC64LE: ${{ matrix.config.cross == 'ppc64le' }} REF_GIT_TAG: v22.03 + RISCV64: ${{ matrix.config.cross == 'riscv64' }} RUN_TESTS: ${{ contains(matrix.config.checks, 'tests') }} strategy:@@ -73,6 +74,10 @@ jobs: compiler: gcc library: shared cross: ppc64le + - os: ubuntu-20.04 + compiler: gcc + library: shared + cross: riscv64 steps: - name: Checkout sources@@ -131,8 +136,12 @@ jobs: if: env.PPC64LE == 'true' run: sudo apt install -y gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross pkg-config-powerpc-linux-gnu + - name: Install riscv64 cross compiling packages + if: env.RISCV64 == 'true' + run: sudo apt install -y gcc-riscv64-linux-gnu libc6-dev-riscv64-cross + pkg-config-riscv64-linux-gnu - name: Install test tools packages - if: env.AARCH64 != 'true' || env.PPC64LE != 'true' || env.RUN_TESTS == 'true' + if: env.AARCH64 != 'true' || env.PPC64LE != 'true' || env.RISCV64 != 'true' || env.RUN_TESTS == 'true' run: sudo apt install -y gdb - name: Install doc generation packages if: env.BUILD_DOCS == 'true'
Re: [PATCH v3 8/8] ci: add RISCV64 cross compilation job
Quoted 11 lines · On Thu, 12 May 2022, 17:47 Aaron Conole, <[email protected]> wrote:
Quoted 8 lines · Stanislaw Kardach
Checks cross-compilation using Ubuntu 20.04 x86.
Signed-off-by David Marchand <[email protected]>Signed-off-by Stanislaw Kardach <[email protected]>--- .ci/linux-build.sh | 4 ++++ .github/workflows/build.yml | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)
Quoted 3 lines
Seems there is still a failure in this series - once that is resolved I think this can go in.
I suspect the failure is due to this series depending on 3 other patches which I've marked with Depends-on in the offending patch. Is CI utilizing those tags? If not, is there a way to relaunch it once dependencies are integrated?
Quoted 59 lines
Quoted 40 lines
.ci/linux-build.sh +4
-0@@ -74,6 +74,10 @@ if [ "$PPC64LE" = "true" ]; then cross_file=config/ppc/ppc64le-power8-linux-gcc-ubuntu fi +if [ "$RISCV64" = "true" ]; then + cross_file=config/riscv/riscv64_linux_gcc +fi + if [ -n "$cross_file" ]; then OPTS="$OPTS --cross-file $cross_file" fi.github/workflows/build.yml +5
-0@@ -25,6 +25,7 @@ jobs: MINI: ${{ matrix.config.mini != '' }} PPC64LE: ${{ matrix.config.cross == 'ppc64le' }} REF_GIT_TAG: v22.03 + RISCV64: ${{ matrix.config.cross == 'riscv64' }} RUN_TESTS: ${{ contains(matrix.config.checks, 'tests') }} strategy:@@ -73,6 +74,10 @@ jobs: compiler: gcc library: shared cross: ppc64le + - os: ubuntu-20.04 + compiler: gcc + library: shared + cross: riscv64 steps: - name: Checkout sources.github/workflows/build.yml jobs: · line 137
Quoted 2 lines
.github/workflows/build.yml +0
-0@@ -131,8 +136,12 @@ jobs: if: env.PPC64LE == 'true' run: sudo apt install -y gcc-powerpc64le-linux-gnulibc6-dev-ppc64el-cross
.github/workflows/build.yml jobs:
Quoted 4 lines
.github/workflows/build.yml +3
-0pkg-config-powerpc-linux-gnu + - name: Install riscv64 cross compiling packages + if: env.RISCV64 == 'true' + run: sudo apt install -y gcc-riscv64-linux-gnulibc6-dev-riscv64-cross
.github/workflows/build.yml jobs:
Quoted 3 lines
.github/workflows/build.yml +1
-1+ pkg-config-riscv64-linux-gnu - name: Install test tools packages - if: env.AARCH64 != 'true' || env.PPC64LE != 'true' ||env.RUN_TESTS == 'true'
.github/workflows/build.yml jobs: · line 144
Quoted 1 line
.github/workflows/build.yml +1
-0+ if: env.AARCH64 != 'true' || env.PPC64LE != 'true' || env.RISCV64!= 'true' || env.RUN_TESTS == 'true'
Quoted 3 lines
.github/workflows/build.yml +0
-0run: sudo apt install -y gdb - name: Install doc generation packages if: env.BUILD_DOCS == 'true'
Re: [PATCH v3 8/8] ci: add RISCV64 cross compilation job
Quoted 13 lines · Stanisław Kardach
On Thu, 12 May 2022, 17:47 Aaron Conole, <[email protected]> wrote:
Quoted 8 lines · Stanislaw Kardach
Checks cross-compilation using Ubuntu 20.04 x86.
Signed-off-by David Marchand <[email protected]>Signed-off-by Stanislaw Kardach <[email protected]>--- .ci/linux-build.sh | 4 ++++ .github/workflows/build.yml | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)
Quoted 5 lines
Seems there is still a failure in this series - once that is resolved I think this can go in.
I suspect the failure is due to this series depending on 3 other patches which I've marked with Depends-on in the offending patch. Is CI utilizing those tags? If not, is there a way to relaunch it once dependencies are integrated?
Ahh okay - yes 0day bot doesn't currently use that. It's planned for after the system upgrade (date on that is pending).
Quoted 52 lines
Quoted 52 lines
.ci/linux-build.sh +4
-0@@ -74,6 +74,10 @@ if [ "$PPC64LE" = "true" ]; then cross_file=config/ppc/ppc64le-power8-linux-gcc-ubuntu fi +if [ "$RISCV64" = "true" ]; then + cross_file=config/riscv/riscv64_linux_gcc +fi + if [ -n "$cross_file" ]; then OPTS="$OPTS --cross-file $cross_file" fi.github/workflows/build.yml +10
-1@@ -25,6 +25,7 @@ jobs: MINI: ${{ matrix.config.mini != '' }} PPC64LE: ${{ matrix.config.cross == 'ppc64le' }} REF_GIT_TAG: v22.03 + RISCV64: ${{ matrix.config.cross == 'riscv64' }} RUN_TESTS: ${{ contains(matrix.config.checks, 'tests') }} strategy:@@ -73,6 +74,10 @@ jobs: compiler: gcc library: shared cross: ppc64le + - os: ubuntu-20.04 + compiler: gcc + library: shared + cross: riscv64 steps: - name: Checkout sources@@ -131,8 +136,12 @@ jobs: if: env.PPC64LE == 'true' run: sudo apt install -y gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross pkg-config-powerpc-linux-gnu + - name: Install riscv64 cross compiling packages + if: env.RISCV64 == 'true' + run: sudo apt install -y gcc-riscv64-linux-gnu libc6-dev-riscv64-cross + pkg-config-riscv64-linux-gnu - name: Install test tools packages - if: env.AARCH64 != 'true' || env.PPC64LE != 'true' || env.RUN_TESTS == 'true' + if: env.AARCH64 != 'true' || env.PPC64LE != 'true' || env.RISCV64 != 'true' || env.RUN_TESTS == 'true' run: sudo apt install -y gdb - name: Install doc generation packages if: env.BUILD_DOCS == 'true'
Quoted 27 lines · Stanislaw Kardach
This patchset adds support for building and running DPDK on 64bit RISC-V architecture. The initial support targets rv64gc (rv64imafdc) ISA and was tested on SiFive Unmatched development board with the Freedom U740 SoC running Linux (freedom-u-sdk based kernel).
I have tested this codebase using DPDK unit and perf tests as well as test-pmd, l2fwd and l3fwd examples.
The NIC attached to the DUT was Intel X520-DA2 which uses ixgbe PMD. On the UIO side, since U740 does not have an IOMMU, I've usedigb_uio,uio_pci_genericand vfio-pci noiommu drivers.Commits 1-2 fix small issues which are encountered if a given platform
does not support any vector operations (which is the case with U740).
Commit 3 introduces EAL and build system support for RISC-V architecture
as well as documentation updates.
Commits 4-7 add missing defines and stubs to enable RISC-V operation in
non-EAL parts.
Commit 8 adds RISC-V specific cpuflags test.
Commit 9 works around a bug in the current GCC intest_ringcompiled
with -O0 or -Og.
Commit 10 adds RISC-V testing totest-meson-builds.shautomatically
iterating over cross-compile config files (currently present for generic rv64gc and SiFive U740).
Commit 11 extends hash r/w perf test by displaying both HTM and non-HTM
measurements. This is an extraneous commit which is not directly needed for RISC-V support but was noticed when we have started gathering test results. If needed, I can submit it separately.
Quoted 4 lines
I appreciate Your comments and feedback.
Best Regards,
Stanislaw Kardach
On an SiFive Unmatched board with Ubuntu Jammy I have been compiling DPDK origin/main (36db4a1ad464) with this series and the test patches that you split off.
The fast tests are either skipped or succeed. But I have seen errors for the performance tests:
4 1GiB hugepages defined
no network devices bound vfio_pci loaded (no IOMMU)
sudo meson -t 30
129/173 DPDK:perf-tests / pmd_perf_autotest FAIL 7.85s (exit status 255 or signal 127 SIGinvalid)
Quoted 1 line
Quoted 1 line
Quoted 1 line
DPDK_TEST=pmd_perf_autotest MALLOC_PERTURB_=135 build/app/test/dpdk-test
136/173 DPDK:perf-tests / ipsec_perf_autotest FAIL 4.47s (exit status 255 or signal 127 SIGinvalid)
Quoted 1 line
Quoted 1 line
Quoted 1 line
MALLOC_PERTURB_=181 DPDK_TEST=ipsec_perf_autotest build/app/test/dpdk-test
160/173 DPDK:driver-tests / link_bonding_mode4_autotest FAIL 31.80s killed by signal 11 SIGSEGV
Quoted 1 line
Quoted 1 line
Quoted 1 line
MALLOC_PERTURB_=62 DPDK_TEST=link_bonding_mode4_autotest build/app/test/dpdk-test
These are the patches used:
# [PATCH 1/1] lpm: add a scalar version of lookupx4 function
https://inbox.dpdk.org/dev/[email protected]/
# [PATCH 1/1] examples/l3fwd: fix scalar LPM compilation
https://inbox.dpdk.org/dev/[email protected]/
# [PATCH 1/1] test/hash: report non HTM numbers for single r/w
https://inbox.dpdk.org/dev/[email protected]/
# [PATCH 1/1] test/ring: remove excessive inlining
https://inbox.dpdk.org/dev/[email protected]/
# [PATCH v3 0/8] Introduce support for RISC-V architecture
https://inbox.dpdk.org/dev/[email protected]/
# [PATCH 1/1] drivers: define OPENSSL_API_COMPAT
https://inbox.dpdk.org/dev/[email protected]/
Running sudo app/test/dpdk-test does not show the errors:
RTE>>pmd_perf_autotest
Start PMD RXTX cycles cost test. At least 1 port(s) used for perf. test Test Failed RTE>>ipsec_perf_autotest
USER1: rte_ipsec_pkt_crypto_prepare fail Test Failed RTE>>link_bonding_mode4_autotest
...
Test OK
RTE>
Best regards
Heinrich
Quoted 105 lines
NOTE: This work was sponsored by StarFive and SiFive which is signified by
"Sponsored-by:" sign-offs in each commit message. After discussing it with Thomas Monjalon it seemed a better choice than "Suggested-by" which does not fully convey the nature of involvement. However it makes Linux checkpatch unhappy so I'm not sure if I shouldn't change the sign-offs.NOTE2: I have added maintainers for each commit based on
MAINTAINERSfile.
However some modules (l3fwd, net/tap and cpuflags unit tests) do not have any maintainers assigned, hence I've targeted [email protected] mailing list as if it was a commit adding new files.Michal Mazurek (3):
lpm: add a scalar version of lookupx4 function
eal: add initial support for RISC-V architecture test/cpuflags: add test for RISC-V cpu flagStanislaw Kardach (8):
examples/l3fwd: fix scalar LPM compilation net/ixgbe: enable vector stubs for RISC-V net/memif: set memfd syscall ID on RISC-V net/tap: set BPF syscall ID for RISC-V examples/l3fwd: enable RISC-V operation test/ring: disable problematic tests for RISC-V
devtools: add RISC-V totest-meson-builds.shtest/hash: report non HTM numbers for single r/wMAINTAINERS | 6 + app/test/test_cpuflags.c | 81 ++++++++++ app/test/test_hash_readwrite.c | 8 +- app/test/test_ring.c | 8 + app/test/test_xmmt_ops.h | 16 ++ config/meson.build | 2 + config/riscv/meson.build | 148 ++++++++++++++++++ config/riscv/riscv64_linux_gcc | 17 ++ config/riscv/riscv64_sifive_u740_linux_gcc | 19 +++ devtools/test-meson-builds.sh | 6 + doc/guides/contributing/design.rst | 2 +- .../linux_gsg/cross_build_dpdk_for_riscv.rst | 125 +++++++++++++++ doc/guides/linux_gsg/index.rst | 1 + doc/guides/nics/features.rst | 5 + doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/ixgbe.ini | 1 + doc/guides/rel_notes/release_22_07.rst | 29 ++++ drivers/net/i40e/meson.build | 6 + drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- drivers/net/memif/rte_eth_memif.h | 2 + drivers/net/tap/tap_bpf.h | 2 + examples/l3fwd/l3fwd_em.c | 8 + examples/l3fwd/l3fwd_fib.c | 2 + examples/l3fwd/l3fwd_lpm.c | 2 +- lib/eal/riscv/include/meson.build | 23 +++ lib/eal/riscv/include/rte_atomic.h | 52 ++++++ lib/eal/riscv/include/rte_byteorder.h | 44 ++++++ lib/eal/riscv/include/rte_cpuflags.h | 55 +++++++ lib/eal/riscv/include/rte_cycles.h | 103 ++++++++++++ lib/eal/riscv/include/rte_io.h | 21 +++ lib/eal/riscv/include/rte_mcslock.h | 18 +++ lib/eal/riscv/include/rte_memcpy.h | 63 ++++++++ lib/eal/riscv/include/rte_pause.h | 31 ++++ lib/eal/riscv/include/rte_pflock.h | 17 ++ lib/eal/riscv/include/rte_power_intrinsics.h | 22 +++ lib/eal/riscv/include/rte_prefetch.h | 50 ++++++ lib/eal/riscv/include/rte_rwlock.h | 44 ++++++ lib/eal/riscv/include/rte_spinlock.h | 67 ++++++++ lib/eal/riscv/include/rte_ticketlock.h | 21 +++ lib/eal/riscv/include/rte_vect.h | 55 +++++++ lib/eal/riscv/meson.build | 11 ++ lib/eal/riscv/rte_cpuflags.c | 122 +++++++++++++++ lib/eal/riscv/rte_cycles.c | 77 +++++++++ lib/eal/riscv/rte_hypervisor.c | 13 ++ lib/eal/riscv/rte_power_intrinsics.c | 56 +++++++ lib/lpm/meson.build | 1 + lib/lpm/rte_lpm.h | 4 +- lib/lpm/rte_lpm_scalar.h | 122 +++++++++++++++ meson.build | 2 + 49 files changed, 1588 insertions(+), 7 deletions(-)create mode 100644 config/riscv/meson.build
create mode 100644 config/riscv/riscv64_linux_gcc
create mode 100644 config/riscv/riscv64_sifive_u740_linux_gcc create mode 100644doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rstcreate mode 100644lib/eal/riscv/include/meson.buildcreate mode 100644lib/eal/riscv/include/rte_atomic.hcreate mode 100644lib/eal/riscv/include/rte_byteorder.hcreate mode 100644lib/eal/riscv/include/rte_cpuflags.hcreate mode 100644lib/eal/riscv/include/rte_cycles.hcreate mode 100644lib/eal/riscv/include/rte_io.h
create mode 100644lib/eal/riscv/include/rte_mcslock.hcreate mode 100644lib/eal/riscv/include/rte_memcpy.hcreate mode 100644lib/eal/riscv/include/rte_pause.hcreate mode 100644lib/eal/riscv/include/rte_pflock.hcreate mode 100644lib/eal/riscv/include/rte_power_intrinsics.hcreate mode 100644lib/eal/riscv/include/rte_prefetch.hcreate mode 100644lib/eal/riscv/include/rte_rwlock.hcreate mode 100644lib/eal/riscv/include/rte_spinlock.hcreate mode 100644lib/eal/riscv/include/rte_ticketlock.hcreate mode 100644lib/eal/riscv/include/rte_vect.h
create mode 100644lib/eal/riscv/meson.build
create mode 100644lib/eal/riscv/rte_cpuflags.c
create mode 100644lib/eal/riscv/rte_cycles.c
create mode 100644lib/eal/riscv/rte_hypervisor.c
create mode 100644lib/eal/riscv/rte_power_intrinsics.ccreate mode 100644lib/lpm/rte_lpm_scalar.h
Quoted 29 lines · Heinrich Schuchardt
Quoted 27 lines · Stanislaw Kardach
This patchset adds support for building and running DPDK on 64bit RISC-V architecture. The initial support targets rv64gc (rv64imafdc) ISA and was tested on SiFive Unmatched development board with the Freedom U740 SoC running Linux (freedom-u-sdk based kernel).
I have tested this codebase using DPDK unit and perf tests as well as test-pmd, l2fwd and l3fwd examples.
The NIC attached to the DUT was Intel X520-DA2 which uses ixgbe PMD. On the UIO side, since U740 does not have an IOMMU, I've usedigb_uio,uio_pci_genericand vfio-pci noiommu drivers.Commits 1-2 fix small issues which are encountered if a given platform
does not support any vector operations (which is the case with U740).
Commit 3 introduces EAL and build system support for RISC-V architecture
as well as documentation updates.
Commits 4-7 add missing defines and stubs to enable RISC-V operation in
non-EAL parts.
Commit 8 adds RISC-V specific cpuflags test.
Commit 9 works around a bug in the current GCC intest_ringcompiled
with -O0 or -Og.
Commit 10 adds RISC-V testing totest-meson-builds.shautomatically
iterating over cross-compile config files (currently present for generic rv64gc and SiFive U740).
Commit 11 extends hash r/w perf test by displaying both HTM and non-HTM
measurements. This is an extraneous commit which is not directly needed for RISC-V support but was noticed when we have started gathering test results. If needed, I can submit it separately.
Quoted 8 lines
Quoted 4 lines
I appreciate Your comments and feedback.
Best Regards,
Stanislaw KardachOn an SiFive Unmatched board with Ubuntu Jammy I have been compiling DPDK origin/main (
36db4a1ad464) with this series and the test patches that you split off.
Thank you for testing!
Quoted 8 lines
The fast tests are either skipped or succeed. But I have seen errors for the performance tests:
4 1GiB hugepages defined
no network devices boundvfio_pciloaded (no IOMMU)
Quoted 6 lines
sudo meson -t 30
129/173 DPDK:perf-tests /
pmd_perf_autotestFAIL 7.85s (exit status 255 or signal 127 SIGinvalid)Quoted 1 line
Quoted 1 line
Quoted 1 line
DPDK_TEST=pmd_perf_autotest MALLOC_PERTURB_=135
build/app/test/dpdk-test
This test I believe requires at least a single NIC port. Conversely fast-tests seem to fail if a device is bound. DPDK CI doesn't bind any on fast-tests, I'm not sure if perf-tests suite is run there. On my local x86 machine perf-tests suite fails when no device is bound too.
Quoted 4 lines
136/173 DPDK:perf-tests /
ipsec_perf_autotestFAIL 4.47s (exit status 255 or signal 127 SIGinvalid)Quoted 1 line
Quoted 1 line
Quoted 1 line
MALLOC_PERTURB_=181 DPDK_TEST=ipsec_perf_autotest
build/app/test/dpdk-test
On my unmatched I don't have openssl compiled so most crypto tests are skipped (since no openssl is installed), aside of this one and it indeed fails. I'm not sure whether it's a matter of a lack of a guard to skip this test if there's no crypto backend built or if it's a real issue.
I admit I haven't tried crypto libraries with RISC-V openssl as there's no real HW offloading on Unmatched.
Quoted 4 lines
160/173 DPDK:driver-tests /
link_bonding_mode4_autotestFAIL 31.80s killed by signal 11 SIGSEGVQuoted 1 line
Quoted 1 line
Quoted 1 line
MALLOC_PERTURB_=62 DPDK_TEST=link_bonding_mode4_autotest
build/app/test/dpdk-test
I use -t40 when testing on Unmatched. Unfortunately lots of the tests hit timeouts.
Quoted 141 lines
These are the patches used:
# [PATCH 1/1] lpm: add a scalar version of lookupx4 function
https://inbox.dpdk.org/dev/[email protected]/
# [PATCH 1/1] examples/l3fwd: fix scalar LPM compilation
https://inbox.dpdk.org/dev/[email protected]/
# [PATCH 1/1] test/hash: report non HTM numbers for single r/w
https://inbox.dpdk.org/dev/[email protected]/
# [PATCH 1/1] test/ring: remove excessive inlining
https://inbox.dpdk.org/dev/[email protected]/
# [PATCH v3 0/8] Introduce support for RISC-V architecture
https://inbox.dpdk.org/dev/[email protected]/
# [PATCH 1/1] drivers: defineOPENSSL_API_COMPAThttps://inbox.dpdk.org/dev/[email protected]/
Running sudo app/test/dpdk-test does not show the errors:
RTE>>pmd_perf_autotest
Start PMD RXTX cycles cost test.
At least 1 port(s) used for perf. test
Test Failed
RTE>>ipsec_perf_autotest
USER1:rte_ipsec_pkt_crypto_preparefail
Test Failed
RTE>>link_bonding_mode4_autotest
...
Test OK
RTE>Best regards
Heinrich
Quoted 105 lines
NOTE: This work was sponsored by StarFive and SiFive which is signified by
"Sponsored-by:" sign-offs in each commit message. After discussing it with Thomas Monjalon it seemed a better choice than "Suggested-by" which does not fully convey the nature of involvement. However it makes Linux checkpatch unhappy so I'm not sure if I shouldn't change the sign-offs.NOTE2: I have added maintainers for each commit based on
MAINTAINERSfile.
However some modules (l3fwd, net/tap and cpuflags unit tests) do not have any maintainers assigned, hence I've targeted [email protected] mailing list as if it was a commit adding new files.Michal Mazurek (3):
lpm: add a scalar version of lookupx4 function
eal: add initial support for RISC-V architecture test/cpuflags: add test for RISC-V cpu flagStanislaw Kardach (8):
examples/l3fwd: fix scalar LPM compilation net/ixgbe: enable vector stubs for RISC-V net/memif: set memfd syscall ID on RISC-V net/tap: set BPF syscall ID for RISC-V examples/l3fwd: enable RISC-V operation test/ring: disable problematic tests for RISC-V
devtools: add RISC-V totest-meson-builds.shtest/hash: report non HTM numbers for single r/wMAINTAINERS | 6 + app/test/test_cpuflags.c | 81 ++++++++++ app/test/test_hash_readwrite.c | 8 +- app/test/test_ring.c | 8 + app/test/test_xmmt_ops.h | 16 ++ config/meson.build | 2 + config/riscv/meson.build | 148 ++++++++++++++++++ config/riscv/riscv64_linux_gcc | 17 ++ config/riscv/riscv64_sifive_u740_linux_gcc | 19 +++ devtools/test-meson-builds.sh | 6 + doc/guides/contributing/design.rst | 2 +- .../linux_gsg/cross_build_dpdk_for_riscv.rst | 125 +++++++++++++++ doc/guides/linux_gsg/index.rst | 1 + doc/guides/nics/features.rst | 5 + doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/ixgbe.ini | 1 + doc/guides/rel_notes/release_22_07.rst | 29 ++++ drivers/net/i40e/meson.build | 6 + drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- drivers/net/memif/rte_eth_memif.h | 2 + drivers/net/tap/tap_bpf.h | 2 + examples/l3fwd/l3fwd_em.c | 8 + examples/l3fwd/l3fwd_fib.c | 2 + examples/l3fwd/l3fwd_lpm.c | 2 +- lib/eal/riscv/include/meson.build | 23 +++ lib/eal/riscv/include/rte_atomic.h | 52 ++++++ lib/eal/riscv/include/rte_byteorder.h | 44 ++++++ lib/eal/riscv/include/rte_cpuflags.h | 55 +++++++ lib/eal/riscv/include/rte_cycles.h | 103 ++++++++++++ lib/eal/riscv/include/rte_io.h | 21 +++ lib/eal/riscv/include/rte_mcslock.h | 18 +++ lib/eal/riscv/include/rte_memcpy.h | 63 ++++++++ lib/eal/riscv/include/rte_pause.h | 31 ++++ lib/eal/riscv/include/rte_pflock.h | 17 ++ lib/eal/riscv/include/rte_power_intrinsics.h | 22 +++ lib/eal/riscv/include/rte_prefetch.h | 50 ++++++ lib/eal/riscv/include/rte_rwlock.h | 44 ++++++ lib/eal/riscv/include/rte_spinlock.h | 67 ++++++++ lib/eal/riscv/include/rte_ticketlock.h | 21 +++ lib/eal/riscv/include/rte_vect.h | 55 +++++++ lib/eal/riscv/meson.build | 11 ++ lib/eal/riscv/rte_cpuflags.c | 122 +++++++++++++++ lib/eal/riscv/rte_cycles.c | 77 +++++++++ lib/eal/riscv/rte_hypervisor.c | 13 ++ lib/eal/riscv/rte_power_intrinsics.c | 56 +++++++ lib/lpm/meson.build | 1 + lib/lpm/rte_lpm.h | 4 +- lib/lpm/rte_lpm_scalar.h | 122 +++++++++++++++ meson.build | 2 + 49 files changed, 1588 insertions(+), 7 deletions(-)create mode 100644 config/riscv/meson.build
create mode 100644 config/riscv/riscv64_linux_gcc
create mode 100644 config/riscv/riscv64_sifive_u740_linux_gcc create mode 100644doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rstcreate mode 100644lib/eal/riscv/include/meson.buildcreate mode 100644lib/eal/riscv/include/rte_atomic.hcreate mode 100644lib/eal/riscv/include/rte_byteorder.hcreate mode 100644lib/eal/riscv/include/rte_cpuflags.hcreate mode 100644lib/eal/riscv/include/rte_cycles.hcreate mode 100644lib/eal/riscv/include/rte_io.h
create mode 100644lib/eal/riscv/include/rte_mcslock.hcreate mode 100644lib/eal/riscv/include/rte_memcpy.hcreate mode 100644lib/eal/riscv/include/rte_pause.hcreate mode 100644lib/eal/riscv/include/rte_pflock.hcreate mode 100644lib/eal/riscv/include/rte_power_intrinsics.hcreate mode 100644lib/eal/riscv/include/rte_prefetch.hcreate mode 100644lib/eal/riscv/include/rte_rwlock.hcreate mode 100644lib/eal/riscv/include/rte_spinlock.hcreate mode 100644lib/eal/riscv/include/rte_ticketlock.hcreate mode 100644lib/eal/riscv/include/rte_vect.h
create mode 100644lib/eal/riscv/meson.build
create mode 100644lib/eal/riscv/rte_cpuflags.c
create mode 100644lib/eal/riscv/rte_cycles.c
create mode 100644lib/eal/riscv/rte_hypervisor.c
create mode 100644lib/eal/riscv/rte_power_intrinsics.ccreate mode 100644lib/lpm/rte_lpm_scalar.h
Quoted 71 lines · Stanisław Kardach
Quoted 29 lines · Heinrich Schuchardt
Quoted 27 lines · Stanislaw Kardach
This patchset adds support for building and running DPDK on 64bit RISC-V architecture. The initial support targets rv64gc (rv64imafdc) ISA and was tested on SiFive Unmatched development board with the Freedom U740 SoC running Linux (freedom-u-sdk based kernel).
I have tested this codebase using DPDK unit and perf tests as well as test-pmd, l2fwd and l3fwd examples.
The NIC attached to the DUT was Intel X520-DA2 which uses ixgbe PMD. On the UIO side, since U740 does not have an IOMMU, I've usedigb_uio,uio_pci_genericand vfio-pci noiommu drivers.Commits 1-2 fix small issues which are encountered if a given platform
does not support any vector operations (which is the case with U740).
Commit 3 introduces EAL and build system support for RISC-V architecture
as well as documentation updates.
Commits 4-7 add missing defines and stubs to enable RISC-V operation in
non-EAL parts.
Commit 8 adds RISC-V specific cpuflags test.
Commit 9 works around a bug in the current GCC intest_ringcompiled
with -O0 or -Og.
Commit 10 adds RISC-V testing totest-meson-builds.shautomatically
iterating over cross-compile config files (currently present for generic rv64gc and SiFive U740).
Commit 11 extends hash r/w perf test by displaying both HTM and non-HTM
measurements. This is an extraneous commit which is not directly needed for RISC-V support but was noticed when we have started gathering test results. If needed, I can submit it separately.Quoted 8 lines
Quoted 4 lines
I appreciate Your comments and feedback.
Best Regards,
Stanislaw KardachOn an SiFive Unmatched board with Ubuntu Jammy I have been compiling DPDK origin/main (
36db4a1ad464) with this series and the test patches that you split off.Thank you for testing!
Quoted 8 lines
The fast tests are either skipped or succeed. But I have seen errors for the performance tests:
4 1GiB hugepages defined
no network devices boundvfio_pciloaded (no IOMMU)Quoted 6 lines
sudo meson -t 30
129/173 DPDK:perf-tests /
pmd_perf_autotestFAIL 7.85s (exit status 255 or signal 127 SIGinvalid)Quoted 1 line
Quoted 1 line
Quoted 1 line
DPDK_TEST=pmd_perf_autotest MALLOC_PERTURB_=135
build/app/test/dpdk-test
This test I believe requires at least a single NIC port. Conversely fast-tests seem to fail if a device is bound. DPDK CI doesn't bind any on fast-tests, I'm not sure if perf-tests suite is run there. On my local x86 machine perf-tests suite fails when no device is bound too.
Quoted 4 lines
136/173 DPDK:perf-tests /
ipsec_perf_autotestFAIL 4.47s (exit status 255 or signal 127 SIGinvalid)Quoted 1 line
Quoted 1 line
Quoted 1 line
MALLOC_PERTURB_=181 DPDK_TEST=ipsec_perf_autotest
build/app/test/dpdk-test
On my unmatched I don't have openssl compiled so most crypto tests are skipped (since no openssl is installed), aside of this one and it indeed fails. I'm not sure whether it's a matter of a lack of a guard to skip this test if there's no crypto backend built or if it's a real issue.
I admit I haven't tried crypto libraries with RISC-V openssl as there's no real HW offloading on Unmatched.
Quoted 41 lines
Quoted 4 lines
160/173 DPDK:driver-tests /
link_bonding_mode4_autotestFAIL 31.80s killed by signal 11 SIGSEGVQuoted 1 line
Quoted 1 line
Quoted 1 line
MALLOC_PERTURB_=62 DPDK_TEST=link_bonding_mode4_autotest
build/app/test/dpdk-test
I use -t40 when testing on Unmatched. Unfortunately lots of the tests hit timeouts.
Quoted 34 lines
These are the patches used:
# [PATCH 1/1] lpm: add a scalar version of lookupx4 function
https://inbox.dpdk.org/dev/[email protected]/ # [PATCH 1/1] examples/l3fwd: fix scalar LPM compilation https://inbox.dpdk.org/dev/[email protected]/ # [PATCH 1/1] test/hash: report non HTM numbers for single r/w https://inbox.dpdk.org/dev/[email protected]/ # [PATCH 1/1] test/ring: remove excessive inlining https://inbox.dpdk.org/dev/[email protected]/ # [PATCH v3 0/8] Introduce support for RISC-V architecture https://inbox.dpdk.org/dev/[email protected]/# [PATCH 1/1] drivers: define
OPENSSL_API_COMPAThttps://inbox.dpdk.org/dev/[email protected]/
Running sudo app/test/dpdk-test does not show the errors:
RTE>>pmd_perf_autotest
Start PMD RXTX cycles cost test.
At least 1 port(s) used for perf. test
Test Failed
RTE>>ipsec_perf_autotest
USER1:rte_ipsec_pkt_crypto_preparefail
Test Failed
RTE>>link_bonding_mode4_autotest
...
Test OK
RTE>Best regards
Heinrich+
The above failures for performance tests without a bound NIC can be reproduced on x86_64. So this is not RISC-V specific.
With both ports of an Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 bound to the sfio-pci driver some fast tests fail on the Unmatched board:
16/173 DPDK:fast-tests / eal_flags_n_opt_autotest FAIL 5.54s (exit
status 255 or signal 127 SIGinvalid)
Quoted 1 line
Quoted 1 line
Quoted 1 line
DPDK_TEST=eal_flags_n_opt_autotest MALLOC_PERTURB_=31 build/app/test/dpdk-test --file-prefix=eal_flags_n_opt_autotest
18/173 DPDK:fast-tests / eal_flags_no_huge_autotest FAIL 5.31s (exit
status 255 or signal 127 SIGinvalid)
Quoted 1 line
Quoted 1 line
Quoted 1 line
DPDK_TEST=eal_flags_no_huge_autotest MALLOC_PERTURB_=150 build/app/test/dpdk-test --file-prefix=eal_flags_no_huge_autotest
21/173 DPDK:fast-tests / eal_flags_vdev_opt_autotest FAIL 5.38s (exit
status 255 or signal 127 SIGinvalid)
Quoted 1 line
Quoted 1 line
Quoted 1 line
MALLOC_PERTURB_=71 DPDK_TEST=eal_flags_vdev_opt_autotest build/app/test/dpdk-test --file-prefix=eal_flags_vdev_opt_autotest
25/173 DPDK:fast-tests / eal_flags_misc_autotest FAIL 5.58s (exit
status 255 or signal 127 SIGinvalid)
Quoted 1 line
Quoted 1 line
Quoted 1 line
DPDK_TEST=eal_flags_misc_autotest MALLOC_PERTURB_=130 build/app/test/dpdk-test --file-prefix=eal_flags_misc_autotest
The eal* tests succeed on x86_64 with a bound Intel I211 NIC.
If the eal* tests are run depends on the installed Linux packages. I have used 'apt build-dep dpdk' on Ubuntu Jammy to install prerequisite packages before building DPDK.
Best regards
Heinrich
Quoted 107 lines
Quoted 107 lines
Quoted 106 lines
NOTE: This work was sponsored by StarFive and SiFive which is signified by
"Sponsored-by:" sign-offs in each commit message. After discussing it with Thomas Monjalon it seemed a better choice than "Suggested-by" which does not fully convey the nature of involvement. However it makes Linux checkpatch unhappy so I'm not sure if I shouldn't change the sign-offs.NOTE2: I have added maintainers for each commit based on
MAINTAINERSfile.
However some modules (l3fwd, net/tap and cpuflags unit tests) do not have any maintainers assigned, hence I've targeted [email protected] mailing list as if it was a commit adding new files.Michal Mazurek (3):
lpm: add a scalar version of lookupx4 function
eal: add initial support for RISC-V architecture test/cpuflags: add test for RISC-V cpu flagStanislaw Kardach (8):
examples/l3fwd: fix scalar LPM compilation net/ixgbe: enable vector stubs for RISC-V net/memif: set memfd syscall ID on RISC-V net/tap: set BPF syscall ID for RISC-V examples/l3fwd: enable RISC-V operation test/ring: disable problematic tests for RISC-V
devtools: add RISC-V totest-meson-builds.shtest/hash: report non HTM numbers for single r/wMAINTAINERS | 6 + app/test/test_cpuflags.c | 81 ++++++++++ app/test/test_hash_readwrite.c | 8 +- app/test/test_ring.c | 8 + app/test/test_xmmt_ops.h | 16 ++ config/meson.build | 2 + config/riscv/meson.build | 148 ++++++++++++++++++ config/riscv/riscv64_linux_gcc | 17 ++ config/riscv/riscv64_sifive_u740_linux_gcc | 19 +++ devtools/test-meson-builds.sh | 6 + doc/guides/contributing/design.rst | 2 +- .../linux_gsg/cross_build_dpdk_for_riscv.rst | 125 +++++++++++++++ doc/guides/linux_gsg/index.rst | 1 + doc/guides/nics/features.rst | 5 + doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/ixgbe.ini | 1 + doc/guides/rel_notes/release_22_07.rst | 29 ++++ drivers/net/i40e/meson.build | 6 + drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- drivers/net/memif/rte_eth_memif.h | 2 + drivers/net/tap/tap_bpf.h | 2 + examples/l3fwd/l3fwd_em.c | 8 + examples/l3fwd/l3fwd_fib.c | 2 + examples/l3fwd/l3fwd_lpm.c | 2 +- lib/eal/riscv/include/meson.build | 23 +++ lib/eal/riscv/include/rte_atomic.h | 52 ++++++ lib/eal/riscv/include/rte_byteorder.h | 44 ++++++ lib/eal/riscv/include/rte_cpuflags.h | 55 +++++++ lib/eal/riscv/include/rte_cycles.h | 103 ++++++++++++ lib/eal/riscv/include/rte_io.h | 21 +++ lib/eal/riscv/include/rte_mcslock.h | 18 +++ lib/eal/riscv/include/rte_memcpy.h | 63 ++++++++ lib/eal/riscv/include/rte_pause.h | 31 ++++ lib/eal/riscv/include/rte_pflock.h | 17 ++ lib/eal/riscv/include/rte_power_intrinsics.h | 22 +++ lib/eal/riscv/include/rte_prefetch.h | 50 ++++++ lib/eal/riscv/include/rte_rwlock.h | 44 ++++++ lib/eal/riscv/include/rte_spinlock.h | 67 ++++++++ lib/eal/riscv/include/rte_ticketlock.h | 21 +++ lib/eal/riscv/include/rte_vect.h | 55 +++++++ lib/eal/riscv/meson.build | 11 ++ lib/eal/riscv/rte_cpuflags.c | 122 +++++++++++++++ lib/eal/riscv/rte_cycles.c | 77 +++++++++ lib/eal/riscv/rte_hypervisor.c | 13 ++ lib/eal/riscv/rte_power_intrinsics.c | 56 +++++++ lib/lpm/meson.build | 1 + lib/lpm/rte_lpm.h | 4 +- lib/lpm/rte_lpm_scalar.h | 122 +++++++++++++++ meson.build | 2 + 49 files changed, 1588 insertions(+), 7 deletions(-)create mode 100644 config/riscv/meson.build
create mode 100644 config/riscv/riscv64_linux_gcc
create mode 100644 config/riscv/riscv64_sifive_u740_linux_gcc create mode 100644doc/guides/linux_gsg/cross_build_dpdk_for_riscv.rstcreate mode 100644lib/eal/riscv/include/meson.buildcreate mode 100644lib/eal/riscv/include/rte_atomic.hcreate mode 100644lib/eal/riscv/include/rte_byteorder.hcreate mode 100644lib/eal/riscv/include/rte_cpuflags.hcreate mode 100644lib/eal/riscv/include/rte_cycles.hcreate mode 100644lib/eal/riscv/include/rte_io.h
create mode 100644lib/eal/riscv/include/rte_mcslock.hcreate mode 100644lib/eal/riscv/include/rte_memcpy.hcreate mode 100644lib/eal/riscv/include/rte_pause.hcreate mode 100644lib/eal/riscv/include/rte_pflock.hcreate mode 100644lib/eal/riscv/include/rte_power_intrinsics.hcreate mode 100644lib/eal/riscv/include/rte_prefetch.hcreate mode 100644lib/eal/riscv/include/rte_rwlock.hcreate mode 100644lib/eal/riscv/include/rte_spinlock.hcreate mode 100644lib/eal/riscv/include/rte_ticketlock.hcreate mode 100644lib/eal/riscv/include/rte_vect.h
create mode 100644lib/eal/riscv/meson.build
create mode 100644lib/eal/riscv/rte_cpuflags.c
create mode 100644lib/eal/riscv/rte_cycles.c
create mode 100644lib/eal/riscv/rte_hypervisor.c
create mode 100644lib/eal/riscv/rte_power_intrinsics.ccreate mode 100644lib/lpm/rte_lpm_scalar.h
On Thu, May 12, 2022 at 11:46 AM Heinrich Schuchardt <[email protected]> wrote:
<snip>
Quoted 17 lines
The above failures for performance tests without a bound NIC can be reproduced on
x86_64. So this is not RISC-V specific.With both ports of an Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 bound to the sfio-pci driver some fast tests fail on the Unmatched board:
16/173 DPDK:fast-tests /
eal_flags_n_opt_autotestFAIL 5.54s (exit
status 255 or signal 127 SIGinvalid)Quoted 1 line
Quoted 1 line
Quoted 1 line
DPDK_TEST=eal_flags_n_opt_autotest MALLOC_PERTURB_=31
build/app/test/dpdk-test --file-prefix=eal_flags_n_opt_autotest
18/173 DPDK:fast-tests /eal_flags_no_huge_autotestFAIL 5.31s (exit
status 255 or signal 127 SIGinvalid)Quoted 1 line
Quoted 1 line
Quoted 1 line
DPDK_TEST=eal_flags_no_huge_autotest MALLOC_PERTURB_=150
build/app/test/dpdk-test --file-prefix=eal_flags_no_huge_autotest
21/173 DPDK:fast-tests /eal_flags_vdev_opt_autotestFAIL 5.38s (exit
status 255 or signal 127 SIGinvalid)
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
MALLOC_PERTURB_=71 DPDK_TEST=eal_flags_vdev_opt_autotest
build/app/test/dpdk-test --file-prefix=eal_flags_vdev_opt_autotest
25/173 DPDK:fast-tests /eal_flags_misc_autotestFAIL 5.58s (exit
status 255 or signal 127 SIGinvalid)Quoted 1 line
Quoted 1 line
Quoted 1 line
DPDK_TEST=eal_flags_misc_autotest MALLOC_PERTURB_=130
build/app/test/dpdk-test --file-prefix=eal_flags_misc_autotest
The eal* tests succeed on
x86_64with a bound Intel I211 NIC.
The common element of those tests is --no-huge flag. The reason why they are failing is a combination of --no-huge and a lack of IOMMU (VT-d on Intel). Lack of IOMMU means that DMA will be done using physical addresses (RTE_IOVA_PA), however that implicitly requires hugepages to function. More details are in [1]. That mail also shows how to replicate the same issue on x86 even without a device bound to UIO.
The following fails:
$ ./app/test/dpdk-test --iova-mode=pa --no-huge But this works: sudo ./app/test/dpdk-test --iova-mode=pa However fixing it is not as straightforward as I thought (some tests are not run where they should - [3]). As I explain in [2], the PCI bus probing may force RTE_IOVA_PA on no-IOMMU platforms. That gives the same effect as passing `--iova-mode=pa`. If no PCI device is bound, then DPDK will be in RTE_IOVA_DC mode and that works just fine with --no-huge.
As DPDK CI does not bind any device for fast-tests I've concluded that it is the way those tests should be run. If not then I'm not sure how should I handle --iova-mode=pa + --no-huge in general. Any suggestions?
[1] http://mails.dpdk.org/archives/dev/2021-June/210773.html
[2] http://mails.dpdk.org/archives/dev/2021-June/211146.html
[3] https://patches.dpdk.org/project/dpdk/patch/[email protected]/
Quoted 9 lines
If the eal* tests are run depends on the installed Linux packages. I have used 'apt build-dep dpdk' on Ubuntu Jammy to install prerequisite packages before building DPDK.
Best regards
Heinrich
Quoted 46 lines · Stanisław Kardach
On Thu, May 12, 2022 at 11:46 AM Heinrich Schuchardt <[email protected]> wrote:
<snip>Quoted 17 lines
The above failures for performance tests without a bound NIC can be reproduced on
x86_64. So this is not RISC-V specific.With both ports of an Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 bound to the sfio-pci driver some fast tests fail on the Unmatched board:
16/173 DPDK:fast-tests / eal_flags_n_opt_autotest FAIL 5.54s (exitstatus 255 or signal 127 SIGinvalid)
Quoted 1 line
Quoted 1 line
Quoted 1 line
DPDK_TEST=eal_flags_n_opt_autotest MALLOC_PERTURB_=31
build/app/test/dpdk-test --file-prefix=eal_flags_n_opt_autotest
18/173 DPDK:fast-tests /eal_flags_no_huge_autotestFAIL 5.31s (exit
status 255 or signal 127 SIGinvalid)Quoted 1 line
Quoted 1 line
Quoted 1 line
DPDK_TEST=eal_flags_no_huge_autotest MALLOC_PERTURB_=150
build/app/test/dpdk-test --file-prefix=eal_flags_no_huge_autotest
21/173 DPDK:fast-tests /eal_flags_vdev_opt_autotestFAIL 5.38s (exit
status 255 or signal 127 SIGinvalid)Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
MALLOC_PERTURB_=71 DPDK_TEST=eal_flags_vdev_opt_autotest
build/app/test/dpdk-test --file-prefix=eal_flags_vdev_opt_autotest
25/173 DPDK:fast-tests /eal_flags_misc_autotestFAIL 5.58s (exit
status 255 or signal 127 SIGinvalid)Quoted 1 line
Quoted 1 line
Quoted 1 line
DPDK_TEST=eal_flags_misc_autotest MALLOC_PERTURB_=130
build/app/test/dpdk-test --file-prefix=eal_flags_misc_autotest
The eal* tests succeed on
x86_64with a bound Intel I211 NIC.The common element of those tests is --no-huge flag. The reason why they are failing is a combination of --no-huge and a lack of IOMMU (VT-d on Intel). Lack of IOMMU means that DMA will be done using physical addresses (
RTE_IOVA_PA), however that implicitly requires hugepages to function. More details are in [1]. That mail also shows how to replicate the same issue on x86 even without a device bound to UIO.
The following fails:$ ./app/test/dpdk-test --iova-mode=pa --no-huge But this works: sudo ./app/test/dpdk-test --iova-mode=pa However fixing it is not as straightforward as I thought (some tests are not run where they should - [3]). As I explain in [2], the PCI bus probing may force RTE_IOVA_PA on no-IOMMU platforms. That gives the same effect as passing `--iova-mode=pa`. If no PCI device is bound, then DPDK will be in RTE_IOVA_DC mode and that works just fine with --no-huge.
Quoted 4 lines
As DPDK CI does not bind any device for fast-tests I've concluded that it is the way those tests should be run. If not then I'm not sure how should I handle --iova-mode=pa + --no-huge in general. Any suggestions?
Thanks for your analysis and explanation. The respective tests should return TEST_SKIPPED if called with an unsupported parameter combination.
According to your analysis this is not a problem specific to the RISC-V series but can be resolved separately.
Maybe you could add a note in doc/guides/rel_notes/known_issues.rst.
Best regards
Heinrich
Quoted 14 lines
[1] http://mails.dpdk.org/archives/dev/2021-June/210773.html
[2] http://mails.dpdk.org/archives/dev/2021-June/211146.html
[3] https://patches.dpdk.org/project/dpdk/patch/[email protected]/Quoted 9 lines
If the eal* tests are run depends on the installed Linux packages. I have used 'apt build-dep dpdk' on Ubuntu Jammy to install prerequisite packages before building DPDK.
Best regards
Heinrich