blob: 4e427bd94d8b163585e2955833f5553e152984da [file] [log] [blame]
#
# Copyright 2021 Google LLC
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
EAPI="7"
inherit linux-mod
# Get realtime / vanilla kernel indicator after numeric version digits. e.g. "v" or "r".
RT=$(ver_cut 4 ${PV})
# Get pure digit version number e.g. from iavf-4.5.3v we will get "4.5.3".
PV=$(ver_cut 1-3)
DESCRIPTION="Intel Adaptive Virtual Function driver ${PV} kernel module."
HOMEPAGE="https://www.intel.com/content/www/us/en/download/18159/intel-network-adapter-linux-virtual-function-driver-for-intel-ethernet-controller-700-and-e810-series.html"
SRC_URI="gs://chromeos-localmirror/distfiles/iavf-${PV}.tar.gz"
LICENSE="BSD-Google LICENSE.ice"
SLOT="vanilla"
case "${RT}" in
r)
SLOT="rt"
;;
*)
;;
esac
KEYWORDS="*"
IUSE=""
RESTRICT="mirror"
DEPEND="virtual/linux-sources"
RDEPEND="${DEPEND}"
S="${WORKDIR}/iavf-${PV}/src"
libdir="kernel/drivers/net/ethernet/intel/iavf"
MODULE_NAMES="iavf(${libdir}:${S}:${S})"
pkg_setup() {
ls "${ROOT}/usr/src"
# We cannot rely on auto detection because we have two kernels installed.
local KERNEL_PREFIX="lakitu-kernel"
case "${RT}" in
r)
KERNEL_PREFIX+="-rt"
;;
*)
;;
esac
KERNEL_DIR="$(find "${ROOT}/usr/src" -maxdepth 1 -name "${KERNEL_PREFIX}-[0-9]*")"
KBUILD_OUTPUT="${KERNEL_DIR}/build"
linux-mod_pkg_setup
}
src_compile() {
LIBELF="$("${CBUILD}-pkg-config" libelf --libs 2>/dev/null || echo -lelf)"
BUILD_PARAMS="HOST_LIBELF_LIBS=${LIBELF} CC=${CC}"
BUILD_PARAMS+=" -C ${KBUILD_OUTPUT} M=${S} LLVM=1 LLVM_IAS=1 CONFIG_IAVF=m"
BUILD_TARGETS="modules"
linux-mod_src_compile
}
src_install() {
# Sign the module first.
MODULE_OBJECT=iavf.ko
cp ${MODULE_OBJECT} ${MODULE_OBJECT}.orig
"${KBUILD_OUTPUT}"/scripts/sign-file \
sha256 \
"${KBUILD_OUTPUT}"/certs/signing_key.pem \
"${KBUILD_OUTPUT}"/certs/signing_key.x509 \
${MODULE_OBJECT} || die "signing failed"
dostrip -x "/lib/modules/${KV_FULL}/${libdir}/${MODULE_OBJECT}"
linux-mod_src_install
}