[rdma/f18] Update to systemd

Doug Ledford dledford at fedoraproject.org
Mon Nov 26 23:32:16 UTC 2012


commit ba9c021449f5b94802d0c2142ba16a043d306613
Author: Doug Ledford <dledford at redhat.com>
Date:   Mon Nov 26 18:31:20 2012 -0500

    Update to systemd
    
    Signed-off-by: Doug Ledford <dledford at redhat.com>

 rdma.ifup-ib    |    6 +-
 rdma.sbin       |  214 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 rdma.service    |   12 +++
 rdma.spec       |   67 +++++++++++++-----
 rdma.udev-rules |   14 ++++
 5 files changed, 294 insertions(+), 19 deletions(-)
---
diff --git a/rdma.ifup-ib b/rdma.ifup-ib
index 9e7f55d..1cfb169 100644
--- a/rdma.ifup-ib
+++ b/rdma.ifup-ib
@@ -87,8 +87,10 @@ fi
 
 # slave device?
 if [ "${SLAVE}" = yes -a "${ISALIAS}" = no -a "${MASTER}" != "" ]; then
-    /sbin/ip link set dev ${DEVICE} down
-    echo "+${DEVICE}" > /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null
+    grep -wq "${DEVICE}" /sys/class/net/${MASTER}/bonding/slaves || {
+	/sbin/ip link set dev ${DEVICE} down
+	echo "+${DEVICE}" > /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null
+    }
 
     if [ -n "$ETHTOOL_OPTS" ] ; then
         /sbin/ethtool -s ${REALDEVICE} $ETHTOOL_OPTS
