Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mellanox] build SDK driver from open source #3

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 =

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to initialize it to some default value (e.g. empty string / "None", ...) ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically it is an empty string. The issue with "None" is that it could be a valid input for wget (which is used internally in slave.mk)

stepanb@arc-build-server:~$ wget none/fw-SPC1.mfa
--2019-10-07 17:49:56--  http://none/fw-SPC1.mfa
Resolving none (none)... failed: Name or service not known.
wget: unable to resolve host address ‘none’

I doubt that someone will call a server as "none" and will rely on wget default protocol http, but in that case they won't be able to use it without specifying protocol.


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why git reset and git clean is needed here?

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 @@ -124,19 +124,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