Linux 驱动相关以及网卡驱动升级案例

images (3)

驱动操作命令:
insmod / modprobe 加载驱动
rmmod                     卸载驱动
lsmod                       查看系统中所有已经被加载了的所有的模块以及模块间的依赖关系
modinfo                    获得模块的信息

查看已经加载的驱动模块的信息:
lsmod                       能够显示驱动的大小以及被谁使用
cat /proc/modules    能够显示驱动模块大小、在内核空间中的地址
cat /proc/devices     只显示驱动的主设备号,且是分类显示
ls /sys/module            下面存在对应的驱动的目录,目录下包含驱动的分段信息等等。

案例 R710升级 网卡驱动 (centos5.x 自带的r710网卡驱动有点问题,每隔一点时间,就需要重启一下网络,所以需要升级一下),具体方法如下:

1 – 在编译网卡之前,先检查网卡使用的网卡驱动模块名。
[root@localhost ~]# cat /etc/modprobe.conf
alias eth0 bnx2  表明网卡驱动模块名为 bnx2
alias eth1 bnx2
alias eth2 bnx2
alias eth3 bnx2
2 – 检查当前是否有已加载网卡驱动模块 bnx2
[root@localhost ~]# lsmod | grep bnx2
bnx2 179021 0  表明系统已有加载完网卡驱动模块

bnx2i 40413 0
cnic 44877 1 bnx2i
libiscsi2 42693 6 be2iscsi,ib_iser,iscsi_tcp,bnx2i,cxgb3i,libiscsi_tcp
scsi_transport_iscsi2 37709 8
be2iscsi,ib_iser,iscsi_tcp,bnx2i,cxgb3i,libiscsi2
scsi_mod 141973 15
be2iscsi,ib_iser,iscsi_tcp,bnx2i,cxgb3i,libiscsi2,scsi_transport_iscs
i2,scsi_dh,sg,pvscsi,libata,mptspi,mptscsih,scsi_transport_spi,sd_mod

3 – 查看当前驱动模块信息,从而得到驱动模块的版本,以便验证稍后网卡驱
动模块升级
[root@localhost redhat]# modinfo bnx2

filename: /lib/modules/2.6.18-194.el5/kernel/drivers/net/bnx2.ko  网
卡驱动存放的路径,升级后网卡存放路径与此路径不同
version: 2.0.2  表明网卡模块版本为 2.0.2,是系统默认网卡驱动版本

license: GPL
description: Broadcom NetXtreme II BCM5706/5708/5709/5716 Driver
author: Michael Chan <mchan@broadcom.com>
srcversion: 7025AAF3645EE432EAF1C00
alias: pci:v000014E4d0000163Csv*sd*bc*sc*i*
alias: pci:v000014E4d0000163Bsv*sd*bc*sc*i*
alias: pci:v000014E4d0000163Asv*sd*bc*sc*i*
alias: pci:v000014E4d00001639sv*sd*bc*sc*i*
alias: pci:v000014E4d000016ACsv*sd*bc*sc*i*
alias: pci:v000014E4d000016AAsv*sd*bc*sc*i*
alias: pci:v000014E4d000016AAsv0000103Csd00003102bc*sc*i*
alias: pci:v000014E4d0000164Csv*sd*bc*sc*i*
alias: pci:v000014E4d0000164Asv*sd*bc*sc*i*
alias: pci:v000014E4d0000164Asv0000103Csd00003106bc*sc*i*
alias: pci:v000014E4d0000164Asv0000103Csd00003101bc*sc*i*
depends:
vermagic: 2.6.18-194.el5 SMP mod_unload 686 REGPARM 4KSTACKS gcc-4.1

parm: disable_msi:Disable Message Signaled Interrupt (MSI) (int)
parm: enable_entropy:Allow bnx2 to populate the /dev/random entropy pool
(int)
module_sig:
883f3504ba037551e1fa4939f6a62931127b30a0e5a160a7ad7a7b9b2c162b309b331
6fddc41f280a0cbecbd80e777d961e16218019c365c4b328d1a8

4 – 从 DELL 网站下载 Broadcom 网卡驱动包
Bcom_LAN_16.2.0_Linux_Source_A01.tar.gz。解压开始安装
[root@localhost mnt]# tar -vzxf Bcom_LAN_16.2.0_Linux_Source_A01.tar.gz

解压驱动包

Bcom_LAN_16.2.0_Linux_Source_A01/
Bcom_LAN_16.2.0_Linux_Source_A01/Linux_Readme/
Bcom_LAN_16.2.0_Linux_Source_A01/Linux_Readme/linux_readme.txt
Bcom_LAN_16.2.0_Linux_Source_A01/NetXtreme/
Bcom_LAN_16.2.0_Linux_Source_A01/NetXtreme/ChangeLog
Bcom_LAN_16.2.0_Linux_Source_A01/NetXtreme/README.TXT
Bcom_LAN_16.2.0_Linux_Source_A01/NetXtreme/tg3-3.115j-1.src.rpm
Bcom_LAN_16.2.0_Linux_Source_A01/NetXtreme/tg3-3.115j.tar.gz
Bcom_LAN_16.2.0_Linux_Source_A01/NetXtreme/tg3_sup-3.115j-1.ISO.tar.g
z
Bcom_LAN_16.2.0_Linux_Source_A01/NetXtremeII/
Bcom_LAN_16.2.0_Linux_Source_A01/NetXtremeII/brcm_iscsi_uio-0.6.2.13.
tar.gz
Bcom_LAN_16.2.0_Linux_Source_A01/NetXtremeII/netxtreme2-6.2.23-1.src.
rpm
Bcom_LAN_16.2.0_Linux_Source_A01/NetXtremeII/netxtreme2-6.2.23.tar.gz
Bcom_LAN_16.2.0_Linux_Source_A01/NetXtremeII/netxtreme2_sup-6.2.23-1.
ISO.tar.gz
Bcom_LAN_16.2.0_Linux_Source_A01/NetXtremeII/README
Bcom_LAN_16.2.0_Linux_Source_A01/NetXtremeII/RELEASE.bnx2.TXT
Bcom_LAN_16.2.0_Linux_Source_A01/NetXtremeII/RELEASE.bnx2i.TXT
Bcom_LAN_16.2.0_Linux_Source_A01/NetXtremeII/RELEASE.bnx2x.TXT
[root@localhost mnt]# cd Bcom_LAN_16.2.0_Linux_Source_A01
进入解压
出来的目录
[root@localhost Bcom_LAN_16.2.0_Linux_Source_A01]# ls
显示文件夹内容
Linux_Readme NetXtreme NetXtremeII
[root@localhost Bcom_LAN_16.2.0_Linux_Source_A01]# cd NetXtremeII/

进入到网卡驱动资源目录

[root@localhost NetXtremeII]# ls   显示此目录的内容

brcm_iscsi_uio-0.6.2.13.tar.gz README
netxtreme2-6.2.23-1.src.rpm RELEASE.bnx2i.TXT
netxtreme2-6.2.23.tar.gz RELEASE.bnx2.TXT
netxtreme2_sup-6.2.23-1.ISO.tar.gz RELEASE.bnx2x.TXT
[root@localhost NetXtremeII]# rpm -ivh netxtreme2-6.2.23-1.src.rpm

安装编译网卡所需要的资源

1:netxtreme2 ########################################### [100%]
*********************************************************************
******
Note:
(1) –
RPM 包 netxtreme2-6.2.23-1.src.rpm 所包含的内容,及存放的目录
[root@localhost NetXtremeII]# rpm -qlp netxtreme2-6.2.23-1.src.rpm
/usr/src/redhat/SOURCES/netxtreme2-6.2.23.tar.bz2
/usr/src/redhat/SPECS/netxtreme2.spec
(2) -
Question:
安装 netxtreme2-6.2.23-1.src.rpm 时会报“error: cannot create %sourcedir
/usr/src/redhat/SOURCES”信息。
Cause:
没有安装 qlp rpm-build-4.4.2.3-18.el5.i386.rpm 包。
Resolution:
安装 rpm-build,同时关联 binutils,elfutils 两个包。可解决此问题。
### /usr/src/redhat/SOURCES 此目录是由 rpm-build 软件包安装生成 ###
[root@localhost redhat]# rpm -qlp rpm-build-4.4.2.3-18.el5.i386.rpm 
检查 rpm-build 软件包所包含的内容
/usr/bin/rpmbuild
/usr/src/redhat
/usr/src/redhat/BUILD
/usr/src/redhat/RPMS
/usr/src/redhat/RPMS/athlon
/usr/src/redhat/RPMS/geode
/usr/src/redhat/RPMS/i386
/usr/src/redhat/RPMS/i486
/usr/src/redhat/RPMS/i586
/usr/src/redhat/RPMS/i686
/usr/src/redhat/RPMS/noarch
/usr/src/redhat/SOURCES/usr/src/redhat/SPECS
/usr/src/redhat/SRPMS
*********************************************************************
******
5 – 编译网卡驱动
[root@localhost redhat]# rpmbuild -bb SPECS/netxtreme2.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.98884
+ umask 022
+ cd /usr/src/redhat/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /usr/src/redhat/BUILD
+ rm -rf netxtreme2-6.2.23
+ /usr/bin/bzip2 -dc /usr/src/redhat/SOURCES/netxtreme2-6.2.23.tar.bz2
+ tar -xvvf -
drwxr-xr-x root/root 0 2011-02-11 04:25:14 netxtreme2-6.2.23/
drwxr-xr-x root/root 0 2011-02-11 04:25:14
netxtreme2-6.2.23/bnx2x-1.62.15/
……  省略编译过程
Requires(interp): /bin/sh /bin/sh
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires(post): /bin/sh
Requires(postun): /bin/sh
Checking for unpackaged file(s): /usr/lib/rpm/check-files
/var/tmp/netxtreme2-buildroot
Wrote: /usr/src/redhat/RPMS/i386/netxtreme2-6.2.23-1.i386.rpm 可以看
到生成的网卡驱动 RPM 包:netxtreme2-6.2.23-1.i386.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.28263
+ umask 022
+ cd /usr/src/redhat/BUILD
+ cd netxtreme2-6.2.23
+ rm -rf /var/tmp/netxtreme2-buildroot
/usr/src/redhat/BUILD/file.list.netxtreme2
+ exit 0
*********************************************************************
******
Note:

(1)- Question: 编译网卡驱动报错,退出编译过程,无法编译成功

[root@localhost redhat]# rpmbuild -bb SPECS/netxtreme2.spec
/var/tmp/rpm-tmp.9077: line 32: make: command not founderror: Bad exit status from /var/tmp/rpm-tmp.9077 (%build)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.9077 (%build)
Cause:
是因为没有编译环境,或编译环境不全导致。
Resolution:
需要安装 RPM 包“kernel-devel”和 RPM 包组"Development Tools"
建议使用 YUM 环境安装以上 RPM 包,以解决 RPM 包关联性问题。安装命令如下:
[root@localhost ~]# yum groupinstall "Development Tools"
[root@localhost ~]# yum install kernel-devel
~~~
(2)- Question: RHEL5.7 使用 DELL 网站下载的网卡驱动,编译报错。

编译过程信息:
In file included from
/usr/src/redhat/BUILD/netxtreme2-6.2.23/bnx2x-1.62.15/src/bnx2x.h:68,
from
/usr/src/redhat/BUILD/netxtreme2-6.2.23/bnx2x-1.62.15/src/bnx2x_main.
c:80:
/usr/src/redhat/BUILD/netxtreme2-6.2.23/bnx2x-1.62.15/src/bnx2x_compa
t.h:995:
error: redefinition of 'skb_checksum_none_assert'
include/linux/skbuff.h:1827: error: previous definition of
'skb_checksum_none_assert' was here
In file included from
/usr/src/redhat/BUILD/netxtreme2-6.2.23/bnx2x-1.62.15/src/bnx2x.h:68,
from
/usr/src/redhat/BUILD/netxtreme2-6.2.23/bnx2x-1.62.15/src/bnx2x_main.
c:80:
/usr/src/redhat/BUILD/netxtreme2-6.2.23/bnx2x-1.62.15/src/bnx2x_compa
t.h:1009:1:
error: "PCI_VPD_LRDT_ID_STRING" redefined
In file included from
/usr/src/redhat/BUILD/netxtreme2-6.2.23/bnx2x-1.62.15/src/bnx2x_main.
c:34:
include/linux/pci.h:997:1: error: this is the location of the previous
definition
In file included from
/usr/src/redhat/BUILD/netxtreme2-6.2.23/bnx2x-1.62.15/src/bnx2x.h:68,from
/usr/src/redhat/BUILD/netxtreme2-6.2.23/bnx2x-1.62.15/src/bnx2x_main.
c:80:
/usr/src/redhat/BUILD/netxtreme2-6.2.23/bnx2x-1.62.15/src/bnx2x_compa
t.h:1011:1:
error: "PCI_VPD_LRDT_RO_DATA" redefined
In file included from
/usr/src/redhat/BUILD/netxtreme2-6.2.23/bnx2x-1.62.15/src/bnx2x_main.
c:34:
include/linux/pci.h:998:1: error: this is the location of the previous
definition
In file included from
/usr/src/redhat/BUILD/netxtreme2-6.2.23/bnx2x-1.62.15/src/bnx2x.h:68,
from
/usr/src/redhat/BUILD/netxtreme2-6.2.23/bnx2x-1.62.15/src/bnx2x_main.
c:80:
/usr/src/redhat/BUILD/netxtreme2-6.2.23/bnx2x-1.62.15/src/bnx2x_compa
t.h:1013:1:
Cause:
从 DELL 网站下载的网卡 Bcom_LAN_16.2.0_Linux_Source_A01.tar.gz 驱动包,
编译过程中,会在编译 Executing(%build)过程,出现编译文件内部错误。
所以可以推断,此编译文件 match 此系统。
Resolution:
从 Broadcom 官网下载 Linux 的驱动来进行编译,即可。
http://www.broadcom.com/support/ethernet_nic/netxtremeii.php
http://www.broadcom.com/support/license.php?file=NXII/linux-7.0.36.zi
p
编译过程与 DELL 网站下载的驱动编译方法一致。
[root@localhost redhat]# modinfo bnx2
filename: /lib/modules/2.6.18-274.el5/updates/bnx2.ko
version: 2.1.12b <-- 升级后的网卡驱动版本
license: GPL
description: Broadcom NetXtreme II BCM5706/5708/5709/5716 Driver
author: Michael Chan
srcversion: FAB396684975ABE7214051B
alias: pci:v000014E4d0000163Csv*sd*bc*sc*i*
alias: pci:v000014E4d0000163Bsv*sd*bc*sc*i*
alias: pci:v000014E4d0000163Asv*sd*bc*sc*i*
alias: pci:v000014E4d00001639sv*sd*bc*sc*i*
alias: pci:v000014E4d000016ACsv*sd*bc*sc*i*
alias: pci:v000014E4d000016AAsv*sd*bc*sc*i*alias: pci:v000014E4d000016AAsv0000103Csd00003102bc*sc*i*
alias: pci:v000014E4d0000164Csv*sd*bc*sc*i*
alias: pci:v000014E4d0000164Asv*sd*bc*sc*i*
alias: pci:v000014E4d0000164Asv0000103Csd00003106bc*sc*i*
alias: pci:v000014E4d0000164Asv0000103Csd00003101bc*sc*i*
depends:
vermagic: 2.6.18-274.el5 SMP mod_unload gcc-4.1
parm: disable_msi:Disable Message Signaled Interrupt (MSI) (int)
parm: stop_on_tx_timeout:For debugging purposes, prevent a chip reset
when a tx timeout occurs (int)
*********************************************************************
******

6 – 安装已编译好的网卡驱动 
[root@localhost redhat]# rpm -ivh
RPMS/i386/netxtreme2-6.2.23-1.i386.rpm
Preparing... ########################################### [100%]
1:netxtreme2 ########################################### [100%]
*********************************************************************
******
Question:

安装编译好的网卡驱动 RPM 包 netxtreme2-6.2.23-1.i386.rpm,检查网卡模块
没有更新成功。

Cause:
安装编译好的驱动是有提示信息,表示安装的 RPM 包文件,与系统以后的文件有
冲突
[root@localhost ~]# rpm -ivh netxtreme2-6.2.23-1.x86_64.rpm
Preparing... ########################################### [100%]
file /usr/share/man/man4/bnx2.4.gz from install of
netxtreme2-6.2.23-1.x86_64 conflicts with file from package
netxtreme2-5.0.17-1.dkms.noarch
file /usr/share/man/man4/bnx2x.4.gz from install of
netxtreme2-6.2.23-1.x86_64 conflicts with file from package
netxtreme2-5.0.17-1.dkms.noarch
会导致/lib/modules/2.6.18-194.el5/updates/目录下,没有新生成的网卡模块
bnx2.ko,从而导致网卡升级失败。
Resolution:# rpm -ivh netxtreme2-6.2.23-1.x86_64.rpm --force  使用“--force”参
数,是以强制的方式安装,覆盖掉已有文件
即刻运行 modinfo bnx2,就可确认到网卡升级到新的版本。
*********************************************************************
******

7 – 安装新网卡驱动 RPM 包后,重新检查已挂载的网卡驱动模块。 

[root@localhost redhat]# modinfo bnx2
filename: /lib/modules/2.6.18-194.el5/updates/bnx2.ko  可以看到网卡
驱动模块地址已经更新
version: 2.0.23b  可以新网卡驱动版本从 2.0.2 升级到 2.0.23b
license: GPL
description: Broadcom NetXtreme II BCM5706/5708/5709/5716 Driver
author: Michael Chan <mchan@broadcom.com>
srcversion: 6E0DD070AB24C11F50B2712
alias: pci:v000014E4d0000163Csv*sd*bc*sc*i*
alias: pci:v000014E4d0000163Bsv*sd*bc*sc*i*
alias: pci:v000014E4d0000163Asv*sd*bc*sc*i*
alias: pci:v000014E4d00001639sv*sd*bc*sc*i*
alias: pci:v000014E4d000016ACsv*sd*bc*sc*i*
alias: pci:v000014E4d000016AAsv*sd*bc*sc*i*
alias: pci:v000014E4d000016AAsv0000103Csd00003102bc*sc*i*
alias: pci:v000014E4d0000164Csv*sd*bc*sc*i*
alias: pci:v000014E4d0000164Asv*sd*bc*sc*i*
alias: pci:v000014E4d0000164Asv0000103Csd00003106bc*sc*i*
alias: pci:v000014E4d0000164Asv0000103Csd00003101bc*sc*i*
depends:
vermagic: 2.6.18-194.el5 SMP mod_unload 686 REGPARM 4KSTACKS gcc-4.1
parm: disable_msi:Disable Message Signaled Interrupt (MSI) (int)
parm: stop_on_tx_timeout:For debugging purposes, prevent a chip reset
when a tx timeout occurs (int)

8. 使网卡驱动生效:
/etc/init.d/network stop; sleep 1; rmmod bnx2; sleep 1; modprobe bnx2; sleep 1; /etc/init.d/network start

再使用 modinfo 命令,再次验收升级结果,如果显示为新模块,表明升级成功

还没有评论,快来抢沙发!

发表评论

  • 😉
  • 😐
  • 😡
  • 😈
  • 🙂
  • 😯
  • 🙁
  • 🙄
  • 😛
  • 😳
  • 😮
  • emoji-mrgree
  • 😆
  • 💡
  • 😀
  • 👿
  • 😥
  • 😎
  • ➡
  • 😕
  • ❓
  • ❗
  • 67 queries in 0.522 seconds