diff --git a/platform/mellanox/non-upstream-patches/README.md b/platform/mellanox/non-upstream-patches/README.md new file mode 100644 index 000000000000..9138d750cbf4 --- /dev/null +++ b/platform/mellanox/non-upstream-patches/README.md @@ -0,0 +1,31 @@ +## Mellanox non-upstream linux kernel patches ## + +To include non-upstream patches into the sonic-linux image during build time, this folder must contain a patch archive. + +### Structure of the patch archive + + 1. It should contain a file named series. series should provide an order in which the patches have to be applied + ``` + admin@build-server:/sonic-buildimage/src/sonic-linux-kernel$ cat linux-5.10.103/non_upstream_patches/series + mlx5-Refactor-module-EEPROM-query.patch + mlx5-Implement-get_module_eeprom_by_page.patch + mlx5-Add-support-for-DSFP-module-EEPROM-dumps.patch + ``` + 2. All the patches should be present in the same folder where series resides. + 3. Developers should make sure patches apply cleanly over the existing patches present in the src/sonic-linux-kernel . + 4. Name of the tarball should match with the one specified under EXTERNAL_KERNEL_PATCH_TAR + +#### Example +``` +admin@build-server:/sonic-buildimage/platform/mellanox/non-upstream-patches$ tar -tf patches.tar.gz +./ +./mlx5-Implement-get_module_eeprom_by_page.patch +./mlx5-Add-support-for-DSFP-module-EEPROM-dumps.patch +./series +./mlx5-Refactor-module-EEPROM-query.patch +``` + +### Include the archive while building sonic linux kernel + +Set `INCLUDE_EXTERNAL_PATCH_TAR=y` using `SONIC_OVERRIDE_BUILD_VARS` to include these changes before building the kernel. +- Eg: `NOJESSIE=1 NOSTRETCH=1 NOBUSTER=1 make SONIC_OVERRIDE_BUILD_VARS=' INCLUDE_EXTERNAL_PATCH_TAR=y ' target/debs/bullseye/linux-headers-5.10.0-12-2-common_5.10.103-1_all.deb` diff --git a/platform/mellanox/rules.mk b/platform/mellanox/rules.mk index 5b5e55cdf494..43aa1829953e 100644 --- a/platform/mellanox/rules.mk +++ b/platform/mellanox/rules.mk @@ -51,4 +51,7 @@ $(DOCKER_PLATFORM_MONITOR)_DEPENDS += $(APPLIBS) $(SX_COMPLIB) $(SXD_LIBS) $(SX_ # Force the target bootloader for mellanox platforms to grub regardless of arch TARGET_BOOTLOADER = grub +# location for the platform specific external kernel patches tarball +override EXTERNAL_KERNEL_PATCH_TAR := $(BUILD_WORKDIR)/$(PLATFORM_PATH)/non-upstream-patches/patches.tar.gz + export SONIC_BUFFER_MODEL=dynamic diff --git a/rules/linux-kernel.mk b/rules/linux-kernel.mk index b51c4d12d05f..23d85054968e 100644 --- a/rules/linux-kernel.mk +++ b/rules/linux-kernel.mk @@ -9,7 +9,17 @@ ifeq ($(CONFIGURED_ARCH), armhf) KVERSION = $(KVERSION_SHORT)-armmp endif +# Place an URL here to .tar.gz file if you want to include those patches +EXTERNAL_KERNEL_PATCH_URL = +# Set y to include non upstream patches tarball provided by the corresponding platform +INCLUDE_EXTERNAL_PATCH_TAR = n +# platforms should override this and provide an absolute path to the tarball +EXTERNAL_KERNEL_PATCH_TAR = + export KVERSION_SHORT KVERSION KERNEL_VERSION KERNEL_SUBVERSION +export EXTERNAL_KERNEL_PATCH_URL +export INCLUDE_EXTERNAL_PATCH_TAR +export EXTERNAL_KERNEL_PATCH_TAR LINUX_HEADERS_COMMON = linux-headers-$(KVERSION_SHORT)-common_$(KERNEL_VERSION)-$(KERNEL_SUBVERSION)_all.deb $(LINUX_HEADERS_COMMON)_SRC_PATH = $(SRC_PATH)/sonic-linux-kernel diff --git a/slave.mk b/slave.mk index 54a01aaa1a29..561f6b47db3f 100644 --- a/slave.mk +++ b/slave.mk @@ -43,7 +43,8 @@ BULLSEYE_DEBS_PATH = $(TARGET_PATH)/debs/bullseye BULLSEYE_FILES_PATH = $(TARGET_PATH)/files/bullseye DBG_IMAGE_MARK = dbg DBG_SRC_ARCHIVE_FILE = $(TARGET_PATH)/sonic_src.tar.gz -DPKG_ADMINDIR_PATH = /sonic/dpkg +BUILD_WORKDIR = /sonic +DPKG_ADMINDIR_PATH = $(BUILD_WORKDIR)/dpkg CONFIGURED_PLATFORM := $(shell [ -f .platform ] && cat .platform || echo generic) PLATFORM_PATH = platform/$(CONFIGURED_PLATFORM) @@ -84,6 +85,7 @@ export MULTIARCH_QEMU_ENVIRON export DOCKER_BASE_ARCH export CROSS_BUILD_ENVIRON export BLDENV +export BUILD_WORKDIR ############################################################################### ## Utility rules