Skip to content

Commit

Permalink
[mellanox] build SDK driver from open source (#3580)
Browse files Browse the repository at this point in the history
* build SDK driver package sx-kernel from open sourced repository Mellanox/Switch-SDK-driver
* copy SDK packages and FW binaries from Mellanox/Switch-SDK-driver

Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
  • Loading branch information
stepanblyschak authored and lguohan committed Oct 8, 2019
1 parent ce2ecf2 commit aec2477
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,6 @@
[submodule "platform/mellanox/mlnx-sai/SAI-Implementation"]
path = platform/mellanox/mlnx-sai/SAI-Implementation
url = https://github.com/Mellanox/SAI-Implementation
[submodule "Switch-SDK-drivers"]
path = platform/mellanox/sdk-src/sx-kernel/Switch-SDK-drivers
url = https://github.com/Mellanox/Switch-SDK-drivers
1 change: 1 addition & 0 deletions platform/mellanox/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mft/*
!mft/Makefile
sdk-src/*/*
!sdk-src/*/Makefile
!sdk-src/sx-kernel/Switch-SDK-drivers/
!sdk-src/*/*.patch
*/build
*/deb_dist
Expand Down
22 changes: 19 additions & 3 deletions platform/mellanox/fw.mk
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
# mellanox firmware

MLNX_FW_BASE_URL = $(MLNX_SDK_BASE_URL)
MLNX_FW_BASE_PATH = $(MLNX_SDK_BASE_PATH)

# Place an URL here to FW if you want to download FW instead
MLNX_FW_BASE_URL =

ifneq ($(MLNX_FW_BASE_URL), )
FW_FROM_URL = y
else
FW_FROM_URL = n
endif


MLNX_SPC_FW_VERSION = 13.2000.2162
MLNX_SPC_FW_FILE = fw-SPC-rel-$(subst .,_,$(MLNX_SPC_FW_VERSION))-EVB.mfa
$(MLNX_SPC_FW_FILE)_PATH = $(MLNX_FW_BASE_PATH)
$(MLNX_SPC_FW_FILE)_URL = $(MLNX_FW_BASE_URL)/$(MLNX_SPC_FW_FILE)
SONIC_ONLINE_FILES += $(MLNX_SPC_FW_FILE)

MLNX_SPC2_FW_VERSION = 29.2000.2162
MLNX_SPC2_FW_FILE = fw-SPC2-rel-$(subst .,_,$(MLNX_SPC2_FW_VERSION))-EVB.mfa
$(MLNX_SPC2_FW_FILE)_PATH = $(MLNX_FW_BASE_PATH)
$(MLNX_SPC2_FW_FILE)_URL = $(MLNX_FW_BASE_URL)/$(MLNX_SPC2_FW_FILE)
SONIC_ONLINE_FILES += $(MLNX_SPC2_FW_FILE)

ifeq ($(FW_FROM_URL),n)
SONIC_COPY_FILES += $(MLNX_SPC_FW_FILE) $(MLNX_SPC2_FW_FILE)
else
SONIC_ONLINE_FILES += $(MLNX_SPC_FW_FILE) $(MLNX_SPC2_FW_FILE)
endif

export MLNX_SPC_FW_VERSION
export MLNX_SPC_FW_FILE
Expand Down
12 changes: 9 additions & 3 deletions platform/mellanox/sdk-src/sx-kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ PACKAGE_NAME = sx_kernel

$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
# get sources
rm -rf sx_kernel-$(MLNX_SDK_VERSION)-$(MLNX_SDK_ISSU_VERSION)

wget -c $(MLNX_SDK_SOURCE_BASE_URL)/$(PACKAGE_NAME)-$(MLNX_SDK_VERSION)-$(MLNX_SDK_ISSU_VERSION).tar.gz -O - | tar -xz
if [ ! -z "$(MLNX_SDK_SOURCE_BASE_URL)" ]; then
rm -rf sx_kernel-$(MLNX_SDK_VERSION)-$(MLNX_SDK_ISSU_VERSION)
wget -c $(MLNX_SDK_SOURCE_BASE_URL)/$(PACKAGE_NAME)-$(MLNX_SDK_VERSION)-$(MLNX_SDK_ISSU_VERSION).tar.gz -O - | tar -xz
pushd sx_kernel-$(MLNX_SDK_VERSION)-$(MLNX_SDK_ISSU_VERSION)
else
pushd Switch-SDK-drivers
git reset --hard
git clean -xfd
fi

# build
pushd sx_kernel-$(MLNX_SDK_VERSION)-$(MLNX_SDK_ISSU_VERSION)
patch -p1 < ../sx_kernel_makefile_sonic_build.patch

debuild -e KVERSION=$(KVERSION) -e KSRC_EXT=/lib/modules/$(KVERSION)/source/ -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS)
Expand Down
1 change: 1 addition & 0 deletions platform/mellanox/sdk-src/sx-kernel/Switch-SDK-drivers
Submodule Switch-SDK-drivers added at 3acd88
18 changes: 10 additions & 8 deletions platform/mellanox/sdk.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MLNX_SDK_BASE_URL = https://github.com/Mellanox/SAI-Implementation/raw/350187a41e408daaf03380401a0a2351b6cb0f9e/sdk
MLNX_SDK_BASE_PATH = $(PLATFORM_PATH)/sdk-src/sx-kernel/Switch-SDK-drivers/bin/
MLNX_SDK_VERSION = 4.3.2104
MLNX_SDK_ISSU_VERSION = 101

Expand Down Expand Up @@ -135,19 +135,21 @@ $(SX_KERNEL)_SRC_PATH = $(PLATFORM_PATH)/sdk-src/sx-kernel
SX_KERNEL_DEV = sx-kernel-dev_1.mlnx.$(MLNX_SDK_DEB_VERSION)_amd64.deb
$(eval $(call add_derived_package,$(SX_KERNEL),$(SX_KERNEL_DEV)))

define make_url
$(1)_URL = $(MLNX_SDK_BASE_URL)/$(1)
define make_path
$(1)_PATH = $(MLNX_SDK_BASE_PATH)

endef

$(eval $(foreach deb,$(MLNX_SDK_DEBS),$(call make_url,$(deb))))
$(eval $(foreach deb,$(MLNX_SDK_RDEBS),$(call make_url,$(deb))))
$(eval $(foreach deb,$(PYTHON_SDK_API) $(SX_KERNEL) $(SX_KERNEL_DEV),$(call make_url,$(deb))))
$(eval $(foreach deb,$(MLNX_SDK_DEBS),$(call make_path,$(deb))))
$(eval $(foreach deb,$(MLNX_SDK_RDEBS),$(call make_path,$(deb))))
$(eval $(foreach deb,$(PYTHON_SDK_API) $(SX_KERNEL) $(SX_KERNEL_DEV),$(call make_path,$(deb))))

SONIC_MAKE_DEBS += $(SX_KERNEL)

ifeq ($(SDK_FROM_SRC), y)
SONIC_MAKE_DEBS += $(MLNX_SDK_RDEBS) $(PYTHON_SDK_API) $(SX_KERNEL)
SONIC_MAKE_DEBS += $(MLNX_SDK_RDEBS) $(PYTHON_SDK_API)
else
SONIC_ONLINE_DEBS += $(MLNX_SDK_RDEBS) $(PYTHON_SDK_API) $(SX_KERNEL)
SONIC_COPY_DEBS += $(MLNX_SDK_RDEBS) $(PYTHON_SDK_API)
endif

SONIC_STRETCH_DEBS += $(SX_KERNEL)
Expand Down

0 comments on commit aec2477

Please sign in to comment.