Skip to content

Commit 9f7a142

Browse files
committed
Added F-Stack FreeBSD support (This is a part of the research work at RCSLab, University of Waterloo)
1 parent 2ffc055 commit 9f7a142

File tree

4 files changed

+72
-10
lines changed

4 files changed

+72
-10
lines changed

README.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,44 +38,59 @@ Currently, besides authorized DNS server of DNSPod, there are various products i
3838
yum install numactl-devel # on Centos
3939
#sudo apt-get install libnuma-dev # on Ubuntu
4040

41+
# Install dependencies (FreeBSD only)
42+
#pkg install meson pkgconf py38-pyelftools
43+
4144
cd f-stack
4245
# Compile DPDK
4346
cd dpdk/
4447
meson -Denable_kmods=true build
4548
ninja -C build
4649
ninja -C build install
4750

48-
# Set hugepage
51+
# Set hugepage (Linux only)
4952
# single-node system
5053
echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
5154

52-
# or NUMA
55+
# or NUMA (Linux only)
5356
echo 1024 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
5457
echo 1024 > /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages
5558

56-
# Using Hugepage with the DPDK
59+
# Using Hugepage with the DPDK (Linux only)
5760
mkdir /mnt/huge
5861
mount -t hugetlbfs nodev /mnt/huge
5962

60-
# Close ASLR; it is necessary in multiple process
63+
# Close ASLR; it is necessary in multiple process (Linux only)
6164
echo 0 > /proc/sys/kernel/randomize_va_space
6265

6366
# Install python for running DPDK python scripts
6467
sudo apt install python # On ubuntu
68+
#sudo pkg install python # On FreeBSD
6569

6670
# Offload NIC
71+
# For Linux:
6772
modprobe uio
6873
insmod /data/f-stack/dpdk/build/kernel/linux/igb_uio/igb_uio.ko
6974
insmod /data/f-stack/dpdk/build/kernel/linux/kni/rte_kni.ko carrier=on # carrier=on is necessary, otherwise need to be up `veth0` via `echo 1 > /sys/class/net/veth0/carrier`
7075
python dpdk-devbind.py --status
7176
ifconfig eth0 down
7277
python dpdk-devbind.py --bind=igb_uio eth0 # assuming that use 10GE NIC and eth0
7378

79+
# For FreeBSD:
80+
# Refer DPDK FreeBSD guide to set tunables in /boot/loader.conf
81+
# Below is an example used for our testing machine
82+
#echo "hw.nic_uio.bdfs=\"2:0:0\"" >> /boot/loader.conf
83+
#echo "hw.contigmem.num_buffers=1" >> /boot/loader.conf
84+
#echo "hw.contigmem.buffer_size=1073741824" >> /boot/loader.conf
85+
#kldload contigmem
86+
#kldload nic_uio
87+
7488
# On Ubuntu, use gawk instead of the default mawk.
7589
#sudo apt-get install gawk # or execute `sudo update-alternatives --config awk` to choose gawk.
7690

7791
# Install dependencies for F-Stack
78-
sudo apt install gcc make libssl-dev # On ubuntu
92+
sudo apt install gcc make libssl-dev # On ubuntu
93+
#sudo pkg install gcc gmake openssl pkgconf libepoll-shim # On FreeBSD
7994

8095
# Upgrade pkg-config while version < 0.28
8196
#cd /data
@@ -92,14 +107,16 @@ Currently, besides authorized DNS server of DNSPod, there are various products i
92107
export FF_PATH=/data/f-stack
93108
export PKG_CONFIG_PATH=/usr/lib64/pkgconfig:/usr/local/lib64/pkgconfig:/usr/lib/pkgconfig
94109
cd /data/f-stack/lib/
95-
make
110+
make # On Linux
111+
#gmake # On FreeBSD
96112

97113
# Install F-STACK
98114
# libfstack.a will be installed to /usr/local/lib
99115
# ff_*.h will be installed to /usr/local/include
100116
# start.sh will be installed to /usr/local/bin/ff_start
101117
# config.ini will be installed to /etc/f-stack.conf
102-
make install
118+
make install # On Linux
119+
#gmake install # On FreeBSD
103120

104121
#### Nginx
105122

dpdk/lib/librte_eal/freebsd/include/rte_os.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@
1414
#include <pthread_np.h>
1515

