blob: 81f336b927fe03dabaf9bebc2b4ef6ef26e5e53c [file] [log] [blame]
developer880c8292022-07-11 11:52:59 +08001/*
2* switch_fun.h: switch function sets
3*/
4#ifndef SWITCH_FUN_H
5#define SWITCH_FUN_H
6
7#include <stdbool.h>
8
developere78dab52024-03-25 14:26:39 +08009struct switch_func_s {
10 void (*pf_table_dump)(int argc, char *argv[]);
11 void (*pf_table_clear)(int argc, char *argv[]);
12 void (*pf_switch_reset)(int argc, char *argv[]);
13 void (*pf_doArlAging)(int argc, char *argv[]);
14 void (*pf_read_mib_counters)(int argc, char *argv[]);
15 void (*pf_clear_mib_counters)(int argc, char *argv[]);
16 void (*pf_read_output_queue_counters)(int argc, char *argv[]);
17 void (*pf_read_free_page_counters)(int argc, char *argv[]);
18 void (*pf_rate_control)(int argc, char *argv[]);
19 void (*pf_igress_rate_set)(int argc, char *argv[]);
20 void (*pf_egress_rate_set)(int argc, char *argv[]);
21 void (*pf_table_add)(int argc, char *argv[]);
22 void (*pf_table_del_fid)(int argc, char *argv[]);
23 void (*pf_table_del_vid)(int argc, char *argv[]);
24 void (*pf_table_search_mac_fid)(int argc, char *argv[]);
25 void (*pf_table_search_mac_vid)(int argc, char *argv[]);
26 void (*pf_global_set_mac_fc)(int argc, char *argv[]);
27 void (*pf_set_mac_pfc)(int argc, char *argv[]);
28 void (*pf_qos_sch_select)(int argc, char *argv[]);
29 void (*pf_qos_set_base)(int argc, char *argv[]);
30 void (*pf_qos_wfq_set_weight)(int argc, char *argv[]);
31 void (*pf_qos_set_portpri)(int argc, char *argv[]);
32 void (*pf_qos_set_dscppri)(int argc, char *argv[]);
33 void (*pf_qos_pri_mapping_queue)(int argc, char *argv[]);
34 void (*pf_doStp)(int argc, char *argv[]);
35 void (*pf_sip_dump)(int argc, char *argv[]);
36 void (*pf_sip_add)(int argc, char *argv[]);
37 void (*pf_sip_del)(int argc, char *argv[]);
38 void (*pf_sip_clear)(int argc, char *argv[]);
39 void (*pf_dip_dump)(int argc, char *argv[]);
40 void (*pf_dip_add)(int argc, char *argv[]);
41 void (*pf_dip_del)(int argc, char *argv[]);
42 void (*pf_dip_clear)(int argc, char *argv[]);
43 void (*pf_set_mirror_to)(int argc, char *argv[]);
44 void (*pf_set_mirror_from)(int argc, char *argv[]);
45 void (*pf_doMirrorEn)(int argc, char *argv[]);
46 void (*pf_doMirrorPortBased)(int argc, char *argv[]);
47 void (*pf_acl_dip_add)(int argc, char *argv[]);
48 void (*pf_acl_dip_modify)(int argc, char *argv[]);
49 void (*pf_acl_dip_pppoe)(int argc, char *argv[]);
50 void (*pf_acl_dip_trtcm)(int argc, char *argv[]);
51 void (*pf_acl_dip_meter)(int argc, char *argv[]);
52 void (*pf_acl_mac_add)(int argc, char *argv[]);
53 void (*pf_acl_ethertype)(int argc, char *argv[]);
54 void (*pf_acl_sp_add)(int argc, char *argv[]);
55 void (*pf_acl_l4_add)(int argc, char *argv[]);
56 void (*pf_acl_port_enable)(int argc, char *argv[]);
57 void (*pf_acl_table_add)(int argc, char *argv[]);
58 void (*pf_acl_mask_table_add)(int argc, char *argv[]);
59 void (*pf_acl_rule_table_add)(int argc, char *argv[]);
60 void (*pf_acl_rate_table_add)(int argc, char *argv[]);
61 void (*pf_vlan_dump)(int argc, char *argv[]);
62 void (*pf_vlan_set)(int argc, char *argv[]);
63 void (*pf_vlan_clear)(int argc, char *argv[]);
64 void (*pf_doVlanSetVid)(int argc, char *argv[]);
65 void (*pf_doVlanSetPvid)(int argc, char *argv[]);
66 void (*pf_doVlanSetAccFrm)(int argc, char *argv[]);
67 void (*pf_doVlanSetPortAttr)(int argc, char *argv[]);
68 void (*pf_doVlanSetPortMode)(int argc, char *argv[]);
69 void (*pf_doVlanSetEgressTagPCR)(int argc, char *argv[]);
70 void (*pf_doVlanSetEgressTagPVC)(int argc, char *argv[]);
71 void (*pf_igmp_on)(int argc, char *argv[]);
72 void (*pf_igmp_off)(int argc, char *argv[]);
73 void (*pf_igmp_enable)(int argc, char *argv[]);
74 void (*pf_igmp_disable)(int argc, char *argv[]);
75 void (*pf_collision_pool_enable)(int argc, char *argv[]);
76 void (*pf_collision_pool_mac_dump)(int argc, char *argv[]);
77 void (*pf_collision_pool_dip_dump)(int argc, char *argv[]);
78 void (*pf_collision_pool_sip_dump)(int argc, char *argv[]);
79 void (*pf_pfc_get_rx_counter)(int argc, char *argv[]);
80 void (*pf_pfc_get_tx_counter)(int argc, char *argv[]);
81 void (*pf_eee_enable)(int argc, char *argv[]);
82 void (*pf_eee_dump)(int argc, char *argv[]);
83};
84
developer880c8292022-07-11 11:52:59 +080085#define MT7530_T10_TEST_CONTROL 0x145
86
87#define MAX_PORT 6
developer5dfa8b72022-11-03 11:33:07 +080088#define MAX_PHY_PORT 5
developer880c8292022-07-11 11:52:59 +080089#define CONFIG_MTK_7531_DVT 1
90
91extern int chip_name;
92extern struct mt753x_attr *attres;
93extern bool nl_init_flag;
developere78dab52024-03-25 14:26:39 +080094extern struct switch_func_s mt753x_switch_func;
95extern struct switch_func_s an8855_switch_func;
developer880c8292022-07-11 11:52:59 +080096
97/*basic operation*/
developer5dfa8b72022-11-03 11:33:07 +080098int reg_read(unsigned int offset, unsigned int *value);
99int reg_write(unsigned int offset, unsigned int value);
100int mii_mgr_read(unsigned int port_num, unsigned int reg, unsigned int *value);
developer880c8292022-07-11 11:52:59 +0800101int mii_mgr_write(unsigned int port_num, unsigned int reg, unsigned int value);
developere78dab52024-03-25 14:26:39 +0800102int mii_mgr_c45_read(unsigned int port_num, unsigned int dev, unsigned int reg,
developercc8110b2024-08-19 13:53:34 +0800103 unsigned int *value);
developere78dab52024-03-25 14:26:39 +0800104int mii_mgr_c45_write(unsigned int port_num, unsigned int dev, unsigned int reg,
developercc8110b2024-08-19 13:53:34 +0800105 unsigned int value);
developer880c8292022-07-11 11:52:59 +0800106
107/*phy setting*/
108int phy_dump(int phy_addr);
109void phy_crossover(int argc, char *argv[]);
110int rw_phy_token_ring(int argc, char *argv[]);
111/*arl setting*/
112void doArlAging(int argc, char *argv[]);
113
114/*acl setting*/
115void acl_mac_add(int argc, char *argv[]);
116void acl_dip_meter(int argc, char *argv[]);
117void acl_dip_trtcm(int argc, char *argv[]);
118void acl_ethertype(int argc, char *argv[]);
119void acl_ethertype(int argc, char *argv[]);
120void acl_dip_modify(int argc, char *argv[]);
121void acl_dip_pppoe(int argc, char *argv[]);
122void acl_dip_add(int argc, char *argv[]);
123void acl_l4_add(int argc, char *argv[]);
124void acl_sp_add(int argc, char *argv[]);
125
126void acl_port_enable(int argc, char *argv[]);
127void acl_table_add(int argc, char *argv[]);
128void acl_mask_table_add(int argc, char *argv[]);
129void acl_rule_table_add(int argc, char *argv[]);
130void acl_rate_table_add(int argc, char *argv[]);
131
132/*dip table*/
developere78dab52024-03-25 14:26:39 +0800133void dip_dump(int argc, char *argv[]);
developer880c8292022-07-11 11:52:59 +0800134void dip_add(int argc, char *argv[]);
135void dip_del(int argc, char *argv[]);
developere78dab52024-03-25 14:26:39 +0800136void dip_clear(int argc, char *argv[]);
developer880c8292022-07-11 11:52:59 +0800137
138/*sip table*/
developere78dab52024-03-25 14:26:39 +0800139void sip_dump(int argc, char *argv[]);
developer880c8292022-07-11 11:52:59 +0800140void sip_add(int argc, char *argv[]);
141void sip_del(int argc, char *argv[]);
developere78dab52024-03-25 14:26:39 +0800142void sip_clear(int argc, char *argv[]);
developer880c8292022-07-11 11:52:59 +0800143
144/*stp*/
145void doStp(int argc, char *argv[]);
146
147/*mac table*/
developere78dab52024-03-25 14:26:39 +0800148void table_dump(int argc, char *argv[]);
developer880c8292022-07-11 11:52:59 +0800149void table_add(int argc, char *argv[]);
150void table_search_mac_vid(int argc, char *argv[]);
151void table_search_mac_fid(int argc, char *argv[]);
152void table_del_fid(int argc, char *argv[]);
153void table_del_vid(int argc, char *argv[]);
developere78dab52024-03-25 14:26:39 +0800154void table_clear(int argc, char *argv[]);
developer880c8292022-07-11 11:52:59 +0800155
156/*vlan table*/
developer5dfa8b72022-11-03 11:33:07 +0800157void vlan_dump(int argc, char *argv[]);
developer880c8292022-07-11 11:52:59 +0800158void vlan_clear(int argc, char *argv[]);
159void vlan_set(int argc, char *argv[]);
160
161void doVlanSetPvid(int argc, char *argv[]);
162void doVlanSetVid(int argc, char *argv[]);
163void doVlanSetAccFrm(int argc, char *argv[]);
164void doVlanSetPortAttr(int argc, char *argv[]);
165void doVlanSetPortMode(int argc, char *argv[]);
166void doVlanSetEgressTagPCR(int argc, char *argv[]);
167void doVlanSetEgressTagPVC(int argc, char *argv[]);
168
169/*igmp function*/
170void igmp_on(int argc, char *argv[]);
developere78dab52024-03-25 14:26:39 +0800171void igmp_off(int argc, char *argv[]);
developer880c8292022-07-11 11:52:59 +0800172void igmp_disable(int argc, char *argv[]);
173void igmp_enable(int argc, char *argv[]);
174
175/*mirror function*/
176void set_mirror_to(int argc, char *argv[]);
177void set_mirror_from(int argc, char *argv[]);
178void doMirrorPortBased(int argc, char *argv[]);
179void doMirrorEn(int argc, char *argv[]);
180
181/*rate control*/
182void rate_control(int argc, char *argv[]);
developere78dab52024-03-25 14:26:39 +0800183void ingress_rate_set(int argc, char *argv[]);
184void egress_rate_set(int argc, char *argv[]);
developer880c8292022-07-11 11:52:59 +0800185
186/*QoS*/
developere78dab52024-03-25 14:26:39 +0800187void qos_sch_select(int argc, char *argv[]);
developer880c8292022-07-11 11:52:59 +0800188void qos_set_base(int argc, char *argv[]);
189void qos_wfq_set_weight(int argc, char *argv[]);
190void qos_set_portpri(int argc, char *argv[]);
191void qos_set_dscppri(int argc, char *argv[]);
192void qos_pri_mapping_queue(int argc, char *argv[]);
193
194/*flow control*/
developere78dab52024-03-25 14:26:39 +0800195void global_set_mac_fc(int argc, char *argv[]);
196void phy_set_fc(int argc, char *argv[]);
197void phy_set_an(int argc, char *argv[]);
developer880c8292022-07-11 11:52:59 +0800198
199/* collision pool functions */
developere78dab52024-03-25 14:26:39 +0800200void collision_pool_enable(int argc, char *argv[]);
201void collision_pool_mac_dump(int argc, char *argv[]);
202void collision_pool_dip_dump(int argc, char *argv[]);
203void collision_pool_sip_dump(int argc, char *argv[]);
developer880c8292022-07-11 11:52:59 +0800204
205/*pfc functions*/
developere78dab52024-03-25 14:26:39 +0800206void set_mac_pfc(int argc, char *argv[]);
developer880c8292022-07-11 11:52:59 +0800207void pfc_get_rx_counter(int argc, char *argv[]);
208void pfc_get_tx_counter(int argc, char *argv[]);
209
210/*switch reset*/
developere78dab52024-03-25 14:26:39 +0800211void switch_reset(int argc, char *argv[]);
developer5dfa8b72022-11-03 11:33:07 +0800212
213/* EEE(802.3az) function */
214void eee_enable(int argc, char *argv[]);
215void eee_dump(int argc, char *argv[]);
developer880c8292022-07-11 11:52:59 +0800216
developere78dab52024-03-25 14:26:39 +0800217void read_mib_counters(int argc, char *argv[]);
218void clear_mib_counters(int argc, char *argv[]);
219void read_output_queue_counters(int argc, char *argv[]);
220void read_free_page_counters(int argc, char *argv[]);
developer880c8292022-07-11 11:52:59 +0800221
222void phy_crossover(int argc, char *argv[]);
developercc8110b2024-08-19 13:53:34 +0800223void exit_free(void);
developer5dfa8b72022-11-03 11:33:07 +0800224#endif