@@ -14,6 +14,7 @@ Source2: https://yum.repos.neuron.amazonaws.com/aws-neuronx-dkms-2.21.37.0.noarc
1414# Use latest-neuron-srpm-url.sh to get this.
1515Source3: https://yum.repos.neuron.amazonaws.com/aws-neuronx-dkms-2.24.7.0.noarch .rpm
1616Source4: gpgkey-00FA2C1079260870A76D2C285749CAD8646D9185.asc
17+ Source5: https://efa-installer.amazonaws.com/aws-efa-installer-1.44.0.tar.gz
1718
1819# Custom Bottlerocket kernel configurations.
1920Source100: config-bottlerocket
@@ -44,6 +45,9 @@ Source300: bootconfig-aws.conf
4445Source301: bootconfig-vmware.conf
4546Source302: bootconfig-metal.conf
4647
48+ # Replace upstream CMakeLists.txt with one that allows overriding kernel paths.
49+ Source400: EFACMakeLists.txt.in
50+
4751# Help out-of-tree module builds run `make prepare` automatically.
4852Patch1001: 1001-Makefile-add-prepare-target-for-external-modules.patch
4953# Expose tools/* targets for out-of-tree module builds.
@@ -59,6 +63,8 @@ Patch1005: 1005-Revert-Revert-drm-fb_helper-improve-CONFIG_FB-depend.patch
5963Patch1006: 1006-strscpy-write-destination-buffer-only-once.patch
6064# Disable incomplete measurement into PCR 9 on aarch64.
6165Patch1007: 1007-efi-libstub-don-t-measure-kernel-command-line-into-P.patch
66+ # Execute EFA tests in serial; concurrency doesn't work with the `make prepare` patch.
67+ Patch2000: 2000-config-efa.cmake-execute-config-tests-in-serial.patch
6268
6369BuildRequires: bc
6470BuildRequires: elfutils-devel
@@ -221,7 +227,7 @@ for patch in ${patches[@]}; do
221227 patch -p1 < ../"$patch"
222228done
223229# Patches listed in this spec (Patch0001...)
224- %autopatch -p1
230+ %autopatch -p1 -m 1000 -M 1999
225231
226232%if "%{_cross_arch }" == "x86_64 "
227233microcode= "$(find %{_cross_libdir }/firmware -type f -path '*/*-ucode/*' -printf '%%P \n' | sort | tr '\n' ' ')"
@@ -276,14 +282,29 @@ find usr/src/ -mindepth 1 -maxdepth 1 -type d -exec mv {} neuron_latest \;
276282rm -r usr
277283%endif
278284
279- %global kmake \
280- make -s\\\
281- ARCH= "%{_cross_karch }"\\\
282- CROSS_COMPILE= "%{_cross_target }-"\\\
283- INSTALL_HDR_PATH= "%{buildroot }%{_cross_prefix }"\\\
284- INSTALL_MOD_PATH= "%{buildroot }%{_cross_prefix }"\\\
285- INSTALL_MOD_STRIP= 1\\\
286- %{nil }
285+ # EFA driver
286+ tar -xf %{S:5 }
287+ rpm2cpio aws-efa-installer/RPMS/ALINUX2023/%{_cross_arch }/efa-driver/efa-*.%{_cross_arch }.rpm | cpio -idmu './usr/src/efa-*'
288+ find usr/src/ -mindepth 1 -maxdepth 1 -type d -exec mv {} efa_driver \;
289+ rm -r aws-efa-installer
290+ mkdir efa_driver/build
291+ sed \
292+ -e "s|__KERNEL_VERSION__|%{version }|g" \
293+ -e "s|__KERNEL_DIR__|%{builddir }/linux-%{version }|g" \
294+ -e "s|__KERNEL_MAKEFILE__|%{builddir }/linux-%{version }/Makefile|g" %{S:400 } > efa_driver/CMakeLists.txt
295+
296+ pushd efa_driver
297+ %patch -P 2000 -p1 -d .
298+ popd
299+
300+ %global kmake %{shrink: \
301+ make -s \
302+ ARCH= "%{_cross_karch }" \
303+ CROSS_COMPILE= "%{_cross_target }-" \
304+ INSTALL_HDR_PATH= "%{buildroot }%{_cross_prefix }" \
305+ INSTALL_MOD_PATH= "%{buildroot }%{_cross_prefix }" \
306+ INSTALL_MOD_STRIP= 1 \
307+ %{nil }}
287308
288309%build
289310%kmake mrproper
@@ -296,6 +317,18 @@ make -s\\\
296317%kmake %{?_smp_mflags } M= %{_builddir }/neuron_latest
297318%endif
298319
320+ # Build EFA driver
321+ pushd %{_builddir }/efa_driver/build
322+ sed -i -e 's,$(MAKE),%{kmake },g' ../config/Makefile
323+
324+ # Prevent polluting the parent environment by configuring CMAKE in a subshell
325+ (
326+ %{cross_cmake } ..
327+ )
328+
329+ %kmake %{?_smp_mflags } M= %{_builddir }/efa_driver/build modules
330+ popd
331+
299332%install
300333%kmake %{?_smp_mflags } headers_install
301334%kmake %{?_smp_mflags } modules_install
@@ -309,6 +342,9 @@ mv %{buildroot}%{_cross_kmoddir}/neuron_2_21/neuron.ko.gz %{buildroot}%{_cross_l
309342mv %{buildroot }%{_cross_kmoddir }/neuron_latest/neuron.ko.gz %{buildroot }%{_cross_libexecdir }/neuron/neuron_latest/
310343%endif
311344
345+ %kmake %{?_smp_mflags } INSTALL_MOD_DIR= efa_driver M= %{_builddir }/efa_driver/build/src V= 1 modules_install
346+ mv %{buildroot }%{_cross_kmoddir }/efa_driver/efa.ko.gz %{buildroot }%{_cross_kmoddir }/kernel/drivers/amazon/net/efa/
347+
312348install -d %{buildroot }/boot
313349install -T -m 0755 arch/%{_cross_karch }/boot/%{_cross_kimage } %{buildroot }/boot/vmlinuz
314350install -m 0644 .config %{buildroot }/boot/config
0 commit comments