Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2e5fb2e
FreeBSD: add FreeBSD-specific build wrapper
kostikbel Dec 25, 2025
f0281a5
libibverbs/cmd_ioctl.h: fix typo in comment
kostikbel Mar 9, 2026
3f5cdd0
test version script: symbols are exported from the binary on FreeBSD
kostikbel Nov 5, 2025
e9512dd
buildlib/rdma_functions.cmake: drop -T option from ln(1) invocation
kostikbel Nov 5, 2025
ad03eb1
buildlib/config.h.in: Make RDMA_CDEV_DIR right on FreeBSD
kostikbel Feb 17, 2026
eaff7af
CMakeLists.txt: netlink/netlink.h and netlink/route/route.h exist on …
kostikbel Dec 25, 2025
4769bb6
librdmacm: on FreeBSD, epoll() is provided by epoll-shim
kostikbel Dec 25, 2025
4372098
*/*: AF_* come from sys/socket.h
kostikbel Dec 24, 2025
a2bb45b
*/*: add netinet/in.h and linux/ip6.h headers
kostikbel Dec 24, 2025
f703b58
libibverbs/examples/xsrq_pingpong.c: needs sys/stat.h for S_IRUSR and…
kostikbel Dec 25, 2025
5ea1ec7
*/*: avoid redefining ALIGN() macro
kostikbel Dec 25, 2025
15a18a5
librdmacm/preload.c: handle namespace polluition from the epoll-shim
kostikbel Jul 21, 2026
297464d
librdmacm/preload.c: account for differences in sendfile with FreeBSD
kostikbel Dec 26, 2025
2a7efbf
librdmacm/preload.c: switch init control to pthread_once
kostikbel Dec 26, 2025
3e7a47b
librdmacm/preload.c: provide program_invocation_short_name for FreeBSD
kostikbel Dec 26, 2025
8350d4d
librdmacm/preload.c: conditionalize handling of non-portable fcntls
kostikbel Dec 26, 2025
5e4916e
FreeBSD: add compat headers to mimic Linux build environment
kostikbel Dec 3, 2025
da63c63
madvise(MADV_*FORK) is spelled minherit(2) on FreeBSD
kostikbel Dec 26, 2025
15499b4
providers/rxe/rxe.c: use portable way to name ipv6 address field in s…
kostikbel Dec 28, 2025
96070e2
pyverbs/providers/mlx5/dr_action.pyx: fix type mismatch
kostikbel Dec 27, 2025
7ef310e
libibverbs: Split Linux-specific initialization into dedicated source
kostikbel Jan 10, 2026
56099b1
libibverbs: Add FreeBSD-specific implementation of init and sysfs access
kostikbel Jan 19, 2026
9945f29
libibverbs/sysfs-sysctl.c: hack for ibv_read_ibdev_sysfs_file("device…
kostikbel Feb 10, 2026
4757d1e
FreeBSD: add IBVERBS_SYSCTL_VERBOSE
kostikbel Feb 2, 2026
bf9b7be
dso versions: set the base to 100 for FreeBSD
kostikbel Aug 11, 2026
bbf0c79
Add README-FreeBSD.txt
kostikbel Dec 28, 2025
a82a1c3
buildlib/make_abi_structs.py: allow #ifdef <system name>
kostikbel Jun 2, 2026
1817d3c
kernel-headers/rdma/mlx5-abi.h: provide FreeBSD layout for mlx5_ib_cr…
kostikbel Jun 2, 2026
34922cc
FreeBSD github ci workflow
kostikbel Jul 13, 2026
0f8b957
FindUDev.cmake: Also set the UDEV_INCLUDE_DIRS var
arrowd Aug 1, 2026
1b26c08
FreeBSD CI: Install the libudev-devd dependency
arrowd Aug 1, 2026
c3093c3
Install contents of freebsd-headers into public location
arrowd Aug 10, 2026
9ae409e
Fix building on FreeBSD/aarch64
arrowd Aug 14, 2026
fce59a7
Get rid of bundled freebsd-headers
arrowd Aug 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/freebsd-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: FreeBSD Build

on:
push:
branches: [ "freebsd" ]
pull_request:
branches: [ "freebsd" ]

jobs:
build-freebsd:
# vmactions runs a QEMU VM inside an Ubuntu runner, so runs-on MUST be ubuntu-latest
runs-on: ubuntu-latest
name: Build rdma-core on FreeBSD

steps:
# Step 1: Check out your rdma-core repository into the Ubuntu host runner
- name: Checkout Code
uses: actions/checkout@v4

# Step 2: Fire up the FreeBSD VM and execute the build steps
- name: Build in FreeBSD VM
uses: vmactions/freebsd-vm@v1
with:
release: "15.1"
usesh: true # Use standard sh rather than tcsh (default shell on FreeBSD)

# The 'prepare' section runs inside the VM before copying files,
# ideal for installing system package dependencies.
prepare: |
uname -a
pkg install -y gcc cmake ninja python3 bash libepoll-shim \
linuxapi libudev-devd pkgconf lang/cython

run: |
bash build-freebsd.sh
13 changes: 11 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,13 @@ FIND_PACKAGE (Threads REQUIRED)

FIND_PACKAGE(PkgConfig REQUIRED)

if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
find_package(linuxapi REQUIRED)
include_directories(BEFORE ${linuxapi_INCLUDE_DIR})
# We need to add an additional -I flag to all generated .pc files
set(PC_FREEBSD_CFLAGS "-I${linuxapi_INCLUDE_DIR}")
endif()

# libnl
if (NOT DEFINED ENABLE_RESOLVE_NEIGH)
set(ENABLE_RESOLVE_NEIGH "ON" CACHE BOOL "Enable internal resolution of neighbours for Etherent")
Expand All @@ -564,13 +571,15 @@ else()
set(NL_LIBRARIES "")
RDMA_DoFixup(0 "netlink/attr.h")
RDMA_DoFixup(0 "netlink/msg.h")
RDMA_DoFixup(0 "netlink/netlink.h")
RDMA_DoFixup(0 "netlink/object-api.h")
RDMA_DoFixup(0 "netlink/route/link.h")
RDMA_DoFixup(0 "netlink/route/link/vlan.h")
RDMA_DoFixup(0 "netlink/route/neighbour.h")
RDMA_DoFixup(0 "netlink/route/route.h")
RDMA_DoFixup(0 "netlink/route/rtnl.h")
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
RDMA_DoFixup(0 "netlink/netlink.h")
RDMA_DoFixup(0 "netlink/route/route.h")
endif()
endif()

# Older stuff blows up if these headers are included together
Expand Down
28 changes: 28 additions & 0 deletions README-FreeBSD.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
The port just compiles.

FreeBSD version should be main or stable/15, after the tdestroy(3) and
strdupa()/strndupa() additions.

You need to install the following packages:
cmake-core
ninja
gcc
python3
pyXXX-cython3
pyXXX-docutils
bash
libepoll-shim
libudev-devd
libdrm
pkgconf

1. All fake constants for (rt)netlink that are added in
freebsd-headers/linux point to the usage areas that need porting.
2. sysfs accesses must be replaced by sysctl.
Similarly, there should be use of /proc that needs to be ported.
3. I have no idea if the FreeBSD verbs/drivers ABI is compatible with
the Linux provided by kernel-headers/*.
4. Tests for the compilation environment properties done in CMakeLists.txt
are performed before the freebsd-headers get chance to populate build
environment. As such, some tests provide invalid results, e.g.
the co-existence of netinet/in.h and linux/in*.h.
22 changes: 22 additions & 0 deletions build-freebsd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -e

LOCALBASE=$(/sbin/sysctl -n user.localbase)
CMAKE=${LOCALBASE}/bin/cmake
NINJA=${LOCALBASE}/bin/ninja
PYTHON=${LOCALBASE}/bin/python3
GCC=${LOCALBASE}/bin/gcc
GXX=${LOCALBASE}/bin/g++

SRCDIR=$(dirname $0)
BUILDDIR=${SRCDIR}/build

mkdir -p ${BUILDDIR}

cd ${BUILDDIR}

${CMAKE} -DIN_PLACE=1 -GNinja -DENABLE_RESOLVE_NEIGH=0 -DIOCTL_MODE=write \
-DPYTHON_EXECUTABLE=${PYTHON} \
-DCMAKE_C_COMPILER=${GCC} -DCMAKE_CXX_COMPILER=${GXX} \
${EXTRA_CMAKE_FLAGS:-} ..
${NINJA} -k 0
10 changes: 9 additions & 1 deletion buildlib/FindLDSymVer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
# find_package helper to detect symbol version support in the compiler and
# linker. If supported then LDSYMVER_MODE will be set to GNU

if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(GLOBAL_SYMBOLS_BIN "
environ;
__progname;
")
endif()

# Basic sample GNU style map file
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test.map" "
IBVERBS_1.0 {
global:
ibv_get_device_list;
local: *;
${GLOBAL_SYMBOLS_BIN}
local: *;
};

IBVERBS_1.1 {
Expand Down
1 change: 1 addition & 0 deletions buildlib/FindUDev.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Licensed under BSD (MIT variant) or GPLv2. See COPYING.

find_library(LIBUDEV_LIBRARY NAMES udev libudev)
find_path(UDEV_INCLUDE_DIRS "libudev.h")

set(UDEV_LIBRARIES ${LIBUDEV_LIBRARY})

Expand Down
4 changes: 4 additions & 0 deletions buildlib/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
// FIXME: Remove this, The cmake version hard-requires new style CLOEXEC support
#define STREAM_CLOEXEC "e"

#if defined __linux__
#define RDMA_CDEV_DIR "/dev/infiniband"
#elif defined __FreeBSD__
#define RDMA_CDEV_DIR "/dev"
#endif

#define IBV_CONFIG_DIR "@CONFIG_DIR@"
#define RS_CONF_DIR "@CMAKE_INSTALL_FULL_SYSCONFDIR@/rdma/rsocket"
Expand Down
31 changes: 27 additions & 4 deletions buildlib/make_abi_structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,33 @@
import re;
import functools;
import sys;
import os;

def in_struct(ln,FO,nesting=0):
sysname=sys.argv[3]

def cpre_sysname():
mapping = {"Linux": "__linux__", "FreeBSD": "__FreeBSD__"}
try:
return mapping[sysname]
except KeyError:
raise NotImplementedError(sysname)

def in_struct(ln,FO,nesting=0,wait_for_endif=False,skip=False):
"""Copy a top level structure over to the #define output, keeping track of
nested structures."""
if wait_for_endif:
g = re.match(r"#endif", ln)
if g != None:
return functools.partial(in_struct,nesting=nesting,wait_for_endif=False,skip=False)
g = re.match(r"#ifdef\s+(\S+)",ln)
if g != None:
ifdefsym = g.group(1)
if ifdefsym == cpre_sysname():
return functools.partial(in_struct,nesting=nesting,wait_for_endif=True,skip=False)
return functools.partial(in_struct,nesting=nesting,wait_for_endif=True,skip=True)
if skip:
return functools.partial(in_struct,nesting=nesting,wait_for_endif=wait_for_endif,skip=skip)

if nesting == 0:
if re.match(r"(}.*);",ln):
FO.write(ln[:-1] + "\n\n");
Expand All @@ -31,11 +54,11 @@ def in_struct(ln,FO,nesting=0):
FO.write(ln + " \\\n");

if ln == "struct {" or ln == "union {":
return functools.partial(in_struct,nesting=nesting+1);
return functools.partial(in_struct,nesting=nesting+1,wait_for_endif=wait_for_endif,skip=skip);

if re.match(r"}.*;",ln):
return functools.partial(in_struct,nesting=nesting-1);
return functools.partial(in_struct,nesting=nesting);
return functools.partial(in_struct,nesting=nesting-1,wait_for_endif=wait_for_endif,skip=skip);
return functools.partial(in_struct,nesting=nesting,wait_for_endif=wait_for_endif,skip=skip);

def find_struct(ln,FO):
"""Look for the start of a top level structure"""
Expand Down
2 changes: 1 addition & 1 deletion buildlib/rdma_functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function(rdma_create_symlink LINK_CONTENT DEST)

# Newer versions of cmake can use "${CMAKE_COMMAND}" "-E" "create_symlink"
# however it is broken weirdly on older versions.
execute_process(COMMAND "ln" "-Tsf"
execute_process(COMMAND "ln" "-sf"
"${LINK_CONTENT}" "${DEST}" RESULT_VARIABLE retcode)
if(NOT "${retcode}" STREQUAL "0")
message(FATAL_ERROR "Failed to create symlink in ${DEST}")
Expand Down
2 changes: 1 addition & 1 deletion buildlib/template.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Version: @PC_VERSION@
Libs: -L${libdir} -l@PC_LIB_NAME@ @PC_RPATH@
Libs.private: @PC_LIB_PRIVATE@
Requires.private: @PC_REQUIRES_PRIVATE@
Cflags: -I${includedir}
Cflags: -I${includedir} @PC_FREEBSD_CFLAGS@
1 change: 1 addition & 0 deletions infiniband-diags/ibaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>

#include <infiniband/umad.h>
#include <infiniband/mad.h>
Expand Down
1 change: 1 addition & 0 deletions infiniband-diags/ibdiag_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include <stdint.h>
#include <sys/stat.h>
#include <stdarg.h>
#include <sys/socket.h>

#include <infiniband/umad.h>
#include <infiniband/mad.h>
Expand Down
1 change: 1 addition & 0 deletions infiniband-diags/saquery.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <ctype.h>
#include <string.h>
#include <errno.h>
#include <sys/socket.h>

#define _GNU_SOURCE

Expand Down
2 changes: 1 addition & 1 deletion kernel-headers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function(rdma_kernel_provider_abi)
set(HDRS ${HDRS} ${OHDR})
add_custom_command(
OUTPUT "${OHDR}"
COMMAND "${PYTHON_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/buildlib/make_abi_structs.py" "${IHDR}" "${OHDR}"
COMMAND "${PYTHON_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/buildlib/make_abi_structs.py" "${IHDR}" "${OHDR}" "${CMAKE_SYSTEM_NAME}"
MAIN_DEPENDENCY "${IHDR}"
DEPENDS "${PROJECT_SOURCE_DIR}/buildlib/make_abi_structs.py"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
Expand Down
13 changes: 13 additions & 0 deletions kernel-headers/rdma/mlx5-abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ enum mlx5_ib_create_cq_flags {
};

struct mlx5_ib_create_cq {
#ifdef __linux__
__aligned_u64 buf_addr;
__aligned_u64 db_addr;
__u32 cqe_size;
Expand All @@ -296,6 +297,18 @@ struct mlx5_ib_create_cq {
__u16 uar_page_index;
__u16 reserved0;
__u32 reserved1;
#endif
#ifdef __FreeBSD__
__u64 buf_addr;
__u64 db_addr;
__u32 cqe_size;
__u16 flags;
__u16 uar_page_index;
__u8 cqe_comp_en;
__u8 cqe_comp_res_format;
__u16 reserved0;
__u32 reserved1;
#endif
};

struct mlx5_ib_create_cq_resp {
Expand Down
12 changes: 10 additions & 2 deletions libibmad/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ publish_internal_headers(util
iba_types.h
)

rdma_library(ibmad libibmad.map
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# See Documentation/versioning.md
5 5.5.${PACKAGE_VERSION}
set(SOVER 5 5.5.${PACKAGE_VERSION})
endif()

if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(SOVER 100 100.5.${PACKAGE_VERSION})
endif()

rdma_library(ibmad libibmad.map
${SOVER}
bm.c
cc.c
dump.c
Expand Down
1 change: 1 addition & 0 deletions libibmad/mad.h
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,7 @@ extern int ibdebug;

/* Misc. macros: */
/** align value \a l to \a size (ceil) */
#undef ALIGN
#define ALIGN(l, size) (((l) + ((size) - 1)) / (size) * (size))

