Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 33 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save Ray33/ba189a729d81babc99d7cef0fb6fbcd8 to your computer and use it in GitHub Desktop.
Save Ray33/ba189a729d81babc99d7cef0fb6fbcd8 to your computer and use it in GitHub Desktop.
Amazon Elastic Network Adapter (ENA) on CentOS 7
sudo su
yum --enablerepo=extras install epel-release
yum -y install patch dkms kernel-devel perl
yum update
#Required for kernel num 5:
yum --enablerepo=elrepo-kernel -y install kernel-ml-devel
reboot
#After reboot:
sudo su
###############Update kernel START###################
## Update to latest kernel - optional
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/ elrepo-release-7.0-5.el7.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install kernel-ml
awk -F\' /^menuentry/{print\$2} /etc/grub2.cfg
#Note: In the list of kernels, identify the latest and remeber it's index (index starts from 0)
#In case the first item in the list (index=0) is the kernel you want to activate, run:
grub2-set-default 0
grub2-mkconfig -o /boot/grub2/grub.cfg
vi /etc/default/grub
#change line: GRUB_DEFAULT=saved to GRUB_DEFAULT=0
reboot
#verify current kernel via:
uname -a
#remove old kernels:
rpm -qa | grep kernel | sort
#for the kernels in the list , that you want to remove:
yum remove REPLACE_WITH_KERNEL_NAME
###############Update kernel END ###################
reboot
sudo su
//TODO fetch latest ena_driver from: https://github.com/amzn/amzn-drivers/releases, this script is based on 2.2.9
cd /tmp
curl -o ena_linux_2.2.9.tar.gz https://codeload.github.com/amzn/amzn-drivers/tar.gz/ena_linux_2.2.9
tar zxvf ena_linux_2.2.9.tar.gz
mv amzn-drivers-ena_linux_2.2.9 /usr/src/ena-2.2.9
#Copy the bellow and paste in command line (lines 52-63):
cat <<EOF > /usr/src/ena-2.2.9/dkms.conf
PACKAGE_NAME="ena"
PACKAGE_VERSION="2.2.9"
AUTOINSTALL="yes"
REMAKE_INITRD="yes"
BUILT_MODULE_LOCATION[0]="kernel/linux/ena"
BUILT_MODULE_NAME[0]="ena"
DEST_MODULE_LOCATION[0]="/updates"
DEST_MODULE_NAME[0]="ena"
CLEAN="cd kernel/linux/ena; make clean"
MAKE="cd kernel/linux/ena; make BUILD_KERNEL=\${kernelver}"
EOF
dkms add -m ena -v 2.2.9
dkms build -m ena -v 2.2.9
dkms install -m ena -v 2.2.9
dracut -f --add-drivers ena
##Verification:
modinfo ena
##### You should get similar info: #####
#filename: /lib/modules/5.7.2-1.el7.elrepo.x86_64/extra/ena.ko
#version: 2.2.9g
#license: GPL
#description: Elastic Network Adapter (ENA)
#author: Amazon.com, Inc. or its affiliates
#srcversion: CBF3F17443FAB1A53E24D56
#alias: pci:v00001D0Fd0000EC21sv*sd*bc*sc*i*
#alias: pci:v00001D0Fd0000EC20sv*sd*bc*sc*i*
#alias: pci:v00001D0Fd00001EC2sv*sd*bc*sc*i*
#alias: pci:v00001D0Fd00000EC2sv*sd*bc*sc*i*
#alias: pci:v00001D0Fd00000051sv*sd*bc*sc*i*
#depends:
#retpoline: Y
#name: ena
#vermagic: 5.7.2-1.el7.elrepo.x86_64 SMP mod_unload modversions
#parm: debug:Debug level (0=none,...,16=all) (int)
#parm: rx_queue_size:Rx queue size. The size should be a power of 2. Max value is 8K
# (int)
#parm: force_large_llq_header:Increases maximum supported header size in LLQ mode to 224 bytes, while reducing the maximum TX queue size by half.
# (int)
#parm: num_io_queues:Sets number of RX/TX queues to allocate to device. The maximum value depends on the device and number of online CPUs.
# (int)
# The below is relevant only if the instance did not have ENA enabled before :
#Stop the instance and from another AWS instance run:
aws ec2 modify-instance-attribute --region THE_INSTANCE_REGION --instance-id THE_INSTANCE_ID --ena-support
#e.g: aws ec2 modify-instance-attribute --region ap-southeast-1 --instance-id i-0123456789abcdef --ena-support
#Create an image from the instance
#Open the image on ENA supportive instance type (e.g. M5 , R4,.. )
#Validate interface:
ifconfig -s -a
#get Iface name, e.g: ens5
ethtool -i ens5
##### You should get similar info: #####
#driver: ena
#version: 2.1.1g ################## the ENA version #############
#firmware-version:
#expansion-rom-version:
#bus-info: 0000:00:05.0
#supports-statistics: yes
#supports-test: no
#supports-eeprom-access: no
#supports-register-dump: no
#supports-priv-flags: no
######################################################################################
# Find this gist useful ?? : Please share your love by clicking the "Star" icon above
######################################################################################
@Ray33
Copy link
Author

Ray33 commented Jun 16, 2019

For anyone that following this and updated the Kernel to 5.0.4 and is getting the error message "Your kernel headers for kernel 5.0.4... cannot be found at..." when running dkms build -m ena -v 2.0.3

You need to install the kernel-ml-devel package, to do this, run
yum --enablerepo=elrepo-kernel -y install kernel-ml-devel

And proceed with the command that failed.

Updated the script following your commnet.

@aquadrehz
Copy link

aquadrehz commented Oct 11, 2019

FYI
Recent success result for modinfo ena
Represent as following

filename: /lib/modules/5.3.5-1.el7.elrepo.x86_64/extra/ena.ko
version: 2.1.1g
license: GPL
description: Elastic Network Adapter (ENA)
author: Amazon.com, Inc. or its affiliates
srcversion: F342F1BEE707726508E3DF8
alias: pci:v00001D0Fd0000EC21svsdbcsci*
alias: pci:v00001D0Fd0000EC20svsdbcsci*
alias: pci:v00001D0Fd00001EC2svsdbcsci*
alias: pci:v00001D0Fd00000EC2svsdbcsci*
depends:
retpoline: Y
name: ena
vermagic: 5.3.5-1.el7.elrepo.x86_64 SMP mod_unload modversions
parm: debug:Debug level (0=none,...,16=all) (int)
parm: rx_queue_size:Rx queue size. The size should be a power of 2. Max value is 8K
(int)
parm: force_large_llq_header:Increases maximum supported header size in LLQ mode to 224 bytes, while reducing the maximum TX queue size by half.
(int)

@Ray33
Copy link
Author

Ray33 commented Jun 15, 2020

updated to version 2.2.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment