blob: 6bcfe8bda6209dfd4fdb8c7cd859398cdf675aea [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 ice-1.3.2v we will get "1.3.2".
PV=$(ver_cut 1-3)
DESCRIPTION="Intel ice driver ${PV} kernel module."
HOMEPAGE="https://www.intel.com/content/www/us/en/download/19630/30303/intel-network-adapter-driver-for-e810-series-devices-under-linux.html"
SRC_URI="gs://chromeos-localmirror/distfiles/ice-${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}/ice-${PV}/src"
libdir="kernel/drivers/net/ethernet/intel/ice"
MODULE_NAMES="ice(${libdir}:${S}:${S})"
FIRMWARE_INSTALL_ROOT="/lib/firmware"
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_ICE=m"
BUILD_TARGETS="modules"
linux-mod_src_compile
}
src_install() {
# Sign the module first.
MODULE_OBJECT=ice.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
# Install the firmware. Need to make sure we don't install firmware twice
# for vanilla and rt, or else the files will collide.
if [[ ${RT} = "v" ]]; then
insinto "${FIRMWARE_INSTALL_ROOT}/intel/ice/ddp"
doins ../ddp/*pkg
dosym ../ddp/*pkg "${FIRMWARE_INSTALL_ROOT}/intel/ice/ddp/ice.pkg"
fi
}