f22e705ebf
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. Sponsored-by: Frank Zhao <frank.zhao@starfivetech.com> Sponsored-by: Sam Grove <sam.grove@sifive.com> Signed-off-by: Michal Mazurek <maz@semihalf.com> Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
129 lines
3.6 KiB
Meson
129 lines
3.6 KiB
Meson
# 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],
|
|
# 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': []
|
|
},
|
|
}
|
|
|
|
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 not vendors.has_key(vendor_id)
|
|
error('Unsupported RISC-V vendor: @0@. '.format(vendor_id) +
|
|
'Please add support for it or use the generic ' +
|
|
'(-Dmachine=generic) build.')
|
|
endif
|
|
vendor_config = vendors[vendor_id]
|
|
|
|
message('RISC-V vendor: ' + vendor_config['description'])
|
|
message('RISC-V architecture id: ' + arch_id)
|
|
|
|
arch_config = vendor_config['arch_config']
|
|
if not arch_config.has_key(arch_id)
|
|
# 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
|
|
arch_config = arch_config[arch_id]
|
|
|
|
# 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))
|