[BPI-R64] OpenWRT and MT7531BE Switch

Does anybody know how to work with MT7531BE switch in the OpenWRT? The Kernel has a driver and it logs messages of switch working (List 1 – plugging/unplugging cable, List 2 – kernel loading).

@sinovoip, @rainfall83, could you explain what are openwrt packages have to be installed?

List 1

[  169.295088] mt753x gsw@0: Port 0 Link is Up - 100Mbps/Full
[  170.838622] mt753x gsw@0: Port 0 Link is Down
[  173.497715] mt753x gsw@0: Port 1 Link is Up - 100Mbps/Full
[  176.666734] mt753x gsw@0: Port 1 Link is Down
[  179.725273] mt753x gsw@0: Port 2 Link is Up - 100Mbps/Full
[  180.950672] mt753x gsw@0: Port 2 Link is Down
[  182.703661] mt753x gsw@0: Port 3 Link is Up - 100Mbps/Full
[  184.069169] mt753x gsw@0: Port 3 Link is Down
[  185.853478] mt753x gsw@0: Port 4 Link is Up - 100Mbps/Full
[  187.766002] mt753x gsw@0: Port 4 Link is Down
[  190.881768] mt753x gsw@0: Port 0 Link is Up - 100Mbps/Full

List 2

[    3.988773] mt753x gsw@0: LAN/WAN VLAN setting=wllll
[    3.994369] mt753x gsw@0: Switch is MediaTek MT7531BE rev 0
[    6.709694] mt753x gsw@0: >>>>>>>>>>>>>>>>>>>>>>>>>>>>> START CALIBRATION:
[    6.718802] mt753x gsw@0: -------- gephy-calbration (port:0) --------
[    6.742196] CALDLY = 40
[    7.091919]  GE Rext AnaCal Saturation!  
[    7.096136] GE Rxet cal something wrong2
[    7.390010]  GE R50 AnaCal Saturation!  
[    7.394139]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[    7.680008]  GE R50 AnaCal Saturation!  
[    7.684137]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[    7.970049]  GE R50 AnaCal Saturation!  
[    7.974178]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[    8.259989]  GE R50 AnaCal Saturation!  
[    8.264117]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[    8.274425]  GE 1e_174(0x8080), 1e_175(0x8080)  
[    8.346764]  GE Tx offset AnaCal Done! (pair-0)(3)(0x22) 0x1e_172=0x2220
[    8.394963]  GE Tx offset AnaCal Done! (pair-1)(3)(0x22) 0x1e_172=0x2222
[    8.443135]  GE Tx offset AnaCal Done! (pair-2)(3)(0x22) 0x1e_173=0x2220
[    8.499589]  GE Tx offset AnaCal Done! (pair-3)(4)(0x23) 0x1e_173=0x2223
[    8.619692]  GE Tx amp AnaCal Done! (pair-0)(1e_12 = 0x5014)
[    8.715098]  GE Tx amp AnaCal Done! (pair-1)(1e_17 = 0x1212)
[    8.806509]  GE Tx amp AnaCal Done! (pair-2)(1e_19 = 0x1b23)
[    8.928767]  GE Tx amp AnaCal Done! (pair-3)(1e_21 = 0xf17)
[    9.025385] PORT 0 RX_DC_OFFSET
[    9.045906] before pairA output = 1d
[    9.052775] after pairA output = ff
[    9.059466] before pairB output = 1e
[    9.066329] after pairB output = ff
[    9.073030] before pairC output = f
[    9.079779] after pairC output = 0
[    9.086382] before pairD output = f
[    9.093166] after pairD output = 1
[    9.097134] mt753x gsw@0: -------- gephy-calbration (port:1) --------
[    9.120541] CALDLY = 40
[    9.404889]  GE R50 AnaCal Saturation!  
[    9.409026]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[    9.694888]  GE R50 AnaCal Saturation!  
[    9.699026]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[    9.984870]  GE R50 AnaCal Saturation!  
[    9.989007]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[   10.274857]  GE R50 AnaCal Saturation!  
[   10.278993]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[   10.289290]  GE 1e_174(0x8080), 1e_175(0x8080)  
[   10.394655]  GE Tx offset AnaCal Done! (pair-0)(7)(0x26) 0x1e_172=0x2620
[   10.426311]  GE Tx offset AnaCal Done! (pair-1)(1)(0x1) 0x1e_172=0x2601
[   10.457876]  GE Tx offset AnaCal Done! (pair-2)(1)(0x1) 0x1e_173=0x120
[   10.489358]  GE Tx offset AnaCal Done! (pair-3)(1)(0x1) 0x1e_173=0x101
[   10.660690]  GE Tx amp AnaCal Done! (pair-0)(1e_12 = 0x4010)
[   10.766338]  GE Tx amp AnaCal Done! (pair-1)(1e_17 = 0x1212)
[   10.847468]  GE Tx amp AnaCal Done! (pair-2)(1e_19 = 0x1b23)
[   10.897748]  GE Tx amp AnaCal Done! (pair-3)(1e_21 = 0x1820)
[   10.994480] PORT 1 RX_DC_OFFSET
[   11.015016] before pairA output = f
[   11.021791] after pairA output = 1
[   11.028396] before pairB output = f
[   11.035176] after pairB output = 0
[   11.041784] before pairC output = 1e
[   11.048645] after pairC output = fe
[   11.055344] before pairD output = 1e
[   11.062213] after pairD output = 0
[   11.066182] mt753x gsw@0: -------- gephy-calbration (port:2) --------
[   11.089577] CALDLY = 40
[   11.373784]  GE R50 AnaCal Saturation!  
[   11.377914]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[   11.663751]  GE R50 AnaCal Saturation!  
[   11.667880]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[   11.953733]  GE R50 AnaCal Saturation!  
[   11.957862]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[   12.243778]  GE R50 AnaCal Saturation!  
[   12.247906]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[   12.258212]  GE 1e_174(0x8080), 1e_175(0x8080)  
[   12.330545]  GE Tx offset AnaCal Done! (pair-0)(3)(0x22) 0x1e_172=0x2220
[   12.395255]  GE Tx offset AnaCal Done! (pair-1)(5)(0x24) 0x1e_172=0x2224
[   12.426889]  GE Tx offset AnaCal Done! (pair-2)(1)(0x1) 0x1e_173=0x120
[   12.458374]  GE Tx offset AnaCal Done! (pair-3)(1)(0x1) 0x1e_173=0x101
[   12.578337]  GE Tx amp AnaCal Done! (pair-0)(1e_12 = 0x681a)
[   12.704593]  GE Tx amp AnaCal Done! (pair-1)(1e_17 = 0x1f1f)
[   12.785725]  GE Tx amp AnaCal Done! (pair-2)(1e_19 = 0x141c)
[   12.907980]  GE Tx amp AnaCal Done! (pair-3)(1e_21 = 0x1f27)
[   13.004738] PORT 2 RX_DC_OFFSET
[   13.025278] before pairA output = 1e
[   13.032150] after pairA output = ff
[   13.038847] before pairB output = e
[   13.045622] after pairB output = 1
[   13.052234] before pairC output = 1e
[   13.059099] after pairC output = ff
[   13.065792] before pairD output = f
[   13.072575] after pairD output = 0
[   13.076544] mt753x gsw@0: -------- gephy-calbration (port:3) --------
[   13.099941] CALDLY = 40
[   13.384266]  GE R50 AnaCal Saturation!  
[   13.388395]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[   13.674261]  GE R50 AnaCal Saturation!  
[   13.678389]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[   13.964260]  GE R50 AnaCal Saturation!  
[   13.968387]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[   14.254197]  GE R50 AnaCal Saturation!  
[   14.258326]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[   14.268634]  GE 1e_174(0x8080), 1e_175(0x8080)  
[   14.340928]  GE Tx offset AnaCal Done! (pair-0)(3)(0x3) 0x1e_172=0x320
[   14.372419]  GE Tx offset AnaCal Done! (pair-1)(1)(0x20) 0x1e_172=0x320
[   14.420498]  GE Tx offset AnaCal Done! (pair-2)(3)(0x22) 0x1e_173=0x2220
[   14.452155]  GE Tx offset AnaCal Done! (pair-3)(1)(0x1) 0x1e_173=0x2201
[   14.644125]  GE Tx amp AnaCal Done! (pair-0)(1e_12 = 0x3c0f)
[   14.749830]  GE Tx amp AnaCal Done! (pair-1)(1e_17 = 0x1212)
[   14.810391]  GE Tx amp AnaCal Done! (pair-2)(1e_19 = 0x161e)
[   14.901708]  GE Tx amp AnaCal Done! (pair-3)(1e_21 = 0x1d25)
[   14.998400] PORT 3 RX_DC_OFFSET
[   15.018904] before pairA output = d
[   15.025676] after pairA output = 0
[   15.032287] before pairB output = f
[   15.039068] after pairB output = ff
[   15.045759] before pairC output = f
[   15.052540] after pairC output = 0
[   15.059144] before pairD output = 1e
[   15.066008] after pairD output = ff
[   15.070074] mt753x gsw@0: -------- gephy-calbration (port:4) --------
[   15.093460] CALDLY = 40
[   15.377648]  GE R50 AnaCal Saturation!  
[   15.381787]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[   15.667726]  GE R50 AnaCal Saturation!  
[   15.671863]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[   15.957667]  GE R50 AnaCal Saturation!  
[   15.961806]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[   16.247639]  GE R50 AnaCal Saturation!  
[   16.251776]  GE R50 AnaCal Done! (32) (0x0)(0x80) 
[   16.262055]  GE 1e_174(0x8080), 1e_175(0x8080)  
[   16.342611]  GE Tx offset AnaCal Done! (pair-0)(4)(0x4) 0x1e_172=0x420
[   16.398842]  GE Tx offset AnaCal Done! (pair-1)(4)(0x23) 0x1e_172=0x423
[   16.446920]  GE Tx offset AnaCal Done! (pair-2)(3)(0x22) 0x1e_173=0x2220
[   16.503367]  GE Tx offset AnaCal Done! (pair-3)(4)(0x23) 0x1e_173=0x2223
[   16.644024]  GE Tx amp AnaCal Done! (pair-0)(1e_12 = 0x5014)
[   16.770267]  GE Tx amp AnaCal Done! (pair-1)(1e_17 = 0xf0f)
[   16.953970]  GE Tx amp AnaCal Done! (pair-2)(1e_19 = 0xa12)
[   17.086367]  GE Tx amp AnaCal Done! (pair-3)(1e_21 = 0xf17)
[   17.182980] PORT 4 RX_DC_OFFSET
[   17.203506] before pairA output = e
[   17.210279] after pairA output = 1
[   17.216883] before pairB output = 1e
[   17.223754] after pairB output = ff
[   17.230449] before pairC output = 1e
[   17.237308] after pairC output = fe
[   17.244012] before pairD output = f
[   17.250788] after pairD output = 1

