这是运行 Linux 3.11(Mint 发行版,但我认为这无关紧要)的老式机器(AMD K8、Nvidia 芯片组)上的驱动程序问题。
claudius ~ # uname -a
Linux claudius 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
claudius ~ # lspci
00:00.0 Host bridge: NVIDIA Corporation nForce3 250Gb Host Bridge (rev a1)
00:01.0 ISA bridge: NVIDIA Corporation nForce3 250Gb LPC Bridge (rev a2)
00:01.1 SMBus: NVIDIA Corporation nForce 250Gb PCI System Management (rev a1)
00:02.0 USB controller: NVIDIA Corporation CK8S USB Controller (rev a1)
00:02.1 USB controller: NVIDIA Corporation CK8S USB Controller (rev a1)
00:02.2 USB controller: NVIDIA Corporation nForce3 EHCI USB 2.0 Controller (rev a2)
00:05.0 Bridge: NVIDIA Corporation CK8S Ethernet Controller (rev a2)
00:08.0 IDE interface: NVIDIA Corporation CK8S Parallel ATA Controller (v2.5) (rev a2)
00:0a.0 IDE interface: NVIDIA Corporation nForce3 Serial ATA Controller (rev a2)
00:0b.0 PCI bridge: NVIDIA Corporation nForce3 250Gb AGP Host to PCI Bridge (rev a2)
00:0e.0 PCI bridge: NVIDIA Corporation nForce3 250Gb PCI-to-PCI Bridge (rev a2)
00:18.0 Host bridge: Advanced Micro Devices, Inc. [AMD] K8 [Athlon64/Opteron] HyperTransport Technology Configuration
00:18.1 Host bridge: Advanced Micro Devices, Inc. [AMD] K8 [Athlon64/Opteron] Address Map
00:18.2 Host bridge: Advanced Micro Devices, Inc. [AMD] K8 [Athlon64/Opteron] DRAM Controller
00:18.3 Host bridge: Advanced Micro Devices, Inc. [AMD] K8 [Athlon64/Opteron] Miscellaneous Control
01:00.0 VGA compatible controller: NVIDIA Corporation NV34 [GeForce FX 5200] (rev a1)
02:05.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8169 PCI Gigabit Ethernet Controller (rev 10)
Run Code Online (Sandbox Code Playgroud)
我希望内核为我的 Realtek 8169 PCI 以太网卡加载替代驱动程序,您可以在列表末尾看到它作为02:05.0
. 这是详细信息:
claudius ~ # lspci -s 02:05.0 -vv -nn
02:05.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8169 PCI Gigabit Ethernet Controller [10ec:8169] (rev 10)
Subsystem: Realtek Semiconductor Co., Ltd. RTL8169/8110 Family PCI Gigabit Ethernet NIC [10ec:8169]
Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV+ VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx-
Status: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Interrupt: pin A routed to IRQ 19
Region 0: I/O ports at e800 [size=256]
Region 1: Memory at febffc00 (32-bit, non-prefetchable) [size=256]
Expansion ROM at febc0000 [disabled] [size=128K]
Capabilities: [dc] Power Management version 2
Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=375mA PME(D0-,D1+,D2+,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Run Code Online (Sandbox Code Playgroud)
问题是r8169
根本行不通。它甚至可能使 Linux 崩溃。我把它列入黑名单/etc/modprobe.d/
。
解决方案似乎是改用r8168
驱动程序。(这个站点上还有一个相关的问题。)你可以从 Realtek 下载源代码,编译并安装它,我就是这样做的。如果你modprobe r8168
,它加载正常但不与硬件关联,所以卡不会出现在ifconfig
.
我认为这与modalias
(编码硬件信息)和/lib/modules/*/modules.alias
.
claudius ~ # cat /sys/devices/pci0000\:00/0000\:00\:0e.0/0000\:02\:05.0/modalias
pci:v000010ECd00008169sv000010ECsd00008169bc02sc00i00
Run Code Online (Sandbox Code Playgroud)
这是我的卡。这是系统中的 Realtek 驱动程序映射:
claudius ~ # grep r816 /lib/modules/3.11.0-12-generic/modules.alias
alias pci:v00001186d00004300sv00001186sd00004C00bc*sc*i* r8169
alias pci:v000010ECd00008169sv*sd*bc*sc*i* r8169
alias pci:v000010ECd00008167sv*sd*bc*sc*i* r8169
alias pci:v00001186d00004300sv00001186sd00004B10bc*sc*i* r8168
alias pci:v000010ECd00008168sv*sd*bc*sc*i* r8168
Run Code Online (Sandbox Code Playgroud)
我尝试将此行添加到文件的末尾(知道您不应该进行手动编辑):
alias pci:v000010ECd00008169sv000010ECsd00008169bc02sc00i00 r8168
Run Code Online (Sandbox Code Playgroud)
然后卸载并重新加载,r8168
但这不会配置卡并且dmesg
.
将我的 NIC 映射到r8168
驱动程序的正确方法是什么?我是否必须重建驱动程序才能声称它可以处理我的卡?还是我必须在适当的位置添加一些配置数据?
您可以使用绑定强制设备使用某个设备。如果设备已由不同的驱动程序拥有,您首先必须取消绑定它。
如果 PCI 供应商 ID(10ec
对于 Realtek)和设备 ID 组合未被识别,您可以在运行时使用以下命令使其被识别:
# echo 10ec 8169 > /sys/bus/pci/drivers/r8169/new_id
Run Code Online (Sandbox Code Playgroud)
例子:
# lspci -s 04: -nnvvv
04:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL-8129 [10ec:8129] (rev 10)
Subsystem: Coreco Inc RTL8111/8168 PCIe Gigabit Ethernet (misconfigured) [11ec:8129]
Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Interrupt: pin A routed to IRQ 3
Region 0: I/O ports at c000 [size=256]
Region 1: Memory at f7b40000 (32-bit, non-prefetchable) [size=256]
[virtual] Expansion ROM at f7b00000 [disabled] [size=256K]
Capabilities: [dc] Power Management version 1
Flags: PMEClk- DSI- D1- D2- AuxCurrent=55mA PME(D0-,D1-,D2-,D3hot-,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Kernel driver in use: pci-stub
# echo 0000:04:00.0 > /sys/bus/pci/drivers/pci-stub/unbind
# echo 0000:04:00.0 > /sys/bus/pci/drivers/r8169/bind
# lspci -s 04: -nnvvv
04:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL-8129 [10ec:8129] (rev 10)
Subsystem: Coreco Inc RTL8111/8168 PCIe Gigabit Ethernet (misconfigured) [11ec:8129]
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV+ VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 32 (8000ns min, 8000ns max), Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 19
Region 0: I/O ports at c000 [size=256]
Region 1: Memory at f7b40000 (32-bit, non-prefetchable) [size=256]
[virtual] Expansion ROM at f7b00000 [disabled] [size=256K]
Capabilities: [dc] Power Management version 1
Flags: PMEClk- DSI- D1- D2- AuxCurrent=55mA PME(D0-,D1-,D2-,D3hot-,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Kernel driver in use: r8169
Run Code Online (Sandbox Code Playgroud)