Skip to contentSkip to conversation

Introduce support for RISC-V architecture

PATCH Superseded Stanislaw Kardach 3 participants 14 messages May 31, 2022 – Jun 8, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v4 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.

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

v4:
- Update RISC-V cross-compilation docs to remove vendor-specific instructions and better match the Ubuntu environment.
- Remove optional "fence" removal in the CYCLE and TIME counter reads as those are irrelevant compared to the cost of a firmware call that allowed such removal. The per-platform build-configuration is left in meson files for setting '-mtune' and reference for future platforms.
- Update cross-files to specify PKG_CONFIG_LIBDIR instead of relying on the riscv64-linux-gnu-pkg-config wrapper which was removed from Ubuntu anyway. Also use sys_root properly instead of using c_args directly.
- Note: rte_rdtsc handling is left as it was in v3: TIME counter default, CYCLE via compile-time option. This is mostly due to CYCLE being core-local with values differing among cores which causes timer_autotest to run overly long if it so happens that CYCLE on core 0 is ahead of other cores' CYCLEs. This makes TIME counter more stable for general usage. Since CYCLE read in userspace can be disabled by the kernel-mode (it isn't currently), the compile-time approach is taken, same as with Aarch64.
- Added details on --no-huge tests failing in the known_issues.rst.
- Additional notes on tests:
- link_bonding_mode4_autotest succeeds and then dpdk-test fails with segmentation fault randomly when run directly (via DPDK_TEST env variable) with MALLOC_PERTURB_. This was not noticed in any other test suggesting that there is a race condition somewhere in the link_bonding PMD that leads to use-after-free (since MALLOC_PERTURB_ causes free() to re-initialize freed memory to a given value).
- ipsec_perf_autotest currently does not check whether there is any crypto device available (as ipsec_autotest does) and therefore fails.
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.

[1] http://lists.infradead.org/pipermail/opensbi/2021-June/001219.html

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

 .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                      | 131 ++++++++++++++++++
 config/riscv/riscv64_linux_gcc                |  17 +++
 config/riscv/riscv64_sifive_u740_linux_gcc    |  20 +++
 devtools/test-meson-builds.sh                 |   4 +
 doc/guides/contributing/design.rst            |   2 +-
 .../linux_gsg/cross_build_dpdk_for_riscv.rst  | 115 +++++++++++++++
 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            | 101 ++++++++++++++
 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, 1410 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
#1 lore raw

PATCH v4 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), its frequency might change due to DVFS and it is core-local and therefore cannot be used as a wall-clock. It can however be used for micro-benchmarking user applications, similarly to Aarch64's PMCCNTR PMU counter.

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                      | 131 ++++++++++++++++++
 config/riscv/riscv64_linux_gcc                |  17 +++
 config/riscv/riscv64_sifive_u740_linux_gcc    |  20 +++
 doc/guides/contributing/design.rst            |   2 +-
 .../linux_gsg/cross_build_dpdk_for_riscv.rst  | 115 +++++++++++++++
 doc/guides/linux_gsg/index.rst                |   1 +
 doc/guides/nics/features.rst                  |   5 +
 doc/guides/nics/features/default.ini          |   1 +
 doc/guides/rel_notes/known_issues.rst         |  10 +-
 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            | 101 ++++++++++++++
 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 +
 40 files changed, 1323 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
MAINTAINERS +6 -0
index 17a0559ee7..8809ceddce 100644
@@ -297,6 +297,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
index 3a82d5ecac..55f256599e 100644
@@ -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
index 7134e80e8d..7f7b6c92fd 100644
@@ -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 +131 -0

131 lines not on this page · raw message

