Advertisement
leksmax

Untitled

Jan 28th, 2018
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.77 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # JNDR3710 vlan configuration
  4. #
  5. # WAN(ar P1) <=> ar P0 <=> esw P5 vid=2
  6. # LAN(ar P2,P3,P4,P5) <=> ar P6 <=> esw P4 vid=1
  7. #
  8. # peter_lu@sdc.sercomm.com
  9. #
  10. ETH_IF=eth2
  11. VID_LAN=1
  12. VID_WAN=2
  13. LAN_IF=${ETH_IF}.${VID_LAN}
  14. WAN_IF=${ETH_IF}.${VID_WAN}
  15. BR_IF=br0
  16.  
  17. netif_config()
  18. {
  19. ifconfig ${ETH_IF} up
  20.  
  21. vconfig add ${ETH_IF} ${VID_WAN}
  22. vconfig add ${ETH_IF} ${VID_LAN}
  23.  
  24. brctl addif ${BR_IF} ${LAN_IF}
  25. ifconfig ${LAN_IF} up
  26.  
  27. ifconfig eth2.2 down
  28. wan_mac=`nvram_get 2860 WAN_MAC_ADDR`
  29. if [ "$wan_mac" != "FF:FF:FF:FF:FF:FF" ]; then
  30. ifconfig eth2.2 hw ether $wan_mac
  31. fi
  32.  
  33. ifconfig ${WAN_IF} 0.0.0.0 up
  34. }
  35.  
  36. bridge_mode_test()
  37. {
  38. brctl addbr ${BR_IF}
  39.  
  40. brctl addif ${BR_IF} ${WAN_IF}
  41. brctl addif ${BR_IF} ${LAN_IF}
  42.  
  43. ifconfig ${BR_IF} up
  44. }
  45.  
  46. write_reg()
  47. {
  48. echo write.g $1 $2 $3 > /proc/sw_ar8327
  49. }
  50.  
  51. write_phy_reg()
  52. {
  53. echo write.p $1 $2 0x0 $3 > /proc/sw_ar8327
  54. }
  55.  
  56. ar8337_reset()
  57. {
  58. # reset switch
  59. #write_reg 0x0 0x0 0x8000
  60.  
  61. # reset phys
  62. write_phy_reg 0x0 0x0 0x9140
  63. write_phy_reg 0x1 0x0 0x9140
  64. write_phy_reg 0x2 0x0 0x9140
  65. write_phy_reg 0x3 0x0 0x9140
  66. write_phy_reg 0x4 0x0 0x9140
  67. }
  68.  
  69. ar8337_a0_workaround()
  70. {
  71. write_phy_reg 0x0 0x1d 0x3d
  72. write_phy_reg 0x0 0x1e 0x68a0
  73. write_phy_reg 0x1 0x1d 0x3d
  74. write_phy_reg 0x1 0x1e 0x68a0
  75. write_phy_reg 0x2 0x1d 0x3d
  76. write_phy_reg 0x2 0x1e 0x68a0
  77. write_phy_reg 0x3 0x1d 0x3d
  78. write_phy_reg 0x3 0x1e 0x68a0
  79. write_phy_reg 0x4 0x1d 0x3d
  80. write_phy_reg 0x4 0x1e 0x68a0
  81. }
  82.  
  83. ar8337_vlan_config()
  84. {
  85. echo "Configure AR8337 port base vlan"
  86.  
  87. write_reg 0x0660 0x0014 0x0202
  88. write_reg 0x066C 0x0014 0x0201
  89. write_reg 0x0678 0x0014 0x0278
  90. write_reg 0x0684 0x0014 0x0274
  91. write_reg 0x0690 0x0014 0x026C
  92. write_reg 0x069C 0x0014 0x025C
  93. write_reg 0x06A8 0x0014 0x023C
  94.  
  95. write_reg 0x0420 0x0002 0x0001
  96. write_reg 0x0428 0x0002 0x0001
  97. write_reg 0x0430 0x0001 0x0001
  98. write_reg 0x0438 0x0001 0x0001
  99. write_reg 0x0440 0x0001 0x0001
  100. write_reg 0x0448 0x0001 0x0001
  101. write_reg 0x0450 0x0001 0x0001
  102.  
  103. write_reg 0x0610 0x001A 0x55F0
  104. write_reg 0x0614 0x8001 0x0002
  105. write_reg 0x0610 0x001B 0xFF60
  106. write_reg 0x0614 0x8002 0x0002
  107.  
  108. write_reg 0x0424 0x0000 0x2040
  109. write_reg 0x042C 0x0000 0x1040
  110. write_reg 0x0434 0x0000 0x1040
  111. write_reg 0x043C 0x0000 0x1040
  112. write_reg 0x0444 0x0000 0x1040
  113. write_reg 0x044C 0x0000 0x1040
  114. write_reg 0x0454 0x0000 0x2040
  115.  
  116. write_reg 0x060c 0x8000 0x0001
  117. }
  118.  
  119. config6855Esw()
  120. {
  121. echo "Configure 6855 ESW port base vlan"
  122.  
  123. #LAN/WAN ports as security mode
  124. switch reg w 2404 ff0003 #port4
  125. switch reg w 2504 ff0003 #port5
  126. switch reg w 2604 ff0003 #port6
  127. switch reg w 2704 ff0003 #port7
  128.  
  129. #LAN/WAN ports as transparent port
  130. switch reg w 2410 810000c0 #port4
  131. switch reg w 2510 810000c0 #port5
  132. #set CPU/P7 port as user port
  133. switch reg w 2610 81000000 #port6
  134. switch reg w 2710 81000000 #port7
  135.  
  136. #set PVID
  137. switch reg w 2414 10001 #port4
  138. switch reg w 2514 10002 #port5
  139. #VLAN member port
  140. switch vlan set 0 1 00001011
  141. switch vlan set 1 2 00000111
  142.  
  143. #clear mac table if vlan configuration changed
  144. switch clear
  145. }
  146.  
  147. restore6855Esw()
  148. {
  149. echo "restore RT6855 ESW to dump switch mode"
  150. #port matrix mode
  151. switch reg w 2004 ff0000 #port0
  152. switch reg w 2104 ff0000 #port1
  153. switch reg w 2204 ff0000 #port2
  154. switch reg w 2304 ff0000 #port3
  155. switch reg w 2404 ff0000 #port4
  156. switch reg w 2504 ff0000 #port5
  157. switch reg w 2604 ff0000 #port6
  158. switch reg w 2704 ff0000 #port7
  159.  
  160. #LAN/WAN ports as transparent mode
  161. switch reg w 2010 810000c0 #port0
  162. switch reg w 2110 810000c0 #port1
  163. switch reg w 2210 810000c0 #port2
  164. switch reg w 2310 810000c0 #port3
  165. switch reg w 2410 810000c0 #port4
  166. switch reg w 2510 810000c0 #port5
  167. switch reg w 2610 810000c0 #port6
  168. switch reg w 2710 810000c0 #port7
  169.  
  170. #clear mac table if vlan configuration changed
  171. switch clear
  172. }
  173.  
  174. config_mdio_to_normal()
  175. {
  176. echo "Set MDIO to normal mode"
  177. reg s 0xb0000000
  178. reg w 0x60 0x181d
  179. }
  180.  
  181. ar8337_vlan_config
  182. # 8337 bug workaround
  183. ar8337_a0_workaround
  184.  
  185. config6855Esw
  186.  
  187. config_mdio_to_normal
  188.  
  189. #netif_config
  190.  
  191. #bridge_mode_test
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement