developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 1 | /* |
| 2 | * switch_fun.h: switch function sets |
| 3 | */ |
| 4 | #ifndef SWITCH_FUN_H |
| 5 | #define SWITCH_FUN_H |
| 6 | |
| 7 | #include <stdbool.h> |
| 8 | |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 9 | void (*pf_chip_func)(int argc, char *argv[]); |
| 10 | |
| 11 | struct switch_func_s { |
| 12 | void (*pf_table_dump)(int argc, char *argv[]); |
| 13 | void (*pf_table_clear)(int argc, char *argv[]); |
| 14 | void (*pf_switch_reset)(int argc, char *argv[]); |
| 15 | void (*pf_doArlAging)(int argc, char *argv[]); |
| 16 | void (*pf_read_mib_counters)(int argc, char *argv[]); |
| 17 | void (*pf_clear_mib_counters)(int argc, char *argv[]); |
| 18 | void (*pf_read_output_queue_counters)(int argc, char *argv[]); |
| 19 | void (*pf_read_free_page_counters)(int argc, char *argv[]); |
| 20 | void (*pf_rate_control)(int argc, char *argv[]); |
| 21 | void (*pf_igress_rate_set)(int argc, char *argv[]); |
| 22 | void (*pf_egress_rate_set)(int argc, char *argv[]); |
| 23 | void (*pf_table_add)(int argc, char *argv[]); |
| 24 | void (*pf_table_del_fid)(int argc, char *argv[]); |
| 25 | void (*pf_table_del_vid)(int argc, char *argv[]); |
| 26 | void (*pf_table_search_mac_fid)(int argc, char *argv[]); |
| 27 | void (*pf_table_search_mac_vid)(int argc, char *argv[]); |
| 28 | void (*pf_global_set_mac_fc)(int argc, char *argv[]); |
| 29 | void (*pf_set_mac_pfc)(int argc, char *argv[]); |
| 30 | void (*pf_qos_sch_select)(int argc, char *argv[]); |
| 31 | void (*pf_qos_set_base)(int argc, char *argv[]); |
| 32 | void (*pf_qos_wfq_set_weight)(int argc, char *argv[]); |
| 33 | void (*pf_qos_set_portpri)(int argc, char *argv[]); |
| 34 | void (*pf_qos_set_dscppri)(int argc, char *argv[]); |
| 35 | void (*pf_qos_pri_mapping_queue)(int argc, char *argv[]); |
| 36 | void (*pf_doStp)(int argc, char *argv[]); |
| 37 | void (*pf_sip_dump)(int argc, char *argv[]); |
| 38 | void (*pf_sip_add)(int argc, char *argv[]); |
| 39 | void (*pf_sip_del)(int argc, char *argv[]); |
| 40 | void (*pf_sip_clear)(int argc, char *argv[]); |
| 41 | void (*pf_dip_dump)(int argc, char *argv[]); |
| 42 | void (*pf_dip_add)(int argc, char *argv[]); |
| 43 | void (*pf_dip_del)(int argc, char *argv[]); |
| 44 | void (*pf_dip_clear)(int argc, char *argv[]); |
| 45 | void (*pf_set_mirror_to)(int argc, char *argv[]); |
| 46 | void (*pf_set_mirror_from)(int argc, char *argv[]); |
| 47 | void (*pf_doMirrorEn)(int argc, char *argv[]); |
| 48 | void (*pf_doMirrorPortBased)(int argc, char *argv[]); |
| 49 | void (*pf_acl_dip_add)(int argc, char *argv[]); |
| 50 | void (*pf_acl_dip_modify)(int argc, char *argv[]); |
| 51 | void (*pf_acl_dip_pppoe)(int argc, char *argv[]); |
| 52 | void (*pf_acl_dip_trtcm)(int argc, char *argv[]); |
| 53 | void (*pf_acl_dip_meter)(int argc, char *argv[]); |
| 54 | void (*pf_acl_mac_add)(int argc, char *argv[]); |
| 55 | void (*pf_acl_ethertype)(int argc, char *argv[]); |
| 56 | void (*pf_acl_sp_add)(int argc, char *argv[]); |
| 57 | void (*pf_acl_l4_add)(int argc, char *argv[]); |
| 58 | void (*pf_acl_port_enable)(int argc, char *argv[]); |
| 59 | void (*pf_acl_table_add)(int argc, char *argv[]); |
| 60 | void (*pf_acl_mask_table_add)(int argc, char *argv[]); |
| 61 | void (*pf_acl_rule_table_add)(int argc, char *argv[]); |
| 62 | void (*pf_acl_rate_table_add)(int argc, char *argv[]); |
| 63 | void (*pf_vlan_dump)(int argc, char *argv[]); |
| 64 | void (*pf_vlan_set)(int argc, char *argv[]); |
| 65 | void (*pf_vlan_clear)(int argc, char *argv[]); |
| 66 | void (*pf_doVlanSetVid)(int argc, char *argv[]); |
| 67 | void (*pf_doVlanSetPvid)(int argc, char *argv[]); |
| 68 | void (*pf_doVlanSetAccFrm)(int argc, char *argv[]); |
| 69 | void (*pf_doVlanSetPortAttr)(int argc, char *argv[]); |
| 70 | void (*pf_doVlanSetPortMode)(int argc, char *argv[]); |
| 71 | void (*pf_doVlanSetEgressTagPCR)(int argc, char *argv[]); |
| 72 | void (*pf_doVlanSetEgressTagPVC)(int argc, char *argv[]); |
| 73 | void (*pf_igmp_on)(int argc, char *argv[]); |
| 74 | void (*pf_igmp_off)(int argc, char *argv[]); |
| 75 | void (*pf_igmp_enable)(int argc, char *argv[]); |
| 76 | void (*pf_igmp_disable)(int argc, char *argv[]); |
| 77 | void (*pf_collision_pool_enable)(int argc, char *argv[]); |
| 78 | void (*pf_collision_pool_mac_dump)(int argc, char *argv[]); |
| 79 | void (*pf_collision_pool_dip_dump)(int argc, char *argv[]); |
| 80 | void (*pf_collision_pool_sip_dump)(int argc, char *argv[]); |
| 81 | void (*pf_pfc_get_rx_counter)(int argc, char *argv[]); |
| 82 | void (*pf_pfc_get_tx_counter)(int argc, char *argv[]); |
| 83 | void (*pf_eee_enable)(int argc, char *argv[]); |
| 84 | void (*pf_eee_dump)(int argc, char *argv[]); |
| 85 | }; |
| 86 | |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 87 | #define MT7530_T10_TEST_CONTROL 0x145 |
| 88 | |
| 89 | #define MAX_PORT 6 |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 90 | #define MAX_PHY_PORT 5 |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 91 | #define CONFIG_MTK_7531_DVT 1 |
| 92 | |
| 93 | extern int chip_name; |
| 94 | extern struct mt753x_attr *attres; |
| 95 | extern bool nl_init_flag; |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 96 | extern struct switch_func_s mt753x_switch_func; |
| 97 | extern struct switch_func_s an8855_switch_func; |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 98 | |
| 99 | /*basic operation*/ |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 100 | int reg_read(unsigned int offset, unsigned int *value); |
| 101 | int reg_write(unsigned int offset, unsigned int value); |
| 102 | int mii_mgr_read(unsigned int port_num, unsigned int reg, unsigned int *value); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 103 | int mii_mgr_write(unsigned int port_num, unsigned int reg, unsigned int value); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 104 | int mii_mgr_c45_read(unsigned int port_num, unsigned int dev, unsigned int reg, |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame^] | 105 | unsigned int *value); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 106 | int mii_mgr_c45_write(unsigned int port_num, unsigned int dev, unsigned int reg, |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame^] | 107 | unsigned int value); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 108 | |
| 109 | /*phy setting*/ |
| 110 | int phy_dump(int phy_addr); |
| 111 | void phy_crossover(int argc, char *argv[]); |
| 112 | int rw_phy_token_ring(int argc, char *argv[]); |
| 113 | /*arl setting*/ |
| 114 | void doArlAging(int argc, char *argv[]); |
| 115 | |
| 116 | /*acl setting*/ |
| 117 | void acl_mac_add(int argc, char *argv[]); |
| 118 | void acl_dip_meter(int argc, char *argv[]); |
| 119 | void acl_dip_trtcm(int argc, char *argv[]); |
| 120 | void acl_ethertype(int argc, char *argv[]); |
| 121 | void acl_ethertype(int argc, char *argv[]); |
| 122 | void acl_dip_modify(int argc, char *argv[]); |
| 123 | void acl_dip_pppoe(int argc, char *argv[]); |
| 124 | void acl_dip_add(int argc, char *argv[]); |
| 125 | void acl_l4_add(int argc, char *argv[]); |
| 126 | void acl_sp_add(int argc, char *argv[]); |
| 127 | |
| 128 | void acl_port_enable(int argc, char *argv[]); |
| 129 | void acl_table_add(int argc, char *argv[]); |
| 130 | void acl_mask_table_add(int argc, char *argv[]); |
| 131 | void acl_rule_table_add(int argc, char *argv[]); |
| 132 | void acl_rate_table_add(int argc, char *argv[]); |
| 133 | |
| 134 | /*dip table*/ |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 135 | void dip_dump(int argc, char *argv[]); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 136 | void dip_add(int argc, char *argv[]); |
| 137 | void dip_del(int argc, char *argv[]); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 138 | void dip_clear(int argc, char *argv[]); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 139 | |
| 140 | /*sip table*/ |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 141 | void sip_dump(int argc, char *argv[]); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 142 | void sip_add(int argc, char *argv[]); |
| 143 | void sip_del(int argc, char *argv[]); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 144 | void sip_clear(int argc, char *argv[]); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 145 | |
| 146 | /*stp*/ |
| 147 | void doStp(int argc, char *argv[]); |
| 148 | |
| 149 | /*mac table*/ |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 150 | void table_dump(int argc, char *argv[]); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 151 | void table_add(int argc, char *argv[]); |
| 152 | void table_search_mac_vid(int argc, char *argv[]); |
| 153 | void table_search_mac_fid(int argc, char *argv[]); |
| 154 | void table_del_fid(int argc, char *argv[]); |
| 155 | void table_del_vid(int argc, char *argv[]); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 156 | void table_clear(int argc, char *argv[]); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 157 | |
| 158 | /*vlan table*/ |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 159 | void vlan_dump(int argc, char *argv[]); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 160 | void vlan_clear(int argc, char *argv[]); |
| 161 | void vlan_set(int argc, char *argv[]); |
| 162 | |
| 163 | void doVlanSetPvid(int argc, char *argv[]); |
| 164 | void doVlanSetVid(int argc, char *argv[]); |
| 165 | void doVlanSetAccFrm(int argc, char *argv[]); |
| 166 | void doVlanSetPortAttr(int argc, char *argv[]); |
| 167 | void doVlanSetPortMode(int argc, char *argv[]); |
| 168 | void doVlanSetEgressTagPCR(int argc, char *argv[]); |
| 169 | void doVlanSetEgressTagPVC(int argc, char *argv[]); |
| 170 | |
| 171 | /*igmp function*/ |
| 172 | void igmp_on(int argc, char *argv[]); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 173 | void igmp_off(int argc, char *argv[]); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 174 | void igmp_disable(int argc, char *argv[]); |
| 175 | void igmp_enable(int argc, char *argv[]); |
| 176 | |
| 177 | /*mirror function*/ |
| 178 | void set_mirror_to(int argc, char *argv[]); |
| 179 | void set_mirror_from(int argc, char *argv[]); |
| 180 | void doMirrorPortBased(int argc, char *argv[]); |
| 181 | void doMirrorEn(int argc, char *argv[]); |
| 182 | |
| 183 | /*rate control*/ |
| 184 | void rate_control(int argc, char *argv[]); |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 185 | void ingress_rate_set(int argc, char *argv[]); |
| 186 | void egress_rate_set(int argc, char *argv[]); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 187 | |
| 188 | /*QoS*/ |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 189 | void qos_sch_select(int argc, char *argv[]); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 190 | void qos_set_base(int argc, char *argv[]); |
| 191 | void qos_wfq_set_weight(int argc, char *argv[]); |
| 192 | void qos_set_portpri(int argc, char *argv[]); |
| 193 | void qos_set_dscppri(int argc, char *argv[]); |
| 194 | void qos_pri_mapping_queue(int argc, char *argv[]); |
| 195 | |
| 196 | /*flow control*/ |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 197 | void global_set_mac_fc(int argc, char *argv[]); |
| 198 | void phy_set_fc(int argc, char *argv[]); |
| 199 | void phy_set_an(int argc, char *argv[]); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 200 | |
| 201 | /* collision pool functions */ |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 202 | void collision_pool_enable(int argc, char *argv[]); |
| 203 | void collision_pool_mac_dump(int argc, char *argv[]); |
| 204 | void collision_pool_dip_dump(int argc, char *argv[]); |
| 205 | void collision_pool_sip_dump(int argc, char *argv[]); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 206 | |
| 207 | /*pfc functions*/ |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 208 | void set_mac_pfc(int argc, char *argv[]); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 209 | void pfc_get_rx_counter(int argc, char *argv[]); |
| 210 | void pfc_get_tx_counter(int argc, char *argv[]); |
| 211 | |
| 212 | /*switch reset*/ |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 213 | void switch_reset(int argc, char *argv[]); |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 214 | |
| 215 | /* EEE(802.3az) function */ |
| 216 | void eee_enable(int argc, char *argv[]); |
| 217 | void eee_dump(int argc, char *argv[]); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 218 | |
developer | e78dab5 | 2024-03-25 14:26:39 +0800 | [diff] [blame] | 219 | void read_mib_counters(int argc, char *argv[]); |
| 220 | void clear_mib_counters(int argc, char *argv[]); |
| 221 | void read_output_queue_counters(int argc, char *argv[]); |
| 222 | void read_free_page_counters(int argc, char *argv[]); |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 223 | |
| 224 | void phy_crossover(int argc, char *argv[]); |
developer | cc8110b | 2024-08-19 13:53:34 +0800 | [diff] [blame^] | 225 | void exit_free(void); |
developer | 5dfa8b7 | 2022-11-03 11:33:07 +0800 | [diff] [blame] | 226 | #endif |