天天看點

ic+ ip175d 5port switch 驅動調試

方案: imx6ul+ip175d ;

産品功能:實作4網口路由器(1wan+3lan)和交換機(4Lan)功能;port5 rmii與cpu rmii相連接配接;

具體實作技術關鍵點:vlan/lan/wan/vconfig/udhcpc/udhcpd/iptables

開發過程:

1. phy驅動開發;

          配置phyid+phy addr(注意與實際硬體addr選擇腳一緻),phy reg(port0-port5)與IEEE 定義一樣;這個難度不大,在此不再展開;

2.vlan訂制;

Group 1:  port 1, port 5 , VID = 1

Group 2:  Port 2, 3, 4, port 5 , VID = 2

Port 1, 2, 3, 4 都是 untag ( Remove Tag)

Port 5 要 Add Tag.

● Register setting:

22.0=0x07FF (Tag based VLAN: Port0-5, PVID classification: Port0-4, VID classification: Port5)

22.5=0x0001 (Port1 PVID=1)

22.6=0x0002 (Port2 PVID=2)

22.7=0x0002 (Port3 PVID=2)

22.8=0x0002 (Port4 PVID=2)

22.10=0x0003 (Enable VLAN0 & VLAN1)

22.14=0x0001 (VLAN0 VID=1)

22.15=0x0002 (VLAN1 VID=2)

23.0=0x3C22 (VLAN0 member: Port1 & Port5, VLAN1 member: Port2-4 & Port5)

23.8=0x2020 (VLAN0 add tag: Port5, VLAN1 add tag: Port5)

23.16=0x1C02 (VLAN0 remove tag: Port1, VLAN1 remove tag: Port2-4)

3.基于802.1q(tag)vlan 網橋在系統層的配置:

vconfig add eth0 1

vconfig set_flag eth0.1 1 1

ifconfig eth0.1 up

#udhcpc -i eth0.1

4.路由轉發功能實作:

echo "1" > /proc/sys/net/ipv4/ip_forward

iptables -A FORWARD -d 192.168.3.1/24 -j ACCEPT

5. mac 轉發表及mac過濾的設定:

1.打開mac過濾功能及配置相應端口的mac白名單;

2.回讀mac;

3.删除mac;

繼續閱讀