Skip to content

Commit

Permalink
Merge branch 'onload-9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sianj-xilinx committed Oct 15, 2024
2 parents 871686c + 61ebc9a commit cef5f13
Show file tree
Hide file tree
Showing 15 changed files with 195 additions and 39 deletions.
4 changes: 4 additions & 0 deletions scripts/debian/debian-templ/control
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Depends: adduser, psmisc, ${shlibs:Depends}, ${misc:Depends}, python3
Suggests: #TYPE#-modules-${source:Version}, #TYPE#-dev
Provides: onload-user
Description: Onload TCP/IP stack - library
Build-Profiles: <!pkg.#TYPE#.nouser>

Package: #TYPE#-source
Architecture: all
Expand All @@ -21,15 +22,18 @@ Description: source for the #TYPE# driver.
This package provides the source code for the #TYPE# kernel modules.
The #TYPE# package is also required in order to make use of these
modules. Kernel source or headers are required to compile these modules.
Build-Profiles: <!pkg.#TYPE#.nosource>

Package: #TYPE#-dkms
Architecture: all
Depends: dkms, #TYPE#-user (>= ${source:Version}), #TYPE#-user (<< ${source:Version}.1~), ${misc:Depends}
Description: Onload debian package with DKMS
Conflicts: #TYPE#-modules
Build-Profiles: <!pkg.#TYPE#.nodkms>

Package: #TYPE#-dev
Architecture: all
Description: Onload development headers
Enhances: #TYPE#-user
Provides: onload-dev
Build-Profiles: <!pkg.#TYPE#.nodev>
22 changes: 19 additions & 3 deletions scripts/debian/debian-templ/rules
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ ifneq ($(call get_build_config,setuid),)
SETUID=--setuid
endif

DOPACKAGES := $(shell dh_listpackages)

# module assistant calculates all needed things for us and sets
# following variables:
# KSRC (kernel source directory), KVERS (kernel version string), KDREV
Expand Down Expand Up @@ -100,12 +102,18 @@ configure-stamp:

touch configure-stamp

override_dh_auto_build: build-arch-stamp
build-arch: configure-stamp build-arch-stamp
build-arch-stamp:
dh_testdir

