eal: add bitset type
Subsystems (5)
PATCH v11 2/7 dpdk: use C linkage only where appropriate
In reply to Mattias RönnblomAssure that 'extern "C" { /../ }' do not cover files included from a particular header file, and address minor issues resulting from this change of order.
Dealing with C++ should delegate to the individual include file level, rather than being imposed by the user of that file. For example, forcing C linkage prevents __Generic macros being replaced with overloaded static inline functions in C++ translation units.
Eliminate 'extern "C"' from files which do not declare any symbols (e.g., only macros or struct types). With this change, the chkextern.py tool fails the build in case it detect such redundancy.
--
PATCH v10:
* Enable redundant C linkage checks in chkincs, and fix headers which had such.
* Fix more ARM build issues.
PATCH v9:
* Fix yet another issue in the ARM build. Author really needs an ARM system powerful enough to build DPDK.
PATCH v8:
* Fix issues in rte_memcpy_64.h causing build failures on ARM.
PATCH v7:
* Fix issues in rte_io.h, rte_pause.h and rte_thash_gfni.h causing build failures on ARM. (David Marchand)
* Fix issue in rte_vfio.h, causing build failures unless VFIO_PRESENT.
PATCH v6:
* Add missing extern "C" in rte_atomic.h, rte_cpuflags.h, rte_io.h, rte_vect.h.
* Fix 32-bit x86 build issues in rte_atomic.h.
PATCH v5:
* rte_dmadev.h was still including files under extern "C" { /../ }. (Chengwen Feng)
* Fix rte_byteorder.h, broken on 32-bit x86.
--- app/test/packet_burst_generator.h | 8 +++--- app/test/virtual_pmd.h | 4 +-- buildtools/chkincs/meson.build | 7 ++++++ drivers/bus/auxiliary/bus_auxiliary_driver.h | 8 +++--- drivers/bus/cdx/bus_cdx_driver.h | 8 +++--- drivers/bus/dpaa/include/fsl_qman.h | 8 +++--- drivers/bus/fslmc/bus_fslmc_driver.h | 8 +++--- drivers/bus/pci/bus_pci_driver.h | 8 +++--- drivers/bus/pci/rte_bus_pci.h | 8 +++--- drivers/bus/platform/bus_platform_driver.h | 8 +++--- drivers/bus/vdev/bus_vdev_driver.h | 8 +++--- drivers/bus/vmbus/bus_vmbus_driver.h | 8 +++--- drivers/bus/vmbus/rte_bus_vmbus.h | 8 +++--- drivers/dma/cnxk/cnxk_dma_event_dp.h | 8 +++--- drivers/dma/ioat/ioat_hw_defs.h | 4 +-- drivers/event/dlb2/rte_pmd_dlb2.h | 8 +++--- drivers/mempool/dpaa2/rte_dpaa2_mempool.h | 6 ++--- drivers/net/avp/rte_avp_fifo.h | 8 +++--- drivers/net/bonding/rte_eth_bond.h | 4 +-- drivers/net/i40e/rte_pmd_i40e.h | 8 +++--- drivers/net/mlx5/mlx5_trace.h | 8 +++--- drivers/net/ring/rte_eth_ring.h | 4 +-- drivers/net/vhost/rte_eth_vhost.h | 8 +++--- drivers/raw/ifpga/afu_pmd_core.h | 8 +++--- drivers/raw/ifpga/afu_pmd_he_hssi.h | 6 ++--- drivers/raw/ifpga/afu_pmd_he_lpbk.h | 6 ++--- drivers/raw/ifpga/afu_pmd_he_mem.h | 6 ++--- drivers/raw/ifpga/afu_pmd_n3000.h | 6 ++--- drivers/raw/ifpga/rte_pmd_afu.h | 4 +-- drivers/raw/ifpga/rte_pmd_ifpga.h | 4 +-- examples/ethtool/lib/rte_ethtool.h | 8 +++--- examples/qos_sched/main.h | 4 +-- examples/vm_power_manager/channel_manager.h | 8 +++--- lib/acl/rte_acl_osdep.h | 8 ------ lib/bbdev/rte_bbdev.h | 8 +++--- lib/bbdev/rte_bbdev_op.h | 8 +++--- lib/bbdev/rte_bbdev_pmd.h | 8 +++--- lib/bpf/bpf_def.h | 9 ------- lib/compressdev/rte_comp.h | 4 +-- lib/compressdev/rte_compressdev.h | 6 ++--- lib/compressdev/rte_compressdev_internal.h | 8 +++--- lib/compressdev/rte_compressdev_pmd.h | 8 +++--- lib/cryptodev/cryptodev_pmd.h | 8 +++--- lib/cryptodev/cryptodev_trace.h | 8 +++--- lib/cryptodev/rte_crypto.h | 8 +++--- lib/cryptodev/rte_crypto_asym.h | 8 ------ lib/cryptodev/rte_crypto_sym.h | 8 +++--- lib/cryptodev/rte_cryptodev.h | 8 +++--- lib/cryptodev/rte_cryptodev_trace_fp.h | 4 +-- lib/dispatcher/rte_dispatcher.h | 8 +++--- lib/dmadev/rte_dmadev.h | 8 ++++++ lib/eal/arm/include/rte_atomic_32.h | 4 +-- lib/eal/arm/include/rte_atomic_64.h | 8 +++--- lib/eal/arm/include/rte_byteorder.h | 8 +++--- lib/eal/arm/include/rte_cpuflags_32.h | 8 ------ lib/eal/arm/include/rte_cpuflags_64.h | 8 ------ lib/eal/arm/include/rte_cycles_32.h | 4 +-- lib/eal/arm/include/rte_cycles_64.h | 4 +-- lib/eal/arm/include/rte_io.h | 8 ------ lib/eal/arm/include/rte_io_64.h | 8 +++--- lib/eal/arm/include/rte_memcpy_32.h | 8 +++--- lib/eal/arm/include/rte_memcpy_64.h | 23 +++++++++++------ lib/eal/arm/include/rte_pause.h | 8 ------ lib/eal/arm/include/rte_pause_32.h | 6 ++--- lib/eal/arm/include/rte_pause_64.h | 8 +++--- lib/eal/arm/include/rte_power_intrinsics.h | 8 ------ lib/eal/arm/include/rte_prefetch_32.h | 8 +++--- lib/eal/arm/include/rte_prefetch_64.h | 8 +++--- lib/eal/arm/include/rte_rwlock.h | 4 +-- lib/eal/arm/include/rte_spinlock.h | 6 ++--- lib/eal/freebsd/include/rte_os.h | 8 ------ lib/eal/include/bus_driver.h | 8 +++--- lib/eal/include/dev_driver.h | 8 ------ lib/eal/include/eal_trace_internal.h | 8 +++--- lib/eal/include/generic/rte_atomic.h | 8 ++++++ lib/eal/include/generic/rte_byteorder.h | 8 ++++++ lib/eal/include/generic/rte_cpuflags.h | 8 ++++++ lib/eal/include/generic/rte_cycles.h | 8 ++++++ lib/eal/include/generic/rte_io.h | 8 ++++++ lib/eal/include/generic/rte_memcpy.h | 8 ++++++ lib/eal/include/generic/rte_pause.h | 8 ++++++ .../include/generic/rte_power_intrinsics.h | 8 ++++++ lib/eal/include/generic/rte_prefetch.h | 8 ++++++ lib/eal/include/generic/rte_rwlock.h | 8 +++--- lib/eal/include/generic/rte_spinlock.h | 8 ++++++ lib/eal/include/generic/rte_vect.h | 8 ++++++ lib/eal/include/rte_alarm.h | 4 +-- lib/eal/include/rte_bitmap.h | 8 +++--- lib/eal/include/rte_branch_prediction.h | 8 ------ lib/eal/include/rte_bus.h | 8 +++--- lib/eal/include/rte_class.h | 4 +-- lib/eal/include/rte_common.h | 8 +++--- lib/eal/include/rte_compat.h | 8 ------ lib/eal/include/rte_dev.h | 8 +++--- lib/eal/include/rte_devargs.h | 8 +++--- lib/eal/include/rte_eal_trace.h | 4 +-- lib/eal/include/rte_errno.h | 4 +-- lib/eal/include/rte_fbarray.h | 8 +++--- lib/eal/include/rte_keepalive.h | 6 ++--- lib/eal/include/rte_mcslock.h | 8 +++--- lib/eal/include/rte_memory.h | 8 +++--- lib/eal/include/rte_pci_dev_feature_defs.h | 8 ------ lib/eal/include/rte_pci_dev_features.h | 8 ------ lib/eal/include/rte_per_lcore.h | 8 ------ lib/eal/include/rte_pflock.h | 8 +++--- lib/eal/include/rte_random.h | 4 +-- lib/eal/include/rte_seqcount.h | 8 +++--- lib/eal/include/rte_seqlock.h | 8 +++--- lib/eal/include/rte_service.h | 8 +++--- lib/eal/include/rte_service_component.h | 4 +-- lib/eal/include/rte_stdatomic.h | 5 +--- lib/eal/include/rte_string_fns.h | 17 +++++++++---- lib/eal/include/rte_tailq.h | 6 ++--- lib/eal/include/rte_ticketlock.h | 8 +++--- lib/eal/include/rte_time.h | 6 ++--- lib/eal/include/rte_trace.h | 8 +++--- lib/eal/include/rte_trace_point.h | 8 +++--- lib/eal/include/rte_trace_point_register.h | 8 +++--- lib/eal/include/rte_uuid.h | 8 +++--- lib/eal/include/rte_version.h | 6 ++--- lib/eal/include/rte_vfio.h | 8 +++--- lib/eal/linux/include/rte_os.h | 8 ------ lib/eal/loongarch/include/rte_atomic.h | 6 ++--- lib/eal/loongarch/include/rte_byteorder.h | 4 +-- lib/eal/loongarch/include/rte_cpuflags.h | 8 ------ lib/eal/loongarch/include/rte_cycles.h | 4 +-- lib/eal/loongarch/include/rte_io.h | 8 ------ lib/eal/loongarch/include/rte_memcpy.h | 4 +-- lib/eal/loongarch/include/rte_pause.h | 8 +++--- .../loongarch/include/rte_power_intrinsics.h | 8 ------ lib/eal/loongarch/include/rte_prefetch.h | 8 +++--- lib/eal/loongarch/include/rte_rwlock.h | 4 +-- lib/eal/loongarch/include/rte_spinlock.h | 6 ++--- lib/eal/ppc/include/rte_atomic.h | 6 ++--- lib/eal/ppc/include/rte_byteorder.h | 6 ++--- lib/eal/ppc/include/rte_cpuflags.h | 8 ------ lib/eal/ppc/include/rte_cycles.h | 8 +++--- lib/eal/ppc/include/rte_io.h | 8 ------ lib/eal/ppc/include/rte_memcpy.h | 4 +-- lib/eal/ppc/include/rte_pause.h | 8 +++--- lib/eal/ppc/include/rte_power_intrinsics.h | 8 ------ lib/eal/ppc/include/rte_prefetch.h | 8 +++--- lib/eal/ppc/include/rte_rwlock.h | 4 +-- lib/eal/ppc/include/rte_spinlock.h | 8 +++--- lib/eal/riscv/include/rte_atomic.h | 8 +++--- lib/eal/riscv/include/rte_byteorder.h | 8 +++--- lib/eal/riscv/include/rte_cpuflags.h | 8 ------ lib/eal/riscv/include/rte_cycles.h | 4 +-- lib/eal/riscv/include/rte_io.h | 8 ------ lib/eal/riscv/include/rte_memcpy.h | 4 +-- lib/eal/riscv/include/rte_pause.h | 8 +++--- lib/eal/riscv/include/rte_power_intrinsics.h | 8 ------ lib/eal/riscv/include/rte_prefetch.h | 8 +++--- lib/eal/riscv/include/rte_rwlock.h | 4 +-- lib/eal/riscv/include/rte_spinlock.h | 6 ++--- lib/eal/windows/include/pthread.h | 6 ++--- lib/eal/windows/include/regex.h | 8 +++--- lib/eal/windows/include/rte_os.h | 8 ------ lib/eal/windows/include/rte_windows.h | 8 ------ lib/eal/x86/include/rte_atomic.h | 25 +++++++++++++------ lib/eal/x86/include/rte_byteorder.h | 16 ++++++------ lib/eal/x86/include/rte_cpuflags.h | 8 ------ lib/eal/x86/include/rte_cycles.h | 8 +++--- lib/eal/x86/include/rte_io.h | 8 +++--- lib/eal/x86/include/rte_pause.h | 7 +++--- lib/eal/x86/include/rte_power_intrinsics.h | 8 ------ lib/eal/x86/include/rte_prefetch.h | 8 +++--- lib/eal/x86/include/rte_rwlock.h | 6 ++--- lib/eal/x86/include/rte_spinlock.h | 9 +++---- lib/ethdev/ethdev_driver.h | 8 +++--- lib/ethdev/ethdev_pci.h | 8 +++--- lib/ethdev/ethdev_trace.h | 8 +++--- lib/ethdev/ethdev_vdev.h | 8 +++--- lib/ethdev/rte_cman.h | 8 ------ lib/ethdev/rte_dev_info.h | 8 ------ lib/ethdev/rte_eth_ctrl.h | 8 ------ lib/ethdev/rte_ethdev.h | 8 +++--- lib/ethdev/rte_ethdev_trace_fp.h | 4 +-- lib/eventdev/event_timer_adapter_pmd.h | 8 ------ lib/eventdev/eventdev_pmd.h | 8 +++--- lib/eventdev/eventdev_pmd_pci.h | 8 +++--- lib/eventdev/eventdev_pmd_vdev.h | 8 +++--- lib/eventdev/eventdev_trace.h | 8 +++--- lib/eventdev/rte_event_crypto_adapter.h | 8 +++--- lib/eventdev/rte_event_eth_rx_adapter.h | 8 +++--- lib/eventdev/rte_event_eth_tx_adapter.h | 8 +++--- lib/eventdev/rte_event_ring.h | 8 +++--- lib/eventdev/rte_event_timer_adapter.h | 8 +++--- lib/eventdev/rte_eventdev.h | 8 +++--- lib/eventdev/rte_eventdev_trace_fp.h | 4 +-- lib/graph/rte_graph_model_mcore_dispatch.h | 8 +++--- lib/graph/rte_graph_worker.h | 6 ++--- lib/gso/rte_gso.h | 6 ++--- lib/hash/rte_fbk_hash.h | 8 +++--- lib/hash/rte_hash_crc.h | 8 +++--- lib/hash/rte_jhash.h | 8 +++--- lib/hash/rte_thash.h | 8 +++--- lib/hash/rte_thash_gfni.h | 8 +++--- lib/ip_frag/rte_ip_frag.h | 8 +++--- lib/ipsec/rte_ipsec.h | 8 +++--- lib/log/rte_log.h | 8 +++--- lib/lpm/rte_lpm.h | 8 +++--- lib/member/rte_member.h | 8 +++--- lib/member/rte_member_sketch.h | 6 ++--- lib/member/rte_member_sketch_avx512.h | 8 +++--- lib/member/rte_member_x86.h | 4 +-- lib/member/rte_xxh64_avx512.h | 6 ++--- lib/mempool/mempool_trace.h | 8 +++--- lib/mempool/rte_mempool_trace_fp.h | 4 +-- lib/meter/rte_meter.h | 8 +++--- lib/mldev/mldev_utils.h | 8 +++--- lib/mldev/rte_mldev_core.h | 8 ------ lib/mldev/rte_mldev_pmd.h | 8 +++--- lib/net/rte_dtls.h | 8 ------ lib/net/rte_ecpri.h | 8 ------ lib/net/rte_esp.h | 8 ------ lib/net/rte_ether.h | 8 +++--- lib/net/rte_geneve.h | 8 ------ lib/net/rte_gre.h | 8 ------ lib/net/rte_gtp.h | 8 ------ lib/net/rte_higig.h | 8 ------ lib/net/rte_ib.h | 8 ------ lib/net/rte_icmp.h | 8 ------ lib/net/rte_l2tpv2.h | 8 ------ lib/net/rte_macsec.h | 8 ------ lib/net/rte_mpls.h | 8 ------ lib/net/rte_net.h | 8 +++--- lib/net/rte_pdcp_hdr.h | 8 ------ lib/net/rte_ppp.h | 8 ------ lib/net/rte_sctp.h | 8 ------ lib/net/rte_tcp.h | 8 ------ lib/net/rte_tls.h | 8 ------ lib/net/rte_udp.h | 8 ------ lib/net/rte_vxlan.h | 10 -------- lib/node/rte_node_eth_api.h | 8 +++--- lib/node/rte_node_ip4_api.h | 8 +++--- lib/node/rte_node_ip6_api.h | 6 ++--- lib/node/rte_node_udp4_input_api.h | 8 +++--- lib/pci/rte_pci.h | 8 +++--- lib/pdcp/rte_pdcp.h | 8 +++--- lib/pipeline/rte_pipeline.h | 8 +++--- lib/pipeline/rte_port_in_action.h | 8 +++--- lib/pipeline/rte_swx_ctl.h | 8 +++--- lib/pipeline/rte_swx_extern.h | 8 ------ lib/pipeline/rte_swx_ipsec.h | 8 +++--- lib/pipeline/rte_swx_pipeline.h | 8 +++--- lib/pipeline/rte_swx_pipeline_spec.h | 8 +++--- lib/pipeline/rte_table_action.h | 8 +++--- lib/port/rte_port.h | 8 ------ lib/port/rte_port_ethdev.h | 8 +++--- lib/port/rte_port_eventdev.h | 8 +++--- lib/port/rte_port_fd.h | 8 +++--- lib/port/rte_port_frag.h | 8 +++--- lib/port/rte_port_ras.h | 8 +++--- lib/port/rte_port_ring.h | 8 +++--- lib/port/rte_port_sched.h | 8 +++--- lib/port/rte_port_source_sink.h | 8 +++--- lib/port/rte_port_sym_crypto.h | 8 +++--- lib/port/rte_swx_port.h | 8 ------ lib/port/rte_swx_port_ethdev.h | 8 +++--- lib/port/rte_swx_port_fd.h | 8 +++--- lib/port/rte_swx_port_ring.h | 8 +++--- lib/port/rte_swx_port_source_sink.h | 8 +++--- lib/rawdev/rte_rawdev.h | 6 ++--- lib/rawdev/rte_rawdev_pmd.h | 8 +++--- lib/rcu/rte_rcu_qsbr.h | 8 +++--- lib/regexdev/rte_regexdev.h | 8 +++--- lib/ring/rte_ring.h | 6 ++--- lib/ring/rte_ring_core.h | 8 ------ lib/ring/rte_ring_elem.h | 8 +++--- lib/ring/rte_ring_hts.h | 4 +-- lib/ring/rte_ring_peek.h | 4 +-- lib/ring/rte_ring_peek_zc.h | 4 +-- lib/ring/rte_ring_rts.h | 4 +-- lib/sched/rte_approx.h | 8 +++--- lib/sched/rte_pie.h | 8 +++--- lib/sched/rte_red.h | 8 +++--- lib/sched/rte_sched.h | 8 +++--- lib/sched/rte_sched_common.h | 6 ++--- lib/security/rte_security.h | 8 +++--- lib/security/rte_security_driver.h | 6 ++--- lib/stack/rte_stack.h | 8 +++--- lib/table/rte_lru.h | 8 ------ lib/table/rte_lru_arm64.h | 8 +++--- lib/table/rte_lru_x86.h | 8 ------ lib/table/rte_swx_hash_func.h | 8 ------ lib/table/rte_swx_keycmp.h | 8 +++--- lib/table/rte_swx_table.h | 8 ------ lib/table/rte_swx_table_em.h | 8 +++--- lib/table/rte_swx_table_learner.h | 8 +++--- lib/table/rte_swx_table_selector.h | 8 +++--- lib/table/rte_swx_table_wm.h | 8 +++--- lib/table/rte_table.h | 8 ------ lib/table/rte_table_acl.h | 8 +++--- lib/table/rte_table_array.h | 8 +++--- lib/table/rte_table_hash.h | 8 +++--- lib/table/rte_table_hash_cuckoo.h | 8 +++--- lib/table/rte_table_hash_func.h | 24 +++++++++++++++--- lib/table/rte_table_lpm.h | 8 +++--- lib/table/rte_table_lpm_ipv6.h | 8 +++--- lib/table/rte_table_stub.h | 8 +++--- lib/telemetry/rte_telemetry.h | 8 +++--- lib/vhost/rte_vdpa.h | 8 +++--- lib/vhost/rte_vhost.h | 8 +++--- lib/vhost/rte_vhost_async.h | 8 +++--- lib/vhost/rte_vhost_crypto.h | 4 +-- lib/vhost/vdpa_driver.h | 8 +++--- 307 files changed, 979 insertions(+), 1337 deletions(-)
app/test/packet_burst_generator.h +4 -4
@@ -5,10 +5,6 @@#ifndef PACKET_BURST_GENERATOR_H_ #define PACKET_BURST_GENERATOR_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_mbuf.h> #include <rte_ether.h> #include <rte_arp.h>
@@ -17,6 +13,10 @@ extern "C" {#include <rte_tcp.h> #include <rte_sctp.h> +#ifdef __cplusplus +extern "C" { +#endif +#define IPV4_ADDR (a, b, c, d)(((a & 0xff) << 24) | ((b & 0xff) << 16) | \ ((c & 0xff) << 8) | (d & 0xff))
app/test/virtual_pmd.h +2 -2
@@ -5,12 +5,12 @@ #ifndef __VIRTUAL_ETHDEV_H_ #define __VIRTUAL_ETHDEV_H_ +#include <rte_ether.h> + #ifdef __cplusplus extern "C" { #endif -#include <rte_ether.h> - int virtual_ethdev_init(void);
buildtools/chkincs/meson.build +7 -0
@@ -43,10 +43,17 @@ chkextern = find_program('chkextern.py') missing_extern_headers = run_command(chkextern, 'missing', dpdk_chkinc_headers, capture: true, check: true).stdout().split() +redundant_extern_headers = run_command(chkextern, 'redundant', dpdk_chkinc_headers, + capture: true, check: true).stdout().split() + if missing_extern_headers != [] error('Files missing C++ \'extern "C"\' guards:\n- ' + '\n- '.join(missing_extern_headers)) endif +if redundant_extern_headers != [] + error('Redundant C++ \'extern "C"\' guards:\n- ' + '\n- '.join(redundant_extern_headers)) +endif + gen_cpp_files = generator(gen_c_file_for_header, output: '@[email protected]', arguments: ['@INPUT@', '@OUTPUT@'])
drivers/bus/auxiliary/bus_auxiliary_driver.h +4 -4
@@ -11,10 +11,6 @@* Auxiliary Bus Interface. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <stdlib.h> #include <limits.h>
@@ -28,6 +24,10 @@ extern "C" {#include <dev_driver.h> #include <rte_kvargs.h> +#ifdef __cplusplus +extern "C" { +#endif +#define RTE_BUS_AUXILIARY_NAME "auxiliary"/* Forward declarations */
drivers/bus/cdx/bus_cdx_driver.h +4 -4
@@ -10,10 +10,6 @@* AMD CDX bus interface */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdlib.h> #include <inttypes.h> #include <linux/types.h>
@@ -22,6 +18,10 @@ extern "C" {#include <dev_driver.h> #include <rte_interrupts.h> +#ifdef __cplusplus +extern "C" { +#endif +/* Forward declarations */ struct rte_cdx_device ;struct rte_cdx_driver ;
drivers/bus/dpaa/include/fsl_qman.h +4 -4
@@ -8,14 +8,14 @@ #ifndef __FSL_QMAN_H #define __FSL_QMAN_H -#ifdef __cplusplus -extern "C" { -#endif - #include <dpaa_rbtree.h> #include <rte_compat.h> #include <rte_eventdev.h> +#ifdef __cplusplus +extern "C" { +#endif + /* FQ lookups (turn this on for 64bit user-space) */ #ifdef RTE_ARCH_64 #define CONFIG_FSL_QMAN_FQ_LOOKUP
drivers/bus/fslmc/bus_fslmc_driver.h +4 -4
@@ -13,10 +13,6 @@* RTE FSLMC Bus Interface */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <stdlib.h> #include <limits.h>
@@ -40,6 +36,10 @@ extern "C" {#include "portal/dpaa2_hw_pvt.h" #include "portal/dpaa2_hw_dpio.h" +#ifdef __cplusplus +extern "C" { +#endif +#define FSLMC_OBJECT_MAX_LEN 32/**< Length of each device on bus */ #define DPAA2_INVALID_MBUF_SEQN 0
drivers/bus/pci/bus_pci_driver.h +4 -4
@@ -6,14 +6,14 @@ #ifndef BUS_PCI_DRIVER_H #define BUS_PCI_DRIVER_H -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_bus_pci.h> #include <dev_driver.h> #include <rte_compat.h> +#ifdef __cplusplus +extern "C" { +#endif + /** Pathname of PCI devices directory. */ __rte_internal const char *rte_pci_get_sysfs_path(void);
drivers/bus/pci/rte_bus_pci.h +4 -4
@@ -11,10 +11,6 @@* PCI device & driver interface */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <stdlib.h> #include <limits.h>
@@ -27,6 +23,10 @@ extern "C" {#include <rte_interrupts.h> #include <rte_pci.h> +#ifdef __cplusplus +extern "C" { +#endif +/* Forward declarations */ struct rte_pci_device ;struct rte_pci_driver ;
drivers/bus/platform/bus_platform_driver.h +4 -4
@@ -10,10 +10,6 @@* Platform bus interface. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stddef.h> #include <stdint.h>
@@ -23,6 +19,10 @@ extern "C" {#include <rte_os.h> #include <rte_vfio.h> +#ifdef __cplusplus +extern "C" { +#endif +/* Forward declarations */ struct rte_platform_bus ;struct rte_platform_device ;
drivers/bus/vdev/bus_vdev_driver.h +4 -4
@@ -5,15 +5,15 @@ #ifndef BUS_VDEV_DRIVER_H #define BUS_VDEV_DRIVER_H -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_bus_vdev.h> #include <rte_compat.h> #include <dev_driver.h> #include <rte_devargs.h> +#ifdef __cplusplus +extern "C" { +#endif + struct rte_vdev_device { RTE_TAILQ_ENTRY(rte_vdev_device) next; /**< Next attached vdev */ struct rte_device device; /**< Inherit core device */
drivers/bus/vmbus/bus_vmbus_driver.h +4 -4
@@ -6,14 +6,14 @@ #ifndef BUS_VMBUS_DRIVER_H #define BUS_VMBUS_DRIVER_H -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_bus_vmbus.h> #include <rte_compat.h> #include <dev_driver.h> +#ifdef __cplusplus +extern "C" { +#endif + struct vmbus_channel; struct vmbus_mon_page;
drivers/bus/vmbus/rte_bus_vmbus.h +4 -4
@@ -11,10 +11,6 @@* * VMBUS Interface */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <stdlib.h> #include <limits.h>
@@ -28,6 +24,10 @@ extern "C" {#include <rte_interrupts.h> #include <rte_vmbus_reg.h> +#ifdef __cplusplus +extern "C" { +#endif +/* Forward declarations */ struct rte_vmbus_device ;struct rte_vmbus_driver ;
drivers/dma/cnxk/cnxk_dma_event_dp.h +4 -4
@@ -5,16 +5,16 @@ #ifndef _CNXK_DMA_EVENT_DP_H_ #define _CNXK_DMA_EVENT_DP_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <stdint.h> #include <rte_common.h> #include <rte_compat.h> #include <rte_eventdev.h> +#ifdef __cplusplus +extern "C" { +#endif + __rte_internal uint16_t cn10k_dma_adapter_enqueue(void *ws, struct rte_event ev[], uint16_t nb_events);
drivers/dma/ioat/ioat_hw_defs.h +2 -2
@@ -5,12 +5,12 @@ #ifndef IOAT_HW_DEFS_H #define IOAT_HW_DEFS_H +#include <stdint.h> + #ifdef __cplusplus extern "C" { #endif -#include <stdint.h> - #define IOAT_PCI_CHANERR_INT_OFFSET 0x180 #define IOAT_VER_3_0 0x30
drivers/event/dlb2/rte_pmd_dlb2.h +4 -4
@@ -11,14 +11,14 @@ #ifndef _RTE_PMD_DLB2_H_ #define _RTE_PMD_DLB2_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <stdint.h> #include <rte_compat.h> +#ifdef __cplusplus +extern "C" { +#endif + /** * @warning * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
drivers/mempool/dpaa2/rte_dpaa2_mempool.h +3 -3
@@ -12,13 +12,13 @@* */ +#include <rte_compat.h> +#include <rte_mempool.h> +#ifdef __cplusplusextern "C" {#endif -#include <rte_compat.h> -#include <rte_mempool.h> -/** * Get BPID corresponding to the packet pool *
drivers/net/avp/rte_avp_fifo.h +4 -4
@@ -8,10 +8,6 @@#include "rte_avp_common.h" -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __KERNEL__/* Write memory barrier for kernel compiles */ #define AVP_WMB () smp_wmb()
@@ -27,6 +23,10 @@ extern "C" { #ifndef __KERNEL__ #include <rte_debug.h> +#ifdef __cplusplus +extern "C" { +#endif + /** * Initializes the avp fifo structure */
drivers/net/bonding/rte_eth_bond.h +2 -2
@@ -17,12 +17,12 @@* load balancing of network ports */ +#include <rte_ether.h> +#ifdef __cplusplusextern "C" {#endif -#include <rte_ether.h> -/* Supported modes of operation of link bonding library */ #define BONDING_MODE_ROUND_ROBIN (0)
drivers/net/i40e/rte_pmd_i40e.h +4 -4
@@ -14,14 +14,14 @@* */ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_compat.h> #include <rte_ethdev.h> #include <rte_ether.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Response sent back to i40e driver from user app after callback */
drivers/net/mlx5/mlx5_trace.h +4 -4
@@ -11,14 +11,14 @@* API for mlx5 PMD trace support */ -#ifdef __cplusplus -extern "C" { -#endif -#include <mlx5_prm.h> #include <rte_mbuf.h> #include <rte_trace_point.h> +#ifdef __cplusplus +extern "C" { +#endif +/* TX burst subroutines trace points. */ RTE_TRACE_POINT_FP( rte_pmd_mlx5_trace_tx_entry,
drivers/net/ring/rte_eth_ring.h +2 -2
@@ -5,12 +5,12 @@ #ifndef _RTE_ETH_RING_H_ #define _RTE_ETH_RING_H_ +#include <rte_ring.h> + #ifdef __cplusplus extern "C" { #endif -#include <rte_ring.h> - /** * Create a new ethdev port from a set of rings *
drivers/net/vhost/rte_eth_vhost.h +4 -4
@@ -5,15 +5,15 @@ #ifndef _RTE_ETH_VHOST_H_ #define _RTE_ETH_VHOST_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <stdint.h> #include <stdbool.h> #include <rte_vhost.h> +#ifdef __cplusplus +extern "C" { +#endif + /* * Event description. */
drivers/raw/ifpga/afu_pmd_core.h +4 -4
@@ -5,10 +5,6 @@#ifndef AFU_PMD_CORE_H #define AFU_PMD_CORE_H -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #include <stdio.h> #include <unistd.h>
@@ -20,6 +16,10 @@ extern "C" {#include "ifpga_rawdev.h" +#ifdef __cplusplus +extern "C" { +#endif +#define AFU_RAWDEV_MAX_DRVS 32struct afu_rawdev ;
drivers/raw/ifpga/afu_pmd_he_hssi.h +3 -3
@@ -5,13 +5,13 @@ #ifndef AFU_PMD_HE_HSSI_H #define AFU_PMD_HE_HSSI_H +#include "afu_pmd_core.h" +#include "rte_pmd_afu.h" + #ifdef __cplusplus extern "C" { #endif -#include "afu_pmd_core.h" -#include "rte_pmd_afu.h" - #define HE_HSSI_UUID_L 0xbb370242ac130002 #define HE_HSSI_UUID_H 0x823c334c98bf11ea #define NUM_HE_HSSI_PORTS 8
drivers/raw/ifpga/afu_pmd_he_lpbk.h +3 -3
@@ -5,13 +5,13 @@ #ifndef AFU_PMD_HE_LPBK_H #define AFU_PMD_HE_LPBK_H +#include "afu_pmd_core.h" +#include "rte_pmd_afu.h" + #ifdef __cplusplus extern "C" { #endif -#include "afu_pmd_core.h" -#include "rte_pmd_afu.h" - #define HE_LPBK_UUID_L 0xb94b12284c31e02b #define HE_LPBK_UUID_H 0x56e203e9864f49a7 #define HE_MEM_LPBK_UUID_L 0xbb652a578330a8eb
drivers/raw/ifpga/afu_pmd_he_mem.h +3 -3
@@ -5,13 +5,13 @@ #ifndef AFU_PMD_HE_MEM_H #define AFU_PMD_HE_MEM_H +#include "afu_pmd_core.h" +#include "rte_pmd_afu.h" + #ifdef __cplusplus extern "C" { #endif -#include "afu_pmd_core.h" -#include "rte_pmd_afu.h" - #define HE_MEM_TG_UUID_L 0xa3dc5b831f5cecbb #define HE_MEM_TG_UUID_H 0x4dadea342c7848cb
drivers/raw/ifpga/afu_pmd_n3000.h +3 -3
@@ -5,13 +5,13 @@ #ifndef AFU_PMD_N3000_H #define AFU_PMD_N3000_H +#include "afu_pmd_core.h" +#include "rte_pmd_afu.h" + #ifdef __cplusplus extern "C" { #endif -#include "afu_pmd_core.h" -#include "rte_pmd_afu.h" - #define N3000_AFU_UUID_L 0xc000c9660d824272 #define N3000_AFU_UUID_H 0x9aeffe5f84570612 #define N3000_NLB0_UUID_L 0xf89e433683f9040b
drivers/raw/ifpga/rte_pmd_afu.h +2 -2
@@ -14,12 +14,12 @@* */ +#include <stdint.h> +#ifdef __cplusplusextern "C" {#endif -#include <stdint.h> -#define RTE_PMD_AFU_N3000_NLB 1#define RTE_PMD_AFU_N3000_DMA 2
drivers/raw/ifpga/rte_pmd_ifpga.h +2 -2
@@ -14,12 +14,12 @@* */ +#include <stdint.h> +#ifdef __cplusplusextern "C" {#endif -#include <stdint.h> -#define IFPGA_MAX_PORT_NUM 4/**
examples/ethtool/lib/rte_ethtool.h +4 -4
@@ -30,14 +30,14 @@* rte_ethtool_net_set_rx_mode net_device_ops::ndo_set_rx_mode * */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #include <rte_ethdev.h> #include <linux/ethtool.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Retrieve the Ethernet device driver information according to * attributes described by ethtool data structure, ethtool_drvinfo.
examples/qos_sched/main.h +2 -2
@@ -5,12 +5,12 @@ #ifndef _MAIN_H_ #define _MAIN_H_ +#include <rte_sched.h> + #ifdef __cplusplus extern "C" { #endif -#include <rte_sched.h> - #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1 /*
examples/vm_power_manager/channel_manager.h +4 -4
@@ -5,16 +5,16 @@ #ifndef CHANNEL_MANAGER_H_ #define CHANNEL_MANAGER_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <linux/limits.h> #include <linux/un.h> #include <stdbool.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif + /* Maximum name length including '\0' terminator */ #define CHANNEL_MGR_MAX_NAME_LEN 64
lib/acl/rte_acl_osdep.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_ACL_OSDEP_H_#define _RTE_ACL_OSDEP_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * @file *
@@ -49,8 +45,4 @@ extern "C" {#include <rte_cpuflags.h> #include <rte_debug.h> -#ifdef __cplusplus -} -#endif -#endif /* _RTE_ACL_OSDEP_H_ */
lib/bbdev/rte_bbdev.h +4 -4
@@ -20,10 +20,6 @@* from the same queue. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #include <stdbool.h>
@@ -32,6 +28,10 @@ extern "C" {#include "rte_bbdev_op.h" +#ifdef __cplusplus +extern "C" { +#endif +#ifndef RTE_BBDEV_MAX_DEVS #define RTE_BBDEV_MAX_DEVS 128/**< Max number of devices */ #endif
lib/bbdev/rte_bbdev_op.h +4 -4
@@ -11,10 +11,6 @@* Defines wireless base band layer 1 operations and capabilities */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #include <rte_compat.h>
@@ -23,6 +19,10 @@ extern "C" {#include <rte_memory.h> #include <rte_mempool.h> +#ifdef __cplusplus +extern "C" { +#endif +/* Number of columns in sub-block interleaver (36.212, section 5.1.4.1.1) */ #define RTE_BBDEV_TURBO_C_SUBBLOCK (32)/* Maximum size of Transport Block (36.213, Table, Table 7.1.7.2.5-1) */
lib/bbdev/rte_bbdev_pmd.h +4 -4
@@ -14,15 +14,15 @@* bbdev interface. User applications should not use this API. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #include <rte_log.h> #include "rte_bbdev.h" +#ifdef __cplusplus +extern "C" { +#endif +/** Suggested value for SW based devices */ #define RTE_BBDEV_DEFAULT_MAX_NB_QUEUES RTE_MAX_LCORE
lib/bpf/bpf_def.h +0 -9
@@ -7,10 +7,6 @@#ifndef _RTE_BPF_DEF_H_#define _RTE_BPF_DEF_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * @file *
@@ -25,7 +21,6 @@ extern "C" {#include <stdint.h> -/* * The instruction encodings. */
@@ -144,8 +139,4 @@ struct ebpf_insn {*/ #define EBPF_FUNC_MAX_ARGS (EBPF_REG_6 - EBPF_REG_1) -#ifdef __cplusplus -} -#endif -#endif /* RTE_BPF_DEF_H_ */
lib/compressdev/rte_comp.h +2 -2
@@ -11,12 +11,12 @@* RTE definitions for Data Compression Service */ +#include <rte_mbuf.h> +#ifdef __cplusplusextern "C" {#endif -#include <rte_mbuf.h> -/** * compression service feature flags *
lib/compressdev/rte_compressdev.h +3 -3
@@ -13,13 +13,13 @@* Defines comp device APIs for the provisioning of compression operations. */ + +#include "rte_comp.h" +#ifdef __cplusplusextern "C" {#endif - -#include "rte_comp.h" -/** * Parameter log base 2 range description. * Final value will be 2^value.
lib/compressdev/rte_compressdev_internal.h +4 -4
@@ -5,10 +5,6 @@#ifndef _RTE_COMPRESSDEV_INTERNAL_H_#define _RTE_COMPRESSDEV_INTERNAL_H_ -#ifdef __cplusplus -extern "C" { -#endif -/* rte_compressdev_internal.h * This file holds Compressdev private data structures. */
@@ -16,6 +12,10 @@ extern "C" {#include "rte_comp.h" +#ifdef __cplusplus +extern "C" { +#endif +#define RTE_COMPRESSDEV_NAME_MAX_LEN (64)/**< Max length of name of comp PMD */
lib/compressdev/rte_compressdev_pmd.h +4 -4
@@ -13,10 +13,6 @@* them directly. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <string.h> #include <dev_driver.h>
@@ -24,6 +20,10 @@ extern "C" {#include "rte_compressdev.h" #include "rte_compressdev_internal.h" +#ifdef __cplusplus +extern "C" { +#endif +#define RTE_COMPRESSDEV_PMD_NAME_ARG ("name")#define RTE_COMPRESSDEV_PMD_SOCKET_ID_ARG ("socket_id")
lib/cryptodev/cryptodev_pmd.h +4 -4
@@ -5,10 +5,6 @@#ifndef _CRYPTODEV_PMD_H_#define _CRYPTODEV_PMD_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** @file * RTE Crypto PMD APIs *
@@ -28,6 +24,10 @@ extern "C" {#include "rte_crypto.h" #include "rte_cryptodev.h" +#ifdef __cplusplus +extern "C" { +#endif +#define RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS 8
lib/cryptodev/cryptodev_trace.h +4 -4
@@ -11,14 +11,14 @@* API for cryptodev trace support */ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_trace_point.h> #include "rte_cryptodev.h" +#ifdef __cplusplus +extern "C" { +#endif + RTE_TRACE_POINT( rte_cryptodev_trace_configure, RTE_TRACE_POINT_ARGS(uint8_t dev_id,
lib/cryptodev/rte_crypto.h +4 -4
@@ -11,10 +11,6 @@* RTE Cryptography Common Definitions */ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_mbuf.h> #include <rte_memory.h>
@@ -24,6 +20,10 @@ extern "C" {#include "rte_crypto_sym.h" #include "rte_crypto_asym.h" +#ifdef __cplusplus +extern "C" { +#endif +/** Crypto operation types */ enum rte_crypto_op_type {RTE_CRYPTO_OP_TYPE_UNDEFINED ,
lib/cryptodev/rte_crypto_asym.h +0 -8
@@ -14,10 +14,6 @@* asymmetric crypto operations. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <string.h> #include <stdint.h>
@@ -728,8 +724,4 @@ struct rte_crypto_asym_op { */ }; -#ifdef __cplusplus -} -#endif -#endif /* _RTE_CRYPTO_ASYM_H_ */
lib/cryptodev/rte_crypto_sym.h +4 -4
@@ -14,10 +14,6 @@* as supported symmetric crypto operation combinations. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <string.h> #include <rte_compat.h>
@@ -26,6 +22,10 @@ extern "C" {#include <rte_mempool.h> #include <rte_common.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Crypto IO Vector (in analogy with struct iovec) * Supposed be used to pass input/output data buffers for crypto data-path
lib/cryptodev/rte_cryptodev.h +4 -4
@@ -14,10 +14,6 @@* authentication operations. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_compat.h> #include "rte_kvargs.h" #include "rte_crypto.h"
@@ -1859,6 +1855,10 @@ int rte_cryptodev_remove_deq_callback(uint8_t dev_id, struct rte_cryptodev_cb *cb);#include <rte_cryptodev_core.h> + +#ifdef __cplusplus +extern "C" { +#endif /** * * Dequeue a burst of processed crypto operations from a queue on the crypto
lib/cryptodev/rte_cryptodev_trace_fp.h +2 -2
@@ -5,12 +5,12 @@ #ifndef _RTE_CRYPTODEV_TRACE_FP_H_ #define _RTE_CRYPTODEV_TRACE_FP_H_ +#include <rte_trace_point.h> + #ifdef __cplusplus extern "C" { #endif -#include <rte_trace_point.h> - RTE_TRACE_POINT_FP( rte_cryptodev_trace_enqueue_burst, RTE_TRACE_POINT_ARGS(uint8_t dev_id, uint16_t qp_id, void **ops,
lib/dispatcher/rte_dispatcher.h +4 -4
@@ -19,16 +19,16 @@* event device. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdbool.h> #include <stdint.h> #include <rte_compat.h> #include <rte_eventdev.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Function prototype for match callbacks. *
lib/dmadev/rte_dmadev.h +8 -0
@@ -772,9 +772,17 @@ struct rte_dma_sge {uint32_t length;/**< The DMA operation length. */ }; +#ifdef __cplusplus +} +#endif +#include "rte_dmadev_core.h" #include "rte_dmadev_trace_fp.h" +#ifdef __cplusplus +extern "C" { +#endif +/**@{@name DMA operation flag * @see rte_dma_copy() * @see rte_dma_copy_sg()
lib/eal/arm/include/rte_atomic_32.h +2 -2
@@ -9,12 +9,12 @@# error Platform must be built with RTE_FORCE_INTRINSICS#endif +#include "generic/rte_atomic.h" +#ifdef __cplusplusextern "C" {#endif -#include "generic/rte_atomic.h" -#define rte_mb () __sync_synchronize()#define rte_wmb () do { asm volatile ("dmb st" : : : "memory"); } while (0)
lib/eal/arm/include/rte_atomic_64.h +4 -4
@@ -10,14 +10,14 @@# error Platform must be built with RTE_FORCE_INTRINSICS#endif -#ifdef __cplusplus -extern "C" { -#endif -#include "generic/rte_atomic.h" #include <rte_branch_prediction.h> #include <rte_debug.h> +#ifdef __cplusplus +extern "C" { +#endif +#define rte_mb () asm volatile("dmb osh" : : : "memory")#define rte_wmb () asm volatile("dmb oshst" : : : "memory")
lib/eal/arm/include/rte_byteorder.h +4 -4
@@ -9,14 +9,14 @@# error Platform must be built with RTE_FORCE_INTRINSICS#endif -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #include <rte_common.h> #include "generic/rte_byteorder.h" +#ifdef __cplusplus +extern "C" { +#endif +/* ARM architecture is bi-endian (both big and little). */ #if RTE_BYTE_ORDER ==RTE_LITTLE_ENDIAN
lib/eal/arm/include/rte_cpuflags_32.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_CPUFLAGS_ARM32_H_#define _RTE_CPUFLAGS_ARM32_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * Enumeration of all CPU features supported */
@@ -46,8 +42,4 @@ enum rte_cpu_flag_t {#include "generic/rte_cpuflags.h" -#ifdef __cplusplus -} -#endif -#endif /* _RTE_CPUFLAGS_ARM32_H_ */
lib/eal/arm/include/rte_cpuflags_64.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_CPUFLAGS_ARM64_H_#define _RTE_CPUFLAGS_ARM64_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * Enumeration of all CPU features supported */
@@ -40,8 +36,4 @@ enum rte_cpu_flag_t {#include "generic/rte_cpuflags.h" -#ifdef __cplusplus -} -#endif -#endif /* _RTE_CPUFLAGS_ARM64_H_ */
lib/eal/arm/include/rte_cycles_32.h +2 -2
@@ -15,12 +15,12 @@#include <time.h> +#include "generic/rte_cycles.h" +#ifdef __cplusplusextern "C" {#endif -#include "generic/rte_cycles.h" -/** * Read the time base register. *
lib/eal/arm/include/rte_cycles_64.h +2 -2
@@ -6,12 +6,12 @@ #ifndef _RTE_CYCLES_ARM64_H_ #define _RTE_CYCLES_ARM64_H_ +#include "generic/rte_cycles.h" + #ifdef __cplusplus extern "C" { #endif -#include "generic/rte_cycles.h" - /** Read generic counter frequency */ static __rte_always_inline uint64_t __rte_arm64_cntfrq(void)
lib/eal/arm/include/rte_io.h +0 -8
@@ -5,18 +5,10 @@#ifndef _RTE_IO_ARM_H_#define _RTE_IO_ARM_H_ -#ifdef __cplusplus -extern "C" { -#endif -#ifdef RTE_ARCH_64 #include "rte_io_64.h" #else #include "generic/rte_io.h" #endif -#ifdef __cplusplus -} -#endif -#endif /* _RTE_IO_ARM_H_ */
lib/eal/arm/include/rte_io_64.h +4 -4
@@ -5,10 +5,6 @@#ifndef _RTE_IO_ARM64_H_#define _RTE_IO_ARM64_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #define RTE_OVERRIDE_IO_H
@@ -17,6 +13,10 @@ extern "C" {#include <rte_compat.h> #include "rte_atomic_64.h" +#ifdef __cplusplus +extern "C" { +#endif + static __rte_always_inline uint8_trte_read8_relaxed (const volatile void *addr) {
lib/eal/arm/include/rte_memcpy_32.h +4 -4
@@ -8,10 +8,6 @@#include <stdint.h> #include <string.h> -#ifdef __cplusplus -extern "C" { -#endif -#include "generic/rte_memcpy.h" #ifdef RTE_ARCH_ARM_NEON_MEMCPY
@@ -23,6 +19,10 @@ extern "C" {/* ARM NEON Intrinsics are used to copy data */ #include <arm_neon.h> +#ifdef __cplusplus +extern "C" { +#endif +static inline void rte_mov16 (uint8_t *dst,const uint8_t *src) {
lib/eal/arm/include/rte_memcpy_64.h +16 -7
@@ -5,10 +5,6 @@#ifndef _RTE_MEMCPY_ARM64_H_#define _RTE_MEMCPY_ARM64_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #include <string.h>
@@ -18,6 +14,10 @@ extern "C" {#include <rte_common.h> #include <rte_branch_prediction.h> +#ifdef __cplusplus +extern "C" { +#endif +/* * The memory copy performance differs on different AArch64 micro-architectures. * And the most recent glibc (e.g. 2.23 or later) can provide a better memcpy()
@@ -324,7 +324,16 @@ void *rte_memcpy(void *dst, const void *src, size_t n) }#endif /* RTE_CACHE_LINE_SIZE >= 128 */ -#else +#ifdef __cplusplus +} +#endif + +#else /* RTE_ARCH_ARM64_MEMCPY */ + +#ifdef __cplusplus +extern "C" { +#endif +static inline void rte_mov16 (uint8_t *dst,const uint8_t *src) {
@@ -363,10 +372,10 @@ rte_mov256(uint8_t *dst, const uint8_t *src)#define rte_memcpy (d, s, n) memcpy((d), (s), (n)) -#endif /* RTE_ARCH_ARM64_MEMCPY */ -#ifdef __cplusplus }#endif +#endif /* RTE_ARCH_ARM64_MEMCPY */ +#endif /* _RTE_MEMCPY_ARM_64_H_ */
lib/eal/arm/include/rte_pause.h +0 -8
@@ -5,18 +5,10 @@#ifndef _RTE_PAUSE_ARM_H_#define _RTE_PAUSE_ARM_H_ -#ifdef __cplusplus -extern "C" { -#endif -#ifdef RTE_ARCH_64 #include <rte_pause_64.h> #else #include <rte_pause_32.h> #endif -#ifdef __cplusplus -} -#endif -#endif /* _RTE_PAUSE_ARM_H_ */
lib/eal/arm/include/rte_pause_32.h +3 -3
@@ -5,13 +5,13 @@ #ifndef _RTE_PAUSE_ARM32_H_ #define _RTE_PAUSE_ARM32_H_ +#include <rte_common.h> +#include "generic/rte_pause.h" + #ifdef __cplusplus extern "C" { #endif -#include <rte_common.h> -#include "generic/rte_pause.h" - static inline void rte_pause(void) { }
lib/eal/arm/include/rte_pause_64.h +4 -4
@@ -6,10 +6,6 @@#ifndef _RTE_PAUSE_ARM64_H_#define _RTE_PAUSE_ARM64_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_common.h> #include <rte_stdatomic.h>
@@ -19,6 +15,10 @@ extern "C" {#include "generic/rte_pause.h" +#ifdef __cplusplus +extern "C" { +#endif +static inline void rte_pause (void ) { asmvolatile ("yield" :::"memory" );
lib/eal/arm/include/rte_power_intrinsics.h +0 -8
@@ -5,16 +5,8 @@#ifndef _RTE_POWER_INTRINSIC_ARM_H_#define _RTE_POWER_INTRINSIC_ARM_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_common.h> #include "generic/rte_power_intrinsics.h" -#ifdef __cplusplus -} -#endif -#endif /* _RTE_POWER_INTRINSIC_ARM_H_ */
lib/eal/arm/include/rte_prefetch_32.h +4 -4
@@ -5,14 +5,14 @@ #ifndef _RTE_PREFETCH_ARM32_H_ #define _RTE_PREFETCH_ARM32_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_compat.h> #include <rte_common.h> #include "generic/rte_prefetch.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void rte_prefetch0(const volatile void *p) { asm volatile ("pld [%0]" : : "r" (p));
lib/eal/arm/include/rte_prefetch_64.h +4 -4
@@ -5,14 +5,14 @@ #ifndef _RTE_PREFETCH_ARM_64_H_ #define _RTE_PREFETCH_ARM_64_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_compat.h> #include <rte_common.h> #include "generic/rte_prefetch.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void rte_prefetch0(const volatile void *p) { asm volatile ("PRFM PLDL1KEEP, [%0]" : : "r" (p));
lib/eal/arm/include/rte_rwlock.h +2 -2
@@ -5,12 +5,12 @@ #ifndef _RTE_RWLOCK_ARM_H_ #define _RTE_RWLOCK_ARM_H_ +#include "generic/rte_rwlock.h" + #ifdef __cplusplus extern "C" { #endif -#include "generic/rte_rwlock.h" - static inline void rte_rwlock_read_lock_tm(rte_rwlock_t *rwl) {
lib/eal/arm/include/rte_spinlock.h +3 -3
@@ -9,13 +9,13 @@# error Platform must be built with RTE_FORCE_INTRINSICS#endif +#include <rte_common.h> +#include "generic/rte_spinlock.h" +#ifdef __cplusplusextern "C" {#endif -#include <rte_common.h> -#include "generic/rte_spinlock.h" -static inline int rte_tm_supported (void ) {return 0 ;
lib/eal/freebsd/include/rte_os.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_OS_H_#define _RTE_OS_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * This header should contain any definition * which is not supported natively or named differently in FreeBSD.
@@ -78,8 +74,4 @@ typedef cpuset_t rte_cpuset_t;#endif /* RTE_EAL_FREEBSD_CPUSET_LEGACY */ -#ifdef __cplusplus -} -#endif -#endif /* _RTE_OS_H_ */
lib/eal/include/bus_driver.h +4 -4
@@ -5,16 +5,16 @@ #ifndef BUS_DRIVER_H #define BUS_DRIVER_H -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_bus.h> #include <rte_compat.h> #include <rte_dev.h> #include <rte_eal.h> #include <rte_tailq.h> +#ifdef __cplusplus +extern "C" { +#endif + struct rte_devargs; struct rte_device;
lib/eal/include/dev_driver.h +0 -8
@@ -5,10 +5,6 @@#ifndef DEV_DRIVER_H #define DEV_DRIVER_H -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_common.h> #include <rte_dev.h>
@@ -34,8 +30,4 @@ struct rte_device { struct rte_devargs *devargs; /**< Arguments for latest probing */ }; -#ifdef __cplusplus -} -#endif -#endif /* DEV_DRIVER_H */
lib/eal/include/eal_trace_internal.h +4 -4
@@ -11,16 +11,16 @@* API for EAL trace support */ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_alarm.h> #include <rte_interrupts.h> #include <rte_trace_point.h> #include "eal_interrupts.h" +#ifdef __cplusplus +extern "C" { +#endif +/* Alarm */ RTE_TRACE_POINT( rte_eal_trace_alarm_set,
lib/eal/include/generic/rte_atomic.h +8 -0
@@ -17,6 +17,10 @@#include <rte_common.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __DOXYGEN__/** @name Memory Barrier
@@ -1156,4 +1160,8 @@ rte_atomic128_cmp_exchange(rte_int128_t *dst,#endif /* __DOXYGEN__ */ +#ifdef __cplusplus +} +#endif +#endif /* _RTE_ATOMIC_H_ */
lib/eal/include/generic/rte_byteorder.h +8 -0
@@ -24,6 +24,10 @@#include <rte_common.h> #include <rte_config.h> +#ifdef __cplusplus +extern "C" { +#endif +/* * Compile-time endianness detection */
@@ -251,4 +255,8 @@ static uint64_t rte_be_to_cpu_64(rte_be64_t x);#endif #endif +#ifdef __cplusplus +} +#endif +#endif /* _RTE_BYTEORDER_H_ */
lib/eal/include/generic/rte_cpuflags.h +8 -0
@@ -15,6 +15,10 @@#include <rte_compat.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Structure used to describe platform-specific intrinsics that may or may not * be supported at runtime.
@@ -104,4 +108,8 @@ rte_cpu_getauxval(unsigned long type);int rte_cpu_strcmp_auxval (unsigned long type,const char *str); +#ifdef __cplusplus +} +#endif +#endif /* _RTE_CPUFLAGS_H_ */
lib/eal/include/generic/rte_cycles.h +8 -0
@@ -16,6 +16,10 @@#include <rte_debug.h> #include <rte_atomic.h> +#ifdef __cplusplus +extern "C" { +#endif +#define MS_PER_S 1000#define US_PER_S 1000000#define NS_PER_S 1000000000
@@ -175,4 +179,8 @@ void rte_delay_us_sleep(unsigned int us);*/ void rte_delay_us_callback_register (void (*userfunc)(unsigned int )); +#ifdef __cplusplus +} +#endif +#endif /* _RTE_CYCLES_H_ */
lib/eal/include/generic/rte_io.h +8 -0
@@ -17,6 +17,10 @@#include <rte_compat.h> #include <rte_atomic.h> +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __DOXYGEN__/**
@@ -396,4 +400,8 @@ rte_write32_wc_relaxed(uint32_t value, volatile void *addr)#endif /* RTE_OVERRIDE_IO_H */ +#ifdef __cplusplus +} +#endif +#endif /* _RTE_IO_H_ */
lib/eal/include/generic/rte_memcpy.h +8 -0
@@ -5,6 +5,10 @@ #ifndef _RTE_MEMCPY_H_ #define _RTE_MEMCPY_H_ +#ifdef __cplusplus +extern "C" { +#endif + /** * @file *
@@ -113,4 +117,8 @@ rte_memcpy(void *dst, const void *src, size_t n);#endif /* __DOXYGEN__ */ +#ifdef __cplusplus +} +#endif +#endif /* _RTE_MEMCPY_H_ */
lib/eal/include/generic/rte_pause.h +8 -0
@@ -19,6 +19,10 @@#include <rte_atomic.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Pause CPU execution for a short while *
@@ -136,4 +140,8 @@ rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected, } while (0)#endif /* ! RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED */ +#ifdef __cplusplus +} +#endif +#endif /* _RTE_PAUSE_H_ */
lib/eal/include/generic/rte_power_intrinsics.h +8 -0
@@ -9,6 +9,10 @@#include <rte_spinlock.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * @file * Advanced power management operations.
@@ -147,4 +151,8 @@ int rte_power_pause(const uint64_t tsc_timestamp);int rte_power_monitor_multi (const struct rte_power_monitor_cond pmc[],const uint32_t num,const uint64_t tsc_timestamp); +#ifdef __cplusplus +} +#endif +#endif /* _RTE_POWER_INTRINSIC_H_ */
lib/eal/include/generic/rte_prefetch.h +8 -0
@@ -7,6 +7,10 @@#include <rte_compat.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * @file *
@@ -146,4 +150,8 @@ __rte_experimentalstatic inline void rte_cldemote (const volatile void *p); +#ifdef __cplusplus +} +#endif +#endif /* _RTE_PREFETCH_H_ */
lib/eal/include/generic/rte_rwlock.h +4 -4
@@ -22,10 +22,6 @@* https://locklessinc.com/articles/locks/ */ -#ifdef __cplusplus -extern "C" { -#endif -#include <errno.h> #include <rte_branch_prediction.h>
@@ -34,6 +30,10 @@ extern "C" {#include <rte_pause.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * The rte_rwlock_t type. *
lib/eal/include/generic/rte_spinlock.h +8 -0
@@ -25,6 +25,10 @@#include <rte_pause.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * The rte_spinlock_t type. */
@@ -318,4 +322,8 @@ __rte_warn_unused_resultstatic inline int rte_spinlock_recursive_trylock_tm (rte_spinlock_recursive_t *slr); +#ifdef __cplusplus +} +#endif +#endif /* _RTE_SPINLOCK_H_ */
lib/eal/include/generic/rte_vect.h +8 -0
@@ -209,6 +209,10 @@ enum rte_vect_max_simd {*/ }; +#ifdef __cplusplus +extern "C" { +#endif +/** * Get the supported SIMD bitwidth. *
@@ -230,4 +234,8 @@ uint16_t rte_vect_get_max_simd_bitwidth(void);*/ int rte_vect_set_max_simd_bitwidth (uint16_t bitwidth); +#ifdef __cplusplus +} +#endif +#endif /* _RTE_VECT_H_ */
lib/eal/include/rte_alarm.h +2 -2
@@ -14,12 +14,12 @@* Does not require hpet support. */ +#include <stdint.h> +#ifdef __cplusplusextern "C" {#endif -#include <stdint.h> -/** * Signature of callback back function called when an alarm goes off. */
lib/eal/include/rte_bitmap.h +4 -4
@@ -5,10 +5,6 @@#ifndef __INCLUDE_RTE_BITMAP_H__#define __INCLUDE_RTE_BITMAP_H__ -#ifdef __cplusplus -extern "C" { -#endif -/** * @file * RTE Bitmap
@@ -43,6 +39,10 @@ extern "C" {#include <rte_branch_prediction.h> #include <rte_prefetch.h> +#ifdef __cplusplus +extern "C" { +#endif +/* Slab */ #define RTE_BITMAP_SLAB_BIT_SIZE 64#define RTE_BITMAP_SLAB_BIT_SIZE_LOG2 6
lib/eal/include/rte_branch_prediction.h +0 -8
@@ -10,10 +10,6 @@#ifndef _RTE_BRANCH_PREDICTION_H_#define _RTE_BRANCH_PREDICTION_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * Check if a branch is likely to be taken. *
@@ -48,8 +44,4 @@ extern "C" {#endif #endif /* unlikely */ -#ifdef __cplusplus -} -#endif -#endif /* _RTE_BRANCH_PREDICTION_H_ */
lib/eal/include/rte_bus.h +4 -4
@@ -14,14 +14,14 @@* over the devices and drivers in EAL. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <rte_eal.h> +#ifdef __cplusplus +extern "C" { +#endif +struct rte_bus ;struct rte_device ;
lib/eal/include/rte_class.h +2 -2
@@ -18,12 +18,12 @@* cryptographic co-processor (crypto), etc. */ +#include <rte_dev.h> +#ifdef __cplusplusextern "C" {#endif -#include <rte_dev.h> -/** Double linked list of classes */ RTE_TAILQ_HEAD (rte_class_list, rte_class);
lib/eal/include/rte_common.h +4 -4
@@ -12,10 +12,6 @@* for DPDK. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <assert.h> #include <limits.h> #include <stdint.h>
@@ -26,6 +22,10 @@ extern "C" {/* OS specific include */ #include <rte_os.h> +#ifdef __cplusplus +extern "C" { +#endif +#ifndef RTE_TOOLCHAIN_MSVC #ifndef typeof#define typeof __typeof__
lib/eal/include/rte_compat.h +0 -8
@@ -6,10 +6,6 @@#ifndef _RTE_COMPAT_H_#define _RTE_COMPAT_H_ -#ifdef __cplusplus -extern "C" { -#endif -#ifndef ALLOW_EXPERIMENTAL_API #ifdef RTE_TOOLCHAIN_MSVC
@@ -70,8 +66,4 @@ __attribute__((section(".text.internal")))#endif -#ifdef __cplusplus -} -#endif -#endif /* _RTE_COMPAT_H_ */
lib/eal/include/rte_dev.h +4 -4
@@ -13,16 +13,16 @@* This file manages the list of device drivers. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <rte_config.h> #include <rte_common.h> #include <rte_log.h> +#ifdef __cplusplus +extern "C" { +#endif +struct rte_bus ;struct rte_devargs ;struct rte_device ;
lib/eal/include/rte_devargs.h +4 -4
@@ -16,14 +16,14 @@* list of rte_devargs structures. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <rte_dev.h> +#ifdef __cplusplus +extern "C" { +#endif +struct rte_bus ;/**
lib/eal/include/rte_eal_trace.h +2 -2
@@ -11,12 +11,12 @@* API for EAL trace support */ +#include <rte_trace_point.h> +#ifdef __cplusplusextern "C" {#endif -#include <rte_trace_point.h> -/* Generic */ RTE_TRACE_POINT( rte_eal_trace_generic_void,
lib/eal/include/rte_errno.h +2 -2
@@ -11,12 +11,12 @@ #ifndef _RTE_ERRNO_H_ #define _RTE_ERRNO_H_ +#include <rte_per_lcore.h> + #ifdef __cplusplus extern "C" { #endif -#include <rte_per_lcore.h> - RTE_DECLARE_PER_LCORE(int, _rte_errno); /**< Per core error number. */ /**
lib/eal/include/rte_fbarray.h +4 -4
@@ -30,14 +30,14 @@* another process is using ``rte_fbarray``. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <rte_rwlock.h> +#ifdef __cplusplus +extern "C" { +#endif + #define RTE_FBARRAY_NAME_LEN 64 struct rte_fbarray {
lib/eal/include/rte_keepalive.h +3 -3
@@ -10,13 +10,13 @@ #ifndef _KEEPALIVE_H_ #define _KEEPALIVE_H_ +#include <rte_config.h> +#include <rte_memory.h> + #ifdef __cplusplus extern "C" { #endif -#include <rte_config.h> -#include <rte_memory.h> - #ifndef RTE_KEEPALIVE_MAXCORES /** * Number of cores to track.
lib/eal/include/rte_mcslock.h +4 -4
@@ -19,16 +19,16 @@* they acquired the lock. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_lcore.h> #include <rte_common.h> #include <rte_pause.h> #include <rte_branch_prediction.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * The rte_mcslock_t type. */
lib/eal/include/rte_memory.h +4 -4
@@ -15,16 +15,16 @@#include <stddef.h> #include <stdio.h> -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_bitops.h> #include <rte_common.h> #include <rte_config.h> #include <rte_eal_memconfig.h> #include <rte_fbarray.h> +#ifdef __cplusplus +extern "C" { +#endif +#define RTE_PGSIZE_4K (1ULL << 12)#define RTE_PGSIZE_64K (1ULL << 16)#define RTE_PGSIZE_256K (1ULL << 18)
lib/eal/include/rte_pci_dev_feature_defs.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_PCI_DEV_DEFS_H_#define _RTE_PCI_DEV_DEFS_H_ -#ifdef __cplusplus -extern "C" { -#endif -/* interrupt mode */ enum rte_intr_mode { RTE_INTR_MODE_NONE = 0,
@@ -17,8 +13,4 @@ enum rte_intr_mode {RTE_INTR_MODE_MSIX }; -#ifdef __cplusplus -} -#endif -#endif /* _RTE_PCI_DEV_DEFS_H_ */
lib/eal/include/rte_pci_dev_features.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_PCI_DEV_FEATURES_H#define _RTE_PCI_DEV_FEATURES_H -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_pci_dev_feature_defs.h> #define RTE_INTR_MODE_NONE_NAME "none"
@@ -16,8 +12,4 @@ extern "C" {#define RTE_INTR_MODE_MSI_NAME "msi"#define RTE_INTR_MODE_MSIX_NAME "msix" -#ifdef __cplusplus -} -#endif -#endif
lib/eal/include/rte_per_lcore.h +0 -8
@@ -18,10 +18,6 @@* Parts of this are execution environment specific. */ -#ifdef __cplusplus -extern "C" { -#endif -#ifdef RTE_TOOLCHAIN_MSVC #define RTE_DEFINE_PER_LCORE (type, name) \ __declspec(thread) type per_lcore_##name
@@ -49,8 +45,4 @@ extern "C" {*/ #define RTE_PER_LCORE (name) (per_lcore_##name) -#ifdef __cplusplus -} -#endif -#endif /* _RTE_PER_LCORE_H_ */
lib/eal/include/rte_pflock.h +4 -4
@@ -27,14 +27,14 @@* All locks must be initialised before use, and only initialised once. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_common.h> #include <rte_pause.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * The rte_pflock_t type. */
lib/eal/include/rte_random.h +2 -2
@@ -11,12 +11,12 @@* Pseudo-random Generators in RTE */ +#include <stdint.h> +#ifdef __cplusplusextern "C" {#endif -#include <stdint.h> -/** * Seed the pseudo-random generator. *
lib/eal/include/rte_seqcount.h +4 -4
@@ -5,10 +5,6 @@#ifndef _RTE_SEQCOUNT_H_#define _RTE_SEQCOUNT_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * @file * RTE Seqcount
@@ -27,6 +23,10 @@ extern "C" {#include <rte_branch_prediction.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * The RTE seqcount type. */
lib/eal/include/rte_seqlock.h +4 -4
@@ -5,10 +5,6 @@#ifndef _RTE_SEQLOCK_H_#define _RTE_SEQLOCK_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * @file * RTE Seqlock
@@ -95,6 +91,10 @@ extern "C" {#include <rte_seqcount.h> #include <rte_spinlock.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * The RTE seqlock type. */
lib/eal/include/rte_service.h +4 -4
@@ -23,16 +23,16 @@* application has access to the remaining lcores as normal. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <stdint.h> #include <rte_config.h> #include <rte_lcore.h> +#ifdef __cplusplus +extern "C" { +#endif +#define RTE_SERVICE_NAME_MAX 32/* Capabilities of a service.
lib/eal/include/rte_service_component.h +2 -2
@@ -10,12 +10,12 @@* operate, and you wish to run the component using service cores */ +#include <rte_service.h> +#ifdef __cplusplusextern "C" {#endif -#include <rte_service.h> -/** * Signature of callback function to run a service. *
lib/eal/include/rte_stdatomic.h +1 -4
@@ -7,10 +7,6 @@#include <assert.h> -#ifdef __cplusplus -extern "C" { -#endif -#ifdef RTE_ENABLE_STDATOMIC #ifndef _MSC_VER#ifdef __STDC_NO_ATOMICS__
@@ -188,6 +184,7 @@ typedef int rte_memory_order;#endif #ifdef __cplusplus +extern "C" { }#endif
lib/eal/include/rte_string_fns.h +12 -5
@@ -11,10 +11,6 @@#ifndef _RTE_STRING_FNS_H_#define _RTE_STRING_FNS_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <ctype.h> #include <stdio.h> #include <string.h>
@@ -22,6 +18,10 @@ extern "C" {#include <rte_common.h> #include <rte_compat.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Takes string "string" parameter and splits it at character "delim" * up to maxtokens-1 times - to give "maxtokens" resulting tokens. Like
@@ -77,6 +77,10 @@ rte_strlcat(char *dst, const char *src, size_t size)return l +strlen (src); } +#ifdef __cplusplus +} +#endif +/* pull in a strlcpy function */ #ifdef RTE_EXEC_ENV_FREEBSD #ifndef __BSD_VISIBLE/* non-standard functions are hidden */
@@ -95,6 +99,10 @@ rte_strlcat(char *dst, const char *src, size_t size)#endif /* RTE_USE_LIBBSD */ #endif /* FREEBSD */ +#ifdef __cplusplus +extern "C" { +#endif +/** * Copy string src to buffer dst of size dsize. * At most dsize-1 chars will be copied.
@@ -141,7 +149,6 @@ rte_str_skip_leading_spaces(const char *src)return p; } - #ifdef __cplusplus }#endif
lib/eal/include/rte_tailq.h +3 -3
@@ -10,13 +10,13 @@* Here defines rte_tailq APIs for only internal use */ +#include <stdio.h> +#include <rte_debug.h> +#ifdef __cplusplusextern "C" {#endif -#include <stdio.h> -#include <rte_debug.h> -/** dummy structure type used by the rte_tailq APIs */ struct rte_tailq_entry {RTE_TAILQ_ENTRY (rte_tailq_entry) next;/**< Pointer entries for a tailq list */
lib/eal/include/rte_ticketlock.h +4 -4
@@ -17,15 +17,15 @@* All locks must be initialised before use, and only initialised once. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_common.h> #include <rte_lcore.h> #include <rte_pause.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * The rte_ticketlock_t type. */
lib/eal/include/rte_time.h +3 -3
@@ -5,13 +5,13 @@ #ifndef _RTE_TIME_H_ #define _RTE_TIME_H_ +#include <stdint.h> +#include <time.h> + #ifdef __cplusplus extern "C" { #endif -#include <stdint.h> -#include <time.h> - #define NSEC_PER_SEC 1000000000L /**
lib/eal/include/rte_trace.h +4 -4
@@ -16,16 +16,16 @@* @b EXPERIMENTAL: this API may change without prior notice */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdbool.h> #include <stdio.h> #include <rte_common.h> #include <rte_compat.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Test if trace is enabled. *
lib/eal/include/rte_trace_point.h +4 -4
@@ -16,10 +16,6 @@* @b EXPERIMENTAL: this API may change without prior notice */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdbool.h> #include <stdio.h>
@@ -32,6 +28,10 @@ extern "C" {#include <rte_string_fns.h> #include <rte_uuid.h> +#ifdef __cplusplus +extern "C" { +#endif +/** The tracepoint object. */ typedef RTE_ATOMIC (uint64_t )rte_trace_point_t ;
lib/eal/include/rte_trace_point_register.h +4 -4
@@ -5,10 +5,6 @@#ifndef _RTE_TRACE_POINT_REGISTER_H_#define _RTE_TRACE_POINT_REGISTER_H_ -#ifdef __cplusplus -extern "C" { -#endif -#ifdef _RTE_TRACE_POINT_H_#error for registration, include this file first before <rte_trace_point.h>#endif
@@ -16,6 +12,10 @@ extern "C" {#include <rte_per_lcore.h> #include <rte_trace_point.h> +#ifdef __cplusplus +extern "C" { +#endif + RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz);#define RTE_TRACE_POINT_REGISTER (trace, name) \
lib/eal/include/rte_uuid.h +4 -4
@@ -10,14 +10,14 @@ #ifndef _RTE_UUID_H_ #define _RTE_UUID_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <stdbool.h> #include <stddef.h> #include <string.h> +#ifdef __cplusplus +extern "C" { +#endif + /** * Struct describing a Universal Unique Identifier */
lib/eal/include/rte_version.h +3 -3
@@ -10,13 +10,13 @@ #ifndef _RTE_VERSION_H_ #define _RTE_VERSION_H_ +#include <string.h> +#include <stdio.h> + #ifdef __cplusplus extern "C" { #endif -#include <string.h> -#include <stdio.h> - /** * Macro to compute a version number usable for comparisons */
lib/eal/include/rte_vfio.h +4 -4
@@ -10,10 +10,6 @@* RTE VFIO. This library provides various VFIO related utility functions. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdbool.h> #include <stdint.h>
@@ -32,6 +28,10 @@ extern "C" {#endif /* kernel version >= 4.0.0 */ #endif /* RTE_EAL_VFIO */ +#ifdef __cplusplus +extern "C" { +#endif +#ifdef VFIO_PRESENT #include <linux/vfio.h>
lib/eal/linux/include/rte_os.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_OS_H_#define _RTE_OS_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * This header should contain any definition * which is not supported natively or named differently in Linux.
@@ -46,8 +42,4 @@ typedef cpu_set_t rte_cpuset_t; } while (0)#endif -#ifdef __cplusplus -} -#endif -#endif /* _RTE_OS_H_ */
lib/eal/loongarch/include/rte_atomic.h +3 -3
@@ -9,13 +9,13 @@# error Platform must be built with RTE_FORCE_INTRINSICS#endif +#include <rte_common.h> +#include "generic/rte_atomic.h" +#ifdef __cplusplusextern "C" {#endif -#include <rte_common.h> -#include "generic/rte_atomic.h" -#define rte_mb () do { asm volatile("dbar 0":::"memory"); } while (0)#define rte_wmb () rte_mb()
lib/eal/loongarch/include/rte_byteorder.h +2 -2
@@ -5,12 +5,12 @@ #ifndef RTE_BYTEORDER_LOONGARCH_H #define RTE_BYTEORDER_LOONGARCH_H +#include "generic/rte_byteorder.h" + #ifdef __cplusplus extern "C" { #endif -#include "generic/rte_byteorder.h" - #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN #define rte_cpu_to_le_16(x) (x)
lib/eal/loongarch/include/rte_cpuflags.h +0 -8
@@ -5,10 +5,6 @@#ifndef RTE_CPUFLAGS_LOONGARCH_H #define RTE_CPUFLAGS_LOONGARCH_H -#ifdef __cplusplus -extern "C" { -#endif -/** * Enumeration of all CPU features supported */
@@ -30,8 +26,4 @@ enum rte_cpu_flag_t {#include "generic/rte_cpuflags.h" -#ifdef __cplusplus -} -#endif -#endif /* RTE_CPUFLAGS_LOONGARCH_H */
lib/eal/loongarch/include/rte_cycles.h +2 -2
@@ -5,12 +5,12 @@ #ifndef RTE_CYCLES_LOONGARCH_H #define RTE_CYCLES_LOONGARCH_H +#include "generic/rte_cycles.h" + #ifdef __cplusplus extern "C" { #endif -#include "generic/rte_cycles.h" - /** * Read the time base register. *
lib/eal/loongarch/include/rte_io.h +0 -8
@@ -5,14 +5,6 @@#ifndef RTE_IO_LOONGARCH_H #define RTE_IO_LOONGARCH_H -#ifdef __cplusplus -extern "C" { -#endif -#include "generic/rte_io.h" -#ifdef __cplusplus -} -#endif -#endif /* RTE_IO_LOONGARCH_H */
lib/eal/loongarch/include/rte_memcpy.h +2 -2
@@ -10,12 +10,12 @@#include "rte_common.h" +#include "generic/rte_memcpy.h" +#ifdef __cplusplusextern "C" {#endif -#include "generic/rte_memcpy.h" -static inline void rte_mov16 (uint8_t *dst,const uint8_t *src) {
lib/eal/loongarch/include/rte_pause.h +4 -4
@@ -5,14 +5,14 @@ #ifndef RTE_PAUSE_LOONGARCH_H #define RTE_PAUSE_LOONGARCH_H -#ifdef __cplusplus -extern "C" { -#endif - #include "rte_atomic.h" #include "generic/rte_pause.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void rte_pause(void) { }
lib/eal/loongarch/include/rte_power_intrinsics.h +0 -8
@@ -5,16 +5,8 @@#ifndef RTE_POWER_INTRINSIC_LOONGARCH_H #define RTE_POWER_INTRINSIC_LOONGARCH_H -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_common.h> #include "generic/rte_power_intrinsics.h" -#ifdef __cplusplus -} -#endif -#endif /* RTE_POWER_INTRINSIC_LOONGARCH_H */
lib/eal/loongarch/include/rte_prefetch.h +4 -4
@@ -5,14 +5,14 @@ #ifndef RTE_PREFETCH_LOONGARCH_H #define RTE_PREFETCH_LOONGARCH_H -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_compat.h> #include <rte_common.h> #include "generic/rte_prefetch.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void rte_prefetch0(const volatile void *p) { __builtin_prefetch((const void *)(uintptr_t)p, 0, 3);
lib/eal/loongarch/include/rte_rwlock.h +2 -2
@@ -5,12 +5,12 @@ #ifndef RTE_RWLOCK_LOONGARCH_H #define RTE_RWLOCK_LOONGARCH_H +#include "generic/rte_rwlock.h" + #ifdef __cplusplus extern "C" { #endif -#include "generic/rte_rwlock.h" - static inline void rte_rwlock_read_lock_tm(rte_rwlock_t *rwl) {
lib/eal/loongarch/include/rte_spinlock.h +3 -3
@@ -5,13 +5,13 @@ #ifndef RTE_SPINLOCK_LOONGARCH_H #define RTE_SPINLOCK_LOONGARCH_H +#include <rte_common.h> +#include "generic/rte_spinlock.h" + #ifdef __cplusplus extern "C" { #endif -#include <rte_common.h> -#include "generic/rte_spinlock.h" - #ifndef RTE_FORCE_INTRINSICS # error Platform must be built with RTE_FORCE_INTRINSICS #endif
lib/eal/ppc/include/rte_atomic.h +3 -3
@@ -12,13 +12,13 @@ #ifndef _RTE_ATOMIC_PPC_64_H_ #define _RTE_ATOMIC_PPC_64_H_ +#include <stdint.h> +#include "generic/rte_atomic.h" + #ifdef __cplusplus extern "C" { #endif -#include <stdint.h> -#include "generic/rte_atomic.h" - #define rte_mb() asm volatile("sync" : : : "memory") #define rte_wmb() asm volatile("sync" : : : "memory")
lib/eal/ppc/include/rte_byteorder.h +3 -3
@@ -8,13 +8,13 @@ #ifndef _RTE_BYTEORDER_PPC_64_H_ #define _RTE_BYTEORDER_PPC_64_H_ +#include <stdint.h> +#include "generic/rte_byteorder.h" + #ifdef __cplusplus extern "C" { #endif -#include <stdint.h> -#include "generic/rte_byteorder.h" - /* * An architecture-optimized byte swap for a 16-bit value. *
lib/eal/ppc/include/rte_cpuflags.h +0 -8
@@ -6,10 +6,6 @@#ifndef _RTE_CPUFLAGS_PPC_64_H_#define _RTE_CPUFLAGS_PPC_64_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * Enumeration of all CPU features supported */
@@ -52,8 +48,4 @@ enum rte_cpu_flag_t {#include "generic/rte_cpuflags.h" -#ifdef __cplusplus -} -#endif -#endif /* _RTE_CPUFLAGS_PPC_64_H_ */
lib/eal/ppc/include/rte_cycles.h +4 -4
@@ -6,10 +6,6 @@#ifndef _RTE_CYCLES_PPC_64_H_#define _RTE_CYCLES_PPC_64_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <features.h> #ifdef __GLIBC__#include <sys/platform/ppc.h>
@@ -20,6 +16,10 @@ extern "C" {#include <rte_byteorder.h> #include <rte_common.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Read the time base register. *
lib/eal/ppc/include/rte_io.h +0 -8
@@ -5,14 +5,6 @@#ifndef _RTE_IO_PPC_64_H_#define _RTE_IO_PPC_64_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include "generic/rte_io.h" -#ifdef __cplusplus -} -#endif -#endif /* _RTE_IO_PPC_64_H_ */
lib/eal/ppc/include/rte_memcpy.h +2 -2
@@ -12,12 +12,12 @@#include "rte_altivec.h" #include "rte_common.h" +#include "generic/rte_memcpy.h" +#ifdef __cplusplusextern "C" {#endif -#include "generic/rte_memcpy.h" -#if defined(RTE_TOOLCHAIN_GCC ) && (GCC_VERSION >=90000 )#pragma GCC diagnostic push#pragma GCC diagnostic ignored "-Warray-bounds"
lib/eal/ppc/include/rte_pause.h +4 -4
@@ -5,14 +5,14 @@ #ifndef _RTE_PAUSE_PPC64_H_ #define _RTE_PAUSE_PPC64_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "rte_atomic.h" #include "generic/rte_pause.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void rte_pause(void) { /* Set hardware multi-threading low priority */
lib/eal/ppc/include/rte_power_intrinsics.h +0 -8
@@ -5,16 +5,8 @@#ifndef _RTE_POWER_INTRINSIC_PPC_H_#define _RTE_POWER_INTRINSIC_PPC_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_common.h> #include "generic/rte_power_intrinsics.h" -#ifdef __cplusplus -} -#endif -#endif /* _RTE_POWER_INTRINSIC_PPC_H_ */
lib/eal/ppc/include/rte_prefetch.h +4 -4
@@ -6,14 +6,14 @@ #ifndef _RTE_PREFETCH_PPC_64_H_ #define _RTE_PREFETCH_PPC_64_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_compat.h> #include <rte_common.h> #include "generic/rte_prefetch.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void rte_prefetch0(const volatile void *p) { asm volatile ("dcbt 0,%[p],0" : : [p] "r" (p));
lib/eal/ppc/include/rte_rwlock.h +2 -2
@@ -3,12 +3,12 @@ #ifndef _RTE_RWLOCK_PPC_64_H_ #define _RTE_RWLOCK_PPC_64_H_ +#include "generic/rte_rwlock.h" + #ifdef __cplusplus extern "C" { #endif -#include "generic/rte_rwlock.h" - static inline void rte_rwlock_read_lock_tm(rte_rwlock_t *rwl) {
lib/eal/ppc/include/rte_spinlock.h +4 -4
@@ -6,14 +6,14 @@ #ifndef _RTE_SPINLOCK_PPC_64_H_ #define _RTE_SPINLOCK_PPC_64_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_common.h> #include <rte_pause.h> #include "generic/rte_spinlock.h" +#ifdef __cplusplus +extern "C" { +#endif + /* Fixme: Use intrinsics to implement the spinlock on Power architecture */ #ifndef RTE_FORCE_INTRINSICS
lib/eal/riscv/include/rte_atomic.h +4 -4
@@ -12,15 +12,15 @@# 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" +#ifdef __cplusplus +extern "C" { +#endif +#define rte_mb () asm volatile("fence rw, rw" : : : "memory")#define rte_wmb () asm volatile("fence w, w" : : : "memory")
lib/eal/riscv/include/rte_byteorder.h +4 -4
@@ -8,14 +8,14 @@ #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" +#ifdef __cplusplus +extern "C" { +#endif + #ifndef RTE_BYTE_ORDER #define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN #endif
lib/eal/riscv/include/rte_cpuflags.h +0 -8
@@ -8,10 +8,6 @@#ifndef RTE_CPUFLAGS_RISCV_H #define RTE_CPUFLAGS_RISCV_H -#ifdef __cplusplus -extern "C" { -#endif -/** * Enumeration of all CPU features supported */
@@ -46,8 +42,4 @@ enum rte_cpu_flag_t {#include "generic/rte_cpuflags.h" -#ifdef __cplusplus -} -#endif -#endif /* RTE_CPUFLAGS_RISCV_H */
lib/eal/riscv/include/rte_cycles.h +2 -2
@@ -8,12 +8,12 @@ #ifndef RTE_CYCLES_RISCV_H #define RTE_CYCLES_RISCV_H +#include "generic/rte_cycles.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
lib/eal/riscv/include/rte_io.h +0 -8
@@ -8,14 +8,6 @@#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_memcpy.h +2 -2
@@ -12,12 +12,12 @@#include "rte_common.h" +#include "generic/rte_memcpy.h" +#ifdef __cplusplusextern "C" {#endif -#include "generic/rte_memcpy.h" -static inline void rte_mov16 (uint8_t *dst,const uint8_t *src) {
lib/eal/riscv/include/rte_pause.h +4 -4
@@ -7,14 +7,14 @@ #ifndef RTE_PAUSE_RISCV_H #define RTE_PAUSE_RISCV_H -#ifdef __cplusplus -extern "C" { -#endif - #include "rte_atomic.h" #include "generic/rte_pause.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void rte_pause(void) { /* Insert pause hint directly to be compatible with old compilers.
lib/eal/riscv/include/rte_power_intrinsics.h +0 -8
@@ -7,16 +7,8 @@#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 +4 -4
@@ -8,14 +8,14 @@ #ifndef RTE_PREFETCH_RISCV_H #define RTE_PREFETCH_RISCV_H -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_compat.h> #include <rte_common.h> #include "generic/rte_prefetch.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void rte_prefetch0(const volatile void *p) { RTE_SET_USED(p);
lib/eal/riscv/include/rte_rwlock.h +2 -2
@@ -7,12 +7,12 @@ #ifndef RTE_RWLOCK_RISCV_H #define RTE_RWLOCK_RISCV_H +#include "generic/rte_rwlock.h" + #ifdef __cplusplus extern "C" { #endif -#include "generic/rte_rwlock.h" - static inline void rte_rwlock_read_lock_tm(rte_rwlock_t *rwl) {
lib/eal/riscv/include/rte_spinlock.h +3 -3
@@ -12,13 +12,13 @@# error Platform must be built with RTE_FORCE_INTRINSICS#endif +#include <rte_common.h> +#include "generic/rte_spinlock.h" +#ifdef __cplusplusextern "C" {#endif -#include <rte_common.h> -#include "generic/rte_spinlock.h" -static inline int rte_tm_supported (void ) {return 0 ;
lib/eal/windows/include/pthread.h +3 -3
@@ -13,13 +13,13 @@* eal_common_thread.c and common\include\rte_per_lcore.h as Microsoft libc * does not contain pthread.h. This may be removed in future releases. */ +#include <rte_common.h> +#include <rte_windows.h> +#ifdef __cplusplusextern "C" {#endif -#include <rte_common.h> -#include <rte_windows.h> -#define PTHREAD_BARRIER_SERIAL_THREAD TRUE/* defining pthread_t type on Windows since there is no in Microsoft libc*/
lib/eal/windows/include/regex.h +4 -4
@@ -10,15 +10,15 @@* as Microsoft libc does not contain regex.h. This may be removed in * future releases. */ -#ifdef __cplusplus -extern "C" { -#endif -#define REG_NOMATCH 1#define REG_ESPACE 12#include <rte_common.h> +#ifdef __cplusplus +extern "C" { +#endif +/* defining regex_t for Windows */ typedef void *regex_t ;/* defining regmatch_t for Windows */
lib/eal/windows/include/rte_os.h +0 -8
@@ -16,10 +16,6 @@#include <sched.h> -#ifdef __cplusplus -extern "C" { -#endif -/* These macros are compatible with bundled sys/queue.h. */ #define RTE_TAILQ_HEAD (name, type) \ struct name { \
@@ -59,8 +55,4 @@ struct { \*/ typedef long long ssize_t ; -#ifdef __cplusplus -} -#endif -#endif /* _RTE_OS_H_ */
lib/eal/windows/include/rte_windows.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_WINDOWS_H_#define _RTE_WINDOWS_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * @file Windows-specific facilities *
@@ -51,8 +47,4 @@ extern "C" {RTE_LOG_LINE_PREFIX (DEBUG ,EAL , \ "GetLastError()=%lu: ", GetLastError(), __VA_ARGS__) -#ifdef __cplusplus -} -#endif -#endif /* _RTE_WINDOWS_H_ */
lib/eal/x86/include/rte_atomic.h +17 -8
@@ -5,10 +5,6 @@#ifndef _RTE_ATOMIC_X86_H_#define _RTE_ATOMIC_X86_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #include <rte_common.h> #include <rte_config.h>
@@ -31,6 +27,10 @@ extern "C" {#define rte_smp_rmb () rte_compiler_barrier() +#ifdef __cplusplus +extern "C" { +#endif +/* * From Intel Software Development Manual; Vol 3; * 8.2.2 Memory Ordering in P6 and More Recent Processor Families:
@@ -99,10 +99,18 @@ rte_atomic_thread_fence(rte_memory_order memorder)__rte_atomic_thread_fence (memorder); } +#ifdef __cplusplus +} +#endif + #ifndef RTE_TOOLCHAIN_MSVC /*------------------------- 16 bit atomic operations -------------------------*/ +#ifdef __cplusplus +extern "C" { +#endif + #ifndef RTE_FORCE_INTRINSICS static inline int rte_atomic16_cmpset(volatile uint16_t *dst, uint16_t exp, uint16_t src)
@@ -273,6 +281,11 @@ static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v) );return ret !=0 ; } + +#ifdef __cplusplus +} +#endif +#endif #ifdef RTE_ARCH_I686
@@ -283,8 +296,4 @@ static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v)#endif -#ifdef __cplusplus -} -#endif -#endif /* _RTE_ATOMIC_X86_H_ */
lib/eal/x86/include/rte_byteorder.h +8 -8
@@ -5,15 +5,15 @@ #ifndef _RTE_BYTEORDER_X86_H_ #define _RTE_BYTEORDER_X86_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <stdint.h> #include <rte_common.h> #include <rte_config.h> #include "generic/rte_byteorder.h" +#ifdef __cplusplus +extern "C" { +#endif + #ifndef RTE_BYTE_ORDER #define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN #endif
@@ -48,6 +48,10 @@ static inline uint32_t rte_arch_bswap32(uint32_t _x)return x; } +#ifdef __cplusplus +} +#endif +#define rte_bswap16 (x) ((uint16_t)(__builtin_constant_p(x) ? \ rte_constant_bswap16(x) : \ rte_arch_bswap16(x)))
@@ -83,8 +87,4 @@ static inline uint32_t rte_arch_bswap32(uint32_t _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_X86_H_ */
lib/eal/x86/include/rte_cpuflags.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_CPUFLAGS_X86_64_H_#define _RTE_CPUFLAGS_X86_64_H_ -#ifdef __cplusplus -extern "C" { -#endif -enum rte_cpu_flag_t {/* (EAX 01h) ECX features*/ RTE_CPUFLAG_SSE3 = 0, /**< SSE3 */
@@ -138,8 +134,4 @@ enum rte_cpu_flag_t {#include "generic/rte_cpuflags.h" -#ifdef __cplusplus -} -#endif -#endif /* _RTE_CPUFLAGS_X86_64_H_ */
lib/eal/x86/include/rte_cycles.h +4 -4
@@ -12,10 +12,6 @@#include <x86intrin.h> #endif -#ifdef __cplusplus -extern "C" { -#endif -#include "generic/rte_cycles.h" #ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT
@@ -26,6 +22,10 @@ extern int rte_cycles_vmware_tsc_map;#include <rte_common.h> #include <rte_config.h> +#ifdef __cplusplus +extern "C" { +#endif +static inline uint64_t rte_rdtsc (void ) {
lib/eal/x86/include/rte_io.h +4 -4
@@ -5,16 +5,16 @@ #ifndef _RTE_IO_X86_H_ #define _RTE_IO_X86_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_compat.h> #include "rte_cpuflags.h" #define RTE_NATIVE_WRITE32_WC #include "generic/rte_io.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * @internal * MOVDIRI wrapper.
lib/eal/x86/include/rte_pause.h +4 -3
@@ -5,13 +5,14 @@#ifndef _RTE_PAUSE_X86_H_#define _RTE_PAUSE_X86_H_ +#include "generic/rte_pause.h" + +#include <emmintrin.h>
Lines of this file are not shown. View the raw message.
lib/eal/x86/include/rte_power_intrinsics.h +0 -8
Lines of this file are not shown. View the raw message.
lib/eventdev/rte_event_crypto_adapter.h +4 -4
Lines of this file are not shown. View the raw message.
lib/eventdev/rte_event_eth_rx_adapter.h +4 -4
Lines of this file are not shown. View the raw message.
lib/eventdev/rte_event_eth_tx_adapter.h +4 -4
Lines of this file are not shown. View the raw message.
lib/graph/rte_graph_model_mcore_dispatch.h +4 -4
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
PATCH v11 3/7 eal: extend bit manipulation functionality
In reply to Mattias RönnblomAdd functionality to test and modify the value of individual bits in 32-bit or 64-bit words.
These functions have no implications on memory ordering, atomicity and does not use volatile and thus does not prevent any compiler optimizations.
--
PATCH v3:
* Remove unnecessary <rte_compat.h> include.
* Remove redundant 'fun' parameter from the __RTE_GEN_BIT_*() macros (Jack Bond-Preston).
* Introduce __RTE_BIT_BIT_OPS() macro, consistent with how things are done when generating the atomic bit operations.
* Refer to volatile bit op functions as variants instead of families (macro parameter naming).
RFC v6:
* Have rte_bit_test() accept const-marked bitsets.
RFC v4:
* Add rte_bit_flip() which, believe it or not, flips the value of a bit.
* Mark macro-generated private functions as experimental.
* Use macros to generate *assign*() functions.
RFC v3:
* Work around lack of C++ support for _Generic (Tyler Retzlaff).
* Fix ','-related checkpatch warnings.
--- lib/eal/include/rte_bitops.h | 260 ++++++++++++++++++++++++++++++++++- 1 file changed, 258 insertions(+), 2 deletions(-)
lib/eal/include/rte_bitops.h +258 -2
@@ -2,6 +2,7 @@* Copyright(c) 2020 Arm Limited * Copyright(c) 2010-2019 Intel Corporation * Copyright(c) 2023 Microsoft Corporation +* Copyright(c) 2024 Ericsson AB */ #ifndef _RTE_BITOPS_H_
@@ -11,12 +12,14 @@* @file * Bit Operations * -* This file defines a family of APIs for bit operations -* without enforcing memory ordering. +* This file provides functionality for low-level, single-word +* arithmetic and bit-level operations, such as counting or +* setting individual bits. */ #include <stdint.h> +#include <rte_compat.h> #include <rte_debug.h> #ifdef __cplusplus
@@ -105,6 +108,197 @@ extern "C" {#define RTE_FIELD_GET64 (mask, reg) \ ((typeof(mask))(((reg) & (mask)) >> rte_ctz64(mask))) +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Test bit in word. +* +* Generic selection macro to test the value of a bit in a 32-bit or +* 64-bit word. The type of operation depends on the type of the @c +* addr parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_test (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_test32, \ + const uint32_t *: __rte_bit_test32, \ + uint64_t *: __rte_bit_test64, \ + const uint64_t *: __rte_bit_test64)(addr, nr) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Set bit in word. +* +* Generic selection macro to set a bit in a 32-bit or 64-bit +* word. The type of operation depends on the type of the @c addr +* parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_set (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_set32, \ + uint64_t *: __rte_bit_set64)(addr, nr) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Clear bit in word. +* +* Generic selection macro to clear a bit in a 32-bit or 64-bit +* word. The type of operation depends on the type of the @c addr +* parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_clear (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_clear32, \ + uint64_t *: __rte_bit_clear64)(addr, nr) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Assign a value to a bit in word. +* +* Generic selection macro to assign a value to a bit in a 32-bit or 64-bit +* word. The type of operation depends on the type of the @c addr parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +* @param value +* The new value of the bit - true for '1', or false for '0'. +*/ +#define rte_bit_assign (addr, nr, value) \ + _Generic((addr), \ + uint32_t *: __rte_bit_assign32, \ + uint64_t *: __rte_bit_assign64)(addr, nr, value) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Flip a bit in word. +* +* Generic selection macro to change the value of a bit to '0' if '1' +* or '1' if '0' in a 32-bit or 64-bit word. The type of operation +* depends on the type of the @c addr parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_flip (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_flip32, \ + uint64_t *: __rte_bit_flip64)(addr, nr) + +#define __RTE_GEN_BIT_TEST (variant, qualifier, size) \ + __rte_experimental \ + static inline bool \ + __rte_bit_ ## variant ## test ## size(const qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = (uint ## size ## _t)1 << nr; \ + return *addr & mask; \ + } + +#define __RTE_GEN_BIT_SET (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## set ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = (uint ## size ## _t)1 << nr; \ + *addr |= mask; \ + } \ + +#define __RTE_GEN_BIT_CLEAR (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## clear ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = ~((uint ## size ## _t)1 << nr); \ + (*addr) &= mask; \ + } \ + +#define __RTE_GEN_BIT_ASSIGN (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## assign ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr, bool value) \ + { \ + if (value) \ + __rte_bit_ ## variant ## set ## size(addr, nr); \ + else \ + __rte_bit_ ## variant ## clear ## size(addr, nr); \ + } + +#define __RTE_GEN_BIT_FLIP (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## flip ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + bool value; \ + \ + value = __rte_bit_ ## variant ## test ## size(addr, nr); \ + __rte_bit_ ## variant ## assign ## size(addr, nr, !value); \ + } + +#define __RTE_GEN_BIT_OPS (v, qualifier, size) \ + __RTE_GEN_BIT_TEST(v, qualifier, size) \ + __RTE_GEN_BIT_SET(v, qualifier, size) \ + __RTE_GEN_BIT_CLEAR(v, qualifier, size) \ + __RTE_GEN_BIT_ASSIGN(v, qualifier, size) \ + __RTE_GEN_BIT_FLIP(v, qualifier, size) + +#define __RTE_GEN_BIT_OPS_SIZE (size) \ + __RTE_GEN_BIT_OPS(,, size) + +__RTE_GEN_BIT_OPS_SIZE(32) +__RTE_GEN_BIT_OPS_SIZE (64 ) +/*------------------------ 32-bit relaxed operations ------------------------*/ /**
@@ -787,6 +981,68 @@ rte_log2_u64(uint64_t v)#ifdef __cplusplus } + +/* +* Since C++ doesn't support generic selection (i.e., _Generic), +* function overloading is used instead. Such functions must be +* defined outside 'extern "C"' to be accepted by the compiler. +*/ + +#undef rte_bit_test +#undef rte_bit_set +#undef rte_bit_clear +#undef rte_bit_assign +#undef rte_bit_flip + +#define __RTE_BIT_OVERLOAD_SZ_2 (fun, qualifier, size, arg1_type, arg1_name) \ + static inline void \ + rte_bit_ ## fun(qualifier uint ## size ## _t *addr, \ + arg1_type arg1_name) \ + { \ + __rte_bit_ ## fun ## size(addr, arg1_name); \ + } + +#define __RTE_BIT_OVERLOAD_2 (fun, qualifier, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2(fun, qualifier, 32, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2(fun, qualifier, 64, arg1_type, arg1_name) + +#define __RTE_BIT_OVERLOAD_SZ_2R (fun, qualifier, size, ret_type, arg1_type, \ + arg1_name) \ + static inline ret_type \ + rte_bit_ ## fun(qualifier uint ## size ## _t *addr, \ + arg1_type arg1_name) \ + { \ + return __rte_bit_ ## fun ## size(addr, arg1_name); \ + } + +#define __RTE_BIT_OVERLOAD_2R (fun, qualifier, ret_type, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2R(fun, qualifier, 32, ret_type, arg1_type, \ + arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2R(fun, qualifier, 64, ret_type, arg1_type, \ + arg1_name) + +#define __RTE_BIT_OVERLOAD_SZ_3 (fun, qualifier, size, arg1_type, arg1_name, \ + arg2_type, arg2_name) \ + static inline void \ + rte_bit_ ## fun(uint ## size ## _t *addr, arg1_type arg1_name, \ + arg2_type arg2_name) \ + { \ + __rte_bit_ ## fun ## size(addr, arg1_name, arg2_name); \ + } + +#define __RTE_BIT_OVERLOAD_3 (fun, qualifier, arg1_type, arg1_name, arg2_type, \ + arg2_name) \ + __RTE_BIT_OVERLOAD_SZ_3(fun, qualifier, 32, arg1_type, arg1_name, \ + arg2_type, arg2_name) \ + __RTE_BIT_OVERLOAD_SZ_3(fun, qualifier, 64, arg1_type, arg1_name, \ + arg2_type, arg2_name) + +__RTE_BIT_OVERLOAD_2R(test, const, bool, unsigned int, nr) +__RTE_BIT_OVERLOAD_2(set,, unsigned int, nr) +__RTE_BIT_OVERLOAD_2(clear,, unsigned int, nr) +__RTE_BIT_OVERLOAD_3(assign,, unsigned int, nr, bool, value) +__RTE_BIT_OVERLOAD_2(flip,, unsigned int, nr) +#endif #endif /* _RTE_BITOPS_H_ */
Signature · 1 line
2.34.1
PATCH v11 4/7 eal: add unit tests for bit operations
In reply to Mattias RönnblomExtend bitops tests to cover the
rte_bit_[test|set|clear|assign|flip]()
functions.
The tests are converted to use the test suite runner framework.
--
RFC v6:
* Test rte_bit_*test() usage through const pointers.
RFC v4:
* Remove redundant line continuations.
--- app/test/test_bitops.c | 85 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 15 deletions(-)
app/test/test_bitops.c +70 -15
@@ -1,13 +1,68 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2019 Arm Limited +* Copyright(c) 2024 Ericsson AB */ +#include <stdbool.h> +#include <rte_launch.h> #include <rte_bitops.h> +#include <rte_random.h> #include "test.h" -uint32_t val32; -uint64_t val64; +#define GEN_TEST_BIT_ACCESS (test_name, set_fun, clear_fun, assign_fun, \ + flip_fun, test_fun, size) \ + static int \ + test_name(void) \ + { \ + uint ## size ## _t reference = (uint ## size ## _t)rte_rand(); \ + unsigned int bit_nr; \ + uint ## size ## _t word = (uint ## size ## _t)rte_rand(); \ + \ + for (bit_nr = 0; bit_nr < size; bit_nr++) { \ + bool reference_bit = (reference >> bit_nr) & 1; \ + bool assign = rte_rand() & 1; \ + if (assign) \ + assign_fun(&word, bit_nr, reference_bit); \ + else { \ + if (reference_bit) \ + set_fun(&word, bit_nr); \ + else \ + clear_fun(&word, bit_nr); \ + \ + } \ + TEST_ASSERT(test_fun(&word, bit_nr) == reference_bit, \ + "Bit %d had unexpected value", bit_nr); \ + flip_fun(&word, bit_nr); \ + TEST_ASSERT(test_fun(&word, bit_nr) != reference_bit, \ + "Bit %d had unflipped value", bit_nr); \ + flip_fun(&word, bit_nr); \ + \ + const uint ## size ## _t *const_ptr = &word; \ + TEST_ASSERT(test_fun(const_ptr, bit_nr) == \ + reference_bit, \ + "Bit %d had unexpected value", bit_nr); \ + } \ + \ + for (bit_nr = 0; bit_nr < size; bit_nr++) { \ + bool reference_bit = (reference >> bit_nr) & 1; \ + TEST_ASSERT(test_fun(&word, bit_nr) == reference_bit, \ + "Bit %d had unexpected value", bit_nr); \ + } \ + \ + TEST_ASSERT(reference == word, "Word had unexpected value"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_ACCESS (test_bit_access32, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 32) + +GEN_TEST_BIT_ACCESS (test_bit_access64, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 64) + +static uint32_t val32; +static uint64_t val64;#define MAX_BITS_32 32#define MAX_BITS_64 64
@@ -117,22 +172,22 @@ test_bit_relaxed_test_set_clear(void)return TEST_SUCCESS ; } +static struct unit_test_suite test_suite = { + .suite_name ="Bitops test suite" , + .unit_test_cases = { +TEST_CASE (test_bit_access32), +TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_relaxed_set), +TEST_CASE (test_bit_relaxed_clear), +TEST_CASE (test_bit_relaxed_test_set_clear), +TEST_CASES_END () + } +}; +static int test_bitops (void ) { - val32 =0 ; - val64 =0 ; - -if (test_bit_relaxed_set () <0 ) -return TEST_FAILED ; - -if (test_bit_relaxed_clear () <0 ) -return TEST_FAILED ; - -if (test_bit_relaxed_test_set_clear () <0 ) -return TEST_FAILED ; - -return TEST_SUCCESS ; +return unit_test_suite_runner (&test_suite); }REGISTER_FAST_TEST (bitops_autotest, true, true, test_bitops);
Signature · 1 line
2.34.1
PATCH v11 5/7 eal: add atomic bit operations
In reply to Mattias RönnblomAdd atomic bit test/set/clear/assign/flip and
test-and-set/clear/assign/flip functions.
All atomic bit functions allow (and indeed, require) the caller to specify a memory order.
--
PATCH v3:
* Introduce __RTE_GEN_BIT_ATOMIC_*() 'qualifier' argument already in this patch (Jack Bond-Preston).
* Refer to volatile bit op functions as variants instead of families (macro parameter naming).
* Update release notes.
PATCH:
* Add missing macro #undef for C++ version of atomic bit flip.
RFC v7:
* Replace compare-exchange-based rte_bitset_atomic_test_and_*() and flip() with implementations that use the previous value as returned by the atomic fetch function.
* Reword documentation to match the non-atomic macro variants.
* Remove pointer to <rte_stdatomic.h> for memory model documentation, since there is no documentation for that API.
RFC v6:
* Have rte_bit_atomic_test() accept const-marked bitsets.
RFC v4:
* Add atomic bit flip.
* Mark macro-generated private functions experimental.
RFC v3:
* Work around lack of C++ support for _Generic (Tyler Retzlaff).
RFC v2:
o Add rte_bit_atomic_test_and_assign() (for consistency).
o Fix bugs in rte_bit_atomic_test_and_[set|clear]().
o Use <rte_stdatomics.h> to support MSVC.
--- doc/guides/rel_notes/release_24_11.rst | 17 + lib/eal/include/rte_bitops.h | 415 +++++++++++++++++++++++++ 2 files changed, 432 insertions(+)
doc/guides/rel_notes/release_24_11.rst +17 -0
@@ -56,6 +56,23 @@ New Features ======================================================= +* **Extended bit operations API.** + + The support for bit-level operations on single 32- and 64-bit words + in <rte_bitops.h> has been extended with two families of + semantically well-defined functions. + + rte_bit_[test|set|clear|assign|flip]() functions provide excellent + performance (by avoiding restricting the compiler and CPU), but give + no guarantees in regards to memory ordering or atomicity. + + rte_bit_atomic_*() provides atomic bit-level operations, including + the possibility to specifying memory ordering constraints. + + The new public API elements are polymorphic, using the _Generic- + based macros (for C) and function overloading (in C++ translation + units). + Removed Items -------------
lib/eal/include/rte_bitops.h +415 -0
451 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v11 6/7 eal: add unit tests for atomic bit access functions
In reply to Mattias RönnblomExtend bitops tests to cover the rte_bit_atomic_*() family of functions.
--
RFC v4:
* Add atomicity test for atomic bit flip.
RFC v3:
* Rename variable 'main' to make ICC happy.
--- app/test/test_bitops.c | 313 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 312 insertions(+), 1 deletion(-)
app/test/test_bitops.c +312 -1
@@ -3,10 +3,13 @@* Copyright(c) 2024 Ericsson AB */ +#include <inttypes.h> #include <stdbool.h> -#include <rte_launch.h> #include <rte_bitops.h> +#include <rte_cycles.h> +#include <rte_launch.h> +#include <rte_lcore.h> #include <rte_random.h> #include "test.h"
@@ -61,6 +64,304 @@ GEN_TEST_BIT_ACCESS(test_bit_access32, rte_bit_set, rte_bit_clear,GEN_TEST_BIT_ACCESS (test_bit_access64, rte_bit_set, rte_bit_clear, rte_bit_assign, rte_bit_flip, rte_bit_test, 64) +#define bit_atomic_set (addr, nr) \ + rte_bit_atomic_set(addr, nr, rte_memory_order_relaxed) + +#define bit_atomic_clear (addr, nr) \ + rte_bit_atomic_clear(addr, nr, rte_memory_order_relaxed) + +#define bit_atomic_assign (addr, nr, value) \ + rte_bit_atomic_assign(addr, nr, value, rte_memory_order_relaxed) + +#define bit_atomic_flip (addr, nr) \ + rte_bit_atomic_flip(addr, nr, rte_memory_order_relaxed) + +#define bit_atomic_test (addr, nr) \ + rte_bit_atomic_test(addr, nr, rte_memory_order_relaxed) + +GEN_TEST_BIT_ACCESS (test_bit_atomic_access32, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 32) + +GEN_TEST_BIT_ACCESS (test_bit_atomic_access64, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 64) + +#define PARALLEL_TEST_RUNTIME 0.25 + +#define GEN_TEST_BIT_PARALLEL_ASSIGN (size) \ + \ + struct parallel_access_lcore ## size \ + { \ + unsigned int bit; \ + uint ## size ##_t *word; \ + bool failed; \ + }; \ + \ + static int \ + run_parallel_assign ## size(void *arg) \ + { \ + struct parallel_access_lcore ## size *lcore = arg; \ + uint64_t deadline = rte_get_timer_cycles() + \ + PARALLEL_TEST_RUNTIME * rte_get_timer_hz(); \ + bool value = false; \ + \ + do { \ + bool new_value = rte_rand() & 1; \ + bool use_test_and_modify = rte_rand() & 1; \ + bool use_assign = rte_rand() & 1; \ + \ + if (rte_bit_atomic_test(lcore->word, lcore->bit, \ + rte_memory_order_relaxed) != value) { \ + lcore->failed = true; \ + break; \ + } \ + \ + if (use_test_and_modify) { \ + bool old_value; \ + if (use_assign) \ + old_value = rte_bit_atomic_test_and_assign( \ + lcore->word, lcore->bit, new_value, \ + rte_memory_order_relaxed); \ + else { \ + old_value = new_value ? \ + rte_bit_atomic_test_and_set( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed) : \ + rte_bit_atomic_test_and_clear( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + } \ + if (old_value != value) { \ + lcore->failed = true; \ + break; \ + } \ + } else { \ + if (use_assign) \ + rte_bit_atomic_assign(lcore->word, lcore->bit, \ + new_value, \ + rte_memory_order_relaxed); \ + else { \ + if (new_value) \ + rte_bit_atomic_set( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + else \ + rte_bit_atomic_clear( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + } \ + } \ + \ + value = new_value; \ + } while (rte_get_timer_cycles() < deadline); \ + \ + return 0; \ + } \ + \ + static int \ + test_bit_atomic_parallel_assign ## size(void) \ + { \ + unsigned int worker_lcore_id; \ + uint ## size ## _t word = 0; \ + struct parallel_access_lcore ## size lmain = { \ + .word = &word \ + }; \ + struct parallel_access_lcore ## size lworker = { \ + .word = &word \ + }; \ + \ + if (rte_lcore_count() < 2) { \ + printf("Need multiple cores to run parallel test.\n"); \ + return TEST_SKIPPED; \ + } \ + \ + worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + \ + lmain.bit = rte_rand_max(size); \ + do { \ + lworker.bit = rte_rand_max(size); \ + } while (lworker.bit == lmain.bit); \ + \ + int rc = rte_eal_remote_launch(run_parallel_assign ## size, \ + &lworker, worker_lcore_id); \ + TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ + \ + run_parallel_assign ## size(&lmain); \ + \ + rte_eal_mp_wait_lcore(); \ + \ + TEST_ASSERT(!lmain.failed, "Main lcore atomic access failed"); \ + TEST_ASSERT(!lworker.failed, "Worker lcore atomic access " \ + "failed"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_PARALLEL_ASSIGN(32) +GEN_TEST_BIT_PARALLEL_ASSIGN(64) + +#define GEN_TEST_BIT_PARALLEL_TEST_AND_MODIFY (size) \ + \ + struct parallel_test_and_set_lcore ## size \ + { \ + uint ## size ##_t *word; \ + unsigned int bit; \ + uint64_t flips; \ + }; \ + \ + static int \ + run_parallel_test_and_modify ## size(void *arg) \ + { \ + struct parallel_test_and_set_lcore ## size *lcore = arg; \ + uint64_t deadline = rte_get_timer_cycles() + \ + PARALLEL_TEST_RUNTIME * rte_get_timer_hz(); \ + do { \ + bool old_value; \ + bool new_value = rte_rand() & 1; \ + bool use_assign = rte_rand() & 1; \ + \ + if (use_assign) \ + old_value = rte_bit_atomic_test_and_assign( \ + lcore->word, lcore->bit, new_value, \ + rte_memory_order_relaxed); \ + else \ + old_value = new_value ? \ + rte_bit_atomic_test_and_set( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed) : \ + rte_bit_atomic_test_and_clear( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + if (old_value != new_value) \ + lcore->flips++; \ + } while (rte_get_timer_cycles() < deadline); \ + \ + return 0; \ + } \ + \ + static int \ + test_bit_atomic_parallel_test_and_modify ## size(void) \ + { \ + unsigned int worker_lcore_id; \ + uint ## size ## _t word = 0; \ + unsigned int bit = rte_rand_max(size); \ + struct parallel_test_and_set_lcore ## size lmain = { \ + .word = &word, \ + .bit = bit \ + }; \ + struct parallel_test_and_set_lcore ## size lworker = { \ + .word = &word, \ + .bit = bit \ + }; \ + \ + if (rte_lcore_count() < 2) { \ + printf("Need multiple cores to run parallel test.\n"); \ + return TEST_SKIPPED; \ + } \ + \ + worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + \ + int rc = rte_eal_remote_launch(run_parallel_test_and_modify ## size, \ + &lworker, worker_lcore_id); \ + TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ + \ + run_parallel_test_and_modify ## size(&lmain); \ + \ + rte_eal_mp_wait_lcore(); \ + \ + uint64_t total_flips = lmain.flips + lworker.flips; \ + bool expected_value = total_flips % 2; \ + \ + TEST_ASSERT(expected_value == rte_bit_test(&word, bit), \ + "After %"PRId64" flips, the bit value " \ + "should be %d", total_flips, expected_value); \ + \ + uint64_t expected_word = 0; \ + rte_bit_assign(&expected_word, bit, expected_value); \ + \ + TEST_ASSERT(expected_word == word, "Untouched bits have " \ + "changed value"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_PARALLEL_TEST_AND_MODIFY(32) +GEN_TEST_BIT_PARALLEL_TEST_AND_MODIFY(64) + +#define GEN_TEST_BIT_PARALLEL_FLIP (size) \ + \ + struct parallel_flip_lcore ## size \ + { \ + uint ## size ##_t *word; \ + unsigned int bit; \ + uint64_t flips; \ + }; \ + \ + static int \ + run_parallel_flip ## size(void *arg) \ + { \ + struct parallel_flip_lcore ## size *lcore = arg; \ + uint64_t deadline = rte_get_timer_cycles() + \ + PARALLEL_TEST_RUNTIME * rte_get_timer_hz(); \ + do { \ + rte_bit_atomic_flip(lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + lcore->flips++; \ + } while (rte_get_timer_cycles() < deadline); \ + \ + return 0; \ + } \ + \ + static int \ + test_bit_atomic_parallel_flip ## size(void) \ + { \ + unsigned int worker_lcore_id; \ + uint ## size ## _t word = 0; \ + unsigned int bit = rte_rand_max(size); \ + struct parallel_flip_lcore ## size lmain = { \ + .word = &word, \ + .bit = bit \ + }; \ + struct parallel_flip_lcore ## size lworker = { \ + .word = &word, \ + .bit = bit \ + }; \ + \ + if (rte_lcore_count() < 2) { \ + printf("Need multiple cores to run parallel test.\n"); \ + return TEST_SKIPPED; \ + } \ + \ + worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + \ + int rc = rte_eal_remote_launch(run_parallel_flip ## size, \ + &lworker, worker_lcore_id); \ + TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ + \ + run_parallel_flip ## size(&lmain); \ + \ + rte_eal_mp_wait_lcore(); \ + \ + uint64_t total_flips = lmain.flips + lworker.flips; \ + bool expected_value = total_flips % 2; \ + \ + TEST_ASSERT(expected_value == rte_bit_test(&word, bit), \ + "After %"PRId64" flips, the bit value " \ + "should be %d", total_flips, expected_value); \ + \ + uint64_t expected_word = 0; \ + rte_bit_assign(&expected_word, bit, expected_value); \ + \ + TEST_ASSERT(expected_word == word, "Untouched bits have " \ + "changed value"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_PARALLEL_FLIP(32) +GEN_TEST_BIT_PARALLEL_FLIP(64) +static uint32_t val32;static uint64_t val64;
@@ -177,6 +478,16 @@ static struct unit_test_suite test_suite = { .unit_test_cases = {TEST_CASE (test_bit_access32),TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_access32), +TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_atomic_access32), +TEST_CASE (test_bit_atomic_access64), +TEST_CASE (test_bit_atomic_parallel_assign32), +TEST_CASE (test_bit_atomic_parallel_assign64), +TEST_CASE (test_bit_atomic_parallel_test_and_modify32), +TEST_CASE (test_bit_atomic_parallel_test_and_modify64), +TEST_CASE (test_bit_atomic_parallel_flip32), +TEST_CASE (test_bit_atomic_parallel_flip64),TEST_CASE (test_bit_relaxed_set),TEST_CASE (test_bit_relaxed_clear), TEST_CASE(test_bit_relaxed_test_set_clear),
Signature · 1 line
2.34.1
PATCH v11 7/7 eal: extend bitops to handle volatile pointers
In reply to Mattias RönnblomHave rte_bit_[test|set|clear|assign|flip]() and rte_bit_atomic_*() handle volatile-marked pointers.
--
PATCH v3:
* Updated to reflect removed 'fun' parameter in __RTE_GEN_BIT_*() (Jack Bond-Preston).
PATCH v2:
* Actually run the test_bit_atomic_v_access*() test functions.
--- app/test/test_bitops.c | 32 +++- lib/eal/include/rte_bitops.h | 301 +++++++++++++++++++++++------------ 2 files changed, 222 insertions(+), 111 deletions(-)
app/test/test_bitops.c +25 -7
@@ -14,13 +14,13 @@#include "test.h" #define GEN_TEST_BIT_ACCESS (test_name, set_fun, clear_fun, assign_fun, \ - flip_fun, test_fun, size) \ + flip_fun, test_fun, size, mod) \ static int \ test_name(void) \ { \ uint ## size ## _t reference = (uint ## size ## _t)rte_rand(); \ unsigned int bit_nr; \ - uint ## size ## _t word = (uint ## size ## _t)rte_rand(); \ + mod uint ## size ## _t word = (uint ## size ## _t)rte_rand(); \ \ for (bit_nr = 0; bit_nr < size; bit_nr++) { \ bool reference_bit = (reference >> bit_nr) & 1; \
@@ -41,7 +41,7 @@ "Bit %d had unflipped value", bit_nr); \flip_fun (&word, bit_nr); \ \ - const uint ## size ## _t *const_ptr = &word; \ + const mod uint ## size ## _t *const_ptr = &word; \ TEST_ASSERT(test_fun(const_ptr, bit_nr) == \ reference_bit, \ "Bit %d had unexpected value", bit_nr); \
@@ -59,10 +59,16 @@ } GEN_TEST_BIT_ACCESS(test_bit_access32, rte_bit_set, rte_bit_clear, - rte_bit_assign, rte_bit_flip, rte_bit_test, 32) + rte_bit_assign, rte_bit_flip, rte_bit_test, 32,) GEN_TEST_BIT_ACCESS(test_bit_access64, rte_bit_set, rte_bit_clear, - rte_bit_assign, rte_bit_flip, rte_bit_test, 64) + rte_bit_assign, rte_bit_flip, rte_bit_test, 64,) + +GEN_TEST_BIT_ACCESS(test_bit_v_access32, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 32, volatile) + +GEN_TEST_BIT_ACCESS(test_bit_v_access64, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 64, volatile) #define bit_atomic_set(addr, nr) \ rte_bit_atomic_set(addr, nr, rte_memory_order_relaxed)
@@ -81,11 +87,19 @@ GEN_TEST_BIT_ACCESS(test_bit_access64, rte_bit_set, rte_bit_clear, GEN_TEST_BIT_ACCESS(test_bit_atomic_access32, bit_atomic_set, bit_atomic_clear, bit_atomic_assign, - bit_atomic_flip, bit_atomic_test, 32) + bit_atomic_flip, bit_atomic_test, 32,) GEN_TEST_BIT_ACCESS(test_bit_atomic_access64, bit_atomic_set, bit_atomic_clear, bit_atomic_assign, - bit_atomic_flip, bit_atomic_test, 64) + bit_atomic_flip, bit_atomic_test, 64,) + +GEN_TEST_BIT_ACCESS(test_bit_atomic_v_access32, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 32, volatile) + +GEN_TEST_BIT_ACCESS(test_bit_atomic_v_access64, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 64, volatile) #define PARALLEL_TEST_RUNTIME 0.25
@@ -480,8 +494,12 @@ static struct unit_test_suite test_suite = {TEST_CASE (test_bit_access64),TEST_CASE (test_bit_access32),TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_v_access32), +TEST_CASE (test_bit_v_access64),TEST_CASE (test_bit_atomic_access32),TEST_CASE (test_bit_atomic_access64), +TEST_CASE (test_bit_atomic_v_access32), +TEST_CASE (test_bit_atomic_v_access64),TEST_CASE (test_bit_atomic_parallel_assign32),TEST_CASE (test_bit_atomic_parallel_assign64), TEST_CASE(test_bit_atomic_parallel_test_and_modify32),
lib/eal/include/rte_bitops.h +197 -104
440 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v10 2/7 dpdk: use C linkage only where appropriate
In reply to Mattias RönnblomAssure that 'extern "C" { /../ }' do not cover files included from a particular header file, and address minor issues resulting from this change of order.
Dealing with C++ should delegate to the individual include file level, rather than being imposed by the user of that file. For example, forcing C linkage prevents __Generic macros being replaced with overloaded static inline functions in C++ translation units.
Eliminate 'extern "C"' from files which do not declare any symbols (e.g., only macros or struct types). With this change, the chkextern.py tool fails the build in case it detect such redundancy.
--
PATCH v10:
* Enable redundant C linkage checks in chkincs, and fix headers which had such.
* Fix more ARM build issues.
PATCH v9:
* Fix yet another issue in the ARM build. Author really needs an ARM system powerful enough to build DPDK.
PATCH v8:
* Fix issues in rte_memcpy_64.h causing build failures on ARM.
PATCH v7:
* Fix issues in rte_io.h, rte_pause.h and rte_thash_gfni.h causing build failures on ARM. (David Marchand)
* Fix issue in rte_vfio.h, causing build failures unless VFIO_PRESENT.
PATCH v6:
* Add missing extern "C" in rte_atomic.h, rte_cpuflags.h, rte_io.h, rte_vect.h.
* Fix 32-bit x86 build issues in rte_atomic.h.
PATCH v5:
* rte_dmadev.h was still including files under extern "C" { /../ }. (Chengwen Feng)
* Fix rte_byteorder.h, broken on 32-bit x86.
--- app/test/packet_burst_generator.h | 8 +++--- app/test/virtual_pmd.h | 4 +-- buildtools/chkincs/meson.build | 7 ++++++ drivers/bus/auxiliary/bus_auxiliary_driver.h | 8 +++--- drivers/bus/cdx/bus_cdx_driver.h | 8 +++--- drivers/bus/dpaa/include/fsl_qman.h | 8 +++--- drivers/bus/fslmc/bus_fslmc_driver.h | 8 +++--- drivers/bus/pci/bus_pci_driver.h | 8 +++--- drivers/bus/pci/rte_bus_pci.h | 8 +++--- drivers/bus/platform/bus_platform_driver.h | 8 +++--- drivers/bus/vdev/bus_vdev_driver.h | 8 +++--- drivers/bus/vmbus/bus_vmbus_driver.h | 8 +++--- drivers/bus/vmbus/rte_bus_vmbus.h | 8 +++--- drivers/dma/cnxk/cnxk_dma_event_dp.h | 8 +++--- drivers/dma/ioat/ioat_hw_defs.h | 4 +-- drivers/event/dlb2/rte_pmd_dlb2.h | 8 +++--- drivers/mempool/dpaa2/rte_dpaa2_mempool.h | 6 ++--- drivers/net/avp/rte_avp_fifo.h | 8 +++--- drivers/net/bonding/rte_eth_bond.h | 4 +-- drivers/net/i40e/rte_pmd_i40e.h | 8 +++--- drivers/net/mlx5/mlx5_trace.h | 8 +++--- drivers/net/ring/rte_eth_ring.h | 4 +-- drivers/net/vhost/rte_eth_vhost.h | 8 +++--- drivers/raw/ifpga/afu_pmd_core.h | 8 +++--- drivers/raw/ifpga/afu_pmd_he_hssi.h | 6 ++--- drivers/raw/ifpga/afu_pmd_he_lpbk.h | 6 ++--- drivers/raw/ifpga/afu_pmd_he_mem.h | 6 ++--- drivers/raw/ifpga/afu_pmd_n3000.h | 6 ++--- drivers/raw/ifpga/rte_pmd_afu.h | 4 +-- drivers/raw/ifpga/rte_pmd_ifpga.h | 4 +-- examples/ethtool/lib/rte_ethtool.h | 8 +++--- examples/qos_sched/main.h | 4 +-- examples/vm_power_manager/channel_manager.h | 8 +++--- lib/acl/rte_acl_osdep.h | 8 ------ lib/bbdev/rte_bbdev.h | 8 +++--- lib/bbdev/rte_bbdev_op.h | 8 +++--- lib/bbdev/rte_bbdev_pmd.h | 8 +++--- lib/bpf/bpf_def.h | 9 ------- lib/compressdev/rte_comp.h | 4 +-- lib/compressdev/rte_compressdev.h | 6 ++--- lib/compressdev/rte_compressdev_internal.h | 8 +++--- lib/compressdev/rte_compressdev_pmd.h | 8 +++--- lib/cryptodev/cryptodev_pmd.h | 8 +++--- lib/cryptodev/cryptodev_trace.h | 8 +++--- lib/cryptodev/rte_crypto.h | 8 +++--- lib/cryptodev/rte_crypto_asym.h | 8 ------ lib/cryptodev/rte_crypto_sym.h | 8 +++--- lib/cryptodev/rte_cryptodev.h | 8 +++--- lib/cryptodev/rte_cryptodev_trace_fp.h | 4 +-- lib/dispatcher/rte_dispatcher.h | 8 +++--- lib/dmadev/rte_dmadev.h | 8 ++++++ lib/eal/arm/include/rte_atomic_32.h | 4 +-- lib/eal/arm/include/rte_atomic_64.h | 8 +++--- lib/eal/arm/include/rte_byteorder.h | 8 +++--- lib/eal/arm/include/rte_cpuflags_32.h | 8 ------ lib/eal/arm/include/rte_cpuflags_64.h | 8 ------ lib/eal/arm/include/rte_cycles_32.h | 4 +-- lib/eal/arm/include/rte_cycles_64.h | 4 +-- lib/eal/arm/include/rte_io.h | 8 ------ lib/eal/arm/include/rte_io_64.h | 8 +++--- lib/eal/arm/include/rte_memcpy_32.h | 8 +++--- lib/eal/arm/include/rte_memcpy_64.h | 23 +++++++++++------ lib/eal/arm/include/rte_pause.h | 8 ------ lib/eal/arm/include/rte_pause_32.h | 6 ++--- lib/eal/arm/include/rte_pause_64.h | 8 +++--- lib/eal/arm/include/rte_power_intrinsics.h | 8 ------ lib/eal/arm/include/rte_prefetch_32.h | 8 +++--- lib/eal/arm/include/rte_prefetch_64.h | 8 +++--- lib/eal/arm/include/rte_rwlock.h | 4 +-- lib/eal/arm/include/rte_spinlock.h | 6 ++--- lib/eal/freebsd/include/rte_os.h | 8 ------ lib/eal/include/bus_driver.h | 8 +++--- lib/eal/include/dev_driver.h | 8 ------ lib/eal/include/eal_trace_internal.h | 8 +++--- lib/eal/include/generic/rte_atomic.h | 8 ++++++ lib/eal/include/generic/rte_byteorder.h | 8 ++++++ lib/eal/include/generic/rte_cpuflags.h | 8 ++++++ lib/eal/include/generic/rte_cycles.h | 8 ++++++ lib/eal/include/generic/rte_io.h | 8 ++++++ lib/eal/include/generic/rte_memcpy.h | 8 ++++++ lib/eal/include/generic/rte_pause.h | 8 ++++++ .../include/generic/rte_power_intrinsics.h | 8 ++++++ lib/eal/include/generic/rte_prefetch.h | 8 ++++++ lib/eal/include/generic/rte_rwlock.h | 8 +++--- lib/eal/include/generic/rte_spinlock.h | 8 ++++++ lib/eal/include/generic/rte_vect.h | 8 ++++++ lib/eal/include/rte_alarm.h | 4 +-- lib/eal/include/rte_bitmap.h | 8 +++--- lib/eal/include/rte_branch_prediction.h | 8 ------ lib/eal/include/rte_bus.h | 8 +++--- lib/eal/include/rte_class.h | 4 +-- lib/eal/include/rte_common.h | 8 +++--- lib/eal/include/rte_compat.h | 8 ------ lib/eal/include/rte_dev.h | 8 +++--- lib/eal/include/rte_devargs.h | 8 +++--- lib/eal/include/rte_eal_trace.h | 4 +-- lib/eal/include/rte_errno.h | 4 +-- lib/eal/include/rte_fbarray.h | 8 +++--- lib/eal/include/rte_keepalive.h | 6 ++--- lib/eal/include/rte_mcslock.h | 8 +++--- lib/eal/include/rte_memory.h | 8 +++--- lib/eal/include/rte_pci_dev_feature_defs.h | 8 ------ lib/eal/include/rte_pci_dev_features.h | 8 ------ lib/eal/include/rte_per_lcore.h | 8 ------ lib/eal/include/rte_pflock.h | 8 +++--- lib/eal/include/rte_random.h | 4 +-- lib/eal/include/rte_seqcount.h | 8 +++--- lib/eal/include/rte_seqlock.h | 8 +++--- lib/eal/include/rte_service.h | 8 +++--- lib/eal/include/rte_service_component.h | 4 +-- lib/eal/include/rte_stdatomic.h | 5 +--- lib/eal/include/rte_string_fns.h | 17 +++++++++---- lib/eal/include/rte_tailq.h | 6 ++--- lib/eal/include/rte_ticketlock.h | 8 +++--- lib/eal/include/rte_time.h | 6 ++--- lib/eal/include/rte_trace.h | 8 +++--- lib/eal/include/rte_trace_point.h | 8 +++--- lib/eal/include/rte_trace_point_register.h | 8 +++--- lib/eal/include/rte_uuid.h | 8 +++--- lib/eal/include/rte_version.h | 6 ++--- lib/eal/include/rte_vfio.h | 8 +++--- lib/eal/linux/include/rte_os.h | 8 ------ lib/eal/loongarch/include/rte_atomic.h | 6 ++--- lib/eal/loongarch/include/rte_byteorder.h | 4 +-- lib/eal/loongarch/include/rte_cpuflags.h | 8 ------ lib/eal/loongarch/include/rte_cycles.h | 4 +-- lib/eal/loongarch/include/rte_io.h | 8 ------ lib/eal/loongarch/include/rte_memcpy.h | 4 +-- lib/eal/loongarch/include/rte_pause.h | 8 +++--- .../loongarch/include/rte_power_intrinsics.h | 8 ------ lib/eal/loongarch/include/rte_prefetch.h | 8 +++--- lib/eal/loongarch/include/rte_rwlock.h | 4 +-- lib/eal/loongarch/include/rte_spinlock.h | 6 ++--- lib/eal/ppc/include/rte_atomic.h | 6 ++--- lib/eal/ppc/include/rte_byteorder.h | 6 ++--- lib/eal/ppc/include/rte_cpuflags.h | 8 ------ lib/eal/ppc/include/rte_cycles.h | 8 +++--- lib/eal/ppc/include/rte_io.h | 8 ------ lib/eal/ppc/include/rte_memcpy.h | 4 +-- lib/eal/ppc/include/rte_pause.h | 8 +++--- lib/eal/ppc/include/rte_power_intrinsics.h | 8 ------ lib/eal/ppc/include/rte_prefetch.h | 8 +++--- lib/eal/ppc/include/rte_rwlock.h | 4 +-- lib/eal/ppc/include/rte_spinlock.h | 8 +++--- lib/eal/riscv/include/rte_atomic.h | 8 +++--- lib/eal/riscv/include/rte_byteorder.h | 8 +++--- lib/eal/riscv/include/rte_cpuflags.h | 8 ------ lib/eal/riscv/include/rte_cycles.h | 4 +-- lib/eal/riscv/include/rte_io.h | 8 ------ lib/eal/riscv/include/rte_memcpy.h | 4 +-- lib/eal/riscv/include/rte_pause.h | 8 +++--- lib/eal/riscv/include/rte_power_intrinsics.h | 8 ------ lib/eal/riscv/include/rte_prefetch.h | 8 +++--- lib/eal/riscv/include/rte_rwlock.h | 4 +-- lib/eal/riscv/include/rte_spinlock.h | 6 ++--- lib/eal/windows/include/pthread.h | 6 ++--- lib/eal/windows/include/regex.h | 8 +++--- lib/eal/windows/include/rte_os.h | 8 ------ lib/eal/windows/include/rte_windows.h | 8 ------ lib/eal/x86/include/rte_atomic.h | 25 +++++++++++++------ lib/eal/x86/include/rte_byteorder.h | 16 ++++++------ lib/eal/x86/include/rte_cpuflags.h | 8 ------ lib/eal/x86/include/rte_cycles.h | 8 +++--- lib/eal/x86/include/rte_io.h | 8 +++--- lib/eal/x86/include/rte_pause.h | 7 +++--- lib/eal/x86/include/rte_power_intrinsics.h | 8 ------ lib/eal/x86/include/rte_prefetch.h | 8 +++--- lib/eal/x86/include/rte_rwlock.h | 6 ++--- lib/eal/x86/include/rte_spinlock.h | 9 +++---- lib/ethdev/ethdev_driver.h | 8 +++--- lib/ethdev/ethdev_pci.h | 8 +++--- lib/ethdev/ethdev_trace.h | 8 +++--- lib/ethdev/ethdev_vdev.h | 8 +++--- lib/ethdev/rte_cman.h | 8 ------ lib/ethdev/rte_dev_info.h | 8 ------ lib/ethdev/rte_eth_ctrl.h | 8 ------ lib/ethdev/rte_ethdev.h | 8 +++--- lib/ethdev/rte_ethdev_trace_fp.h | 4 +-- lib/eventdev/event_timer_adapter_pmd.h | 8 ------ lib/eventdev/eventdev_pmd.h | 8 +++--- lib/eventdev/eventdev_pmd_pci.h | 8 +++--- lib/eventdev/eventdev_pmd_vdev.h | 8 +++--- lib/eventdev/eventdev_trace.h | 8 +++--- lib/eventdev/rte_event_crypto_adapter.h | 8 +++--- lib/eventdev/rte_event_eth_rx_adapter.h | 8 +++--- lib/eventdev/rte_event_eth_tx_adapter.h | 8 +++--- lib/eventdev/rte_event_ring.h | 8 +++--- lib/eventdev/rte_event_timer_adapter.h | 8 +++--- lib/eventdev/rte_eventdev.h | 8 +++--- lib/eventdev/rte_eventdev_trace_fp.h | 4 +-- lib/graph/rte_graph_model_mcore_dispatch.h | 8 +++--- lib/graph/rte_graph_worker.h | 6 ++--- lib/gso/rte_gso.h | 6 ++--- lib/hash/rte_fbk_hash.h | 8 +++--- lib/hash/rte_hash_crc.h | 8 +++--- lib/hash/rte_jhash.h | 8 +++--- lib/hash/rte_thash.h | 8 +++--- lib/hash/rte_thash_gfni.h | 8 +++--- lib/ip_frag/rte_ip_frag.h | 8 +++--- lib/ipsec/rte_ipsec.h | 8 +++--- lib/log/rte_log.h | 8 +++--- lib/lpm/rte_lpm.h | 8 +++--- lib/member/rte_member.h | 8 +++--- lib/member/rte_member_sketch.h | 6 ++--- lib/member/rte_member_sketch_avx512.h | 8 +++--- lib/member/rte_member_x86.h | 4 +-- lib/member/rte_xxh64_avx512.h | 6 ++--- lib/mempool/mempool_trace.h | 8 +++--- lib/mempool/rte_mempool_trace_fp.h | 4 +-- lib/meter/rte_meter.h | 8 +++--- lib/mldev/mldev_utils.h | 8 +++--- lib/mldev/rte_mldev_core.h | 8 ------ lib/mldev/rte_mldev_pmd.h | 8 +++--- lib/net/rte_dtls.h | 8 ------ lib/net/rte_ecpri.h | 8 ------ lib/net/rte_esp.h | 8 ------ lib/net/rte_ether.h | 8 +++--- lib/net/rte_geneve.h | 8 ------ lib/net/rte_gre.h | 8 ------ lib/net/rte_gtp.h | 8 ------ lib/net/rte_higig.h | 8 ------ lib/net/rte_ib.h | 8 ------ lib/net/rte_icmp.h | 8 ------ lib/net/rte_l2tpv2.h | 8 ------ lib/net/rte_macsec.h | 8 ------ lib/net/rte_mpls.h | 8 ------ lib/net/rte_net.h | 8 +++--- lib/net/rte_pdcp_hdr.h | 8 ------ lib/net/rte_ppp.h | 8 ------ lib/net/rte_sctp.h | 8 ------ lib/net/rte_tcp.h | 8 ------ lib/net/rte_tls.h | 8 ------ lib/net/rte_udp.h | 8 ------ lib/net/rte_vxlan.h | 10 -------- lib/node/rte_node_eth_api.h | 8 +++--- lib/node/rte_node_ip4_api.h | 8 +++--- lib/node/rte_node_ip6_api.h | 6 ++--- lib/node/rte_node_udp4_input_api.h | 8 +++--- lib/pci/rte_pci.h | 8 +++--- lib/pdcp/rte_pdcp.h | 8 +++--- lib/pipeline/rte_pipeline.h | 8 +++--- lib/pipeline/rte_port_in_action.h | 8 +++--- lib/pipeline/rte_swx_ctl.h | 8 +++--- lib/pipeline/rte_swx_extern.h | 8 ------ lib/pipeline/rte_swx_ipsec.h | 8 +++--- lib/pipeline/rte_swx_pipeline.h | 8 +++--- lib/pipeline/rte_swx_pipeline_spec.h | 8 +++--- lib/pipeline/rte_table_action.h | 8 +++--- lib/port/rte_port.h | 8 ------ lib/port/rte_port_ethdev.h | 8 +++--- lib/port/rte_port_eventdev.h | 8 +++--- lib/port/rte_port_fd.h | 8 +++--- lib/port/rte_port_frag.h | 8 +++--- lib/port/rte_port_ras.h | 8 +++--- lib/port/rte_port_ring.h | 8 +++--- lib/port/rte_port_sched.h | 8 +++--- lib/port/rte_port_source_sink.h | 8 +++--- lib/port/rte_port_sym_crypto.h | 8 +++--- lib/port/rte_swx_port.h | 8 ------ lib/port/rte_swx_port_ethdev.h | 8 +++--- lib/port/rte_swx_port_fd.h | 8 +++--- lib/port/rte_swx_port_ring.h | 8 +++--- lib/port/rte_swx_port_source_sink.h | 8 +++--- lib/rawdev/rte_rawdev.h | 6 ++--- lib/rawdev/rte_rawdev_pmd.h | 8 +++--- lib/rcu/rte_rcu_qsbr.h | 8 +++--- lib/regexdev/rte_regexdev.h | 8 +++--- lib/ring/rte_ring.h | 6 ++--- lib/ring/rte_ring_core.h | 8 ------ lib/ring/rte_ring_elem.h | 8 +++--- lib/ring/rte_ring_hts.h | 4 +-- lib/ring/rte_ring_peek.h | 4 +-- lib/ring/rte_ring_peek_zc.h | 4 +-- lib/ring/rte_ring_rts.h | 4 +-- lib/sched/rte_approx.h | 8 +++--- lib/sched/rte_pie.h | 8 +++--- lib/sched/rte_red.h | 8 +++--- lib/sched/rte_sched.h | 8 +++--- lib/sched/rte_sched_common.h | 6 ++--- lib/security/rte_security.h | 8 +++--- lib/security/rte_security_driver.h | 6 ++--- lib/stack/rte_stack.h | 8 +++--- lib/table/rte_lru.h | 8 ------ lib/table/rte_lru_arm64.h | 8 +++--- lib/table/rte_lru_x86.h | 8 ------ lib/table/rte_swx_hash_func.h | 8 ------ lib/table/rte_swx_keycmp.h | 8 +++--- lib/table/rte_swx_table.h | 8 ------ lib/table/rte_swx_table_em.h | 8 +++--- lib/table/rte_swx_table_learner.h | 8 +++--- lib/table/rte_swx_table_selector.h | 8 +++--- lib/table/rte_swx_table_wm.h | 8 +++--- lib/table/rte_table.h | 8 ------ lib/table/rte_table_acl.h | 8 +++--- lib/table/rte_table_array.h | 8 +++--- lib/table/rte_table_hash.h | 8 +++--- lib/table/rte_table_hash_cuckoo.h | 8 +++--- lib/table/rte_table_hash_func.h | 24 +++++++++++++++--- lib/table/rte_table_lpm.h | 8 +++--- lib/table/rte_table_lpm_ipv6.h | 8 +++--- lib/table/rte_table_stub.h | 8 +++--- lib/telemetry/rte_telemetry.h | 8 +++--- lib/vhost/rte_vdpa.h | 8 +++--- lib/vhost/rte_vhost.h | 8 +++--- lib/vhost/rte_vhost_async.h | 8 +++--- lib/vhost/rte_vhost_crypto.h | 4 +-- lib/vhost/vdpa_driver.h | 8 +++--- 307 files changed, 979 insertions(+), 1337 deletions(-)
app/test/packet_burst_generator.h +4 -4
@@ -5,10 +5,6 @@#ifndef PACKET_BURST_GENERATOR_H_ #define PACKET_BURST_GENERATOR_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_mbuf.h> #include <rte_ether.h> #include <rte_arp.h>
@@ -17,6 +13,10 @@ extern "C" {#include <rte_tcp.h> #include <rte_sctp.h> +#ifdef __cplusplus +extern "C" { +#endif +#define IPV4_ADDR (a, b, c, d)(((a & 0xff) << 24) | ((b & 0xff) << 16) | \ ((c & 0xff) << 8) | (d & 0xff))
app/test/virtual_pmd.h +2 -2
@@ -5,12 +5,12 @@ #ifndef __VIRTUAL_ETHDEV_H_ #define __VIRTUAL_ETHDEV_H_ +#include <rte_ether.h> + #ifdef __cplusplus extern "C" { #endif -#include <rte_ether.h> - int virtual_ethdev_init(void);
buildtools/chkincs/meson.build +7 -0
@@ -43,10 +43,17 @@ chkextern = find_program('chkextern.py') missing_extern_headers = run_command(chkextern, 'missing', dpdk_chkinc_headers, capture: true, check: true).stdout().split() +redundant_extern_headers = run_command(chkextern, 'redundant', dpdk_chkinc_headers, + capture: true, check: true).stdout().split() + if missing_extern_headers != [] error('Files missing C++ \'extern "C"\' guards:\n- ' + '\n- '.join(missing_extern_headers)) endif +if redundant_extern_headers != [] + error('Redundant C++ \'extern "C"\' guards:\n- ' + '\n- '.join(redundant_extern_headers)) +endif + gen_cpp_files = generator(gen_c_file_for_header, output: '@[email protected]', arguments: ['@INPUT@', '@OUTPUT@'])
drivers/bus/auxiliary/bus_auxiliary_driver.h +4 -4
@@ -11,10 +11,6 @@* Auxiliary Bus Interface. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <stdlib.h> #include <limits.h>
@@ -28,6 +24,10 @@ extern "C" {#include <dev_driver.h> #include <rte_kvargs.h> +#ifdef __cplusplus +extern "C" { +#endif +#define RTE_BUS_AUXILIARY_NAME "auxiliary"/* Forward declarations */
drivers/bus/cdx/bus_cdx_driver.h +4 -4
@@ -10,10 +10,6 @@* AMD CDX bus interface */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdlib.h> #include <inttypes.h> #include <linux/types.h>
@@ -22,6 +18,10 @@ extern "C" {#include <dev_driver.h> #include <rte_interrupts.h> +#ifdef __cplusplus +extern "C" { +#endif +/* Forward declarations */ struct rte_cdx_device ;struct rte_cdx_driver ;
drivers/bus/dpaa/include/fsl_qman.h +4 -4
@@ -8,14 +8,14 @@ #ifndef __FSL_QMAN_H #define __FSL_QMAN_H -#ifdef __cplusplus -extern "C" { -#endif - #include <dpaa_rbtree.h> #include <rte_compat.h> #include <rte_eventdev.h> +#ifdef __cplusplus +extern "C" { +#endif + /* FQ lookups (turn this on for 64bit user-space) */ #ifdef RTE_ARCH_64 #define CONFIG_FSL_QMAN_FQ_LOOKUP
drivers/bus/fslmc/bus_fslmc_driver.h +4 -4
@@ -13,10 +13,6 @@* RTE FSLMC Bus Interface */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <stdlib.h> #include <limits.h>
@@ -40,6 +36,10 @@ extern "C" {#include "portal/dpaa2_hw_pvt.h" #include "portal/dpaa2_hw_dpio.h" +#ifdef __cplusplus +extern "C" { +#endif +#define FSLMC_OBJECT_MAX_LEN 32/**< Length of each device on bus */ #define DPAA2_INVALID_MBUF_SEQN 0
drivers/bus/pci/bus_pci_driver.h +4 -4
@@ -6,14 +6,14 @@ #ifndef BUS_PCI_DRIVER_H #define BUS_PCI_DRIVER_H -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_bus_pci.h> #include <dev_driver.h> #include <rte_compat.h> +#ifdef __cplusplus +extern "C" { +#endif + /** Pathname of PCI devices directory. */ __rte_internal const char *rte_pci_get_sysfs_path(void);
drivers/bus/pci/rte_bus_pci.h +4 -4
@@ -11,10 +11,6 @@* PCI device & driver interface */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <stdlib.h> #include <limits.h>
@@ -27,6 +23,10 @@ extern "C" {#include <rte_interrupts.h> #include <rte_pci.h> +#ifdef __cplusplus +extern "C" { +#endif +/* Forward declarations */ struct rte_pci_device ;struct rte_pci_driver ;
drivers/bus/platform/bus_platform_driver.h +4 -4
@@ -10,10 +10,6 @@* Platform bus interface. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stddef.h> #include <stdint.h>
@@ -23,6 +19,10 @@ extern "C" {#include <rte_os.h> #include <rte_vfio.h> +#ifdef __cplusplus +extern "C" { +#endif +/* Forward declarations */ struct rte_platform_bus ;struct rte_platform_device ;
drivers/bus/vdev/bus_vdev_driver.h +4 -4
@@ -5,15 +5,15 @@ #ifndef BUS_VDEV_DRIVER_H #define BUS_VDEV_DRIVER_H -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_bus_vdev.h> #include <rte_compat.h> #include <dev_driver.h> #include <rte_devargs.h> +#ifdef __cplusplus +extern "C" { +#endif + struct rte_vdev_device { RTE_TAILQ_ENTRY(rte_vdev_device) next; /**< Next attached vdev */ struct rte_device device; /**< Inherit core device */
drivers/bus/vmbus/bus_vmbus_driver.h +4 -4
@@ -6,14 +6,14 @@ #ifndef BUS_VMBUS_DRIVER_H #define BUS_VMBUS_DRIVER_H -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_bus_vmbus.h> #include <rte_compat.h> #include <dev_driver.h> +#ifdef __cplusplus +extern "C" { +#endif + struct vmbus_channel; struct vmbus_mon_page;
drivers/bus/vmbus/rte_bus_vmbus.h +4 -4
@@ -11,10 +11,6 @@* * VMBUS Interface */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <stdlib.h> #include <limits.h>
@@ -28,6 +24,10 @@ extern "C" {#include <rte_interrupts.h> #include <rte_vmbus_reg.h> +#ifdef __cplusplus +extern "C" { +#endif +/* Forward declarations */ struct rte_vmbus_device ;struct rte_vmbus_driver ;
drivers/dma/cnxk/cnxk_dma_event_dp.h +4 -4
@@ -5,16 +5,16 @@ #ifndef _CNXK_DMA_EVENT_DP_H_ #define _CNXK_DMA_EVENT_DP_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <stdint.h> #include <rte_common.h> #include <rte_compat.h> #include <rte_eventdev.h> +#ifdef __cplusplus +extern "C" { +#endif + __rte_internal uint16_t cn10k_dma_adapter_enqueue(void *ws, struct rte_event ev[], uint16_t nb_events);
drivers/dma/ioat/ioat_hw_defs.h +2 -2
@@ -5,12 +5,12 @@ #ifndef IOAT_HW_DEFS_H #define IOAT_HW_DEFS_H +#include <stdint.h> + #ifdef __cplusplus extern "C" { #endif -#include <stdint.h> - #define IOAT_PCI_CHANERR_INT_OFFSET 0x180 #define IOAT_VER_3_0 0x30
drivers/event/dlb2/rte_pmd_dlb2.h +4 -4
@@ -11,14 +11,14 @@ #ifndef _RTE_PMD_DLB2_H_ #define _RTE_PMD_DLB2_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <stdint.h> #include <rte_compat.h> +#ifdef __cplusplus +extern "C" { +#endif + /** * @warning * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
drivers/mempool/dpaa2/rte_dpaa2_mempool.h +3 -3
@@ -12,13 +12,13 @@* */ +#include <rte_compat.h> +#include <rte_mempool.h> +#ifdef __cplusplusextern "C" {#endif -#include <rte_compat.h> -#include <rte_mempool.h> -/** * Get BPID corresponding to the packet pool *
drivers/net/avp/rte_avp_fifo.h +4 -4
@@ -8,10 +8,6 @@#include "rte_avp_common.h" -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __KERNEL__/* Write memory barrier for kernel compiles */ #define AVP_WMB () smp_wmb()
@@ -27,6 +23,10 @@ extern "C" { #ifndef __KERNEL__ #include <rte_debug.h> +#ifdef __cplusplus +extern "C" { +#endif + /** * Initializes the avp fifo structure */
drivers/net/bonding/rte_eth_bond.h +2 -2
@@ -17,12 +17,12 @@* load balancing of network ports */ +#include <rte_ether.h> +#ifdef __cplusplusextern "C" {#endif -#include <rte_ether.h> -/* Supported modes of operation of link bonding library */ #define BONDING_MODE_ROUND_ROBIN (0)
drivers/net/i40e/rte_pmd_i40e.h +4 -4
@@ -14,14 +14,14 @@* */ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_compat.h> #include <rte_ethdev.h> #include <rte_ether.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Response sent back to i40e driver from user app after callback */
drivers/net/mlx5/mlx5_trace.h +4 -4
@@ -11,14 +11,14 @@* API for mlx5 PMD trace support */ -#ifdef __cplusplus -extern "C" { -#endif -#include <mlx5_prm.h> #include <rte_mbuf.h> #include <rte_trace_point.h> +#ifdef __cplusplus +extern "C" { +#endif +/* TX burst subroutines trace points. */ RTE_TRACE_POINT_FP( rte_pmd_mlx5_trace_tx_entry,
drivers/net/ring/rte_eth_ring.h +2 -2
@@ -5,12 +5,12 @@ #ifndef _RTE_ETH_RING_H_ #define _RTE_ETH_RING_H_ +#include <rte_ring.h> + #ifdef __cplusplus extern "C" { #endif -#include <rte_ring.h> - /** * Create a new ethdev port from a set of rings *
drivers/net/vhost/rte_eth_vhost.h +4 -4
@@ -5,15 +5,15 @@ #ifndef _RTE_ETH_VHOST_H_ #define _RTE_ETH_VHOST_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <stdint.h> #include <stdbool.h> #include <rte_vhost.h> +#ifdef __cplusplus +extern "C" { +#endif + /* * Event description. */
drivers/raw/ifpga/afu_pmd_core.h +4 -4
@@ -5,10 +5,6 @@#ifndef AFU_PMD_CORE_H #define AFU_PMD_CORE_H -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #include <stdio.h> #include <unistd.h>
@@ -20,6 +16,10 @@ extern "C" {#include "ifpga_rawdev.h" +#ifdef __cplusplus +extern "C" { +#endif +#define AFU_RAWDEV_MAX_DRVS 32struct afu_rawdev ;
drivers/raw/ifpga/afu_pmd_he_hssi.h +3 -3
@@ -5,13 +5,13 @@ #ifndef AFU_PMD_HE_HSSI_H #define AFU_PMD_HE_HSSI_H +#include "afu_pmd_core.h" +#include "rte_pmd_afu.h" + #ifdef __cplusplus extern "C" { #endif -#include "afu_pmd_core.h" -#include "rte_pmd_afu.h" - #define HE_HSSI_UUID_L 0xbb370242ac130002 #define HE_HSSI_UUID_H 0x823c334c98bf11ea #define NUM_HE_HSSI_PORTS 8
drivers/raw/ifpga/afu_pmd_he_lpbk.h +3 -3
@@ -5,13 +5,13 @@ #ifndef AFU_PMD_HE_LPBK_H #define AFU_PMD_HE_LPBK_H +#include "afu_pmd_core.h" +#include "rte_pmd_afu.h" + #ifdef __cplusplus extern "C" { #endif -#include "afu_pmd_core.h" -#include "rte_pmd_afu.h" - #define HE_LPBK_UUID_L 0xb94b12284c31e02b #define HE_LPBK_UUID_H 0x56e203e9864f49a7 #define HE_MEM_LPBK_UUID_L 0xbb652a578330a8eb
drivers/raw/ifpga/afu_pmd_he_mem.h +3 -3
@@ -5,13 +5,13 @@ #ifndef AFU_PMD_HE_MEM_H #define AFU_PMD_HE_MEM_H +#include "afu_pmd_core.h" +#include "rte_pmd_afu.h" + #ifdef __cplusplus extern "C" { #endif -#include "afu_pmd_core.h" -#include "rte_pmd_afu.h" - #define HE_MEM_TG_UUID_L 0xa3dc5b831f5cecbb #define HE_MEM_TG_UUID_H 0x4dadea342c7848cb
drivers/raw/ifpga/afu_pmd_n3000.h +3 -3
@@ -5,13 +5,13 @@ #ifndef AFU_PMD_N3000_H #define AFU_PMD_N3000_H +#include "afu_pmd_core.h" +#include "rte_pmd_afu.h" + #ifdef __cplusplus extern "C" { #endif -#include "afu_pmd_core.h" -#include "rte_pmd_afu.h" - #define N3000_AFU_UUID_L 0xc000c9660d824272 #define N3000_AFU_UUID_H 0x9aeffe5f84570612 #define N3000_NLB0_UUID_L 0xf89e433683f9040b
drivers/raw/ifpga/rte_pmd_afu.h +2 -2
@@ -14,12 +14,12 @@* */ +#include <stdint.h> +#ifdef __cplusplusextern "C" {#endif -#include <stdint.h> -#define RTE_PMD_AFU_N3000_NLB 1#define RTE_PMD_AFU_N3000_DMA 2
drivers/raw/ifpga/rte_pmd_ifpga.h +2 -2
@@ -14,12 +14,12 @@* */ +#include <stdint.h> +#ifdef __cplusplusextern "C" {#endif -#include <stdint.h> -#define IFPGA_MAX_PORT_NUM 4/**
examples/ethtool/lib/rte_ethtool.h +4 -4
@@ -30,14 +30,14 @@* rte_ethtool_net_set_rx_mode net_device_ops::ndo_set_rx_mode * */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #include <rte_ethdev.h> #include <linux/ethtool.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Retrieve the Ethernet device driver information according to * attributes described by ethtool data structure, ethtool_drvinfo.
examples/qos_sched/main.h +2 -2
@@ -5,12 +5,12 @@ #ifndef _MAIN_H_ #define _MAIN_H_ +#include <rte_sched.h> + #ifdef __cplusplus extern "C" { #endif -#include <rte_sched.h> - #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1 /*
examples/vm_power_manager/channel_manager.h +4 -4
@@ -5,16 +5,16 @@ #ifndef CHANNEL_MANAGER_H_ #define CHANNEL_MANAGER_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <linux/limits.h> #include <linux/un.h> #include <stdbool.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif + /* Maximum name length including '\0' terminator */ #define CHANNEL_MGR_MAX_NAME_LEN 64
lib/acl/rte_acl_osdep.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_ACL_OSDEP_H_#define _RTE_ACL_OSDEP_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * @file *
@@ -49,8 +45,4 @@ extern "C" {#include <rte_cpuflags.h> #include <rte_debug.h> -#ifdef __cplusplus -} -#endif -#endif /* _RTE_ACL_OSDEP_H_ */
lib/bbdev/rte_bbdev.h +4 -4
@@ -20,10 +20,6 @@* from the same queue. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #include <stdbool.h>
@@ -32,6 +28,10 @@ extern "C" {#include "rte_bbdev_op.h" +#ifdef __cplusplus +extern "C" { +#endif +#ifndef RTE_BBDEV_MAX_DEVS #define RTE_BBDEV_MAX_DEVS 128/**< Max number of devices */ #endif
lib/bbdev/rte_bbdev_op.h +4 -4
@@ -11,10 +11,6 @@* Defines wireless base band layer 1 operations and capabilities */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #include <rte_compat.h>
@@ -23,6 +19,10 @@ extern "C" {#include <rte_memory.h> #include <rte_mempool.h> +#ifdef __cplusplus +extern "C" { +#endif +/* Number of columns in sub-block interleaver (36.212, section 5.1.4.1.1) */ #define RTE_BBDEV_TURBO_C_SUBBLOCK (32)/* Maximum size of Transport Block (36.213, Table, Table 7.1.7.2.5-1) */
lib/bbdev/rte_bbdev_pmd.h +4 -4
@@ -14,15 +14,15 @@* bbdev interface. User applications should not use this API. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #include <rte_log.h> #include "rte_bbdev.h" +#ifdef __cplusplus +extern "C" { +#endif +/** Suggested value for SW based devices */ #define RTE_BBDEV_DEFAULT_MAX_NB_QUEUES RTE_MAX_LCORE
lib/bpf/bpf_def.h +0 -9
@@ -7,10 +7,6 @@#ifndef _RTE_BPF_DEF_H_#define _RTE_BPF_DEF_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * @file *
@@ -25,7 +21,6 @@ extern "C" {#include <stdint.h> -/* * The instruction encodings. */
@@ -144,8 +139,4 @@ struct ebpf_insn {*/ #define EBPF_FUNC_MAX_ARGS (EBPF_REG_6 - EBPF_REG_1) -#ifdef __cplusplus -} -#endif -#endif /* RTE_BPF_DEF_H_ */
lib/compressdev/rte_comp.h +2 -2
@@ -11,12 +11,12 @@* RTE definitions for Data Compression Service */ +#include <rte_mbuf.h> +#ifdef __cplusplusextern "C" {#endif -#include <rte_mbuf.h> -/** * compression service feature flags *
lib/compressdev/rte_compressdev.h +3 -3
@@ -13,13 +13,13 @@* Defines comp device APIs for the provisioning of compression operations. */ + +#include "rte_comp.h" +#ifdef __cplusplusextern "C" {#endif - -#include "rte_comp.h" -/** * Parameter log base 2 range description. * Final value will be 2^value.
lib/compressdev/rte_compressdev_internal.h +4 -4
@@ -5,10 +5,6 @@#ifndef _RTE_COMPRESSDEV_INTERNAL_H_#define _RTE_COMPRESSDEV_INTERNAL_H_ -#ifdef __cplusplus -extern "C" { -#endif -/* rte_compressdev_internal.h * This file holds Compressdev private data structures. */
@@ -16,6 +12,10 @@ extern "C" {#include "rte_comp.h" +#ifdef __cplusplus +extern "C" { +#endif +#define RTE_COMPRESSDEV_NAME_MAX_LEN (64)/**< Max length of name of comp PMD */
lib/compressdev/rte_compressdev_pmd.h +4 -4
@@ -13,10 +13,6 @@* them directly. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <string.h> #include <dev_driver.h>
@@ -24,6 +20,10 @@ extern "C" {#include "rte_compressdev.h" #include "rte_compressdev_internal.h" +#ifdef __cplusplus +extern "C" { +#endif +#define RTE_COMPRESSDEV_PMD_NAME_ARG ("name")#define RTE_COMPRESSDEV_PMD_SOCKET_ID_ARG ("socket_id")
lib/cryptodev/cryptodev_pmd.h +4 -4
@@ -5,10 +5,6 @@#ifndef _CRYPTODEV_PMD_H_#define _CRYPTODEV_PMD_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** @file * RTE Crypto PMD APIs *
@@ -28,6 +24,10 @@ extern "C" {#include "rte_crypto.h" #include "rte_cryptodev.h" +#ifdef __cplusplus +extern "C" { +#endif +#define RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS 8
lib/cryptodev/cryptodev_trace.h +4 -4
@@ -11,14 +11,14 @@* API for cryptodev trace support */ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_trace_point.h> #include "rte_cryptodev.h" +#ifdef __cplusplus +extern "C" { +#endif + RTE_TRACE_POINT( rte_cryptodev_trace_configure, RTE_TRACE_POINT_ARGS(uint8_t dev_id,
lib/cryptodev/rte_crypto.h +4 -4
@@ -11,10 +11,6 @@* RTE Cryptography Common Definitions */ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_mbuf.h> #include <rte_memory.h>
@@ -24,6 +20,10 @@ extern "C" {#include "rte_crypto_sym.h" #include "rte_crypto_asym.h" +#ifdef __cplusplus +extern "C" { +#endif +/** Crypto operation types */ enum rte_crypto_op_type {RTE_CRYPTO_OP_TYPE_UNDEFINED ,
lib/cryptodev/rte_crypto_asym.h +0 -8
@@ -14,10 +14,6 @@* asymmetric crypto operations. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <string.h> #include <stdint.h>
@@ -728,8 +724,4 @@ struct rte_crypto_asym_op { */ }; -#ifdef __cplusplus -} -#endif -#endif /* _RTE_CRYPTO_ASYM_H_ */
lib/cryptodev/rte_crypto_sym.h +4 -4
@@ -14,10 +14,6 @@* as supported symmetric crypto operation combinations. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <string.h> #include <rte_compat.h>
@@ -26,6 +22,10 @@ extern "C" {#include <rte_mempool.h> #include <rte_common.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Crypto IO Vector (in analogy with struct iovec) * Supposed be used to pass input/output data buffers for crypto data-path
lib/cryptodev/rte_cryptodev.h +4 -4
@@ -14,10 +14,6 @@* authentication operations. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_compat.h> #include "rte_kvargs.h" #include "rte_crypto.h"
@@ -1859,6 +1855,10 @@ int rte_cryptodev_remove_deq_callback(uint8_t dev_id, struct rte_cryptodev_cb *cb);#include <rte_cryptodev_core.h> + +#ifdef __cplusplus +extern "C" { +#endif /** * * Dequeue a burst of processed crypto operations from a queue on the crypto
lib/cryptodev/rte_cryptodev_trace_fp.h +2 -2
@@ -5,12 +5,12 @@ #ifndef _RTE_CRYPTODEV_TRACE_FP_H_ #define _RTE_CRYPTODEV_TRACE_FP_H_ +#include <rte_trace_point.h> + #ifdef __cplusplus extern "C" { #endif -#include <rte_trace_point.h> - RTE_TRACE_POINT_FP( rte_cryptodev_trace_enqueue_burst, RTE_TRACE_POINT_ARGS(uint8_t dev_id, uint16_t qp_id, void **ops,
lib/dispatcher/rte_dispatcher.h +4 -4
@@ -19,16 +19,16 @@* event device. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdbool.h> #include <stdint.h> #include <rte_compat.h> #include <rte_eventdev.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Function prototype for match callbacks. *
lib/dmadev/rte_dmadev.h +8 -0
@@ -772,9 +772,17 @@ struct rte_dma_sge {uint32_t length;/**< The DMA operation length. */ }; +#ifdef __cplusplus +} +#endif +#include "rte_dmadev_core.h" #include "rte_dmadev_trace_fp.h" +#ifdef __cplusplus +extern "C" { +#endif +/**@{@name DMA operation flag * @see rte_dma_copy() * @see rte_dma_copy_sg()
lib/eal/arm/include/rte_atomic_32.h +2 -2
@@ -9,12 +9,12 @@# error Platform must be built with RTE_FORCE_INTRINSICS#endif +#include "generic/rte_atomic.h" +#ifdef __cplusplusextern "C" {#endif -#include "generic/rte_atomic.h" -#define rte_mb () __sync_synchronize()#define rte_wmb () do { asm volatile ("dmb st" : : : "memory"); } while (0)
lib/eal/arm/include/rte_atomic_64.h +4 -4
@@ -10,14 +10,14 @@# error Platform must be built with RTE_FORCE_INTRINSICS#endif -#ifdef __cplusplus -extern "C" { -#endif -#include "generic/rte_atomic.h" #include <rte_branch_prediction.h> #include <rte_debug.h> +#ifdef __cplusplus +extern "C" { +#endif +#define rte_mb () asm volatile("dmb osh" : : : "memory")#define rte_wmb () asm volatile("dmb oshst" : : : "memory")
lib/eal/arm/include/rte_byteorder.h +4 -4
@@ -9,14 +9,14 @@# error Platform must be built with RTE_FORCE_INTRINSICS#endif -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #include <rte_common.h> #include "generic/rte_byteorder.h" +#ifdef __cplusplus +extern "C" { +#endif +/* ARM architecture is bi-endian (both big and little). */ #if RTE_BYTE_ORDER ==RTE_LITTLE_ENDIAN
lib/eal/arm/include/rte_cpuflags_32.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_CPUFLAGS_ARM32_H_#define _RTE_CPUFLAGS_ARM32_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * Enumeration of all CPU features supported */
@@ -46,8 +42,4 @@ enum rte_cpu_flag_t {#include "generic/rte_cpuflags.h" -#ifdef __cplusplus -} -#endif -#endif /* _RTE_CPUFLAGS_ARM32_H_ */
lib/eal/arm/include/rte_cpuflags_64.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_CPUFLAGS_ARM64_H_#define _RTE_CPUFLAGS_ARM64_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * Enumeration of all CPU features supported */
@@ -40,8 +36,4 @@ enum rte_cpu_flag_t {#include "generic/rte_cpuflags.h" -#ifdef __cplusplus -} -#endif -#endif /* _RTE_CPUFLAGS_ARM64_H_ */
lib/eal/arm/include/rte_cycles_32.h +2 -2
@@ -15,12 +15,12 @@#include <time.h> +#include "generic/rte_cycles.h" +#ifdef __cplusplusextern "C" {#endif -#include "generic/rte_cycles.h" -/** * Read the time base register. *
lib/eal/arm/include/rte_cycles_64.h +2 -2
@@ -6,12 +6,12 @@ #ifndef _RTE_CYCLES_ARM64_H_ #define _RTE_CYCLES_ARM64_H_ +#include "generic/rte_cycles.h" + #ifdef __cplusplus extern "C" { #endif -#include "generic/rte_cycles.h" - /** Read generic counter frequency */ static __rte_always_inline uint64_t __rte_arm64_cntfrq(void)
lib/eal/arm/include/rte_io.h +0 -8
@@ -5,18 +5,10 @@#ifndef _RTE_IO_ARM_H_#define _RTE_IO_ARM_H_ -#ifdef __cplusplus -extern "C" { -#endif -#ifdef RTE_ARCH_64 #include "rte_io_64.h" #else #include "generic/rte_io.h" #endif -#ifdef __cplusplus -} -#endif -#endif /* _RTE_IO_ARM_H_ */
lib/eal/arm/include/rte_io_64.h +4 -4
@@ -5,10 +5,6 @@#ifndef _RTE_IO_ARM64_H_#define _RTE_IO_ARM64_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #define RTE_OVERRIDE_IO_H
@@ -17,6 +13,10 @@ extern "C" {#include <rte_compat.h> #include "rte_atomic_64.h" +#ifdef __cplusplus +extern "C" { +#endif + static __rte_always_inline uint8_trte_read8_relaxed (const volatile void *addr) {
lib/eal/arm/include/rte_memcpy_32.h +4 -4
@@ -8,10 +8,6 @@#include <stdint.h> #include <string.h> -#ifdef __cplusplus -extern "C" { -#endif -#include "generic/rte_memcpy.h" #ifdef RTE_ARCH_ARM_NEON_MEMCPY
@@ -23,6 +19,10 @@ extern "C" {/* ARM NEON Intrinsics are used to copy data */ #include <arm_neon.h> +#ifdef __cplusplus +extern "C" { +#endif +static inline void rte_mov16 (uint8_t *dst,const uint8_t *src) {
lib/eal/arm/include/rte_memcpy_64.h +16 -7
@@ -5,10 +5,6 @@#ifndef _RTE_MEMCPY_ARM64_H_#define _RTE_MEMCPY_ARM64_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #include <string.h>
@@ -18,6 +14,10 @@ extern "C" {#include <rte_common.h> #include <rte_branch_prediction.h> +#ifdef __cplusplus +extern "C" { +#endif +/* * The memory copy performance differs on different AArch64 micro-architectures. * And the most recent glibc (e.g. 2.23 or later) can provide a better memcpy()
@@ -324,7 +324,16 @@ void *rte_memcpy(void *dst, const void *src, size_t n) }#endif /* RTE_CACHE_LINE_SIZE >= 128 */ -#else +#ifdef __cplusplus +} +#endif + +#else /* RTE_ARCH_ARM64_MEMCPY */ + +#ifdef __cplusplus +extern "C" { +#endif +static inline void rte_mov16 (uint8_t *dst,const uint8_t *src) {
@@ -363,10 +372,10 @@ rte_mov256(uint8_t *dst, const uint8_t *src)#define rte_memcpy (d, s, n) memcpy((d), (s), (n)) -#endif /* RTE_ARCH_ARM64_MEMCPY */ -#ifdef __cplusplus }#endif +#endif /* RTE_ARCH_ARM64_MEMCPY */ +#endif /* _RTE_MEMCPY_ARM_64_H_ */
lib/eal/arm/include/rte_pause.h +0 -8
@@ -5,18 +5,10 @@#ifndef _RTE_PAUSE_ARM_H_#define _RTE_PAUSE_ARM_H_ -#ifdef __cplusplus -extern "C" { -#endif -#ifdef RTE_ARCH_64 #include <rte_pause_64.h> #else #include <rte_pause_32.h> #endif -#ifdef __cplusplus -} -#endif -#endif /* _RTE_PAUSE_ARM_H_ */
lib/eal/arm/include/rte_pause_32.h +3 -3
@@ -5,13 +5,13 @@ #ifndef _RTE_PAUSE_ARM32_H_ #define _RTE_PAUSE_ARM32_H_ +#include <rte_common.h> +#include "generic/rte_pause.h" + #ifdef __cplusplus extern "C" { #endif -#include <rte_common.h> -#include "generic/rte_pause.h" - static inline void rte_pause(void) { }
lib/eal/arm/include/rte_pause_64.h +4 -4
@@ -6,10 +6,6 @@#ifndef _RTE_PAUSE_ARM64_H_#define _RTE_PAUSE_ARM64_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_common.h> #include <rte_stdatomic.h>
@@ -19,6 +15,10 @@ extern "C" {#include "generic/rte_pause.h" +#ifdef __cplusplus +extern "C" { +#endif +static inline void rte_pause (void ) { asmvolatile ("yield" :::"memory" );
lib/eal/arm/include/rte_power_intrinsics.h +0 -8
@@ -5,16 +5,8 @@#ifndef _RTE_POWER_INTRINSIC_ARM_H_#define _RTE_POWER_INTRINSIC_ARM_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_common.h> #include "generic/rte_power_intrinsics.h" -#ifdef __cplusplus -} -#endif -#endif /* _RTE_POWER_INTRINSIC_ARM_H_ */
lib/eal/arm/include/rte_prefetch_32.h +4 -4
@@ -5,14 +5,14 @@ #ifndef _RTE_PREFETCH_ARM32_H_ #define _RTE_PREFETCH_ARM32_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_compat.h> #include <rte_common.h> #include "generic/rte_prefetch.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void rte_prefetch0(const volatile void *p) { asm volatile ("pld [%0]" : : "r" (p));
lib/eal/arm/include/rte_prefetch_64.h +4 -4
@@ -5,14 +5,14 @@ #ifndef _RTE_PREFETCH_ARM_64_H_ #define _RTE_PREFETCH_ARM_64_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_compat.h> #include <rte_common.h> #include "generic/rte_prefetch.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void rte_prefetch0(const volatile void *p) { asm volatile ("PRFM PLDL1KEEP, [%0]" : : "r" (p));
lib/eal/arm/include/rte_rwlock.h +2 -2
@@ -5,12 +5,12 @@ #ifndef _RTE_RWLOCK_ARM_H_ #define _RTE_RWLOCK_ARM_H_ +#include "generic/rte_rwlock.h" + #ifdef __cplusplus extern "C" { #endif -#include "generic/rte_rwlock.h" - static inline void rte_rwlock_read_lock_tm(rte_rwlock_t *rwl) {
lib/eal/arm/include/rte_spinlock.h +3 -3
@@ -9,13 +9,13 @@# error Platform must be built with RTE_FORCE_INTRINSICS#endif +#include <rte_common.h> +#include "generic/rte_spinlock.h" +#ifdef __cplusplusextern "C" {#endif -#include <rte_common.h> -#include "generic/rte_spinlock.h" -static inline int rte_tm_supported (void ) {return 0 ;
lib/eal/freebsd/include/rte_os.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_OS_H_#define _RTE_OS_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * This header should contain any definition * which is not supported natively or named differently in FreeBSD.
@@ -78,8 +74,4 @@ typedef cpuset_t rte_cpuset_t;#endif /* RTE_EAL_FREEBSD_CPUSET_LEGACY */ -#ifdef __cplusplus -} -#endif -#endif /* _RTE_OS_H_ */
lib/eal/include/bus_driver.h +4 -4
@@ -5,16 +5,16 @@ #ifndef BUS_DRIVER_H #define BUS_DRIVER_H -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_bus.h> #include <rte_compat.h> #include <rte_dev.h> #include <rte_eal.h> #include <rte_tailq.h> +#ifdef __cplusplus +extern "C" { +#endif + struct rte_devargs; struct rte_device;
lib/eal/include/dev_driver.h +0 -8
@@ -5,10 +5,6 @@#ifndef DEV_DRIVER_H #define DEV_DRIVER_H -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_common.h> #include <rte_dev.h>
@@ -34,8 +30,4 @@ struct rte_device { struct rte_devargs *devargs; /**< Arguments for latest probing */ }; -#ifdef __cplusplus -} -#endif -#endif /* DEV_DRIVER_H */
lib/eal/include/eal_trace_internal.h +4 -4
@@ -11,16 +11,16 @@* API for EAL trace support */ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_alarm.h> #include <rte_interrupts.h> #include <rte_trace_point.h> #include "eal_interrupts.h" +#ifdef __cplusplus +extern "C" { +#endif +/* Alarm */ RTE_TRACE_POINT( rte_eal_trace_alarm_set,
lib/eal/include/generic/rte_atomic.h +8 -0
@@ -17,6 +17,10 @@#include <rte_common.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __DOXYGEN__/** @name Memory Barrier
@@ -1156,4 +1160,8 @@ rte_atomic128_cmp_exchange(rte_int128_t *dst,#endif /* __DOXYGEN__ */ +#ifdef __cplusplus +} +#endif +#endif /* _RTE_ATOMIC_H_ */
lib/eal/include/generic/rte_byteorder.h +8 -0
@@ -24,6 +24,10 @@#include <rte_common.h> #include <rte_config.h> +#ifdef __cplusplus +extern "C" { +#endif +/* * Compile-time endianness detection */
@@ -251,4 +255,8 @@ static uint64_t rte_be_to_cpu_64(rte_be64_t x);#endif #endif +#ifdef __cplusplus +} +#endif +#endif /* _RTE_BYTEORDER_H_ */
lib/eal/include/generic/rte_cpuflags.h +8 -0
@@ -15,6 +15,10 @@#include <rte_compat.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Structure used to describe platform-specific intrinsics that may or may not * be supported at runtime.
@@ -104,4 +108,8 @@ rte_cpu_getauxval(unsigned long type);int rte_cpu_strcmp_auxval (unsigned long type,const char *str); +#ifdef __cplusplus +} +#endif +#endif /* _RTE_CPUFLAGS_H_ */
lib/eal/include/generic/rte_cycles.h +8 -0
@@ -16,6 +16,10 @@#include <rte_debug.h> #include <rte_atomic.h> +#ifdef __cplusplus +extern "C" { +#endif +#define MS_PER_S 1000#define US_PER_S 1000000#define NS_PER_S 1000000000
@@ -175,4 +179,8 @@ void rte_delay_us_sleep(unsigned int us);*/ void rte_delay_us_callback_register (void (*userfunc)(unsigned int )); +#ifdef __cplusplus +} +#endif +#endif /* _RTE_CYCLES_H_ */
lib/eal/include/generic/rte_io.h +8 -0
@@ -17,6 +17,10 @@#include <rte_compat.h> #include <rte_atomic.h> +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __DOXYGEN__/**
@@ -396,4 +400,8 @@ rte_write32_wc_relaxed(uint32_t value, volatile void *addr)#endif /* RTE_OVERRIDE_IO_H */ +#ifdef __cplusplus +} +#endif +#endif /* _RTE_IO_H_ */
lib/eal/include/generic/rte_memcpy.h +8 -0
@@ -5,6 +5,10 @@ #ifndef _RTE_MEMCPY_H_ #define _RTE_MEMCPY_H_ +#ifdef __cplusplus +extern "C" { +#endif + /** * @file *
@@ -113,4 +117,8 @@ rte_memcpy(void *dst, const void *src, size_t n);#endif /* __DOXYGEN__ */ +#ifdef __cplusplus +} +#endif +#endif /* _RTE_MEMCPY_H_ */
lib/eal/include/generic/rte_pause.h +8 -0
@@ -19,6 +19,10 @@#include <rte_atomic.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Pause CPU execution for a short while *
@@ -136,4 +140,8 @@ rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected, } while (0)#endif /* ! RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED */ +#ifdef __cplusplus +} +#endif +#endif /* _RTE_PAUSE_H_ */
lib/eal/include/generic/rte_power_intrinsics.h +8 -0
@@ -9,6 +9,10 @@#include <rte_spinlock.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * @file * Advanced power management operations.
@@ -147,4 +151,8 @@ int rte_power_pause(const uint64_t tsc_timestamp);int rte_power_monitor_multi (const struct rte_power_monitor_cond pmc[],const uint32_t num,const uint64_t tsc_timestamp); +#ifdef __cplusplus +} +#endif +#endif /* _RTE_POWER_INTRINSIC_H_ */
lib/eal/include/generic/rte_prefetch.h +8 -0
@@ -7,6 +7,10 @@#include <rte_compat.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * @file *
@@ -146,4 +150,8 @@ __rte_experimentalstatic inline void rte_cldemote (const volatile void *p); +#ifdef __cplusplus +} +#endif +#endif /* _RTE_PREFETCH_H_ */
lib/eal/include/generic/rte_rwlock.h +4 -4
@@ -22,10 +22,6 @@* https://locklessinc.com/articles/locks/ */ -#ifdef __cplusplus -extern "C" { -#endif -#include <errno.h> #include <rte_branch_prediction.h>
@@ -34,6 +30,10 @@ extern "C" {#include <rte_pause.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * The rte_rwlock_t type. *
lib/eal/include/generic/rte_spinlock.h +8 -0
@@ -25,6 +25,10 @@#include <rte_pause.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * The rte_spinlock_t type. */
@@ -318,4 +322,8 @@ __rte_warn_unused_resultstatic inline int rte_spinlock_recursive_trylock_tm (rte_spinlock_recursive_t *slr); +#ifdef __cplusplus +} +#endif +#endif /* _RTE_SPINLOCK_H_ */
lib/eal/include/generic/rte_vect.h +8 -0
@@ -209,6 +209,10 @@ enum rte_vect_max_simd {*/ }; +#ifdef __cplusplus +extern "C" { +#endif +/** * Get the supported SIMD bitwidth. *
@@ -230,4 +234,8 @@ uint16_t rte_vect_get_max_simd_bitwidth(void);*/ int rte_vect_set_max_simd_bitwidth (uint16_t bitwidth); +#ifdef __cplusplus +} +#endif +#endif /* _RTE_VECT_H_ */
lib/eal/include/rte_alarm.h +2 -2
@@ -14,12 +14,12 @@* Does not require hpet support. */ +#include <stdint.h> +#ifdef __cplusplusextern "C" {#endif -#include <stdint.h> -/** * Signature of callback back function called when an alarm goes off. */
lib/eal/include/rte_bitmap.h +4 -4
@@ -5,10 +5,6 @@#ifndef __INCLUDE_RTE_BITMAP_H__#define __INCLUDE_RTE_BITMAP_H__ -#ifdef __cplusplus -extern "C" { -#endif -/** * @file * RTE Bitmap
@@ -43,6 +39,10 @@ extern "C" {#include <rte_branch_prediction.h> #include <rte_prefetch.h> +#ifdef __cplusplus +extern "C" { +#endif +/* Slab */ #define RTE_BITMAP_SLAB_BIT_SIZE 64#define RTE_BITMAP_SLAB_BIT_SIZE_LOG2 6
lib/eal/include/rte_branch_prediction.h +0 -8
@@ -10,10 +10,6 @@#ifndef _RTE_BRANCH_PREDICTION_H_#define _RTE_BRANCH_PREDICTION_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * Check if a branch is likely to be taken. *
@@ -48,8 +44,4 @@ extern "C" {#endif #endif /* unlikely */ -#ifdef __cplusplus -} -#endif -#endif /* _RTE_BRANCH_PREDICTION_H_ */
lib/eal/include/rte_bus.h +4 -4
@@ -14,14 +14,14 @@* over the devices and drivers in EAL. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <rte_eal.h> +#ifdef __cplusplus +extern "C" { +#endif +struct rte_bus ;struct rte_device ;
lib/eal/include/rte_class.h +2 -2
@@ -18,12 +18,12 @@* cryptographic co-processor (crypto), etc. */ +#include <rte_dev.h> +#ifdef __cplusplusextern "C" {#endif -#include <rte_dev.h> -/** Double linked list of classes */ RTE_TAILQ_HEAD (rte_class_list, rte_class);
lib/eal/include/rte_common.h +4 -4
@@ -12,10 +12,6 @@* for DPDK. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <assert.h> #include <limits.h> #include <stdint.h>
@@ -26,6 +22,10 @@ extern "C" {/* OS specific include */ #include <rte_os.h> +#ifdef __cplusplus +extern "C" { +#endif +#ifndef RTE_TOOLCHAIN_MSVC #ifndef typeof#define typeof __typeof__
lib/eal/include/rte_compat.h +0 -8
@@ -6,10 +6,6 @@#ifndef _RTE_COMPAT_H_#define _RTE_COMPAT_H_ -#ifdef __cplusplus -extern "C" { -#endif -#ifndef ALLOW_EXPERIMENTAL_API #ifdef RTE_TOOLCHAIN_MSVC
@@ -70,8 +66,4 @@ __attribute__((section(".text.internal")))#endif -#ifdef __cplusplus -} -#endif -#endif /* _RTE_COMPAT_H_ */
lib/eal/include/rte_dev.h +4 -4
@@ -13,16 +13,16 @@* This file manages the list of device drivers. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <rte_config.h> #include <rte_common.h> #include <rte_log.h> +#ifdef __cplusplus +extern "C" { +#endif +struct rte_bus ;struct rte_devargs ;struct rte_device ;
lib/eal/include/rte_devargs.h +4 -4
@@ -16,14 +16,14 @@* list of rte_devargs structures. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <rte_dev.h> +#ifdef __cplusplus +extern "C" { +#endif +struct rte_bus ;/**
lib/eal/include/rte_eal_trace.h +2 -2
@@ -11,12 +11,12 @@* API for EAL trace support */ +#include <rte_trace_point.h> +#ifdef __cplusplusextern "C" {#endif -#include <rte_trace_point.h> -/* Generic */ RTE_TRACE_POINT( rte_eal_trace_generic_void,
lib/eal/include/rte_errno.h +2 -2
@@ -11,12 +11,12 @@ #ifndef _RTE_ERRNO_H_ #define _RTE_ERRNO_H_ +#include <rte_per_lcore.h> + #ifdef __cplusplus extern "C" { #endif -#include <rte_per_lcore.h> - RTE_DECLARE_PER_LCORE(int, _rte_errno); /**< Per core error number. */ /**
lib/eal/include/rte_fbarray.h +4 -4
@@ -30,14 +30,14 @@* another process is using ``rte_fbarray``. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <rte_rwlock.h> +#ifdef __cplusplus +extern "C" { +#endif + #define RTE_FBARRAY_NAME_LEN 64 struct rte_fbarray {
lib/eal/include/rte_keepalive.h +3 -3
@@ -10,13 +10,13 @@ #ifndef _KEEPALIVE_H_ #define _KEEPALIVE_H_ +#include <rte_config.h> +#include <rte_memory.h> + #ifdef __cplusplus extern "C" { #endif -#include <rte_config.h> -#include <rte_memory.h> - #ifndef RTE_KEEPALIVE_MAXCORES /** * Number of cores to track.
lib/eal/include/rte_mcslock.h +4 -4
@@ -19,16 +19,16 @@* they acquired the lock. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_lcore.h> #include <rte_common.h> #include <rte_pause.h> #include <rte_branch_prediction.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * The rte_mcslock_t type. */
lib/eal/include/rte_memory.h +4 -4
@@ -15,16 +15,16 @@#include <stddef.h> #include <stdio.h> -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_bitops.h> #include <rte_common.h> #include <rte_config.h> #include <rte_eal_memconfig.h> #include <rte_fbarray.h> +#ifdef __cplusplus +extern "C" { +#endif +#define RTE_PGSIZE_4K (1ULL << 12)#define RTE_PGSIZE_64K (1ULL << 16)#define RTE_PGSIZE_256K (1ULL << 18)
lib/eal/include/rte_pci_dev_feature_defs.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_PCI_DEV_DEFS_H_#define _RTE_PCI_DEV_DEFS_H_ -#ifdef __cplusplus -extern "C" { -#endif -/* interrupt mode */ enum rte_intr_mode { RTE_INTR_MODE_NONE = 0,
@@ -17,8 +13,4 @@ enum rte_intr_mode {RTE_INTR_MODE_MSIX }; -#ifdef __cplusplus -} -#endif -#endif /* _RTE_PCI_DEV_DEFS_H_ */
lib/eal/include/rte_pci_dev_features.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_PCI_DEV_FEATURES_H#define _RTE_PCI_DEV_FEATURES_H -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_pci_dev_feature_defs.h> #define RTE_INTR_MODE_NONE_NAME "none"
@@ -16,8 +12,4 @@ extern "C" {#define RTE_INTR_MODE_MSI_NAME "msi"#define RTE_INTR_MODE_MSIX_NAME "msix" -#ifdef __cplusplus -} -#endif -#endif
lib/eal/include/rte_per_lcore.h +0 -8
@@ -18,10 +18,6 @@* Parts of this are execution environment specific. */ -#ifdef __cplusplus -extern "C" { -#endif -#ifdef RTE_TOOLCHAIN_MSVC #define RTE_DEFINE_PER_LCORE (type, name) \ __declspec(thread) type per_lcore_##name
@@ -49,8 +45,4 @@ extern "C" {*/ #define RTE_PER_LCORE (name) (per_lcore_##name) -#ifdef __cplusplus -} -#endif -#endif /* _RTE_PER_LCORE_H_ */
lib/eal/include/rte_pflock.h +4 -4
@@ -27,14 +27,14 @@* All locks must be initialised before use, and only initialised once. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_common.h> #include <rte_pause.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * The rte_pflock_t type. */
lib/eal/include/rte_random.h +2 -2
@@ -11,12 +11,12 @@* Pseudo-random Generators in RTE */ +#include <stdint.h> +#ifdef __cplusplusextern "C" {#endif -#include <stdint.h> -/** * Seed the pseudo-random generator. *
lib/eal/include/rte_seqcount.h +4 -4
@@ -5,10 +5,6 @@#ifndef _RTE_SEQCOUNT_H_#define _RTE_SEQCOUNT_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * @file * RTE Seqcount
@@ -27,6 +23,10 @@ extern "C" {#include <rte_branch_prediction.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * The RTE seqcount type. */
lib/eal/include/rte_seqlock.h +4 -4
@@ -5,10 +5,6 @@#ifndef _RTE_SEQLOCK_H_#define _RTE_SEQLOCK_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * @file * RTE Seqlock
@@ -95,6 +91,10 @@ extern "C" {#include <rte_seqcount.h> #include <rte_spinlock.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * The RTE seqlock type. */
lib/eal/include/rte_service.h +4 -4
@@ -23,16 +23,16 @@* application has access to the remaining lcores as normal. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdio.h> #include <stdint.h> #include <rte_config.h> #include <rte_lcore.h> +#ifdef __cplusplus +extern "C" { +#endif +#define RTE_SERVICE_NAME_MAX 32/* Capabilities of a service.
lib/eal/include/rte_service_component.h +2 -2
@@ -10,12 +10,12 @@* operate, and you wish to run the component using service cores */ +#include <rte_service.h> +#ifdef __cplusplusextern "C" {#endif -#include <rte_service.h> -/** * Signature of callback function to run a service. *
lib/eal/include/rte_stdatomic.h +1 -4
@@ -7,10 +7,6 @@#include <assert.h> -#ifdef __cplusplus -extern "C" { -#endif -#ifdef RTE_ENABLE_STDATOMIC #ifndef _MSC_VER#ifdef __STDC_NO_ATOMICS__
@@ -188,6 +184,7 @@ typedef int rte_memory_order;#endif #ifdef __cplusplus +extern "C" { }#endif
lib/eal/include/rte_string_fns.h +12 -5
@@ -11,10 +11,6 @@#ifndef _RTE_STRING_FNS_H_#define _RTE_STRING_FNS_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <ctype.h> #include <stdio.h> #include <string.h>
@@ -22,6 +18,10 @@ extern "C" {#include <rte_common.h> #include <rte_compat.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Takes string "string" parameter and splits it at character "delim" * up to maxtokens-1 times - to give "maxtokens" resulting tokens. Like
@@ -77,6 +77,10 @@ rte_strlcat(char *dst, const char *src, size_t size)return l +strlen (src); } +#ifdef __cplusplus +} +#endif +/* pull in a strlcpy function */ #ifdef RTE_EXEC_ENV_FREEBSD #ifndef __BSD_VISIBLE/* non-standard functions are hidden */
@@ -95,6 +99,10 @@ rte_strlcat(char *dst, const char *src, size_t size)#endif /* RTE_USE_LIBBSD */ #endif /* FREEBSD */ +#ifdef __cplusplus +extern "C" { +#endif +/** * Copy string src to buffer dst of size dsize. * At most dsize-1 chars will be copied.
@@ -141,7 +149,6 @@ rte_str_skip_leading_spaces(const char *src)return p; } - #ifdef __cplusplus }#endif
lib/eal/include/rte_tailq.h +3 -3
@@ -10,13 +10,13 @@* Here defines rte_tailq APIs for only internal use */ +#include <stdio.h> +#include <rte_debug.h> +#ifdef __cplusplusextern "C" {#endif -#include <stdio.h> -#include <rte_debug.h> -/** dummy structure type used by the rte_tailq APIs */ struct rte_tailq_entry {RTE_TAILQ_ENTRY (rte_tailq_entry) next;/**< Pointer entries for a tailq list */
lib/eal/include/rte_ticketlock.h +4 -4
@@ -17,15 +17,15 @@* All locks must be initialised before use, and only initialised once. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_common.h> #include <rte_lcore.h> #include <rte_pause.h> #include <rte_stdatomic.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * The rte_ticketlock_t type. */
lib/eal/include/rte_time.h +3 -3
@@ -5,13 +5,13 @@ #ifndef _RTE_TIME_H_ #define _RTE_TIME_H_ +#include <stdint.h> +#include <time.h> + #ifdef __cplusplus extern "C" { #endif -#include <stdint.h> -#include <time.h> - #define NSEC_PER_SEC 1000000000L /**
lib/eal/include/rte_trace.h +4 -4
@@ -16,16 +16,16 @@* @b EXPERIMENTAL: this API may change without prior notice */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdbool.h> #include <stdio.h> #include <rte_common.h> #include <rte_compat.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Test if trace is enabled. *
lib/eal/include/rte_trace_point.h +4 -4
@@ -16,10 +16,6 @@* @b EXPERIMENTAL: this API may change without prior notice */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdbool.h> #include <stdio.h>
@@ -32,6 +28,10 @@ extern "C" {#include <rte_string_fns.h> #include <rte_uuid.h> +#ifdef __cplusplus +extern "C" { +#endif +/** The tracepoint object. */ typedef RTE_ATOMIC (uint64_t )rte_trace_point_t ;
lib/eal/include/rte_trace_point_register.h +4 -4
@@ -5,10 +5,6 @@#ifndef _RTE_TRACE_POINT_REGISTER_H_#define _RTE_TRACE_POINT_REGISTER_H_ -#ifdef __cplusplus -extern "C" { -#endif -#ifdef _RTE_TRACE_POINT_H_#error for registration, include this file first before <rte_trace_point.h>#endif
@@ -16,6 +12,10 @@ extern "C" {#include <rte_per_lcore.h> #include <rte_trace_point.h> +#ifdef __cplusplus +extern "C" { +#endif + RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz);#define RTE_TRACE_POINT_REGISTER (trace, name) \
lib/eal/include/rte_uuid.h +4 -4
@@ -10,14 +10,14 @@ #ifndef _RTE_UUID_H_ #define _RTE_UUID_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <stdbool.h> #include <stddef.h> #include <string.h> +#ifdef __cplusplus +extern "C" { +#endif + /** * Struct describing a Universal Unique Identifier */
lib/eal/include/rte_version.h +3 -3
@@ -10,13 +10,13 @@ #ifndef _RTE_VERSION_H_ #define _RTE_VERSION_H_ +#include <string.h> +#include <stdio.h> + #ifdef __cplusplus extern "C" { #endif -#include <string.h> -#include <stdio.h> - /** * Macro to compute a version number usable for comparisons */
lib/eal/include/rte_vfio.h +4 -4
@@ -10,10 +10,6 @@* RTE VFIO. This library provides various VFIO related utility functions. */ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdbool.h> #include <stdint.h>
@@ -32,6 +28,10 @@ extern "C" {#endif /* kernel version >= 4.0.0 */ #endif /* RTE_EAL_VFIO */ +#ifdef __cplusplus +extern "C" { +#endif +#ifdef VFIO_PRESENT #include <linux/vfio.h>
lib/eal/linux/include/rte_os.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_OS_H_#define _RTE_OS_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * This header should contain any definition * which is not supported natively or named differently in Linux.
@@ -46,8 +42,4 @@ typedef cpu_set_t rte_cpuset_t; } while (0)#endif -#ifdef __cplusplus -} -#endif -#endif /* _RTE_OS_H_ */
lib/eal/loongarch/include/rte_atomic.h +3 -3
@@ -9,13 +9,13 @@# error Platform must be built with RTE_FORCE_INTRINSICS#endif +#include <rte_common.h> +#include "generic/rte_atomic.h" +#ifdef __cplusplusextern "C" {#endif -#include <rte_common.h> -#include "generic/rte_atomic.h" -#define rte_mb () do { asm volatile("dbar 0":::"memory"); } while (0)#define rte_wmb () rte_mb()
lib/eal/loongarch/include/rte_byteorder.h +2 -2
@@ -5,12 +5,12 @@ #ifndef RTE_BYTEORDER_LOONGARCH_H #define RTE_BYTEORDER_LOONGARCH_H +#include "generic/rte_byteorder.h" + #ifdef __cplusplus extern "C" { #endif -#include "generic/rte_byteorder.h" - #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN #define rte_cpu_to_le_16(x) (x)
lib/eal/loongarch/include/rte_cpuflags.h +0 -8
@@ -5,10 +5,6 @@#ifndef RTE_CPUFLAGS_LOONGARCH_H #define RTE_CPUFLAGS_LOONGARCH_H -#ifdef __cplusplus -extern "C" { -#endif -/** * Enumeration of all CPU features supported */
@@ -30,8 +26,4 @@ enum rte_cpu_flag_t {#include "generic/rte_cpuflags.h" -#ifdef __cplusplus -} -#endif -#endif /* RTE_CPUFLAGS_LOONGARCH_H */
lib/eal/loongarch/include/rte_cycles.h +2 -2
@@ -5,12 +5,12 @@ #ifndef RTE_CYCLES_LOONGARCH_H #define RTE_CYCLES_LOONGARCH_H +#include "generic/rte_cycles.h" + #ifdef __cplusplus extern "C" { #endif -#include "generic/rte_cycles.h" - /** * Read the time base register. *
lib/eal/loongarch/include/rte_io.h +0 -8
@@ -5,14 +5,6 @@#ifndef RTE_IO_LOONGARCH_H #define RTE_IO_LOONGARCH_H -#ifdef __cplusplus -extern "C" { -#endif -#include "generic/rte_io.h" -#ifdef __cplusplus -} -#endif -#endif /* RTE_IO_LOONGARCH_H */
lib/eal/loongarch/include/rte_memcpy.h +2 -2
@@ -10,12 +10,12 @@#include "rte_common.h" +#include "generic/rte_memcpy.h" +#ifdef __cplusplusextern "C" {#endif -#include "generic/rte_memcpy.h" -static inline void rte_mov16 (uint8_t *dst,const uint8_t *src) {
lib/eal/loongarch/include/rte_pause.h +4 -4
@@ -5,14 +5,14 @@ #ifndef RTE_PAUSE_LOONGARCH_H #define RTE_PAUSE_LOONGARCH_H -#ifdef __cplusplus -extern "C" { -#endif - #include "rte_atomic.h" #include "generic/rte_pause.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void rte_pause(void) { }
lib/eal/loongarch/include/rte_power_intrinsics.h +0 -8
@@ -5,16 +5,8 @@#ifndef RTE_POWER_INTRINSIC_LOONGARCH_H #define RTE_POWER_INTRINSIC_LOONGARCH_H -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_common.h> #include "generic/rte_power_intrinsics.h" -#ifdef __cplusplus -} -#endif -#endif /* RTE_POWER_INTRINSIC_LOONGARCH_H */
lib/eal/loongarch/include/rte_prefetch.h +4 -4
@@ -5,14 +5,14 @@ #ifndef RTE_PREFETCH_LOONGARCH_H #define RTE_PREFETCH_LOONGARCH_H -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_compat.h> #include <rte_common.h> #include "generic/rte_prefetch.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void rte_prefetch0(const volatile void *p) { __builtin_prefetch((const void *)(uintptr_t)p, 0, 3);
lib/eal/loongarch/include/rte_rwlock.h +2 -2
@@ -5,12 +5,12 @@ #ifndef RTE_RWLOCK_LOONGARCH_H #define RTE_RWLOCK_LOONGARCH_H +#include "generic/rte_rwlock.h" + #ifdef __cplusplus extern "C" { #endif -#include "generic/rte_rwlock.h" - static inline void rte_rwlock_read_lock_tm(rte_rwlock_t *rwl) {
lib/eal/loongarch/include/rte_spinlock.h +3 -3
@@ -5,13 +5,13 @@ #ifndef RTE_SPINLOCK_LOONGARCH_H #define RTE_SPINLOCK_LOONGARCH_H +#include <rte_common.h> +#include "generic/rte_spinlock.h" + #ifdef __cplusplus extern "C" { #endif -#include <rte_common.h> -#include "generic/rte_spinlock.h" - #ifndef RTE_FORCE_INTRINSICS # error Platform must be built with RTE_FORCE_INTRINSICS #endif
lib/eal/ppc/include/rte_atomic.h +3 -3
@@ -12,13 +12,13 @@ #ifndef _RTE_ATOMIC_PPC_64_H_ #define _RTE_ATOMIC_PPC_64_H_ +#include <stdint.h> +#include "generic/rte_atomic.h" + #ifdef __cplusplus extern "C" { #endif -#include <stdint.h> -#include "generic/rte_atomic.h" - #define rte_mb() asm volatile("sync" : : : "memory") #define rte_wmb() asm volatile("sync" : : : "memory")
lib/eal/ppc/include/rte_byteorder.h +3 -3
@@ -8,13 +8,13 @@ #ifndef _RTE_BYTEORDER_PPC_64_H_ #define _RTE_BYTEORDER_PPC_64_H_ +#include <stdint.h> +#include "generic/rte_byteorder.h" + #ifdef __cplusplus extern "C" { #endif -#include <stdint.h> -#include "generic/rte_byteorder.h" - /* * An architecture-optimized byte swap for a 16-bit value. *
lib/eal/ppc/include/rte_cpuflags.h +0 -8
@@ -6,10 +6,6 @@#ifndef _RTE_CPUFLAGS_PPC_64_H_#define _RTE_CPUFLAGS_PPC_64_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * Enumeration of all CPU features supported */
@@ -52,8 +48,4 @@ enum rte_cpu_flag_t {#include "generic/rte_cpuflags.h" -#ifdef __cplusplus -} -#endif -#endif /* _RTE_CPUFLAGS_PPC_64_H_ */
lib/eal/ppc/include/rte_cycles.h +4 -4
@@ -6,10 +6,6 @@#ifndef _RTE_CYCLES_PPC_64_H_#define _RTE_CYCLES_PPC_64_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <features.h> #ifdef __GLIBC__#include <sys/platform/ppc.h>
@@ -20,6 +16,10 @@ extern "C" {#include <rte_byteorder.h> #include <rte_common.h> +#ifdef __cplusplus +extern "C" { +#endif +/** * Read the time base register. *
lib/eal/ppc/include/rte_io.h +0 -8
@@ -5,14 +5,6 @@#ifndef _RTE_IO_PPC_64_H_#define _RTE_IO_PPC_64_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include "generic/rte_io.h" -#ifdef __cplusplus -} -#endif -#endif /* _RTE_IO_PPC_64_H_ */
lib/eal/ppc/include/rte_memcpy.h +2 -2
@@ -12,12 +12,12 @@#include "rte_altivec.h" #include "rte_common.h" +#include "generic/rte_memcpy.h" +#ifdef __cplusplusextern "C" {#endif -#include "generic/rte_memcpy.h" -#if defined(RTE_TOOLCHAIN_GCC ) && (GCC_VERSION >=90000 )#pragma GCC diagnostic push#pragma GCC diagnostic ignored "-Warray-bounds"
lib/eal/ppc/include/rte_pause.h +4 -4
@@ -5,14 +5,14 @@ #ifndef _RTE_PAUSE_PPC64_H_ #define _RTE_PAUSE_PPC64_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "rte_atomic.h" #include "generic/rte_pause.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void rte_pause(void) { /* Set hardware multi-threading low priority */
lib/eal/ppc/include/rte_power_intrinsics.h +0 -8
@@ -5,16 +5,8 @@#ifndef _RTE_POWER_INTRINSIC_PPC_H_#define _RTE_POWER_INTRINSIC_PPC_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <rte_common.h> #include "generic/rte_power_intrinsics.h" -#ifdef __cplusplus -} -#endif -#endif /* _RTE_POWER_INTRINSIC_PPC_H_ */
lib/eal/ppc/include/rte_prefetch.h +4 -4
@@ -6,14 +6,14 @@ #ifndef _RTE_PREFETCH_PPC_64_H_ #define _RTE_PREFETCH_PPC_64_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_compat.h> #include <rte_common.h> #include "generic/rte_prefetch.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void rte_prefetch0(const volatile void *p) { asm volatile ("dcbt 0,%[p],0" : : [p] "r" (p));
lib/eal/ppc/include/rte_rwlock.h +2 -2
@@ -3,12 +3,12 @@ #ifndef _RTE_RWLOCK_PPC_64_H_ #define _RTE_RWLOCK_PPC_64_H_ +#include "generic/rte_rwlock.h" + #ifdef __cplusplus extern "C" { #endif -#include "generic/rte_rwlock.h" - static inline void rte_rwlock_read_lock_tm(rte_rwlock_t *rwl) {
lib/eal/ppc/include/rte_spinlock.h +4 -4
@@ -6,14 +6,14 @@ #ifndef _RTE_SPINLOCK_PPC_64_H_ #define _RTE_SPINLOCK_PPC_64_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_common.h> #include <rte_pause.h> #include "generic/rte_spinlock.h" +#ifdef __cplusplus +extern "C" { +#endif + /* Fixme: Use intrinsics to implement the spinlock on Power architecture */ #ifndef RTE_FORCE_INTRINSICS
lib/eal/riscv/include/rte_atomic.h +4 -4
@@ -12,15 +12,15 @@# 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" +#ifdef __cplusplus +extern "C" { +#endif +#define rte_mb () asm volatile("fence rw, rw" : : : "memory")#define rte_wmb () asm volatile("fence w, w" : : : "memory")
lib/eal/riscv/include/rte_byteorder.h +4 -4
@@ -8,14 +8,14 @@ #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" +#ifdef __cplusplus +extern "C" { +#endif + #ifndef RTE_BYTE_ORDER #define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN #endif
lib/eal/riscv/include/rte_cpuflags.h +0 -8
@@ -8,10 +8,6 @@#ifndef RTE_CPUFLAGS_RISCV_H #define RTE_CPUFLAGS_RISCV_H -#ifdef __cplusplus -extern "C" { -#endif -/** * Enumeration of all CPU features supported */
@@ -46,8 +42,4 @@ enum rte_cpu_flag_t {#include "generic/rte_cpuflags.h" -#ifdef __cplusplus -} -#endif -#endif /* RTE_CPUFLAGS_RISCV_H */
lib/eal/riscv/include/rte_cycles.h +2 -2
@@ -8,12 +8,12 @@ #ifndef RTE_CYCLES_RISCV_H #define RTE_CYCLES_RISCV_H +#include "generic/rte_cycles.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
lib/eal/riscv/include/rte_io.h +0 -8
@@ -8,14 +8,6 @@#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_memcpy.h +2 -2
@@ -12,12 +12,12 @@#include "rte_common.h" +#include "generic/rte_memcpy.h" +#ifdef __cplusplusextern "C" {#endif -#include "generic/rte_memcpy.h" -static inline void rte_mov16 (uint8_t *dst,const uint8_t *src) {
lib/eal/riscv/include/rte_pause.h +4 -4
@@ -7,14 +7,14 @@ #ifndef RTE_PAUSE_RISCV_H #define RTE_PAUSE_RISCV_H -#ifdef __cplusplus -extern "C" { -#endif - #include "rte_atomic.h" #include "generic/rte_pause.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void rte_pause(void) { /* Insert pause hint directly to be compatible with old compilers.
lib/eal/riscv/include/rte_power_intrinsics.h +0 -8
@@ -7,16 +7,8 @@#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 +4 -4
@@ -8,14 +8,14 @@ #ifndef RTE_PREFETCH_RISCV_H #define RTE_PREFETCH_RISCV_H -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_compat.h> #include <rte_common.h> #include "generic/rte_prefetch.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void rte_prefetch0(const volatile void *p) { RTE_SET_USED(p);
lib/eal/riscv/include/rte_rwlock.h +2 -2
@@ -7,12 +7,12 @@ #ifndef RTE_RWLOCK_RISCV_H #define RTE_RWLOCK_RISCV_H +#include "generic/rte_rwlock.h" + #ifdef __cplusplus extern "C" { #endif -#include "generic/rte_rwlock.h" - static inline void rte_rwlock_read_lock_tm(rte_rwlock_t *rwl) {
lib/eal/riscv/include/rte_spinlock.h +3 -3
@@ -12,13 +12,13 @@# error Platform must be built with RTE_FORCE_INTRINSICS#endif +#include <rte_common.h> +#include "generic/rte_spinlock.h" +#ifdef __cplusplusextern "C" {#endif -#include <rte_common.h> -#include "generic/rte_spinlock.h" -static inline int rte_tm_supported (void ) {return 0 ;
lib/eal/windows/include/pthread.h +3 -3
@@ -13,13 +13,13 @@* eal_common_thread.c and common\include\rte_per_lcore.h as Microsoft libc * does not contain pthread.h. This may be removed in future releases. */ +#include <rte_common.h> +#include <rte_windows.h> +#ifdef __cplusplusextern "C" {#endif -#include <rte_common.h> -#include <rte_windows.h> -#define PTHREAD_BARRIER_SERIAL_THREAD TRUE/* defining pthread_t type on Windows since there is no in Microsoft libc*/
lib/eal/windows/include/regex.h +4 -4
@@ -10,15 +10,15 @@* as Microsoft libc does not contain regex.h. This may be removed in * future releases. */ -#ifdef __cplusplus -extern "C" { -#endif -#define REG_NOMATCH 1#define REG_ESPACE 12#include <rte_common.h> +#ifdef __cplusplus +extern "C" { +#endif +/* defining regex_t for Windows */ typedef void *regex_t ;/* defining regmatch_t for Windows */
lib/eal/windows/include/rte_os.h +0 -8
@@ -16,10 +16,6 @@#include <sched.h> -#ifdef __cplusplus -extern "C" { -#endif -/* These macros are compatible with bundled sys/queue.h. */ #define RTE_TAILQ_HEAD (name, type) \ struct name { \
@@ -59,8 +55,4 @@ struct { \*/ typedef long long ssize_t ; -#ifdef __cplusplus -} -#endif -#endif /* _RTE_OS_H_ */
lib/eal/windows/include/rte_windows.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_WINDOWS_H_#define _RTE_WINDOWS_H_ -#ifdef __cplusplus -extern "C" { -#endif -/** * @file Windows-specific facilities *
@@ -51,8 +47,4 @@ extern "C" {RTE_LOG_LINE_PREFIX (DEBUG ,EAL , \ "GetLastError()=%lu: ", GetLastError(), __VA_ARGS__) -#ifdef __cplusplus -} -#endif -#endif /* _RTE_WINDOWS_H_ */
lib/eal/x86/include/rte_atomic.h +17 -8
@@ -5,10 +5,6 @@#ifndef _RTE_ATOMIC_X86_H_#define _RTE_ATOMIC_X86_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include <stdint.h> #include <rte_common.h> #include <rte_config.h>
@@ -31,6 +27,10 @@ extern "C" {#define rte_smp_rmb () rte_compiler_barrier() +#ifdef __cplusplus +extern "C" { +#endif +/* * From Intel Software Development Manual; Vol 3; * 8.2.2 Memory Ordering in P6 and More Recent Processor Families:
@@ -99,10 +99,18 @@ rte_atomic_thread_fence(rte_memory_order memorder)__rte_atomic_thread_fence (memorder); } +#ifdef __cplusplus +} +#endif + #ifndef RTE_TOOLCHAIN_MSVC /*------------------------- 16 bit atomic operations -------------------------*/ +#ifdef __cplusplus +extern "C" { +#endif + #ifndef RTE_FORCE_INTRINSICS static inline int rte_atomic16_cmpset(volatile uint16_t *dst, uint16_t exp, uint16_t src)
@@ -273,6 +281,11 @@ static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v) );return ret !=0 ; } + +#ifdef __cplusplus +} +#endif +#endif #ifdef RTE_ARCH_I686
@@ -283,8 +296,4 @@ static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v)#endif -#ifdef __cplusplus -} -#endif -#endif /* _RTE_ATOMIC_X86_H_ */
lib/eal/x86/include/rte_byteorder.h +8 -8
@@ -5,15 +5,15 @@ #ifndef _RTE_BYTEORDER_X86_H_ #define _RTE_BYTEORDER_X86_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <stdint.h> #include <rte_common.h> #include <rte_config.h> #include "generic/rte_byteorder.h" +#ifdef __cplusplus +extern "C" { +#endif + #ifndef RTE_BYTE_ORDER #define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN #endif
@@ -48,6 +48,10 @@ static inline uint32_t rte_arch_bswap32(uint32_t _x)return x; } +#ifdef __cplusplus +} +#endif +#define rte_bswap16 (x) ((uint16_t)(__builtin_constant_p(x) ? \ rte_constant_bswap16(x) : \ rte_arch_bswap16(x)))
@@ -83,8 +87,4 @@ static inline uint32_t rte_arch_bswap32(uint32_t _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_X86_H_ */
lib/eal/x86/include/rte_cpuflags.h +0 -8
@@ -5,10 +5,6 @@#ifndef _RTE_CPUFLAGS_X86_64_H_#define _RTE_CPUFLAGS_X86_64_H_ -#ifdef __cplusplus -extern "C" { -#endif -enum rte_cpu_flag_t {/* (EAX 01h) ECX features*/ RTE_CPUFLAG_SSE3 = 0, /**< SSE3 */
@@ -138,8 +134,4 @@ enum rte_cpu_flag_t {#include "generic/rte_cpuflags.h" -#ifdef __cplusplus -} -#endif -#endif /* _RTE_CPUFLAGS_X86_64_H_ */
lib/eal/x86/include/rte_cycles.h +4 -4
@@ -12,10 +12,6 @@#include <x86intrin.h> #endif -#ifdef __cplusplus -extern "C" { -#endif -#include "generic/rte_cycles.h" #ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT
@@ -26,6 +22,10 @@ extern int rte_cycles_vmware_tsc_map;#include <rte_common.h> #include <rte_config.h> +#ifdef __cplusplus +extern "C" { +#endif +static inline uint64_t rte_rdtsc (void ) {
lib/eal/x86/include/rte_io.h +4 -4
@@ -5,16 +5,16 @@ #ifndef _RTE_IO_X86_H_ #define _RTE_IO_X86_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include <rte_compat.h> #include "rte_cpuflags.h" #define RTE_NATIVE_WRITE32_WC #include "generic/rte_io.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * @internal * MOVDIRI wrapper.
lib/eal/x86/include/rte_pause.h +4 -3
@@ -5,13 +5,14 @@#ifndef _RTE_PAUSE_X86_H_#define _RTE_PAUSE_X86_H_ +#include "generic/rte_pause.h" + +#include <emmintrin.h>
Lines of this file are not shown. View the raw message.
lib/eal/x86/include/rte_power_intrinsics.h +0 -8
Lines of this file are not shown. View the raw message.
lib/eventdev/rte_event_crypto_adapter.h +4 -4
Lines of this file are not shown. View the raw message.
lib/eventdev/rte_event_eth_rx_adapter.h +4 -4
Lines of this file are not shown. View the raw message.
lib/eventdev/rte_event_eth_tx_adapter.h +4 -4
Lines of this file are not shown. View the raw message.
lib/graph/rte_graph_model_mcore_dispatch.h +4 -4
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
PATCH v10 3/7 eal: extend bit manipulation functionality
In reply to Mattias RönnblomAdd functionality to test and modify the value of individual bits in 32-bit or 64-bit words.
These functions have no implications on memory ordering, atomicity and does not use volatile and thus does not prevent any compiler optimizations.
--
PATCH v3:
* Remove unnecessary <rte_compat.h> include.
* Remove redundant 'fun' parameter from the __RTE_GEN_BIT_*() macros (Jack Bond-Preston).
* Introduce __RTE_BIT_BIT_OPS() macro, consistent with how things are done when generating the atomic bit operations.
* Refer to volatile bit op functions as variants instead of families (macro parameter naming).
RFC v6:
* Have rte_bit_test() accept const-marked bitsets.
RFC v4:
* Add rte_bit_flip() which, believe it or not, flips the value of a bit.
* Mark macro-generated private functions as experimental.
* Use macros to generate *assign*() functions.
RFC v3:
* Work around lack of C++ support for _Generic (Tyler Retzlaff).
* Fix ','-related checkpatch warnings.
--- lib/eal/include/rte_bitops.h | 260 ++++++++++++++++++++++++++++++++++- 1 file changed, 258 insertions(+), 2 deletions(-)
lib/eal/include/rte_bitops.h +258 -2
@@ -2,6 +2,7 @@* Copyright(c) 2020 Arm Limited * Copyright(c) 2010-2019 Intel Corporation * Copyright(c) 2023 Microsoft Corporation +* Copyright(c) 2024 Ericsson AB */ #ifndef _RTE_BITOPS_H_
@@ -11,12 +12,14 @@* @file * Bit Operations * -* This file defines a family of APIs for bit operations -* without enforcing memory ordering. +* This file provides functionality for low-level, single-word +* arithmetic and bit-level operations, such as counting or +* setting individual bits. */ #include <stdint.h> +#include <rte_compat.h> #include <rte_debug.h> #ifdef __cplusplus
@@ -105,6 +108,197 @@ extern "C" {#define RTE_FIELD_GET64 (mask, reg) \ ((typeof(mask))(((reg) & (mask)) >> rte_ctz64(mask))) +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Test bit in word. +* +* Generic selection macro to test the value of a bit in a 32-bit or +* 64-bit word. The type of operation depends on the type of the @c +* addr parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_test (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_test32, \ + const uint32_t *: __rte_bit_test32, \ + uint64_t *: __rte_bit_test64, \ + const uint64_t *: __rte_bit_test64)(addr, nr) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Set bit in word. +* +* Generic selection macro to set a bit in a 32-bit or 64-bit +* word. The type of operation depends on the type of the @c addr +* parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_set (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_set32, \ + uint64_t *: __rte_bit_set64)(addr, nr) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Clear bit in word. +* +* Generic selection macro to clear a bit in a 32-bit or 64-bit +* word. The type of operation depends on the type of the @c addr +* parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_clear (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_clear32, \ + uint64_t *: __rte_bit_clear64)(addr, nr) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Assign a value to a bit in word. +* +* Generic selection macro to assign a value to a bit in a 32-bit or 64-bit +* word. The type of operation depends on the type of the @c addr parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +* @param value +* The new value of the bit - true for '1', or false for '0'. +*/ +#define rte_bit_assign (addr, nr, value) \ + _Generic((addr), \ + uint32_t *: __rte_bit_assign32, \ + uint64_t *: __rte_bit_assign64)(addr, nr, value) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Flip a bit in word. +* +* Generic selection macro to change the value of a bit to '0' if '1' +* or '1' if '0' in a 32-bit or 64-bit word. The type of operation +* depends on the type of the @c addr parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_flip (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_flip32, \ + uint64_t *: __rte_bit_flip64)(addr, nr) + +#define __RTE_GEN_BIT_TEST (variant, qualifier, size) \ + __rte_experimental \ + static inline bool \ + __rte_bit_ ## variant ## test ## size(const qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = (uint ## size ## _t)1 << nr; \ + return *addr & mask; \ + } + +#define __RTE_GEN_BIT_SET (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## set ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = (uint ## size ## _t)1 << nr; \ + *addr |= mask; \ + } \ + +#define __RTE_GEN_BIT_CLEAR (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## clear ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = ~((uint ## size ## _t)1 << nr); \ + (*addr) &= mask; \ + } \ + +#define __RTE_GEN_BIT_ASSIGN (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## assign ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr, bool value) \ + { \ + if (value) \ + __rte_bit_ ## variant ## set ## size(addr, nr); \ + else \ + __rte_bit_ ## variant ## clear ## size(addr, nr); \ + } + +#define __RTE_GEN_BIT_FLIP (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## flip ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + bool value; \ + \ + value = __rte_bit_ ## variant ## test ## size(addr, nr); \ + __rte_bit_ ## variant ## assign ## size(addr, nr, !value); \ + } + +#define __RTE_GEN_BIT_OPS (v, qualifier, size) \ + __RTE_GEN_BIT_TEST(v, qualifier, size) \ + __RTE_GEN_BIT_SET(v, qualifier, size) \ + __RTE_GEN_BIT_CLEAR(v, qualifier, size) \ + __RTE_GEN_BIT_ASSIGN(v, qualifier, size) \ + __RTE_GEN_BIT_FLIP(v, qualifier, size) + +#define __RTE_GEN_BIT_OPS_SIZE (size) \ + __RTE_GEN_BIT_OPS(,, size) + +__RTE_GEN_BIT_OPS_SIZE(32) +__RTE_GEN_BIT_OPS_SIZE (64 ) +/*------------------------ 32-bit relaxed operations ------------------------*/ /**
@@ -787,6 +981,68 @@ rte_log2_u64(uint64_t v)#ifdef __cplusplus } + +/* +* Since C++ doesn't support generic selection (i.e., _Generic), +* function overloading is used instead. Such functions must be +* defined outside 'extern "C"' to be accepted by the compiler. +*/ + +#undef rte_bit_test +#undef rte_bit_set +#undef rte_bit_clear +#undef rte_bit_assign +#undef rte_bit_flip + +#define __RTE_BIT_OVERLOAD_SZ_2 (fun, qualifier, size, arg1_type, arg1_name) \ + static inline void \ + rte_bit_ ## fun(qualifier uint ## size ## _t *addr, \ + arg1_type arg1_name) \ + { \ + __rte_bit_ ## fun ## size(addr, arg1_name); \ + } + +#define __RTE_BIT_OVERLOAD_2 (fun, qualifier, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2(fun, qualifier, 32, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2(fun, qualifier, 64, arg1_type, arg1_name) + +#define __RTE_BIT_OVERLOAD_SZ_2R (fun, qualifier, size, ret_type, arg1_type, \ + arg1_name) \ + static inline ret_type \ + rte_bit_ ## fun(qualifier uint ## size ## _t *addr, \ + arg1_type arg1_name) \ + { \ + return __rte_bit_ ## fun ## size(addr, arg1_name); \ + } + +#define __RTE_BIT_OVERLOAD_2R (fun, qualifier, ret_type, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2R(fun, qualifier, 32, ret_type, arg1_type, \ + arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2R(fun, qualifier, 64, ret_type, arg1_type, \ + arg1_name) + +#define __RTE_BIT_OVERLOAD_SZ_3 (fun, qualifier, size, arg1_type, arg1_name, \ + arg2_type, arg2_name) \ + static inline void \ + rte_bit_ ## fun(uint ## size ## _t *addr, arg1_type arg1_name, \ + arg2_type arg2_name) \ + { \ + __rte_bit_ ## fun ## size(addr, arg1_name, arg2_name); \ + } + +#define __RTE_BIT_OVERLOAD_3 (fun, qualifier, arg1_type, arg1_name, arg2_type, \ + arg2_name) \ + __RTE_BIT_OVERLOAD_SZ_3(fun, qualifier, 32, arg1_type, arg1_name, \ + arg2_type, arg2_name) \ + __RTE_BIT_OVERLOAD_SZ_3(fun, qualifier, 64, arg1_type, arg1_name, \ + arg2_type, arg2_name) + +__RTE_BIT_OVERLOAD_2R(test, const, bool, unsigned int, nr) +__RTE_BIT_OVERLOAD_2(set,, unsigned int, nr) +__RTE_BIT_OVERLOAD_2(clear,, unsigned int, nr) +__RTE_BIT_OVERLOAD_3(assign,, unsigned int, nr, bool, value) +__RTE_BIT_OVERLOAD_2(flip,, unsigned int, nr) +#endif #endif /* _RTE_BITOPS_H_ */
Signature · 1 line
2.34.1
PATCH v10 4/7 eal: add unit tests for bit operations
In reply to Mattias RönnblomExtend bitops tests to cover the
rte_bit_[test|set|clear|assign|flip]()
functions.
The tests are converted to use the test suite runner framework.
--
RFC v6:
* Test rte_bit_*test() usage through const pointers.
RFC v4:
* Remove redundant line continuations.
--- app/test/test_bitops.c | 85 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 15 deletions(-)
app/test/test_bitops.c +70 -15
@@ -1,13 +1,68 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2019 Arm Limited +* Copyright(c) 2024 Ericsson AB */ +#include <stdbool.h> +#include <rte_launch.h> #include <rte_bitops.h> +#include <rte_random.h> #include "test.h" -uint32_t val32; -uint64_t val64; +#define GEN_TEST_BIT_ACCESS (test_name, set_fun, clear_fun, assign_fun, \ + flip_fun, test_fun, size) \ + static int \ + test_name(void) \ + { \ + uint ## size ## _t reference = (uint ## size ## _t)rte_rand(); \ + unsigned int bit_nr; \ + uint ## size ## _t word = (uint ## size ## _t)rte_rand(); \ + \ + for (bit_nr = 0; bit_nr < size; bit_nr++) { \ + bool reference_bit = (reference >> bit_nr) & 1; \ + bool assign = rte_rand() & 1; \ + if (assign) \ + assign_fun(&word, bit_nr, reference_bit); \ + else { \ + if (reference_bit) \ + set_fun(&word, bit_nr); \ + else \ + clear_fun(&word, bit_nr); \ + \ + } \ + TEST_ASSERT(test_fun(&word, bit_nr) == reference_bit, \ + "Bit %d had unexpected value", bit_nr); \ + flip_fun(&word, bit_nr); \ + TEST_ASSERT(test_fun(&word, bit_nr) != reference_bit, \ + "Bit %d had unflipped value", bit_nr); \ + flip_fun(&word, bit_nr); \ + \ + const uint ## size ## _t *const_ptr = &word; \ + TEST_ASSERT(test_fun(const_ptr, bit_nr) == \ + reference_bit, \ + "Bit %d had unexpected value", bit_nr); \ + } \ + \ + for (bit_nr = 0; bit_nr < size; bit_nr++) { \ + bool reference_bit = (reference >> bit_nr) & 1; \ + TEST_ASSERT(test_fun(&word, bit_nr) == reference_bit, \ + "Bit %d had unexpected value", bit_nr); \ + } \ + \ + TEST_ASSERT(reference == word, "Word had unexpected value"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_ACCESS (test_bit_access32, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 32) + +GEN_TEST_BIT_ACCESS (test_bit_access64, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 64) + +static uint32_t val32; +static uint64_t val64;#define MAX_BITS_32 32#define MAX_BITS_64 64
@@ -117,22 +172,22 @@ test_bit_relaxed_test_set_clear(void)return TEST_SUCCESS ; } +static struct unit_test_suite test_suite = { + .suite_name ="Bitops test suite" , + .unit_test_cases = { +TEST_CASE (test_bit_access32), +TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_relaxed_set), +TEST_CASE (test_bit_relaxed_clear), +TEST_CASE (test_bit_relaxed_test_set_clear), +TEST_CASES_END () + } +}; +static int test_bitops (void ) { - val32 =0 ; - val64 =0 ; - -if (test_bit_relaxed_set () <0 ) -return TEST_FAILED ; - -if (test_bit_relaxed_clear () <0 ) -return TEST_FAILED ; - -if (test_bit_relaxed_test_set_clear () <0 ) -return TEST_FAILED ; - -return TEST_SUCCESS ; +return unit_test_suite_runner (&test_suite); }REGISTER_FAST_TEST (bitops_autotest, true, true, test_bitops);
Signature · 1 line
2.34.1
PATCH v10 5/7 eal: add atomic bit operations
In reply to Mattias RönnblomAdd atomic bit test/set/clear/assign/flip and
test-and-set/clear/assign/flip functions.
All atomic bit functions allow (and indeed, require) the caller to specify a memory order.
--
PATCH v3:
* Introduce __RTE_GEN_BIT_ATOMIC_*() 'qualifier' argument already in this patch (Jack Bond-Preston).
* Refer to volatile bit op functions as variants instead of families (macro parameter naming).
* Update release notes.
PATCH:
* Add missing macro #undef for C++ version of atomic bit flip.
RFC v7:
* Replace compare-exchange-based rte_bitset_atomic_test_and_*() and flip() with implementations that use the previous value as returned by the atomic fetch function.
* Reword documentation to match the non-atomic macro variants.
* Remove pointer to <rte_stdatomic.h> for memory model documentation, since there is no documentation for that API.
RFC v6:
* Have rte_bit_atomic_test() accept const-marked bitsets.
RFC v4:
* Add atomic bit flip.
* Mark macro-generated private functions experimental.
RFC v3:
* Work around lack of C++ support for _Generic (Tyler Retzlaff).
RFC v2:
o Add rte_bit_atomic_test_and_assign() (for consistency).
o Fix bugs in rte_bit_atomic_test_and_[set|clear]().
o Use <rte_stdatomics.h> to support MSVC.
--- doc/guides/rel_notes/release_24_11.rst | 17 + lib/eal/include/rte_bitops.h | 415 +++++++++++++++++++++++++ 2 files changed, 432 insertions(+)
doc/guides/rel_notes/release_24_11.rst +17 -0
@@ -56,6 +56,23 @@ New Features ======================================================= +* **Extended bit operations API.** + + The support for bit-level operations on single 32- and 64-bit words + in <rte_bitops.h> has been extended with two families of + semantically well-defined functions. + + rte_bit_[test|set|clear|assign|flip]() functions provide excellent + performance (by avoiding restricting the compiler and CPU), but give + no guarantees in regards to memory ordering or atomicity. + + rte_bit_atomic_*() provides atomic bit-level operations, including + the possibility to specifying memory ordering constraints. + + The new public API elements are polymorphic, using the _Generic- + based macros (for C) and function overloading (in C++ translation + units). + Removed Items -------------
lib/eal/include/rte_bitops.h +415 -0
451 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v10 6/7 eal: add unit tests for atomic bit access functions
In reply to Mattias RönnblomExtend bitops tests to cover the rte_bit_atomic_*() family of functions.
--
RFC v4:
* Add atomicity test for atomic bit flip.
RFC v3:
* Rename variable 'main' to make ICC happy.
--- app/test/test_bitops.c | 313 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 312 insertions(+), 1 deletion(-)
app/test/test_bitops.c +312 -1
@@ -3,10 +3,13 @@* Copyright(c) 2024 Ericsson AB */ +#include <inttypes.h> #include <stdbool.h> -#include <rte_launch.h> #include <rte_bitops.h> +#include <rte_cycles.h> +#include <rte_launch.h> +#include <rte_lcore.h> #include <rte_random.h> #include "test.h"
@@ -61,6 +64,304 @@ GEN_TEST_BIT_ACCESS(test_bit_access32, rte_bit_set, rte_bit_clear,GEN_TEST_BIT_ACCESS (test_bit_access64, rte_bit_set, rte_bit_clear, rte_bit_assign, rte_bit_flip, rte_bit_test, 64) +#define bit_atomic_set (addr, nr) \ + rte_bit_atomic_set(addr, nr, rte_memory_order_relaxed) + +#define bit_atomic_clear (addr, nr) \ + rte_bit_atomic_clear(addr, nr, rte_memory_order_relaxed) + +#define bit_atomic_assign (addr, nr, value) \ + rte_bit_atomic_assign(addr, nr, value, rte_memory_order_relaxed) + +#define bit_atomic_flip (addr, nr) \ + rte_bit_atomic_flip(addr, nr, rte_memory_order_relaxed) + +#define bit_atomic_test (addr, nr) \ + rte_bit_atomic_test(addr, nr, rte_memory_order_relaxed) + +GEN_TEST_BIT_ACCESS (test_bit_atomic_access32, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 32) + +GEN_TEST_BIT_ACCESS (test_bit_atomic_access64, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 64) + +#define PARALLEL_TEST_RUNTIME 0.25 + +#define GEN_TEST_BIT_PARALLEL_ASSIGN (size) \ + \ + struct parallel_access_lcore ## size \ + { \ + unsigned int bit; \ + uint ## size ##_t *word; \ + bool failed; \ + }; \ + \ + static int \ + run_parallel_assign ## size(void *arg) \ + { \ + struct parallel_access_lcore ## size *lcore = arg; \ + uint64_t deadline = rte_get_timer_cycles() + \ + PARALLEL_TEST_RUNTIME * rte_get_timer_hz(); \ + bool value = false; \ + \ + do { \ + bool new_value = rte_rand() & 1; \ + bool use_test_and_modify = rte_rand() & 1; \ + bool use_assign = rte_rand() & 1; \ + \ + if (rte_bit_atomic_test(lcore->word, lcore->bit, \ + rte_memory_order_relaxed) != value) { \ + lcore->failed = true; \ + break; \ + } \ + \ + if (use_test_and_modify) { \ + bool old_value; \ + if (use_assign) \ + old_value = rte_bit_atomic_test_and_assign( \ + lcore->word, lcore->bit, new_value, \ + rte_memory_order_relaxed); \ + else { \ + old_value = new_value ? \ + rte_bit_atomic_test_and_set( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed) : \ + rte_bit_atomic_test_and_clear( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + } \ + if (old_value != value) { \ + lcore->failed = true; \ + break; \ + } \ + } else { \ + if (use_assign) \ + rte_bit_atomic_assign(lcore->word, lcore->bit, \ + new_value, \ + rte_memory_order_relaxed); \ + else { \ + if (new_value) \ + rte_bit_atomic_set( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + else \ + rte_bit_atomic_clear( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + } \ + } \ + \ + value = new_value; \ + } while (rte_get_timer_cycles() < deadline); \ + \ + return 0; \ + } \ + \ + static int \ + test_bit_atomic_parallel_assign ## size(void) \ + { \ + unsigned int worker_lcore_id; \ + uint ## size ## _t word = 0; \ + struct parallel_access_lcore ## size lmain = { \ + .word = &word \ + }; \ + struct parallel_access_lcore ## size lworker = { \ + .word = &word \ + }; \ + \ + if (rte_lcore_count() < 2) { \ + printf("Need multiple cores to run parallel test.\n"); \ + return TEST_SKIPPED; \ + } \ + \ + worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + \ + lmain.bit = rte_rand_max(size); \ + do { \ + lworker.bit = rte_rand_max(size); \ + } while (lworker.bit == lmain.bit); \ + \ + int rc = rte_eal_remote_launch(run_parallel_assign ## size, \ + &lworker, worker_lcore_id); \ + TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ + \ + run_parallel_assign ## size(&lmain); \ + \ + rte_eal_mp_wait_lcore(); \ + \ + TEST_ASSERT(!lmain.failed, "Main lcore atomic access failed"); \ + TEST_ASSERT(!lworker.failed, "Worker lcore atomic access " \ + "failed"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_PARALLEL_ASSIGN(32) +GEN_TEST_BIT_PARALLEL_ASSIGN(64) + +#define GEN_TEST_BIT_PARALLEL_TEST_AND_MODIFY (size) \ + \ + struct parallel_test_and_set_lcore ## size \ + { \ + uint ## size ##_t *word; \ + unsigned int bit; \ + uint64_t flips; \ + }; \ + \ + static int \ + run_parallel_test_and_modify ## size(void *arg) \ + { \ + struct parallel_test_and_set_lcore ## size *lcore = arg; \ + uint64_t deadline = rte_get_timer_cycles() + \ + PARALLEL_TEST_RUNTIME * rte_get_timer_hz(); \ + do { \ + bool old_value; \ + bool new_value = rte_rand() & 1; \ + bool use_assign = rte_rand() & 1; \ + \ + if (use_assign) \ + old_value = rte_bit_atomic_test_and_assign( \ + lcore->word, lcore->bit, new_value, \ + rte_memory_order_relaxed); \ + else \ + old_value = new_value ? \ + rte_bit_atomic_test_and_set( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed) : \ + rte_bit_atomic_test_and_clear( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + if (old_value != new_value) \ + lcore->flips++; \ + } while (rte_get_timer_cycles() < deadline); \ + \ + return 0; \ + } \ + \ + static int \ + test_bit_atomic_parallel_test_and_modify ## size(void) \ + { \ + unsigned int worker_lcore_id; \ + uint ## size ## _t word = 0; \ + unsigned int bit = rte_rand_max(size); \ + struct parallel_test_and_set_lcore ## size lmain = { \ + .word = &word, \ + .bit = bit \ + }; \ + struct parallel_test_and_set_lcore ## size lworker = { \ + .word = &word, \ + .bit = bit \ + }; \ + \ + if (rte_lcore_count() < 2) { \ + printf("Need multiple cores to run parallel test.\n"); \ + return TEST_SKIPPED; \ + } \ + \ + worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + \ + int rc = rte_eal_remote_launch(run_parallel_test_and_modify ## size, \ + &lworker, worker_lcore_id); \ + TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ + \ + run_parallel_test_and_modify ## size(&lmain); \ + \ + rte_eal_mp_wait_lcore(); \ + \ + uint64_t total_flips = lmain.flips + lworker.flips; \ + bool expected_value = total_flips % 2; \ + \ + TEST_ASSERT(expected_value == rte_bit_test(&word, bit), \ + "After %"PRId64" flips, the bit value " \ + "should be %d", total_flips, expected_value); \ + \ + uint64_t expected_word = 0; \ + rte_bit_assign(&expected_word, bit, expected_value); \ + \ + TEST_ASSERT(expected_word == word, "Untouched bits have " \ + "changed value"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_PARALLEL_TEST_AND_MODIFY(32) +GEN_TEST_BIT_PARALLEL_TEST_AND_MODIFY(64) + +#define GEN_TEST_BIT_PARALLEL_FLIP (size) \ + \ + struct parallel_flip_lcore ## size \ + { \ + uint ## size ##_t *word; \ + unsigned int bit; \ + uint64_t flips; \ + }; \ + \ + static int \ + run_parallel_flip ## size(void *arg) \ + { \ + struct parallel_flip_lcore ## size *lcore = arg; \ + uint64_t deadline = rte_get_timer_cycles() + \ + PARALLEL_TEST_RUNTIME * rte_get_timer_hz(); \ + do { \ + rte_bit_atomic_flip(lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + lcore->flips++; \ + } while (rte_get_timer_cycles() < deadline); \ + \ + return 0; \ + } \ + \ + static int \ + test_bit_atomic_parallel_flip ## size(void) \ + { \ + unsigned int worker_lcore_id; \ + uint ## size ## _t word = 0; \ + unsigned int bit = rte_rand_max(size); \ + struct parallel_flip_lcore ## size lmain = { \ + .word = &word, \ + .bit = bit \ + }; \ + struct parallel_flip_lcore ## size lworker = { \ + .word = &word, \ + .bit = bit \ + }; \ + \ + if (rte_lcore_count() < 2) { \ + printf("Need multiple cores to run parallel test.\n"); \ + return TEST_SKIPPED; \ + } \ + \ + worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + \ + int rc = rte_eal_remote_launch(run_parallel_flip ## size, \ + &lworker, worker_lcore_id); \ + TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ + \ + run_parallel_flip ## size(&lmain); \ + \ + rte_eal_mp_wait_lcore(); \ + \ + uint64_t total_flips = lmain.flips + lworker.flips; \ + bool expected_value = total_flips % 2; \ + \ + TEST_ASSERT(expected_value == rte_bit_test(&word, bit), \ + "After %"PRId64" flips, the bit value " \ + "should be %d", total_flips, expected_value); \ + \ + uint64_t expected_word = 0; \ + rte_bit_assign(&expected_word, bit, expected_value); \ + \ + TEST_ASSERT(expected_word == word, "Untouched bits have " \ + "changed value"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_PARALLEL_FLIP(32) +GEN_TEST_BIT_PARALLEL_FLIP(64) +static uint32_t val32;static uint64_t val64;
@@ -177,6 +478,16 @@ static struct unit_test_suite test_suite = { .unit_test_cases = {TEST_CASE (test_bit_access32),TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_access32), +TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_atomic_access32), +TEST_CASE (test_bit_atomic_access64), +TEST_CASE (test_bit_atomic_parallel_assign32), +TEST_CASE (test_bit_atomic_parallel_assign64), +TEST_CASE (test_bit_atomic_parallel_test_and_modify32), +TEST_CASE (test_bit_atomic_parallel_test_and_modify64), +TEST_CASE (test_bit_atomic_parallel_flip32), +TEST_CASE (test_bit_atomic_parallel_flip64),TEST_CASE (test_bit_relaxed_set),TEST_CASE (test_bit_relaxed_clear), TEST_CASE(test_bit_relaxed_test_set_clear),
Signature · 1 line
2.34.1
PATCH v10 7/7 eal: extend bitops to handle volatile pointers
In reply to Mattias RönnblomHave rte_bit_[test|set|clear|assign|flip]() and rte_bit_atomic_*() handle volatile-marked pointers.
--
PATCH v3:
* Updated to reflect removed 'fun' parameter in __RTE_GEN_BIT_*() (Jack Bond-Preston).
PATCH v2:
* Actually run the test_bit_atomic_v_access*() test functions.
--- app/test/test_bitops.c | 32 +++- lib/eal/include/rte_bitops.h | 301 +++++++++++++++++++++++------------ 2 files changed, 222 insertions(+), 111 deletions(-)
app/test/test_bitops.c +25 -7
@@ -14,13 +14,13 @@#include "test.h" #define GEN_TEST_BIT_ACCESS (test_name, set_fun, clear_fun, assign_fun, \ - flip_fun, test_fun, size) \ + flip_fun, test_fun, size, mod) \ static int \ test_name(void) \ { \ uint ## size ## _t reference = (uint ## size ## _t)rte_rand(); \ unsigned int bit_nr; \ - uint ## size ## _t word = (uint ## size ## _t)rte_rand(); \ + mod uint ## size ## _t word = (uint ## size ## _t)rte_rand(); \ \ for (bit_nr = 0; bit_nr < size; bit_nr++) { \ bool reference_bit = (reference >> bit_nr) & 1; \
@@ -41,7 +41,7 @@ "Bit %d had unflipped value", bit_nr); \flip_fun (&word, bit_nr); \ \ - const uint ## size ## _t *const_ptr = &word; \ + const mod uint ## size ## _t *const_ptr = &word; \ TEST_ASSERT(test_fun(const_ptr, bit_nr) == \ reference_bit, \ "Bit %d had unexpected value", bit_nr); \
@@ -59,10 +59,16 @@ } GEN_TEST_BIT_ACCESS(test_bit_access32, rte_bit_set, rte_bit_clear, - rte_bit_assign, rte_bit_flip, rte_bit_test, 32) + rte_bit_assign, rte_bit_flip, rte_bit_test, 32,) GEN_TEST_BIT_ACCESS(test_bit_access64, rte_bit_set, rte_bit_clear, - rte_bit_assign, rte_bit_flip, rte_bit_test, 64) + rte_bit_assign, rte_bit_flip, rte_bit_test, 64,) + +GEN_TEST_BIT_ACCESS(test_bit_v_access32, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 32, volatile) + +GEN_TEST_BIT_ACCESS(test_bit_v_access64, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 64, volatile) #define bit_atomic_set(addr, nr) \ rte_bit_atomic_set(addr, nr, rte_memory_order_relaxed)
@@ -81,11 +87,19 @@ GEN_TEST_BIT_ACCESS(test_bit_access64, rte_bit_set, rte_bit_clear, GEN_TEST_BIT_ACCESS(test_bit_atomic_access32, bit_atomic_set, bit_atomic_clear, bit_atomic_assign, - bit_atomic_flip, bit_atomic_test, 32) + bit_atomic_flip, bit_atomic_test, 32,) GEN_TEST_BIT_ACCESS(test_bit_atomic_access64, bit_atomic_set, bit_atomic_clear, bit_atomic_assign, - bit_atomic_flip, bit_atomic_test, 64) + bit_atomic_flip, bit_atomic_test, 64,) + +GEN_TEST_BIT_ACCESS(test_bit_atomic_v_access32, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 32, volatile) + +GEN_TEST_BIT_ACCESS(test_bit_atomic_v_access64, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 64, volatile) #define PARALLEL_TEST_RUNTIME 0.25
@@ -480,8 +494,12 @@ static struct unit_test_suite test_suite = {TEST_CASE (test_bit_access64),TEST_CASE (test_bit_access32),TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_v_access32), +TEST_CASE (test_bit_v_access64),TEST_CASE (test_bit_atomic_access32),TEST_CASE (test_bit_atomic_access64), +TEST_CASE (test_bit_atomic_v_access32), +TEST_CASE (test_bit_atomic_v_access64),TEST_CASE (test_bit_atomic_parallel_assign32),TEST_CASE (test_bit_atomic_parallel_assign64), TEST_CASE(test_bit_atomic_parallel_test_and_modify32),
lib/eal/include/rte_bitops.h +197 -104
440 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v9 2/6 eal: extend bit manipulation functionality
In reply to Mattias RönnblomAdd functionality to test and modify the value of individual bits in 32-bit or 64-bit words.
These functions have no implications on memory ordering, atomicity and does not use volatile and thus does not prevent any compiler optimizations.
--
PATCH v3:
* Remove unnecessary <rte_compat.h> include.
* Remove redundant 'fun' parameter from the __RTE_GEN_BIT_*() macros (Jack Bond-Preston).
* Introduce __RTE_BIT_BIT_OPS() macro, consistent with how things are done when generating the atomic bit operations.
* Refer to volatile bit op functions as variants instead of families (macro parameter naming).
RFC v6:
* Have rte_bit_test() accept const-marked bitsets.
RFC v4:
* Add rte_bit_flip() which, believe it or not, flips the value of a bit.
* Mark macro-generated private functions as experimental.
* Use macros to generate *assign*() functions.
RFC v3:
* Work around lack of C++ support for _Generic (Tyler Retzlaff).
* Fix ','-related checkpatch warnings.
--- lib/eal/include/rte_bitops.h | 260 ++++++++++++++++++++++++++++++++++- 1 file changed, 258 insertions(+), 2 deletions(-)
lib/eal/include/rte_bitops.h +258 -2
@@ -2,6 +2,7 @@* Copyright(c) 2020 Arm Limited * Copyright(c) 2010-2019 Intel Corporation * Copyright(c) 2023 Microsoft Corporation +* Copyright(c) 2024 Ericsson AB */ #ifndef _RTE_BITOPS_H_
@@ -11,12 +12,14 @@* @file * Bit Operations * -* This file defines a family of APIs for bit operations -* without enforcing memory ordering. +* This file provides functionality for low-level, single-word +* arithmetic and bit-level operations, such as counting or +* setting individual bits. */ #include <stdint.h> +#include <rte_compat.h> #include <rte_debug.h> #ifdef __cplusplus
@@ -105,6 +108,197 @@ extern "C" {#define RTE_FIELD_GET64 (mask, reg) \ ((typeof(mask))(((reg) & (mask)) >> rte_ctz64(mask))) +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Test bit in word. +* +* Generic selection macro to test the value of a bit in a 32-bit or +* 64-bit word. The type of operation depends on the type of the @c +* addr parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_test (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_test32, \ + const uint32_t *: __rte_bit_test32, \ + uint64_t *: __rte_bit_test64, \ + const uint64_t *: __rte_bit_test64)(addr, nr) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Set bit in word. +* +* Generic selection macro to set a bit in a 32-bit or 64-bit +* word. The type of operation depends on the type of the @c addr +* parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_set (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_set32, \ + uint64_t *: __rte_bit_set64)(addr, nr) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Clear bit in word. +* +* Generic selection macro to clear a bit in a 32-bit or 64-bit +* word. The type of operation depends on the type of the @c addr +* parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_clear (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_clear32, \ + uint64_t *: __rte_bit_clear64)(addr, nr) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Assign a value to a bit in word. +* +* Generic selection macro to assign a value to a bit in a 32-bit or 64-bit +* word. The type of operation depends on the type of the @c addr parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +* @param value +* The new value of the bit - true for '1', or false for '0'. +*/ +#define rte_bit_assign (addr, nr, value) \ + _Generic((addr), \ + uint32_t *: __rte_bit_assign32, \ + uint64_t *: __rte_bit_assign64)(addr, nr, value) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Flip a bit in word. +* +* Generic selection macro to change the value of a bit to '0' if '1' +* or '1' if '0' in a 32-bit or 64-bit word. The type of operation +* depends on the type of the @c addr parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_flip (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_flip32, \ + uint64_t *: __rte_bit_flip64)(addr, nr) + +#define __RTE_GEN_BIT_TEST (variant, qualifier, size) \ + __rte_experimental \ + static inline bool \ + __rte_bit_ ## variant ## test ## size(const qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = (uint ## size ## _t)1 << nr; \ + return *addr & mask; \ + } + +#define __RTE_GEN_BIT_SET (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## set ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = (uint ## size ## _t)1 << nr; \ + *addr |= mask; \ + } \ + +#define __RTE_GEN_BIT_CLEAR (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## clear ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = ~((uint ## size ## _t)1 << nr); \ + (*addr) &= mask; \ + } \ + +#define __RTE_GEN_BIT_ASSIGN (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## assign ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr, bool value) \ + { \ + if (value) \ + __rte_bit_ ## variant ## set ## size(addr, nr); \ + else \ + __rte_bit_ ## variant ## clear ## size(addr, nr); \ + } + +#define __RTE_GEN_BIT_FLIP (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## flip ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + bool value; \ + \ + value = __rte_bit_ ## variant ## test ## size(addr, nr); \ + __rte_bit_ ## variant ## assign ## size(addr, nr, !value); \ + } + +#define __RTE_GEN_BIT_OPS (v, qualifier, size) \ + __RTE_GEN_BIT_TEST(v, qualifier, size) \ + __RTE_GEN_BIT_SET(v, qualifier, size) \ + __RTE_GEN_BIT_CLEAR(v, qualifier, size) \ + __RTE_GEN_BIT_ASSIGN(v, qualifier, size) \ + __RTE_GEN_BIT_FLIP(v, qualifier, size) + +#define __RTE_GEN_BIT_OPS_SIZE (size) \ + __RTE_GEN_BIT_OPS(,, size) + +__RTE_GEN_BIT_OPS_SIZE(32) +__RTE_GEN_BIT_OPS_SIZE (64 ) +/*------------------------ 32-bit relaxed operations ------------------------*/ /**
@@ -787,6 +981,68 @@ rte_log2_u64(uint64_t v)#ifdef __cplusplus } + +/* +* Since C++ doesn't support generic selection (i.e., _Generic), +* function overloading is used instead. Such functions must be +* defined outside 'extern "C"' to be accepted by the compiler. +*/ + +#undef rte_bit_test +#undef rte_bit_set +#undef rte_bit_clear +#undef rte_bit_assign +#undef rte_bit_flip + +#define __RTE_BIT_OVERLOAD_SZ_2 (fun, qualifier, size, arg1_type, arg1_name) \ + static inline void \ + rte_bit_ ## fun(qualifier uint ## size ## _t *addr, \ + arg1_type arg1_name) \ + { \ + __rte_bit_ ## fun ## size(addr, arg1_name); \ + } + +#define __RTE_BIT_OVERLOAD_2 (fun, qualifier, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2(fun, qualifier, 32, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2(fun, qualifier, 64, arg1_type, arg1_name) + +#define __RTE_BIT_OVERLOAD_SZ_2R (fun, qualifier, size, ret_type, arg1_type, \ + arg1_name) \ + static inline ret_type \ + rte_bit_ ## fun(qualifier uint ## size ## _t *addr, \ + arg1_type arg1_name) \ + { \ + return __rte_bit_ ## fun ## size(addr, arg1_name); \ + } + +#define __RTE_BIT_OVERLOAD_2R (fun, qualifier, ret_type, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2R(fun, qualifier, 32, ret_type, arg1_type, \ + arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2R(fun, qualifier, 64, ret_type, arg1_type, \ + arg1_name) + +#define __RTE_BIT_OVERLOAD_SZ_3 (fun, qualifier, size, arg1_type, arg1_name, \ + arg2_type, arg2_name) \ + static inline void \ + rte_bit_ ## fun(uint ## size ## _t *addr, arg1_type arg1_name, \ + arg2_type arg2_name) \ + { \ + __rte_bit_ ## fun ## size(addr, arg1_name, arg2_name); \ + } + +#define __RTE_BIT_OVERLOAD_3 (fun, qualifier, arg1_type, arg1_name, arg2_type, \ + arg2_name) \ + __RTE_BIT_OVERLOAD_SZ_3(fun, qualifier, 32, arg1_type, arg1_name, \ + arg2_type, arg2_name) \ + __RTE_BIT_OVERLOAD_SZ_3(fun, qualifier, 64, arg1_type, arg1_name, \ + arg2_type, arg2_name) + +__RTE_BIT_OVERLOAD_2R(test, const, bool, unsigned int, nr) +__RTE_BIT_OVERLOAD_2(set,, unsigned int, nr) +__RTE_BIT_OVERLOAD_2(clear,, unsigned int, nr) +__RTE_BIT_OVERLOAD_3(assign,, unsigned int, nr, bool, value) +__RTE_BIT_OVERLOAD_2(flip,, unsigned int, nr) +#endif #endif /* _RTE_BITOPS_H_ */
Signature · 1 line
2.34.1
PATCH v9 3/6 eal: add unit tests for bit operations
In reply to Mattias RönnblomExtend bitops tests to cover the
rte_bit_[test|set|clear|assign|flip]()
functions.
The tests are converted to use the test suite runner framework.
--
RFC v6:
* Test rte_bit_*test() usage through const pointers.
RFC v4:
* Remove redundant line continuations.
--- app/test/test_bitops.c | 85 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 15 deletions(-)
app/test/test_bitops.c +70 -15
@@ -1,13 +1,68 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2019 Arm Limited +* Copyright(c) 2024 Ericsson AB */ +#include <stdbool.h> +#include <rte_launch.h> #include <rte_bitops.h> +#include <rte_random.h> #include "test.h" -uint32_t val32; -uint64_t val64; +#define GEN_TEST_BIT_ACCESS (test_name, set_fun, clear_fun, assign_fun, \ + flip_fun, test_fun, size) \ + static int \ + test_name(void) \ + { \ + uint ## size ## _t reference = (uint ## size ## _t)rte_rand(); \ + unsigned int bit_nr; \ + uint ## size ## _t word = (uint ## size ## _t)rte_rand(); \ + \ + for (bit_nr = 0; bit_nr < size; bit_nr++) { \ + bool reference_bit = (reference >> bit_nr) & 1; \ + bool assign = rte_rand() & 1; \ + if (assign) \ + assign_fun(&word, bit_nr, reference_bit); \ + else { \ + if (reference_bit) \ + set_fun(&word, bit_nr); \ + else \ + clear_fun(&word, bit_nr); \ + \ + } \ + TEST_ASSERT(test_fun(&word, bit_nr) == reference_bit, \ + "Bit %d had unexpected value", bit_nr); \ + flip_fun(&word, bit_nr); \ + TEST_ASSERT(test_fun(&word, bit_nr) != reference_bit, \ + "Bit %d had unflipped value", bit_nr); \ + flip_fun(&word, bit_nr); \ + \ + const uint ## size ## _t *const_ptr = &word; \ + TEST_ASSERT(test_fun(const_ptr, bit_nr) == \ + reference_bit, \ + "Bit %d had unexpected value", bit_nr); \ + } \ + \ + for (bit_nr = 0; bit_nr < size; bit_nr++) { \ + bool reference_bit = (reference >> bit_nr) & 1; \ + TEST_ASSERT(test_fun(&word, bit_nr) == reference_bit, \ + "Bit %d had unexpected value", bit_nr); \ + } \ + \ + TEST_ASSERT(reference == word, "Word had unexpected value"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_ACCESS (test_bit_access32, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 32) + +GEN_TEST_BIT_ACCESS (test_bit_access64, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 64) + +static uint32_t val32; +static uint64_t val64;#define MAX_BITS_32 32#define MAX_BITS_64 64
@@ -117,22 +172,22 @@ test_bit_relaxed_test_set_clear(void)return TEST_SUCCESS ; } +static struct unit_test_suite test_suite = { + .suite_name ="Bitops test suite" , + .unit_test_cases = { +TEST_CASE (test_bit_access32), +TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_relaxed_set), +TEST_CASE (test_bit_relaxed_clear), +TEST_CASE (test_bit_relaxed_test_set_clear), +TEST_CASES_END () + } +}; +static int test_bitops (void ) { - val32 =0 ; - val64 =0 ; - -if (test_bit_relaxed_set () <0 ) -return TEST_FAILED ; - -if (test_bit_relaxed_clear () <0 ) -return TEST_FAILED ; - -if (test_bit_relaxed_test_set_clear () <0 ) -return TEST_FAILED ; - -return TEST_SUCCESS ; +return unit_test_suite_runner (&test_suite); }REGISTER_FAST_TEST (bitops_autotest, true, true, test_bitops);
Signature · 1 line
2.34.1
PATCH v9 4/6 eal: add atomic bit operations
In reply to Mattias RönnblomAdd atomic bit test/set/clear/assign/flip and
test-and-set/clear/assign/flip functions.
All atomic bit functions allow (and indeed, require) the caller to specify a memory order.
--
PATCH v3:
* Introduce __RTE_GEN_BIT_ATOMIC_*() 'qualifier' argument already in this patch (Jack Bond-Preston).
* Refer to volatile bit op functions as variants instead of families (macro parameter naming).
* Update release notes.
PATCH:
* Add missing macro #undef for C++ version of atomic bit flip.
RFC v7:
* Replace compare-exchange-based rte_bitset_atomic_test_and_*() and flip() with implementations that use the previous value as returned by the atomic fetch function.
* Reword documentation to match the non-atomic macro variants.
* Remove pointer to <rte_stdatomic.h> for memory model documentation, since there is no documentation for that API.
RFC v6:
* Have rte_bit_atomic_test() accept const-marked bitsets.
RFC v4:
* Add atomic bit flip.
* Mark macro-generated private functions experimental.
RFC v3:
* Work around lack of C++ support for _Generic (Tyler Retzlaff).
RFC v2:
o Add rte_bit_atomic_test_and_assign() (for consistency).
o Fix bugs in rte_bit_atomic_test_and_[set|clear]().
o Use <rte_stdatomics.h> to support MSVC.
--- doc/guides/rel_notes/release_24_11.rst | 17 + lib/eal/include/rte_bitops.h | 415 +++++++++++++++++++++++++ 2 files changed, 432 insertions(+)
doc/guides/rel_notes/release_24_11.rst +17 -0
@@ -56,6 +56,23 @@ New Features ======================================================= +* **Extended bit operations API.** + + The support for bit-level operations on single 32- and 64-bit words + in <rte_bitops.h> has been extended with two families of + semantically well-defined functions. + + rte_bit_[test|set|clear|assign|flip]() functions provide excellent + performance (by avoiding restricting the compiler and CPU), but give + no guarantees in regards to memory ordering or atomicity. + + rte_bit_atomic_*() provides atomic bit-level operations, including + the possibility to specifying memory ordering constraints. + + The new public API elements are polymorphic, using the _Generic- + based macros (for C) and function overloading (in C++ translation + units). + Removed Items -------------
lib/eal/include/rte_bitops.h +415 -0
451 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v9 5/6 eal: add unit tests for atomic bit access functions
In reply to Mattias RönnblomExtend bitops tests to cover the rte_bit_atomic_*() family of functions.
--
RFC v4:
* Add atomicity test for atomic bit flip.
RFC v3:
* Rename variable 'main' to make ICC happy.
--- app/test/test_bitops.c | 313 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 312 insertions(+), 1 deletion(-)
app/test/test_bitops.c +312 -1
@@ -3,10 +3,13 @@* Copyright(c) 2024 Ericsson AB */ +#include <inttypes.h> #include <stdbool.h> -#include <rte_launch.h> #include <rte_bitops.h> +#include <rte_cycles.h> +#include <rte_launch.h> +#include <rte_lcore.h> #include <rte_random.h> #include "test.h"
@@ -61,6 +64,304 @@ GEN_TEST_BIT_ACCESS(test_bit_access32, rte_bit_set, rte_bit_clear,GEN_TEST_BIT_ACCESS (test_bit_access64, rte_bit_set, rte_bit_clear, rte_bit_assign, rte_bit_flip, rte_bit_test, 64) +#define bit_atomic_set (addr, nr) \ + rte_bit_atomic_set(addr, nr, rte_memory_order_relaxed) + +#define bit_atomic_clear (addr, nr) \ + rte_bit_atomic_clear(addr, nr, rte_memory_order_relaxed) + +#define bit_atomic_assign (addr, nr, value) \ + rte_bit_atomic_assign(addr, nr, value, rte_memory_order_relaxed) + +#define bit_atomic_flip (addr, nr) \ + rte_bit_atomic_flip(addr, nr, rte_memory_order_relaxed) + +#define bit_atomic_test (addr, nr) \ + rte_bit_atomic_test(addr, nr, rte_memory_order_relaxed) + +GEN_TEST_BIT_ACCESS (test_bit_atomic_access32, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 32) + +GEN_TEST_BIT_ACCESS (test_bit_atomic_access64, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 64) + +#define PARALLEL_TEST_RUNTIME 0.25 + +#define GEN_TEST_BIT_PARALLEL_ASSIGN (size) \ + \ + struct parallel_access_lcore ## size \ + { \ + unsigned int bit; \ + uint ## size ##_t *word; \ + bool failed; \ + }; \ + \ + static int \ + run_parallel_assign ## size(void *arg) \ + { \ + struct parallel_access_lcore ## size *lcore = arg; \ + uint64_t deadline = rte_get_timer_cycles() + \ + PARALLEL_TEST_RUNTIME * rte_get_timer_hz(); \ + bool value = false; \ + \ + do { \ + bool new_value = rte_rand() & 1; \ + bool use_test_and_modify = rte_rand() & 1; \ + bool use_assign = rte_rand() & 1; \ + \ + if (rte_bit_atomic_test(lcore->word, lcore->bit, \ + rte_memory_order_relaxed) != value) { \ + lcore->failed = true; \ + break; \ + } \ + \ + if (use_test_and_modify) { \ + bool old_value; \ + if (use_assign) \ + old_value = rte_bit_atomic_test_and_assign( \ + lcore->word, lcore->bit, new_value, \ + rte_memory_order_relaxed); \ + else { \ + old_value = new_value ? \ + rte_bit_atomic_test_and_set( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed) : \ + rte_bit_atomic_test_and_clear( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + } \ + if (old_value != value) { \ + lcore->failed = true; \ + break; \ + } \ + } else { \ + if (use_assign) \ + rte_bit_atomic_assign(lcore->word, lcore->bit, \ + new_value, \ + rte_memory_order_relaxed); \ + else { \ + if (new_value) \ + rte_bit_atomic_set( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + else \ + rte_bit_atomic_clear( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + } \ + } \ + \ + value = new_value; \ + } while (rte_get_timer_cycles() < deadline); \ + \ + return 0; \ + } \ + \ + static int \ + test_bit_atomic_parallel_assign ## size(void) \ + { \ + unsigned int worker_lcore_id; \ + uint ## size ## _t word = 0; \ + struct parallel_access_lcore ## size lmain = { \ + .word = &word \ + }; \ + struct parallel_access_lcore ## size lworker = { \ + .word = &word \ + }; \ + \ + if (rte_lcore_count() < 2) { \ + printf("Need multiple cores to run parallel test.\n"); \ + return TEST_SKIPPED; \ + } \ + \ + worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + \ + lmain.bit = rte_rand_max(size); \ + do { \ + lworker.bit = rte_rand_max(size); \ + } while (lworker.bit == lmain.bit); \ + \ + int rc = rte_eal_remote_launch(run_parallel_assign ## size, \ + &lworker, worker_lcore_id); \ + TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ + \ + run_parallel_assign ## size(&lmain); \ + \ + rte_eal_mp_wait_lcore(); \ + \ + TEST_ASSERT(!lmain.failed, "Main lcore atomic access failed"); \ + TEST_ASSERT(!lworker.failed, "Worker lcore atomic access " \ + "failed"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_PARALLEL_ASSIGN(32) +GEN_TEST_BIT_PARALLEL_ASSIGN(64) + +#define GEN_TEST_BIT_PARALLEL_TEST_AND_MODIFY (size) \ + \ + struct parallel_test_and_set_lcore ## size \ + { \ + uint ## size ##_t *word; \ + unsigned int bit; \ + uint64_t flips; \ + }; \ + \ + static int \ + run_parallel_test_and_modify ## size(void *arg) \ + { \ + struct parallel_test_and_set_lcore ## size *lcore = arg; \ + uint64_t deadline = rte_get_timer_cycles() + \ + PARALLEL_TEST_RUNTIME * rte_get_timer_hz(); \ + do { \ + bool old_value; \ + bool new_value = rte_rand() & 1; \ + bool use_assign = rte_rand() & 1; \ + \ + if (use_assign) \ + old_value = rte_bit_atomic_test_and_assign( \ + lcore->word, lcore->bit, new_value, \ + rte_memory_order_relaxed); \ + else \ + old_value = new_value ? \ + rte_bit_atomic_test_and_set( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed) : \ + rte_bit_atomic_test_and_clear( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + if (old_value != new_value) \ + lcore->flips++; \ + } while (rte_get_timer_cycles() < deadline); \ + \ + return 0; \ + } \ + \ + static int \ + test_bit_atomic_parallel_test_and_modify ## size(void) \ + { \ + unsigned int worker_lcore_id; \ + uint ## size ## _t word = 0; \ + unsigned int bit = rte_rand_max(size); \ + struct parallel_test_and_set_lcore ## size lmain = { \ + .word = &word, \ + .bit = bit \ + }; \ + struct parallel_test_and_set_lcore ## size lworker = { \ + .word = &word, \ + .bit = bit \ + }; \ + \ + if (rte_lcore_count() < 2) { \ + printf("Need multiple cores to run parallel test.\n"); \ + return TEST_SKIPPED; \ + } \ + \ + worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + \ + int rc = rte_eal_remote_launch(run_parallel_test_and_modify ## size, \ + &lworker, worker_lcore_id); \ + TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ + \ + run_parallel_test_and_modify ## size(&lmain); \ + \ + rte_eal_mp_wait_lcore(); \ + \ + uint64_t total_flips = lmain.flips + lworker.flips; \ + bool expected_value = total_flips % 2; \ + \ + TEST_ASSERT(expected_value == rte_bit_test(&word, bit), \ + "After %"PRId64" flips, the bit value " \ + "should be %d", total_flips, expected_value); \ + \ + uint64_t expected_word = 0; \ + rte_bit_assign(&expected_word, bit, expected_value); \ + \ + TEST_ASSERT(expected_word == word, "Untouched bits have " \ + "changed value"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_PARALLEL_TEST_AND_MODIFY(32) +GEN_TEST_BIT_PARALLEL_TEST_AND_MODIFY(64) + +#define GEN_TEST_BIT_PARALLEL_FLIP (size) \ + \ + struct parallel_flip_lcore ## size \ + { \ + uint ## size ##_t *word; \ + unsigned int bit; \ + uint64_t flips; \ + }; \ + \ + static int \ + run_parallel_flip ## size(void *arg) \ + { \ + struct parallel_flip_lcore ## size *lcore = arg; \ + uint64_t deadline = rte_get_timer_cycles() + \ + PARALLEL_TEST_RUNTIME * rte_get_timer_hz(); \ + do { \ + rte_bit_atomic_flip(lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + lcore->flips++; \ + } while (rte_get_timer_cycles() < deadline); \ + \ + return 0; \ + } \ + \ + static int \ + test_bit_atomic_parallel_flip ## size(void) \ + { \ + unsigned int worker_lcore_id; \ + uint ## size ## _t word = 0; \ + unsigned int bit = rte_rand_max(size); \ + struct parallel_flip_lcore ## size lmain = { \ + .word = &word, \ + .bit = bit \ + }; \ + struct parallel_flip_lcore ## size lworker = { \ + .word = &word, \ + .bit = bit \ + }; \ + \ + if (rte_lcore_count() < 2) { \ + printf("Need multiple cores to run parallel test.\n"); \ + return TEST_SKIPPED; \ + } \ + \ + worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + \ + int rc = rte_eal_remote_launch(run_parallel_flip ## size, \ + &lworker, worker_lcore_id); \ + TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ + \ + run_parallel_flip ## size(&lmain); \ + \ + rte_eal_mp_wait_lcore(); \ + \ + uint64_t total_flips = lmain.flips + lworker.flips; \ + bool expected_value = total_flips % 2; \ + \ + TEST_ASSERT(expected_value == rte_bit_test(&word, bit), \ + "After %"PRId64" flips, the bit value " \ + "should be %d", total_flips, expected_value); \ + \ + uint64_t expected_word = 0; \ + rte_bit_assign(&expected_word, bit, expected_value); \ + \ + TEST_ASSERT(expected_word == word, "Untouched bits have " \ + "changed value"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_PARALLEL_FLIP(32) +GEN_TEST_BIT_PARALLEL_FLIP(64) +static uint32_t val32;static uint64_t val64;
@@ -177,6 +478,16 @@ static struct unit_test_suite test_suite = { .unit_test_cases = {TEST_CASE (test_bit_access32),TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_access32), +TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_atomic_access32), +TEST_CASE (test_bit_atomic_access64), +TEST_CASE (test_bit_atomic_parallel_assign32), +TEST_CASE (test_bit_atomic_parallel_assign64), +TEST_CASE (test_bit_atomic_parallel_test_and_modify32), +TEST_CASE (test_bit_atomic_parallel_test_and_modify64), +TEST_CASE (test_bit_atomic_parallel_flip32), +TEST_CASE (test_bit_atomic_parallel_flip64),TEST_CASE (test_bit_relaxed_set),TEST_CASE (test_bit_relaxed_clear), TEST_CASE(test_bit_relaxed_test_set_clear),
Signature · 1 line
2.34.1
PATCH v9 6/6 eal: extend bitops to handle volatile pointers
In reply to Mattias RönnblomHave rte_bit_[test|set|clear|assign|flip]() and rte_bit_atomic_*() handle volatile-marked pointers.
--
PATCH v3:
* Updated to reflect removed 'fun' parameter in __RTE_GEN_BIT_*() (Jack Bond-Preston).
PATCH v2:
* Actually run the test_bit_atomic_v_access*() test functions.
--- app/test/test_bitops.c | 32 +++- lib/eal/include/rte_bitops.h | 301 +++++++++++++++++++++++------------ 2 files changed, 222 insertions(+), 111 deletions(-)
app/test/test_bitops.c +25 -7
@@ -14,13 +14,13 @@#include "test.h" #define GEN_TEST_BIT_ACCESS (test_name, set_fun, clear_fun, assign_fun, \ - flip_fun, test_fun, size) \ + flip_fun, test_fun, size, mod) \ static int \ test_name(void) \ { \ uint ## size ## _t reference = (uint ## size ## _t)rte_rand(); \ unsigned int bit_nr; \ - uint ## size ## _t word = (uint ## size ## _t)rte_rand(); \ + mod uint ## size ## _t word = (uint ## size ## _t)rte_rand(); \ \ for (bit_nr = 0; bit_nr < size; bit_nr++) { \ bool reference_bit = (reference >> bit_nr) & 1; \
@@ -41,7 +41,7 @@ "Bit %d had unflipped value", bit_nr); \flip_fun (&word, bit_nr); \ \ - const uint ## size ## _t *const_ptr = &word; \ + const mod uint ## size ## _t *const_ptr = &word; \ TEST_ASSERT(test_fun(const_ptr, bit_nr) == \ reference_bit, \ "Bit %d had unexpected value", bit_nr); \
@@ -59,10 +59,16 @@ } GEN_TEST_BIT_ACCESS(test_bit_access32, rte_bit_set, rte_bit_clear, - rte_bit_assign, rte_bit_flip, rte_bit_test, 32) + rte_bit_assign, rte_bit_flip, rte_bit_test, 32,) GEN_TEST_BIT_ACCESS(test_bit_access64, rte_bit_set, rte_bit_clear, - rte_bit_assign, rte_bit_flip, rte_bit_test, 64) + rte_bit_assign, rte_bit_flip, rte_bit_test, 64,) + +GEN_TEST_BIT_ACCESS(test_bit_v_access32, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 32, volatile) + +GEN_TEST_BIT_ACCESS(test_bit_v_access64, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 64, volatile) #define bit_atomic_set(addr, nr) \ rte_bit_atomic_set(addr, nr, rte_memory_order_relaxed)
@@ -81,11 +87,19 @@ GEN_TEST_BIT_ACCESS(test_bit_access64, rte_bit_set, rte_bit_clear, GEN_TEST_BIT_ACCESS(test_bit_atomic_access32, bit_atomic_set, bit_atomic_clear, bit_atomic_assign, - bit_atomic_flip, bit_atomic_test, 32) + bit_atomic_flip, bit_atomic_test, 32,) GEN_TEST_BIT_ACCESS(test_bit_atomic_access64, bit_atomic_set, bit_atomic_clear, bit_atomic_assign, - bit_atomic_flip, bit_atomic_test, 64) + bit_atomic_flip, bit_atomic_test, 64,) + +GEN_TEST_BIT_ACCESS(test_bit_atomic_v_access32, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 32, volatile) + +GEN_TEST_BIT_ACCESS(test_bit_atomic_v_access64, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 64, volatile) #define PARALLEL_TEST_RUNTIME 0.25
@@ -480,8 +494,12 @@ static struct unit_test_suite test_suite = {TEST_CASE (test_bit_access64),TEST_CASE (test_bit_access32),TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_v_access32), +TEST_CASE (test_bit_v_access64),TEST_CASE (test_bit_atomic_access32),TEST_CASE (test_bit_atomic_access64), +TEST_CASE (test_bit_atomic_v_access32), +TEST_CASE (test_bit_atomic_v_access64),TEST_CASE (test_bit_atomic_parallel_assign32),TEST_CASE (test_bit_atomic_parallel_assign64), TEST_CASE(test_bit_atomic_parallel_test_and_modify32),
lib/eal/include/rte_bitops.h +197 -104
440 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v8 2/6 eal: extend bit manipulation functionality
In reply to Mattias RönnblomAdd functionality to test and modify the value of individual bits in 32-bit or 64-bit words.
These functions have no implications on memory ordering, atomicity and does not use volatile and thus does not prevent any compiler optimizations.
--
PATCH v3:
* Remove unnecessary <rte_compat.h> include.
* Remove redundant 'fun' parameter from the __RTE_GEN_BIT_*() macros (Jack Bond-Preston).
* Introduce __RTE_BIT_BIT_OPS() macro, consistent with how things are done when generating the atomic bit operations.
* Refer to volatile bit op functions as variants instead of families (macro parameter naming).
RFC v6:
* Have rte_bit_test() accept const-marked bitsets.
RFC v4:
* Add rte_bit_flip() which, believe it or not, flips the value of a bit.
* Mark macro-generated private functions as experimental.
* Use macros to generate *assign*() functions.
RFC v3:
* Work around lack of C++ support for _Generic (Tyler Retzlaff).
* Fix ','-related checkpatch warnings.
--- lib/eal/include/rte_bitops.h | 260 ++++++++++++++++++++++++++++++++++- 1 file changed, 258 insertions(+), 2 deletions(-)
lib/eal/include/rte_bitops.h +258 -2
@@ -2,6 +2,7 @@* Copyright(c) 2020 Arm Limited * Copyright(c) 2010-2019 Intel Corporation * Copyright(c) 2023 Microsoft Corporation +* Copyright(c) 2024 Ericsson AB */ #ifndef _RTE_BITOPS_H_
@@ -11,12 +12,14 @@* @file * Bit Operations * -* This file defines a family of APIs for bit operations -* without enforcing memory ordering. +* This file provides functionality for low-level, single-word +* arithmetic and bit-level operations, such as counting or +* setting individual bits. */ #include <stdint.h> +#include <rte_compat.h> #include <rte_debug.h> #ifdef __cplusplus
@@ -105,6 +108,197 @@ extern "C" {#define RTE_FIELD_GET64 (mask, reg) \ ((typeof(mask))(((reg) & (mask)) >> rte_ctz64(mask))) +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Test bit in word. +* +* Generic selection macro to test the value of a bit in a 32-bit or +* 64-bit word. The type of operation depends on the type of the @c +* addr parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_test (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_test32, \ + const uint32_t *: __rte_bit_test32, \ + uint64_t *: __rte_bit_test64, \ + const uint64_t *: __rte_bit_test64)(addr, nr) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Set bit in word. +* +* Generic selection macro to set a bit in a 32-bit or 64-bit +* word. The type of operation depends on the type of the @c addr +* parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_set (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_set32, \ + uint64_t *: __rte_bit_set64)(addr, nr) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Clear bit in word. +* +* Generic selection macro to clear a bit in a 32-bit or 64-bit +* word. The type of operation depends on the type of the @c addr +* parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_clear (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_clear32, \ + uint64_t *: __rte_bit_clear64)(addr, nr) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Assign a value to a bit in word. +* +* Generic selection macro to assign a value to a bit in a 32-bit or 64-bit +* word. The type of operation depends on the type of the @c addr parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +* @param value +* The new value of the bit - true for '1', or false for '0'. +*/ +#define rte_bit_assign (addr, nr, value) \ + _Generic((addr), \ + uint32_t *: __rte_bit_assign32, \ + uint64_t *: __rte_bit_assign64)(addr, nr, value) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Flip a bit in word. +* +* Generic selection macro to change the value of a bit to '0' if '1' +* or '1' if '0' in a 32-bit or 64-bit word. The type of operation +* depends on the type of the @c addr parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_flip (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_flip32, \ + uint64_t *: __rte_bit_flip64)(addr, nr) + +#define __RTE_GEN_BIT_TEST (variant, qualifier, size) \ + __rte_experimental \ + static inline bool \ + __rte_bit_ ## variant ## test ## size(const qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = (uint ## size ## _t)1 << nr; \ + return *addr & mask; \ + } + +#define __RTE_GEN_BIT_SET (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## set ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = (uint ## size ## _t)1 << nr; \ + *addr |= mask; \ + } \ + +#define __RTE_GEN_BIT_CLEAR (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## clear ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = ~((uint ## size ## _t)1 << nr); \ + (*addr) &= mask; \ + } \ + +#define __RTE_GEN_BIT_ASSIGN (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## assign ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr, bool value) \ + { \ + if (value) \ + __rte_bit_ ## variant ## set ## size(addr, nr); \ + else \ + __rte_bit_ ## variant ## clear ## size(addr, nr); \ + } + +#define __RTE_GEN_BIT_FLIP (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## flip ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + bool value; \ + \ + value = __rte_bit_ ## variant ## test ## size(addr, nr); \ + __rte_bit_ ## variant ## assign ## size(addr, nr, !value); \ + } + +#define __RTE_GEN_BIT_OPS (v, qualifier, size) \ + __RTE_GEN_BIT_TEST(v, qualifier, size) \ + __RTE_GEN_BIT_SET(v, qualifier, size) \ + __RTE_GEN_BIT_CLEAR(v, qualifier, size) \ + __RTE_GEN_BIT_ASSIGN(v, qualifier, size) \ + __RTE_GEN_BIT_FLIP(v, qualifier, size) + +#define __RTE_GEN_BIT_OPS_SIZE (size) \ + __RTE_GEN_BIT_OPS(,, size) + +__RTE_GEN_BIT_OPS_SIZE(32) +__RTE_GEN_BIT_OPS_SIZE (64 ) +/*------------------------ 32-bit relaxed operations ------------------------*/ /**
@@ -787,6 +981,68 @@ rte_log2_u64(uint64_t v)#ifdef __cplusplus } + +/* +* Since C++ doesn't support generic selection (i.e., _Generic), +* function overloading is used instead. Such functions must be +* defined outside 'extern "C"' to be accepted by the compiler. +*/ + +#undef rte_bit_test +#undef rte_bit_set +#undef rte_bit_clear +#undef rte_bit_assign +#undef rte_bit_flip + +#define __RTE_BIT_OVERLOAD_SZ_2 (fun, qualifier, size, arg1_type, arg1_name) \ + static inline void \ + rte_bit_ ## fun(qualifier uint ## size ## _t *addr, \ + arg1_type arg1_name) \ + { \ + __rte_bit_ ## fun ## size(addr, arg1_name); \ + } + +#define __RTE_BIT_OVERLOAD_2 (fun, qualifier, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2(fun, qualifier, 32, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2(fun, qualifier, 64, arg1_type, arg1_name) + +#define __RTE_BIT_OVERLOAD_SZ_2R (fun, qualifier, size, ret_type, arg1_type, \ + arg1_name) \ + static inline ret_type \ + rte_bit_ ## fun(qualifier uint ## size ## _t *addr, \ + arg1_type arg1_name) \ + { \ + return __rte_bit_ ## fun ## size(addr, arg1_name); \ + } + +#define __RTE_BIT_OVERLOAD_2R (fun, qualifier, ret_type, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2R(fun, qualifier, 32, ret_type, arg1_type, \ + arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2R(fun, qualifier, 64, ret_type, arg1_type, \ + arg1_name) + +#define __RTE_BIT_OVERLOAD_SZ_3 (fun, qualifier, size, arg1_type, arg1_name, \ + arg2_type, arg2_name) \ + static inline void \ + rte_bit_ ## fun(uint ## size ## _t *addr, arg1_type arg1_name, \ + arg2_type arg2_name) \ + { \ + __rte_bit_ ## fun ## size(addr, arg1_name, arg2_name); \ + } + +#define __RTE_BIT_OVERLOAD_3 (fun, qualifier, arg1_type, arg1_name, arg2_type, \ + arg2_name) \ + __RTE_BIT_OVERLOAD_SZ_3(fun, qualifier, 32, arg1_type, arg1_name, \ + arg2_type, arg2_name) \ + __RTE_BIT_OVERLOAD_SZ_3(fun, qualifier, 64, arg1_type, arg1_name, \ + arg2_type, arg2_name) + +__RTE_BIT_OVERLOAD_2R(test, const, bool, unsigned int, nr) +__RTE_BIT_OVERLOAD_2(set,, unsigned int, nr) +__RTE_BIT_OVERLOAD_2(clear,, unsigned int, nr) +__RTE_BIT_OVERLOAD_3(assign,, unsigned int, nr, bool, value) +__RTE_BIT_OVERLOAD_2(flip,, unsigned int, nr) +#endif #endif /* _RTE_BITOPS_H_ */
Signature · 1 line
2.34.1
PATCH v8 3/6 eal: add unit tests for bit operations
In reply to Mattias RönnblomExtend bitops tests to cover the
rte_bit_[test|set|clear|assign|flip]()
functions.
The tests are converted to use the test suite runner framework.
--
RFC v6:
* Test rte_bit_*test() usage through const pointers.
RFC v4:
* Remove redundant line continuations.
--- app/test/test_bitops.c | 85 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 15 deletions(-)
app/test/test_bitops.c +70 -15
@@ -1,13 +1,68 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2019 Arm Limited +* Copyright(c) 2024 Ericsson AB */ +#include <stdbool.h> +#include <rte_launch.h> #include <rte_bitops.h> +#include <rte_random.h> #include "test.h" -uint32_t val32; -uint64_t val64; +#define GEN_TEST_BIT_ACCESS (test_name, set_fun, clear_fun, assign_fun, \ + flip_fun, test_fun, size) \ + static int \ + test_name(void) \ + { \ + uint ## size ## _t reference = (uint ## size ## _t)rte_rand(); \ + unsigned int bit_nr; \ + uint ## size ## _t word = (uint ## size ## _t)rte_rand(); \ + \ + for (bit_nr = 0; bit_nr < size; bit_nr++) { \ + bool reference_bit = (reference >> bit_nr) & 1; \ + bool assign = rte_rand() & 1; \ + if (assign) \ + assign_fun(&word, bit_nr, reference_bit); \ + else { \ + if (reference_bit) \ + set_fun(&word, bit_nr); \ + else \ + clear_fun(&word, bit_nr); \ + \ + } \ + TEST_ASSERT(test_fun(&word, bit_nr) == reference_bit, \ + "Bit %d had unexpected value", bit_nr); \ + flip_fun(&word, bit_nr); \ + TEST_ASSERT(test_fun(&word, bit_nr) != reference_bit, \ + "Bit %d had unflipped value", bit_nr); \ + flip_fun(&word, bit_nr); \ + \ + const uint ## size ## _t *const_ptr = &word; \ + TEST_ASSERT(test_fun(const_ptr, bit_nr) == \ + reference_bit, \ + "Bit %d had unexpected value", bit_nr); \ + } \ + \ + for (bit_nr = 0; bit_nr < size; bit_nr++) { \ + bool reference_bit = (reference >> bit_nr) & 1; \ + TEST_ASSERT(test_fun(&word, bit_nr) == reference_bit, \ + "Bit %d had unexpected value", bit_nr); \ + } \ + \ + TEST_ASSERT(reference == word, "Word had unexpected value"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_ACCESS (test_bit_access32, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 32) + +GEN_TEST_BIT_ACCESS (test_bit_access64, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 64) + +static uint32_t val32; +static uint64_t val64;#define MAX_BITS_32 32#define MAX_BITS_64 64
@@ -117,22 +172,22 @@ test_bit_relaxed_test_set_clear(void)return TEST_SUCCESS ; } +static struct unit_test_suite test_suite = { + .suite_name ="Bitops test suite" , + .unit_test_cases = { +TEST_CASE (test_bit_access32), +TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_relaxed_set), +TEST_CASE (test_bit_relaxed_clear), +TEST_CASE (test_bit_relaxed_test_set_clear), +TEST_CASES_END () + } +}; +static int test_bitops (void ) { - val32 =0 ; - val64 =0 ; - -if (test_bit_relaxed_set () <0 ) -return TEST_FAILED ; - -if (test_bit_relaxed_clear () <0 ) -return TEST_FAILED ; - -if (test_bit_relaxed_test_set_clear () <0 ) -return TEST_FAILED ; - -return TEST_SUCCESS ; +return unit_test_suite_runner (&test_suite); }REGISTER_FAST_TEST (bitops_autotest, true, true, test_bitops);
Signature · 1 line
2.34.1
PATCH v8 4/6 eal: add atomic bit operations
In reply to Mattias RönnblomAdd atomic bit test/set/clear/assign/flip and
test-and-set/clear/assign/flip functions.
All atomic bit functions allow (and indeed, require) the caller to specify a memory order.
--
PATCH v3:
* Introduce __RTE_GEN_BIT_ATOMIC_*() 'qualifier' argument already in this patch (Jack Bond-Preston).
* Refer to volatile bit op functions as variants instead of families (macro parameter naming).
* Update release notes.
PATCH:
* Add missing macro #undef for C++ version of atomic bit flip.
RFC v7:
* Replace compare-exchange-based rte_bitset_atomic_test_and_*() and flip() with implementations that use the previous value as returned by the atomic fetch function.
* Reword documentation to match the non-atomic macro variants.
* Remove pointer to <rte_stdatomic.h> for memory model documentation, since there is no documentation for that API.
RFC v6:
* Have rte_bit_atomic_test() accept const-marked bitsets.
RFC v4:
* Add atomic bit flip.
* Mark macro-generated private functions experimental.
RFC v3:
* Work around lack of C++ support for _Generic (Tyler Retzlaff).
RFC v2:
o Add rte_bit_atomic_test_and_assign() (for consistency).
o Fix bugs in rte_bit_atomic_test_and_[set|clear]().
o Use <rte_stdatomics.h> to support MSVC.
--- doc/guides/rel_notes/release_24_11.rst | 17 + lib/eal/include/rte_bitops.h | 415 +++++++++++++++++++++++++ 2 files changed, 432 insertions(+)
doc/guides/rel_notes/release_24_11.rst +17 -0
@@ -56,6 +56,23 @@ New Features ======================================================= +* **Extended bit operations API.** + + The support for bit-level operations on single 32- and 64-bit words + in <rte_bitops.h> has been extended with two families of + semantically well-defined functions. + + rte_bit_[test|set|clear|assign|flip]() functions provide excellent + performance (by avoiding restricting the compiler and CPU), but give + no guarantees in regards to memory ordering or atomicity. + + rte_bit_atomic_*() provides atomic bit-level operations, including + the possibility to specifying memory ordering constraints. + + The new public API elements are polymorphic, using the _Generic- + based macros (for C) and function overloading (in C++ translation + units). + Removed Items -------------
lib/eal/include/rte_bitops.h +415 -0
451 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v8 5/6 eal: add unit tests for atomic bit access functions
In reply to Mattias RönnblomExtend bitops tests to cover the rte_bit_atomic_*() family of functions.
--
RFC v4:
* Add atomicity test for atomic bit flip.
RFC v3:
* Rename variable 'main' to make ICC happy.
--- app/test/test_bitops.c | 313 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 312 insertions(+), 1 deletion(-)
app/test/test_bitops.c +312 -1
@@ -3,10 +3,13 @@* Copyright(c) 2024 Ericsson AB */ +#include <inttypes.h> #include <stdbool.h> -#include <rte_launch.h> #include <rte_bitops.h> +#include <rte_cycles.h> +#include <rte_launch.h> +#include <rte_lcore.h> #include <rte_random.h> #include "test.h"
@@ -61,6 +64,304 @@ GEN_TEST_BIT_ACCESS(test_bit_access32, rte_bit_set, rte_bit_clear,GEN_TEST_BIT_ACCESS (test_bit_access64, rte_bit_set, rte_bit_clear, rte_bit_assign, rte_bit_flip, rte_bit_test, 64) +#define bit_atomic_set (addr, nr) \ + rte_bit_atomic_set(addr, nr, rte_memory_order_relaxed) + +#define bit_atomic_clear (addr, nr) \ + rte_bit_atomic_clear(addr, nr, rte_memory_order_relaxed) + +#define bit_atomic_assign (addr, nr, value) \ + rte_bit_atomic_assign(addr, nr, value, rte_memory_order_relaxed) + +#define bit_atomic_flip (addr, nr) \ + rte_bit_atomic_flip(addr, nr, rte_memory_order_relaxed) + +#define bit_atomic_test (addr, nr) \ + rte_bit_atomic_test(addr, nr, rte_memory_order_relaxed) + +GEN_TEST_BIT_ACCESS (test_bit_atomic_access32, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 32) + +GEN_TEST_BIT_ACCESS (test_bit_atomic_access64, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 64) + +#define PARALLEL_TEST_RUNTIME 0.25 + +#define GEN_TEST_BIT_PARALLEL_ASSIGN (size) \ + \ + struct parallel_access_lcore ## size \ + { \ + unsigned int bit; \ + uint ## size ##_t *word; \ + bool failed; \ + }; \ + \ + static int \ + run_parallel_assign ## size(void *arg) \ + { \ + struct parallel_access_lcore ## size *lcore = arg; \ + uint64_t deadline = rte_get_timer_cycles() + \ + PARALLEL_TEST_RUNTIME * rte_get_timer_hz(); \ + bool value = false; \ + \ + do { \ + bool new_value = rte_rand() & 1; \ + bool use_test_and_modify = rte_rand() & 1; \ + bool use_assign = rte_rand() & 1; \ + \ + if (rte_bit_atomic_test(lcore->word, lcore->bit, \ + rte_memory_order_relaxed) != value) { \ + lcore->failed = true; \ + break; \ + } \ + \ + if (use_test_and_modify) { \ + bool old_value; \ + if (use_assign) \ + old_value = rte_bit_atomic_test_and_assign( \ + lcore->word, lcore->bit, new_value, \ + rte_memory_order_relaxed); \ + else { \ + old_value = new_value ? \ + rte_bit_atomic_test_and_set( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed) : \ + rte_bit_atomic_test_and_clear( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + } \ + if (old_value != value) { \ + lcore->failed = true; \ + break; \ + } \ + } else { \ + if (use_assign) \ + rte_bit_atomic_assign(lcore->word, lcore->bit, \ + new_value, \ + rte_memory_order_relaxed); \ + else { \ + if (new_value) \ + rte_bit_atomic_set( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + else \ + rte_bit_atomic_clear( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + } \ + } \ + \ + value = new_value; \ + } while (rte_get_timer_cycles() < deadline); \ + \ + return 0; \ + } \ + \ + static int \ + test_bit_atomic_parallel_assign ## size(void) \ + { \ + unsigned int worker_lcore_id; \ + uint ## size ## _t word = 0; \ + struct parallel_access_lcore ## size lmain = { \ + .word = &word \ + }; \ + struct parallel_access_lcore ## size lworker = { \ + .word = &word \ + }; \ + \ + if (rte_lcore_count() < 2) { \ + printf("Need multiple cores to run parallel test.\n"); \ + return TEST_SKIPPED; \ + } \ + \ + worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + \ + lmain.bit = rte_rand_max(size); \ + do { \ + lworker.bit = rte_rand_max(size); \ + } while (lworker.bit == lmain.bit); \ + \ + int rc = rte_eal_remote_launch(run_parallel_assign ## size, \ + &lworker, worker_lcore_id); \ + TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ + \ + run_parallel_assign ## size(&lmain); \ + \ + rte_eal_mp_wait_lcore(); \ + \ + TEST_ASSERT(!lmain.failed, "Main lcore atomic access failed"); \ + TEST_ASSERT(!lworker.failed, "Worker lcore atomic access " \ + "failed"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_PARALLEL_ASSIGN(32) +GEN_TEST_BIT_PARALLEL_ASSIGN(64) + +#define GEN_TEST_BIT_PARALLEL_TEST_AND_MODIFY (size) \ + \ + struct parallel_test_and_set_lcore ## size \ + { \ + uint ## size ##_t *word; \ + unsigned int bit; \ + uint64_t flips; \ + }; \ + \ + static int \ + run_parallel_test_and_modify ## size(void *arg) \ + { \ + struct parallel_test_and_set_lcore ## size *lcore = arg; \ + uint64_t deadline = rte_get_timer_cycles() + \ + PARALLEL_TEST_RUNTIME * rte_get_timer_hz(); \ + do { \ + bool old_value; \ + bool new_value = rte_rand() & 1; \ + bool use_assign = rte_rand() & 1; \ + \ + if (use_assign) \ + old_value = rte_bit_atomic_test_and_assign( \ + lcore->word, lcore->bit, new_value, \ + rte_memory_order_relaxed); \ + else \ + old_value = new_value ? \ + rte_bit_atomic_test_and_set( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed) : \ + rte_bit_atomic_test_and_clear( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + if (old_value != new_value) \ + lcore->flips++; \ + } while (rte_get_timer_cycles() < deadline); \ + \ + return 0; \ + } \ + \ + static int \ + test_bit_atomic_parallel_test_and_modify ## size(void) \ + { \ + unsigned int worker_lcore_id; \ + uint ## size ## _t word = 0; \ + unsigned int bit = rte_rand_max(size); \ + struct parallel_test_and_set_lcore ## size lmain = { \ + .word = &word, \ + .bit = bit \ + }; \ + struct parallel_test_and_set_lcore ## size lworker = { \ + .word = &word, \ + .bit = bit \ + }; \ + \ + if (rte_lcore_count() < 2) { \ + printf("Need multiple cores to run parallel test.\n"); \ + return TEST_SKIPPED; \ + } \ + \ + worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + \ + int rc = rte_eal_remote_launch(run_parallel_test_and_modify ## size, \ + &lworker, worker_lcore_id); \ + TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ + \ + run_parallel_test_and_modify ## size(&lmain); \ + \ + rte_eal_mp_wait_lcore(); \ + \ + uint64_t total_flips = lmain.flips + lworker.flips; \ + bool expected_value = total_flips % 2; \ + \ + TEST_ASSERT(expected_value == rte_bit_test(&word, bit), \ + "After %"PRId64" flips, the bit value " \ + "should be %d", total_flips, expected_value); \ + \ + uint64_t expected_word = 0; \ + rte_bit_assign(&expected_word, bit, expected_value); \ + \ + TEST_ASSERT(expected_word == word, "Untouched bits have " \ + "changed value"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_PARALLEL_TEST_AND_MODIFY(32) +GEN_TEST_BIT_PARALLEL_TEST_AND_MODIFY(64) + +#define GEN_TEST_BIT_PARALLEL_FLIP (size) \ + \ + struct parallel_flip_lcore ## size \ + { \ + uint ## size ##_t *word; \ + unsigned int bit; \ + uint64_t flips; \ + }; \ + \ + static int \ + run_parallel_flip ## size(void *arg) \ + { \ + struct parallel_flip_lcore ## size *lcore = arg; \ + uint64_t deadline = rte_get_timer_cycles() + \ + PARALLEL_TEST_RUNTIME * rte_get_timer_hz(); \ + do { \ + rte_bit_atomic_flip(lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + lcore->flips++; \ + } while (rte_get_timer_cycles() < deadline); \ + \ + return 0; \ + } \ + \ + static int \ + test_bit_atomic_parallel_flip ## size(void) \ + { \ + unsigned int worker_lcore_id; \ + uint ## size ## _t word = 0; \ + unsigned int bit = rte_rand_max(size); \ + struct parallel_flip_lcore ## size lmain = { \ + .word = &word, \ + .bit = bit \ + }; \ + struct parallel_flip_lcore ## size lworker = { \ + .word = &word, \ + .bit = bit \ + }; \ + \ + if (rte_lcore_count() < 2) { \ + printf("Need multiple cores to run parallel test.\n"); \ + return TEST_SKIPPED; \ + } \ + \ + worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + \ + int rc = rte_eal_remote_launch(run_parallel_flip ## size, \ + &lworker, worker_lcore_id); \ + TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ + \ + run_parallel_flip ## size(&lmain); \ + \ + rte_eal_mp_wait_lcore(); \ + \ + uint64_t total_flips = lmain.flips + lworker.flips; \ + bool expected_value = total_flips % 2; \ + \ + TEST_ASSERT(expected_value == rte_bit_test(&word, bit), \ + "After %"PRId64" flips, the bit value " \ + "should be %d", total_flips, expected_value); \ + \ + uint64_t expected_word = 0; \ + rte_bit_assign(&expected_word, bit, expected_value); \ + \ + TEST_ASSERT(expected_word == word, "Untouched bits have " \ + "changed value"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_PARALLEL_FLIP(32) +GEN_TEST_BIT_PARALLEL_FLIP(64) +static uint32_t val32;static uint64_t val64;
@@ -177,6 +478,16 @@ static struct unit_test_suite test_suite = { .unit_test_cases = {TEST_CASE (test_bit_access32),TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_access32), +TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_atomic_access32), +TEST_CASE (test_bit_atomic_access64), +TEST_CASE (test_bit_atomic_parallel_assign32), +TEST_CASE (test_bit_atomic_parallel_assign64), +TEST_CASE (test_bit_atomic_parallel_test_and_modify32), +TEST_CASE (test_bit_atomic_parallel_test_and_modify64), +TEST_CASE (test_bit_atomic_parallel_flip32), +TEST_CASE (test_bit_atomic_parallel_flip64),TEST_CASE (test_bit_relaxed_set),TEST_CASE (test_bit_relaxed_clear), TEST_CASE(test_bit_relaxed_test_set_clear),
Signature · 1 line
2.34.1
PATCH v8 6/6 eal: extend bitops to handle volatile pointers
In reply to Mattias RönnblomHave rte_bit_[test|set|clear|assign|flip]() and rte_bit_atomic_*() handle volatile-marked pointers.
--
PATCH v3:
* Updated to reflect removed 'fun' parameter in __RTE_GEN_BIT_*() (Jack Bond-Preston).
PATCH v2:
* Actually run the test_bit_atomic_v_access*() test functions.
--- app/test/test_bitops.c | 32 +++- lib/eal/include/rte_bitops.h | 301 +++++++++++++++++++++++------------ 2 files changed, 222 insertions(+), 111 deletions(-)
app/test/test_bitops.c +25 -7
@@ -14,13 +14,13 @@#include "test.h" #define GEN_TEST_BIT_ACCESS (test_name, set_fun, clear_fun, assign_fun, \ - flip_fun, test_fun, size) \ + flip_fun, test_fun, size, mod) \ static int \ test_name(void) \ { \ uint ## size ## _t reference = (uint ## size ## _t)rte_rand(); \ unsigned int bit_nr; \ - uint ## size ## _t word = (uint ## size ## _t)rte_rand(); \ + mod uint ## size ## _t word = (uint ## size ## _t)rte_rand(); \ \ for (bit_nr = 0; bit_nr < size; bit_nr++) { \ bool reference_bit = (reference >> bit_nr) & 1; \
@@ -41,7 +41,7 @@ "Bit %d had unflipped value", bit_nr); \flip_fun (&word, bit_nr); \ \ - const uint ## size ## _t *const_ptr = &word; \ + const mod uint ## size ## _t *const_ptr = &word; \ TEST_ASSERT(test_fun(const_ptr, bit_nr) == \ reference_bit, \ "Bit %d had unexpected value", bit_nr); \
@@ -59,10 +59,16 @@ } GEN_TEST_BIT_ACCESS(test_bit_access32, rte_bit_set, rte_bit_clear, - rte_bit_assign, rte_bit_flip, rte_bit_test, 32) + rte_bit_assign, rte_bit_flip, rte_bit_test, 32,) GEN_TEST_BIT_ACCESS(test_bit_access64, rte_bit_set, rte_bit_clear, - rte_bit_assign, rte_bit_flip, rte_bit_test, 64) + rte_bit_assign, rte_bit_flip, rte_bit_test, 64,) + +GEN_TEST_BIT_ACCESS(test_bit_v_access32, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 32, volatile) + +GEN_TEST_BIT_ACCESS(test_bit_v_access64, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 64, volatile) #define bit_atomic_set(addr, nr) \ rte_bit_atomic_set(addr, nr, rte_memory_order_relaxed)
@@ -81,11 +87,19 @@ GEN_TEST_BIT_ACCESS(test_bit_access64, rte_bit_set, rte_bit_clear, GEN_TEST_BIT_ACCESS(test_bit_atomic_access32, bit_atomic_set, bit_atomic_clear, bit_atomic_assign, - bit_atomic_flip, bit_atomic_test, 32) + bit_atomic_flip, bit_atomic_test, 32,) GEN_TEST_BIT_ACCESS(test_bit_atomic_access64, bit_atomic_set, bit_atomic_clear, bit_atomic_assign, - bit_atomic_flip, bit_atomic_test, 64) + bit_atomic_flip, bit_atomic_test, 64,) + +GEN_TEST_BIT_ACCESS(test_bit_atomic_v_access32, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 32, volatile) + +GEN_TEST_BIT_ACCESS(test_bit_atomic_v_access64, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 64, volatile) #define PARALLEL_TEST_RUNTIME 0.25
@@ -480,8 +494,12 @@ static struct unit_test_suite test_suite = {TEST_CASE (test_bit_access64),TEST_CASE (test_bit_access32),TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_v_access32), +TEST_CASE (test_bit_v_access64),TEST_CASE (test_bit_atomic_access32),TEST_CASE (test_bit_atomic_access64), +TEST_CASE (test_bit_atomic_v_access32), +TEST_CASE (test_bit_atomic_v_access64),TEST_CASE (test_bit_atomic_parallel_assign32),TEST_CASE (test_bit_atomic_parallel_assign64), TEST_CASE(test_bit_atomic_parallel_test_and_modify32),
lib/eal/include/rte_bitops.h +197 -104
440 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v7 2/6 eal: extend bit manipulation functionality
In reply to Mattias RönnblomAdd functionality to test and modify the value of individual bits in 32-bit or 64-bit words.
These functions have no implications on memory ordering, atomicity and does not use volatile and thus does not prevent any compiler optimizations.
--
PATCH v3:
* Remove unnecessary <rte_compat.h> include.
* Remove redundant 'fun' parameter from the __RTE_GEN_BIT_*() macros (Jack Bond-Preston).
* Introduce __RTE_BIT_BIT_OPS() macro, consistent with how things are done when generating the atomic bit operations.
* Refer to volatile bit op functions as variants instead of families (macro parameter naming).
RFC v6:
* Have rte_bit_test() accept const-marked bitsets.
RFC v4:
* Add rte_bit_flip() which, believe it or not, flips the value of a bit.
* Mark macro-generated private functions as experimental.
* Use macros to generate *assign*() functions.
RFC v3:
* Work around lack of C++ support for _Generic (Tyler Retzlaff).
* Fix ','-related checkpatch warnings.
--- lib/eal/include/rte_bitops.h | 260 ++++++++++++++++++++++++++++++++++- 1 file changed, 258 insertions(+), 2 deletions(-)
lib/eal/include/rte_bitops.h +258 -2
@@ -2,6 +2,7 @@* Copyright(c) 2020 Arm Limited * Copyright(c) 2010-2019 Intel Corporation * Copyright(c) 2023 Microsoft Corporation +* Copyright(c) 2024 Ericsson AB */ #ifndef _RTE_BITOPS_H_
@@ -11,12 +12,14 @@* @file * Bit Operations * -* This file defines a family of APIs for bit operations -* without enforcing memory ordering. +* This file provides functionality for low-level, single-word +* arithmetic and bit-level operations, such as counting or +* setting individual bits. */ #include <stdint.h> +#include <rte_compat.h> #include <rte_debug.h> #ifdef __cplusplus
@@ -105,6 +108,197 @@ extern "C" {#define RTE_FIELD_GET64 (mask, reg) \ ((typeof(mask))(((reg) & (mask)) >> rte_ctz64(mask))) +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Test bit in word. +* +* Generic selection macro to test the value of a bit in a 32-bit or +* 64-bit word. The type of operation depends on the type of the @c +* addr parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_test (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_test32, \ + const uint32_t *: __rte_bit_test32, \ + uint64_t *: __rte_bit_test64, \ + const uint64_t *: __rte_bit_test64)(addr, nr) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Set bit in word. +* +* Generic selection macro to set a bit in a 32-bit or 64-bit +* word. The type of operation depends on the type of the @c addr +* parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_set (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_set32, \ + uint64_t *: __rte_bit_set64)(addr, nr) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Clear bit in word. +* +* Generic selection macro to clear a bit in a 32-bit or 64-bit +* word. The type of operation depends on the type of the @c addr +* parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_clear (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_clear32, \ + uint64_t *: __rte_bit_clear64)(addr, nr) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Assign a value to a bit in word. +* +* Generic selection macro to assign a value to a bit in a 32-bit or 64-bit +* word. The type of operation depends on the type of the @c addr parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +* @param value +* The new value of the bit - true for '1', or false for '0'. +*/ +#define rte_bit_assign (addr, nr, value) \ + _Generic((addr), \ + uint32_t *: __rte_bit_assign32, \ + uint64_t *: __rte_bit_assign64)(addr, nr, value) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Flip a bit in word. +* +* Generic selection macro to change the value of a bit to '0' if '1' +* or '1' if '0' in a 32-bit or 64-bit word. The type of operation +* depends on the type of the @c addr parameter. +* +* This macro does not give any guarantees in regards to memory +* ordering or atomicity. +* +* @param addr +* A pointer to the word to modify. +* @param nr +* The index of the bit. +*/ +#define rte_bit_flip (addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_flip32, \ + uint64_t *: __rte_bit_flip64)(addr, nr) + +#define __RTE_GEN_BIT_TEST (variant, qualifier, size) \ + __rte_experimental \ + static inline bool \ + __rte_bit_ ## variant ## test ## size(const qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = (uint ## size ## _t)1 << nr; \ + return *addr & mask; \ + } + +#define __RTE_GEN_BIT_SET (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## set ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = (uint ## size ## _t)1 << nr; \ + *addr |= mask; \ + } \ + +#define __RTE_GEN_BIT_CLEAR (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## clear ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = ~((uint ## size ## _t)1 << nr); \ + (*addr) &= mask; \ + } \ + +#define __RTE_GEN_BIT_ASSIGN (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## assign ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr, bool value) \ + { \ + if (value) \ + __rte_bit_ ## variant ## set ## size(addr, nr); \ + else \ + __rte_bit_ ## variant ## clear ## size(addr, nr); \ + } + +#define __RTE_GEN_BIT_FLIP (variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## flip ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + bool value; \ + \ + value = __rte_bit_ ## variant ## test ## size(addr, nr); \ + __rte_bit_ ## variant ## assign ## size(addr, nr, !value); \ + } + +#define __RTE_GEN_BIT_OPS (v, qualifier, size) \ + __RTE_GEN_BIT_TEST(v, qualifier, size) \ + __RTE_GEN_BIT_SET(v, qualifier, size) \ + __RTE_GEN_BIT_CLEAR(v, qualifier, size) \ + __RTE_GEN_BIT_ASSIGN(v, qualifier, size) \ + __RTE_GEN_BIT_FLIP(v, qualifier, size) + +#define __RTE_GEN_BIT_OPS_SIZE (size) \ + __RTE_GEN_BIT_OPS(,, size) + +__RTE_GEN_BIT_OPS_SIZE(32) +__RTE_GEN_BIT_OPS_SIZE (64 ) +/*------------------------ 32-bit relaxed operations ------------------------*/ /**
@@ -787,6 +981,68 @@ rte_log2_u64(uint64_t v)#ifdef __cplusplus } + +/* +* Since C++ doesn't support generic selection (i.e., _Generic), +* function overloading is used instead. Such functions must be +* defined outside 'extern "C"' to be accepted by the compiler. +*/ + +#undef rte_bit_test +#undef rte_bit_set +#undef rte_bit_clear +#undef rte_bit_assign +#undef rte_bit_flip + +#define __RTE_BIT_OVERLOAD_SZ_2 (fun, qualifier, size, arg1_type, arg1_name) \ + static inline void \ + rte_bit_ ## fun(qualifier uint ## size ## _t *addr, \ + arg1_type arg1_name) \ + { \ + __rte_bit_ ## fun ## size(addr, arg1_name); \ + } + +#define __RTE_BIT_OVERLOAD_2 (fun, qualifier, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2(fun, qualifier, 32, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2(fun, qualifier, 64, arg1_type, arg1_name) + +#define __RTE_BIT_OVERLOAD_SZ_2R (fun, qualifier, size, ret_type, arg1_type, \ + arg1_name) \ + static inline ret_type \ + rte_bit_ ## fun(qualifier uint ## size ## _t *addr, \ + arg1_type arg1_name) \ + { \ + return __rte_bit_ ## fun ## size(addr, arg1_name); \ + } + +#define __RTE_BIT_OVERLOAD_2R (fun, qualifier, ret_type, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2R(fun, qualifier, 32, ret_type, arg1_type, \ + arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2R(fun, qualifier, 64, ret_type, arg1_type, \ + arg1_name) + +#define __RTE_BIT_OVERLOAD_SZ_3 (fun, qualifier, size, arg1_type, arg1_name, \ + arg2_type, arg2_name) \ + static inline void \ + rte_bit_ ## fun(uint ## size ## _t *addr, arg1_type arg1_name, \ + arg2_type arg2_name) \ + { \ + __rte_bit_ ## fun ## size(addr, arg1_name, arg2_name); \ + } + +#define __RTE_BIT_OVERLOAD_3 (fun, qualifier, arg1_type, arg1_name, arg2_type, \ + arg2_name) \ + __RTE_BIT_OVERLOAD_SZ_3(fun, qualifier, 32, arg1_type, arg1_name, \ + arg2_type, arg2_name) \ + __RTE_BIT_OVERLOAD_SZ_3(fun, qualifier, 64, arg1_type, arg1_name, \ + arg2_type, arg2_name) + +__RTE_BIT_OVERLOAD_2R(test, const, bool, unsigned int, nr) +__RTE_BIT_OVERLOAD_2(set,, unsigned int, nr) +__RTE_BIT_OVERLOAD_2(clear,, unsigned int, nr) +__RTE_BIT_OVERLOAD_3(assign,, unsigned int, nr, bool, value) +__RTE_BIT_OVERLOAD_2(flip,, unsigned int, nr) +#endif #endif /* _RTE_BITOPS_H_ */
Signature · 1 line
2.34.1
PATCH v7 3/6 eal: add unit tests for bit operations
In reply to Mattias RönnblomExtend bitops tests to cover the
rte_bit_[test|set|clear|assign|flip]()
functions.
The tests are converted to use the test suite runner framework.
--
RFC v6:
* Test rte_bit_*test() usage through const pointers.
RFC v4:
* Remove redundant line continuations.
--- app/test/test_bitops.c | 85 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 15 deletions(-)
app/test/test_bitops.c +70 -15
@@ -1,13 +1,68 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2019 Arm Limited +* Copyright(c) 2024 Ericsson AB */ +#include <stdbool.h> +#include <rte_launch.h> #include <rte_bitops.h> +#include <rte_random.h> #include "test.h" -uint32_t val32; -uint64_t val64; +#define GEN_TEST_BIT_ACCESS (test_name, set_fun, clear_fun, assign_fun, \ + flip_fun, test_fun, size) \ + static int \ + test_name(void) \ + { \ + uint ## size ## _t reference = (uint ## size ## _t)rte_rand(); \ + unsigned int bit_nr; \ + uint ## size ## _t word = (uint ## size ## _t)rte_rand(); \ + \ + for (bit_nr = 0; bit_nr < size; bit_nr++) { \ + bool reference_bit = (reference >> bit_nr) & 1; \ + bool assign = rte_rand() & 1; \ + if (assign) \ + assign_fun(&word, bit_nr, reference_bit); \ + else { \ + if (reference_bit) \ + set_fun(&word, bit_nr); \ + else \ + clear_fun(&word, bit_nr); \ + \ + } \ + TEST_ASSERT(test_fun(&word, bit_nr) == reference_bit, \ + "Bit %d had unexpected value", bit_nr); \ + flip_fun(&word, bit_nr); \ + TEST_ASSERT(test_fun(&word, bit_nr) != reference_bit, \ + "Bit %d had unflipped value", bit_nr); \ + flip_fun(&word, bit_nr); \ + \ + const uint ## size ## _t *const_ptr = &word; \ + TEST_ASSERT(test_fun(const_ptr, bit_nr) == \ + reference_bit, \ + "Bit %d had unexpected value", bit_nr); \ + } \ + \ + for (bit_nr = 0; bit_nr < size; bit_nr++) { \ + bool reference_bit = (reference >> bit_nr) & 1; \ + TEST_ASSERT(test_fun(&word, bit_nr) == reference_bit, \ + "Bit %d had unexpected value", bit_nr); \ + } \ + \ + TEST_ASSERT(reference == word, "Word had unexpected value"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_ACCESS (test_bit_access32, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 32) + +GEN_TEST_BIT_ACCESS (test_bit_access64, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 64) + +static uint32_t val32; +static uint64_t val64;#define MAX_BITS_32 32#define MAX_BITS_64 64
@@ -117,22 +172,22 @@ test_bit_relaxed_test_set_clear(void)return TEST_SUCCESS ; } +static struct unit_test_suite test_suite = { + .suite_name ="Bitops test suite" , + .unit_test_cases = { +TEST_CASE (test_bit_access32), +TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_relaxed_set), +TEST_CASE (test_bit_relaxed_clear), +TEST_CASE (test_bit_relaxed_test_set_clear), +TEST_CASES_END () + } +}; +static int test_bitops (void ) { - val32 =0 ; - val64 =0 ; - -if (test_bit_relaxed_set () <0 ) -return TEST_FAILED ; - -if (test_bit_relaxed_clear () <0 ) -return TEST_FAILED ; - -if (test_bit_relaxed_test_set_clear () <0 ) -return TEST_FAILED ; - -return TEST_SUCCESS ; +return unit_test_suite_runner (&test_suite); }REGISTER_FAST_TEST (bitops_autotest, true, true, test_bitops);
Signature · 1 line
2.34.1
PATCH v7 4/6 eal: add atomic bit operations
In reply to Mattias RönnblomAdd atomic bit test/set/clear/assign/flip and
test-and-set/clear/assign/flip functions.
All atomic bit functions allow (and indeed, require) the caller to specify a memory order.
--
PATCH v3:
* Introduce __RTE_GEN_BIT_ATOMIC_*() 'qualifier' argument already in this patch (Jack Bond-Preston).
* Refer to volatile bit op functions as variants instead of families (macro parameter naming).
* Update release notes.
PATCH:
* Add missing macro #undef for C++ version of atomic bit flip.
RFC v7:
* Replace compare-exchange-based rte_bitset_atomic_test_and_*() and flip() with implementations that use the previous value as returned by the atomic fetch function.
* Reword documentation to match the non-atomic macro variants.
* Remove pointer to <rte_stdatomic.h> for memory model documentation, since there is no documentation for that API.
RFC v6:
* Have rte_bit_atomic_test() accept const-marked bitsets.
RFC v4:
* Add atomic bit flip.
* Mark macro-generated private functions experimental.
RFC v3:
* Work around lack of C++ support for _Generic (Tyler Retzlaff).
RFC v2:
o Add rte_bit_atomic_test_and_assign() (for consistency).
o Fix bugs in rte_bit_atomic_test_and_[set|clear]().
o Use <rte_stdatomics.h> to support MSVC.
--- doc/guides/rel_notes/release_24_11.rst | 17 + lib/eal/include/rte_bitops.h | 415 +++++++++++++++++++++++++ 2 files changed, 432 insertions(+)
doc/guides/rel_notes/release_24_11.rst +17 -0
@@ -56,6 +56,23 @@ New Features ======================================================= +* **Extended bit operations API.** + + The support for bit-level operations on single 32- and 64-bit words + in <rte_bitops.h> has been extended with two families of + semantically well-defined functions. + + rte_bit_[test|set|clear|assign|flip]() functions provide excellent + performance (by avoiding restricting the compiler and CPU), but give + no guarantees in regards to memory ordering or atomicity. + + rte_bit_atomic_*() provides atomic bit-level operations, including + the possibility to specifying memory ordering constraints. + + The new public API elements are polymorphic, using the _Generic- + based macros (for C) and function overloading (in C++ translation + units). + Removed Items -------------
lib/eal/include/rte_bitops.h +415 -0
451 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v7 5/6 eal: add unit tests for atomic bit access functions
In reply to Mattias RönnblomExtend bitops tests to cover the rte_bit_atomic_*() family of functions.
--
RFC v4:
* Add atomicity test for atomic bit flip.
RFC v3:
* Rename variable 'main' to make ICC happy.
--- app/test/test_bitops.c | 313 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 312 insertions(+), 1 deletion(-)
app/test/test_bitops.c +312 -1
@@ -3,10 +3,13 @@* Copyright(c) 2024 Ericsson AB */ +#include <inttypes.h> #include <stdbool.h> -#include <rte_launch.h> #include <rte_bitops.h> +#include <rte_cycles.h> +#include <rte_launch.h> +#include <rte_lcore.h> #include <rte_random.h> #include "test.h"
@@ -61,6 +64,304 @@ GEN_TEST_BIT_ACCESS(test_bit_access32, rte_bit_set, rte_bit_clear,GEN_TEST_BIT_ACCESS (test_bit_access64, rte_bit_set, rte_bit_clear, rte_bit_assign, rte_bit_flip, rte_bit_test, 64) +#define bit_atomic_set (addr, nr) \ + rte_bit_atomic_set(addr, nr, rte_memory_order_relaxed) + +#define bit_atomic_clear (addr, nr) \ + rte_bit_atomic_clear(addr, nr, rte_memory_order_relaxed) + +#define bit_atomic_assign (addr, nr, value) \ + rte_bit_atomic_assign(addr, nr, value, rte_memory_order_relaxed) + +#define bit_atomic_flip (addr, nr) \ + rte_bit_atomic_flip(addr, nr, rte_memory_order_relaxed) + +#define bit_atomic_test (addr, nr) \ + rte_bit_atomic_test(addr, nr, rte_memory_order_relaxed) + +GEN_TEST_BIT_ACCESS (test_bit_atomic_access32, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 32) + +GEN_TEST_BIT_ACCESS (test_bit_atomic_access64, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 64) + +#define PARALLEL_TEST_RUNTIME 0.25 + +#define GEN_TEST_BIT_PARALLEL_ASSIGN (size) \ + \ + struct parallel_access_lcore ## size \ + { \ + unsigned int bit; \ + uint ## size ##_t *word; \ + bool failed; \ + }; \ + \ + static int \ + run_parallel_assign ## size(void *arg) \ + { \ + struct parallel_access_lcore ## size *lcore = arg; \ + uint64_t deadline = rte_get_timer_cycles() + \ + PARALLEL_TEST_RUNTIME * rte_get_timer_hz(); \ + bool value = false; \ + \ + do { \ + bool new_value = rte_rand() & 1; \ + bool use_test_and_modify = rte_rand() & 1; \ + bool use_assign = rte_rand() & 1; \ + \ + if (rte_bit_atomic_test(lcore->word, lcore->bit, \ + rte_memory_order_relaxed) != value) { \ + lcore->failed = true; \ + break; \ + } \ + \ + if (use_test_and_modify) { \ + bool old_value; \ + if (use_assign) \ + old_value = rte_bit_atomic_test_and_assign( \ + lcore->word, lcore->bit, new_value, \ + rte_memory_order_relaxed); \ + else { \ + old_value = new_value ? \ + rte_bit_atomic_test_and_set( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed) : \ + rte_bit_atomic_test_and_clear( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + } \ + if (old_value != value) { \ + lcore->failed = true; \ + break; \ + } \ + } else { \ + if (use_assign) \ + rte_bit_atomic_assign(lcore->word, lcore->bit, \ + new_value, \ + rte_memory_order_relaxed); \ + else { \ + if (new_value) \ + rte_bit_atomic_set( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + else \ + rte_bit_atomic_clear( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + } \ + } \ + \ + value = new_value; \ + } while (rte_get_timer_cycles() < deadline); \ + \ + return 0; \ + } \ + \ + static int \ + test_bit_atomic_parallel_assign ## size(void) \ + { \ + unsigned int worker_lcore_id; \ + uint ## size ## _t word = 0; \ + struct parallel_access_lcore ## size lmain = { \ + .word = &word \ + }; \ + struct parallel_access_lcore ## size lworker = { \ + .word = &word \ + }; \ + \ + if (rte_lcore_count() < 2) { \ + printf("Need multiple cores to run parallel test.\n"); \ + return TEST_SKIPPED; \ + } \ + \ + worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + \ + lmain.bit = rte_rand_max(size); \ + do { \ + lworker.bit = rte_rand_max(size); \ + } while (lworker.bit == lmain.bit); \ + \ + int rc = rte_eal_remote_launch(run_parallel_assign ## size, \ + &lworker, worker_lcore_id); \ + TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ + \ + run_parallel_assign ## size(&lmain); \ + \ + rte_eal_mp_wait_lcore(); \ + \ + TEST_ASSERT(!lmain.failed, "Main lcore atomic access failed"); \ + TEST_ASSERT(!lworker.failed, "Worker lcore atomic access " \ + "failed"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_PARALLEL_ASSIGN(32) +GEN_TEST_BIT_PARALLEL_ASSIGN(64) + +#define GEN_TEST_BIT_PARALLEL_TEST_AND_MODIFY (size) \ + \ + struct parallel_test_and_set_lcore ## size \ + { \ + uint ## size ##_t *word; \ + unsigned int bit; \ + uint64_t flips; \ + }; \ + \ + static int \ + run_parallel_test_and_modify ## size(void *arg) \ + { \ + struct parallel_test_and_set_lcore ## size *lcore = arg; \ + uint64_t deadline = rte_get_timer_cycles() + \ + PARALLEL_TEST_RUNTIME * rte_get_timer_hz(); \ + do { \ + bool old_value; \ + bool new_value = rte_rand() & 1; \ + bool use_assign = rte_rand() & 1; \ + \ + if (use_assign) \ + old_value = rte_bit_atomic_test_and_assign( \ + lcore->word, lcore->bit, new_value, \ + rte_memory_order_relaxed); \ + else \ + old_value = new_value ? \ + rte_bit_atomic_test_and_set( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed) : \ + rte_bit_atomic_test_and_clear( \ + lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + if (old_value != new_value) \ + lcore->flips++; \ + } while (rte_get_timer_cycles() < deadline); \ + \ + return 0; \ + } \ + \ + static int \ + test_bit_atomic_parallel_test_and_modify ## size(void) \ + { \ + unsigned int worker_lcore_id; \ + uint ## size ## _t word = 0; \ + unsigned int bit = rte_rand_max(size); \ + struct parallel_test_and_set_lcore ## size lmain = { \ + .word = &word, \ + .bit = bit \ + }; \ + struct parallel_test_and_set_lcore ## size lworker = { \ + .word = &word, \ + .bit = bit \ + }; \ + \ + if (rte_lcore_count() < 2) { \ + printf("Need multiple cores to run parallel test.\n"); \ + return TEST_SKIPPED; \ + } \ + \ + worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + \ + int rc = rte_eal_remote_launch(run_parallel_test_and_modify ## size, \ + &lworker, worker_lcore_id); \ + TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ + \ + run_parallel_test_and_modify ## size(&lmain); \ + \ + rte_eal_mp_wait_lcore(); \ + \ + uint64_t total_flips = lmain.flips + lworker.flips; \ + bool expected_value = total_flips % 2; \ + \ + TEST_ASSERT(expected_value == rte_bit_test(&word, bit), \ + "After %"PRId64" flips, the bit value " \ + "should be %d", total_flips, expected_value); \ + \ + uint64_t expected_word = 0; \ + rte_bit_assign(&expected_word, bit, expected_value); \ + \ + TEST_ASSERT(expected_word == word, "Untouched bits have " \ + "changed value"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_PARALLEL_TEST_AND_MODIFY(32) +GEN_TEST_BIT_PARALLEL_TEST_AND_MODIFY(64) + +#define GEN_TEST_BIT_PARALLEL_FLIP (size) \ + \ + struct parallel_flip_lcore ## size \ + { \ + uint ## size ##_t *word; \ + unsigned int bit; \ + uint64_t flips; \ + }; \ + \ + static int \ + run_parallel_flip ## size(void *arg) \ + { \ + struct parallel_flip_lcore ## size *lcore = arg; \ + uint64_t deadline = rte_get_timer_cycles() + \ + PARALLEL_TEST_RUNTIME * rte_get_timer_hz(); \ + do { \ + rte_bit_atomic_flip(lcore->word, lcore->bit, \ + rte_memory_order_relaxed); \ + lcore->flips++; \ + } while (rte_get_timer_cycles() < deadline); \ + \ + return 0; \ + } \ + \ + static int \ + test_bit_atomic_parallel_flip ## size(void) \ + { \ + unsigned int worker_lcore_id; \ + uint ## size ## _t word = 0; \ + unsigned int bit = rte_rand_max(size); \ + struct parallel_flip_lcore ## size lmain = { \ + .word = &word, \ + .bit = bit \ + }; \ + struct parallel_flip_lcore ## size lworker = { \ + .word = &word, \ + .bit = bit \ + }; \ + \ + if (rte_lcore_count() < 2) { \ + printf("Need multiple cores to run parallel test.\n"); \ + return TEST_SKIPPED; \ + } \ + \ + worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + \ + int rc = rte_eal_remote_launch(run_parallel_flip ## size, \ + &lworker, worker_lcore_id); \ + TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ + \ + run_parallel_flip ## size(&lmain); \ + \ + rte_eal_mp_wait_lcore(); \ + \ + uint64_t total_flips = lmain.flips + lworker.flips; \ + bool expected_value = total_flips % 2; \ + \ + TEST_ASSERT(expected_value == rte_bit_test(&word, bit), \ + "After %"PRId64" flips, the bit value " \ + "should be %d", total_flips, expected_value); \ + \ + uint64_t expected_word = 0; \ + rte_bit_assign(&expected_word, bit, expected_value); \ + \ + TEST_ASSERT(expected_word == word, "Untouched bits have " \ + "changed value"); \ + \ + return TEST_SUCCESS; \ + } + +GEN_TEST_BIT_PARALLEL_FLIP(32) +GEN_TEST_BIT_PARALLEL_FLIP(64) +static uint32_t val32;static uint64_t val64;
@@ -177,6 +478,16 @@ static struct unit_test_suite test_suite = { .unit_test_cases = {TEST_CASE (test_bit_access32),TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_access32), +TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_atomic_access32), +TEST_CASE (test_bit_atomic_access64), +TEST_CASE (test_bit_atomic_parallel_assign32), +TEST_CASE (test_bit_atomic_parallel_assign64), +TEST_CASE (test_bit_atomic_parallel_test_and_modify32), +TEST_CASE (test_bit_atomic_parallel_test_and_modify64), +TEST_CASE (test_bit_atomic_parallel_flip32), +TEST_CASE (test_bit_atomic_parallel_flip64),TEST_CASE (test_bit_relaxed_set),TEST_CASE (test_bit_relaxed_clear), TEST_CASE(test_bit_relaxed_test_set_clear),
Signature · 1 line
2.34.1
PATCH v7 6/6 eal: extend bitops to handle volatile pointers
In reply to Mattias RönnblomHave rte_bit_[test|set|clear|assign|flip]() and rte_bit_atomic_*() handle volatile-marked pointers.
--
PATCH v3:
* Updated to reflect removed 'fun' parameter in __RTE_GEN_BIT_*() (Jack Bond-Preston).
PATCH v2:
* Actually run the test_bit_atomic_v_access*() test functions.
--- app/test/test_bitops.c | 32 +++- lib/eal/include/rte_bitops.h | 301 +++++++++++++++++++++++------------ 2 files changed, 222 insertions(+), 111 deletions(-)
app/test/test_bitops.c +25 -7
@@ -14,13 +14,13 @@#include "test.h" #define GEN_TEST_BIT_ACCESS (test_name, set_fun, clear_fun, assign_fun, \ - flip_fun, test_fun, size) \ + flip_fun, test_fun, size, mod) \ static int \ test_name(void) \ { \ uint ## size ## _t reference = (uint ## size ## _t)rte_rand(); \ unsigned int bit_nr; \ - uint ## size ## _t word = (uint ## size ## _t)rte_rand(); \ + mod uint ## size ## _t word = (uint ## size ## _t)rte_rand(); \ \ for (bit_nr = 0; bit_nr < size; bit_nr++) { \ bool reference_bit = (reference >> bit_nr) & 1; \
@@ -41,7 +41,7 @@ "Bit %d had unflipped value", bit_nr); \flip_fun (&word, bit_nr); \ \ - const uint ## size ## _t *const_ptr = &word; \ + const mod uint ## size ## _t *const_ptr = &word; \ TEST_ASSERT(test_fun(const_ptr, bit_nr) == \ reference_bit, \ "Bit %d had unexpected value", bit_nr); \
@@ -59,10 +59,16 @@ } GEN_TEST_BIT_ACCESS(test_bit_access32, rte_bit_set, rte_bit_clear, - rte_bit_assign, rte_bit_flip, rte_bit_test, 32) + rte_bit_assign, rte_bit_flip, rte_bit_test, 32,) GEN_TEST_BIT_ACCESS(test_bit_access64, rte_bit_set, rte_bit_clear, - rte_bit_assign, rte_bit_flip, rte_bit_test, 64) + rte_bit_assign, rte_bit_flip, rte_bit_test, 64,) + +GEN_TEST_BIT_ACCESS(test_bit_v_access32, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 32, volatile) + +GEN_TEST_BIT_ACCESS(test_bit_v_access64, rte_bit_set, rte_bit_clear, + rte_bit_assign, rte_bit_flip, rte_bit_test, 64, volatile) #define bit_atomic_set(addr, nr) \ rte_bit_atomic_set(addr, nr, rte_memory_order_relaxed)
@@ -81,11 +87,19 @@ GEN_TEST_BIT_ACCESS(test_bit_access64, rte_bit_set, rte_bit_clear, GEN_TEST_BIT_ACCESS(test_bit_atomic_access32, bit_atomic_set, bit_atomic_clear, bit_atomic_assign, - bit_atomic_flip, bit_atomic_test, 32) + bit_atomic_flip, bit_atomic_test, 32,) GEN_TEST_BIT_ACCESS(test_bit_atomic_access64, bit_atomic_set, bit_atomic_clear, bit_atomic_assign, - bit_atomic_flip, bit_atomic_test, 64) + bit_atomic_flip, bit_atomic_test, 64,) + +GEN_TEST_BIT_ACCESS(test_bit_atomic_v_access32, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 32, volatile) + +GEN_TEST_BIT_ACCESS(test_bit_atomic_v_access64, bit_atomic_set, + bit_atomic_clear, bit_atomic_assign, + bit_atomic_flip, bit_atomic_test, 64, volatile) #define PARALLEL_TEST_RUNTIME 0.25
@@ -480,8 +494,12 @@ static struct unit_test_suite test_suite = {TEST_CASE (test_bit_access64),TEST_CASE (test_bit_access32),TEST_CASE (test_bit_access64), +TEST_CASE (test_bit_v_access32), +TEST_CASE (test_bit_v_access64),TEST_CASE (test_bit_atomic_access32),TEST_CASE (test_bit_atomic_access64), +TEST_CASE (test_bit_atomic_v_access32), +TEST_CASE (test_bit_atomic_v_access64),TEST_CASE (test_bit_atomic_parallel_assign32),TEST_CASE (test_bit_atomic_parallel_assign64), TEST_CASE(test_bit_atomic_parallel_test_and_modify32),
lib/eal/include/rte_bitops.h +197 -104
440 lines not on this page · raw message
Signature · 1 line
2.34.1
v2 cover Add bitset type
In reply to Mattias Rönnblomv1 did not go through the CI.
Resending this series after rebasing and doing some coding style changes.
Signature · 29 lines
David Marchand Mattias Rönnblom (4): eal: add bitset type bitset: add atomic functions service: use multi-word bitset to represent service flags event/dsw: add support for larger port count MAINTAINERS | 6 + app/test/meson.build | 1 + app/test/test_bitset.c | 905 +++++++++++++++++++ doc/api/doxy-api-index.md | 1 + doc/guides/rel_notes/release_24_11.rst | 9 + drivers/event/dsw/dsw_evdev.c | 19 +- drivers/event/dsw/dsw_evdev.h | 3 +- drivers/event/dsw/dsw_event.c | 7 +- lib/eal/common/meson.build | 1 + lib/eal/common/rte_bitset.c | 30 + lib/eal/common/rte_service.c | 70 +- lib/eal/include/meson.build | 1 + lib/eal/include/rte_bitset.h | 1141 ++++++++++++++++++++++++ lib/eal/version.map | 3 + 14 files changed, 2138 insertions(+), 59 deletions(-) create mode 100644 app/test/test_bitset.c create mode 100644 lib/eal/common/rte_bitset.c create mode 100644 lib/eal/include/rte_bitset.h -- 2.46.2
PATCH v2 1/4 eal: add bitset type
From: Mattias Rönnblom <[email protected]>
Introduce a set of functions and macros that operate on sets of bits, kept in arrays of 64-bit words.
RTE bitset is designed for bitsets which are larger than what fits in a single machine word (i.e., 64 bits).
For very large bitsets, the <rte_bitmap.h> API may be a more appropriate choice.
--- MAINTAINERS | 6 + app/test/meson.build | 1 + app/test/test_bitset.c | 861 +++++++++++++++++++++ doc/api/doxy-api-index.md | 1 + doc/guides/rel_notes/release_24_11.rst | 9 + lib/eal/common/meson.build | 1 + lib/eal/common/rte_bitset.c | 30 + lib/eal/include/meson.build | 1 + lib/eal/include/rte_bitset.h | 998 +++++++++++++++++++++++++ lib/eal/version.map | 3 + 10 files changed, 1911 insertions(+) create mode 100644 app/test/test_bitset.c create mode 100644 lib/eal/common/rte_bitset.c create mode 100644 lib/eal/include/rte_bitset.h
MAINTAINERS +6 -0
@@ -255,6 +255,12 @@ M: Jack Bond-Preston <[email protected]> F: lib/eal/include/rte_bitops.h F: app/test/test_bitops.c +Bitset +M: Mattias Rönnblom <[email protected]> +F: lib/eal/include/rte_bitset.h +F: lib/eal/common/rte_bitset.c +F: app/test/test_bitset.c + Bitmap M: Cristian Dumitrescu <[email protected]> F: lib/eal/include/rte_bitmap.h
app/test/meson.build +1 -0
@@ -33,6 +33,7 @@ source_file_deps = { 'test_bitcount.c': [], 'test_bitmap.c': [], 'test_bitops.c': [], + 'test_bitset.c': [], 'test_bitratestats.c': ['metrics', 'bitratestats', 'ethdev'] + sample_packet_forward_deps, 'test_bpf.c': ['bpf', 'net'], 'test_byteorder.c': [],
app/test/test_bitset.c new file +861 -0
861 lines not on this page · raw message
doc/api/doxy-api-index.md +1 -0
@@ -174,6 +174,7 @@ The public API headers are grouped by topics: [ring](@ref rte_ring.h), [stack](@ref rte_stack.h), [tailq](@ref rte_tailq.h), + [bitset](@ref rte_bitset.h), [bitmap](@ref rte_bitmap.h) - **packet framework**:
doc/guides/rel_notes/release_24_11.rst +9 -0
@@ -70,6 +70,15 @@ New Features The new public API elements are polymorphic, using the _Generic-based macros (for C) and function overloading (in C++ translation units). +* **Added multi-word bitset API.** + + A new multi-word bitset API has been introduced in the EAL. + The RTE bitset is optimized for scenarios where the bitset size exceeds the + capacity of a single word (e.g., larger than 64 bits), but is not large + enough to justify the overhead and complexity of the more scalable, + yet slower, <rte_bitmap.h> API. This addition provides an efficient and + straightforward alternative for handling bitsets of intermediate sizes. + * **Extended service cores statistics.** Two new per-service counters are added to the service cores framework.
lib/eal/common/meson.build +1 -0
@@ -31,6 +31,7 @@ sources += files( 'eal_common_uuid.c', 'malloc_elem.c', 'malloc_heap.c', + 'rte_bitset.c', 'rte_malloc.c', 'rte_random.c', 'rte_reciprocal.c',
lib/eal/common/rte_bitset.c new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2023 Ericsson AB +*/ + +#include <errno.h> +#include <stdbool.h> +#include <stdint.h> +#include <sys/types.h> + +#include "rte_bitset.h" + +ssize_t +rte_bitset_to_str (const uint64_t *bitset,size_t num_bits,char *buf,size_t capacity) +{ +size_t i; + +if (capacity < (num_bits +1 )) +return -EINVAL ; + +for (i =0 ; i < num_bits; i++) { +bool value; + + value =rte_bitset_test (bitset, num_bits -1 - i); + buf[i] = value ?'1' :'0' ; + } + + buf[num_bits] ='\0' ; + +return num_bits +1 ; +}
lib/eal/include/meson.build +1 -0
@@ -7,6 +7,7 @@ headers += files( 'rte_alarm.h', 'rte_bitmap.h', 'rte_bitops.h', + 'rte_bitset.h', 'rte_branch_prediction.h', 'rte_bus.h', 'rte_class.h',
lib/eal/include/rte_bitset.h new file +998 -0
998 lines not on this page · raw message
lib/eal/version.map +3 -0
@@ -396,6 +396,9 @@ EXPERIMENTAL { # added in 24.03 rte_vfio_get_device_info; # WINDOWS_NO_EXPORT + + # added in 24.11 + rte_bitset_to_str; }; INTERNAL {
Signature · 1 line
2.46.2