Have you any Problems with it in openwrt?

I using same drive in my repo and have some issues getting sgmii-link (for lan-ports) up (in 5.4) when booting kernel from sdcard…tftp works

I can’t say if there are any problems or not. I do not know how to work with the switch inside OpenWRT yet. Other words I don’t know how to get interfaces of each physical port of board inside OS. I see only eth0 and eth1.

right, there is no dsa-driver…eth1 is wan-port,eth0 for all 4 lan-ports (like lan-ports are bridged together)

File “emmc_singleimage.img” (eMMC all-in-one single image) with OpenWRT (LEDE 17.01) has a tool named “switch”. This image from @rainfall83 's post, here: Bpi-r64 quick start (boot from eMMC)) . It can configure MT7531BE switch. Doesn’t it use the driver what you mean?

root@LEDE:/# switch devs
register switch dev:
id: 0, model: MT7531BE, node: gsw
root@LEDE:/# 
root@LEDE:/# switch vlan dump
  vid  fid  portmap    s-tag
    1    0  -1111-1-       0
    2    0  1----1--       0
    3    0  invalid
    4    0  invalid
    5    0  invalid
    6    0  invalid
    7    0  invalid
    8    0  invalid
    9    0  invalid
   10    0  invalid
   11    0  invalid
   12    0  invalid
   13    0  invalid
   14    0  invalid
   15    0  invalid
   16    0  invalid



