From 9deab98578d2d4c5a7f6fa2b6e515d5a8997d7a5 Mon Sep 17 00:00:00 2001 From: Vivek Reddy Date: Fri, 7 Oct 2022 17:46:56 +0000 Subject: [PATCH 1/4] Added ENV vars for non-upstream patches Signed-off-by: Vivek Reddy --- platform/mellanox/rules.mk | 6 +++++- rules/linux-kernel.mk | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/platform/mellanox/rules.mk b/platform/mellanox/rules.mk index 5b5e55cdf494..55b3826da90c 100644 --- a/platform/mellanox/rules.mk +++ b/platform/mellanox/rules.mk @@ -51,4 +51,8 @@ $(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 -export SONIC_BUFFER_MODEL=dynamic +# Set y to include non upstream patches for mellanox +INCLUDE_MLNX_PATCHES = n +MLNX_PATCH_LOC = $(PLATFORM_PATH)/non-upstream-patches/patches.tar.gz + +export MLNX_PATCH_LOC SONIC_BUFFER_MODEL=dynamic diff --git a/rules/linux-kernel.mk b/rules/linux-kernel.mk index b51c4d12d05f..d882de3ca48a 100644 --- a/rules/linux-kernel.mk +++ b/rules/linux-kernel.mk @@ -9,7 +9,10 @@ ifeq ($(CONFIGURED_ARCH), armhf) KVERSION = $(KVERSION_SHORT)-armmp endif -export KVERSION_SHORT KVERSION KERNEL_VERSION KERNEL_SUBVERSION +# Place an URL here to .tar.gz file if you want to include those patches +EXTERNAL_KERNEL_PATCHES = + +export KVERSION_SHORT KVERSION KERNEL_VERSION KERNEL_SUBVERSION EXTERNAL_KERNEL_PATCHES LINUX_HEADERS_COMMON = linux-headers-$(KVERSION_SHORT)-common_$(KERNEL_VERSION)-$(KERNEL_SUBVERSION)_all.deb $(LINUX_HEADERS_COMMON)_SRC_PATH = $(SRC_PATH)/sonic-linux-kernel From dcffcb529568afcae88b6410281da7b701ff74fe Mon Sep 17 00:00:00 2001 From: Vivek Reddy Date: Thu, 13 Oct 2022 22:45:20 +0000 Subject: [PATCH 2/4] Made MLNX_PATCH_LOC an absolute path Signed-off-by: Vivek Reddy --- platform/mellanox/rules.mk | 5 +++-- slave.mk | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/platform/mellanox/rules.mk b/platform/mellanox/rules.mk index 55b3826da90c..f9d1de2d8cff 100644 --- a/platform/mellanox/rules.mk +++ b/platform/mellanox/rules.mk @@ -53,6 +53,7 @@ TARGET_BOOTLOADER = grub # Set y to include non upstream patches for mellanox INCLUDE_MLNX_PATCHES = n -MLNX_PATCH_LOC = $(PLATFORM_PATH)/non-upstream-patches/patches.tar.gz +MLNX_PATCH_LOC = $(BUILD_WORKDIR)/$(PLATFORM_PATH)/non-upstream-patches/patches.tar.gz -export MLNX_PATCH_LOC SONIC_BUFFER_MODEL=dynamic +export SONIC_BUFFER_MODEL=dynamic +export MLNX_PATCH_LOC diff --git a/slave.mk b/slave.mk index 28efed3dfc11..b8ed1c22fa78 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 From 6eaa75ea71e86719b71f855f566167154784c5be Mon Sep 17 00:00:00 2001 From: Vivek Reddy Date: Mon, 17 Oct 2022 22:10:17 +0000 Subject: [PATCH 3/4] Added non-upstream-patches dir Signed-off-by: Vivek Reddy --- platform/mellanox/non-upstream-patches/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 platform/mellanox/non-upstream-patches/README.md diff --git a/platform/mellanox/non-upstream-patches/README.md b/platform/mellanox/non-upstream-patches/README.md new file mode 100644 index 000000000000..e69de29bb2d1 From b751662c8b53ec018fddf0a3d30418d99235474e Mon Sep 17 00:00:00 2001 From: Vivek Date: Mon, 17 Oct 2022 15:21:52 -0700 Subject: [PATCH 4/4] Update README.md --- .../mellanox/non-upstream-patches/README.md | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/platform/mellanox/non-upstream-patches/README.md b/platform/mellanox/non-upstream-patches/README.md index e69de29bb2d1..0c3a5ca74b30 100644 --- a/platform/mellanox/non-upstream-patches/README.md +++ b/platform/mellanox/non-upstream-patches/README.md @@ -0,0 +1,25 @@ +## 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. The tarball should be gzip compressed i.e. of extension .tar.gz + 2. It should contain a file named series. series should provide an order of which the patches have to be applied + 3. All the patches should be present in the archive in the same folder where series resides. + 4. Developers should make sure patches apply cleanly over the existing patches present in the sonic-linux-kernel/ repo. + +#### Example +``` +admin@build-server:/sonic-buildimage/platform/mellanox/non-upstream-patches$ tar -tvf patches.tar.gz +drwxr-xr-x vkarri/dip 0 2022-10-07 00:20 ./ +-rw-r--r-- vkarri/dip 4865 2022-10-06 22:50 ./mlx5-Implement-get_module_eeprom_by_page.patch +-rw-r--r-- vkarri/dip 1529 2022-10-06 22:48 ./mlx5-Add-support-for-DSFP-module-EEPROM-dumps.patch +-rw-r--r-- vkarri/dip 139 2022-10-07 00:20 ./series +-rw-r--r-- vkarri/dip 4827 2022-10-06 22:47 ./mlx5-Refactor-module-EEPROM-query.patch +``` + +### Include the archive while building sonic linux kernel + +Set `INCLUDE_MLNX_PATCHES=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_MLNX_PATCHES=y ' target/debs/bullseye/linux-headers-5.10.0-12-2-common_5.10.103-1_all.deb`