关于DM8168平台扩展PCIE网卡的问题
/******************************************************************
* author: 卢浩
* time: 2013.05.21
* environment: ubuntu10.04LTS +TI DM8168
* kernel version: linux-2.6.37
* QQ Group For Technology Exchange:122879839
******************************************************************/
这是TI的DM8168的PCIE接口定义图,大家可以看到B10 B11没有接,一开始我用的RTL8111C的网卡,上电之后板子都起不来,后来给B10飞了一个3.3V供电,就OK了,但是这种情况在BCM5751 PCIE网卡上并没有。
B11是远程唤醒等,在这里用不上,所以不接也没问题。
还有就是TI本身是PCIE4X的插槽,我买的网卡模块是PCIE1X的。这个没问题的,兼容的,插上去可以直接用的。
此时上面的拨码开关SW5设置为off,此时为芯片内部复位。
在内核里面添加相关设备的驱动。
这里我添加了两个网卡的驱动,一个是RTL8111系列的,一个是BCM57系列的,至于下面的那个RTL8111F是我自己从官方网站下的,后来调试了一下,发现和内核自带的8169的驱动是通用的,所以大家就不必要去官方下载驱动了。
编译完内核下载到板子运行。
当linux系统启动完成之后,我们可以从内核打印的log看到,网卡已经正常初始化并加载成功
r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
PCI: enabling device 0000:01:00.0 (0140 -> 0142)
r8169 0000:01:00.0: eth0: RTL8168c/8111c at 0xd708a000, 00:e0:4c:a2:06:a1, XID 1c4000c0 IRQ 368
但是当我ping的时候,发现网卡竟然不通,后来在手册上看到这样一句话:
Since TI81XX RC supports maximum remote read request size (MRRQS) as 256 bytes, ensure that the EP driver/device you are using doesn't set read request size more than this value. If it does, then modify the driver to set read request size to 256 bytes before building it. Ensuring Maximum Read Request size within 256 Byte limit is required even for any intermediate Switch/Bridge devices in the fabric.
doesn't set read request size more than 256 bytes
驱动里面有一下几句
define MAX_READ_REQUEST_SHIFT12
这里我已经改掉了。本来是0X5向左偏移12位。就是101000000000000,结果事20480.我直接写了一个256,这样子强制小于等于256bytes。
编译内核下载运行
root@luhao:/luhao/5.05# ping 193.168.252.11 -I eth0
PING 193.168.252.11 (193.168.252.11): 56 data bytes
64 bytes from 193.168.252.11: seq=0 ttl=64 time=0.357 ms
64 bytes from 193.168.252.11: seq=1 ttl=64 time=0.290 ms
64 bytes from 193.168.252.11: seq=2 ttl=64 time=0.250 ms
64 bytes from 193.168.252.11: seq=3 ttl=64 time=0.312 ms
64 bytes from 193.168.252.11: seq=4 ttl=64 time=0.337 ms
64 bytes from 193.168.252.11: seq=5 ttl=64 time=0.262 ms
--- 193.168.252.11 ping statistics ---
6 packets transmitted, 6 packets received, 0% packet loss
round-trip min/avg/max = 0.250/0.301/0.357 ms
root@luhao:/luhao/5.05# ifconfig
eth0 Link encap:Ethernet HWaddr 00:E0:4C:A2:06:A1
inet addr:193.168.252.10 Bcast:193.168.252.255 Mask:255.255.255.0
inet6 addr: fe80::2e0:4cff:fea2:6a1/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:1139274 errors:0 dropped:1096065 overruns:0 frame:0
TX packets:79 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1462647402 (1.3 GiB) TX bytes:24126 (23.5 KiB)
Interrupt:112 Base address:0xa000
OK。在看一下lspci的信息
root@luhao:/luhao/5.05# lspci -v
00:00.0 Class 0604: Device 104c:b800 (rev 01)
Flags: bus master, fast devsel, latency 0
Memory at <ignored> (32-bit, non-prefetchable)
Memory at <ignored> (32-bit, prefetchable)
Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
Memory behind bridge: 20000000-200fffff
Prefetchable memory behind bridge: 20100000-201fffff
Capabilities: [40] Power Management version 3
Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
Capabilities: [70] Express Root Port (Slot-), MSI 00
Capabilities: [100] Advanced Error Reporting
01:00.0 Class 0200: Device 10ec:8168 (rev 02)
Subsystem: Device 10ec:8168
Flags: bus master, fast devsel, latency 0, IRQ 368
I/O ports at <unassigned> [disabled]
Memory at 20000000 (64-bit, non-prefetchable) [size=4K]
Memory at 20120000 (64-bit, prefetchable) [size=64K]
[virtual] Expansion ROM at 20100000 [disabled] [size=128K]
Capabilities: [40] Power Management version 3
Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
Capabilities: [70] Express Endpoint, MSI 01
Capabilities: [b0] MSI-X: Enable- Count=2 Masked-
Capabilities: [d0] Vital Product Data
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Virtual Channel <?>
Capabilities: [160] Device Serial Number a1-06-00-00-68-4c-e0-00
Kernel driver in use: r8169
在看一下PCIE网卡的当前属性
root@luhao:/luhao/5.05# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Link partner advertised pause frame use: No
Link partner advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: d
Current message level: 0x00000033 (51)
drv probe ifdown ifup
Link detected: yes
OK,收工。