diff --git a/package/arm/config.default b/package/arm/config.default index 0ec9be0df..9e1fe352c 100644 --- a/package/arm/config.default +++ b/package/arm/config.default @@ -2566,7 +2566,29 @@ CONFIG_FM10K=m # CONFIG_IGC is not set # CONFIG_JME is not set # CONFIG_NET_VENDOR_MARVELL is not set -# CONFIG_NET_VENDOR_MELLANOX is not set +CONFIG_NET_VENDOR_MELLANOX=y +CONFIG_MLX4_EN=m +CONFIG_MLX4_EN_DCB=y +CONFIG_MLX4_CORE=m +CONFIG_MLX4_DEBUG=y +CONFIG_MLX4_CORE_GEN2=y +CONFIG_MLX5_CORE=m +CONFIG_MLX5_ACCEL=y +CONFIG_MLX5_FPGA=y +CONFIG_MLX5_CORE_EN=y +CONFIG_MLX5_EN_ARFS=y +CONFIG_MLX5_EN_RXNFC=y +CONFIG_MLX5_MPFS=y +CONFIG_MLX5_CORE_EN_DCB=y +CONFIG_MLX5_CORE_IPOIB=y +CONFIG_MLX5_FPGA_IPSEC=y +CONFIG_MLXSW_CORE=m +CONFIG_MLXSW_CORE_HWMON=y +CONFIG_MLXSW_CORE_THERMAL=y +CONFIG_MLXSW_PCI=m +CONFIG_MLXSW_I2C=m +CONFIG_MLXSW_MINIMAL=m +CONFIG_MLXFW=m # CONFIG_NET_VENDOR_MICREL is not set CONFIG_NET_VENDOR_MICROCHIP=y # CONFIG_ENC28J60 is not set @@ -4577,6 +4599,7 @@ CONFIG_INFINIBAND_VIRT_DMA=y # CONFIG_INFINIBAND_MTHCA is not set # CONFIG_INFINIBAND_I40IW is not set # CONFIG_MLX4_INFINIBAND is not set +# CONFIG_MLX5_INFINIBAND is not set # CONFIG_INFINIBAND_OCRDMA is not set CONFIG_INFINIBAND_HNS=m # CONFIG_INFINIBAND_HNS_HIP06 is not set diff --git a/package/arm/kernel-tlinux.spec b/package/arm/kernel-tlinux.spec index aa506255f..a6f503c9e 100644 --- a/package/arm/kernel-tlinux.spec +++ b/package/arm/kernel-tlinux.spec @@ -357,6 +357,7 @@ do mv %buildroot/boot/.vmlinuz-%{tagged_name}%{?dist}.hmac %buildroot/lib/modules/$KernelVer/dist_compat %endif + env -i PATH=$PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH HOME=$HOME USER=$USER bash -c "$PWD/package/arm/mlx/mlnx_ofed_integrate_into_kernel.sh $KernelVer $PWD %buildroot" # Copy the System.map file for depmod to use, and create a backup of the # full module tree so we can restore it after we're done filtering diff --git a/package/arm/mlx/mlnx_ofed_integrate_into_kernel.sh b/package/arm/mlx/mlnx_ofed_integrate_into_kernel.sh new file mode 100755 index 000000000..38ea57edf --- /dev/null +++ b/package/arm/mlx/mlnx_ofed_integrate_into_kernel.sh @@ -0,0 +1,268 @@ +#!/bin/bash +# +# Copyright (c) 2020 Mellanox Technologies. All rights reserved. +# +# This Software is licensed under one of the following licenses: +# +# 1) under the terms of the "Common Public License 1.0" a copy of which is +# available from the Open Source Initiative, see +# http://www.opensource.org/licenses/cpl.php. +# +# 2) under the terms of the "The BSD License" a copy of which is +# available from the Open Source Initiative, see +# http://www.opensource.org/licenses/bsd-license.php. +# +# 3) under the terms of the "GNU General Public License (GPL) Version 2" a +# copy of which is available from the Open Source Initiative, see +# http://www.opensource.org/licenses/gpl-license.php. +# +# Licensee has the right to choose one of the above licenses. +# +# Redistributions of source code must retain the above copyright +# notice and one of the license notices. +# +# Redistributions in binary form must reproduce both the above copyright +# notice, one of the license notices in the documentation +# and/or other materials provided with the distribution. +# +# Author: Alaa Hleihel +# + +set -ex + +############################################################################ +# Settings: + +# Additional flags to pass to mlnxofedinstall +mlnxofedinstall_flags="" + +# +# Disabling build of specific modules: +# +mlnxofedinstall_flags=" ${mlnxofedinstall_flags} \ + --without-mlx5_fpga_tools \ + --without-mlnx-rdma-rxe \ + --without-mlnx-nfsrdma \ + --without-mlnx-nvme \ + --without-isert \ + --without-iser \ + --without-srp \ + --without-rshim \ + --without-mdev \ + " + +# +# Disabling checking for required packages: +# +# Uncomment the next line in case you have a customised build host that +# causes mlnxofedinstall to fail when checking for required packages (as +# they might be provided by packages with unexpected names, etc). +# +mlnxofedinstall_flags=" ${mlnxofedinstall_flags} --without-depcheck" + + + +# +############################################################################ +# get args + +# kernel version number (for building modules) +KERNELRELEASE=$1; shift + +# path to kernel rpm build directory (for temp build folder) +kbdir=$1; shift + +# path to kernel rpm build root (for kernel sources and installing modules) +buildroot=$1; shift + +# Path to full mlnx_ofed package +ofedsrc=${kbdir}/package/arm/mlx/MLNX_OFED_LINUX-5.1-2.5.8.0.46-rhel8.3-aarch64.tgz + +mlx_splits_dir=${kbdir}/package/arm/mlx +mlx_splits="mlx_split*" +if [ ! -e "${ofedsrc}" ]; then + cat $mlx_splits_dir/$mlx_splits > $ofedsrc +fi + +if [ ! -e "${ofedsrc}" ]; then + echo "ERROR: ofedsrc not provided or path '${ofedsrc}' does not exist." >&2 + echo 1 +fi + +if [ "X${KERNELRELEASE}" == "X" ]; then + echo "ERROR: KERNELRELEASE not provided." >&2 + echo 1 +fi +if [ ! -d "${kbdir}" ]; then + echo "ERROR: kbdir not provided" >&2 + echo 1 +fi +if [ ! -d "${buildroot}" ]; then + echo "ERROR: buildroot not provided" >&2 + echo 1 +fi + +K_SRC=${buildroot}/usr/src/kernels/${KERNELRELEASE} +K_DIR_INSTALL=${buildroot}/lib/modules/${KERNELRELEASE}/kernel + +export MAKE=${MAKE:-"make"} + + +############################################################################ +# +# make sure we have each modules installed once under the new kernel: +# - if the module we want to install already exists, replace it wit the new one. +# - if it's a new module, then just install it. +# +function inst_mod() +{ + local mod=$1; shift + + local mod_name=$(basename ${mod}) + local tdir= + + for ii in $(find ${K_DIR_INSTALL} -name "*${mod_name}*") + do + # save module location + tdir=$(dirname ${ii}) + + /bin/rm -fv ${ii} + done + + # install new module + if [ ! -e "${tdir}" ]; then + tdir="${K_DIR_INSTALL}/drivers/ofed_addon/" + mkdir -p ${tdir} + fi + + /bin/cp -fv ${mod} ${tdir}/ +} + +function handle_rpm() +{ + local pkg=$1; shift + + /bin/rm -rf ext_rpm + mkdir -p ext_rpm + cd ext_rpm + + # extract rpm + rpm2cpio ${pkg} | cpio -id + + # copy all modules + for mod in $(find . -name "*.ko*") + do + inst_mod ${mod} + done + + cd - +} + +function handle_rpms_ofa_kernel() +{ + local mod_rpms=$1; shift + + for mrpm in ${mod_rpms} + do + case "${mrpm}" in + *mlnx-ofa_kernel*devel*) + continue + ;; + *mlnx-ofa_kernel*) + handle_rpm ${mrpm} + ;; + esac + done +} + +function handle_rpms_all() +{ + local mod_rpms=$1; shift + + for mrpm in ${mod_rpms} + do + case "${mrpm}" in + *mlnx-ofa_kernel*) + continue + ;; + *) + handle_rpm ${mrpm} + ;; + esac + done +} + +__cleanup() +{ + sed -i '/__os_install_post/d' ~/.rpmmacros + sed -i '/__brp_mangle_shebangs/d' ~/.rpmmacros +} +trap '__cleanup' INT TERM ERR EXIT + +############################################################################ + +cd ${kbdir} +/bin/rm -rf ofedbuild && mkdir ofedbuild && cd ofedbuild +mkdir mtmp +TMPD="$PWD/mtmp" + +# extract MLNX_OFED +tar xzf ${ofedsrc} +cd MLNX_OFED_LINUX-* + +distro=$(cat distro 2>/dev/null) +echo "This MLNX_OFED was built for distro: ${distro}" + +#this will cause error in chroot environment +#echo "%__os_install_post %{nil}" >> ~/.rpmmacros +echo "%__brp_mangle_shebangs %{nil}" >> ~/.rpmmacros + +# compile modules against target kernel +./mlnxofedinstall \ + --add-kernel-support-build-only \ + --disable-kmp \ + --distro ${distro} \ + --kernel ${KERNELRELEASE} \ + --kernel-sources ${K_SRC} \ + --tmpdir ${TMPD} \ + --skip-distro-check \ + --skip-repo ${mlnxofedinstall_flags} + +sed -i '/__os_install_post/d' ~/.rpmmacros +sed -i '/__brp_mangle_shebangs/d' ~/.rpmmacros + +# fix permissiosn +chown -R ${USER} ${TMPD} + +echo +echo "Compilation done, now get the modules and copy the to kernel buildroot..." +echo + +# open RPMs and copy modules +/bin/rm -rf ${TMPD}/new +mkdir -p ${TMPD}/new +cd ${TMPD}/new +tar xzf ${TMPD}/MLNX_OFED_LINUX-*/MLNX_OFED_LINUX-*tgz + +# get all kernel module rpms that were built against target kernel +mod_rpms= +for pkg in $(find ${TMPD}/new/MLNX_OFED_LINUX-*/RPMS -name "*rpm") +do + if rpm -qlp ${pkg} | grep "\.ko" | grep -q "${KERNELRELEASE}"; then + # take each rpm only once + rpkg=$(readlink -f ${pkg}) + if ! echo "${mod_rpms}" | grep -q "${rpkg}"; then + mod_rpms="${mod_rpms} ${rpkg}" + fi + fi +done + +# first handle ofa_kernel rpm since it's our base package +handle_rpms_ofa_kernel "${mod_rpms}" + +# now handle the additional packages +handle_rpms_all "${mod_rpms}" + +# cleanup +cd ${kbdir} +/bin/rm -rf ofedbuild diff --git a/package/arm/mlx/mlx_split0 b/package/arm/mlx/mlx_split0 new file mode 100644 index 000000000..a2eb32502 Binary files /dev/null and b/package/arm/mlx/mlx_split0 differ diff --git a/package/arm/mlx/mlx_split1 b/package/arm/mlx/mlx_split1 new file mode 100644 index 000000000..69166808b Binary files /dev/null and b/package/arm/mlx/mlx_split1 differ diff --git a/package/arm/mlx/mlx_split2 b/package/arm/mlx/mlx_split2 new file mode 100644 index 000000000..61dfca988 Binary files /dev/null and b/package/arm/mlx/mlx_split2 differ diff --git a/package/arm/mlx/mlx_split3 b/package/arm/mlx/mlx_split3 new file mode 100644 index 000000000..e14729e5b Binary files /dev/null and b/package/arm/mlx/mlx_split3 differ