CentOS 编译安装 ixgbe-5.3.7

1. 安装依赖

1
# yum install gcc kernel-header kernel-devel

2. 解压源码并编译

1
2
3
# tar zxvf ixgbe-5.3.7.tar.gz
# cd ixgbe-5.3.7/src/
# make 

此时还是有以下错误

1
2
3
4
# make
common.mk:102: *** Kernel header files not in any of the expected locations.
common.mk:103: *** Install the appropriate kernel development package, e.g.
common.mk:104: *** kernel-devel, for building kernel modules and try again.  Stop.

打开 common.mk 发现编译时需要 /usr/src/linux 目录,但是系统并没有此目录,手动创建 /usr/src/kernels/3.10.0-862.6.3.el7.x86_64/ 到 /usr/src/linux 的链接即可

1
# ln -s /usr/src/kernels/3.10.0-862.6.3.el7.x86_64/ /usr/src/linux

重新编译

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# make 
make[1]: Entering directory `/usr/src/kernels/3.10.0-862.6.3.el7.x86_64'
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_main.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_api.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_common.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_dcb.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_dcb_82598.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_dcb_82599.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_ethtool.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_lib.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_mbx.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_sriov.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_param.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_phy.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_procfs.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_82598.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_82599.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_x540.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_x550.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_dcb_nl.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_debugfs.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_fcoe.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_ptp.o
  CC [M]  /root/ixgbe-5.3.7/src/ixgbe_sysfs.o
  CC [M]  /root/ixgbe-5.3.7/src/kcompat.o
  LD [M]  /root/ixgbe-5.3.7/src/ixgbe.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /root/ixgbe-5.3.7/src/ixgbe.mod.o
  LD [M]  /root/ixgbe-5.3.7/src/ixgbe.ko
make[1]: Leaving directory `/usr/src/kernels/3.10.0-862.6.3.el7.x86_64'

查看编译后驱动信息

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# modinfo ./ixgbe.ko
filename:       /root/ixgbe-5.3.7/src/./ixgbe.ko
version:        5.3.7
license:        GPL
description:    Intel(R) 10GbE PCI Express Linux Network Driver
author:         Intel Corporation, <linux.nics@intel.com>
retpoline:      Y
rhelversion:    7.5
srcversion:     9E1B3824190E963083DADF5
…………

3. 加载驱动

如果系统已经安装 ixgbe 驱动要先卸载

1
2
3
4
# rmmod ixgbe.ko

# lsmod | grep ixgbe
ixgbevf                62069  0 

加载ixgbe驱动

1
2
3
4
5
6
7
# insmod ./ixgbe.ko

# lsmod | grep ixgbe
ixgbe                 329961  0 
ixgbevf                62069  0 
dca                    15130  2 ixgbe,ioatdma
ptp                    19231  2 tg3,ixgbe

使用 dmesg 验证驱动是否加载成功

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# dmesg

[681507.970884] Intel(R) 10GbE PCI Express Linux Network Driver - version 5.3.7
[681507.970886] Copyright(c) 1999 - 2018 Intel Corporation.
[681507.989690] ixgbe: 0000:05:00.0: ixgbe_check_options: FCoE Offload feature enabled
[681508.138527] ixgbe 0000:05:00.0: irq 95 for MSI/MSI-X
[681508.138537] ixgbe 0000:05:00.0: irq 96 for MSI/MSI-X
[681508.138549] ixgbe 0000:05:00.0: irq 97 for MSI/MSI-X
[681508.138557] ixgbe 0000:05:00.0: irq 98 for MSI/MSI-X
[681508.138569] ixgbe 0000:05:00.0: irq 99 for MSI/MSI-X
[681508.138577] ixgbe 0000:05:00.0: irq 100 for MSI/MSI-X
[681508.138589] ixgbe 0000:05:00.0: irq 101 for MSI/MSI-X
[681508.138597] ixgbe 0000:05:00.0: irq 102 for MSI/MSI-X
[681508.138609] ixgbe 0000:05:00.0: irq 103 for MSI/MSI-X
[681508.138616] ixgbe 0000:05:00.0: irq 104 for MSI/MSI-X
[681508.138624] ixgbe 0000:05:00.0: irq 105 for MSI/MSI-X
[681508.138632] ixgbe 0000:05:00.0: irq 106 for MSI/MSI-X
[681508.138640] ixgbe 0000:05:00.0: irq 107 for MSI/MSI-X
[681508.138648] ixgbe 0000:05:00.0: irq 108 for MSI/MSI-X
[681508.138656] ixgbe 0000:05:00.0: irq 109 for MSI/MSI-X
[681508.138664] ixgbe 0000:05:00.0: irq 110 for MSI/MSI-X
[681508.138671] ixgbe 0000:05:00.0: irq 111 for MSI/MSI-X
[681508.138679] ixgbe 0000:05:00.0: irq 112 for MSI/MSI-X
[681508.138691] ixgbe 0000:05:00.0: irq 113 for MSI/MSI-X
[681508.138698] ixgbe 0000:05:00.0: irq 114 for MSI/MSI-X
[681508.138706] ixgbe 0000:05:00.0: irq 115 for MSI/MSI-X
[681508.138714] ixgbe 0000:05:00.0: irq 116 for MSI/MSI-X
[681508.138722] ixgbe 0000:05:00.0: irq 117 for MSI/MSI-X
[681508.138730] ixgbe 0000:05:00.0: irq 118 for MSI/MSI-X
[681508.138737] ixgbe 0000:05:00.0: irq 119 for MSI/MSI-X
[681508.138751] ixgbe 0000:05:00.0: irq 120 for MSI/MSI-X
[681508.138758] ixgbe 0000:05:00.0: irq 121 for MSI/MSI-X

4. 安装 ixgbe 驱动

确认驱动加载成功后,继续安装驱动到系统

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# make install

make[1]: Entering directory `/usr/src/kernels/3.10.0-862.6.3.el7.x86_64'
  Building modules, stage 2.
  MODPOST 1 modules
make[1]: Leaving directory `/usr/src/kernels/3.10.0-862.6.3.el7.x86_64'
Copying manpages...
Installing modules...
make[1]: Entering directory `/usr/src/kernels/3.10.0-862.6.3.el7.x86_64'
  INSTALL /root/ixgbe-5.3.7/src/ixgbe.ko
Can't read private key
  DEPMOD  3.10.0-862.6.3.el7.x86_64
make[1]: Leaving directory `/usr/src/kernels/3.10.0-862.6.3.el7.x86_64'
Running depmod...

ixgbe.ko 会被安装到以下目录

1
/lib/modules/KERNEL_VERSION/updates/drivers/net/ethernet/intel/ixgbe/

编译好的驱动将在启动的时候自动加载,也可以用以下命令加载

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# modprobe ixgbe

# modinfo ixgbe
filename:       /lib/modules/3.10.0-862.6.3.el7.x86_64/updates/drivers/net/ethernet/intel/ixgbe/ixgbe.ko
version:        5.3.7
license:        GPL
description:    Intel(R) 10GbE PCI Express Linux Network Driver
author:         Intel Corporation, <linux.nics@intel.com>
retpoline:      Y
rhelversion:    7.5
srcversion:     9E1B3824190E963083DADF5
……

参考文章

How to compile ixgbe driver on CentOS, RHEL or Fedora

一个默默无闻的工程师的日常
Built with Hugo
主题 StackJimmy 设计