diff --git a/rdma.sbin b/rdma.sbin
new file mode 100644
index 0000000..0d8a2fa
--- /dev/null
+++ b/rdma.sbin
@@ -0,0 +1,214 @@
+#!/bin/bash
+#
+# Bring up the kernel RDMA stack
+#
+# This is usually run automatically by systemd after a hardware activation
+# event in udev has triggered a start of the rdma.service unit
+#
+
+CONFIG=/etc/rdma/rdma.conf
+FIXUP_MTRR=/usr/sbin/rdma-fixup-mtrr.awk
+
+LOAD_ULP_MODULES=""
+LOAD_CORE_USER_MODULES="ib_umad ib_uverbs ib_ucm rdma_ucm"
+LOAD_CORE_CM_MODULES="iw_cm ib_cm rdma_cm"
+LOAD_CORE_MODULES="ib_core ib_mad ib_sa ib_addr"
+
+if [ -f $CONFIG ]; then
+    . $CONFIG
+
+    if [ "${RDS_LOAD}" == "yes" ]; then
+        IPOIB_LOAD=yes
+    fi
+
+    if [ "${IPOIB_LOAD}" == "yes" ]; then
+	LOAD_ULP_MODULES="ib_ipoib"
+    fi
+
+    if [ "${RDS_LOAD}" == "yes" ]; then
+	LOAD_ULP_MODULES="$LOAD_ULP_MODULES rds"
+    fi
+
+    if [ "${SRP_LOAD}" == "yes" ]; then
+	LOAD_ULP_MODULES="$LOAD_ULP_MODULES ib_srp"
+    fi
+
+    if [ "${ISER_LOAD}" == "yes" ]; then
+	LOAD_ULP_MODULES="$LOAD_ULP_MODULES ib_iser"
+    fi
+else
+    LOAD_ULP_MODULES="ib_ipoib"
+fi
+
+# If module $1 is loaded return - 0 else - 1
+is_module()
+{
+    /sbin/lsmod | grep -w "$1" > /dev/null 2>&1
+    return $?    
+}
+
+load_modules()
+{
+    local RC=0
+
+    for module in $*; do
+	if ! is_module $module; then
+	    /sbin/modprobe $module
+	    res=$?
+	    RC=$[ $RC + $res ]
+	    if [ $res -ne 0 ]; then
+		echo
+		echo -n "Failed to load module $mod"
+	    fi
+	fi
+    done
+    return $RC
+}
+
+# This function is a horrible hack to work around BIOS authors that should
+# be shot.  Specifically, certain BIOSes will map the entire 4GB address
+# space as write-back cacheable when the machine has 4GB or more of RAM, and
+# then they will exclude the reserved PCI I/O addresses from that 4GB
+# cacheable mapping by making on overlapping uncacheable mapping.  However,
+# once you do that, it is then impossible to set *any* of the PCI I/O
+# address space as write-combining.  This is an absolute death-knell to
+# certain IB hardware.  So, we unroll this mapping here.  Instead of
+# punching a hole in a single 4GB mapping, we redo the base 4GB mapping as
+# a series of discreet mappings that effectively are the same as the 4GB
+# mapping minus the hole, and then we delete the uncacheable mappings that
+# are used to punch the hole.  This then leaves the PCI I/O address space
+# unregistered (which defaults it to uncacheable), but available for
+# write-combining mappings where needed.
+check_mtrr_registers()
+{
+    # If we actually change the mtrr registers, then the awk script will
+    # return true, and we need to unload the ib_ipath module if it's already
+    # loaded.  The udevtrigger in load_hardware_modules will immediately
+    # reload the ib_ipath module for us, so there shouldn't be a problem.
+    [ -f /proc/mtrr -a -f $MTRR_SCRIPT ] && 
+	awk -f $MTRR_SCRIPT /proc/mtrr 2>/dev/null &&
+	if is_module ib_ipath; then
+		/sbin/rmmod ib_ipath
+	fi
+}
+
+load_hardware_modules()
+{
+    local -i RC=0
+
+    [ "$FIXUP_MTRR_REGS" = "yes" ] && check_mtrr_registers
+    # We match both class NETWORK and class INFINIBAND devices since our
+    # iWARP hardware is listed under class NETWORK.  The side effect of
+    # this is that we might cause a non-iWARP network driver to be loaded.
+    udevadm trigger --subsystem-match=pci --attr-nomatch=driver --attr-match=class=0x020000 --attr-match=class=0x0c0600
+    udevadm settle
+    if [ -r /proc/device-tree ]; then
+	if [ -n "`ls /proc/device-tree | grep lhca`" ]; then
+	    if ! is_module ib_ehca; then
+		load_modules ib_ehca
+		RC+=$?
+	    fi
+	fi
+    fi
+    if is_module cxgb3 -a ! is_module iw_cxgb3; then
+	load_modules iw_cxgb3
+	RC+=$?
+    fi
+    if is_module mlx4_core -a ! is_module mlx4_ib; then
+	load_modules mlx4_ib
+	RC+=$?
+    fi
+    return $RC
+}
+
+errata_58()
+{
+    # Check AMD chipset issue Errata #58
+    if test -x /sbin/lspci && test -x /sbin/setpci; then
+	if ( /sbin/lspci -nd 1022:1100 | grep "1100" > /dev/null ) &&
+	   ( /sbin/lspci -nd 1022:7450 | grep "7450" > /dev/null ) &&
+	   ( /sbin/lspci -nd 15b3:5a46 | grep "5a46" > /dev/null ); then
+	    CURVAL=`/sbin/setpci -d 1022:1100 69`
+	    for val in $CURVAL
+	    do
+		if [ "${val}" != "c0" ]; then
+		    /sbin/setpci -d 1022:1100 69=c0
+		    if [ $? -eq 0 ]; then
+			break
+		    else
+			echo "Failed to apply AMD-8131 Errata #58 workaround"
+		    fi
+		fi
+	    done
+	fi
+    fi
+}
+
+errata_56()
+{
+    # Check AMD chipset issue Errata #56
+    if test -x /sbin/lspci && test -x /sbin/setpci; then
+	if ( /sbin/lspci -nd 1022:1100 | grep "1100" > /dev/null ) &&
+	   ( /sbin/lspci -nd 1022:7450 | grep "7450" > /dev/null ) &&
+	   ( /sbin/lspci -nd 15b3:5a46 | grep "5a46" > /dev/null ); then
+	    bus=""
+	    # Look for devices AMD-8131
+	    for dev in `/sbin/setpci -v -f -d 1022:7450 19 | cut -d':' -f1,2`
+	    do
+		bus=`/sbin/setpci -s $dev 19`
+		rev=`/sbin/setpci -s $dev 8`
+		# Look for Tavor attach to secondary bus of this devices
+		for device in `/sbin/setpci -f -s $bus: -d 15b3:5a46 19`
+		do
+		    if [ $rev -lt 13 ]; then
+			/sbin/setpci -d 15b3:5a44 72=14
+			if [ $? -eq 0 ]; then
+			    break
+			else
+			    echo
+			    echo "Failed to apply AMD-8131 Errata #56 workaround"
+			fi
+		    else
+			continue
+		    fi
+		    # If more than one device is on the bus the issue a
+		    # warning
+		    num=`/sbin/setpci -f -s $bus: 0 | wc -l |  sed 's/\ *//g'`
+		    if [ $num -gt 1 ]; then
+			echo "Warning: your current PCI-X configuration might be incorrect."
+			echo "see AMD-8131 Errata 56 for more details."
+		    fi
+		done
+	    done
+	fi
+    fi
+}
+
+load_hardware_modules
+RC=$[ $RC + $? ]
+load_modules $LOAD_CORE_MODULES
+RC=$[ $RC + $? ]
+load_modules $LOAD_CORE_CM_MODULES
+RC=$[ $RC + $? ]
+load_modules $LOAD_CORE_USER_MODULES
+RC=$[ $RC + $? ]
+load_modules $LOAD_ULP_MODULES
+RC=$[ $RC + $? ]
+   
+# Add node description to sysfs
+IBSYSDIR="/sys/class/infiniband"
+if [ -d ${IBSYSDIR} ]; then
+	declare -i hca_id=1
+	for hca in ${IBSYSDIR}/*
+	do
+		if [ -w ${hca}/node_desc ]; then
+			echo -n "$(hostname | cut -f 1 -d .) HCA-${hca_id}" >> ${hca}/node_desc 2> /dev/null
+		fi
+		let hca_id++
+	done
+fi
+   
+errata_58
+errata_56
+    
+exit $RC
diff --git a/rdma.service b/rdma.service
new file mode 100644
index 0000000..c4b92b6
--- /dev/null
+++ b/rdma.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Initialize the iWARP/InfiniBand/RDMA stack in the kernel
+Documentation=file:///etc/rdma/rdma.conf
+RefuseManualStop=true
+DefaultDependencies=false
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/usr/sbin/rdma-init-kernel
+Before=network.target,remote-fs.target
+Wants=sysinit.target
diff --git a/rdma.spec b/rdma.spec
index 26be502..8ec5e42 100644
--- a/rdma.spec
+++ b/rdma.spec
@@ -5,8 +5,8 @@
 
 Summary: Infiniband/iWARP Kernel Module Initializer
 Name: rdma
-Version: 1.0
-Release: 12%{?dist}
+Version: 2.0
+Release: 1%{?dist}
 License: GPLv2+
 Group: System Environment/Base
 Source0: rdma.conf
@@ -14,39 +14,63 @@ Source1: rdma.init
 Source2: rdma.fixup-mtrr.awk
 Source4: rdma.ifup-ib
 Source5: rdma.ifdown-ib
+Source6: rdma.service
+Source7: rdma.sbin
+Source8: rdma.udev-rules
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildArch: noarch
-Requires(post): chkconfig
-Requires(preun): chkconfig
+BuildRequires: systemd
 Requires: udev >= 095
+
 %description 
 User space initialization scripts for the kernel InfiniBand/iWARP drivers
 
+%package sysv
+Summary: Backward compatible SysV init script
+Group: System Environment/Base
+Requires: %{name} = %{version}-%{release}
+Requires(post): chkconfig
+Requires(preun): chkconfig
+
+%description sysv
+The RDMA package has been updated to the newer systemd way of starting
+services, this subpackage contains the old SysV init script that used to
+be used to start the RDMA subsystem in the kernel.
+
 %prep
 
 %build
 
 %install
-rm -rf ${RPM_BUILD_ROOT}
-install -d ${RPM_BUILD_ROOT}%{_initrddir}
-install -d ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}
-install -d ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/network-scripts
-
-install -m 0644 %{SOURCE0} ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/%{name}.conf
-install -m 0755 %{SOURCE1} ${RPM_BUILD_ROOT}%{_initrddir}/%{name}
-install -m 0644 %{SOURCE2} ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/fixup-mtrr.awk
+rm -rf %{buildroot}
+install -d %{buildroot}%{_initrddir}
+install -d %{buildroot}%{_sysconfdir}/%{name}
+install -d %{buildroot}%{_sysconfdir}/sysconfig/network-scripts
+install -d %{buildroot}%{_sbindir}
+install -d %{buildroot}%{_unitdir}
+install -d %{buildroot}/lib/udev/rules.d
+
+# Stuff to go into the base package
+install -m 0644 %{SOURCE0} %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf
+install -m 0644 %{SOURCE6} %{buildroot}%{_unitdir}/rdma.service
+install -m 0755 %{SOURCE7} %{buildroot}%{_sbindir}/rdma-init-kernel
+install -m 0644 %{SOURCE2} %{buildroot}%{_sbindir}/rdma-fixup-mtrr.awk
 install -m 0755 %{SOURCE4} %{buildroot}%{_sysconfdir}/sysconfig/network-scripts/ifup-ib
 install -m 0755 %{SOURCE5} %{buildroot}%{_sysconfdir}/sysconfig/network-scripts/ifdown-ib
+install -m 0644 %{SOURCE8} %{buildroot}/lib/udev/rules.d/98-rdma.rules
+
+#Stuff for the SysV package
+install -m 0755 %{SOURCE1} %{buildroot}%{_initrddir}/%{name}
 
 %clean
-rm -rf ${RPM_BUILD_ROOT}
+rm -rf %{buildroot}
 
-%post
+%post sysv
 if [ $1 = 1 ]; then
     /sbin/chkconfig --add %{name} 
 fi
 
-%preun
+%preun sysv
 if [ $1 = 0 ]; then
     /sbin/chkconfig --del %{name}
 fi
@@ -55,11 +79,20 @@ fi
 %defattr(-,root,root,-)
 %dir %{_sysconfdir}/%{name}
 %config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
-%{_sysconfdir}/%{name}/fixup-mtrr.awk
-%{_initrddir}/%{name}
+%{_unitdir}/%{name}.service
+%{_sbindir}/rdma-init-kernel
+%{_sbindir}/rdma-fixup-mtrr.awk
 %{_sysconfdir}/sysconfig/network-scripts/*
+/lib/udev/rules.d/*
+
+%files sysv
+%defattr(-,root,root,-)
+%{_initrddir}/%{name}
 
 %changelog
+* Mon Nov 26 2012 Doug Ledford <dledford at redhat.com> - 2.0-1
+- Update version to reflect addition of systemd support
+
 * Sat Jul 21 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.0-12
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
 
diff --git a/rdma.udev-rules b/rdma.udev-rules
new file mode 100644
index 0000000..d9cf5ba
--- /dev/null
+++ b/rdma.udev-rules
@@ -0,0 +1,14 @@
+# We list all the various kernel modules that drive hardware in the
+# InfiniBand stack (and a few in the network stack that might not actually
+# be RDMA capable, but we don't know that at this time and it's safe to
+# enable the IB stack, so do so unilaterally) and on load of any of that
+# hardware, we trigger the rdma.service load in systemd
+
+SUBSYSTEM=="module", KERNEL=="cxgb3", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service"
+SUBSYSTEM=="module", KERNEL=="cxgb4", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service"
+SUBSYSTEM=="module", KERNEL=="ib_mthca", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service"
+SUBSYSTEM=="module", KERNEL=="mlx4_core", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service"
+SUBSYSTEM=="module", KERNEL=="ib_ipath", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service"
+SUBSYSTEM=="module", KERNEL=="ib_qib", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service"
+SUBSYSTEM=="module", KERNEL=="iw_c2", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service"
+SUBSYSTEM=="module", KERNEL=="iw_nes", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service"


More information about the scm-commits mailing list