root@LEDE:/# switch
==================Usage===============================================================================================================================
1) mt753x switch Basic operations=================================================================================================================>>>>
 1.1) switch devs							- list switch device id and model name  
 1.2) switch sysctl							- show the ways to access kenerl driver: netlink or ioctl 
 1.3) switch reset							- sw reset switch fsm and registers
 1.4) switch reg r [offset]						- read the reg with default switch 
 1.5) switch reg w [offset] [value]					- write the reg with default switch 
 1.6) switch reg d [offset]						- dump the reg with default switch
 1.7) switch dev [devid] reg r [addr]				- read the reg with the switch devid  
 1.8) switch dev [devid] reg w [addr] [value] 			- write the regs with the switch devid 
 1.9) switch dev [devid] reg d [addr]				- dump the regs with the switch devid 
																			
2) mt753x switch PHY operations===================================================================================================================>>>>
 2.1) switch phy							- dump all phy registers (clause 22)
 2.2) switch phy [phy_addr]						- dump phy register of specific port (clause 22)
 2.3) switch phy cl22 r [port_num] [phy_reg]			- read specific phy register of specific port by clause 22
 2.4) switch phy cl22 w [port_num] [phy_reg] [value]		- write specific phy register of specific port by clause 22
 2.5) switch phy cl45 r [port_num] [dev_num] [phy_reg]		- read specific phy register of specific port by clause 45
 2.6) switch phy cl45 w [port_num] [dev_num] [phy_reg] [value]	- write specific phy register of specific port by clause 45
 2.7) switch phy fc [port_num] [enable 0|1]				- set switch phy flow control, port is 0~4, enable is 1, disable is 0 
 2.8) switch phy an [port_num] [enable 0|1]				- set switch phy auto-negotiation, port is 0~4, enable is 1, disable is 0 
 2.9) switch trreg r [port_num] [ch_addr] [node_addr] [data_addr]	- read phy token-ring of specific port
 2.10) switch trreg w [port_num] [ch_addr] [node_addr] [data_addr]	- write phy token-ring of specific port
		[high_value] [low_value]									
 2.11) switch crossover [port_num] [mode auto|mdi|mdix]		- switch auto or force mdi/mdix mode for crossover cable
																			
