Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # JNDR3710 vlan configuration
- #
- # WAN(ar P1) <=> ar P0 <=> esw P5 vid=2
- # LAN(ar P2,P3,P4,P5) <=> ar P6 <=> esw P4 vid=1
- #
- # peter_lu@sdc.sercomm.com
- #
- ETH_IF=eth2
- VID_LAN=1
- VID_WAN=2
- LAN_IF=${ETH_IF}.${VID_LAN}
- WAN_IF=${ETH_IF}.${VID_WAN}
- BR_IF=br0
- netif_config()
- {
- ifconfig ${ETH_IF} up
- vconfig add ${ETH_IF} ${VID_WAN}
- vconfig add ${ETH_IF} ${VID_LAN}
- brctl addif ${BR_IF} ${LAN_IF}
- ifconfig ${LAN_IF} up
- ifconfig eth2.2 down
- wan_mac=`nvram_get 2860 WAN_MAC_ADDR`
- if [ "$wan_mac" != "FF:FF:FF:FF:FF:FF" ]; then
- ifconfig eth2.2 hw ether $wan_mac
- fi
- ifconfig ${WAN_IF} 0.0.0.0 up
- }
- bridge_mode_test()
- {
- brctl addbr ${BR_IF}
- brctl addif ${BR_IF} ${WAN_IF}
- brctl addif ${BR_IF} ${LAN_IF}
- ifconfig ${BR_IF} up
- }
- write_reg()
- {
- echo write.g $1 $2 $3 > /proc/sw_ar8327
- }
- write_phy_reg()
- {
- echo write.p $1 $2 0x0 $3 > /proc/sw_ar8327
- }
- ar8337_reset()
- {
- # reset switch
- #write_reg 0x0 0x0 0x8000
- # reset phys
- write_phy_reg 0x0 0x0 0x9140
- write_phy_reg 0x1 0x0 0x9140
- write_phy_reg 0x2 0x0 0x9140
- write_phy_reg 0x3 0x0 0x9140
- write_phy_reg 0x4 0x0 0x9140
- }
- ar8337_a0_workaround()
- {
- write_phy_reg 0x0 0x1d 0x3d
- write_phy_reg 0x0 0x1e 0x68a0
- write_phy_reg 0x1 0x1d 0x3d
- write_phy_reg 0x1 0x1e 0x68a0
- write_phy_reg 0x2 0x1d 0x3d
- write_phy_reg 0x2 0x1e 0x68a0
- write_phy_reg 0x3 0x1d 0x3d
- write_phy_reg 0x3 0x1e 0x68a0
- write_phy_reg 0x4 0x1d 0x3d
- write_phy_reg 0x4 0x1e 0x68a0
- }
- ar8337_vlan_config()
- {
- echo "Configure AR8337 port base vlan"
- write_reg 0x0660 0x0014 0x0202
- write_reg 0x066C 0x0014 0x0201
- write_reg 0x0678 0x0014 0x0278
- write_reg 0x0684 0x0014 0x0274
- write_reg 0x0690 0x0014 0x026C
- write_reg 0x069C 0x0014 0x025C
- write_reg 0x06A8 0x0014 0x023C
- write_reg 0x0420 0x0002 0x0001
- write_reg 0x0428 0x0002 0x0001
- write_reg 0x0430 0x0001 0x0001
- write_reg 0x0438 0x0001 0x0001
- write_reg 0x0440 0x0001 0x0001
- write_reg 0x0448 0x0001 0x0001
- write_reg 0x0450 0x0001 0x0001
- write_reg 0x0610 0x001A 0x55F0
- write_reg 0x0614 0x8001 0x0002
- write_reg 0x0610 0x001B 0xFF60
- write_reg 0x0614 0x8002 0x0002
- write_reg 0x0424 0x0000 0x2040
- write_reg 0x042C 0x0000 0x1040
- write_reg 0x0434 0x0000 0x1040
- write_reg 0x043C 0x0000 0x1040
- write_reg 0x0444 0x0000 0x1040
- write_reg 0x044C 0x0000 0x1040
- write_reg 0x0454 0x0000 0x2040
- write_reg 0x060c 0x8000 0x0001
- }
- config6855Esw()
- {
- echo "Configure 6855 ESW port base vlan"
- #LAN/WAN ports as security mode
- switch reg w 2404 ff0003 #port4
- switch reg w 2504 ff0003 #port5
- switch reg w 2604 ff0003 #port6
- switch reg w 2704 ff0003 #port7
- #LAN/WAN ports as transparent port
- switch reg w 2410 810000c0 #port4
- switch reg w 2510 810000c0 #port5
- #set CPU/P7 port as user port
- switch reg w 2610 81000000 #port6
- switch reg w 2710 81000000 #port7
- #set PVID
- switch reg w 2414 10001 #port4
- switch reg w 2514 10002 #port5
- #VLAN member port
- switch vlan set 0 1 00001011
- switch vlan set 1 2 00000111
- #clear mac table if vlan configuration changed
- switch clear
- }
- restore6855Esw()
- {
- echo "restore RT6855 ESW to dump switch mode"
- #port matrix mode
- switch reg w 2004 ff0000 #port0
- switch reg w 2104 ff0000 #port1
- switch reg w 2204 ff0000 #port2
- switch reg w 2304 ff0000 #port3
- switch reg w 2404 ff0000 #port4
- switch reg w 2504 ff0000 #port5
- switch reg w 2604 ff0000 #port6
- switch reg w 2704 ff0000 #port7
- #LAN/WAN ports as transparent mode
- switch reg w 2010 810000c0 #port0
- switch reg w 2110 810000c0 #port1
- switch reg w 2210 810000c0 #port2
- switch reg w 2310 810000c0 #port3
- switch reg w 2410 810000c0 #port4
- switch reg w 2510 810000c0 #port5
- switch reg w 2610 810000c0 #port6
- switch reg w 2710 810000c0 #port7
- #clear mac table if vlan configuration changed
- switch clear
- }
- config_mdio_to_normal()
- {
- echo "Set MDIO to normal mode"
- reg s 0xb0000000
- reg w 0x60 0x181d
- }
- ar8337_vlan_config
- # 8337 bug workaround
- ar8337_a0_workaround
- config6855Esw
- config_mdio_to_normal
- #netif_config
- #bridge_mode_test
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement