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:/#
7531 upstream driver : Patchwork/Mailinglist there was a DSA-driver for mt7531 released :
https://patchwork.kernel.org/project/linux-mediatek/list/?submitter=189635
@Ivan_Revyakin @frank-w, Thanks, that provide a way to query the switch port link state for me.
But Is there a way to get notify when the switch port cable removed? I have try the ifplugd, failed, ifplugd can’t get notify when the switch port cable removed.
@sinovoip, If use the DSA-driver, can i query the switch port state from /sys/bus/mdio_bus?
I guess you should can use ethtool or ip link to get status of interface…i don’t know how to use ifplugd or similar. Does it not work with dsa-driver? I’m guess it can not work with openwrts phy-driver
I currently use the openwrt master source code, it not included the DSA-driver patch, and can’t use ethtool, ip link, ifstatus, /sys/class/net/eth1/operstate, /sys/class/net/eth1/carrier to get the correctly switch port link state.
If apply the DSA-driver patch, the ethtool can get the correctly switch port link state?
It seems @Ivan_Revyakin can use swconfig to get the correctly state, have you apply the DSA-driver patch?
As with openwrts phy-driver linux does not see switchports (only gmacs) you cannot use userspace tools like ip,ethtool,…maybe you can query portstate with swconfig which has indirect access to ports
With dsa driver you can use ip,ethtool because each port is visible as separate interface