3) mt753x switch MAC operations====================================================================================================================>>>>
 3.1) switch dump							- dump switch mac table
 3.2) switch clear							- clear switch mac table
 3.3) switch add [mac] [portmap]					- add an entry (with portmap) to switch mac table
 3.4) switch add [mac] [portmap] [vlan id]				- add an entry (with portmap, vlan id) to switch mac table
 3.5) switch add [mac] [portmap] [vlan id] [age]			- add an entry (with portmap, vlan id, age out time) to switch mac table
 3.6) switch del mac [mac] vid [vid]				- delete an entry from switch mac table
 3.7) switch del mac [mac] fid [fid]				- delete an entry from switch mac table
 3.8) switch search mac [mac] vid [vid]				- search an entry with specific mac and vid
 3.9) switch search mac [mac] fid [fid]				- search an entry with specific mac and fid
 3.10) switch filt [mac]						- add a SA filtering entry (with portmap 1111111) to switch mac table
 3.11) switch filt [mac] [portmap]					- add a SA filtering entry (with portmap)to switch mac table
 3.12) switch filt [mac] [portmap] [vlan id				- add a SA filtering entry (with portmap, vlan id)to switch mac table
 3.13) switch filt [mac] [portmap] [vlan id] [age]			- add a SA filtering entry (with portmap, vlan id, age out time) to switch table
 3.14) switch arl aging [active:0|1] [time:1~65536]			- set switch arl aging timeout value 
 3.15) switch macctl fc [enable|disable]				- set switch mac global flow control,enable is 1, disable is 0 
																			
4) mt753x switch mib counter operations============================================================================================================>>>>
 4.1) switch esw_cnt get						-get switch mib counters          
 4.2) switch esw_cnt clear						-clear switch mib counters         
 4.3) switch output_queue_cnt get					-get switch output queue counters 
 4.4) switch free_page get						-get switch system free page counters  
																			
5) mt753x switch acl function operations============================================================================================================>>>>
 5.1) switch acl enable [port] [port_enable:0|1]			- set switch acl function enabled, port is 0~6,enable is 1, disable is 0  
 5.2) switch acl etype add [ethtype] [portmap]			- drop L2 ethertype packets 
 5.3) switch acl dmac add [mac] [portmap]				- drop L2 dest-Mac packets 
 5.4) switch acl dip add [dip] [portmap]				- drop dip packets 
 5.5) switch acl port add [sport] [portmap]				- drop L4 UDP/TCP source port packets
 5.6) switch acl L4 add [2byes] [portmap]				- drop L4 packets with 2bytes payload
 5.7) switch acl acltbl-add  [tbl_idx:0~63/255] [vawd1] [vawd2]	- set switch acl table new entry, max index-7530:63,7531:255 
 5.8) switch acl masktbl-add [tbl_idx:0~31/127] [vawd1] [vawd2]	- set switch acl mask table new entry, max index-7530:31,7531:127   
 5.9) switch acl ruletbl-add [tbl_idx:0~31/127] [vawd1] [vawd2]	- set switch acl rule table new entry, max index-7530:31,7531:127  
 5.10) switch acl ratetbl-add [tbl_idx:0~31] [vawd1] [vawd2] 	- set switch acl rate table new entry  
 5.11) switch acl dip meter [dip] [portmap][meter:kbps]		- rate limit dip packets 
 5.12) switch acl dip trtcm [dip] [portmap][CIR:kbps][CBS][PIR][PBS]- TrTCM dip packets 
 5.13) switch acl dip modup [dip] [portmap][usr_pri]		- modify usr priority from ACL 
 5.14) switch acl dip pppoe [dip] [portmap]				- pppoe header removal 
																			
6) mt753x switch dip table operations=================================================================================================================>>>>
 6.1) switch dip dump						- dump switch dip table
 6.2) switch dip clear						- clear switch dip table
 6.3) switch dip add [dip] [portmap]				- add a dip entry to switch table
 6.4) switch dip del [dip]						- del a dip entry to switch table
																			
7) mt753x switch sip table operations=================================================================================================================>>>>
 7.1) switch sip dump						- dump switch sip table
 7.2) switch sip clear						- clear switch sip table
 7.3) switch sip add [sip] [dip] [portmap]				- add a sip entry to switch table
 7.4) switch sip del [sip] [dip]					- del a sip entry to switch table
																			
8) mt753x switch sip table operations====================================================================================================================>>>>
 8.1) switch vlan dump						- dump switch vlan table
 8.2) switch vlan set [vlan idx] [vid] [portmap]			- set vlan id and associated member at switch vlan table
 8.3) switch vlan vid [vlan idx] [active:0|1] [vid] [portMap] 	- set switch vlan vid elements  
			[egtagPortMap] [ivl_en] [fid] [stag]							 
 8.4) switch vlan pvid [port] [pvid]				- set switch vlan pvid  
 8.5) switch vlan acc-frm [port] [acceptable_frame_type:0~3]	- set switch vlan acceptable_frame type : admit all frames: 0, 
									admit only vlan-taged frames: 1,admit only untagged or priority-tagged frames: 2, reserved:3 
 8.6) switch vlan port-attr [port] [attr:0~3]			- set switch vlan port attribute: user port: 0, statck port: 1, 
									translation port: 2, transparent port:3        
 8.7) switch vlan port-mode [port] [mode:0~3]			- set switch vlan port mode : port matrix mode: 0, fallback mode: 1,  
									check mode: 2, security mode:3                    
 8.8) switch vlan eg-tag-pvc [port] [eg_tag:0~7]			- set switch vlan eg tag pvc : disable: 0, consistent: 1, reserved: 2, 
									reserved:3,untagged:4,swap:5,tagged:6, stack:7                 
 8.9) switch vlan eg-tag-pcr [port] [eg_tag:0~3]			- set switch vlan eg tag pcr : untagged: 0, swap: 1, tagged: 2, stack:3 
																			