/** printf style warning MACRO, includes name of function and pid */
Expand Down
1 change: 1 addition & 0 deletions libibmad/portid.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/socket.h>

#include <infiniband/mad.h>

Expand Down
1 change: 1 addition & 0 deletions libibmad/resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <string.h>
#include <arpa/inet.h>
#include <errno.h>
#include <sys/socket.h>

#include <infiniband/umad.h>
#include <infiniband/mad.h>
Expand Down
12 changes: 10 additions & 2 deletions libibumad/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ publish_headers(infiniband
umad_types.h
)

rdma_library(ibumad libibumad.map
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# See Documentation/versioning.md
3 3.4.${PACKAGE_VERSION}
set(SOVER 3 3.4.${PACKAGE_VERSION})
endif()

if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(SOVER 100 100.4.${PACKAGE_VERSION})
endif()

rdma_library(ibumad libibumad.map
${SOVER}
sysfs.c
umad.c
umad_str.c
Expand Down
1 change: 1 addition & 0 deletions libibumad/tests/umad_sa_mcm_rereg_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <errno.h>
#include <inttypes.h>
#include <unistd.h>
#include <sys/socket.h>

#include <infiniband/umad.h>
#include <infiniband/umad_sa_mcm.h>
Expand Down
16 changes: 13 additions & 3 deletions libibverbs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,19 @@ publish_internal_headers(infiniband
configure_file("libibverbs.map.in"
"${CMAKE_CURRENT_BINARY_DIR}/libibverbs.map" @ONLY)

rdma_library(ibverbs "${CMAKE_CURRENT_BINARY_DIR}/libibverbs.map"
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(SYSDEP_SOURCES init-sysfs.c sysfs-sysfs.c)
# See Documentation/versioning.md
1 1.18.${PACKAGE_VERSION}
set(SOVER 1 1.18.${PACKAGE_VERSION})
endif()

if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(SYSDEP_SOURCES init-sysctl.c sysfs-sysctl.c)
set(SOVER 100 100.18.${PACKAGE_VERSION})
endif()

rdma_library(ibverbs "${CMAKE_CURRENT_BINARY_DIR}/libibverbs.map"
${SOVER}
all_providers.c
cmd.c
cmd_ah.c
Expand Down Expand Up @@ -57,8 +67,8 @@ rdma_library(ibverbs "${CMAKE_CURRENT_BINARY_DIR}/libibverbs.map"
memory.c
neigh.c
static_driver.c
sysfs.c
verbs.c
${SYSDEP_SOURCES}
)
target_link_libraries(ibverbs LINK_PRIVATE
${NL_LIBRARIES}
Expand Down
2 changes: 1 addition & 1 deletion libibverbs/cmd_ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ unsigned int __ioctl_final_num_attrs(unsigned int num_attrs,

/*
* C99 does not permit an initializer for VLAs, so this function does the init
* instead. It is called in the wonky way so that DELCARE_COMMAND_BUFFER can
* instead. It is called in the wonky way so that DECLARE_COMMAND_BUFFER can
* still be a 'variable', and we so we don't require C11 mode.
*/
static inline int _ioctl_init_cmdb(struct ibv_command_buffer *cmd,
Expand Down
Loading
Loading