# Add here command to compile/build the package.
ifneq (,$(filter #TYPE#-user,$(DOPACKAGES)))
scripts/onload_build $(BUILD_FLAGS) --user
else
ifneq (,$(filter #TYPE#-dev,$(DOPACKAGES)))
mkdir build
endif
endif

touch $@

Expand Down Expand Up @@ -167,6 +175,7 @@ install: build
dh_prep
dh_installdirs

ifneq (,$(filter #TYPE#-source,$(DOPACKAGES)))
# Create the directories to install the source into
dh_installdirs -p$(psource) usr/src/modules/$(sname)/debian

Expand All @@ -183,9 +192,10 @@ install: build
cp debian/rules debian/changelog debian/copyright \
debian/compat debian/$(psource)/usr/src/modules/$(sname)/debian/
cd debian/$(psource)/usr/src && tar c modules | bzip2 -9 > $(sname).tar.bz2 && rm -rf modules
endif

# perform above operations also for the DKMS build:

ifneq (,$(filter #TYPE#-dkms,$(DOPACKAGES)))
# Create the directories to install the source into
dh_installdirs -p$(pdkms) usr/src/modules/$(sname)-#VERSION#/debian

Expand All @@ -204,6 +214,7 @@ install: build
sed -e "s,#BUILDFLAGS#,$(BUILD_FLAGS),g" \
< debian/#TYPE#-dkms.dkms > debian/$(pdkms)/usr/src/modules/$(sname)-#VERSION#/debian/#TYPE#-dkms.dkms
cd debian/$(pdkms)/usr/src && tar c modules | bzip2 -9 > $(sname).tar.bz2 && rm -rf modules
endif

# Add here commands to install the package into debian/#TYPE#.

Expand Down Expand Up @@ -239,9 +250,11 @@ binary-indep: build install
dh_gencontrol -i
dh_md5sums -i

ifneq (,$(filter #TYPE#-dev,$(DOPACKAGES)))
dh_installdirs -p$(develpackage) usr/include/
i_prefix=$(CURDIR)/debian/$(develpackage) scripts/onload_install \
--verbose --packaged --headers --nobaseheaders
endif
dh_builddeb -i

# Build architecture-dependent files here.
Expand Down Expand Up @@ -272,13 +285,16 @@ binary-arch: build install
dh_shlibdeps -a
dh_gencontrol -a
dh_md5sums -a
#

ifneq (,$(filter #TYPE#-user,$(DOPACKAGES)))
# Create the directories to install the source into
dh_installdirs -p$(userpackage) lib/onload

i_prefix=$(CURDIR)/debian/$(userpackage) scripts/onload_install --verbose \
--packaged --userfiles --modprobe --modulesloadd --python-layout=deb \
$(BUILD_FLAGS) $(SETUID)
endif

dh_builddeb -a

binary: binary-indep binary-arch
Expand Down
14 changes: 2 additions & 12 deletions scripts/onload_install
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,7 @@ install_uninstall() {
install_userland() {
# Install libraries and tools.
try $docd "$TOP/build"
userarch="$(mmaketool --userarch)"
if ${devel}; then
u64="$(mmaketool --userbuild)"
else
u64="gnu_${userarch}"
fi
u64="$(mmaketool --userbuild)"

if [ -d "$u64" ]; then
# Tolerate lack of 32-bit transport library on 64-bit systems.
Expand Down Expand Up @@ -673,10 +668,6 @@ logprog=true
sfccheck=true
ppc_at=
noinitramfs=false
devel=false
# $debug_dir is relevant for blob binaries only. We package debug and ndebug
# versions, and need to select between them.
debug_dir=
nosfc=false
python_install_layout=

Expand Down Expand Up @@ -704,7 +695,7 @@ while [ $# -gt 0 ]; do
--nosetuid) setuid=false;;
--noaffinity) affinity=false; buildargs="$buildargs $1";;
--affinity) affinity=true; buildargs="$buildargs $1";;
--debug) buildargs="$buildargs $1"; debug_dir=debug;;
--debug) buildargs="$buildargs $1";;
--strict) buildargs="$buildargs $1";;
--require-optional-targets) buildargs="$buildargs $1";;
--no-efct) buildargs="$buildargs --no-efct";;
Expand Down Expand Up @@ -739,7 +730,6 @@ while [ $# -gt 0 ]; do
--build-profile=*) buildargs="$buildargs $1"; build_profile="${1#--build-profile=}";;
--python-layout=*) python_install_layout="--install-layout ${1#--python-layout=}";;
--no-initramfs) noinitramfs=true;;
--devel) devel=true; build=false; noinitramfs=true;debug_dir=;;
--sbindir=*) sbindir=${1#--sbindir=};;
--usrsbindir=*) usrsbindir=${1#--usrsbindir=};;
--bindir=*) bindir=${1#--bindir=};;
Expand Down
2 changes: 2 additions & 0 deletions scripts/onload_misc/openonload.rpmlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
addFilter("use-of-RPM_SOURCE_DIR")
addFilter("invalid-url")
77 changes: 68 additions & 9 deletions scripts/onload_misc/openonload.spec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
# If you don't want to build the kernel module package, use:
# --without kmod
#
# If you want to build the kernel module Akmods package, use:
# --with akmod
#
# If you don't want to build the userland package, use:
# --without user
#
Expand All @@ -37,6 +40,9 @@
# If you want to install the Onload libraries with setuid add:
# --define "setuid true"
#
# If you want to install the kernel modules in a different directory add:
# --define "moddir extra"
#
# If your distribution does not provide a dist macro (e.g. CentOS) which is used
# to differentiate the filename, you may overrise it:
# --define 'dist .el5'
Expand All @@ -62,11 +68,13 @@
%bcond_without user # add option to skip userland builds
%bcond_without kmod # add option to skip kmod builds
%bcond_without devel # add option to skip devel builds
%bcond_with akmod # add option to include Akmods package

%define pkgversion 20100910

%undefine __brp_mangle_shebangs

%{?kernels: %global kernel %kernels} # Hard-coded into `akmodsbuild`
%{!?kernel: %{expand: %%define kernel %%(uname -r)}}
%{!?target_cpu: %{expand: %%define target_cpu %{_host_cpu}}}
%{!?debuginfo: %{expand: %%define debuginfo false}}
Expand Down Expand Up @@ -110,13 +118,14 @@ Source0: %{name}-%{pkgversion}.tgz
BuildRoot: %{_builddir}/%{name}-root
AutoReqProv: no
ExclusiveArch: x86_64 ppc64
BuildRequires: gawk gcc sed make bash libpcap libpcap-devel automake libtool autoconf libcap-devel
# The glibc, python-devel, and libcap packages we need depend on distro and platform

%global base_build_requires gawk gcc sed make bash libpcap libpcap-devel automake libtool autoconf libcap-devel
%if 0%{?suse_version}
BuildRequires: glibc-devel glibc python3-devel libcap2
%global dist_build_requires glibc-devel glibc python3-devel libcap2
%else
BuildRequires: glibc-common python3-devel libcap
%global dist_build_requires glibc-common python3-devel libcap
%endif
BuildRequires: %{base_build_requires} %{dist_build_requires}

%description
OpenOnload is a high performance user-level network stack. Please see
Expand Down Expand Up @@ -158,13 +167,12 @@ efct_disttag() {
}
echo -n $(efct_disttag)
)}

BuildRequires: kernel-module-xilinx-efct-%{efct_disttag}-%{kernel} >= 1.5.3.0

%global efct_build_requires kernel-module-xilinx-efct-%{efct_disttag}-%{kernel} >= 1.5.3.0
%if "%{dist}" == ".el7"
BuildRequires: kernel-module-auxiliary-%{efct_disttag}-%{kernel} >= 1.0.4.0
%global efct_build_requires %{efct_build_requires} kernel-module-auxiliary-%{efct_disttag}-%{kernel} >= 1.0.4.0
Requires: kernel-module-auxiliary-%{efct_disttag}-%{kernel} >= 1.0.4.0
%endif
BuildRequires: %{efct_build_requires}
%endif

%description kmod-%{kverrel}
Expand Down Expand Up @@ -210,6 +218,33 @@ fi
/lib/modules/%{kernel}/*/*
%endif

###############################################################################
# Akmod
%if %{with akmod}
%package akmod
Summary: OpenOnload kernel modules as Akmod source
Requires: akmods %{base_build_requires} %{dist_build_requires} %{?efct_build_requires:%efct_build_requires}
Conflicts: kernel-module-sfc-RHEL%{maindist}
Provides: openonload-kmod = %{version}-%{release}
Provides: sfc-kmod-symvers = %{version}-%{release}

%description akmod
OpenOnload is a high performance user-level network stack. Please see
www.openonload.org for more information.

This package comprises the kernel module components of OpenOnload as source.

%posttrans akmod
nohup /usr/sbin/akmods --from-akmod-posttrans --akmod %{name} &> /dev/null &

%post akmod
[ -x /usr/sbin/akmods-ostree-post ] && /usr/sbin/akmods-ostree-post %{name} %{_usrsrc}/akmods/%{name}-kmod-%{version}-%{release}.src.rpm

%files akmod
%defattr(-,root,root,-)
%{_usrsrc}/akmods/*
%endif

###############################################################################
%if %{with devel}
%package devel
Expand Down Expand Up @@ -273,15 +308,17 @@ mkdir build
%endif

%install
%if %{with user}%{with kmod}%{with devel}
export i_prefix=%{buildroot}
mkdir -p "$i_prefix/etc/modprobe.d"
mkdir -p "$i_prefix/etc/depmod.d"
./scripts/onload_install --packaged \
%{?build_profile:--build-profile %build_profile} \
%{?debug:--debug} %{?setuid:--setuid} \
%{?debug:--debug} %{?setuid:--setuid} %{?moddir:--moddir=%moddir} \
%{?with_user: --userfiles --modprobe --modulesloadd --udev} \
%{?with_kmod: --kernelfiles --kernelver "%{kernel}"} \
%{?with_devel: --headers}
%endif
%if %{with user}
# Removing these files is fine since they would only ever be generated on a build machine.
rm -f "$i_prefix/etc/sysconfig/modules/onload.modules"
Expand All @@ -290,6 +327,28 @@ mkdir -p "$i_prefix/usr/share/onload"
cp ./scripts/onload_misc/onload_modules-load.d.conf $i_prefix/usr/share/onload/onload_modules-load.d.conf
cp ./scripts/onload_misc/sysconfig_onload_modules $i_prefix/usr/share/onload/sysconfig_onload_modules
%endif
%if %{with akmod}
# Akmod RPM must contain an SRPM which only builds the kmod subpackage.
# Akmods requires directory /lib/modules/%%{kernel}/extra/%%{name}.
sed \
-e "/bcond_without user/ {s/without/with/; s/skip/include/}" \
-e "/bcond_without devel/ {s/without/with/; s/skip/include/}" \
-e "/bcond_without akmod/ {s/without/with/; s/skip/include/}" \
-e "/bcond_with kernel_package_deps/ {s/with/without/; s/include/skip/}" \
-e '/define "moddir extra"/ s/.*/%%global moddir extra\/onload/' \
%{?debug:-e '/define "debug true"/ s/.*/%%global debug true/'} \
%{?setuid:-e '/define "setuid true"/ s/.*/%%global setuid true/'} \
"%{_specdir}/openonload.spec" > %{_specdir}/%{name}-akmod.spec
# Based on output of `kmodtool --akmod`
mkdir -p %{buildroot}/%{_usrsrc}/akmods/
rpmbuild \
--define "_sourcedir %{_sourcedir}" \
--define "_srcrpmdir %{buildroot}/%{_usrsrc}/akmods/" \
%{?dist:--define 'dist %{dist}'} \
-bs --nodeps %{_specdir}/%{name}-akmod.spec
ln -s $(ls %{buildroot}/%{_usrsrc}/akmods/) %{buildroot}/%{_usrsrc}/akmods/%{name}-kmod.latest
%endif

%post

if [ `cat /proc/1/comm` == systemd ]
Expand Down
21 changes: 21 additions & 0 deletions src/driver/linux_onload/onload_kernel_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,26 @@ static inline int efrm_unregister_netdevice_notifier(struct notifier_block *b)
#define unregister_netdevice_notifier efrm_unregister_netdevice_notifier
#endif

static inline struct fown_struct* efrm_file_f_owner(struct file *file)
{
#ifdef EFRM_F_OWNER_IS_VAL
return &file->f_owner;
#else
/* linux 6.12+ */
return file->f_owner;
#endif
}

#ifdef EFRM_CLOEXEC_FILES_STRUCT
/* linux 6.12+ */
#define efrm_close_on_exec close_on_exec
#else
static inline bool efrm_close_on_exec(unsigned int fd,
const struct files_struct *files)
{
return close_on_exec(fd, files_fdtable(files));
}
#endif


#endif /* __ONLOAD_KERNEL_COMPAT_H__ */
12 changes: 6 additions & 6 deletions src/driver/linux_onload/ossock_calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ oo_fd_replace_file(struct file* old_filp, struct file* new_filp,

task_unlock(current);
rcu_read_lock(); /* for files_fdtable() */
flags = close_on_exec(old_fd, files_fdtable(current->files)) ?
O_CLOEXEC : 0;
flags = efrm_close_on_exec(old_fd, current->files) ? O_CLOEXEC : 0;
rcu_read_unlock();
new_fd = get_unused_fd_flags(flags);
if( new_fd < 0 ) {
Expand Down Expand Up @@ -657,14 +656,15 @@ int efab_tcp_helper_create_os_sock(ci_private_t *priv)

/* Copy F_SETOWN_EX, F_SETSIG to the new file */
#ifdef F_SETOWN_EX
if(priv->_filp->f_owner.pid != 0) {
if(efrm_file_f_owner(priv->_filp)->pid != 0) {
rcu_read_lock();
__f_setown(sock->file, priv->_filp->f_owner.pid,
priv->_filp->f_owner.pid_type, 1);
__f_setown(sock->file, efrm_file_f_owner(priv->_filp)->pid,
efrm_file_f_owner(priv->_filp)->pid_type, 1);
rcu_read_unlock();
}
#endif
sock->file->f_owner.signum = priv->_filp->f_owner.signum;
efrm_file_f_owner(sock->file)->signum =
efrm_file_f_owner(priv->_filp)->signum;

rc = ci_tcp_sync_sockopts_to_os_sock(ni, ep->id, sock);
put_linux_socket(sock);
Expand Down
8 changes: 8 additions & 0 deletions src/driver/linux_resource/kernel_compat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ EFRM_HAVE_SET_RXFH_CONTEXT memtype struct_ethtool_ops set_rxfh_context include/l
EFRM_HAVE_EPOLL_PWAIT2 symbol sys_epoll_pwait2 include/linux/syscalls.h
EFRM_F_OWNER_IS_VAL memtype struct_file f_owner include/linux/fs.h struct fown_struct
EFRM_CLOEXEC_FILES_STRUCT symtype close_on_exec include/linux/fdtable.h bool(unsigned int, const struct files_struct *)
EFRM_HAVE_FOLLOW_PFNMAP_START symbol follow_pfnmap_start include/linux/mm.h
EFRM_HAVE_FOLLOW_PTE symbol follow_pte include/linux/mm.h
# TODO move onload-related stuff from net kernel_compat
" | grep -E -v -e '^#' -e '^$' | sed 's/[ \t][ \t]*/:/g'
}
Expand Down
Loading

0 comments on commit cef5f13

Please sign in to comment.