-
-
Save 5c077yP/13c4224f0642655da08e to your computer and use it in GitHub Desktop.
ixgbevf 2.16.1 upgrade for AWS EC2 SR-IOV "Enhanced Networking" on Ubuntu 14.04 (Trusty) LTS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
set -o pipefail | |
# globals | |
readonly VERSION='2.16.1' | |
readonly DOWNLOAD_URL='http://sourceforge.net/projects/e1000/files/ixgbevf%20stable/2.16.1/ixgbevf-2.16.1.tar.gz' | |
readonly INSTALL_DIR='/usr/src' # must be here for dkms | |
function log { | |
echo "[$(date +'%Y-%m-d %H:%M:%S')]:" $@ | |
} | |
# 0 | |
function install_dependencies { | |
log 'installing dependencies' | |
apt-get -q install -y dkms build-essential wget curl | |
} | |
# 1 - download sources to /tmp and move them to the install dir | |
function download_sources { | |
log 'downloading the sources' | |
# https://gist.github.com/CBarraford/8850424 | |
readonly local download_tar=`basename "${DOWNLOAD_URL}"` | |
readonly local untared=`echo ${download_tar} | sed 's/.tar.gz//g'` | |
cd /tmp | |
if [[ ! -f "${download_tar}" ]]; then | |
wget "${DOWNLOAD_URL}" | |
fi | |
if [[ ! -d "${untared}" ]]; then | |
tar -xzf "${download_tar}" | |
fi | |
if [[ ! -d "${INSTALL_DIR}/${untared}" ]]; then | |
cp -r "${untared}" "${INSTALL_DIR}" | |
fi | |
cd "${INSTALL_DIR}"/${untared} | |
} | |
# 2 - add dkms config | |
function add_dkms_config { | |
log 'adding dkms config' | |
# @see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enhanced-networking-ubuntu | |
cat > dkms.conf <<EOF | |
PACKAGE_NAME="ixgbevf" | |
PACKAGE_VERSION="${VERSION}" | |
CLEAN="cd src/; make clean" | |
MAKE="cd src/; make BUILD_KERNEL=\${kernelver}" | |
BUILT_MODULE_LOCATION[0]="src/" | |
BUILT_MODULE_NAME[0]="ixgbevf" | |
DEST_MODULE_LOCATION[0]="/updates" | |
DEST_MODULE_NAME[0]="ixgbevf" | |
AUTOINSTALL="yes" | |
EOF | |
} | |
# 3 - get patch file and apply it | |
function patch_sources { | |
log 'patching the sources' | |
readonly local patchfile='patch-ubuntu_14.04.1-ixgbevf-2.16.1-kcompat.h.patch' | |
# @see https://gist.github.com/defila-aws/44946d3a3c0874fe3d17/raw/af64c3c589811a0d214059d1e4fd220a96eaebb3/patch-ubuntu_14.04.1-ixgbevf-2.16.1-kcompat.h.patch | |
cat > "${patchfile}" <<EOF | |
--- /usr/src/ixgbevf-2.16.1/src/kcompat.h.orig 2015-02-03 18:34:22.901474028 +0000 | |
+++ /usr/src/ixgbevf-2.16.1/src/kcompat.h 2015-02-03 18:35:32.577440102 +0000 | |
@@ -3219,8 +3219,6 @@ | |
#define u64_stats_update_begin(a) do { } while(0) | |
#define u64_stats_update_end(a) do { } while(0) | |
#define u64_stats_fetch_begin(a) do { } while(0) | |
-#define u64_stats_fetch_retry_bh(a) (0) | |
-#define u64_stats_fetch_begin_bh(a) (0) | |
#if (RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,1)) | |
#define HAVE_8021P_SUPPORT | |
@@ -4174,8 +4172,8 @@ | |
/*****************************************************************************/ | |
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) ) | |
-#define u64_stats_fetch_begin_irq u64_stats_fetch_begin_bh | |
-#define u64_stats_fetch_retry_irq u64_stats_fetch_retry_bh | |
+#define u64_stats_fetch_begin_irq(a) (0) | |
+#define u64_stats_fetch_retry_irq(a, b) (0) | |
#else | |
#define HAVE_PTP_1588_CLOCK_PINS | |
#define HAVE_NETDEV_PORT | |
EOF | |
cd src | |
set +e | |
patch -p5 -N --dry-run --silent < "../${patchfile}" 2>/dev/null | |
readonly local ret_val=$? | |
set -e | |
if [[ $ret_val -eq 0 ]]; then | |
patch -p5 < "../${patchfile}" | |
fi | |
} | |
# 4 - build / install | |
function build_module { | |
log 'building the module' | |
readonly local installed=`dkms status -m ixgbevf -v ${VERSION}` | |
if [[ ! "${installed}" =~ 'installed' ]]; then | |
dkms add -m ixgbevf -v ${VERSION} | |
dkms build -m ixgbevf -v ${VERSION} | |
dkms install -m ixgbevf -v ${VERSION} | |
fi | |
modprobe ixgbevf | |
update-initramfs -c -k all | |
echo "options ixgbevf InterruptThrottleRate=1,1,1,1,1,1,1,1" > /etc/modprobe.d/ixgbevf.conf | |
} | |
# 5 - check that it worked | |
function list_current_options { | |
log 'listing the current setup' | |
modinfo ixgbevf | |
ethtool -i eth0 | |
} | |
# :: main :: | |
install_dependencies | |
download_sources | |
add_dkms_config | |
patch_sources | |
build_module | |
list_current_options |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment