前幾天裝了個fedora9實體機,無奈網卡一直不能用,今天終於搞定了,這裏記錄下。
下載驅動源碼:下載地址
安裝完對應的kernel-devel後,解壓tg3壓縮包,按照README.txt中描述安裝,其中介紹了2種方法,我採用的是下面這中rpm的方式:
- The following are general guidelines for installing the driver.
- 1. Install the source RPM package:
- rpm -ivh tg3-<version>.src.rpm
- 2. CD to the RPM path and build the binary driver for your kernel:
- cd /usr/src/{redhat,OpenLinux,turbo,packages,rpm ..}
- rpm -bb SPECS/tg3.spec
- or
- rpmbuild -bb SPECS/tg3.spec (for RPM version 4.x.x)
- Note that the RPM path is different for different Linux distributions.
- The driver will be compiled for the running kernel by default. To build
- the driver for a kernel different than the running one, specify the
- kernel by defining it in KVER:
- rpmbuild -bb SPECS/tg3.spec --define "KVER <kernel version>"
- where <kernel version> in the form of 2.x.y-z is the version of another
- kernel that is installed on the system.
- 3. Install the newly built package (driver and man page):
- rpm -ivh RPMS/<arch>/tg3-<version>.<arch>.rpm
- <arch> is the architecture of the machine, e.g. i386:
- rpm -ivh RPMS/i386/tg3-<version>.i386.rpm
但是在進行到第2步
- rpmbuild -bb SPECS/tg3.spec
的時候出錯了,提示如下錯誤
- make -C /lib/modules/2.6.25-14.fc9.i686/build SUBDIRS=/usr/src/redhat/BUILD/tg3-3.116j modules
- make[1]: Entering directory `/usr/src/kernels/2.6.25-14.fc9.i686'
- CC [M] /usr/src/redhat/BUILD/tg3-3.116j/tg3.o
- /usr/src/redhat/BUILD/tg3-3.116j/tg3.c: In function 'tg3_napi_fini':
- /usr/src/redhat/BUILD/tg3-3.116j/tg3.c:5821: error: implicit declaration of function 'netif_napi_del'
- make[2]: *** [/usr/src/redhat/BUILD/tg3-3.116j/tg3.o] Error 1
- make[1]: *** [_module_/usr/src/redhat/BUILD/tg3-3.116j] Error 2
- make[1]: Leaving directory `/usr/src/kernels/2.6.25-14.fc9.i686'
- make: *** [default] Error 2
- error: Bad exit status from /var/tmp/rpm-tmp.81225 (%build)
解決方法如下:
打開/usr/src/kernels/2.6.25-14.fc9.i686/include/linux/netdevice.h 文件,在netif_napi_add函數下添加
- static inline void netif_napi_del(struct napi_struct *napi)
- {
- #ifdef CONFIG_NETPOLL
- list_del(&napi->dev_list);
- #endif
- }
保存後重新運行
- rpmbuild -bb SPECS/tg3.spec
沒有錯誤,搞定。。。
這時候你會在/usr/src/redhat/RPMS/i386目錄下看到剛生成的tg3-3.116j-1.i386.rpm文件,用rpm安裝即可。