developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1 | /* |
| 2 | * switch_753x.c: set for 753x switch |
| 3 | */ |
| 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <unistd.h> |
| 7 | #include <string.h> |
| 8 | #include <sys/ioctl.h> |
| 9 | #include <sys/socket.h> |
| 10 | #include <linux/if.h> |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame] | 11 | #include <errno.h> |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 12 | |
| 13 | #include "switch_netlink.h" |
| 14 | #include "switch_ioctl.h" |
| 15 | #include "switch_fun.h" |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 16 | #include "switch_fun_an8855.h" |
| 17 | |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame] | 18 | #define SWITCH_APP_VERSION "1.0.7" |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 19 | |
| 20 | struct mt753x_attr *attres; |
| 21 | int chip_name; |
| 22 | bool nl_init_flag; |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame] | 23 | bool air_skip_check_flag; |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 24 | struct switch_func_s *p_switch_func; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 25 | |
| 26 | static void usage(char *cmd) |
| 27 | { |
| 28 | printf("==================Usage===============================================================================================================================\n"); |
| 29 | |
| 30 | /* 1. basic operations */ |
| 31 | printf("1) mt753x switch Basic operations=================================================================================================================>>>>\n"); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 32 | printf(" 1.1) %s devs - list switch device id and model name\n", cmd); |
| 33 | printf(" 1.2) %s sysctl - show the ways to access kenerl driver: netlink or ioctl\n", cmd); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 34 | printf(" 1.3) %s reset - sw reset switch fsm and registers\n", cmd); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 35 | printf(" 1.4) %s reg r [offset] - read the reg with default switch\n", cmd); |
| 36 | printf(" 1.5) %s reg w [offset] [value] - write the reg with default switch\n", cmd); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 37 | printf(" 1.6) %s reg d [offset] - dump the reg with default switch\n", cmd); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 38 | printf(" 1.7) %s dev [devid] reg r [addr] - read the reg with the switch devid\n", cmd); |
| 39 | printf(" 1.8) %s dev [devid] reg w [addr] [value] - write the regs with the switch devid\n", cmd); |
| 40 | printf(" 1.9) %s dev [devid] reg d [addr] - dump the regs with the switch devid\n", cmd); |
| 41 | printf("\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 42 | |
| 43 | /* 2. phy operations */ |
| 44 | printf("2) mt753x switch PHY operations===================================================================================================================>>>>\n"); |
| 45 | printf(" 2.1) %s phy - dump all phy registers (clause 22)\n", cmd); |
| 46 | printf(" 2.2) %s phy [phy_addr] - dump phy register of specific port (clause 22)\n", cmd); |
| 47 | printf(" 2.3) %s phy cl22 r [port_num] [phy_reg] - read specific phy register of specific port by clause 22\n", cmd); |
| 48 | printf(" 2.4) %s phy cl22 w [port_num] [phy_reg] [value] - write specific phy register of specific port by clause 22\n", cmd); |
| 49 | printf(" 2.5) %s phy cl45 r [port_num] [dev_num] [phy_reg] - read specific phy register of specific port by clause 45\n", cmd); |
| 50 | printf(" 2.6) %s phy cl45 w [port_num] [dev_num] [phy_reg] [value] - write specific phy register of specific port by clause 45\n", cmd); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 51 | printf(" 2.7) %s phy fc [port_num] [enable 0|1] - set switch phy flow control, port is 0~4, enable is 1, disable is 0\n", cmd); |
| 52 | printf(" 2.8) %s phy an [port_num] [enable 0|1] - set switch phy auto-negotiation, port is 0~4, enable is 1, disable is 0\n", cmd); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 53 | printf(" 2.9) %s trreg r [port_num] [ch_addr] [node_addr] [data_addr] - read phy token-ring of specific port\n", cmd); |
| 54 | printf(" 2.10) %s trreg w [port_num] [ch_addr] [node_addr] [data_addr] - write phy token-ring of specific port\n", cmd); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 55 | printf(" [high_value] [low_value]\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 56 | printf(" 2.11) %s crossover [port_num] [mode auto|mdi|mdix] - switch auto or force mdi/mdix mode for crossover cable\n", cmd); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 57 | printf("\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 58 | |
| 59 | /* 3. mac operations */ |
| 60 | printf("3) mt753x switch MAC operations====================================================================================================================>>>>\n"); |
| 61 | printf(" 3.1) %s dump - dump switch mac table\n", cmd); |
| 62 | printf(" 3.2) %s clear - clear switch mac table\n", cmd); |
| 63 | printf(" 3.3) %s add [mac] [portmap] - add an entry (with portmap) to switch mac table\n", cmd); |
| 64 | printf(" 3.4) %s add [mac] [portmap] [vlan id] - add an entry (with portmap, vlan id) to switch mac table\n", cmd); |
| 65 | printf(" 3.5) %s add [mac] [portmap] [vlan id] [age] - add an entry (with portmap, vlan id, age out time) to switch mac table\n", cmd); |
| 66 | printf(" 3.6) %s del mac [mac] vid [vid] - delete an entry from switch mac table\n", cmd); |
| 67 | printf(" 3.7) %s del mac [mac] fid [fid] - delete an entry from switch mac table\n", cmd); |
| 68 | printf(" 3.8) %s search mac [mac] vid [vid] - search an entry with specific mac and vid\n", cmd); |
| 69 | printf(" 3.9) %s search mac [mac] fid [fid] - search an entry with specific mac and fid\n", cmd); |
| 70 | printf(" 3.10) %s filt [mac] - add a SA filtering entry (with portmap 1111111) to switch mac table\n", cmd); |
| 71 | printf(" 3.11) %s filt [mac] [portmap] - add a SA filtering entry (with portmap)to switch mac table\n", cmd); |
| 72 | printf(" 3.12) %s filt [mac] [portmap] [vlan id - add a SA filtering entry (with portmap, vlan id)to switch mac table\n", cmd); |
| 73 | printf(" 3.13) %s filt [mac] [portmap] [vlan id] [age] - add a SA filtering entry (with portmap, vlan id, age out time) to switch table\n", cmd); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 74 | printf(" 3.14) %s arl aging [active:0|1] [time:1~65536] - set switch arl aging timeout value\n", cmd); |
| 75 | printf(" 3.15) %s macctl fc [enable|disable] - set switch mac global flow control,enable is 1, disable is 0\n", cmd); |
| 76 | printf("\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 77 | |
| 78 | /* 4. mib counter operations */ |
| 79 | printf("4) mt753x switch mib counter operations============================================================================================================>>>>\n"); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 80 | printf(" 4.1) %s esw_cnt get -get switch mib counters\n", cmd); |
| 81 | printf(" 4.2) %s esw_cnt clear -clear switch mib counters\n", cmd); |
| 82 | printf(" 4.3) %s output_queue_cnt get -get switch output queue counters\n", cmd); |
| 83 | printf(" 4.4) %s free_page get -get switch system free page counters\n", cmd); |
| 84 | printf("\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 85 | |
| 86 | /* 5. acl function operations */ |
| 87 | printf("5) mt753x switch acl function operations============================================================================================================>>>>\n"); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 88 | printf(" 5.1) %s acl enable [port] [port_enable:0|1] - set switch acl function enabled, port is 0~6,enable is 1, disable is 0\n", cmd); |
| 89 | printf(" 5.2) %s acl etype add [ethtype] [portmap] - drop L2 ethertype packets\n", cmd); |
| 90 | printf(" 5.3) %s acl dmac add [mac] [portmap] - drop L2 dest-Mac packets\n", cmd); |
| 91 | printf(" 5.4) %s acl dip add [dip] [portmap] - drop dip packets\n", cmd); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 92 | printf(" 5.5) %s acl port add [sport] [portmap] - drop L4 UDP/TCP source port packets\n", cmd); |
| 93 | printf(" 5.6) %s acl L4 add [2byes] [portmap] - drop L4 packets with 2bytes payload\n", cmd); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 94 | printf(" 5.7) %s acl acltbl-add [tbl_idx:0~63/255] [vawd1] [vawd2] - set switch acl table new entry, max index-7530:63,7531:255\n", cmd); |
| 95 | printf(" 5.8) %s acl masktbl-add [tbl_idx:0~31/127] [vawd1] [vawd2] - set switch acl mask table new entry, max index-7530:31,7531:127\n", cmd); |
| 96 | printf(" 5.9) %s acl ruletbl-add [tbl_idx:0~31/127] [vawd1] [vawd2] - set switch acl rule table new entry, max index-7530:31,7531:127\n", cmd); |
| 97 | printf(" 5.10) %s acl ratetbl-add [tbl_idx:0~31] [vawd1] [vawd2] - set switch acl rate table new entry\n", cmd); |
| 98 | printf(" 5.11) %s acl dip meter [dip] [portmap][meter:kbps] - rate limit dip packets\n", cmd); |
| 99 | printf(" 5.12) %s acl dip trtcm [dip] [portmap][CIR:kbps][CBS][PIR][PBS]- TrTCM dip packets\n", cmd); |
| 100 | printf(" 5.13) %s acl dip modup [dip] [portmap][usr_pri] - modify usr priority from ACL\n", cmd); |
| 101 | printf(" 5.14) %s acl dip pppoe [dip] [portmap] - pppoe header removal\n", cmd); |
| 102 | printf("\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 103 | |
| 104 | /* 6. dip table operations */ |
| 105 | printf("6) mt753x switch dip table operations=================================================================================================================>>>>\n"); |
| 106 | printf(" 6.1) %s dip dump - dump switch dip table\n", cmd); |
| 107 | printf(" 6.2) %s dip clear - clear switch dip table\n", cmd); |
| 108 | printf(" 6.3) %s dip add [dip] [portmap] - add a dip entry to switch table\n", cmd); |
| 109 | printf(" 6.4) %s dip del [dip] - del a dip entry to switch table\n", cmd); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 110 | printf("\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 111 | |
| 112 | /* 7. sip table operations */ |
| 113 | printf("7) mt753x switch sip table operations=================================================================================================================>>>>\n"); |
| 114 | printf(" 7.1) %s sip dump - dump switch sip table\n", cmd); |
| 115 | printf(" 7.2) %s sip clear - clear switch sip table\n", cmd); |
| 116 | printf(" 7.3) %s sip add [sip] [dip] [portmap] - add a sip entry to switch table\n", cmd); |
| 117 | printf(" 7.4) %s sip del [sip] [dip] - del a sip entry to switch table\n", cmd); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 118 | printf("\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 119 | |
| 120 | /* 8. vlan table operations */ |
| 121 | printf("8) mt753x switch sip table operations====================================================================================================================>>>>\n"); |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 122 | printf(" 8.1) %s vlan dump (egtag) - dump switch vlan table (with per port eg_tag setting)\n", cmd); |
| 123 | printf(" 8.2) %s vlan set [fid:0~7] [vid] [portmap] - set vlan id and associated member at switch vlan table\n", cmd); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 124 | printf(" ([stag:0~4095] [eg_con:0|1] [egtagPortMap 0:untagged 2:tagged])\n"); |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 125 | printf(" Full Example: %s vlan set 0 3 10000100 0 0 20000200\n", cmd); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 126 | printf(" 8.3) %s vlan vid [vlan idx] [active:0|1] [vid] [portMap] - set switch vlan vid elements\n", cmd); |
| 127 | printf(" [egtagPortMap] [ivl_en] [fid] [stag]\n"); |
| 128 | printf(" 8.4) %s vlan pvid [port] [pvid] - set switch vlan pvid\n", cmd); |
| 129 | printf(" 8.5) %s vlan acc-frm [port] [acceptable_frame_type:0~3] - set switch vlan acceptable_frame type : admit all frames: 0,\n", cmd); |
| 130 | printf(" admit only vlan-taged frames: 1,admit only untagged or priority-tagged frames: 2, reserved:3\n"); |
| 131 | printf(" 8.6) %s vlan port-attr [port] [attr:0~3] - set switch vlan port attribute: user port: 0, statck port: 1,\n", cmd); |
| 132 | printf(" translation port: 2, transparent port:3\n"); |
| 133 | printf(" 8.7) %s vlan port-mode [port] [mode:0~3] - set switch vlan port mode : port matrix mode: 0, fallback mode: 1,\n", cmd); |
| 134 | printf(" check mode: 2, security mode:3\n"); |
| 135 | printf(" 8.8) %s vlan eg-tag-pvc [port] [eg_tag:0~7] - set switch vlan eg tag pvc : disable: 0, consistent: 1, reserved: 2,\n", cmd); |
| 136 | printf(" reserved:3,untagged:4,swap:5,tagged:6, stack:7\n"); |
| 137 | printf(" 8.9) %s vlan eg-tag-pcr [port] [eg_tag:0~3] - set switch vlan eg tag pcr : untagged: 0, swap: 1, tagged: 2, stack:3\n", cmd); |
| 138 | printf("\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 139 | |
| 140 | /* 9. rate limit operations */ |
| 141 | printf("9) mt753x switch rate limit operations=================================================================================================================>>>>\n"); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 142 | printf(" 9.1) %s ratectl [in_ex_gress:0|1] [port] [rate] - set switch port ingress(1) or egress(0) rate\n", cmd); |
| 143 | printf(" 9.2) %s ingress-rate on [port] [Kbps] - set ingress rate limit on port n (n= 0~ switch max port)\n", cmd); |
| 144 | printf(" 9.3) %s egress-rate on [port] [Kbps] - set egress rate limit on port n (n= 0~ switch max port)\n", cmd); |
| 145 | printf(" 9.4) %s ingress-rate off [port] - disable ingress rate limit on port n (n= 0~ switch max port)\n", cmd); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 146 | printf(" 9.5) %s egress-rate off [port] - disable egress rate limit on port n (n= 0~ switch max port)\n", cmd); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 147 | printf("\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 148 | |
| 149 | /* 10. igmp operations */ |
| 150 | printf("10) mt753x igmp operations===============================================================================================================================>>>>\n"); |
| 151 | printf(" 10.1) %s igmpsnoop on [leaky_en] [wan_num] - turn on IGMP snoop and router port learning\n", cmd); |
| 152 | printf(" leaky_en: 1 or 0. default 0; wan_num: 0 or 4. default 4\n"); |
| 153 | printf(" 10.2) %s igmpsnoop off - turn off IGMP snoop and router port learning\n", cmd); |
| 154 | printf(" 10.3) %s igmpsnoop enable [port#] - enable IGMP HW leave/join/Squery/Gquery\n", cmd); |
| 155 | printf(" 10.4) %s igmpsnoop disable [port#] - disable IGMP HW leave/join/Squery/Gquery\n", cmd); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 156 | printf("\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 157 | |
| 158 | /* 11. QoS operations */ |
| 159 | printf("11) mt753x QoS operations================================================================================================================================>>>>\n"); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 160 | printf(" 11.1) %s qos sch [port:0~6] [queue:0~7] [shaper:min|max] [type:rr:0|sp:1|wfq:2] - set switch qos sch type\n", cmd); |
| 161 | printf(" 11.2) %s qos base [port:0~6] [base] - set switch qos base(UPW); port-based:0, tag-based:1,\n", cmd); |
| 162 | printf(" dscp-based:2, acl-based:3, arl-based:4, stag-based:5\n"); |
| 163 | printf(" 11.3) %s qos port-weight [port:0~6] [q0] [q1][q2][q3] - set switch qos port queue weight;\n", cmd); |
| 164 | printf(" [q4][q5][q6][q7] [qn]: the weight of queue n, range: 1~16\n"); |
| 165 | printf(" 11.4) %s qos port-prio [port:0~6] [prio:0~7] - set switch port qos user priority; port is 0~6, priority is 0~7\n", cmd); |
| 166 | printf(" 11.5) %s qos dscp-prio [dscp:0~63] [prio:0~7] - set switch qos dscp user priority; dscp is 0~63, priority is 0~7\n", cmd); |
| 167 | printf(" 11.6) %s 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\n", cmd); |
| 168 | printf("\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 169 | |
| 170 | /*12. port mirror operations*/ |
| 171 | printf(" 12) mt753x port mirror operations========================================================================================================================>>>>\n"); |
| 172 | printf(" 12.1) %s mirror monitor [port] - enable port mirror and indicate monitor port number\n", cmd); |
| 173 | printf(" 12.2) %s mirror target [port] - set port mirror target\n", cmd); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 174 | printf(" [direction| 0:off, 1:rx, 2:tx, 3:all]\n"); |
| 175 | printf(" 12.3) %s mirror enable [mirror_en:0|1] [mirror_port: 0-6] - set switch mirror function enable(1) or disabled(0) for port 0~6\n", cmd); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 176 | printf(" 12.4) %s mirror port-based [port] [port_tx_mir:0|1] - set switch mirror port: target tx/rx/acl/vlan/igmp\n", cmd); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 177 | printf(" [port_rx_mir:0|1] [acl_mir:0|1]\n"); |
| 178 | printf(" [vlan_mis:0|1] [igmp_mir:0|1]\n"); |
| 179 | printf("\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 180 | |
| 181 | /*13. stp function*/ |
| 182 | printf(" 13) mt753x stp operations===============================================================================================================================>>>>\n"); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 183 | printf(" 13.1) %s stp [port] [fid] [state] - set switch spanning tree state, port is 0~6, fid is 0~7,\n", cmd); |
| 184 | printf(" state is 0~3(Disable/Discarding:0,Blocking/Listening/Discarding:1,)\n"); |
| 185 | printf(" Learning:2,Forwarding:3\n"); |
| 186 | printf("\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 187 | |
| 188 | /*14. collision pool operations*/ |
| 189 | printf("14) mt753x collision pool operations========================================================================================================================>>>>\n"); |
| 190 | printf(" 14.1) %s collision-pool enable [enable 0|1] - enable or disable collision pool\n", cmd); |
| 191 | printf(" 14.2) %s collision-pool mac dump - dump collision pool mac table\n", cmd); |
| 192 | printf(" 14.3) %s collision-pool dip dump - dump collision pool dip table\n", cmd); |
| 193 | printf(" 14.4) %s collision-pool sip dump - dump collision pool sip table\n", cmd); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 194 | printf("\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 195 | |
| 196 | /*15. pfc(priority flow control) operations*/ |
| 197 | printf("15) mt753x pfc(priority flow control) operations==============================================================================================================>>>>\n"); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 198 | printf(" 15.1) %s pfc enable [port] [enable 0|1] - enable or disable port's pfc\n", cmd); |
| 199 | printf(" 15.2) %s pfc rx_counter [port] - get port n pfc 8 up rx counter\n", cmd); |
| 200 | printf(" 15.3) %s pfc tx_counter [port] - get port n pfc 8 up rx counter\n", cmd); |
| 201 | printf("\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 202 | |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 203 | /*15. pfc(priority flow control) operations*/ |
| 204 | printf("16) mt753x EEE(802.3az) operations==============================================================================================================>>>>\n"); |
| 205 | printf(" 16.1) %s eee enable [enable 0|1] ([portMap]) - enable or disable EEE (by portMap)\n", cmd); |
| 206 | printf(" 16.2) %s eee dump ([port]) - dump EEE capability (by port)\n", cmd); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 207 | printf("\n"); |
| 208 | |
| 209 | if (chip_name == 0x8855) { |
| 210 | printf("switch an8855 <sub cmd> supported commands===================================================================================================================>>>>\n"); |
| 211 | printf("\n"); |
| 212 | printf("Register/GPHY access commands===============================================================================================================>>>>\n"); |
| 213 | printf("reg r <reg(4'hex)>\n"); |
| 214 | printf("reg w <reg(4'hex)> <value(8'hex)>\n"); |
| 215 | printf("phy cl22 r <port(0..4)> <reg(2'hex)>\n"); |
| 216 | printf("phy cl22 w <port(0..4)> <reg(2'hex)> <value(4'hex)>\n"); |
| 217 | printf("phy cl45 r <port(0..4)> <dev(2'hex)> <reg(3'hex)>\n"); |
| 218 | printf("phy cl45 w <port(0..4)> <dev(2'hex)> <reg(3'hex)> <value(4'hex)>\n"); |
| 219 | printf("\n"); |
| 220 | printf("Port configuration commands=================================================================================================================>>>>\n"); |
| 221 | printf("port set matrix <port(0..6)> <matrix(6:0)>\n"); |
| 222 | printf("port get matrix <port(0..6)>\n"); |
| 223 | printf("port set vlanMode <port(0..6)> <vlanMode(0:matrix,1:fallback,2:check,3:security)>\n"); |
| 224 | printf("port get vlanMode <port(0..6)>\n"); |
| 225 | printf("port set flowCtrl <port(0..6)> <dir(0:Tx,1:Rx)> <fc_en(1:En,0:Dis)>\n"); |
| 226 | printf("port get flowCtrl <port(0..6)> <dir(0:Tx,1:Rx)>\n"); |
| 227 | printf("port set jumbo <pkt_len(0:1518,1:1536,2:1552,3:max)> <frame_len(2..15)>\n"); |
| 228 | printf("port get jumbo\n"); |
| 229 | printf("port set anMode <port(0..4)> <en(0:force,1:AN)>\n"); |
| 230 | printf("port get anMode <port(0..4)>\n"); |
| 231 | printf("port set localAdv <port(0..4)> <10H(1:En,0:Dis)> <10F(1:En,0:Dis)> <100H(1:En,0:Dis)> <100F(1:En,0:Dis)> <1000F(1:En,0:Dis)> <pause(1:En,0:Dis)>\n"); |
| 232 | printf("port get localAdv <port(0..4)>\n"); |
| 233 | printf("port get remoteAdv <port(0..4)>\n"); |
| 234 | printf("port set speed <port(0..4)> <speed(0:10M,1:100M,2:1G,3:2.5G)>\n"); |
| 235 | printf("port get speed <port(0..4)>\n"); |
| 236 | printf("port set duplex <port(0..4)> <duplex(0:half,1:full)>\n"); |
| 237 | printf("port get duplex <port(0..4)>\n"); |
| 238 | printf("port get status <port(0..4)>\n"); |
| 239 | printf("port set bckPres <port(0..6)> <bckPres(1:En,0:Dis)>\n"); |
| 240 | printf("port get bckPres <port(0..6)>\n"); |
| 241 | printf("port set psMode <port(0..4)> <ls(1:En,0:Dis)> <eee(1:En,0:Dis)>\n"); |
| 242 | printf("port get psMode <port(0..4)>\n"); |
| 243 | printf("port set smtSpdDwn <port(0..4)> <en(1:En,0:Dis)> <retry(2..5)>\n"); |
| 244 | printf("port get smtSpdDwn <port(0..4)>\n"); |
| 245 | printf("port set spTag <port(0..6)> <en(1:En,0:Dis)>\n"); |
| 246 | printf("port get spTag <port(0..6)>\n"); |
| 247 | printf("port set enable <port(0..4)> <en(1:En,0:Dis)>\n"); |
| 248 | printf("port get enable <port(0..4)>\n"); |
| 249 | printf("port set 5GBaseRMode\n"); |
| 250 | printf("port set hsgmiiMode\n"); |
| 251 | printf("port set sgmiiMode <mode(0:AN,1:Force)> <speed(0:10M,1:100M,2:1G)>\n"); |
| 252 | printf("port set rmiiMode <speed(0:10M,1:100M)>\n"); |
| 253 | printf("port set rgmiiMode <speed(0:10M,1:100M,2:1G)>\n"); |
| 254 | printf("\n"); |
| 255 | printf("Special tag commands========================================================================================================================>>>>\n"); |
| 256 | printf("sptag setEnable port<port(0..6)> enable<1:enable 0:disable>\n"); |
| 257 | printf("sptag getEnable port<port(0..6)>\n"); |
| 258 | printf("sptag setmode port<port(0..6)> mode<0:inset 1:replace>\n"); |
| 259 | printf("sptag getmode port<port(0..6)>\n"); |
| 260 | printf("sptag encode mode={ insert | replace } opc={ portmap | portid | lookup } dp={bitimap hex} vpm={ untagged | 8100 | 88a8 } pri=<UINT> cfi=<UINT> vid=<UINT>\n"); |
| 261 | printf("sptag decode <byte(hex)> <byte(hex)> <byte(hex)> <byte(hex)>\n"); |
| 262 | printf("\n"); |
| 263 | printf("Vlan commands===============================================================================================================================>>>>\n"); |
| 264 | printf("sptag set fid <vid(0..4095)> <fid(0..7)>\n"); |
| 265 | printf("sptag set memPort <vid(0..4095)> <bitmap(6:0)>\n"); |
| 266 | printf("sptag set ivl <vid(0..4095)> <(1:En,0:Dis)>\n"); |
| 267 | printf("sptag set portBaseStag <vid(0..4095)> <(1:En,0:Dis)>\n"); |
| 268 | printf("sptag set stag <vid(0..4095)> <stag(0..4095)>\n"); |
| 269 | printf("sptag set egsTagCtlEn <vid(0..4095)> <(1:En,0:Dis)>\n"); |
| 270 | printf("sptag set egsTagCtlCon <vid(0..4095)> <(1:En,0:Dis)>\n"); |
| 271 | printf("sptag set egsTagCtl <vid(0..4095)> <port(0..6)> <ctlType(0:untag,2:tagged)>\n"); |
| 272 | printf("sptag set portActFrame <port(0..6)> <frameType(0:all,1:tagged,2:untagged)>\n"); |
| 273 | printf("sptag get portActFrame <port(0..6)>\n"); |
| 274 | printf("sptag set LeakyVlanEn <port(0..6)> <pktType(0:uc,1:mc,2:bc,3:ipmc)> <(1:En,0:Dis)>\n"); |
| 275 | printf("sptag get leakyVlanEn <port(0..6)>\n"); |
| 276 | printf("sptag set portVlanAttr <port(0..6)> <vlanAttr(0:user,1:stack,2:translation,3:transparent)>\n"); |
| 277 | printf("sptag get portVlanAttr <port(0..6)>\n"); |
| 278 | printf("sptag set igsPortETagAttr <port(0..6)> <egsTagAttr(0:disable,1:consistent,4:untagged,5:swap,6:tagged,7:stack)>\n"); |
| 279 | printf("sptag get igsPortETagAttr <port(0..6)>\n"); |
| 280 | printf("sptag set portEgsTagAttr <port(0..6)> <egsTagAttr(0:untagged,1:swap,2:tagged,3:stack)>\n"); |
| 281 | printf("sptag get portEgsTagAttr <port(0..6)>\n"); |
| 282 | printf("sptag set portOuterTPID <port(0..6)> <TPID(hex)>\n"); |
| 283 | printf("sptag get portOuterTPID <port(0..6)>\n"); |
| 284 | printf("sptag set pvid <port(0..6)> <vid(0..4095)>\n"); |
| 285 | printf("sptag get pvid <port(0..6)>\n"); |
| 286 | printf("sptag initiate <vid(0..4095)> <fid(0..7)> <bitmap(6:0)> <ivl(1:En,0:Dis)> <portbasestag(1:En,0:Dis)> <stag(0..4095)> <egstagctlen(1:En,0:Dis)> <egstagcon(1:En,0:Dis)> <taggedbitmap(6:0)>\n"); |
| 287 | printf("sptag create <vid(0..4095)>\n"); |
| 288 | printf("sptag destroy [ <vid(0..4095)> | <vidRange(vid0-vid1)> ]\n"); |
| 289 | printf("sptag destroyAll [ <restoreDefVlan(0:false,1:true)> | ]\n"); |
| 290 | printf("sptag dump [ <vid(0..4095)> | <vidRange(vid0-vid1)> | ]\n"); |
| 291 | printf("sptag addPortMem <vid(0..4095)> <port(0..6)>\n"); |
| 292 | printf("sptag addPortMem <vid(0..4095)> <port(0..6)>\n"); |
| 293 | printf("\n"); |
| 294 | printf("Layer2 commands=============================================================================================================================>>>>\n"); |
| 295 | printf("l2 dump mac\n"); |
| 296 | printf("l2 add mac <static(0:dynamic,1:static)> <unauth(0:auth,1:unauth)> <mac(12'hex)> <portlist(uintlist)> [ vid <vid(0..4095)> | fid <fid(0..15)> ] <src_mac_forward=(0:default,1:cpu-exclude,2:cpu-include,3:cpu-only,4:drop)>\n"); |
| 297 | printf("l2 del mac <mac(12'hex)> [ vid <vid(0..4095)> | fid <fid(0..15)> ]\n"); |
| 298 | printf("l2 get mac <mac(12'hex)> [ vid <vid(0..4095)> | fid <fid(0..15)> ]\n"); |
| 299 | printf("l2 clear mac\n"); |
| 300 | printf("l2 set macAddrAgeOut <time(1, 1000000)>\n"); |
| 301 | printf("l2 get macAddrAgeOut\n"); |
| 302 | printf("\n"); |
| 303 | printf("Link Aggregation commands===================================================================================================================>>>>\n"); |
| 304 | printf("lag set member <group_id(0 or 1)> <member_index(0..3)> <enable(0,1)> <port index(0..6)>\n"); |
| 305 | printf("lag get member group_id(0 or 1)\n"); |
| 306 | printf("lag set dstInfo <sp(1:En,0:Dis)> <sa(1:En,0:Dis)> <da(1:En,0:Dis)> <sip(1:En,0:Dis)> <dip(1:En,0:Dis)> <sport(1:En,0:Dis)> <dport(1:En,0:Dis)>\n"); |
| 307 | printf("lag get dstInfo\n"); |
| 308 | printf("lag set ptseed <hex32>\n"); |
| 309 | printf("lag get ptseed\n"); |
| 310 | printf("lag set hashtype <0-crc32lsb;1-crc32msb;2-crc16;3-xor4>\n"); |
| 311 | printf("lag get hashtype\n"); |
| 312 | printf("lag set state <state(1:En,0:Dis)>\n"); |
| 313 | printf("lag get state\n"); |
| 314 | printf("lag set spsel <soure port enable(1:En,0:Dis)>\n"); |
| 315 | printf("lag get spsel\n"); |
| 316 | printf("\n"); |
| 317 | printf("STP commands================================================================================================================================>>>>\n"); |
| 318 | printf("stp set portstate <port(0..6)> <fid(0..15)> <state(0:disable,1:listen,2:learn,3:forward)>\n"); |
| 319 | printf("stp get portstate <port(0..6)> <fid(0..15)>\n"); |
| 320 | printf("\n"); |
| 321 | printf("Mirror commands=============================================================================================================================>>>>\n"); |
| 322 | printf("mirror set session <sid(0,1)> <dst_port(UINT)> <state(1:En,0:Dis)> <tag(1:on, 0:off)> <list(UINTLIST)> <dir(0:none,1:tx,2:rx,3:both)>\n"); |
| 323 | printf("mirror set session-enable <sid(0,1)> <state(1:En,0:Dis)>\n"); |
| 324 | printf("mirror add session-rlist <sid(0,1)> <list(UINTLIST)>\n"); |
| 325 | printf("mirror add session-tlist <sid(0,1)> <list(UINTLIST)>\n"); |
| 326 | printf("mirror get session <sid(0,1)>\n"); |
| 327 | printf("mirror del session <sid(0,1)>\n"); |
| 328 | printf("\n"); |
| 329 | printf("MIB commands================================================================================================================================>>>>\n"); |
| 330 | printf("mib get port <port(0..6)>\n"); |
| 331 | printf("mib get acl <event(0..7)>\n"); |
| 332 | printf("mib clear port <port(0..6)>\n"); |
| 333 | printf("mib clear all\n"); |
| 334 | printf("mib clear acl\n"); |
| 335 | printf("\n"); |
| 336 | printf("QoS commands================================================================================================================================>>>>\n"); |
| 337 | printf("qos set scheduleAlgo <portlist(UINTLIST)> <queue(UINT)> <scheduler(0:SP,1:WRR,2:WFQ)> <weight(0..128)>, weight 0 is valid only on sp mode\n"); |
| 338 | printf("qos get scheduleAlgo <portlist(UINTLIST)> <queue(UINT)>\n"); |
| 339 | printf("qos set trustMode <portlist(UINTLIST)> <mode(0:port,1:1p-port,2:dscp-port,3:dscp-1p-port>\n"); |
| 340 | printf("qos get trustMode <portlist(UINTLIST)>\n"); |
| 341 | printf("qos set pri2Queue <priority(0..7)> <queue(0..7)>\n"); |
| 342 | printf("qos get pri2Queue\n"); |
| 343 | printf("qos set dscp2Pri <dscp(0..63)> <priority(0..7)>\n"); |
| 344 | printf("qos get dscp2Pri <dscp(0..63)>\n"); |
| 345 | printf("qos set rateLimitEnable <portlist(UINTLIST)> <dir(0:egress,1:ingress)> <rate_en(1:En,0:Dis)>\n"); |
| 346 | printf("qos get rateLimitEnable <portlist(UINTLIST)>\n"); |
| 347 | printf("qos set rateLimit <portlist(UINTLIST)> <I_CIR(0..80000)> <I_CBS(0..127)> <E_CIR(0..80000)> <E_CBS(0..127)>\n"); |
| 348 | printf("qos get rateLimit <portlist(UINTLIST)>\n"); |
| 349 | printf("qos set portPriority <portlist(UINTLIST)> <priority(0..7)>\n"); |
| 350 | printf("qos get portPriority <portlist(UINTLIST)>\n"); |
| 351 | printf("qos set rateLmtExMngFrm <dir(0:egress)> <en(0:include,1:exclude)>\n"); |
| 352 | printf("qos get rateLmtExMngFrm\n"); |
| 353 | printf("\n"); |
| 354 | printf("Diag commands===============================================================================================================================>>>>\n"); |
| 355 | printf("diag set txComply <phy(0..4)> <mode(0..8)>\n"); |
| 356 | printf("diag get txComply <phy(0..4)>\n"); |
| 357 | printf("\n"); |
| 358 | printf("LED commands================================================================================================================================>>>>\n"); |
| 359 | printf("led set mode <mode(0:disable, 1..3:2 LED, 4:user-define)>\n"); |
| 360 | printf("led get mode\n"); |
| 361 | printf("led set state <led(0..1)> <state(1:En,0:Dis)>\n"); |
| 362 | printf("led get state <led(0..1)>\n"); |
| 363 | printf("led set usr <led(0..1)> <polarity(0:low, 1:high)> <on_evt(7'bin)> <blink_evt(10'bin)>\n"); |
| 364 | printf("led get usr <led(0..1)>\n"); |
| 365 | printf("led set time <time(0..5:32ms~1024ms)>\n"); |
| 366 | printf("led get time\n"); |
| 367 | printf("\n"); |
| 368 | printf("Security commands===========================================================================================================================>>>>\n"); |
| 369 | printf("sec set stormEnable <port(0..6)> <type(0:bcst,1:mcst,2:ucst)> <en(1:En,0:Dis)>\n"); |
| 370 | printf("sec get stormEnable <port(0..6)> <type(0:bcst,1:mcst,2:ucst)>\n"); |
| 371 | printf("sec set stormRate <port(0..6)> <type(0:bcst,1:mcst,2:ucst)> <count(0..255)> <unit(0:64k,1:256k,2:1M,3:4M,4:16M)>\n"); |
| 372 | printf("sec get stormRate <port(0..6)> <type(0:bcst,1:mcst,2:ucst)>\n"); |
| 373 | printf("sec set fldMode <port(0..6)> <type(0:bcst,1:mcst,2:ucst,3:qury> <en(1:En,0:Dis)>\n"); |
| 374 | printf("sec get fldMode <port(0..6)> <type(0:bcst,1:mcst,2:ucst,3:qury>\n"); |
| 375 | printf("sec set saLearning <port(0..6)> <learn(0:disable,1:enable)>\n"); |
| 376 | printf("sec get saLearning <port(0..6)>\n"); |
| 377 | printf("sec set saLimit <port(0..6)> <mode(0:disable,1:enable)> <count(0..4095)>\n"); |
| 378 | printf("sec get saLimit <port(0..6)>\n"); |
| 379 | printf("\n"); |
| 380 | printf("Switch commands=============================================================================================================================>>>>\n"); |
| 381 | printf("switch set cpuPortEn <cpu_en(1:En,0:Dis)>\n"); |
| 382 | printf("switch get cpuPortEn\n"); |
| 383 | printf("switch set cpuPort <port_number>\n"); |
| 384 | printf("switch get cpuPort\n"); |
| 385 | printf("switch set phyLCIntrEn <phy(0..6)> <(1:En,0:Dis)>\n"); |
| 386 | printf("switch get phyLCIntrEn <phy(0..6)>\n"); |
| 387 | printf("switch set phyLCIntrSts <phy(0..6)> <(1:Clear)>\n"); |
| 388 | printf("switch get phyLCIntrSts <phy(0..6)>\n"); |
| 389 | printf("\n"); |
| 390 | printf("ACL commands================================================================================================================================>>>>\n"); |
| 391 | printf("acl set en <en(1:En,0:Dis)>\n"); |
| 392 | printf("acl get en\n"); |
| 393 | printf("acl set rule <idx(0..127)>\n <state(0:Dis,1:En)> <reverse(0:Dis,1:En)> <end(0:Dis,1:En)>\n <portmap(7'bin)><ipv6(0:Dis,1:En,2:Not care)>\n[ dmac <dmac(12'hex)> <dmac_mask(12'hex)> ]\n[ smac <smac(12'hex)> <smac_mask(12'hex)> ]\n[ stag <stag(4'hex)> <stag_mask(4'hex)> ]\n[ ctag <ctag(4'hex)> <ctag_mask(4'hex)> ]\n[ etype <etype(4'hex)> <etype_mask(4'hex)> ]\n[ dip <dip(IPADDR)> <dip_mask(IPADDR)> ]\n[ sip <sip(IPADDR)> <sip_mask(IPADDR)> ]\n[ dscp <dscp(2'hex)> <dscp_mask(2'hex)> ]\n[ protocol <protocol(12'hex)> <protocol_mask(12'hex)> ]\n[ dport <dport(4'hex)> <dport_mask(4'hex)> ]\n[ sport <sport(4'hex)> <sport_mask(4'hex)> ]\n[ flow_label <flow_label(4'hex)> <flow_label_mask(4'hex)> ]\n[ udf <udf(4'hex)> <udf_mask(4'hex)> ] "); |
| 394 | printf("acl get rule <idx(0..127)> "); |
| 395 | printf("acl del rule <idx(0..127)>\n"); |
| 396 | printf("acl clear rule\n"); |
| 397 | printf("acl set udfRule <idx(0..15)> <mode(0:pattern, 1:threshold)> [ <pat(4'hex)> <mask(4'hex)> | <low(4'hex)> <high(4'hex)> ] <start(0:MAC header, 1:L2 payload, 2:IPv4 header, 3:IPv6 header, 4:L3 payload, 5:TCP header, 6:UDP header, 7: L4 payload)> <offset(0..127,unit:2 bytes)> <portmap(7'bin)>\n"); |
| 398 | printf("acl get udfRule <idx(0..15)>\n"); |
| 399 | printf("acl del udfRule <idx(0..15)>\n"); |
| 400 | printf("acl clear udfRule\n"); |
| 401 | printf("acl set action <idx(0..127)>\n[ forward <forward(0:Default,4:Exclude CPU,5:Include CPU,6:CPU only,7:Drop)> ]\n[ egtag <egtag(0:Default,1:Consistent,4:Untag,5:Swap,6:Tag,7:Stack)> ]\n[ mirrormap <mirrormap(2'bin)> ]\n[ priority <priority(0..7)> ]\n[ redirect <redirect(0:Dst,1:Vlan)> <portmap(7'bin)> ]\n[ leaky_vlan <leaky_vlan(1:En,0:Dis)> ]\n[ cnt_idx <cnt_idx(0..63)> ]\n[ rate_idx <rate_idx(0..31)> ]\n[ attack_idx <attack_idx(0..95)> ]\n[ vid <vid(0..4095)> ]\n[ manage <manage(1:En,0:Dis)> ]\n[ bpdu <bpdu(1:En,0:Dis)> ]\n[ class <class(0:Original,1:Defined)>[0..7] ]\n[ drop_pcd <drop_pcd(0:Original,1:Defined)> [red <red(0..7)>][yellow <yellow(0..7)>][green <green(0..7)>] ]\n[ color <color(0:Defined,1:Trtcm)> [ <defined_color(0:Dis,1:Green,2:Yellow,3:Red)> | <trtcm_idx(0..31)> ] ]"); |
| 402 | printf("acl get action <idx(0..127)>\n"); |
| 403 | printf("acl del action <idx(0..127)>\n"); |
| 404 | printf("acl clear action\n"); |
| 405 | printf("acl set trtcm <idx(1..31)> <cir(4'hex)> <pir(4'hex)> <cbs(4'hex)> <pbs(4'hex)>\n"); |
| 406 | printf("acl get trtcm <idx(1..31)>\n"); |
| 407 | printf("acl del trtcm <idx(0..31)>\n"); |
| 408 | printf("acl clear trtcm\n"); |
| 409 | printf("acl set trtcmEn <en(1:En,0:Dis)>\n"); |
| 410 | printf("acl get trtcmEn\n"); |
| 411 | printf("acl set portEn <port(0..6)> <en(1:En,0:Dis)>\n"); |
| 412 | printf("acl get portEn <port(0..6)>\n"); |
| 413 | printf("acl set dropEn <port(0..6)> <en(1:En,0:Dis)>\n"); |
| 414 | printf("acl get dropEn <port(0..6)>\n"); |
| 415 | printf("acl set dropThrsh <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)> <high(0..2047)> <low(0..2047)>\n"); |
| 416 | printf("acl get dropThrsh <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)>\n"); |
| 417 | printf("acl set dropPbb <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)> <probability(0..1023)>\n"); |
| 418 | printf("acl get dropPbb <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)>\n"); |
| 419 | printf("acl set meter <idx(0..31)> <en(1:En,0:Dis)> <rate(0..65535)>\n Note: Limit rate = rate * 64Kbps"); |
| 420 | printf("acl get meter <idx(0..31)>\n"); |
| 421 | printf("\n"); |
| 422 | } |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 423 | |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 424 | exit_free(); |
| 425 | exit(0); |
| 426 | } |
| 427 | |
| 428 | static void parse_reg_cmd(int argc, char *argv[], int len) |
| 429 | { |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 430 | unsigned int val; |
| 431 | unsigned int off; |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame] | 432 | char *endptr; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 433 | int i, j; |
| 434 | |
| 435 | if (!strncmp(argv[len - 3], "reg", 4)) { |
| 436 | if (argv[len - 2][0] == 'r') { |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame] | 437 | errno = 0; |
| 438 | off = strtoul(argv[len - 1], &endptr, 16); |
| 439 | if (errno != 0 || *endptr != '\0') |
| 440 | goto error; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 441 | reg_read(off, &val); |
| 442 | printf(" Read reg=%x, value=%x\n", off, val); |
| 443 | } else if (argv[len - 2][0] == 'w') { |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame] | 444 | errno = 0; |
| 445 | off = strtoul(argv[len - 1], &endptr, 16); |
| 446 | if (errno != 0 || *endptr != '\0') |
| 447 | goto error; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 448 | if (argc != len + 1) |
| 449 | usage(argv[0]); |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame] | 450 | errno = 0; |
| 451 | val = strtoul(argv[len], &endptr, 16); |
| 452 | if (errno != 0 || *endptr != '\0') |
| 453 | goto error; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 454 | reg_write(off, val); |
| 455 | printf(" Write reg=%x, value=%x\n", off, val); |
| 456 | } else if (argv[len - 2][0] == 'd') { |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame] | 457 | errno = 0; |
| 458 | off = strtoul(argv[len - 1], &endptr, 16); |
| 459 | if (errno != 0 || *endptr != '\0') |
| 460 | goto error; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 461 | for (i = 0; i < 16; i++) { |
| 462 | printf("0x%08x: ", off + 0x10 * i); |
| 463 | for (j = 0; j < 4; j++) { |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame] | 464 | reg_read(off + i * 0x10 + j * 0x4, &val); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 465 | printf(" 0x%08x", val); |
| 466 | } |
| 467 | printf("\n"); |
| 468 | } |
| 469 | } else |
| 470 | usage(argv[0]); |
| 471 | } else |
| 472 | usage(argv[0]); |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame] | 473 | return; |
| 474 | error: |
| 475 | printf("Error: string converting\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | static int get_chip_name() |
| 479 | { |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 480 | int temp = 0, rc = 0; |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 481 | FILE *fp = NULL; |
| 482 | char buff[255]; |
| 483 | |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame] | 484 | /*judge an8855, must be placed before reg_read*/ |
| 485 | if (air_skip_check_flag) { |
| 486 | temp = 0x8855; |
| 487 | return temp; |
| 488 | } |
| 489 | |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 490 | /*judge jaguar embedded switch */ |
| 491 | fp = fopen("/proc/device-tree/compatible", "r"); |
| 492 | if (fp != NULL) { |
| 493 | temp = -1; |
| 494 | if (fgets(buff, 255, (FILE *) fp) && strstr(buff, "mt7988")) |
| 495 | temp = 0x7988; |
| 496 | |
| 497 | rc = fclose(fp); |
| 498 | if (rc == 0 && temp == 0x7988) |
| 499 | return temp; |
| 500 | } |
| 501 | |
| 502 | /*judge 7530 */ |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 503 | reg_read((0x7ffc), &temp); |
| 504 | temp = temp >> 16; |
| 505 | if (temp == 0x7530) |
| 506 | return temp; |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 507 | |
| 508 | /*judge 7531 */ |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 509 | reg_read(0x781c, &temp); |
| 510 | temp = temp >> 16; |
| 511 | if (temp == 0x7531) |
| 512 | return temp; |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 513 | |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 514 | return -1; |
| 515 | } |
| 516 | |
| 517 | static int phy_operate(int argc, char *argv[]) |
| 518 | { |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 519 | unsigned int port_num = 0; |
| 520 | unsigned int dev_num = 0; |
| 521 | unsigned int value = 0, cl_value = 0; |
| 522 | unsigned int reg = 0; |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 523 | int ret = 0, cl_ret = 0; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 524 | char op; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 525 | |
| 526 | if (strncmp(argv[2], "cl22", 4) && strncmp(argv[2], "cl45", 4)) |
| 527 | usage(argv[0]); |
| 528 | |
| 529 | op = argv[3][0]; |
| 530 | |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 531 | switch (op) { |
| 532 | case 'r': |
developer | 1ec6807 | 2024-10-17 14:25:33 +0800 | [diff] [blame^] | 533 | reg = strtoul(argv[argc - 1], NULL, 0); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 534 | if (reg >= 0xFFFFFFFF) { |
| 535 | printf(" Phy read reg fail\n"); |
| 536 | ret = -1; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 537 | break; |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 538 | } |
| 539 | |
| 540 | if (argc == 6) { |
| 541 | port_num = strtoul(argv[argc - 2], NULL, 0); |
| 542 | if (port_num > MAX_PORT) { |
| 543 | printf(" Phy read reg fail\n"); |
| 544 | ret = -1; |
| 545 | break; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 546 | } |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 547 | |
| 548 | ret = mii_mgr_read(port_num, reg, &value); |
| 549 | if (ret < 0) |
| 550 | printf(" Phy read reg fail\n"); |
| 551 | else |
| 552 | printf(" Phy read reg=0x%x, value=0x%x\n", |
| 553 | reg, value); |
| 554 | } else if (argc == 7) { |
developer | 1ec6807 | 2024-10-17 14:25:33 +0800 | [diff] [blame^] | 555 | dev_num = strtoul(argv[argc - 2], NULL, 0); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 556 | if (dev_num > 0xFFFFFFFF) { |
| 557 | printf(" Phy read reg fail\n"); |
| 558 | ret = -1; |
| 559 | break; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 560 | } |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 561 | |
| 562 | port_num = strtoul(argv[argc - 3], NULL, 0); |
| 563 | if (port_num > MAX_PORT) { |
| 564 | printf(" Phy read reg fail\n"); |
| 565 | ret = -1; |
| 566 | break; |
| 567 | } |
| 568 | |
| 569 | ret = mii_mgr_c45_read(port_num, dev_num, reg, |
| 570 | &value); |
| 571 | if (ret < 0) |
| 572 | printf(" Phy read reg fail\n"); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 573 | else |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 574 | printf(" Phy read dev_num=0x%x, reg=0x%x, value=0x%x\n", |
| 575 | dev_num, reg, value); |
| 576 | } else |
| 577 | ret = phy_dump(32); |
| 578 | break; |
| 579 | case 'w': |
developer | 1ec6807 | 2024-10-17 14:25:33 +0800 | [diff] [blame^] | 580 | reg = strtoul(argv[argc - 2], NULL, 0); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 581 | if (reg >= 0xFFFFFFFF) { |
| 582 | printf(" Phy write reg fail\n"); |
| 583 | ret = -1; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 584 | break; |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | value = strtoul(argv[argc - 1], NULL, 16); |
| 588 | if (value > 0xFFFF) { |
| 589 | printf(" Phy write reg fail\n"); |
| 590 | ret = -1; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 591 | break; |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | if (argc == 7) { |
| 595 | port_num = strtoul(argv[argc - 3], NULL, 0); |
| 596 | if (port_num > MAX_PORT) { |
| 597 | printf(" Phy write reg fail\n"); |
| 598 | ret = -1; |
| 599 | break; |
| 600 | } |
| 601 | |
| 602 | ret = mii_mgr_write(port_num, reg, value); |
| 603 | cl_ret = mii_mgr_read(port_num, reg, &cl_value); |
| 604 | if (cl_ret < 0) |
| 605 | printf(" Phy write reg fail\n"); |
| 606 | else |
| 607 | printf(" Phy write reg=0x%x, value=0x%x\n", |
| 608 | reg, cl_value); |
| 609 | } else if (argc == 8) { |
developer | 1ec6807 | 2024-10-17 14:25:33 +0800 | [diff] [blame^] | 610 | dev_num = strtoul(argv[argc - 3], NULL, 0); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 611 | if (dev_num > 0xFFFFFFFF) { |
| 612 | printf(" Phy write reg fail\n"); |
| 613 | ret = -1; |
| 614 | break; |
| 615 | } |
| 616 | |
| 617 | port_num = strtoul(argv[argc - 4], NULL, 0); |
| 618 | if (port_num > MAX_PORT) { |
| 619 | printf(" Phy write reg fail\n"); |
| 620 | ret = -1; |
| 621 | break; |
| 622 | } |
| 623 | |
| 624 | ret = mii_mgr_c45_write(port_num, dev_num, reg, value); |
| 625 | cl_ret = mii_mgr_c45_read(port_num, dev_num, reg, |
| 626 | &cl_value); |
| 627 | if (cl_ret < 0) |
| 628 | printf(" Phy write reg fail\n"); |
| 629 | else |
| 630 | printf(" Phy write dev_num=0x%x reg=0x%x, value=0x%x\n", |
| 631 | dev_num, reg, cl_value); |
| 632 | } |
| 633 | break; |
| 634 | default: |
| 635 | break; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 636 | } |
| 637 | |
| 638 | return ret; |
| 639 | } |
| 640 | |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 641 | int main(int argc, char *argv[]) |
| 642 | { |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame] | 643 | int err = -EINVAL; |
| 644 | FILE *fp = NULL; |
| 645 | char buff[255]; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 646 | |
| 647 | attres = (struct mt753x_attr *)malloc(sizeof(struct mt753x_attr)); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 648 | if (attres == NULL) { |
| 649 | printf("Failed to allocate memory.\n"); |
| 650 | exit(0); |
| 651 | } |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 652 | attres->dev_id = -1; |
| 653 | attres->port_num = -1; |
| 654 | attres->phy_dev = -1; |
| 655 | nl_init_flag = true; |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame] | 656 | air_skip_check_flag = false; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 657 | |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame] | 658 | fp = fopen("/proc/air_sw/device", "r"); |
| 659 | if (fp != NULL) { |
| 660 | if (fgets(buff, 255, (FILE *) fp) && strstr(buff, "an8855")) |
| 661 | air_skip_check_flag = true; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 662 | |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame] | 663 | if ((fclose(fp) == 0) && air_skip_check_flag) { |
| 664 | err = mt753x_netlink_init(AN8855_DSA_GENL_NAME); |
| 665 | if (!err) |
| 666 | chip_name = get_chip_name(); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 667 | |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame] | 668 | if (err < 0) { |
| 669 | err = mt753x_netlink_init(AN8855_GENL_NAME); |
| 670 | if (!err) |
| 671 | chip_name = get_chip_name(); |
| 672 | } |
| 673 | } |
| 674 | } else { |
| 675 | /* dsa netlink family might not be enabled. Try gsw netlink family. */ |
| 676 | err = mt753x_netlink_init(MT753X_DSA_GENL_NAME); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 677 | if (!err) |
| 678 | chip_name = get_chip_name(); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 679 | |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame] | 680 | if (err < 0) { |
| 681 | err = mt753x_netlink_init(MT753X_GENL_NAME); |
| 682 | if (!err) |
| 683 | chip_name = get_chip_name(); |
| 684 | } |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 685 | } |
| 686 | |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 687 | if (err < 0) { |
| 688 | err = switch_ioctl_init(); |
| 689 | if (!err) { |
| 690 | nl_init_flag = false; |
| 691 | chip_name = get_chip_name(); |
| 692 | if (chip_name < 0) { |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 693 | printf |
| 694 | ("no chip unsupport or chip id is invalid!\n"); |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 695 | exit_free(); |
| 696 | exit(0); |
| 697 | } |
| 698 | } |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 699 | } |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 700 | #ifndef COMPAT_MODE |
| 701 | if (chip_name == 0x8855) { |
| 702 | AIR_INIT_PARAM_T init_param = { 0 }; |
| 703 | |
| 704 | init_param.printf = printf; |
| 705 | init_param.malloc = malloc; |
| 706 | init_param.free = free; |
| 707 | init_param.udelay = usleep; |
| 708 | init_param.dev_access.read_callback = an8855_reg_read; |
| 709 | init_param.dev_access.write_callback = an8855_reg_write; |
| 710 | init_param.dev_access.phy_read_callback = an8855_phy_cl22_read; |
| 711 | init_param.dev_access.phy_write_callback = |
| 712 | an8855_phy_cl22_write; |
| 713 | init_param.dev_access.phy_cl45_read_callback = |
| 714 | an8855_phy_cl45_read; |
| 715 | init_param.dev_access.phy_cl45_write_callback = |
| 716 | an8855_phy_cl45_write; |
| 717 | |
| 718 | air_init(0, &init_param); |
| 719 | air_parse_cmd((argc - 1), &argv[1]); |
| 720 | } |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 721 | |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 722 | exit_free(); |
| 723 | return 0; |
| 724 | #else |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 725 | if (argc < 2) |
| 726 | usage(argv[0]); |
| 727 | |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 728 | if (chip_name == 0x8855) { |
| 729 | AIR_INIT_PARAM_T init_param = { 0 }; |
| 730 | |
| 731 | init_param.printf = printf; |
| 732 | init_param.malloc = malloc; |
| 733 | init_param.free = free; |
| 734 | init_param.udelay = usleep; |
| 735 | init_param.dev_access.read_callback = an8855_reg_read; |
| 736 | init_param.dev_access.write_callback = an8855_reg_write; |
| 737 | init_param.dev_access.phy_read_callback = an8855_phy_cl22_read; |
| 738 | init_param.dev_access.phy_write_callback = |
| 739 | an8855_phy_cl22_write; |
| 740 | init_param.dev_access.phy_cl45_read_callback = |
| 741 | an8855_phy_cl45_read; |
| 742 | init_param.dev_access.phy_cl45_write_callback = |
| 743 | an8855_phy_cl45_write; |
| 744 | air_init(0, &init_param); |
| 745 | |
| 746 | p_switch_func = &an8855_switch_func; |
| 747 | } else { |
| 748 | p_switch_func = &mt753x_switch_func; |
| 749 | } |
| 750 | |
| 751 | if ((argc > 2) && !strcmp(argv[1], "an8855") |
| 752 | && (chip_name == 0x8855)) { |
| 753 | air_parse_cmd((argc - 2), (const char **)&argv[2]); |
| 754 | exit_free(); |
| 755 | return 0; |
| 756 | } |
| 757 | |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 758 | if (!strcmp(argv[1], "dev")) { |
| 759 | attres->dev_id = strtoul(argv[2], NULL, 0); |
| 760 | argv += 2; |
| 761 | argc -= 2; |
| 762 | if (argc < 2) |
| 763 | usage(argv[0]); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 764 | } |
| 765 | |
| 766 | if (argc == 2) { |
| 767 | if (!strcmp(argv[1], "devs")) { |
| 768 | attres->type = MT753X_ATTR_TYPE_MESG; |
| 769 | mt753x_list_swdev(attres, MT753X_CMD_REQUEST); |
| 770 | } else if (!strncmp(argv[1], "dump", 5)) { |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 771 | p_switch_func->pf_table_dump(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 772 | } else if (!strncmp(argv[1], "clear", 6)) { |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 773 | p_switch_func->pf_table_clear(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 774 | printf("done.\n"); |
| 775 | } else if (!strncmp(argv[1], "reset", 5)) { |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 776 | p_switch_func->pf_switch_reset(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 777 | } else if (!strncmp(argv[1], "phy", 4)) { |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 778 | phy_dump(32); //dump all phy register |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 779 | } else if (!strncmp(argv[1], "sysctl", 7)) { |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 780 | if (nl_init_flag) { |
| 781 | if (chip_name == 0x8855) |
| 782 | printf("netlink(%s)\n", |
| 783 | AN8855_GENL_NAME); |
| 784 | else |
| 785 | printf("netlink(%s)\n", |
| 786 | MT753X_GENL_NAME); |
| 787 | } else |
| 788 | printf("ioctl(%s)\n", ETH_DEVNAME); |
| 789 | } else if (!strncmp(argv[1], "ver", 4)) { |
| 790 | if (chip_name == 0x8855) |
| 791 | printf("Switch APP version: %s\r\n", |
| 792 | SWITCH_APP_VERSION); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 793 | } else |
| 794 | usage(argv[0]); |
| 795 | } else if (!strncmp(argv[1], "arl", 4)) { |
| 796 | if (!strncmp(argv[2], "aging", 6)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 797 | p_switch_func->pf_doArlAging(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 798 | } else if (!strncmp(argv[1], "esw_cnt", 8)) { |
| 799 | if (!strncmp(argv[2], "get", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 800 | p_switch_func->pf_read_mib_counters(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 801 | else if (!strncmp(argv[2], "clear", 6)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 802 | p_switch_func->pf_clear_mib_counters(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 803 | else |
| 804 | usage(argv[0]); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 805 | } else if (!strncmp(argv[1], "output_queue_cnt", 17)) { |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 806 | if (!strncmp(argv[2], "get", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 807 | p_switch_func->pf_read_output_queue_counters(argc, |
| 808 | argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 809 | else |
| 810 | usage(argv[0]); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 811 | } else if (!strncmp(argv[1], "free_page", 10)) { |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 812 | if (!strncmp(argv[2], "get", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 813 | p_switch_func->pf_read_free_page_counters(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 814 | else |
| 815 | usage(argv[0]); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 816 | } else if (!strncmp(argv[1], "ratectl", 8)) |
| 817 | p_switch_func->pf_rate_control(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 818 | else if (!strncmp(argv[1], "add", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 819 | p_switch_func->pf_table_add(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 820 | else if (!strncmp(argv[1], "filt", 5)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 821 | p_switch_func->pf_table_add(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 822 | else if (!strncmp(argv[1], "del", 4)) { |
| 823 | if (!strncmp(argv[4], "fid", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 824 | p_switch_func->pf_table_del_fid(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 825 | else if (!strncmp(argv[4], "vid", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 826 | p_switch_func->pf_table_del_vid(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 827 | else |
| 828 | usage(argv[0]); |
| 829 | } else if (!strncmp(argv[1], "search", 7)) { |
| 830 | if (!strncmp(argv[4], "fid", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 831 | p_switch_func->pf_table_search_mac_fid(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 832 | else if (!strncmp(argv[4], "vid", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 833 | p_switch_func->pf_table_search_mac_vid(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 834 | else |
| 835 | usage(argv[0]); |
| 836 | } else if (!strncmp(argv[1], "phy", 4)) { |
| 837 | if (argc == 3) { |
| 838 | int phy_addr = strtoul(argv[2], NULL, 0); |
| 839 | if (phy_addr < 0 || phy_addr > 31) |
| 840 | usage(argv[0]); |
| 841 | phy_dump(phy_addr); |
| 842 | } else if (argc == 5) { |
| 843 | if (!strncmp(argv[2], "fc", 2)) |
| 844 | phy_set_fc(argc, argv); |
| 845 | else if (!strncmp(argv[2], "an", 2)) |
| 846 | phy_set_an(argc, argv); |
| 847 | else |
| 848 | phy_dump(32); |
| 849 | } else |
| 850 | phy_operate(argc, argv); |
| 851 | } else if (!strncmp(argv[1], "trreg", 4)) { |
| 852 | if (rw_phy_token_ring(argc, argv) < 0) |
| 853 | usage(argv[0]); |
| 854 | } else if (!strncmp(argv[1], "macctl", 7)) { |
| 855 | if (argc < 3) |
| 856 | usage(argv[0]); |
| 857 | if (!strncmp(argv[2], "fc", 3)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 858 | p_switch_func->pf_global_set_mac_fc(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 859 | else if (!strncmp(argv[2], "pfc", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 860 | p_switch_func->pf_set_mac_pfc(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 861 | else |
| 862 | usage(argv[0]); |
| 863 | } else if (!strncmp(argv[1], "qos", 4)) { |
| 864 | if (argc < 3) |
| 865 | usage(argv[0]); |
| 866 | if (!strncmp(argv[2], "sch", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 867 | p_switch_func->pf_qos_sch_select(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 868 | else if (!strncmp(argv[2], "base", 5)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 869 | p_switch_func->pf_qos_set_base(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 870 | else if (!strncmp(argv[2], "port-weight", 12)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 871 | p_switch_func->pf_qos_wfq_set_weight(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 872 | else if (!strncmp(argv[2], "port-prio", 10)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 873 | p_switch_func->pf_qos_set_portpri(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 874 | else if (!strncmp(argv[2], "dscp-prio", 10)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 875 | p_switch_func->pf_qos_set_dscppri(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 876 | else if (!strncmp(argv[2], "prio-qmap", 10)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 877 | p_switch_func->pf_qos_pri_mapping_queue(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 878 | else |
| 879 | usage(argv[0]); |
| 880 | } else if (!strncmp(argv[1], "stp", 3)) { |
| 881 | if (argc < 3) |
| 882 | usage(argv[0]); |
| 883 | else |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 884 | p_switch_func->pf_doStp(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 885 | } else if (!strncmp(argv[1], "sip", 5)) { |
| 886 | if (argc < 3) |
| 887 | usage(argv[0]); |
| 888 | if (!strncmp(argv[2], "dump", 5)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 889 | p_switch_func->pf_sip_dump(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 890 | else if (!strncmp(argv[2], "add", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 891 | p_switch_func->pf_sip_add(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 892 | else if (!strncmp(argv[2], "del", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 893 | p_switch_func->pf_sip_del(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 894 | else if (!strncmp(argv[2], "clear", 6)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 895 | p_switch_func->pf_sip_clear(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 896 | else |
| 897 | usage(argv[0]); |
| 898 | } else if (!strncmp(argv[1], "dip", 4)) { |
| 899 | if (argc < 3) |
| 900 | usage(argv[0]); |
| 901 | if (!strncmp(argv[2], "dump", 5)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 902 | p_switch_func->pf_dip_dump(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 903 | else if (!strncmp(argv[2], "add", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 904 | p_switch_func->pf_dip_add(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 905 | else if (!strncmp(argv[2], "del", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 906 | p_switch_func->pf_dip_del(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 907 | else if (!strncmp(argv[2], "clear", 6)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 908 | p_switch_func->pf_dip_clear(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 909 | else |
| 910 | usage(argv[0]); |
| 911 | } else if (!strncmp(argv[1], "mirror", 7)) { |
| 912 | if (argc < 3) |
| 913 | usage(argv[0]); |
| 914 | if (!strncmp(argv[2], "monitor", 8)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 915 | p_switch_func->pf_set_mirror_to(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 916 | else if (!strncmp(argv[2], "target", 7)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 917 | p_switch_func->pf_set_mirror_from(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 918 | else if (!strncmp(argv[2], "enable", 7)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 919 | p_switch_func->pf_doMirrorEn(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 920 | else if (!strncmp(argv[2], "port-based", 11)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 921 | p_switch_func->pf_doMirrorPortBased(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 922 | else |
| 923 | usage(argv[0]); |
| 924 | } else if (!strncmp(argv[1], "acl", 4)) { |
| 925 | if (argc < 3) |
| 926 | usage(argv[0]); |
| 927 | if (!strncmp(argv[2], "dip", 4)) { |
| 928 | if (!strncmp(argv[3], "add", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 929 | p_switch_func->pf_acl_dip_add(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 930 | else if (!strncmp(argv[3], "modup", 6)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 931 | p_switch_func->pf_acl_dip_modify(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 932 | else if (!strncmp(argv[3], "pppoe", 6)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 933 | p_switch_func->pf_acl_dip_pppoe(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 934 | else if (!strncmp(argv[3], "trtcm", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 935 | p_switch_func->pf_acl_dip_trtcm(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 936 | else if (!strncmp(argv[3], "meter", 6)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 937 | p_switch_func->pf_acl_dip_meter(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 938 | else |
| 939 | usage(argv[0]); |
| 940 | } else if (!strncmp(argv[2], "dmac", 6)) { |
| 941 | if (!strncmp(argv[3], "add", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 942 | p_switch_func->pf_acl_mac_add(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 943 | else |
| 944 | usage(argv[0]); |
| 945 | } else if (!strncmp(argv[2], "etype", 6)) { |
| 946 | if (!strncmp(argv[3], "add", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 947 | p_switch_func->pf_acl_ethertype(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 948 | else |
| 949 | usage(argv[0]); |
| 950 | } else if (!strncmp(argv[2], "port", 5)) { |
| 951 | if (!strncmp(argv[3], "add", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 952 | p_switch_func->pf_acl_sp_add(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 953 | else |
| 954 | usage(argv[0]); |
| 955 | } else if (!strncmp(argv[2], "L4", 5)) { |
| 956 | if (!strncmp(argv[3], "add", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 957 | p_switch_func->pf_acl_l4_add(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 958 | else |
| 959 | usage(argv[0]); |
| 960 | } else if (!strncmp(argv[2], "enable", 7)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 961 | p_switch_func->pf_acl_port_enable(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 962 | else if (!strncmp(argv[2], "acltbl-add", 11)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 963 | p_switch_func->pf_acl_table_add(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 964 | else if (!strncmp(argv[2], "masktbl-add", 12)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 965 | p_switch_func->pf_acl_mask_table_add(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 966 | else if (!strncmp(argv[2], "ruletbl-add", 12)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 967 | p_switch_func->pf_acl_rule_table_add(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 968 | else if (!strncmp(argv[2], "ratetbl-add", 12)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 969 | p_switch_func->pf_acl_rate_table_add(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 970 | else |
| 971 | usage(argv[0]); |
| 972 | } else if (!strncmp(argv[1], "vlan", 5)) { |
| 973 | if (argc < 3) |
| 974 | usage(argv[0]); |
| 975 | if (!strncmp(argv[2], "dump", 5)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 976 | p_switch_func->pf_vlan_dump(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 977 | else if (!strncmp(argv[2], "set", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 978 | p_switch_func->pf_vlan_set(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 979 | else if (!strncmp(argv[2], "clear", 6)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 980 | p_switch_func->pf_vlan_clear(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 981 | else if (!strncmp(argv[2], "vid", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 982 | p_switch_func->pf_doVlanSetVid(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 983 | else if (!strncmp(argv[2], "pvid", 5)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 984 | p_switch_func->pf_doVlanSetPvid(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 985 | else if (!strncmp(argv[2], "acc-frm", 8)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 986 | p_switch_func->pf_doVlanSetAccFrm(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 987 | else if (!strncmp(argv[2], "port-attr", 10)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 988 | p_switch_func->pf_doVlanSetPortAttr(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 989 | else if (!strncmp(argv[2], "port-mode", 10)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 990 | p_switch_func->pf_doVlanSetPortMode(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 991 | else if (!strncmp(argv[2], "eg-tag-pcr", 11)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 992 | p_switch_func->pf_doVlanSetEgressTagPCR(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 993 | else if (!strncmp(argv[2], "eg-tag-pvc", 11)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 994 | p_switch_func->pf_doVlanSetEgressTagPVC(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 995 | else |
| 996 | usage(argv[0]); |
| 997 | } else if (!strncmp(argv[1], "reg", 4)) { |
| 998 | parse_reg_cmd(argc, argv, 4); |
| 999 | } else if (!strncmp(argv[1], "ingress-rate", 6)) { |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1000 | p_switch_func->pf_igress_rate_set(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1001 | } else if (!strncmp(argv[1], "egress-rate", 6)) { |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1002 | p_switch_func->pf_egress_rate_set(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1003 | } else if (!strncmp(argv[1], "igmpsnoop", 10)) { |
| 1004 | if (argc < 3) |
| 1005 | usage(argv[0]); |
| 1006 | if (!strncmp(argv[2], "on", 3)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1007 | p_switch_func->pf_igmp_on(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1008 | else if (!strncmp(argv[2], "off", 4)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1009 | p_switch_func->pf_igmp_off(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1010 | else if (!strncmp(argv[2], "enable", 7)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1011 | p_switch_func->pf_igmp_enable(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1012 | else if (!strncmp(argv[2], "disable", 8)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1013 | p_switch_func->pf_igmp_disable(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1014 | else |
| 1015 | usage(argv[0]); |
| 1016 | } else if (!strncmp(argv[1], "collision-pool", 15)) { |
| 1017 | if (argc < 3) |
| 1018 | usage(argv[0]); |
| 1019 | if (!strncmp(argv[2], "enable", 7)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1020 | p_switch_func->pf_collision_pool_enable(argc, argv); |
| 1021 | else if (!strncmp(argv[2], "mac", 4)) { |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1022 | if (!strncmp(argv[3], "dump", 5)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1023 | p_switch_func->pf_collision_pool_mac_dump(argc, |
| 1024 | argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1025 | else |
| 1026 | usage(argv[0]); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1027 | } else if (!strncmp(argv[2], "dip", 4)) { |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1028 | if (!strncmp(argv[3], "dump", 5)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1029 | p_switch_func->pf_collision_pool_dip_dump(argc, |
| 1030 | argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1031 | else |
| 1032 | usage(argv[0]); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1033 | } else if (!strncmp(argv[2], "sip", 4)) { |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1034 | if (!strncmp(argv[3], "dump", 5)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1035 | p_switch_func->pf_collision_pool_sip_dump(argc, |
| 1036 | argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1037 | else |
| 1038 | usage(argv[0]); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1039 | } else |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1040 | usage(argv[0]); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1041 | } else if (!strncmp(argv[1], "pfc", 15)) { |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1042 | if (argc < 4 || argc > 5) |
| 1043 | usage(argv[0]); |
| 1044 | if (!strncmp(argv[2], "enable", 7)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1045 | p_switch_func->pf_set_mac_pfc(argc, argv); |
| 1046 | else if (!strncmp(argv[2], "rx_counter", 11)) { |
| 1047 | p_switch_func->pf_pfc_get_rx_counter(argc, argv); |
| 1048 | } else if (!strncmp(argv[2], "tx_counter", 11)) { |
| 1049 | p_switch_func->pf_pfc_get_tx_counter(argc, argv); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1050 | } else |
| 1051 | usage(argv[0]); |
| 1052 | } else if (!strncmp(argv[1], "crossover", 10)) { |
| 1053 | if (argc < 4) |
| 1054 | usage(argv[0]); |
| 1055 | else |
| 1056 | phy_crossover(argc, argv); |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 1057 | } else if (!strncmp(argv[1], "eee", 4)) { |
| 1058 | if (argc < 3) |
| 1059 | usage(argv[0]); |
| 1060 | if (!strncmp(argv[2], "enable", 7) || |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1061 | !strncmp(argv[2], "disable", 8)) |
| 1062 | p_switch_func->pf_eee_enable(argc, argv); |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 1063 | else if (!strncmp(argv[2], "dump", 5)) |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1064 | p_switch_func->pf_eee_dump(argc, argv); |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 1065 | else |
| 1066 | usage(argv[0]); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1067 | } else |
| 1068 | usage(argv[0]); |
| 1069 | |
| 1070 | exit_free(); |
| 1071 | return 0; |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 1072 | #endif |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1073 | } |