9) mt753x switch rate limit operations=================================================================================================================>>>>
 9.1) switch ratectl [in_ex_gress:0|1] [port] [rate]		- set switch port ingress(1) or egress(0) rate  
 9.2) switch ingress-rate on [port] [Kbps]				- set ingress rate limit on port n (n= 0~ switch max port) 
 9.3) switch egress-rate on [port] [Kbps]				- set egress rate limit on port n (n= 0~ switch max port) 
 9.4) switch ingress-rate off [port]				- disable ingress rate limit on port n (n= 0~ switch max port) 
 9.5) switch egress-rate off [port]					- disable egress rate limit on port n (n= 0~ switch max port)
																			
10) mt753x igmp operations===============================================================================================================================>>>>
 10.1) switch igmpsnoop on [leaky_en] [wan_num]			- turn on IGMP snoop and router port learning
									leaky_en: 1 or 0. default 0; wan_num: 0 or 4. default 4
 10.2) switch igmpsnoop off						- turn off IGMP snoop and router port learning
 10.3) switch igmpsnoop enable [port#]				- enable IGMP HW leave/join/Squery/Gquery
 10.4) switch igmpsnoop disable [port#]				- disable IGMP HW leave/join/Squery/Gquery
																			
11) mt753x QoS operations================================================================================================================================>>>>
 11.1) switch qos sch [port:0~6] [queue:0~7] [shaper:min|max] [type:rr:0|sp:1|wfq:2]     - set switch qos sch type
 11.2) switch qos base [port:0~6] [base]					- set switch qos base(UPW); port-based:0, tag-based:1, 
									dscp-based:2, acl-based:3, arl-based:4, stag-based:5   
 11.3) switch qos port-weight [port:0~6] [q0] [q1][q2][q3]		- set switch qos port queue weight; 
				[q4][q5][q6][q7]				 [qn]: the weight of queue n, range: 1~16     
 11.4) switch qos port-prio [port:0~6] [prio:0~7]			- set switch port qos user priority;  port is 0~6, priority is 0~7  
 11.5) switch qos dscp-prio [dscp:0~63] [prio:0~7]			- set switch qos dscp user priority;  dscp is 0~63, priority is 0~7  
 11.6) switch qos prio-qmap [port:0~6] [prio:0~7]  [queue:0~7]			- set switch qos priority queue map; priority is 0~7,queue is 0~7  
																			
 12) mt753x port mirror operations========================================================================================================================>>>>
 12.1) switch mirror monitor [port]					- enable port mirror and indicate monitor port number
 12.2) switch mirror target  [port]					- set port mirror target
			[direction| 0:off, 1:rx, 2:tx, 3:all]					
 12.3) switch mirror enable [mirror_en:0|1] [mirror_port: 0-6]	- set switch mirror function enable(1) or disabled(0) for port 0~6  
 12.4) switch mirror port-based [port] [port_tx_mir:0|1]		- set switch mirror port: target tx/rx/acl/vlan/igmp
				[port_rx_mir:0|1] [acl_mir:0|1]						
				[vlan_mis:0|1] [igmp_mir:0|1]						
																			
 13) mt753x stp operations===============================================================================================================================>>>>
 13.1) switch stp [port] [fid] [state]				- set switch spanning tree state, port is 0~6, fid is 0~7,  
									state is 0~3(Disable/Discarding:0,Blocking/Listening/Discarding:1,) 
									Learning:2,Forwarding:3 
																			
14) mt753x collision pool operations========================================================================================================================>>>>
 14.1) switch collision-pool enable [enable 0|1]			- enable or disable collision pool
 14.2) switch collision-pool mac dump				- dump collision pool mac table
 14.3) switch collision-pool dip dump				- dump collision pool dip table
 14.4) switch collision-pool sip dump				- dump collision pool sip table
																			
15) mt753x pfc(priority flow control) operations==============================================================================================================>>>>
 15.1) switch pfc enable [port] [enable 0|1]			- enable or disable port's pfc 
 15.2) switch pfc rx_counter [port]					- get port n pfc 8 up rx counter 
 15.3) switch pfc tx_counter [port]					- get port n pfc 8 up rx counter

it use the same driver only with swconfig-patch (which i don’t use because the swconfig application does only exist in openwrt)

