Skip to content

Commit

Permalink
linux/efa: Add spec file for EFA kernel driver
Browse files Browse the repository at this point in the history
Add a spec file to package the EFA kernel driver source and install it
using dkms. This is so we can install the driver in an environment where
we do not control the kernel installation.  We should add another spec
file to build the kernel driver and package it when we package the
driver with the kernel.

Signed-off-by: Robert Wespetal <wesper@amazon.com>
Signed-off-by: Gal Pressman <galpress@amazon.com>
  • Loading branch information
rwespetal authored and gal-pressman committed Mar 24, 2019
1 parent 173bbc5 commit 0328a70
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kernel/linux/efa/README
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ sudo yum install kernel-devel-$(uname -r)
Compilation:
Run "make", efa.ko is created inside the folder.

To build EFA RPMs run `make` in the rpm/ folder. Your environment will need to
be setup to build RPMs. The EFA RPM will install the EFA kernel driver source,
setup DKMS in order to build the driver when the kernel is updated, and update
the configuration files to load EFA and its dependencies at boot time.

Driver installation
===================
Loading driver
Expand Down
10 changes: 10 additions & 0 deletions kernel/linux/efa/conf/dkms.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PACKAGE_NAME="efa"
PACKAGE_VERSION="0.9.0"
CLEAN="make clean"
MAKE="make KERNEL_VERSION=${kernelver}"
BUILT_MODULE_NAME[0]="efa"
BUILT_MODULE_LOCATION=""
DEST_MODULE_LOCATION="/extra"
DEST_MODULE_NAME[0]="efa"
AUTOINSTALL="yes"
NO_WEAK_MODULES="yes"
4 changes: 4 additions & 0 deletions kernel/linux/efa/conf/efa.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# /etc/modules-load.d/efa.conf
ib_core
ib_uverbs
efa
39 changes: 39 additions & 0 deletions kernel/linux/efa/rpm/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Makefile for creating rpm of the Amazon EFA driver

NAME = efa
VERSION = 0.9.0

TOPDIR := $(shell git rev-parse --show-toplevel)
TAG = master
TARBALL = $(NAME)-$(VERSION).tar

RPMDEFS = --define '_topdir %(pwd)' \
--define '_ntopdir %(pwd)' \
--define '_builddir %{_ntopdir}/build' \
--define '_buildrootdir %{_builddir}' \
--define '_sourcedir %{_ntopdir}' \
--define '_specdir %{_ntopdir}' \
--define '_rpmdir %{_ntopdir}' \
--define '_srcrpmdir %{_ntopdir}' \
--define "driver_version $(VERSION)"

all : rpm

tarball : $(TARBALL)
$(TARBALL) : always
(cd $(TOPDIR) && \
git archive --format=tar --prefix=$(NAME)-$(VERSION)/ $(TAG) \
kernel/linux/efa/) > $@

srpm : $(TARBALL) Makefile
rpmbuild -bs $(RPMDEFS) efa.spec

rpm : $(TARBALL) Makefile
rpmbuild -ba $(RPMDEFS) efa.spec

clean :
rm -f $(TARBALL) *.src.rpm

always:

.PHONY : srpm clean always
64 changes: 64 additions & 0 deletions kernel/linux/efa/rpm/efa.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
%define name efa
%define debug_package %{nil}

Name: %{name}
Version: %{driver_version}
Release: 1%{?dist}
Summary: %{name} kernel module

Group: System/Kernel
License: Dual BSD/GPL
URL: https://github.com/amzn/amzn-drivers/
Source0: %{name}-%{version}.tar

Requires: dkms %kernel_module_package_buildreqs

%define install_path /usr/src/%{name}-%{version}

%description
%{name} kernel module source and DKMS scripts to build the kernel module.

%prep
%setup -n %{name}-%{version} -q

%post
dkms add -m %{name} -v %{driver_version}
dkms build -m %{name} -v %{driver_version}
dkms install -m %{name} -v %{driver_version}

%preun
dkms remove -m %{name} -v %{driver_version} --all

%build

%install
cd kernel/linux/efa
mkdir -p %{buildroot}%{install_path}
install -D -m 644 conf/efa.conf %{buildroot}/etc/modules-load.d/efa.conf
install -m 644 conf/dkms.conf %{buildroot}%{install_path}
install -m 644 efa_com.c %{buildroot}%{install_path}
install -m 644 efa_com_cmd.c %{buildroot}%{install_path}
install -m 644 efa_main.c %{buildroot}%{install_path}
install -m 644 efa_sysfs.c %{buildroot}%{install_path}
install -m 644 efa_verbs.c %{buildroot}%{install_path}
install -m 644 efa-abi.h %{buildroot}%{install_path}
install -m 644 efa_admin_cmds_defs.h %{buildroot}%{install_path}
install -m 644 efa_admin_defs.h %{buildroot}%{install_path}
install -m 644 efa_com_cmd.h %{buildroot}%{install_path}
install -m 644 efa_com.h %{buildroot}%{install_path}
install -m 644 efa_common_defs.h %{buildroot}%{install_path}
install -m 644 efa.h %{buildroot}%{install_path}
install -m 644 efa_regs_defs.h %{buildroot}%{install_path}
install -m 644 efa_sysfs.h %{buildroot}%{install_path}
install -m 644 kcompat.h %{buildroot}%{install_path}
install -m 644 Makefile %{buildroot}%{install_path}
install -m 644 README %{buildroot}%{install_path}
install -m 644 RELEASENOTES.md %{buildroot}%{install_path}

%files
%{install_path}
/etc/modules-load.d/efa.conf

%changelog
* Fri Mar 8 2019 Robert Wespetal <wesper@amazon.com> - 0.9.0
- initial build for RHEL

0 comments on commit 0328a70

Please sign in to comment.