From 7d6e8a56db5eadc9772bb50c2468acdbbb6bef80 Mon Sep 17 00:00:00 2001 From: Oleksandr Ivantsiv Date: Mon, 6 Dec 2021 16:36:20 +0000 Subject: [PATCH] [bluefield] Integrate MFT v4.18.0 packages. --- platform/nvidia-bluefield/mft/Makefile | 72 +++++++++++++++++++ .../recipes/installer-image.mk | 2 +- platform/nvidia-bluefield/recipes/mft.dep | 18 +++++ platform/nvidia-bluefield/recipes/mft.mk | 34 +++++++++ platform/nvidia-bluefield/rules.dep | 18 +++++ platform/nvidia-bluefield/rules.mk | 1 + 6 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 platform/nvidia-bluefield/mft/Makefile create mode 100644 platform/nvidia-bluefield/recipes/mft.dep create mode 100644 platform/nvidia-bluefield/recipes/mft.mk create mode 100644 platform/nvidia-bluefield/rules.dep diff --git a/platform/nvidia-bluefield/mft/Makefile b/platform/nvidia-bluefield/mft/Makefile new file mode 100644 index 000000000000..d07d85098ee8 --- /dev/null +++ b/platform/nvidia-bluefield/mft/Makefile @@ -0,0 +1,72 @@ +# +# Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +.ONESHELL: +SHELL = /bin/bash +.SHELLFLAGS += -e + +MFT_NAME = mft-$(MFT_VERSION)-$(MFT_REVISION)-arm64-deb +MFT_TGZ = $(MFT_NAME).tgz + +SRC_DEB = kernel-mft-dkms_$(MFT_VERSION)-$(MFT_REVISION)_all.deb +MOD_DEB = kernel-mft-dkms-modules-$(KVERSION)_$(MFT_VERSION)_arm64.deb + +MAIN_TARGET = mft_$(MFT_VERSION)-$(MFT_REVISION)_arm64.deb +DERIVED_TARGETS = $(MOD_DEB) mft-oem_$(MFT_VERSION)-$(MFT_REVISION)_arm64.deb + +DKMS_BMDEB = /var/lib/dkms/kernel-mft-dkms/$(MFT_VERSION)/bmdeb +DKMS_TMP := $(shell mktemp -u -d -t dkms.XXXXXXXXXX) + +$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : + rm -rf $(MFT_NAME) + wget -O $(MFT_TGZ) http://www.mellanox.com/downloads/MFT/$(MFT_TGZ) + tar xzf $(MFT_TGZ) + +ifneq (,$(findstring bullseye,$(DEST))) + pushd $(MFT_NAME)/SDEBS + + # put a lock here because dpkg does not allow installing packages in parallel + while true; do + if mkdir $(DEST)/dpkg_lock &> /dev/null; then + { sudo dpkg -i $(SRC_DEB) && rm -d $(DEST)/dpkg_lock && break; } || { rm -d $(DEST)/dpkg_lock && exit 1 ; } + fi + done + + popd + + sudo dkms build kernel-mft-dkms/$(MFT_VERSION) -k $(KVERSION) -a arm64 + sudo dkms mkbmdeb kernel-mft-dkms/$(MFT_VERSION) -k $(KVERSION) -a arm64 + + # w/a: remove dependencies + mkdir -p $(DKMS_TMP)/DEBIAN + + dpkg -e $(DKMS_BMDEB)/$(MOD_DEB) $(DKMS_TMP)/DEBIAN + dpkg -x $(DKMS_BMDEB)/$(MOD_DEB) $(DKMS_TMP) + + sed -i '/^Depends:/c\Depends:' $(DKMS_TMP)/DEBIAN/control + + pushd $(MFT_NAME)/DEBS + dpkg -b $(DKMS_TMP) . + popd + + rm -rf $(DKMS_TMP) +endif + + # fix timestamp because we do not actually build tools, only kernel + touch $(MFT_NAME)/DEBS/*.deb + mv $(MFT_NAME)/DEBS/*.deb $(DEST) + +$(addprefix $(DEST)/, $(DERIVED_TARGETS)): $(DEST)/% : $(DEST)/$(MAIN_TARGET) diff --git a/platform/nvidia-bluefield/recipes/installer-image.mk b/platform/nvidia-bluefield/recipes/installer-image.mk index 556ef74f7cd5..f4ecd25100d1 100644 --- a/platform/nvidia-bluefield/recipes/installer-image.mk +++ b/platform/nvidia-bluefield/recipes/installer-image.mk @@ -21,7 +21,7 @@ SONIC_BF2_IMAGE_BASE = sonic-nvidia-bluefield $(SONIC_BF2_IMAGE_BASE)_MACHINE = nvidia-bluefield # Install the packages during the build_debian phase -$(SONIC_BF2_IMAGE_BASE)_INSTALLS += $(ETHTOOL) $(LIBPKA_DEB) $(SYSTEMD_SONIC_GENERATOR) +$(SONIC_BF2_IMAGE_BASE)_INSTALLS += $(ETHTOOL) $(LIBPKA_DEB) $(SYSTEMD_SONIC_GENERATOR) $(KERNEL_MFT) $(MFT_OEM) $(MFT) # Required Dockers # TODO: Add swss, syncd and pmon later diff --git a/platform/nvidia-bluefield/recipes/mft.dep b/platform/nvidia-bluefield/recipes/mft.dep new file mode 100644 index 000000000000..861adc49255e --- /dev/null +++ b/platform/nvidia-bluefield/recipes/mft.dep @@ -0,0 +1,18 @@ +# DPKG FRK + +SPATH := $($(MFT)_SRC_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) $(PLATFORM_PATH)/$(RECIPE_DIR)/mft.mk $(PLATFORM_PATH)/$(RECIPE_DIR)/mft.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES += $(shell git ls-files -- $(SPATH)) + +$(MFT)_CACHE_MODE := GIT_CONTENT_SHA +$(MFT)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(MFT)_DEP_FILES := $(DEP_FILES) + +$(KERNEL_MFT)_CACHE_MODE := GIT_CONTENT_SHA +$(KERNEL_MFT)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(KERNEL_MFT)_DEP_FILES := $(DEP_FILES) + +$(MFT_OEM)_CACHE_MODE := GIT_CONTENT_SHA +$(MFT_OEM)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(MFT_OEM)_DEP_FILES := $(DEP_FILES) diff --git a/platform/nvidia-bluefield/recipes/mft.mk b/platform/nvidia-bluefield/recipes/mft.mk new file mode 100644 index 000000000000..71dde585ec30 --- /dev/null +++ b/platform/nvidia-bluefield/recipes/mft.mk @@ -0,0 +1,34 @@ +# +# Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +MFT_VERSION = 4.18.0 +MFT_REVISION = 106 + +export MFT_VERSION MFT_REVISION + +MFT = mft_$(MFT_VERSION)-$(MFT_REVISION)_arm64.deb +$(MFT)_SRC_PATH = $(PLATFORM_PATH)/mft +SONIC_MAKE_DEBS += $(MFT) + +ifeq ($(BLDENV), bullseye) +$(MFT)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) + +KERNEL_MFT = kernel-mft-dkms-modules-$(KVERSION)_$(MFT_VERSION)_arm64.deb +$(eval $(call add_derived_package,$(MFT),$(KERNEL_MFT))) +endif + +MFT_OEM = mft-oem_$(MFT_VERSION)-$(MFT_REVISION)_arm64.deb +$(eval $(call add_derived_package,$(MFT),$(MFT_OEM))) diff --git a/platform/nvidia-bluefield/rules.dep b/platform/nvidia-bluefield/rules.dep new file mode 100644 index 000000000000..6128c704bea5 --- /dev/null +++ b/platform/nvidia-bluefield/rules.dep @@ -0,0 +1,18 @@ +# +# Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include $(PLATFORM_PATH)/$(RECIPE_DIR)/mft.dep diff --git a/platform/nvidia-bluefield/rules.mk b/platform/nvidia-bluefield/rules.mk index 455fc41f9357..fd82f332eb41 100644 --- a/platform/nvidia-bluefield/rules.mk +++ b/platform/nvidia-bluefield/rules.mk @@ -41,6 +41,7 @@ include $(PLATFORM_PATH)/$(RECIPE_DIR)/rshim.mk include $(PLATFORM_PATH)/$(RECIPE_DIR)/bootimages.mk include $(PLATFORM_PATH)/$(RECIPE_DIR)/bfscripts.mk include $(PLATFORM_PATH)/$(RECIPE_DIR)/platform-modules-bf2.mk +include $(PLATFORM_PATH)/$(RECIPE_DIR)/mft.mk include $(PLATFORM_PATH)/$(RECIPE_DIR)/installer-image.mk # TODO: This deb has dependency issues, skipped for now