this application can be used to set vlans on the switch (default only pvid which are internally dropped to only separate lan and wan to each gmac) to separate ports.

just give eth0 ip address you want to use for lan and configure eth1 for wan-port (e.g. dhcp) for a first test

Ok, got it. I’ll try to start with eth0/1. But where I can get sources of OpenWRT’s “switch” and “swconfig” for MT7531BE? If there is an OpenWRT image contained it mean there is an sources for OpenWRT.

Swconfig is part of openwrt,you can try compile 4.19 kernel with mt7531 from main repository

Swconfig source is here,but you need mt7531 driver compiled with swconfig-option

Example why you need to compile kernel with ethernet-driver and swconfig-option:

I have not yet figured out how to compile swconfig outside of openwrt (to use with my kernels)

Btw. This i my thread regarding it: Compile swconfig for r64

@frank-w, I built the img including swconfig from the main openwrt rep, but unsuccessful – “swconfig list” does not show me a switch. May be I miss somewhat in “make menuconfig”?

[  619.913583] mt753x gsw@0: Port 0 Link is Down
[  623.824121] mt753x gsw@0: Port 0 Link is Up - 100Mbps/Full
root@OpenWrt:/# swconfig
swconfig list
swconfig dev <dev> [port <port>|vlan <vlan>] (help|set <key> <value>|get <key>|load <config>|show)
root@OpenWrt:/# swconfig list
root@OpenWrt:/#

Maybe you have to propagate mt7531 to swconfig…i don’t know how swconfig gets switch data but it needs any api to communicate with switch

Maybe you could add a prink here: https://github.com/frank-w/BPI-R2-4.14/blob/8d8e1d48e8f31ee6631fccc300a6ee2fb6694c6a/drivers/net/phy/mtk/mt753x/mt753x_swconfig.c#L495

Just to see if registerswitch is called…

@frank-w, files “mt753x_swconfig.c” are the same in both repo. The difference between mtk dirs of your repo and openwrt are in two files:

diff -u -r target/linux/mediatek/files-4.19/drivers/net/phy/mtk/mt753x/mt753x_mdio.c ../BPI-R2-4.14/drivers/net/phy/mtk/mt753x/mt753x_mdio.c
--- target/linux/mediatek/files-4.19/drivers/net/phy/mtk/mt753x/mt753x_mdio.c	2019-10-24 14:51:51.996998082 +0300
+++ ../BPI-R2-4.14/drivers/net/phy/mtk/mt753x/mt753x_mdio.c	2019-10-23 13:42:03.712666539 +0300
@@ -23,6 +23,7 @@
 #include "mt753x_swconfig.h"
 #include "mt753x_regs.h"
 #include "mt753x_nl.h"
+#include "mt753x_vlan.h"
 #include "mt7530.h"
 #include "mt7531.h"
 
@@ -519,7 +520,8 @@
 
 	mt753x_add_gsw(gsw);
 
-	mt753x_swconfig_init(gsw);
+	//mt753x_swconfig_init(gsw);
+	mt753x_apply_vlan_config(gsw);
 
 	if (sw->post_init)
 		sw->post_init(gsw);
diff -u -r target/linux/mediatek/files-4.19/drivers/net/phy/mtk/mt753x/mt753x_nl.c ../BPI-R2-4.14/drivers/net/phy/mtk/mt753x/mt753x_nl.c
--- target/linux/mediatek/files-4.19/drivers/net/phy/mtk/mt753x/mt753x_nl.c	2019-10-24 14:51:51.996998082 +0300
+++ ../BPI-R2-4.14/drivers/net/phy/mtk/mt753x/mt753x_nl.c	2019-10-23 13:42:03.712666539 +0300
@@ -37,17 +37,14 @@
 	{
 		.cmd = MT753X_CMD_REQUEST,
 		.doit = mt753x_nl_response,
-		.policy = mt753x_nl_cmd_policy,
 		.flags = GENL_ADMIN_PERM,
 	}, {
 		.cmd = MT753X_CMD_READ,
 		.doit = mt753x_nl_response,
-		.policy = mt753x_nl_cmd_policy,
 		.flags = GENL_ADMIN_PERM,
 	}, {
 		.cmd = MT753X_CMD_WRITE,
 		.doit = mt753x_nl_response,
-		.policy = mt753x_nl_cmd_policy,
 		.flags = GENL_ADMIN_PERM,
 	},
 };
@@ -58,6 +55,7 @@
 	.maxattr =	MT753X_NR_ATTR_TYPE,
 	.ops =		mt753x_nl_ops,
 	.n_ops =	ARRAY_SIZE(mt753x_nl_ops),
+	.policy = mt753x_nl_cmd_policy,
 };
 
 static int mt753x_nl_list_devs(char *buff, int size)

That are my changes. First one was test (and should be reverted) because i thought mt753x_apply_vlan_config was not called without swconfig. This is needed for port-separation. before i’ve updated driver all ports were connected to both gmacs…

second is adaption to 5.4 where netlink policy is moved to family