1616
typedef cpuset_t rte_cpuset_t;
17+
#if __FreeBSD_version >= 1301000
18+
#define RTE_CPU_AND(dst, src1, src2) do \
19+
{ \
20+
cpuset_t tmp; \
21+
CPU_COPY(src1, &tmp); \
22+
CPU_AND(&tmp, &tmp, src2); \
23+
CPU_COPY(&tmp, dst); \
24+
} while (0)
25+
#define RTE_CPU_OR(dst, src1, src2) do \
26+
{ \
27+
cpuset_t tmp; \
28+
CPU_COPY(src1, &tmp); \
29+
CPU_OR(&tmp, &tmp, src2); \
30+
CPU_COPY(&tmp, dst); \
31+
} while (0)
32+
#else
1733
#define RTE_CPU_AND(dst, src1, src2) do \
1834
{ \
1935
cpuset_t tmp; \
@@ -28,6 +44,7 @@ typedef cpuset_t rte_cpuset_t;
2844
CPU_OR(&tmp, src2); \
2945
CPU_COPY(&tmp, dst); \
3046
} while (0)
47+
#endif
3148
#define RTE_CPU_FILL(set) CPU_FILL(set)
3249

3350
/* In FreeBSD 13 CPU_NAND macro is CPU_ANDNOT */
@@ -40,13 +57,24 @@ typedef cpuset_t rte_cpuset_t;
4057
CPU_COPY(&tmp, dst); \
4158
} while (0)
4259
#else
60+
#if __FreeBSD_version >= 1301000
61+
#define RTE_CPU_NOT(dst, src) do \
62+
{ \
63+
cpuset_t tmp; \
64+
CPU_FILL(&tmp); \
65+
CPU_ANDNOT(&tmp, &tmp, src); \
66+
CPU_COPY(&tmp, dst); \
67+
} while (0)
68+
#else
4369
#define RTE_CPU_NOT(dst, src) do \
4470
{ \
4571
cpuset_t tmp; \
4672
CPU_FILL(&tmp); \
4773
CPU_ANDNOT(&tmp, src); \
4874
CPU_COPY(&tmp, dst); \
4975
} while (0)
76+
77+
#endif
5078
#endif
5179

5280
#endif /* _RTE_OS_H_ */

lib/Makefile

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,19 @@ PREFIX_INCLUDE=/usr/local/include
2121
PREFIX_BIN=/usr/local/bin
2222
F-STACK_CONF=/etc/f-stack.conf
2323
F-STACK_VERSION=1.22
24+
TGT_OS=$(shell uname)
25+
ifeq ($(TGT_OS),FreeBSD)
26+
CC=gcc
27+
endif
2428

2529
HOST_OS:=$(shell uname -s)
2630

2731
DEBUG=-O0 -gdwarf-2 -g3 -Wno-format-truncation
2832

33+
# No DPDK KNI support on FreeBSD
34+
ifneq ($(TGT_OS),FreeBSD)
2935
FF_KNI=1
36+
endif
3037

3138
#FF_FLOW_ISOLATE=1
3239

@@ -59,6 +66,11 @@ INCLUDES+= -I./opt
5966

6067
# Include search path for files that only include host OS headers
6168
HOST_INCLUDES= -I.
69+
# Use libepoll shim on FreeBSD
70+
ifeq ($(TGT_OS),FreeBSD)
71+
HOST_INCLUDES+= -I/usr/local/include/libepoll-shim
72+
endif
73+
6274
ifndef DEBUG
6375
HOST_CFLAGS = -O2 -frename-registers -funswitch-loops -fweb -Wno-format-truncation
6476
else
@@ -524,11 +536,15 @@ EXTRA_TCP_STACKS_SRCS+= \
524536
bbr.c
525537
endif
526538

539+
540+
ifneq ($(TGT_OS),FreeBSD)
527541
ifndef FF_KNI
528542
FF_HOST_SRCS+= \
529543
ff_dpdk_kni.c
530-
endif
531-
endif
544+
endif #FF_KNI
545+
endif #FreeBSD OS Check
546+
547+
endif #INET6
532548

533549
ifdef FF_IPFW
534550
NETIPFW_SRCS+= \

lib/ff_dpdk_if.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,8 @@ protocol_filter(const void *data, uint16_t len)
11791179
if(ether_type == RTE_ETHER_TYPE_ARP)
11801180
return FILTER_ARP;
11811181

1182-
#ifdef INET6
1182+
#if (!defined(__FreeBSD__) && defined(INET6) ) || \
1183+
( defined(__FreeBSD__) && defined(INET6) && defined(FF_KNI))
11831184
if (ether_type == RTE_ETHER_TYPE_IPV6) {
11841185
return ff_kni_proto_filter(data,
11851186
len, ether_type);

0 commit comments

Comments
 (0)