-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile
executable file
·200 lines (154 loc) · 6.1 KB
/
compile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/usr/bin/env sh
set -e
set -f
set -u
depends()
{
:
}
depends x86_64-linux-musl-cc
compile_compile()
{
x86_64-linux-musl-cc $CFLAGS "$@"
}
compile_compileBaseDriverCFile()
{
local source="$1"
shift 1
compile_compile -I"$underlayIncludeFolderPath" -Werror "$@" -c -o "$source".o "$source".c
}
depends x86_64-linux-musl-ar
compile_archive()
{
x86_64-linux-musl-ar "$@"
}
depends rm
compile_archiveBaseDriver()
{
compile_archive rcs ../../"$driver".base.a "$@"
rm -rf "$@"
}
depends mv sed rm
compile_macosSedInplaceWorkaround()
{
local filePath="$1"
local sedPattern="$2"
mv "$filePath" "$filePath".orig
sed -E -e "$sedPattern" "$filePath".orig >"$filePath"
rm "$filePath".orig
}
compile_compileBaseDriverCFilesToArArchive()
{
local driver="$1"
local sources="$2"
local additionalCFLAGS="$3"
printf 'Compiling base driver for %s' "$driver" 1>&2
cd "$compile_buildFolderPath"/"$driver"/base 1>/dev/null 2>/dev/null
set --
local source
for source in $sources
do
compile_compileBaseDriverCFile "$source" $additionalCFLAGS
set -- "$@" "$source".o
done
compile_archiveBaseDriver "$@"
cd - 1>/dev/null 2>/dev/null
printf ' done\n' 1>&2
}
depends rm mkdir
compile_createBuildFolder()
{
rm -rf "$compile_buildFolderPath"
mkdir -m 0700 -p "$compile_buildFolderPath"
}
compile_setCFLAGS()
{
CFLAGS='-O3 -m64 -mmmx -msse -msse2 -msse3 -mssse3 -msse4 -msse4a -msse4.1 -msse4.2 -mavx -mpclmul -maes -mfsgsbase -mrdrnd -mf16c -mpopcnt -DRTE_ARCH_X86'
local modernAvxSupport=''
case "$modernAvxSupport" in
AVX2)
CFLAGS="$CFLAGS -mavx2 -DCC_AVX2_SUPPORT -DDRTE_MACHINE_CPUFLAG_AVX2 -mavx512f -DRTE_MACHINE_CPUFLAG_AVX512F"
;;
AVX512F)
CFLAGS="$CFLAGS -mavx2 -DCC_AVX2_SUPPORT -DDRTE_MACHINE_CPUFLAG_AVX2 -mavx512f -DRTE_MACHINE_CPUFLAG_AVX512F"
;;
esac
}
depends mkdir rsync
compile_copyDriverToBuildAndCompile()
{
local driver="$1"
set -- --archive --quiet --exclude meson.build --exclude README --exclude Makefile --exclude '*.map'
case "$driver" in
iavf)
rsync "$@" "$(pwd)"/library/dpdk-"$compile_dpdkVersion"/drivers/net/"$driver" "$compile_buildFolderPath"/
mkdir -m 0700 -p "$compile_buildFolderPath"/"$driver"/base
rsync "$@" "$(pwd)"/library/dpdk-"$compile_dpdkVersion"/drivers/common/"$driver"/ "$compile_buildFolderPath"/"$driver"/base/
;;
*)
rsync "$@" "$(pwd)"/library/dpdk-"$compile_dpdkVersion"/drivers/net/"$driver" "$compile_buildFolderPath"/
;;
esac
compile_driver_${driver}
}
# base driver originates from the package cid-shared-code.2016.11.22 for FreeBSD.
compile_driver_e1000()
{
compile_compileBaseDriverCFilesToArArchive "$driver" 'e1000_80003es2lan e1000_82540 e1000_82541 e1000_82542 e1000_82543 e1000_82571 e1000_82575 e1000_i210 e1000_api e1000_ich8lan ../e1000_logs e1000_mac e1000_manage e1000_mbx e1000_nvm e1000_osdep e1000_phy e1000_vf' '-Wno-uninitialized -Wno-unused-parameter -Wno-unused-variable -Wno-misleading-indentation'
# igb
# igb_ethdev igb_rxtx igb_pf igb_flow
# em
# em_ethdev em_rxtx
}
# base driver originates from the package of cid-fm10k.2017.01.24.tar.gz for FreeBSD.
compile_driver_fm10k()
{
compile_compileBaseDriverCFilesToArArchive "$driver" 'fm10k_pf fm10k_tlv fm10k_common fm10k_mbx fm10k_vf fm10k_api' '-Wno-deprecated -Wno-unused-parameter -Wno-unused-value -Wno-strict-aliasing -Wno-format-extra-args -Wno-unused-variable -Wno-unused-but-set-variable'
# fm10k_ethdev fm10k_rxtx fm10k_pf fm10k_rxtx_vec
}
# base driver originates from the package cid-i40e.2018.09.13.tar.gz for FreeBSD.
compile_driver_i40e()
{
# Add missing errno.h header using sed (note use of `\` before the embedded newline for macos sed)!
compile_macosSedInplaceWorkaround "$compile_buildFolderPath"/"$driver"/base/i40e_osdep.h 's;#include <string.h>;#include <string.h>\
#include <errno.h>;g'
compile_compileBaseDriverCFilesToArArchive "$driver" 'i40e_adminq i40e_common i40e_diag i40e_hmc i40e_lan_hmc i40e_nvm i40e_dcb' '-DPF_DRIVER -DVF_DRIVER -DINTEGRATED_VF -DX722_A0_SUPPORT -Wno-sign-compare -Wno-unused-value -Wno-unused-parameter -Wno-strict-aliasing -Wno-format -Wno-pointer-to-int-cast -Wno-format-nonliteral -Wno-format-security -Wno-unused-variable -Wno-unused-but-set-variable'
# PMD Specific
# -DRTE_LIBRTE_IEEE1588
# i40e Specific
# -DRTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
# i40e_ethdev i40e_rxtx i40e_rxtx_vec_sse i40e_ethdev_vf i40e_pf i40e_fdir i40e_flow rte_pmd_i40e i40e_tm i40e_vf_representor i40e_rxtx_vec_avx2
}
# ? https://downloadcenter.intel.com/download/25161/Intel-Network-Adapter-Virtual-Function-Driver-for-40-Gigabit-Network-Connections-under-FreeBSD-
compile_driver_iavf()
{
compile_compileBaseDriverCFilesToArArchive "$driver" 'iavf_adminq iavf_common iavf_impl' '-Wno-pointer-arith -Wno-cast-qual'
}
# base driver originates from the ice package version 2019.10.16 for FreeBSD.
compile_driver_ice()
{
compile_compileBaseDriverCFilesToArArchive "$driver" 'ice_controlq ice_common ice_sched ice_switch ice_nvm ice_flex_pipe ice_flow ice_dcb ice_fdir' '-Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable'
# ice_ethdev ice_rxtx ice_rxtx_vec_sse ice_switch_filter ice_fdir_filter ice_hash ice_rxtx_vec_avx2 ice_generic_flow
}
# base driver originates from the ixgbe package version cid-ixgbe.2018.08.28.tar.gz for FreeBSD.
compile_driver_ixgbe()
{
compile_compileBaseDriverCFilesToArArchive "$driver" 'ixgbe_common ixgbe_82598 ixgbe_82599 ixgbe_x540 ixgbe_x550 ixgbe_phy ixgbe_api ixgbe_vf ixgbe_hv_vf ixgbe_dcb ixgbe_dcb_82599 ixgbe_dcb_82598 ixgbe_mbx' '-Wno-unused-parameter -Wno-unused-value -Wno-strict-aliasing -Wno-format-extra-args'
# ixgbe_pf ixgbe_rxtx ixgbe_ethdev ixgbe_fdir ixgbe_flow ixgbe_rxtx_vec_sse ixgbe_bypass ixgbe_82599_bypass rte_pmd_ixgbe ixgbe_tm ixgbe_vf_representor
# Needs librte_security / RTE_LIBRTE_SECURITY ixgbe_ipsec
}
compile_main()
{
local compile_dpdkVersion=20.02
local compile_buildFolderPath="$(pwd)"/build
compile_createBuildFolder
local CFLAGS
compile_setCFLAGS
local underlayIncludeFolderPath="$(pwd)"/underlay
local driver
for driver in e1000 fm10k i40e iavf ice ixgbe
do
compile_copyDriverToBuildAndCompile "$driver"
done
}
compile_main "$@"