If I understood you correctly I did this:

    swdev->ops = &mt753x_swdev_ops;

    printk("-----======###### Mark 1 #####=====-----")
    ret = register_switch(swdev, NULL);
    printk("-----======###### Mark 2 #####=====-----")
    if (ret) {

But these marks did not appear at the log…

yes looks right

And you have compiled with CONFIG_SWCONFIG?

these lines should appear because with swconfig-option set mt753x_swconfig_init is only defined in line 14 and used from mt753x_swconfig.c

Yes this was a reason swconf did not work correctly! @frank-w, thx! It’s a litle bit strange for me the switching on swconf and kmod-swconfig via “make menuconf” does not switch on SWCONFIG (Switch configuration API) for Kernel… I had to do it via “make kernel_menuconfig”.

That can be changed in Kconfig that swconf also selects SWCONFIG but maybe this should not be done by some reason

Can you post output of swconfig?

Here:

root@OpenWrt:/# swconfig list
Found: switch0 - MT7531BE
root@OpenWrt:/# 
root@OpenWrt:/# swconfig dev switch0 show
Global attributes:
	enable_vlan: 1
Port 0:
	mib: Port 0 MIB counters
TxDrop     : 0
TxCRC      : 0
TxUni      : 865758
TxMulti    : 23
TxBroad    : 6
TxCollision: 0
TxSingleCol: 0
TxMultiCol : 0
TxDefer    : 0
TxLateCol  : 0
TxExcCol   : 0
TxPause    : 0
Tx64Byte   : 21
Tx65Byte   : 54158
Tx128Byte  : 16
Tx256Byte  : 7
Tx512Byte  : 0
Tx1024Byte : 811585
TxByte     : 1235785479
RxDrop     : 0
RxFiltered : 0
RxUni      : 1221231
RxMulti    : 8
RxBroad    : 3
RxAlignErr : 0
RxCRC      : 0
RxUnderSize: 0
RxFragment : 0
RxOverSize : 0
RxJabber   : 0
RxPause    : 0
Rx64Byte   : 116
Rx65Byte   : 411649
Rx128Byte  : 8
Rx256Byte  : 7
Rx512Byte  : 0
Rx1024Byte : 809462
RxByte     : 1257877688
RxCtrlDrop : 0
RxIngDrop  : 0
RxARLDrop  : 0

	pvid: 2
	link: port:0 link:down
Port 1:
	mib: Port 1 MIB counters
TxDrop     : 0
TxCRC      : 0
TxUni      : 865074
TxMulti    : 7
TxBroad    : 3
TxCollision: 0
TxSingleCol: 0
TxMultiCol : 0
TxDefer    : 0
TxLateCol  : 0
TxExcCol   : 0
TxPause    : 0
Tx64Byte   : 12
Tx65Byte   : 54203
Tx128Byte  : 6
Tx256Byte  : 5
Tx512Byte  : 0
Tx1024Byte : 810858
TxByte     : 1234681167
RxDrop     : 0
RxFiltered : 0
RxUni      : 1216940
RxMulti    : 8
RxBroad    : 3
RxAlignErr : 0
RxCRC      : 0
RxUnderSize: 0
RxFragment : 0
RxOverSize : 0
RxJabber   : 0
RxPause    : 0
Rx64Byte   : 103
Rx65Byte   : 406839
Rx128Byte  : 0
Rx256Byte  : 5
Rx512Byte  : 1
Rx1024Byte : 810003
RxByte     : 1258355749
RxCtrlDrop : 0
RxIngDrop  : 0
RxARLDrop  : 0

	pvid: 1
	link: port:1 link:up speed:1000baseT full-duplex 
Port 2:
	mib: Port 2 MIB counters
TxDrop     : 0
TxCRC      : 0
TxUni      : 0
TxMulti    : 0
TxBroad    : 0
TxCollision: 0
TxSingleCol: 0
TxMultiCol : 0
TxDefer    : 0
TxLateCol  : 0
TxExcCol   : 0
TxPause    : 0
Tx64Byte   : 0
Tx65Byte   : 0
Tx128Byte  : 0
Tx256Byte  : 0
Tx512Byte  : 0
Tx1024Byte : 0
TxByte     : 0
RxDrop     : 0
RxFiltered : 0
RxUni      : 0
RxMulti    : 0
RxBroad    : 0
RxAlignErr : 0
RxCRC      : 0
RxUnderSize: 0
RxFragment : 0
RxOverSize : 0
RxJabber   : 0
RxPause    : 0
Rx64Byte   : 0
Rx65Byte   : 0
Rx128Byte  : 0
Rx256Byte  : 0
Rx512Byte  : 0
Rx1024Byte : 0
RxByte     : 0
RxCtrlDrop : 0
RxIngDrop  : 0
RxARLDrop  : 0

	pvid: 1
	link: port:2 link:down
Port 3:
	mib: Port 3 MIB counters
TxDrop     : 0
TxCRC      : 0
TxUni      : 0
TxMulti    : 0
TxBroad    : 0
TxCollision: 0
TxSingleCol: 0
TxMultiCol : 0
TxDefer    : 0
TxLateCol  : 0
TxExcCol   : 0
TxPause    : 0
Tx64Byte   : 0
Tx65Byte   : 0
Tx128Byte  : 0
Tx256Byte  : 0
Tx512Byte  : 0
Tx1024Byte : 0
TxByte     : 0
RxDrop     : 0
RxFiltered : 0
RxUni      : 0
RxMulti    : 0
RxBroad    : 0
RxAlignErr : 0
RxCRC      : 0
RxUnderSize: 0
RxFragment : 0
RxOverSize : 0
RxJabber   : 0
RxPause    : 0
Rx64Byte   : 0
Rx65Byte   : 0
Rx128Byte  : 0
Rx256Byte  : 0
Rx512Byte  : 0
Rx1024Byte : 0
RxByte     : 0
RxCtrlDrop : 0
RxIngDrop  : 0
RxARLDrop  : 0

	pvid: 1
	link: port:3 link:down
Port 4:
	mib: Port 4 MIB counters
TxDrop     : 0
TxCRC      : 0
TxUni      : 0
TxMulti    : 0
TxBroad    : 0
TxCollision: 0
TxSingleCol: 0
TxMultiCol : 0
TxDefer    : 0
TxLateCol  : 0
TxExcCol   : 0
TxPause    : 0
Tx64Byte   : 0
Tx65Byte   : 0
Tx128Byte  : 0
Tx256Byte  : 0
Tx512Byte  : 0
Tx1024Byte : 0
TxByte     : 0
RxDrop     : 0
RxFiltered : 0
RxUni      : 0
RxMulti    : 0
RxBroad    : 0
RxAlignErr : 0
RxCRC      : 0
RxUnderSize: 0
RxFragment : 0
RxOverSize : 0
RxJabber   : 0
RxPause    : 0
Rx64Byte   : 0
Rx65Byte   : 0
Rx128Byte  : 0
Rx256Byte  : 0
Rx512Byte  : 0
Rx1024Byte : 0
RxByte     : 0
RxCtrlDrop : 0
RxIngDrop  : 0
RxARLDrop  : 0

	pvid: 1
	link: port:4 link:down
Port 5:
	mib: Port 5 MIB counters
TxDrop     : 0
TxCRC      : 0
TxUni      : 1221231
TxMulti    : 8
TxBroad    : 3
TxCollision: 0
TxSingleCol: 0
TxMultiCol : 0
TxDefer    : 0
TxLateCol  : 0
TxExcCol   : 0
TxPause    : 0
Tx64Byte   : 116
Tx65Byte   : 411649
Tx128Byte  : 8
Tx256Byte  : 7
Tx512Byte  : 0
Tx1024Byte : 809462
TxByte     : 1257877688
RxDrop     : 0
RxFiltered : 0
RxUni      : 865758
RxMulti    : 23
RxBroad    : 6
RxAlignErr : 0
RxCRC      : 0
RxUnderSize: 0
RxFragment : 0
RxOverSize : 0
RxJabber   : 0
RxPause    : 0
Rx64Byte   : 21
Rx65Byte   : 54158
Rx128Byte  : 16
Rx256Byte  : 7
Rx512Byte  : 0
Rx1024Byte : 811585
RxByte     : 1235785479
RxCtrlDrop : 0
RxIngDrop  : 0
RxARLDrop  : 0

	pvid: 2
	link: port:5 link:up speed:1000baseT full-duplex 
Port 6:
	mib: Port 6 MIB counters
TxDrop     : 0
TxCRC      : 0
TxUni      : 1216940
TxMulti    : 8
TxBroad    : 3
TxCollision: 0
TxSingleCol: 0
TxMultiCol : 0
TxDefer    : 0
TxLateCol  : 0
TxExcCol   : 0
TxPause    : 1060
Tx64Byte   : 1163
Tx65Byte   : 406839
Tx128Byte  : 0
Tx256Byte  : 5
Tx512Byte  : 1
Tx1024Byte : 810003
TxByte     : 1258423589
RxDrop     : 0
RxFiltered : 24
RxUni      : 865074
RxMulti    : 30
RxBroad    : 4
RxAlignErr : 0
RxCRC      : 0
RxUnderSize: 0
RxFragment : 0
RxOverSize : 0
RxJabber   : 0
RxPause    : 0
Rx64Byte   : 12
Rx65Byte   : 54215
Rx128Byte  : 17
Rx256Byte  : 6
Rx512Byte  : 0
Rx1024Byte : 810858
RxByte     : 1234684535
RxCtrlDrop : 0
RxIngDrop  : 0
RxARLDrop  : 0

	pvid: 1
	link: port:6 link:up speed:1000baseT full-duplex 
VLAN 1:
	vid: 1
	ports: 1 2 3 4 6 
VLAN 2:
	vid: 2
	ports: 0 5 
root@OpenWrt:/#
1 Like