@@ -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.
@@ -221,7 +225,7 @@ for patch in ${patches[@]}; do
221225 patch -p1 < ../"$patch"
222226done
223227# Patches listed in this spec (Patch0001...)
224- %autopatch -p1
228+ %autopatch -p1 -m 1000 -M 1999
225229
226230%if "%{_cross_arch }" == "x86_64 "
227231microcode= "$(find %{_cross_libdir }/firmware -type f -path '*/*-ucode/*' -printf '%%P \n' | sort | tr '\n' ' ')"
@@ -256,9 +260,9 @@ if ! diff "${KCONFIG_CONFIG}" "${SOURCE_FILE}"; then
256260fi
257261
258262rm -f ../config-* ../*.patch
263+ cd %{_builddir }
259264
260265%if "%{_cross_arch }" == "x86_64 "
261- cd %{_builddir }
262266# 2.21 for inf1 support
263267rpmkeys --import %{S:4 } --dbpath "${PWD}/rpmdb"
264268rpmkeys --checksig %{S:2 } --dbpath "${PWD}/rpmdb"
@@ -276,14 +280,25 @@ find usr/src/ -mindepth 1 -maxdepth 1 -type d -exec mv {} neuron_latest \;
276280rm -r usr
277281%endif
278282
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 }
283+ # EFA driver
284+ tar -xf %{S:5 }
285+ rpm2cpio aws-efa-installer/RPMS/ALINUX2023/%{_cross_arch }/efa-driver/efa-*.%{_cross_arch }.rpm | cpio -idmu './usr/src/efa-*'
286+ find usr/src/ -mindepth 1 -maxdepth 1 -type d -exec mv {} efa_driver \;
287+ rm -r aws-efa-installer
288+ mkdir efa_driver/build
289+ sed \
290+ -e "s|__KERNEL_VERSION__|%{version }|g" \
291+ -e "s|__KERNEL_DIR__|%{builddir }/linux-%{version }|g" \
292+ -e "s|__KERNEL_MAKEFILE__|%{builddir }/linux-%{version }/Makefile|g" %{S:400 } > efa_driver/CMakeLists.txt
293+
294+ %global kmake %{shrink: \
295+ make -s \
296+ ARCH= "%{_cross_karch }" \
297+ CROSS_COMPILE= "%{_cross_target }-" \
298+ INSTALL_HDR_PATH= "%{buildroot }%{_cross_prefix }" \
299+ INSTALL_MOD_PATH= "%{buildroot }%{_cross_prefix }" \
300+ INSTALL_MOD_STRIP= 1 \
301+ %{nil }}
287302
288303%build
289304%kmake mrproper
@@ -296,6 +311,18 @@ make -s\\\
296311%kmake %{?_smp_mflags } M= %{_builddir }/neuron_latest
297312%endif
298313
314+ # Build EFA driver
315+ pushd %{_builddir }/efa_driver/build
316+ sed -i -e 's,$(MAKE),PREPARE= true %{kmake },g' ../config/Makefile
317+
318+ # Prevent polluting the parent environment by configuring CMAKE in a subshell
319+ (
320+ %{cross_cmake } ..
321+ )
322+
323+ %kmake %{?_smp_mflags } M= %{_builddir }/efa_driver/build modules
324+ popd
325+
299326%install
300327%kmake %{?_smp_mflags } headers_install
301328%kmake %{?_smp_mflags } modules_install
@@ -309,6 +336,9 @@ mv %{buildroot}%{_cross_kmoddir}/neuron_2_21/neuron.ko.gz %{buildroot}%{_cross_l
309336mv %{buildroot }%{_cross_kmoddir }/neuron_latest/neuron.ko.gz %{buildroot }%{_cross_libexecdir }/neuron/neuron_latest/
310337%endif
311338
339+ %kmake %{?_smp_mflags } INSTALL_MOD_DIR= efa_driver M= %{_builddir }/efa_driver/build/src V= 1 modules_install
340+ mv %{buildroot }%{_cross_kmoddir }/efa_driver/efa.ko.gz %{buildroot }%{_cross_kmoddir }/kernel/drivers/amazon/net/efa/
341+
312342install -d %{buildroot }/boot
313343install -T -m 0755 arch/%{_cross_karch }/boot/%{_cross_kimage } %{buildroot }/boot/vmlinuz
314344install -m 0644 .config %{buildroot }/boot/config
0 commit comments