config/riscv/riscv64_linux_gcc new file +17 -0
new file mode 100644
index 0000000000..ed4d3ce7fb
@@ -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 = ''
+
+[host_machine]
+system = 'linux'
+cpu_family = 'riscv64'
+cpu = 'rv64gc'
+endian = 'little'
+
+[properties]
+vendor_id = 'generic'
+arch_id = 'generic'
+pkg_config_libdir = '/usr/lib/riscv64-linux-gnu/pkgconfig'
config/riscv/riscv64_sifive_u740_linux_gcc new file +20 -0
new file mode 100644
index 0000000000..3d1905c434
@@ -0,0 +1,20 @@
+[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 = ''
+
+[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
+pkg_config_libdir = '/usr/lib/riscv64-linux-gnu/pkgconfig'
+sys_root = '/opt/riscv/sysroot'
doc/guides/contributing/design.rst +1 -1
index d5ca8b4d9c..0383afe5c8 100644
@@ -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 +115 -0

115 lines not on this page · raw message

doc/guides/linux_gsg/index.rst +1 -0
index 16a9a67260..747552c385 100644
@@ -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
index 21bedb743f..6c4fa74bc7 100644
@@ -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
index b1d18ac62c..02198682c6 100644
@@ -74,6 +74,7 @@ ARMv8                =
 Power8               =
 x86-32               =
 x86-64               =
+rv64                 =
 Usage doc            =
 Design doc           =
 Perf doc             =
doc/guides/rel_notes/known_issues.rst +7 -3
index 187d9c942e..613ff7c3df 100644
@@ -249,11 +249,15 @@ PMD does not work with --no-huge EAL command line parameter
 -----------------------------------------------------------
 
 **Description**:
-   Currently, the DPDK does not store any information about memory allocated by ``malloc()` (for example, NUMA node,
-   physical address), hence PMDs do not work when the ``--no-huge`` command line parameter is supplied to EAL.
+   Currently, the DPDK does not store any information about memory allocated by ``malloc()`` (for example, NUMA node,
+   physical address), hence PMDs do not work when the ``--no-huge`` command line parameter is supplied to EAL. This
+   happens when using non-IOMMU based UIO drivers (i.e. ``igb_uio`` or ``uio_pci_generic``) or when IOVA mode is
+   explicitly set to use physical addresses (via the ``--iova-mode=pa`` EAL parameter).
 
 **Implication**:
-   Sending and receiving data with PMD will not work.
+   Sending and receiving data with PMD will not work. Unit tests checking ``--no-huge`` operation will fail if
+   there is a device bound to the PMD (eal_flags_n_opt_autotest, eal_flags_no_huge_autotest,
+   eal_flags_vdev_opt_autotest, eal_flags_misc_autotest).
 
 **Resolution/Workaround**:
    Use huge page memory or use VFIO to map devices.
doc/guides/rel_notes/release_22_07.rst +8 -0
index 0cf3f71269..f2311c5c1e 100644
@@ -60,6 +60,14 @@ New Features
   Added an API which can get the number of in-flight packets in
   vhost async data path without using lock.
 
+* **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
index efc5f93e35..a4c1c9079a 100644
@@ -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
index 162f8d5f46..88539e97d5 100644
@@ -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
index 680bc8631c..9afb495953 100644
@@ -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
index c09713a67b..3efac9ac07 100644
@@ -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
index 0830b3eb31..75fa19b7fe 100644
@@ -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
new file mode 100644
index 0000000000..7f6e4a5b1e
@@ -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 +101 -0

101 lines not on this page · raw message

lib/eal/riscv/include/rte_io.h new file +21 -0
new file mode 100644
index 0000000000..29659c9590
@@ -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
new file mode 100644
index 0000000000..b517cd5fc5
@@ -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
new file mode 100644
index 0000000000..c24c1f32e8
@@ -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.
+	 */
+	asm volatile(".int 0x0100000F"::: "memory");
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RTE_PAUSE_RISCV_H */
lib/eal/riscv/include/rte_pflock.h new file +17 -0
new file mode 100644
index 0000000000..ce6ca02aca
@@ -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
new file mode 100644
index 0000000000..636e58e71f
@@ -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
new file mode 100644
index 0000000000..b8d2a4f937
@@ -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
new file mode 100644
index 0000000000..dca1106aae
@@ -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
new file mode 100644
index 0000000000..92b5435993
@@ -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
index 937f6110c0..a8db04a1ee 100644
@@ -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
#2 lore raw

PATCH v4 2/8 net/ixgbe: enable vector stubs for RISC-V

In reply to Stanislaw Kardach

Re-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
index c5333d1142..b776ca1cf1 100644
@@ -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
index 9e8ea366a5..009d9b624a 100644
@@ -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
index 88539e97d5..162f8d5f46 100644
@@ -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
#3 lore raw

PATCH v4 3/8 net/memif: set memfd syscall ID on RISC-V

In reply to Stanislaw Kardach

Define 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
index 9afb495953..680bc8631c 100644
@@ -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
index a5ee23d42e..81e7dceae0 100644
@@ -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
#4 lore raw

PATCH v4 4/8 net/tap: set BPF syscall ID for RISC-V

In reply to Stanislaw Kardach

Define 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
index 3efac9ac07..c09713a67b 100644
@@ -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
index f0b9fc7a2c..639bdf3a79 100644
@@ -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
#5 lore raw

PATCH v4 5/8 examples/l3fwd: enable RISC-V operation

In reply to Stanislaw Kardach

Add 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
index 6f8d94f120..10be24c61d 100644
@@ -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
index 26d0767ae2..e02e4b3f5a 100644
@@ -18,6 +18,8 @@
 #include "l3fwd_neon.h"
 #elif defined RTE_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
index 75fa19b7fe..0830b3eb31 100644
@@ -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
#6 lore raw

PATCH v4 6/8 test/cpuflags: add test for RISC-V cpu flag

In reply to Stanislaw Kardach

From: 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
index 40f6ac7fca..98a99c2c7d 100644
@@ -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
#7 lore raw

PATCH v4 7/8 devtools: add RISC-V to test-meson-builds.sh

In reply to Stanislaw Kardach

Validate 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
index a653b253cb..f732dccf6c 100755
@@ -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
#8 lore raw

PATCH v4 8/8 ci: add RISCV64 cross compilation job

In reply to Stanislaw Kardach

Checks 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
index 1de8962f0e..06104eca22 100755
@@ -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
index ad8ad1a187..7c8528cb04 100644
@@ -26,6 +26,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:
@@ -74,6 +75,10 @@ jobs:
             compiler: gcc
             library: shared
             cross: ppc64le
+          - os: ubuntu-20.04
+            compiler: gcc
+            library: shared
+            cross: riscv64
 
     steps:
     - name: Checkout sources
@@ -132,8 +137,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
#9 lore raw
In reply to Stanislaw Kardach
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 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.

Quoted 6 lines

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.

Overall, the series lgtm.
It did not get much reviews, but the porting is straightforward and clean enough.

I'm waiting for some compilation to finish and I will merge it for 22.07-rc1.

Some comments that will probably require some followup patches for rc2:

- I removed the known issue about --no-huge from the EAL patch. This seems to be a generic issue that does not block the RISC V port and can be re-submitted as a separate patch.

- I had some trouble with finding a right toolchain for test-meson-builds.sh. The mentionned toolchains in the cross build guide don't work for me on FC36. I managed to cross compile with a Bootlin toolchain, though I had to adjust the cross compilation file.
I'll probably end up compiling my own toolchain later unless you have a better idea.

At least the compilation in GHA works.

- The hardcoded pkg-config path in config/riscv/riscv64_linux_gcc does not seem generic.
It is probably not a big issue, but I'd rather move it to a Ubuntu specific cross compile meson file.
WDYT?

- I adjusted some coding style in some asm and some indentation and wording in meson.

- The cross compilation guide mentions using crossbuild-essential-riscv64 for Ubuntu.
We should switch to it in GHA.
Though after trying myself, there is an issue in the C++ headers check in GHA for some acl header including rte_vect.h.
Can you have a look?

- There was a patch from Heinrich about native compilation, can you review it?

Signature · 1 line
David Marchand
#10 lore raw
Quoted 35 lines · David Marchand
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 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.

Quoted 6 lines

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.

Quoted 5 lines

Overall, the series lgtm.
It did not get much reviews, but the porting is straightforward and clean enough.

I'm waiting for some compilation to finish and I will merge it for 22.07-rc1.

Welcome to RISC-V in DPDK!

Let's work out the last details in -rc2.
Series applied, thanks.

Signature · 1 line
David Marchand
#11 lore raw
Quoted 42 lines · David Marchand
Quoted 39 lines · David Marchand
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 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.

Quoted 6 lines

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.

Overall, the series lgtm.
It did not get much reviews, but the porting is straightforward and clean enough.

Quoted 6 lines
Quoted 1 line

I'm waiting for some compilation to finish and I will merge it for 22.07-rc1.

Welcome to RISC-V in DPDK!

Let's work out the last details in -rc2.
Series applied, thanks.

Awesome, thanks!

Quoted 5 lines

--
David Marchand

#12 lore raw
In reply to David Marchand
Quoted 49 lines · David Marchand
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 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.

Quoted 6 lines

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.

Overall, the series lgtm.
It did not get much reviews, but the porting is straightforward and clean enough.

I'm waiting for some compilation to finish and I will merge it for 22.07-rc1.

Some comments that will probably require some followup patches for rc2:

- I removed the known issue about --no-huge from the EAL patch. This seems to be a generic issue that does not block the RISC V port and can be re-submitted as a separate patch.

Quoted 6 lines

- I had some trouble with finding a right toolchain for test-meson-builds.sh. The mentionned toolchains in the cross build guide don't work for me on FC36. I managed to cross compile with a Bootlin toolchain, though I had to adjust the cross compilation file.
I'll probably end up compiling my own toolchain later unless you have a better idea.

Please, consider building natively too. https://wiki.ubuntu.com/RISC-V describes setting setting up a virtual machine.

Quoted 23 lines

At least the compilation in GHA works.

- The hardcoded pkg-config path in config/riscv/riscv64_linux_gcc does not seem generic.
It is probably not a big issue, but I'd rather move it to a Ubuntu specific cross compile meson file.
WDYT?

- I adjusted some coding style in some asm and some indentation and wording in meson.

- The cross compilation guide mentions using crossbuild-essential-riscv64 for Ubuntu.
We should switch to it in GHA.
Though after trying myself, there is an issue in the C++ headers check in GHA for some acl header including rte_vect.h.
Can you have a look?

Quoted 1 line

- There was a patch from Heinrich about native compilation, can you review it?

[PATCH] Fix RISC-V builds
http://mails.dpdk.org/archives/dev/2022-May/242749.html
relates to PktGen.

Best regards

Heinrich

#13 lore raw
In reply to David Marchand
Quoted 40 lines · David Marchand
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 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.

Quoted 6 lines

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.

Overall, the series lgtm.
It did not get much reviews, but the porting is straightforward and clean enough.

Quoted 8 lines

I'm waiting for some compilation to finish and I will merge it for 22.07-rc1.

Some comments that will probably require some followup patches for rc2:

- I removed the known issue about --no-huge from the EAL patch. This seems to be a generic issue that does not block the RISC V port and can be re-submitted as a separate patch.

If you mean the modified entry in the known_issues, I've added it at Heinrich's request, although I agree I should have placed it in a separate patch.

Quoted 8 lines

- I had some trouble with finding a right toolchain for test-meson-builds.sh. The mentionned toolchains in the cross build guide don't work for me on FC36. I managed to cross compile with a Bootlin toolchain, though I had to adjust the cross compilation file.
I'll probably end up compiling my own toolchain later unless you have a better idea.

I have just checked with fedora/36 docker and it seems that only gcc and binutils packages are there but stdlib isn't. Hence meson fails at basic checks because it can't find "stdio.h". So that's a bug to post to Fedora I believe.
What does work in terms of cross-compiling is using a riscv-gnu-toolchain tarball + modified cross-file (i.e. from here:
https://github.com/riscv-collab/riscv-gnu-toolchain/releases/tag/2022.06.03).
That most likely won't work for building RPMs but for static compilations it might be enough.
Or you could use a Ubuntu docker and cross-compile there (though the same problem as before):
docker run -v /path/to/dpdk:/opt/dpdk -it ubuntu:jammy /bin/bash
Or a VM as Heinrich suggested.

Quoted 2 lines

At least the compilation in GHA works.

That's because I've used Ubuntu as a base, which has a proper toolchain setup. Also riscv-gnu-toolchain project targets Ubuntu, so that helps.

Quoted 7 lines

- The hardcoded pkg-config path in config/riscv/riscv64_linux_gcc does not seem generic.
It is probably not a big issue, but I'd rather move it to a Ubuntu specific cross compile meson file.
WDYT?

I think I'll rename the config file.
In theory, the man file of pkg-config
(https://linux.die.net/man/1/pkg-config) mentions the default searching path as prefix/lib/pkgconfig. Prefix being /usr/riscv64-linux-gnu the generic location should be /usr/riscv64-linux-gnu/lib/pkgconfig but Ubuntu doesn't follow that. There are no RISC-V cross-libs offering pkg-config neither in Ubuntu or Fedora so I can't really tell what's the best path to use. Though that also means we won't hit this issue for some time.

Quoted 4 lines

- I adjusted some coding style in some asm and some indentation and wording in meson.

Thanks!

Quoted 8 lines

- The cross compilation guide mentions using crossbuild-essential-riscv64 for Ubuntu.
We should switch to it in GHA.
Though after trying myself, there is an issue in the C++ headers check in GHA for some acl header including rte_vect.h.
Can you have a look?

I'm testing a fix for this. I have not taken C++ type conversion rules into account.

Quoted 3 lines

- There was a patch from Heinrich about native compilation, can you review it?

I see it was merged but your question from that thread still stands. I'm compiling native now to check.

Quoted 6 lines

--
David Marchand