[][openwrt][common][app][Refactor switch command to support switches with different design]

[Description]
Refactor switch command to support switches wtih different design.
Original switch command only support mt7530 and mt7531 switch design.
After refactor, it can also support an8855 switch design.

[Release-log]
N/A

Change-Id: I0d54e41d952a32e86ab3a79c6374a95a61bfdf73
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8766441
diff --git a/feed/app/switch/src/switch_753x.c b/feed/app/switch/src/switch_753x.c
index 9c7c921..79bc298 100644
--- a/feed/app/switch/src/switch_753x.c
+++ b/feed/app/switch/src/switch_753x.c
@@ -12,10 +12,14 @@
 #include "switch_netlink.h"
 #include "switch_ioctl.h"
 #include "switch_fun.h"
+#include "switch_fun_an8855.h"
+
+#define SWITCH_APP_VERSION "1.0.1"
 
 struct mt753x_attr *attres;
 int chip_name;
 bool nl_init_flag;
+struct switch_func_s *p_switch_func;
 
 static void usage(char *cmd)
 {
@@ -23,16 +27,16 @@
 
 	/* 1. basic operations */
 	printf("1) mt753x switch Basic operations=================================================================================================================>>>>\n");
-	printf(" 1.1) %s devs							- list switch device id and model name  \n", cmd);
-	printf(" 1.2) %s sysctl							- show the ways to access kenerl driver: netlink or ioctl \n", cmd);
+	printf(" 1.1) %s devs							- list switch device id and model name\n", cmd);
+	printf(" 1.2) %s sysctl							- show the ways to access kenerl driver: netlink or ioctl\n", cmd);
 	printf(" 1.3) %s reset							- sw reset switch fsm and registers\n", cmd);
-	printf(" 1.4) %s reg r [offset]						- read the reg with default switch \n", cmd);
-	printf(" 1.5) %s reg w [offset] [value]					- write the reg with default switch \n", cmd);
+	printf(" 1.4) %s reg r [offset]						- read the reg with default switch\n", cmd);
+	printf(" 1.5) %s reg w [offset] [value]					- write the reg with default switch\n", cmd);
 	printf(" 1.6) %s reg d [offset]						- dump the reg with default switch\n", cmd);
-	printf(" 1.7) %s dev [devid] reg r [addr]				- read the reg with the switch devid  \n", cmd);
-	printf(" 1.8) %s dev [devid] reg w [addr] [value] 			- write the regs with the switch devid \n", cmd);
-	printf(" 1.9) %s dev [devid] reg d [addr]				- dump the regs with the switch devid \n", cmd);
-	printf("																			\n");
+	printf(" 1.7) %s dev [devid] reg r [addr]				- read the reg with the switch devid\n", cmd);
+	printf(" 1.8) %s dev [devid] reg w [addr] [value]			- write the regs with the switch devid\n", cmd);
+	printf(" 1.9) %s dev [devid] reg d [addr]				- dump the regs with the switch devid\n", cmd);
+	printf("\n");
 
 	/* 2. phy operations */
 	printf("2) mt753x switch PHY operations===================================================================================================================>>>>\n");
@@ -42,13 +46,13 @@
 	printf(" 2.4) %s phy cl22 w [port_num] [phy_reg] [value]		- write specific phy register of specific port by clause 22\n", cmd);
 	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);
 	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);
-	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);
-	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);
+	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);
+	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);
 	printf(" 2.9) %s trreg r [port_num] [ch_addr] [node_addr] [data_addr]	- read phy token-ring of specific port\n", cmd);
 	printf(" 2.10) %s trreg w [port_num] [ch_addr] [node_addr] [data_addr]	- write phy token-ring of specific port\n", cmd);
-	printf("		[high_value] [low_value]									\n");
+	printf("		[high_value] [low_value]\n");
 	printf(" 2.11) %s crossover [port_num] [mode auto|mdi|mdix]		- switch auto or force mdi/mdix mode for crossover cable\n", cmd);
-	printf("																			\n");
+	printf("\n");
 
 	/* 3. mac operations */
 	printf("3) mt753x switch MAC operations====================================================================================================================>>>>\n");
@@ -65,35 +69,35 @@
 	printf(" 3.11) %s filt [mac] [portmap]					- add a SA filtering entry (with portmap)to switch mac table\n", cmd);
 	printf(" 3.12) %s filt [mac] [portmap] [vlan id				- add a SA filtering entry (with portmap, vlan id)to switch mac table\n", cmd);
 	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);
-	printf(" 3.14) %s arl aging [active:0|1] [time:1~65536]			- set switch arl aging timeout value \n", cmd);
-	printf(" 3.15) %s macctl fc [enable|disable]				- set switch mac global flow control,enable is 1, disable is 0 \n", cmd);
-	printf("																			\n");
+	printf(" 3.14) %s arl aging [active:0|1] [time:1~65536]			- set switch arl aging timeout value\n", cmd);
+	printf(" 3.15) %s macctl fc [enable|disable]				- set switch mac global flow control,enable is 1, disable is 0\n", cmd);
+	printf("\n");
 
 	/* 4. mib counter operations */
 	printf("4) mt753x switch mib counter operations============================================================================================================>>>>\n");
-	printf(" 4.1) %s esw_cnt get						-get switch mib counters          \n", cmd);
-	printf(" 4.2) %s esw_cnt clear						-clear switch mib counters         \n", cmd);
-	printf(" 4.3) %s output_queue_cnt get					-get switch output queue counters \n", cmd);
-	printf(" 4.4) %s free_page get						-get switch system free page counters  \n", cmd);
-	printf("																			\n");
+	printf(" 4.1) %s esw_cnt get						-get switch mib counters\n", cmd);
+	printf(" 4.2) %s esw_cnt clear						-clear switch mib counters\n", cmd);
+	printf(" 4.3) %s output_queue_cnt get					-get switch output queue counters\n", cmd);
+	printf(" 4.4) %s free_page get						-get switch system free page counters\n", cmd);
+	printf("\n");
 
 	/* 5. acl function operations */
 	printf("5) mt753x switch acl function operations============================================================================================================>>>>\n");
-	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);
-	printf(" 5.2) %s acl etype add [ethtype] [portmap]			- drop L2 ethertype packets \n", cmd);
-	printf(" 5.3) %s acl dmac add [mac] [portmap]				- drop L2 dest-Mac packets \n", cmd);
-	printf(" 5.4) %s acl dip add [dip] [portmap]				- drop dip packets \n", cmd);
+	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);
+	printf(" 5.2) %s acl etype add [ethtype] [portmap]			- drop L2 ethertype packets\n", cmd);
+	printf(" 5.3) %s acl dmac add [mac] [portmap]				- drop L2 dest-Mac packets\n", cmd);
+	printf(" 5.4) %s acl dip add [dip] [portmap]				- drop dip packets\n", cmd);
 	printf(" 5.5) %s acl port add [sport] [portmap]				- drop L4 UDP/TCP source port packets\n", cmd);
 	printf(" 5.6) %s acl L4 add [2byes] [portmap]				- drop L4 packets with 2bytes payload\n", cmd);
-	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);
-	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);
-	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);
-	printf(" 5.10) %s acl ratetbl-add [tbl_idx:0~31] [vawd1] [vawd2] 	- set switch acl rate table new entry  \n", cmd);
-	printf(" 5.11) %s acl dip meter [dip] [portmap][meter:kbps]		- rate limit dip packets \n", cmd);
-	printf(" 5.12) %s acl dip trtcm [dip] [portmap][CIR:kbps][CBS][PIR][PBS]- TrTCM dip packets \n", cmd);
-	printf(" 5.13) %s acl dip modup [dip] [portmap][usr_pri]		- modify usr priority from ACL \n", cmd);
-	printf(" 5.14) %s acl dip pppoe [dip] [portmap]				- pppoe header removal \n", cmd);
-	printf("																			\n");
+	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);
+	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);
+	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);
+	printf(" 5.10) %s acl ratetbl-add [tbl_idx:0~31] [vawd1] [vawd2]	- set switch acl rate table new entry\n", cmd);
+	printf(" 5.11) %s acl dip meter [dip] [portmap][meter:kbps]		- rate limit dip packets\n", cmd);
+	printf(" 5.12) %s acl dip trtcm [dip] [portmap][CIR:kbps][CBS][PIR][PBS]- TrTCM dip packets\n", cmd);
+	printf(" 5.13) %s acl dip modup [dip] [portmap][usr_pri]		- modify usr priority from ACL\n", cmd);
+	printf(" 5.14) %s acl dip pppoe [dip] [portmap]				- pppoe header removal\n", cmd);
+	printf("\n");
 
 	/* 6. dip table operations */
 	printf("6) mt753x switch dip table operations=================================================================================================================>>>>\n");
@@ -101,7 +105,7 @@
 	printf(" 6.2) %s dip clear						- clear switch dip table\n", cmd);
 	printf(" 6.3) %s dip add [dip] [portmap]				- add a dip entry to switch table\n", cmd);
 	printf(" 6.4) %s dip del [dip]						- del a dip entry to switch table\n", cmd);
-	printf("																			\n");
+	printf("\n");
 
 	/* 7. sip table operations */
 	printf("7) mt753x switch sip table operations=================================================================================================================>>>>\n");
@@ -109,36 +113,36 @@
 	printf(" 7.2) %s sip clear						- clear switch sip table\n", cmd);
 	printf(" 7.3) %s sip add [sip] [dip] [portmap]				- add a sip entry to switch table\n", cmd);
 	printf(" 7.4) %s sip del [sip] [dip]					- del a sip entry to switch table\n", cmd);
-	printf("																			\n");
+	printf("\n");
 
 	/* 8. vlan table operations */
 	printf("8) mt753x switch sip table operations====================================================================================================================>>>>\n");
 	printf(" 8.1) %s vlan dump (egtag)					- dump switch vlan table (with per port eg_tag setting)\n", cmd);
 	printf(" 8.2) %s vlan set [fid:0~7] [vid] [portmap]			- set vlan id and associated member at switch vlan table\n", cmd);
-	printf("			([stag:0~4095] [eg_con:0|1] [egtagPortMap 0:untagged 2:tagged]) \n");
+	printf("			([stag:0~4095] [eg_con:0|1] [egtagPortMap 0:untagged 2:tagged])\n");
 	printf("			Full Example: %s vlan set 0 3 10000100 0 0 20000200\n", cmd);
-	printf(" 8.3) %s vlan vid [vlan idx] [active:0|1] [vid] [portMap] 	- set switch vlan vid elements  \n", cmd);
-	printf("			[egtagPortMap] [ivl_en] [fid] [stag]							 \n");
-	printf(" 8.4) %s vlan pvid [port] [pvid]				- set switch vlan pvid  \n", cmd);
-	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);
-	printf("									admit only vlan-taged frames: 1,admit only untagged or priority-tagged frames: 2, reserved:3 \n");
-	printf(" 8.6) %s vlan port-attr [port] [attr:0~3]			- set switch vlan port attribute: user port: 0, statck port: 1, \n", cmd);
-	printf("									translation port: 2, transparent port:3        \n");
-	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);
-	printf("									check mode: 2, security mode:3                    \n");
-	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);
-	printf("									reserved:3,untagged:4,swap:5,tagged:6, stack:7                 \n");
-	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);
-	printf("																			\n");
+	printf(" 8.3) %s vlan vid [vlan idx] [active:0|1] [vid] [portMap]	- set switch vlan vid elements\n", cmd);
+	printf("			[egtagPortMap] [ivl_en] [fid] [stag]\n");
+	printf(" 8.4) %s vlan pvid [port] [pvid]				- set switch vlan pvid\n", cmd);
+	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);
+	printf("									admit only vlan-taged frames: 1,admit only untagged or priority-tagged frames: 2, reserved:3\n");
+	printf(" 8.6) %s vlan port-attr [port] [attr:0~3]			- set switch vlan port attribute: user port: 0, statck port: 1,\n", cmd);
+	printf("									translation port: 2, transparent port:3\n");
+	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);
+	printf("									check mode: 2, security mode:3\n");
+	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);
+	printf("									reserved:3,untagged:4,swap:5,tagged:6, stack:7\n");
+	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);
+	printf("\n");
 
 	/* 9. rate limit operations */
 	printf("9) mt753x switch rate limit operations=================================================================================================================>>>>\n");
-	printf(" 9.1) %s ratectl [in_ex_gress:0|1] [port] [rate]		- set switch port ingress(1) or egress(0) rate  \n", cmd);
-	printf(" 9.2) %s ingress-rate on [port] [Kbps]				- set ingress rate limit on port n (n= 0~ switch max port) \n", cmd);
-	printf(" 9.3) %s egress-rate on [port] [Kbps]				- set egress rate limit on port n (n= 0~ switch max port) \n", cmd);
-	printf(" 9.4) %s ingress-rate off [port]				- disable ingress rate limit on port n (n= 0~ switch max port) \n", cmd);
+	printf(" 9.1) %s ratectl [in_ex_gress:0|1] [port] [rate]		- set switch port ingress(1) or egress(0) rate\n", cmd);
+	printf(" 9.2) %s ingress-rate on [port] [Kbps]				- set ingress rate limit on port n (n= 0~ switch max port)\n", cmd);
+	printf(" 9.3) %s egress-rate on [port] [Kbps]				- set egress rate limit on port n (n= 0~ switch max port)\n", cmd);
+	printf(" 9.4) %s ingress-rate off [port]				- disable ingress rate limit on port n (n= 0~ switch max port)\n", cmd);
 	printf(" 9.5) %s egress-rate off [port]					- disable egress rate limit on port n (n= 0~ switch max port)\n", cmd);
-	printf("																			\n");
+	printf("\n");
 
 	/* 10. igmp operations */
 	printf("10) mt753x igmp operations===============================================================================================================================>>>>\n");
@@ -147,37 +151,37 @@
 	printf(" 10.2) %s igmpsnoop off						- turn off IGMP snoop and router port learning\n", cmd);
 	printf(" 10.3) %s igmpsnoop enable [port#]				- enable IGMP HW leave/join/Squery/Gquery\n", cmd);
 	printf(" 10.4) %s igmpsnoop disable [port#]				- disable IGMP HW leave/join/Squery/Gquery\n", cmd);
-	printf("																			\n");
+	printf("\n");
 
 	/* 11. QoS operations */
 	printf("11) mt753x QoS operations================================================================================================================================>>>>\n");
-	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);
-	printf(" 11.2) %s qos base [port:0~6] [base]					- set switch qos base(UPW); port-based:0, tag-based:1, \n", cmd);
-	printf("									dscp-based:2, acl-based:3, arl-based:4, stag-based:5   \n");
-	printf(" 11.3) %s qos port-weight [port:0~6] [q0] [q1][q2][q3]		- set switch qos port queue weight; \n", cmd);
-	printf("				[q4][q5][q6][q7]				 [qn]: the weight of queue n, range: 1~16     \n");
-	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);
-	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);
-	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);
-	printf("																			\n");
+	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);
+	printf(" 11.2) %s qos base [port:0~6] [base]					- set switch qos base(UPW); port-based:0, tag-based:1,\n", cmd);
+	printf("									dscp-based:2, acl-based:3, arl-based:4, stag-based:5\n");
+	printf(" 11.3) %s qos port-weight [port:0~6] [q0] [q1][q2][q3]		- set switch qos port queue weight;\n", cmd);
+	printf("				[q4][q5][q6][q7]				 [qn]: the weight of queue n, range: 1~16\n");
+	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);
+	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);
+	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);
+	printf("\n");
 
 	/*12. port mirror operations*/
 	printf(" 12) mt753x port mirror operations========================================================================================================================>>>>\n");
 	printf(" 12.1) %s mirror monitor [port]					- enable port mirror and indicate monitor port number\n", cmd);
 	printf(" 12.2) %s mirror target  [port]					- set port mirror target\n", cmd);
-	printf("			[direction| 0:off, 1:rx, 2:tx, 3:all]					\n");
-	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);
+	printf("			[direction| 0:off, 1:rx, 2:tx, 3:all]\n");
+	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);
 	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);
-	printf("				[port_rx_mir:0|1] [acl_mir:0|1]						\n");
-	printf("				[vlan_mis:0|1] [igmp_mir:0|1]						\n");
-	printf("																			\n");
+	printf("				[port_rx_mir:0|1] [acl_mir:0|1]\n");
+	printf("				[vlan_mis:0|1] [igmp_mir:0|1]\n");
+	printf("\n");
 
 	/*13. stp function*/
 	printf(" 13) mt753x stp operations===============================================================================================================================>>>>\n");
-	printf(" 13.1) %s stp [port] [fid] [state]				- set switch spanning tree state, port is 0~6, fid is 0~7,  \n", cmd);
-	printf("									state is 0~3(Disable/Discarding:0,Blocking/Listening/Discarding:1,) \n");
-	printf("									Learning:2,Forwarding:3 \n");
-	printf("																			\n");
+	printf(" 13.1) %s stp [port] [fid] [state]				- set switch spanning tree state, port is 0~6, fid is 0~7,\n", cmd);
+	printf("									state is 0~3(Disable/Discarding:0,Blocking/Listening/Discarding:1,)\n");
+	printf("									Learning:2,Forwarding:3\n");
+	printf("\n");
 
 	/*14. collision pool operations*/
 	printf("14) mt753x collision pool operations========================================================================================================================>>>>\n");
@@ -185,20 +189,235 @@
 	printf(" 14.2) %s collision-pool mac dump				- dump collision pool mac table\n", cmd);
 	printf(" 14.3) %s collision-pool dip dump				- dump collision pool dip table\n", cmd);
 	printf(" 14.4) %s collision-pool sip dump				- dump collision pool sip table\n", cmd);
-	printf("																			\n");
+	printf("\n");
 
 	/*15. pfc(priority flow control) operations*/
 	printf("15) mt753x pfc(priority flow control) operations==============================================================================================================>>>>\n");
-	printf(" 15.1) %s pfc enable [port] [enable 0|1]			- enable or disable port's pfc \n", cmd);
-	printf(" 15.2) %s pfc rx_counter [port]					- get port n pfc 8 up rx counter \n", cmd);
-	printf(" 15.3) %s pfc tx_counter [port]					- get port n pfc 8 up rx counter \n", cmd);
-	printf("																			\n");
+	printf(" 15.1) %s pfc enable [port] [enable 0|1]			- enable or disable port's pfc\n", cmd);
+	printf(" 15.2) %s pfc rx_counter [port]					- get port n pfc 8 up rx counter\n", cmd);
+	printf(" 15.3) %s pfc tx_counter [port]					- get port n pfc 8 up rx counter\n", cmd);
+	printf("\n");
 
 	/*15. pfc(priority flow control) operations*/
 	printf("16) mt753x EEE(802.3az) operations==============================================================================================================>>>>\n");
 	printf(" 16.1) %s eee enable [enable 0|1] ([portMap])			- enable or disable EEE (by portMap)\n", cmd);
 	printf(" 16.2) %s eee dump ([port])					- dump EEE capability (by port)\n", cmd);
-	printf("																			\n");
+	printf("\n");
+
+	if (chip_name == 0x8855) {
+		printf("switch an8855 <sub cmd> supported commands===================================================================================================================>>>>\n");
+		printf("\n");
+		printf("Register/GPHY access commands===============================================================================================================>>>>\n");
+		printf("reg r <reg(4'hex)>\n");
+		printf("reg w <reg(4'hex)> <value(8'hex)>\n");
+		printf("phy cl22 r <port(0..4)> <reg(2'hex)>\n");
+		printf("phy cl22 w <port(0..4)> <reg(2'hex)> <value(4'hex)>\n");
+		printf("phy cl45 r <port(0..4)> <dev(2'hex)> <reg(3'hex)>\n");
+		printf("phy cl45 w <port(0..4)> <dev(2'hex)> <reg(3'hex)> <value(4'hex)>\n");
+		printf("\n");
+		printf("Port configuration commands=================================================================================================================>>>>\n");
+		printf("port set matrix <port(0..6)> <matrix(6:0)>\n");
+		printf("port get matrix <port(0..6)>\n");
+		printf("port set vlanMode <port(0..6)> <vlanMode(0:matrix,1:fallback,2:check,3:security)>\n");
+		printf("port get vlanMode <port(0..6)>\n");
+		printf("port set flowCtrl <port(0..6)> <dir(0:Tx,1:Rx)> <fc_en(1:En,0:Dis)>\n");
+		printf("port get flowCtrl <port(0..6)> <dir(0:Tx,1:Rx)>\n");
+		printf("port set jumbo <pkt_len(0:1518,1:1536,2:1552,3:max)> <frame_len(2..15)>\n");
+		printf("port get jumbo\n");
+		printf("port set anMode <port(0..4)> <en(0:force,1:AN)>\n");
+		printf("port get anMode <port(0..4)>\n");
+		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");
+		printf("port get localAdv <port(0..4)>\n");
+		printf("port get remoteAdv <port(0..4)>\n");
+		printf("port set speed <port(0..4)> <speed(0:10M,1:100M,2:1G,3:2.5G)>\n");
+		printf("port get speed <port(0..4)>\n");
+		printf("port set duplex <port(0..4)> <duplex(0:half,1:full)>\n");
+		printf("port get duplex <port(0..4)>\n");
+		printf("port get status <port(0..4)>\n");
+		printf("port set bckPres <port(0..6)> <bckPres(1:En,0:Dis)>\n");
+		printf("port get bckPres <port(0..6)>\n");
+		printf("port set psMode <port(0..4)> <ls(1:En,0:Dis)> <eee(1:En,0:Dis)>\n");
+		printf("port get psMode <port(0..4)>\n");
+		printf("port set smtSpdDwn <port(0..4)> <en(1:En,0:Dis)> <retry(2..5)>\n");
+		printf("port get smtSpdDwn <port(0..4)>\n");
+		printf("port set spTag <port(0..6)> <en(1:En,0:Dis)>\n");
+		printf("port get spTag <port(0..6)>\n");
+		printf("port set enable <port(0..4)> <en(1:En,0:Dis)>\n");
+		printf("port get enable <port(0..4)>\n");
+		printf("port set 5GBaseRMode\n");
+		printf("port set hsgmiiMode\n");
+		printf("port set sgmiiMode <mode(0:AN,1:Force)> <speed(0:10M,1:100M,2:1G)>\n");
+		printf("port set rmiiMode <speed(0:10M,1:100M)>\n");
+		printf("port set rgmiiMode <speed(0:10M,1:100M,2:1G)>\n");
+		printf("\n");
+		printf("Special tag commands========================================================================================================================>>>>\n");
+		printf("sptag  setEnable port<port(0..6)> enable<1:enable 0:disable>\n");
+		printf("sptag  getEnable port<port(0..6)>\n");
+		printf("sptag  setmode port<port(0..6)> mode<0:inset 1:replace>\n");
+		printf("sptag  getmode port<port(0..6)>\n");
+		printf("sptag  encode mode={ insert | replace } opc={ portmap | portid | lookup } dp={bitimap hex} vpm={ untagged | 8100 | 88a8 } pri=<UINT> cfi=<UINT> vid=<UINT>\n");
+		printf("sptag  decode <byte(hex)> <byte(hex)> <byte(hex)> <byte(hex)>\n");
+		printf("\n");
+		printf("Vlan commands===============================================================================================================================>>>>\n");
+		printf("sptag  set fid <vid(0..4095)> <fid(0..7)>\n");
+		printf("sptag  set memPort <vid(0..4095)> <bitmap(6:0)>\n");
+		printf("sptag  set ivl <vid(0..4095)> <(1:En,0:Dis)>\n");
+		printf("sptag  set portBaseStag <vid(0..4095)> <(1:En,0:Dis)>\n");
+		printf("sptag  set stag <vid(0..4095)> <stag(0..4095)>\n");
+		printf("sptag  set egsTagCtlEn <vid(0..4095)> <(1:En,0:Dis)>\n");
+		printf("sptag  set egsTagCtlCon <vid(0..4095)> <(1:En,0:Dis)>\n");
+		printf("sptag  set egsTagCtl <vid(0..4095)> <port(0..6)> <ctlType(0:untag,2:tagged)>\n");
+		printf("sptag  set portActFrame <port(0..6)> <frameType(0:all,1:tagged,2:untagged)>\n");
+		printf("sptag  get portActFrame <port(0..6)>\n");
+		printf("sptag  set LeakyVlanEn <port(0..6)> <pktType(0:uc,1:mc,2:bc,3:ipmc)> <(1:En,0:Dis)>\n");
+		printf("sptag  get leakyVlanEn <port(0..6)>\n");
+		printf("sptag  set portVlanAttr <port(0..6)> <vlanAttr(0:user,1:stack,2:translation,3:transparent)>\n");
+		printf("sptag  get portVlanAttr <port(0..6)>\n");
+		printf("sptag  set igsPortETagAttr <port(0..6)> <egsTagAttr(0:disable,1:consistent,4:untagged,5:swap,6:tagged,7:stack)>\n");
+		printf("sptag  get igsPortETagAttr <port(0..6)>\n");
+		printf("sptag  set portEgsTagAttr <port(0..6)> <egsTagAttr(0:untagged,1:swap,2:tagged,3:stack)>\n");
+		printf("sptag  get portEgsTagAttr <port(0..6)>\n");
+		printf("sptag  set portOuterTPID <port(0..6)> <TPID(hex)>\n");
+		printf("sptag  get portOuterTPID <port(0..6)>\n");
+		printf("sptag  set pvid <port(0..6)> <vid(0..4095)>\n");
+		printf("sptag  get pvid <port(0..6)>\n");
+		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");
+		printf("sptag  create <vid(0..4095)>\n");
+		printf("sptag  destroy [ <vid(0..4095)> | <vidRange(vid0-vid1)> ]\n");
+		printf("sptag  destroyAll [ <restoreDefVlan(0:false,1:true)> | ]\n");
+		printf("sptag  dump [ <vid(0..4095)> | <vidRange(vid0-vid1)> | ]\n");
+		printf("sptag  addPortMem <vid(0..4095)> <port(0..6)>\n");
+		printf("sptag  addPortMem <vid(0..4095)> <port(0..6)>\n");
+		printf("\n");
+		printf("Layer2 commands=============================================================================================================================>>>>\n");
+		printf("l2 dump mac\n");
+		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");
+		printf("l2 del mac <mac(12'hex)> [ vid <vid(0..4095)> | fid <fid(0..15)> ]\n");
+		printf("l2 get mac <mac(12'hex)> [ vid <vid(0..4095)> | fid <fid(0..15)> ]\n");
+		printf("l2 clear mac\n");
+		printf("l2 set macAddrAgeOut <time(1, 1000000)>\n");
+		printf("l2 get macAddrAgeOut\n");
+		printf("\n");
+		printf("Link Aggregation commands===================================================================================================================>>>>\n");
+		printf("lag set member <group_id(0 or 1)> <member_index(0..3)> <enable(0,1)> <port index(0..6)>\n");
+		printf("lag get member group_id(0 or 1)\n");
+		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");
+		printf("lag get dstInfo\n");
+		printf("lag set ptseed <hex32>\n");
+		printf("lag get ptseed\n");
+		printf("lag set hashtype <0-crc32lsb;1-crc32msb;2-crc16;3-xor4>\n");
+		printf("lag get hashtype\n");
+		printf("lag set state <state(1:En,0:Dis)>\n");
+		printf("lag get state\n");
+		printf("lag set spsel <soure port enable(1:En,0:Dis)>\n");
+		printf("lag get spsel\n");
+		printf("\n");
+		printf("STP commands================================================================================================================================>>>>\n");
+		printf("stp set portstate <port(0..6)> <fid(0..15)> <state(0:disable,1:listen,2:learn,3:forward)>\n");
+		printf("stp get portstate <port(0..6)> <fid(0..15)>\n");
+		printf("\n");
+		printf("Mirror commands=============================================================================================================================>>>>\n");
+		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");
+		printf("mirror set session-enable <sid(0,1)> <state(1:En,0:Dis)>\n");
+		printf("mirror add session-rlist <sid(0,1)> <list(UINTLIST)>\n");
+		printf("mirror add session-tlist <sid(0,1)> <list(UINTLIST)>\n");
+		printf("mirror get session <sid(0,1)>\n");
+		printf("mirror del session <sid(0,1)>\n");
+		printf("\n");
+		printf("MIB commands================================================================================================================================>>>>\n");
+		printf("mib get port <port(0..6)>\n");
+		printf("mib get acl <event(0..7)>\n");
+		printf("mib clear port <port(0..6)>\n");
+		printf("mib clear all\n");
+		printf("mib clear acl\n");
+		printf("\n");
+		printf("QoS commands================================================================================================================================>>>>\n");
+		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");
+		printf("qos get scheduleAlgo <portlist(UINTLIST)> <queue(UINT)>\n");
+		printf("qos set trustMode <portlist(UINTLIST)> <mode(0:port,1:1p-port,2:dscp-port,3:dscp-1p-port>\n");
+		printf("qos get trustMode <portlist(UINTLIST)>\n");
+		printf("qos set pri2Queue <priority(0..7)> <queue(0..7)>\n");
+		printf("qos get pri2Queue\n");
+		printf("qos set dscp2Pri <dscp(0..63)> <priority(0..7)>\n");
+		printf("qos get dscp2Pri <dscp(0..63)>\n");
+		printf("qos set rateLimitEnable <portlist(UINTLIST)> <dir(0:egress,1:ingress)> <rate_en(1:En,0:Dis)>\n");
+		printf("qos get rateLimitEnable <portlist(UINTLIST)>\n");
+		printf("qos set rateLimit <portlist(UINTLIST)> <I_CIR(0..80000)> <I_CBS(0..127)> <E_CIR(0..80000)> <E_CBS(0..127)>\n");
+		printf("qos get rateLimit <portlist(UINTLIST)>\n");
+		printf("qos set portPriority <portlist(UINTLIST)> <priority(0..7)>\n");
+		printf("qos get portPriority <portlist(UINTLIST)>\n");
+		printf("qos set rateLmtExMngFrm <dir(0:egress)> <en(0:include,1:exclude)>\n");
+		printf("qos get rateLmtExMngFrm\n");
+		printf("\n");
+		printf("Diag commands===============================================================================================================================>>>>\n");
+		printf("diag set txComply <phy(0..4)> <mode(0..8)>\n");
+		printf("diag get txComply <phy(0..4)>\n");
+		printf("\n");
+		printf("LED commands================================================================================================================================>>>>\n");
+		printf("led set mode <mode(0:disable, 1..3:2 LED, 4:user-define)>\n");
+		printf("led get mode\n");
+		printf("led set state <led(0..1)> <state(1:En,0:Dis)>\n");
+		printf("led get state <led(0..1)>\n");
+		printf("led set usr <led(0..1)> <polarity(0:low, 1:high)> <on_evt(7'bin)> <blink_evt(10'bin)>\n");
+		printf("led get usr <led(0..1)>\n");
+		printf("led set time <time(0..5:32ms~1024ms)>\n");
+		printf("led get time\n");
+		printf("\n");
+		printf("Security commands===========================================================================================================================>>>>\n");
+		printf("sec set stormEnable <port(0..6)> <type(0:bcst,1:mcst,2:ucst)> <en(1:En,0:Dis)>\n");
+		printf("sec get stormEnable <port(0..6)> <type(0:bcst,1:mcst,2:ucst)>\n");
+		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");
+		printf("sec get stormRate <port(0..6)> <type(0:bcst,1:mcst,2:ucst)>\n");
+		printf("sec set fldMode <port(0..6)> <type(0:bcst,1:mcst,2:ucst,3:qury> <en(1:En,0:Dis)>\n");
+		printf("sec get fldMode <port(0..6)> <type(0:bcst,1:mcst,2:ucst,3:qury>\n");
+		printf("sec set saLearning <port(0..6)> <learn(0:disable,1:enable)>\n");
+		printf("sec get saLearning <port(0..6)>\n");
+		printf("sec set saLimit <port(0..6)> <mode(0:disable,1:enable)> <count(0..4095)>\n");
+		printf("sec get saLimit <port(0..6)>\n");
+		printf("\n");
+		printf("Switch commands=============================================================================================================================>>>>\n");
+		printf("switch set cpuPortEn <cpu_en(1:En,0:Dis)>\n");
+		printf("switch get cpuPortEn\n");
+		printf("switch set cpuPort <port_number>\n");
+		printf("switch get cpuPort\n");
+		printf("switch set phyLCIntrEn <phy(0..6)> <(1:En,0:Dis)>\n");
+		printf("switch get phyLCIntrEn <phy(0..6)>\n");
+		printf("switch set phyLCIntrSts <phy(0..6)> <(1:Clear)>\n");
+		printf("switch get phyLCIntrSts <phy(0..6)>\n");
+		printf("\n");
+		printf("ACL commands================================================================================================================================>>>>\n");
+		printf("acl set en <en(1:En,0:Dis)>\n");
+		printf("acl get en\n");
+		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)> ] ");
+		printf("acl get rule <idx(0..127)> ");
+		printf("acl del rule <idx(0..127)>\n");
+		printf("acl clear rule\n");
+		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");
+		printf("acl get udfRule <idx(0..15)>\n");
+		printf("acl del udfRule <idx(0..15)>\n");
+		printf("acl clear udfRule\n");
+		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)> ] ]");
+		printf("acl get action <idx(0..127)>\n");
+		printf("acl del action <idx(0..127)>\n");
+		printf("acl clear action\n");
+		printf("acl set trtcm <idx(1..31)> <cir(4'hex)> <pir(4'hex)> <cbs(4'hex)> <pbs(4'hex)>\n");
+		printf("acl get trtcm <idx(1..31)>\n");
+		printf("acl del trtcm <idx(0..31)>\n");
+		printf("acl clear trtcm\n");
+		printf("acl set trtcmEn <en(1:En,0:Dis)>\n");
+		printf("acl get trtcmEn\n");
+		printf("acl set portEn <port(0..6)> <en(1:En,0:Dis)>\n");
+		printf("acl get portEn <port(0..6)>\n");
+		printf("acl set dropEn <port(0..6)> <en(1:En,0:Dis)>\n");
+		printf("acl get dropEn <port(0..6)>\n");
+		printf("acl set dropThrsh <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)> <high(0..2047)> <low(0..2047)>\n");
+		printf("acl get dropThrsh <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)>\n");
+		printf("acl set dropPbb <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)> <probability(0..1023)>\n");
+		printf("acl get dropPbb <port(0..6)> <color(0:green,1:yellow,2:red)> <queue(0..7)>\n");
+		printf("acl set meter <idx(0..31)> <en(1:En,0:Dis)> <rate(0..65535)>\n Note: Limit rate = rate * 64Kbps");
+		printf("acl get meter <idx(0..31)>\n");
+		printf("\n");
+	}
 
 	exit_free();
 	exit(0);
@@ -227,7 +446,8 @@
 			for (i = 0; i < 16; i++) {
 				printf("0x%08x: ", off + 0x10 * i);
 				for (j = 0; j < 4; j++) {
-					reg_read(off + i * 0x10 + j * 0x4, &val);
+					reg_read(off + i * 0x10 + j * 0x4,
+						 &val);
 					printf(" 0x%08x", val);
 				}
 				printf("\n");
@@ -240,30 +460,35 @@
 
 static int get_chip_name()
 {
-	int temp;
+	int temp = 0, rc = 0;
 	FILE *fp = NULL;
 	char buff[255];
 
-	/*judge 7530*/
+	/*judge 7530 */
 	reg_read((0x7ffc), &temp);
 	temp = temp >> 16;
 	if (temp == 0x7530)
 		return temp;
-	/*judge 7531*/
+	/*judge 7531 */
 	reg_read(0x781c, &temp);
 	temp = temp >> 16;
 	if (temp == 0x7531)
 		return temp;
+	/*judge an8855 */
+	reg_read(0x10005000, &temp);
+	if (temp == 0x8855)
+		return temp;
 
-	/*judge jaguar embedded switch*/
+	/*judge jaguar embedded switch */
 	fp = fopen("/proc/device-tree/compatible", "r");
 	if (fp != NULL) {
 		temp = -1;
-		if (fgets(buff, 255, (FILE *)fp) && strstr(buff, "mt7988"))
+		if (fgets(buff, 255, (FILE *) fp) && strstr(buff, "mt7988"))
 			temp = 0x7988;
 
-		fclose(fp);
-		return temp;
+		rc = fclose(fp);
+		if (rc == 0)
+			return temp;
 	}
 
 	return -1;
@@ -271,10 +496,10 @@
 
 static int phy_operate(int argc, char *argv[])
 {
-	unsigned int port_num;
-	unsigned int dev_num;
-	unsigned int value, cl_value;
-	unsigned int reg;
+	unsigned int port_num = 0;
+	unsigned int dev_num = 0;
+	unsigned int value = 0, cl_value = 0;
+	unsigned int reg = 0;
 	int ret = 0, cl_ret = 0;
 	char op;
 
@@ -283,65 +508,125 @@
 
 	op = argv[3][0];
 
-	switch(op) {
-		case 'r':
-			reg = strtoul(argv[argc-1], NULL, 0);
-			if (argc == 6) {
-				port_num = strtoul(argv[argc-2], NULL, 0);
-				ret = mii_mgr_read(port_num, reg, &value);
-				if (ret < 0)
-					printf(" Phy read reg fail\n");
-				else
-					printf(" Phy read reg=0x%x, value=0x%x\n", reg, value);
-			} else if (argc == 7) {
-				dev_num = strtoul(argv[argc-2], NULL, 0);
-				port_num = strtoul(argv[argc-3], NULL, 0);
-				ret = mii_mgr_c45_read(port_num, dev_num, reg, &value);
-				if (ret < 0)
-					printf(" Phy read reg fail\n");
-				else
-					printf(" Phy read reg=0x%x, value=0x%x\n", reg, value);
-			} else
-				ret = phy_dump(32);
+	switch (op) {
+	case 'r':
+		reg = strtoul(argv[argc - 1], NULL, 16);
+		if (reg >= 0xFFFFFFFF) {
+			printf(" Phy read reg fail\n");
+			ret = -1;
 			break;
-		case 'w':
-			reg = strtoul(argv[argc-2], NULL, 0);
-			value = strtoul(argv[argc-1], NULL, 0);
-			if (argc == 7) {
-				port_num = strtoul(argv[argc-3], NULL, 0);
-				ret = mii_mgr_write(port_num, reg, value);
-				cl_ret = mii_mgr_read(port_num, reg, &cl_value);
-				if (cl_ret < 0)
-					printf(" Phy read reg fail\n");
-				else
-					printf(" Phy read reg=0x%x, value=0x%x\n", reg, cl_value);
+		}
+
+		if (argc == 6) {
+			port_num = strtoul(argv[argc - 2], NULL, 0);
+			if (port_num > MAX_PORT) {
+				printf(" Phy read reg fail\n");
+				ret = -1;
+				break;
 			}
-			else if (argc == 8) {
-				dev_num = strtoul(argv[argc-3], NULL, 0);
-				port_num = strtoul(argv[argc-4], NULL, 0);
-				ret = mii_mgr_c45_write(port_num, dev_num, reg, value);
-				cl_ret = mii_mgr_c45_read(port_num, dev_num, reg, &cl_value);
-				if (cl_ret < 0)
-					printf(" Phy read reg fail\n");
-				else
-					printf(" Phy read reg=0x%x, value=0x%x\n", reg, cl_value);
+
+			ret = mii_mgr_read(port_num, reg, &value);
+			if (ret < 0)
+				printf(" Phy read reg fail\n");
+			else
+				printf(" Phy read reg=0x%x, value=0x%x\n",
+				       reg, value);
+		} else if (argc == 7) {
+			dev_num = strtoul(argv[argc - 2], NULL, 16);
+			if (dev_num > 0xFFFFFFFF) {
+				printf(" Phy read reg fail\n");
+				ret = -1;
+				break;
 			}
+
+			port_num = strtoul(argv[argc - 3], NULL, 0);
+			if (port_num > MAX_PORT) {
+				printf(" Phy read reg fail\n");
+				ret = -1;
+				break;
+			}
+
+			ret = mii_mgr_c45_read(port_num, dev_num, reg,
+					       &value);
+			if (ret < 0)
+				printf(" Phy read reg fail\n");
 			else
-				usage(argv[0]);
+				printf(" Phy read dev_num=0x%x, reg=0x%x, value=0x%x\n",
+				       dev_num, reg, value);
+		} else
+			ret = phy_dump(32);
+		break;
+	case 'w':
+		reg = strtoul(argv[argc - 2], NULL, 16);
+		if (reg >= 0xFFFFFFFF) {
+			printf(" Phy write reg fail\n");
+			ret = -1;
 			break;
-		default:
+		}
+
+		value = strtoul(argv[argc - 1], NULL, 16);
+		if (value > 0xFFFF) {
+			printf(" Phy write reg fail\n");
+			ret = -1;
 			break;
+		}
+
+		if (argc == 7) {
+			port_num = strtoul(argv[argc - 3], NULL, 0);
+			if (port_num > MAX_PORT) {
+				printf(" Phy write reg fail\n");
+				ret = -1;
+				break;
+			}
+
+			ret = mii_mgr_write(port_num, reg, value);
+			cl_ret = mii_mgr_read(port_num, reg, &cl_value);
+			if (cl_ret < 0)
+				printf(" Phy write reg fail\n");
+			else
+				printf(" Phy write reg=0x%x, value=0x%x\n",
+				       reg, cl_value);
+		} else if (argc == 8) {
+			dev_num = strtoul(argv[argc - 3], NULL, 16);
+			if (dev_num > 0xFFFFFFFF) {
+				printf(" Phy write reg fail\n");
+				ret = -1;
+				break;
+			}
+
+			port_num = strtoul(argv[argc - 4], NULL, 0);
+			if (port_num > MAX_PORT) {
+				printf(" Phy write reg fail\n");
+				ret = -1;
+				break;
+			}
+
+			ret = mii_mgr_c45_write(port_num, dev_num, reg, value);
+			cl_ret = mii_mgr_c45_read(port_num, dev_num, reg,
+						  &cl_value);
+			if (cl_ret < 0)
+				printf(" Phy write reg fail\n");
+			else
+				printf(" Phy write dev_num=0x%x reg=0x%x, value=0x%x\n",
+				       dev_num, reg, cl_value);
+		}
+		break;
+	default:
+		break;
 	}
 
 	return ret;
 }
 
-
 int main(int argc, char *argv[])
 {
 	int err;
 
 	attres = (struct mt753x_attr *)malloc(sizeof(struct mt753x_attr));
+	if (attres == NULL) {
+		printf("Failed to allocate memory.\n");
+		exit(0);
+	}
 	attres->dev_id = -1;
 	attres->port_num = -1;
 	attres->phy_dev = -1;
@@ -357,30 +642,94 @@
 		if (!err)
 			chip_name = get_chip_name();
 	}
-	
+
+	err = mt753x_netlink_init(AN8855_DSA_GENL_NAME);
+	if (!err)
+		chip_name = get_chip_name();
+
+	if (err < 0) {
+		err = mt753x_netlink_init(AN8855_GENL_NAME);
+		if (!err)
+			chip_name = get_chip_name();
+	}
+
 	if (err < 0) {
 		err = switch_ioctl_init();
 		if (!err) {
 			nl_init_flag = false;
 			chip_name = get_chip_name();
 			if (chip_name < 0) {
-				printf("no chip unsupport or chip id is invalid!\n");
+				printf
+				    ("no chip unsupport or chip id is invalid!\n");
 				exit_free();
 				exit(0);
 			}
 		}
 	}
+#ifndef COMPAT_MODE
+	if (chip_name == 0x8855) {
+		AIR_INIT_PARAM_T init_param = { 0 };
 
+		init_param.printf = printf;
+		init_param.malloc = malloc;
+		init_param.free = free;
+		init_param.udelay = usleep;
+		init_param.dev_access.read_callback = an8855_reg_read;
+		init_param.dev_access.write_callback = an8855_reg_write;
+		init_param.dev_access.phy_read_callback = an8855_phy_cl22_read;
+		init_param.dev_access.phy_write_callback =
+		    an8855_phy_cl22_write;
+		init_param.dev_access.phy_cl45_read_callback =
+		    an8855_phy_cl45_read;
+		init_param.dev_access.phy_cl45_write_callback =
+		    an8855_phy_cl45_write;
+
+		air_init(0, &init_param);
+		air_parse_cmd((argc - 1), &argv[1]);
+	}
+
+	exit_free();
+	return 0;
+#else
 	if (argc < 2)
 		usage(argv[0]);
 
+	if (chip_name == 0x8855) {
+		AIR_INIT_PARAM_T init_param = { 0 };
+
+		init_param.printf = printf;
+		init_param.malloc = malloc;
+		init_param.free = free;
+		init_param.udelay = usleep;
+		init_param.dev_access.read_callback = an8855_reg_read;
+		init_param.dev_access.write_callback = an8855_reg_write;
+		init_param.dev_access.phy_read_callback = an8855_phy_cl22_read;
+		init_param.dev_access.phy_write_callback =
+		    an8855_phy_cl22_write;
+		init_param.dev_access.phy_cl45_read_callback =
+		    an8855_phy_cl45_read;
+		init_param.dev_access.phy_cl45_write_callback =
+		    an8855_phy_cl45_write;
+		air_init(0, &init_param);
+
+		p_switch_func = &an8855_switch_func;
+	} else {
+		p_switch_func = &mt753x_switch_func;
+	}
+
+	if ((argc > 2) && !strcmp(argv[1], "an8855")
+	    && (chip_name == 0x8855)) {
+		air_parse_cmd((argc - 2), (const char **)&argv[2]);
+		exit_free();
+		return 0;
+	}
+
 	if (!strcmp(argv[1], "dev")) {
 		attres->dev_id = strtoul(argv[2], NULL, 0);
 		argv += 2;
 		argc -= 2;
 		if (argc < 2)
 			usage(argv[0]);
-
 	}
 
 	if (argc == 2) {
@@ -388,60 +737,69 @@
 			attres->type = MT753X_ATTR_TYPE_MESG;
 			mt753x_list_swdev(attres, MT753X_CMD_REQUEST);
 		} else if (!strncmp(argv[1], "dump", 5)) {
-			table_dump();
+			p_switch_func->pf_table_dump(argc, argv);
 		} else if (!strncmp(argv[1], "clear", 6)) {
-			table_clear();
+			p_switch_func->pf_table_clear(argc, argv);
 			printf("done.\n");
 		} else if (!strncmp(argv[1], "reset", 5)) {
-			switch_reset(argc, argv);
+			p_switch_func->pf_switch_reset(argc, argv);
 		} else if (!strncmp(argv[1], "phy", 4)) {
-			phy_dump(32); //dump all phy register
+			phy_dump(32);	//dump all phy register
 		} else if (!strncmp(argv[1], "sysctl", 7)) {
-			if (nl_init_flag)
-				printf("netlink(%s)\n",MT753X_GENL_NAME);
-			else
-				printf("ioctl(%s)\n",ETH_DEVNAME);
+			if (nl_init_flag) {
+				if (chip_name == 0x8855)
+					printf("netlink(%s)\n",
+					       AN8855_GENL_NAME);
+				else
+					printf("netlink(%s)\n",
+					       MT753X_GENL_NAME);
+			} else
+				printf("ioctl(%s)\n", ETH_DEVNAME);
+		} else if (!strncmp(argv[1], "ver", 4)) {
+			if (chip_name == 0x8855)
+				printf("Switch APP version: %s\r\n",
+				       SWITCH_APP_VERSION);
 		} else
 			usage(argv[0]);
 	} else if (!strncmp(argv[1], "arl", 4)) {
 		if (!strncmp(argv[2], "aging", 6))
-			doArlAging(argc, argv);
+			p_switch_func->pf_doArlAging(argc, argv);
 	} else if (!strncmp(argv[1], "esw_cnt", 8)) {
 		if (!strncmp(argv[2], "get", 4))
-			read_mib_counters();
+			p_switch_func->pf_read_mib_counters(argc, argv);
 		else if (!strncmp(argv[2], "clear", 6))
-			clear_mib_counters();
+			p_switch_func->pf_clear_mib_counters(argc, argv);
 		else
 			usage(argv[0]);
-	}else if (!strncmp(argv[1], "output_queue_cnt", 17)) {
+	} else if (!strncmp(argv[1], "output_queue_cnt", 17)) {
 		if (!strncmp(argv[2], "get", 4))
-			read_output_queue_counters();
+			p_switch_func->pf_read_output_queue_counters(argc,
+								     argv);
 		else
 			usage(argv[0]);
-	}else if (!strncmp(argv[1], "free_page", 10)) {
+	} else if (!strncmp(argv[1], "free_page", 10)) {
 		if (!strncmp(argv[2], "get", 4))
-			read_free_page_counters();
+			p_switch_func->pf_read_free_page_counters(argc, argv);
 		else
 			usage(argv[0]);
-	}
-	else if (!strncmp(argv[1], "ratectl", 8))
-		rate_control(argc, argv);
+	} else if (!strncmp(argv[1], "ratectl", 8))
+		p_switch_func->pf_rate_control(argc, argv);
 	else if (!strncmp(argv[1], "add", 4))
-		table_add(argc, argv);
+		p_switch_func->pf_table_add(argc, argv);
 	else if (!strncmp(argv[1], "filt", 5))
-		table_add(argc, argv);
+		p_switch_func->pf_table_add(argc, argv);
 	else if (!strncmp(argv[1], "del", 4)) {
 		if (!strncmp(argv[4], "fid", 4))
-			table_del_fid(argc, argv);
+			p_switch_func->pf_table_del_fid(argc, argv);
 		else if (!strncmp(argv[4], "vid", 4))
-			table_del_vid(argc, argv);
+			p_switch_func->pf_table_del_vid(argc, argv);
 		else
 			usage(argv[0]);
 	} else if (!strncmp(argv[1], "search", 7)) {
 		if (!strncmp(argv[4], "fid", 4))
-			table_search_mac_fid(argc, argv);
+			p_switch_func->pf_table_search_mac_fid(argc, argv);
 		else if (!strncmp(argv[4], "vid", 4))
-			table_search_mac_vid(argc, argv);
+			p_switch_func->pf_table_search_mac_vid(argc, argv);
 		else
 			usage(argv[0]);
 	} else if (!strncmp(argv[1], "phy", 4)) {
@@ -466,70 +824,70 @@
 		if (argc < 3)
 			usage(argv[0]);
 		if (!strncmp(argv[2], "fc", 3))
-			global_set_mac_fc(argc, argv);
+			p_switch_func->pf_global_set_mac_fc(argc, argv);
 		else if (!strncmp(argv[2], "pfc", 4))
-			set_mac_pfc(argc, argv);
+			p_switch_func->pf_set_mac_pfc(argc, argv);
 		else
 			usage(argv[0]);
 	} else if (!strncmp(argv[1], "qos", 4)) {
 		if (argc < 3)
 			usage(argv[0]);
 		if (!strncmp(argv[2], "sch", 4))
-			qos_sch_select(argc, argv);
+			p_switch_func->pf_qos_sch_select(argc, argv);
 		else if (!strncmp(argv[2], "base", 5))
-			qos_set_base(argc, argv);
+			p_switch_func->pf_qos_set_base(argc, argv);
 		else if (!strncmp(argv[2], "port-weight", 12))
-			qos_wfq_set_weight(argc, argv);
+			p_switch_func->pf_qos_wfq_set_weight(argc, argv);
 		else if (!strncmp(argv[2], "port-prio", 10))
-			qos_set_portpri(argc, argv);
+			p_switch_func->pf_qos_set_portpri(argc, argv);
 		else if (!strncmp(argv[2], "dscp-prio", 10))
-			qos_set_dscppri(argc, argv);
+			p_switch_func->pf_qos_set_dscppri(argc, argv);
 		else if (!strncmp(argv[2], "prio-qmap", 10))
-			qos_pri_mapping_queue(argc, argv);
+			p_switch_func->pf_qos_pri_mapping_queue(argc, argv);
 		else
 			usage(argv[0]);
 	} else if (!strncmp(argv[1], "stp", 3)) {
 		if (argc < 3)
 			usage(argv[0]);
 		else
-			doStp(argc, argv);
+			p_switch_func->pf_doStp(argc, argv);
 	} else if (!strncmp(argv[1], "sip", 5)) {
 		if (argc < 3)
 			usage(argv[0]);
 		if (!strncmp(argv[2], "dump", 5))
-			sip_dump();
+			p_switch_func->pf_sip_dump(argc, argv);
 		else if (!strncmp(argv[2], "add", 4))
-			sip_add(argc, argv);
+			p_switch_func->pf_sip_add(argc, argv);
 		else if (!strncmp(argv[2], "del", 4))
-			sip_del(argc, argv);
+			p_switch_func->pf_sip_del(argc, argv);
 		else if (!strncmp(argv[2], "clear", 6))
-			sip_clear();
+			p_switch_func->pf_sip_clear(argc, argv);
 		else
 			usage(argv[0]);
 	} else if (!strncmp(argv[1], "dip", 4)) {
 		if (argc < 3)
 			usage(argv[0]);
 		if (!strncmp(argv[2], "dump", 5))
-			dip_dump();
+			p_switch_func->pf_dip_dump(argc, argv);
 		else if (!strncmp(argv[2], "add", 4))
-			dip_add(argc, argv);
+			p_switch_func->pf_dip_add(argc, argv);
 		else if (!strncmp(argv[2], "del", 4))
-			dip_del(argc, argv);
+			p_switch_func->pf_dip_del(argc, argv);
 		else if (!strncmp(argv[2], "clear", 6))
-			dip_clear();
+			p_switch_func->pf_dip_clear(argc, argv);
 		else
 			usage(argv[0]);
 	} else if (!strncmp(argv[1], "mirror", 7)) {
 		if (argc < 3)
 			usage(argv[0]);
 		if (!strncmp(argv[2], "monitor", 8))
-			set_mirror_to(argc, argv);
+			p_switch_func->pf_set_mirror_to(argc, argv);
 		else if (!strncmp(argv[2], "target", 7))
-			set_mirror_from(argc, argv);
+			p_switch_func->pf_set_mirror_from(argc, argv);
 		else if (!strncmp(argv[2], "enable", 7))
-			doMirrorEn(argc, argv);
+			p_switch_func->pf_doMirrorEn(argc, argv);
 		else if (!strncmp(argv[2], "port-based", 11))
-			doMirrorPortBased(argc, argv);
+			p_switch_func->pf_doMirrorPortBased(argc, argv);
 		else
 			usage(argv[0]);
 	} else if (!strncmp(argv[1], "acl", 4)) {
@@ -537,152 +895,127 @@
 			usage(argv[0]);
 		if (!strncmp(argv[2], "dip", 4)) {
 			if (!strncmp(argv[3], "add", 4))
-				acl_dip_add(argc, argv);
+				p_switch_func->pf_acl_dip_add(argc, argv);
 			else if (!strncmp(argv[3], "modup", 6))
-				acl_dip_modify(argc, argv);
+				p_switch_func->pf_acl_dip_modify(argc, argv);
 			else if (!strncmp(argv[3], "pppoe", 6))
-				acl_dip_pppoe(argc, argv);
+				p_switch_func->pf_acl_dip_pppoe(argc, argv);
 			else if (!strncmp(argv[3], "trtcm", 4))
-				acl_dip_trtcm(argc, argv);
+				p_switch_func->pf_acl_dip_trtcm(argc, argv);
 			else if (!strncmp(argv[3], "meter", 6))
-				acl_dip_meter(argc, argv);
+				p_switch_func->pf_acl_dip_meter(argc, argv);
 			else
 				usage(argv[0]);
 		} else if (!strncmp(argv[2], "dmac", 6)) {
 			if (!strncmp(argv[3], "add", 4))
-				acl_mac_add(argc, argv);
+				p_switch_func->pf_acl_mac_add(argc, argv);
 			else
 				usage(argv[0]);
 		} else if (!strncmp(argv[2], "etype", 6)) {
 			if (!strncmp(argv[3], "add", 4))
-				acl_ethertype(argc, argv);
+				p_switch_func->pf_acl_ethertype(argc, argv);
 			else
 				usage(argv[0]);
 		} else if (!strncmp(argv[2], "port", 5)) {
 			if (!strncmp(argv[3], "add", 4))
-				acl_sp_add(argc, argv);
+				p_switch_func->pf_acl_sp_add(argc, argv);
 			else
 				usage(argv[0]);
 		} else if (!strncmp(argv[2], "L4", 5)) {
 			if (!strncmp(argv[3], "add", 4))
-				acl_l4_add(argc, argv);
+				p_switch_func->pf_acl_l4_add(argc, argv);
 			else
 				usage(argv[0]);
 		} else if (!strncmp(argv[2], "enable", 7))
-			acl_port_enable(argc, argv);
+			p_switch_func->pf_acl_port_enable(argc, argv);
 		else if (!strncmp(argv[2], "acltbl-add", 11))
-			acl_table_add(argc, argv);
+			p_switch_func->pf_acl_table_add(argc, argv);
 		else if (!strncmp(argv[2], "masktbl-add", 12))
-			acl_mask_table_add(argc, argv);
+			p_switch_func->pf_acl_mask_table_add(argc, argv);
 		else if (!strncmp(argv[2], "ruletbl-add", 12))
-			acl_rule_table_add(argc, argv);
+			p_switch_func->pf_acl_rule_table_add(argc, argv);
 		else if (!strncmp(argv[2], "ratetbl-add", 12))
-			acl_rate_table_add(argc, argv);
+			p_switch_func->pf_acl_rate_table_add(argc, argv);
 		else
 			usage(argv[0]);
 	} else if (!strncmp(argv[1], "vlan", 5)) {
 		if (argc < 3)
 			usage(argv[0]);
 		if (!strncmp(argv[2], "dump", 5))
-			vlan_dump(argc, argv);
+			p_switch_func->pf_vlan_dump(argc, argv);
 		else if (!strncmp(argv[2], "set", 4))
-			vlan_set(argc, argv);
+			p_switch_func->pf_vlan_set(argc, argv);
 		else if (!strncmp(argv[2], "clear", 6))
-			vlan_clear(argc, argv);
+			p_switch_func->pf_vlan_clear(argc, argv);
 		else if (!strncmp(argv[2], "vid", 4))
-			doVlanSetVid(argc, argv);
+			p_switch_func->pf_doVlanSetVid(argc, argv);
 		else if (!strncmp(argv[2], "pvid", 5))
-			doVlanSetPvid(argc, argv);
+			p_switch_func->pf_doVlanSetPvid(argc, argv);
 		else if (!strncmp(argv[2], "acc-frm", 8))
-			doVlanSetAccFrm(argc, argv);
+			p_switch_func->pf_doVlanSetAccFrm(argc, argv);
 		else if (!strncmp(argv[2], "port-attr", 10))
-			doVlanSetPortAttr(argc, argv);
+			p_switch_func->pf_doVlanSetPortAttr(argc, argv);
 		else if (!strncmp(argv[2], "port-mode", 10))
-			doVlanSetPortMode(argc, argv);
+			p_switch_func->pf_doVlanSetPortMode(argc, argv);
 		else if (!strncmp(argv[2], "eg-tag-pcr", 11))
-			doVlanSetEgressTagPCR(argc, argv);
+			p_switch_func->pf_doVlanSetEgressTagPCR(argc, argv);
 		else if (!strncmp(argv[2], "eg-tag-pvc", 11))
-			doVlanSetEgressTagPVC(argc, argv);
+			p_switch_func->pf_doVlanSetEgressTagPVC(argc, argv);
 		else
 			usage(argv[0]);
 	} else if (!strncmp(argv[1], "reg", 4)) {
 		parse_reg_cmd(argc, argv, 4);
 	} else if (!strncmp(argv[1], "ingress-rate", 6)) {
-		int port = 0, bw = 0;
-		if (argv[2][1] == 'n') {
-			port = strtoul(argv[3], NULL, 0);
-			bw = strtoul(argv[4], NULL, 0);
-			if (ingress_rate_set(1, port, bw) == 0)
-				printf("switch port=%d, bw=%d\n", port, bw);
-		}
-		else if (argv[2][1] == 'f') {
-			if (argc != 4)
-				usage(argv[0]);
-			port = strtoul(argv[3], NULL, 0);
-			if (ingress_rate_set(0, port, bw) == 0)
-				printf("switch port=%d ingress rate limit off\n", port);
-		} else
-			usage(argv[0]);
+		p_switch_func->pf_igress_rate_set(argc, argv);
 	} else if (!strncmp(argv[1], "egress-rate", 6)) {
-		int port = 0, bw = 0;
-		if (argv[2][1] == 'n') {
-			port = strtoul(argv[3], NULL, 0);
-			bw = strtoul(argv[4], NULL, 0);
-			if (egress_rate_set(1, port, bw) == 0)
-				printf("switch port=%d, bw=%d\n", port, bw);
-		} else if (argv[2][1] == 'f') {
-			if (argc != 4)
-				usage(argv[0]);
-			port = strtoul(argv[3], NULL, 0);
-			if (egress_rate_set(0, port, bw) == 0)
-				printf("switch port=%d egress rate limit off\n", port);
-		} else
-			usage(argv[0]);
+		p_switch_func->pf_egress_rate_set(argc, argv);
 	} else if (!strncmp(argv[1], "igmpsnoop", 10)) {
 		if (argc < 3)
 			usage(argv[0]);
 		if (!strncmp(argv[2], "on", 3))
-			igmp_on(argc, argv);
+			p_switch_func->pf_igmp_on(argc, argv);
 		else if (!strncmp(argv[2], "off", 4))
-			igmp_off();
+			p_switch_func->pf_igmp_off(argc, argv);
 		else if (!strncmp(argv[2], "enable", 7))
-			igmp_enable(argc, argv);
+			p_switch_func->pf_igmp_enable(argc, argv);
 		else if (!strncmp(argv[2], "disable", 8))
-			igmp_disable(argc, argv);
+			p_switch_func->pf_igmp_disable(argc, argv);
 		else
 			usage(argv[0]);
 	} else if (!strncmp(argv[1], "collision-pool", 15)) {
 		if (argc < 3)
 			usage(argv[0]);
 		if (!strncmp(argv[2], "enable", 7))
-			collision_pool_enable(argc, argv);
-		else if (!strncmp(argv[2], "mac", 4)){
+			p_switch_func->pf_collision_pool_enable(argc, argv);
+		else if (!strncmp(argv[2], "mac", 4)) {
 			if (!strncmp(argv[3], "dump", 5))
-				collision_pool_mac_dump();
+				p_switch_func->pf_collision_pool_mac_dump(argc,
+									  argv);
 			else
 				usage(argv[0]);
-		} else if (!strncmp(argv[2], "dip", 4)){
+		} else if (!strncmp(argv[2], "dip", 4)) {
 			if (!strncmp(argv[3], "dump", 5))
-				collision_pool_dip_dump();
+				p_switch_func->pf_collision_pool_dip_dump(argc,
+									  argv);
 			else
 				usage(argv[0]);
-		} else if (!strncmp(argv[2], "sip", 4)){
+		} else if (!strncmp(argv[2], "sip", 4)) {
 			if (!strncmp(argv[3], "dump", 5))
-				collision_pool_sip_dump();
+				p_switch_func->pf_collision_pool_sip_dump(argc,
+									  argv);
 			else
 				usage(argv[0]);
-			}
-		else
+		} else
 			usage(argv[0]);
-	}  else if (!strncmp(argv[1], "pfc", 15)) {
+	} else if (!strncmp(argv[1], "pfc", 15)) {
 		if (argc < 4 || argc > 5)
 			usage(argv[0]);
 		if (!strncmp(argv[2], "enable", 7))
-			set_mac_pfc(argc, argv);
-		else if (!strncmp(argv[2], "rx_counter", 11)){
-			pfc_get_rx_counter(argc, argv);
-		} else if (!strncmp(argv[2], "tx_counter", 11)){
-			pfc_get_tx_counter(argc, argv);
+			p_switch_func->pf_set_mac_pfc(argc, argv);
+		else if (!strncmp(argv[2], "rx_counter", 11)) {
+			p_switch_func->pf_pfc_get_rx_counter(argc, argv);
+		} else if (!strncmp(argv[2], "tx_counter", 11)) {
+			p_switch_func->pf_pfc_get_tx_counter(argc, argv);
 		} else
 			usage(argv[0]);
 	} else if (!strncmp(argv[1], "crossover", 10)) {
@@ -694,10 +1027,10 @@
 		if (argc < 3)
 			usage(argv[0]);
 		if (!strncmp(argv[2], "enable", 7) ||
-			 !strncmp(argv[2], "disable", 8))
-			eee_enable(argc, argv);
+		    !strncmp(argv[2], "disable", 8))
+			p_switch_func->pf_eee_enable(argc, argv);
 		else if (!strncmp(argv[2], "dump", 5))
-			eee_dump(argc, argv);
+			p_switch_func->pf_eee_dump(argc, argv);
 		else
 			usage(argv[0]);
 	} else
@@ -705,4 +1038,5 @@
 
 	exit_free();
 	return 0;
+#endif
 }
diff --git a/feed/app/switch/src/switch_fun.c b/feed/app/switch/src/switch_fun.c
old mode 100755
new mode 100644
index 8ee9675..9e9f4fe
--- a/feed/app/switch/src/switch_fun.c
+++ b/feed/app/switch/src/switch_fun.c
@@ -19,6 +19,82 @@
 
 #define leaky_bucket 0
 
+struct switch_func_s mt753x_switch_func = {
+	.pf_table_dump = table_dump,
+	.pf_table_clear = table_clear,
+	.pf_switch_reset = switch_reset,
+	.pf_doArlAging = doArlAging,
+	.pf_read_mib_counters = read_mib_counters,
+	.pf_clear_mib_counters = clear_mib_counters,
+	.pf_read_output_queue_counters = read_output_queue_counters,
+	.pf_read_free_page_counters = read_free_page_counters,
+	.pf_rate_control = rate_control,
+	.pf_igress_rate_set = ingress_rate_set,
+	.pf_egress_rate_set = egress_rate_set,
+	.pf_table_add = table_add,
+	.pf_table_del_fid = table_del_fid,
+	.pf_table_del_vid = table_del_vid,
+	.pf_table_search_mac_fid = table_search_mac_fid,
+	.pf_table_search_mac_vid = table_search_mac_vid,
+	.pf_global_set_mac_fc = global_set_mac_fc,
+	.pf_set_mac_pfc = set_mac_pfc,
+	.pf_qos_sch_select = qos_sch_select,
+	.pf_qos_set_base = qos_set_base,
+	.pf_qos_wfq_set_weight = qos_wfq_set_weight,
+	.pf_qos_set_portpri = qos_set_portpri,
+	.pf_qos_set_dscppri = qos_set_dscppri,
+	.pf_qos_pri_mapping_queue = qos_pri_mapping_queue,
+	.pf_doStp = doStp,
+	.pf_sip_dump = sip_dump,
+	.pf_sip_add = sip_add,
+	.pf_sip_del = sip_del,
+	.pf_sip_clear = sip_clear,
+	.pf_dip_dump = dip_dump,
+	.pf_dip_add = dip_add,
+	.pf_dip_del = dip_del,
+	.pf_dip_clear = dip_clear,
+	.pf_set_mirror_to = set_mirror_to,
+	.pf_set_mirror_from = set_mirror_from,
+	.pf_doMirrorEn = doMirrorEn,
+	.pf_doMirrorPortBased = doMirrorPortBased,
+	.pf_acl_dip_add = acl_dip_add,
+	.pf_acl_dip_modify = acl_dip_modify,
+	.pf_acl_dip_pppoe = acl_dip_pppoe,
+	.pf_acl_dip_trtcm = acl_dip_trtcm,
+	.pf_acl_dip_meter = acl_dip_meter,
+	.pf_acl_mac_add = acl_mac_add,
+	.pf_acl_ethertype = acl_ethertype,
+	.pf_acl_sp_add = acl_sp_add,
+	.pf_acl_l4_add = acl_l4_add,
+	.pf_acl_port_enable = acl_port_enable,
+	.pf_acl_table_add = acl_table_add,
+	.pf_acl_mask_table_add = acl_mask_table_add,
+	.pf_acl_rule_table_add = acl_rule_table_add,
+	.pf_acl_rate_table_add = acl_rate_table_add,
+	.pf_vlan_dump = vlan_dump,
+	.pf_vlan_set = vlan_set,
+	.pf_vlan_clear = vlan_clear,
+	.pf_doVlanSetVid = doVlanSetVid,
+	.pf_doVlanSetPvid = doVlanSetPvid,
+	.pf_doVlanSetAccFrm = doVlanSetAccFrm,
+	.pf_doVlanSetPortAttr = doVlanSetPortAttr,
+	.pf_doVlanSetPortMode = doVlanSetPortMode,
+	.pf_doVlanSetEgressTagPCR = doVlanSetEgressTagPCR,
+	.pf_doVlanSetEgressTagPVC = doVlanSetEgressTagPVC,
+	.pf_igmp_on = igmp_on,
+	.pf_igmp_off = igmp_off,
+	.pf_igmp_enable = igmp_enable,
+	.pf_igmp_disable = igmp_disable,
+	.pf_collision_pool_enable = collision_pool_enable,
+	.pf_collision_pool_mac_dump = collision_pool_mac_dump,
+	.pf_collision_pool_dip_dump = collision_pool_dip_dump,
+	.pf_collision_pool_sip_dump = collision_pool_sip_dump,
+	.pf_pfc_get_rx_counter = pfc_get_rx_counter,
+	.pf_pfc_get_tx_counter = pfc_get_tx_counter,
+	.pf_eee_enable = eee_enable,
+	.pf_eee_dump = eee_dump,
+};
+
 static int getnext(char *src, int separator, char *dest)
 {
 	char *c;
@@ -66,7 +142,7 @@
 	c[1] = *(ptr + 1);
 	c[2] = *(ptr + 2);
 	c[3] = *(ptr + 3);
-	/*sprintf(str, "%d.%d.%d.%d", c[0], c[1], c[2], c[3]);*/
+	/*sprintf(str, "%d.%d.%d.%d", c[0], c[1], c[2], c[3]); */
 	sprintf(str, "%d.%d.%d.%d", c[3], c[2], c[1], c[0]);
 }
 
@@ -153,7 +229,8 @@
 	return 0;
 }
 
-int mii_mgr_c45_read(unsigned int port_num, unsigned int dev, unsigned int reg, unsigned int *value)
+int mii_mgr_c45_read(unsigned int port_num, unsigned int dev, unsigned int reg,
+		     unsigned int *value)
 {
 	int ret;
 
@@ -176,7 +253,8 @@
 	return 0;
 }
 
-int mii_mgr_c45_write(unsigned int port_num, unsigned int dev, unsigned int reg, unsigned int value)
+int mii_mgr_c45_write(unsigned int port_num, unsigned int dev, unsigned int reg,
+		      unsigned int value)
 {
 	int ret;
 
@@ -199,7 +277,6 @@
 	return 0;
 }
 
-
 int phy_dump(int phy_addr)
 {
 	int ret;
@@ -221,7 +298,7 @@
 void phy_crossover(int argc, char *argv[])
 {
 	unsigned int port_num = strtoul(argv[2], NULL, 10);
-	unsigned int value;
+	unsigned int value = 0;
 	int ret;
 
 	if (port_num > 4) {
@@ -230,9 +307,13 @@
 	}
 
 	if (nl_init_flag == true)
-		ret = phy_cl45_read_netlink(attres, port_num, 0x1E, MT7530_T10_TEST_CONTROL, &value);
+		ret =
+		    phy_cl45_read_netlink(attres, port_num, 0x1E,
+					  MT7530_T10_TEST_CONTROL, &value);
 	else
-		ret = mii_mgr_cl45_read_ioctl(port_num, 0x1E, MT7530_T10_TEST_CONTROL, &value);
+		ret =
+		    mii_mgr_cl45_read_ioctl(port_num, 0x1E,
+					    MT7530_T10_TEST_CONTROL, &value);
 	if (ret < 0) {
 		printf("phy_cl45 read fail\n");
 		exit_free();
@@ -240,10 +321,10 @@
 	}
 
 	printf("mii_mgr_cl45:");
-	printf("Read:  port#=%d, device=0x%x, reg=0x%x, value=0x%x\n", port_num, 0x1E, MT7530_T10_TEST_CONTROL, value);
+	printf("Read:  port#=%d, device=0x%x, reg=0x%x, value=0x%x\n", port_num,
+	       0x1E, MT7530_T10_TEST_CONTROL, value);
 
-	if (!strncmp(argv[3], "auto", 5))
-	{
+	if (!strncmp(argv[3], "auto", 5)) {
 		value &= (~(0x3 << 3));
 	} else if (!strncmp(argv[3], "mdi", 4)) {
 		value &= (~(0x3 << 3));
@@ -254,12 +335,17 @@
 		printf("invaild parameter\n");
 		return;
 	}
-	printf("Write: port#=%d, device=0x%x, reg=0x%x. value=0x%x\n", port_num, 0x1E, MT7530_T10_TEST_CONTROL, value);
+	printf("Write: port#=%d, device=0x%x, reg=0x%x. value=0x%x\n", port_num,
+	       0x1E, MT7530_T10_TEST_CONTROL, value);
 
 	if (nl_init_flag == true)
-		ret = phy_cl45_write_netlink(attres, port_num, 0x1E, MT7530_T10_TEST_CONTROL, value);
+		ret =
+		    phy_cl45_write_netlink(attres, port_num, 0x1E,
+					   MT7530_T10_TEST_CONTROL, value);
 	else
-		ret = mii_mgr_cl45_write_ioctl(port_num, 0x1E, MT7530_T10_TEST_CONTROL, value);
+		ret =
+		    mii_mgr_cl45_write_ioctl(port_num, 0x1E,
+					     MT7530_T10_TEST_CONTROL, value);
 
 	if (ret < 0) {
 		printf("phy_cl45 write fail\n");
@@ -282,7 +368,7 @@
 	if (argv[2][0] == 'r') {
 		if (argc != 7)
 			return -1;
-		mii_mgr_write(0, 0x1f, 0x52b5); // r31 = 0x52b5
+		mii_mgr_write(0, 0x1f, 0x52b5);	// r31 = 0x52b5
 		port_num = strtoul(argv[3], NULL, 0);
 		if (port_num > MAX_PORT) {
 			printf("Illegal port index and port:0~6\n");
@@ -291,16 +377,21 @@
 		ch_addr = strtoul(argv[4], NULL, 0);
 		node_addr = strtoul(argv[5], NULL, 0);
 		data_addr = strtoul(argv[6], NULL, 0);
-		printf("port = %x, ch_addr = %x, node_addr=%x, data_addr=%x\n", port_num, ch_addr, node_addr, data_addr);
-		tr_reg_control = (1 << 15) | (1 << 13) | (ch_addr << 11) | (node_addr << 7) | (data_addr << 1);
-		mii_mgr_write(port_num, 16, tr_reg_control); // r16 = tr_reg_control
+		printf("port = %x, ch_addr = %x, node_addr=%x, data_addr=%x\n",
+		       port_num, ch_addr, node_addr, data_addr);
+		tr_reg_control =
+		    (1 << 15) | (1 << 13) | (ch_addr << 11) | (node_addr << 7) |
+		    (data_addr << 1);
+		mii_mgr_write(port_num, 16, tr_reg_control);	// r16 = tr_reg_control
 		mii_mgr_read(port_num, 17, &val_l);
 		mii_mgr_read(port_num, 18, &val_h);
-		printf("switch trreg read tr_reg_control=%x, value_H=%x, value_L=%x\n", tr_reg_control, val_h, val_l);
+		printf
+		    ("switch trreg read tr_reg_control=%x, value_H=%x, value_L=%x\n",
+		     tr_reg_control, val_h, val_l);
 	} else if (argv[2][0] == 'w') {
 		if (argc != 9)
 			return -1;
-		mii_mgr_write(0, 0x1f, 0x52b5); // r31 = 0x52b5
+		mii_mgr_write(0, 0x1f, 0x52b5);	// r31 = 0x52b5
 		port_num = strtoul(argv[3], NULL, 0);
 		if (port_num > MAX_PORT) {
 			printf("\n**Illegal port index and port:0~6\n");
@@ -311,20 +402,26 @@
 		data_addr = strtoul(argv[6], NULL, 0);
 		val_h = strtoul(argv[7], NULL, 0);
 		val_l = strtoul(argv[8], NULL, 0);
-		printf("port = %x, ch_addr = %x, node_addr=%x, data_addr=%x\n", port_num, ch_addr, node_addr, data_addr);
-		tr_reg_control = (1 << 15) | (0 << 13) | (ch_addr << 11) | (node_addr << 7) | (data_addr << 1);
+		printf("port = %x, ch_addr = %x, node_addr=%x, data_addr=%x\n",
+		       port_num, ch_addr, node_addr, data_addr);
+		tr_reg_control =
+		    (1 << 15) | (0 << 13) | (ch_addr << 11) | (node_addr << 7) |
+		    (data_addr << 1);
 		mii_mgr_write(port_num, 17, val_l);
 		mii_mgr_write(port_num, 18, val_h);
-		mii_mgr_write(port_num, 16, tr_reg_control); // r16 = tr_reg_control
-		printf("switch trreg Write tr_reg_control=%x, value_H=%x, value_L=%x\n", tr_reg_control, val_h, val_l);
+		mii_mgr_write(port_num, 16, tr_reg_control);	// r16 = tr_reg_control
+		printf
+		    ("switch trreg Write tr_reg_control=%x, value_H=%x, value_L=%x\n",
+		     tr_reg_control, val_h, val_l);
 	} else
 		return -1;
 	return 0;
 }
 
-void write_acl_table(unsigned char tbl_idx, unsigned int vawd1, unsigned int vawd2)
+void write_acl_table(unsigned char tbl_idx, unsigned int vawd1,
+		     unsigned int vawd2)
 {
-	unsigned int value, reg;
+	unsigned int value = 0, reg = 0;
 	unsigned int max_index;
 
 	if (chip_name == 0x7531 || chip_name == 0x7988)
@@ -340,8 +437,7 @@
 	}
 
 	reg = REG_VTCR_ADDR;
-	while (1)
-	{ // wait until not busy
+	while (1) {		// wait until not busy
 		reg_read(reg, &value);
 		if ((value & REG_VTCR_BUSY_MASK) == 0) {
 			break;
@@ -356,8 +452,7 @@
 	reg_write(reg, value);
 	printf("write reg: %x, value: %x\n", reg, value);
 
-	while (1)
-	{ 	// wait until not busy
+	while (1) {		// wait until not busy
 		reg_read(reg, &value);
 		if ((value & REG_VTCR_BUSY_MASK) == 0)
 			break;
@@ -366,8 +461,8 @@
 
 void acl_table_add(int argc, char *argv[])
 {
-	unsigned int vawd1, vawd2;
-	unsigned char tbl_idx;
+	unsigned int vawd1 = 0, vawd2 = 0;
+	unsigned char tbl_idx = 0;
 
 	tbl_idx = atoi(argv[3]);
 	vawd1 = strtoul(argv[4], (char **)NULL, 16);
@@ -375,10 +470,11 @@
 	write_acl_table(tbl_idx, vawd1, vawd2);
 }
 
-void write_acl_mask_table(unsigned char tbl_idx, unsigned int vawd1, unsigned int vawd2)
+void write_acl_mask_table(unsigned char tbl_idx, unsigned int vawd1,
+			  unsigned int vawd2)
 {
-	unsigned int value, reg;
-	unsigned int max_index;
+	unsigned int value = 0, reg = 0;
+	unsigned int max_index = 0;
 
 	if (chip_name == 0x7531 || chip_name == 0x7988)
 		max_index = 128;
@@ -392,8 +488,7 @@
 		return;
 	}
 	reg = REG_VTCR_ADDR;
-	while (1)
-	{ // wait until not busy
+	while (1) {		// wait until not busy
 		reg_read(reg, &value);
 		if ((value & REG_VTCR_BUSY_MASK) == 0)
 			break;
@@ -406,8 +501,7 @@
 	value = REG_VTCR_BUSY_MASK | (0x09 << REG_VTCR_FUNC_OFFT) | tbl_idx;
 	reg_write(reg, value);
 	printf("write reg: %x, value: %x\n", reg, value);
-	while (1)
-	{ // wait until not busy
+	while (1) {		// wait until not busy
 		reg_read(reg, &value);
 		if ((value & REG_VTCR_BUSY_MASK) == 0)
 			break;
@@ -416,8 +510,8 @@
 
 void acl_mask_table_add(int argc, char *argv[])
 {
-	unsigned int vawd1, vawd2;
-	unsigned char tbl_idx;
+	unsigned int vawd1 = 0, vawd2 = 0;
+	unsigned char tbl_idx = 0;
 
 	tbl_idx = atoi(argv[3]);
 	vawd1 = strtoul(argv[4], (char **)NULL, 16);
@@ -425,10 +519,11 @@
 	write_acl_mask_table(tbl_idx, vawd1, vawd2);
 }
 
-void write_acl_rule_table(unsigned char tbl_idx, unsigned int vawd1, unsigned int vawd2)
+void write_acl_rule_table(unsigned char tbl_idx, unsigned int vawd1,
+			  unsigned int vawd2)
 {
-	unsigned int value, reg;
-	unsigned int max_index;
+	unsigned int value = 0, reg = 0;
+	unsigned int max_index = 0;
 
 	if (chip_name == 0x7531 || chip_name == 0x7988)
 		max_index = 128;
@@ -437,14 +532,13 @@
 
 	printf("Rule_control_tbl_idx:%d\n", tbl_idx);
 
-	if (tbl_idx >= max_index) { /*Check the input parameters is right or not.*/
+	if (tbl_idx >= max_index) {	/* Check the input parameters is right or not. */
 		printf(HELP_ACL_RULE_TBL_ADD);
 		return;
 	}
 	reg = REG_VTCR_ADDR;
 
-	while (1)
-	{ // wait until not busy
+	while (1) {		// wait until not busy
 		reg_read(reg, &value);
 		if ((value & REG_VTCR_BUSY_MASK) == 0) {
 			break;
@@ -459,8 +553,7 @@
 	reg_write(reg, value);
 	printf("write reg: %x, value: %x\n", reg, value);
 
-	while (1)
-	{ // wait until not busy
+	while (1) {		// wait until not busy
 		reg_read(reg, &value);
 		if ((value & REG_VTCR_BUSY_MASK) == 0) {
 			break;
@@ -470,8 +563,8 @@
 
 void acl_rule_table_add(int argc, char *argv[])
 {
-	unsigned int vawd1, vawd2;
-	unsigned char tbl_idx;
+	unsigned int vawd1 = 0, vawd2 = 0;
+	unsigned char tbl_idx = 0;
 
 	tbl_idx = atoi(argv[3]);
 	vawd1 = strtoul(argv[4], (char **)NULL, 16);
@@ -479,9 +572,10 @@
 	write_acl_rule_table(tbl_idx, vawd1, vawd2);
 }
 
-void write_rate_table(unsigned char tbl_idx, unsigned int vawd1, unsigned int vawd2)
+void write_rate_table(unsigned char tbl_idx, unsigned int vawd1,
+		      unsigned int vawd2)
 {
-	unsigned int value, reg;
+	unsigned int value = 0, reg = 0;
 	unsigned int max_index = 32;
 
 	printf("Rule_action_tbl_idx:%d\n", tbl_idx);
@@ -492,7 +586,7 @@
 	}
 
 	reg = REG_VTCR_ADDR;
-	while (1) { 	// wait until not busy
+	while (1) {		// wait until not busy
 		reg_read(reg, &value);
 		if ((value & REG_VTCR_BUSY_MASK) == 0)
 			break;
@@ -507,7 +601,7 @@
 	reg_write(reg, value);
 	printf("write reg: %x, value: %x\n", reg, value);
 
-	while (1) { // wait until not busy
+	while (1) {		// wait until not busy
 		reg_read(reg, &value);
 		if ((value & REG_VTCR_BUSY_MASK) == 0)
 			break;
@@ -516,8 +610,8 @@
 
 void acl_rate_table_add(int argc, char *argv[])
 {
-	unsigned int vawd1, vawd2;
-	unsigned char tbl_idx;
+	unsigned int vawd1 = 0, vawd2 = 0;
+	unsigned char tbl_idx = 0;
 
 	tbl_idx = atoi(argv[3]);
 	vawd1 = strtoul(argv[4], (char **)NULL, 16);
@@ -526,9 +620,10 @@
 	write_rate_table(tbl_idx, vawd1, vawd2);
 }
 
-void write_trTCM_table(unsigned char tbl_idx, unsigned int vawd1, unsigned int vawd2)
+void write_trTCM_table(unsigned char tbl_idx, unsigned int vawd1,
+		       unsigned int vawd2)
 {
-	unsigned int value, reg;
+	unsigned int value = 0, reg = 0;
 	unsigned int max_index = 32;
 
 	printf("trTCM_tbl_idx:%d\n", tbl_idx);
@@ -539,7 +634,7 @@
 	}
 
 	reg = REG_VTCR_ADDR;
-	while (1) { 	// wait until not busy
+	while (1) {		// wait until not busy
 		reg_read(reg, &value);
 		if ((value & REG_VTCR_BUSY_MASK) == 0)
 			break;
@@ -554,16 +649,17 @@
 	reg_write(reg, value);
 	printf("write reg: %x, value: %x\n", reg, value);
 
-	while (1) { // wait until not busy
+	while (1) {		// wait until not busy
 		reg_read(reg, &value);
 		if ((value & REG_VTCR_BUSY_MASK) == 0)
 			break;
 	}
 }
 
-int acl_parameters_pre_del(int len1, int len2, int argc, char *argv[], int *port)
+int acl_parameters_pre_del(int len1, int len2, int argc, char *argv[],
+			   int *port)
 {
-	int i;
+	int i = 0;
 
 	*port = 0;
 	if (argc < len1) {
@@ -571,10 +667,11 @@
 		return -1;
 	}
 
-	if (len2 == 12)
-	{
+	if (len2 == 12) {
 		if (!argv[4] || strlen(argv[4]) != len2) {
-			printf("The [%s] format error, should be of length %d\n",argv[4], len2);
+			printf
+			    ("The [%s] format error, should be of length %d\n",
+			     argv[4], len2);
 			return -1;
 		}
 	}
@@ -586,7 +683,8 @@
 
 	for (i = 0; i < 7; i++) {
 		if (argv[5][i] != '0' && argv[5][i] != '1') {
-			printf("portmap format error, should be of combination of 0 or 1\n");
+			printf
+			    ("portmap format error, should be of combination of 0 or 1\n");
 			return -1;
 		}
 		*port += (argv[5][i] - '0') * (1 << i);
@@ -594,31 +692,32 @@
 	return 0;
 }
 
-void acl_compare_pattern(int ports, int comparion, int base, int word, unsigned char table_index)
+void acl_compare_pattern(int ports, int comparion, int base, int word,
+			 unsigned char table_index)
 {
-	unsigned int value;
+	unsigned int value = 0;
 
-	comparion |= 0xffff0000; //compare mask
+	comparion |= 0xffff0000;	//compare mask
 
-	value = ports << 8; //w_port_map
-	value |= 0x1 << 19; //enable
-	value |= base << 16; //mac header
-	value |= word << 1;  //word offset
+	value = ports << 8;	//w_port_map
+	value |= 0x1 << 19;	//enable
+	value |= base << 16;	//mac header
+	value |= word << 1;	//word offset
 
 	write_acl_table(table_index, comparion, value);
 }
 
 void acl_mac_add(int argc, char *argv[])
 {
-	unsigned int value;
-	int ports;
+	unsigned int value = 0;
+	int ports = 0;
 	char tmpstr[5];
 	int ret;
 
 	ret = acl_parameters_pre_del(6, 12, argc, argv, &ports);
 	if (ret < 0)
 		return;
-	//set pattern
+	/* Set pattern */
 	strncpy(tmpstr, argv[4], 4);
 	tmpstr[4] = '\0';
 	value = strtoul(tmpstr, NULL, 16);
@@ -635,20 +734,20 @@
 	acl_compare_pattern(ports, value, 0x0, 2, 2);
 
 	//set mask
-	write_acl_mask_table(0,0x7,0);
+	write_acl_mask_table(0, 0x7, 0);
 
 	//set action
-	value = 0x7;      //drop
-	value |= 1 << 28; //acl intterupt enable
-	value |= 1 << 27; //acl hit count
-	value |= 2 << 24; //acl hit count group index (0~3)
-	write_acl_rule_table(0,value,0);
+	value = 0x7;		//drop
+	value |= 1 << 28;	//acl intterupt enable
+	value |= 1 << 27;	//acl hit count
+	value |= 2 << 24;	//acl hit count group index (0~3)
+	write_acl_rule_table(0, value, 0);
 }
 
 void acl_dip_meter(int argc, char *argv[])
 {
-	unsigned int value, ip_value, meter;
-	int ports;
+	unsigned int value = 0, ip_value = 0, meter = 0;
+	int ports = 0;
 	int ret;
 
 	ip_value = 0;
@@ -666,31 +765,31 @@
 	acl_compare_pattern(ports, value, 0x2, 0x9, 1);
 
 	//set mask
-	write_acl_mask_table(0,0x3,0);
+	write_acl_mask_table(0, 0x3, 0);
 
 	//set action
 	meter = strtoul(argv[6], NULL, 0);
 	if (((chip_name == 0x7530) && (meter > 1000000)) ||
-		((chip_name == 0x7531) && (meter > 2500000)) ||
-		((chip_name == 0x7988) && (meter > 4000000))) {
+	    ((chip_name == 0x7531) && (meter > 2500000)) ||
+	    ((chip_name == 0x7988) && (meter > 4000000))) {
 		printf("\n**Illegal meter input, and 7530: 0~1000000Kpbs, 7531: 0~2500000Kpbs, 7988: 0~4000000Kpbs**\n");
 		return;
 	}
 	if (((chip_name == 0x7531 || chip_name == 0x7988) && (meter > 1000000))) {
-		reg_read(0xc,&value);
+		reg_read(0xc, &value);
 		value |= 0x1 << 30;
-		reg_write(0xC,value);
-		printf("AGC: 0x%x\n",value);
-		value = meter / 1000; //uint is 1Mbps
+		reg_write(0xC, value);
+		printf("AGC: 0x%x\n", value);
+		value = meter / 1000;	//uint is 1Mbps
 	} else {
-		reg_read(0xc,&value);
+		reg_read(0xc, &value);
 		value &= ~(0x1 << 30);
-		reg_write(0xC,value);
-		printf("AGC: 0x%x\n",value);
-		value = meter >> 6; //uint is 64Kbps
+		reg_write(0xC, value);
+		printf("AGC: 0x%x\n", value);
+		value = meter >> 6;	//uint is 64Kbps
 	}
-	value |= 0x1 << 15; //enable rate control
-	printf("Acl rate control:0x%x\n",value);
+	value |= 0x1 << 15;	//enable rate control
+	printf("Acl rate control:0x%x\n", value);
 	write_rate_table(0, value, 0);
 }
 
@@ -721,30 +820,30 @@
 	PIR = strtoul(argv[8], NULL, 0);
 	PBS = strtoul(argv[9], NULL, 0);
 
-	if (CIR > 65535*64 || CBS > 65535 || PIR > 65535*64  || PBS > 65535) {
+	if (CIR > 65535 * 64 || CBS > 65535 || PIR > 65535 * 64 || PBS > 65535) {
 		printf("\n**Illegal input parameters**\n");
 		return;
 	}
 
-	value = CBS << 16; //bit16~31
-	value |= PBS;      //bit0~15
-			   //value |= 1;//valid
+	value = CBS << 16;	//bit16~31
+	value |= PBS;		//bit0~15
+	//value |= 1;//valid
 	CIR = CIR >> 6;
 	PIR = PIR >> 6;
 
-	value2 = CIR << 16; //bit16~31
-	value2 |= PIR;      //bit0~15
-	write_trTCM_table(0,value,value2);
+	value2 = CIR << 16;	//bit16~31
+	value2 |= PIR;		//bit0~15
+	write_trTCM_table(0, value, value2);
 
 	//set pattern
-	write_acl_mask_table(0,0x3,0);
+	write_acl_mask_table(0, 0x3, 0);
 
 	//set action
-	value = 0x1 << (11 + 1); //TrTCM green  meter#0 Low drop
-	value |= 0x2 << (8 + 1); //TrTCM yellow  meter#0 Med drop
-	value |= 0x3 << (5 + 1); //TrTCM red  meter#0    Hig drop
-	value |= 0x1 << 0;       //TrTCM drop pcd select
-	write_acl_rule_table(0,0,value);
+	value = 0x1 << (11 + 1);	//TrTCM green  meter#0 Low drop
+	value |= 0x2 << (8 + 1);	//TrTCM yellow  meter#0 Med drop
+	value |= 0x3 << (5 + 1);	//TrTCM red  meter#0    Hig drop
+	value |= 0x1 << 0;	//TrTCM drop pcd select
+	write_acl_rule_table(0, 0, value);
 }
 
 void acl_ethertype(int argc, char *argv[])
@@ -756,21 +855,21 @@
 	ret = acl_parameters_pre_del(6, -1, argc, argv, &ports);
 	if (ret < 0)
 		return;
-	printf("ports:0x%x\n",ports);
+	printf("ports:0x%x\n", ports);
 	ethertype = strtoul(argv[4], NULL, 16);
 	//set pattern
 	value = ethertype;
 	acl_compare_pattern(ports, value, 0x0, 0x6, 0);
 
 	//set pattern
-	write_acl_mask_table(0,0x1,0);
+	write_acl_mask_table(0, 0x1, 0);
 
 	//set action(drop)
-	value = 0x7;      //default. Nodrop
-	value |= 1 << 28; //acl intterupt enable
-	value |= 1 << 27; //acl hit count
+	value = 0x7;		//default. Nodrop
+	value |= 1 << 28;	//acl intterupt enable
+	value |= 1 << 27;	//acl hit count
 
-	write_acl_rule_table(0,value,0);
+	write_acl_rule_table(0, value, 0);
 }
 
 void acl_dip_modify(int argc, char *argv[])
@@ -801,14 +900,14 @@
 	acl_compare_pattern(ports, value, 0x2, 0x9, 1);
 
 	//set pattern
-	write_acl_mask_table(0,0x3,0);
+	write_acl_mask_table(0, 0x3, 0);
 
 	//set action
-	value = 0x0;      //default. Nodrop
-	value |= 1 << 28; //acl intterupt enable
-	value |= 1 << 27; //acl hit count
-	value |= priority << 4;  //acl UP
-	write_acl_rule_table(0,value,0);
+	value = 0x0;		//default. Nodrop
+	value |= 1 << 28;	//acl intterupt enable
+	value |= 1 << 27;	//acl hit count
+	value |= priority << 4;	//acl UP
+	write_acl_rule_table(0, value, 0);
 }
 
 void acl_dip_pppoe(int argc, char *argv[])
@@ -832,16 +931,16 @@
 	acl_compare_pattern(ports, value, 0x2, 0x9, 1);
 
 	//set pattern
-	write_acl_mask_table(0,0x3,0);
+	write_acl_mask_table(0, 0x3, 0);
 
 	//set action
-	value = 0x0;      //default. Nodrop
-	value |= 1 << 28; //acl intterupt enable
-	value |= 1 << 27; //acl hit count
-	value |= 1 << 20; //pppoe header remove
-	value |= 1 << 21; //SA MAC SWAP
-	value |= 1 << 22; //DA MAC SWAP
-	write_acl_rule_table(0,value,7);
+	value = 0x0;		//default. Nodrop
+	value |= 1 << 28;	//acl intterupt enable
+	value |= 1 << 27;	//acl hit count
+	value |= 1 << 20;	//pppoe header remove
+	value |= 1 << 21;	//SA MAC SWAP
+	value |= 1 << 22;	//DA MAC SWAP
+	write_acl_rule_table(0, value, 7);
 }
 
 void acl_dip_add(int argc, char *argv[])
@@ -865,20 +964,20 @@
 	acl_compare_pattern(ports, value, 0x2, 0x9, 1);
 
 	//set pattern
-	write_acl_mask_table(0,0x3,0);
+	write_acl_mask_table(0, 0x3, 0);
 
 	//set action
 	//value = 0x0; //default
-	value = 0x7;      //drop
-	value |= 1 << 28; //acl intterupt enable
-	value |= 1 << 27; //acl hit count
-	value |= 2 << 24; //acl hit count group index (0~3)
-	write_acl_rule_table(0,value,0);
+	value = 0x7;		//drop
+	value |= 1 << 28;	//acl intterupt enable
+	value |= 1 << 27;	//acl hit count
+	value |= 2 << 24;	//acl hit count group index (0~3)
+	write_acl_rule_table(0, value, 0);
 }
 
 void acl_l4_add(int argc, char *argv[])
 {
-	unsigned int value;
+	unsigned int value = 0;
 	int ports;
 	int ret;
 
@@ -891,16 +990,16 @@
 	acl_compare_pattern(ports, value, 0x5, 0x0, 0);
 
 	//set rue mask
-	write_acl_mask_table(0,0x1,0);
+	write_acl_mask_table(0, 0x1, 0);
 	//set action
-	value = 0x7; //drop
-		     //value |= 1;//valid
-	write_acl_rule_table(0,value,0);
+	value = 0x7;		//drop
+	//value |= 1;//valid
+	write_acl_rule_table(0, value, 0);
 }
 
 void acl_sp_add(int argc, char *argv[])
 {
-	unsigned int value;
+	unsigned int value = 0;
 	int ports;
 	int ret;
 
@@ -912,31 +1011,31 @@
 	acl_compare_pattern(ports, value, 0x4, 0x0, 0);
 
 	//set rue mask
-	write_acl_mask_table(0,0x1,0);
+	write_acl_mask_table(0, 0x1, 0);
 
 	//set action
-	value = 0x7; //drop
-		     //value |= 1;//valid
-	write_acl_rule_table(0,value,0);
+	value = 0x7;		//drop
+	//value |= 1;//valid
+	write_acl_rule_table(0, value, 0);
 }
 
 void acl_port_enable(int argc, char *argv[])
 {
-	unsigned int value, reg;
-	unsigned char acl_port, acl_en;
+	unsigned int value = 0, reg = 0;
+	unsigned char acl_port = 0, acl_en = 0;
 
 	acl_port = atoi(argv[3]);
 	acl_en = atoi(argv[4]);
 
 	printf("acl_port:%d, acl_en:%d\n", acl_port, acl_en);
 
-	/*Check the input parameters is right or not.*/
+	/*Check the input parameters is right or not. */
 	if ((acl_port > SWITCH_MAX_PORT) || (acl_en > 1)) {
 		printf(HELP_ACL_SETPORTEN);
 		return;
 	}
 
-	reg = REG_PCR_P0_ADDR + (0x100 * acl_port); // 0x2004[10]
+	reg = REG_PCR_P0_ADDR + (0x100 * acl_port);	// 0x2004[10]
 	reg_read(reg, &value);
 	value &= (~REG_PORT_ACL_EN_MASK);
 	value |= (acl_en << REG_PORT_ACL_EN_OFFT);
@@ -948,37 +1047,37 @@
 static void dip_dump_internal(int type)
 {
 	unsigned int i, j, value, mac, mac2, value2;
-	char tmpstr[16];
+	char tmpstr[16] = { 0 };
 	int table_size = 0;
 	int hit_value1 = 0;
 	int hit_value2 = 0;
 
-	if(type == GENERAL_TABLE) {
+	if (type == GENERAL_TABLE) {
 		table_size = 0x800;
-		reg_write(REG_ATC_ADDR, 0x8104); //dip search command
-		} else {
+		reg_write(REG_ATC_ADDR, 0x8104);	//dip search command
+	} else {
 		table_size = 0x40;
-		reg_write(REG_ATC_ADDR, 0x811c); //dip search command
+		reg_write(REG_ATC_ADDR, 0x811c);	//dip search command
 	}
-	printf("hash   port(0:6)   rsp_cnt  flag  timer    dip-address       ATRD\n");
+	printf
+	    ("hash   port(0:6)   rsp_cnt  flag  timer    dip-address       ATRD\n");
 	for (i = 0; i < table_size; i++) {
-		while (1)
-		{
+		while (1) {
 			reg_read(REG_ATC_ADDR, &value);
-			if(type == GENERAL_TABLE) {
+			if (type == GENERAL_TABLE) {
 				hit_value1 = value & (0x1 << 13);
 				hit_value2 = 1;
-			}else {
+			} else {
 				hit_value1 = value & (0x1 << 13);
 				hit_value2 = value & (0x1 << 28);
 			}
 
-			if (hit_value1 && hit_value2 ) { //search_rdy
+			if (hit_value1 && hit_value2) {	//search_rdy
 				reg_read(REG_ATRD_ADDR, &value2);
 				//printf("REG_ATRD_ADDR=0x%x\n\r",value2);
 
-				printf("%03x:   ", (value >> 16) & 0xfff); //hash_addr_lu
-				j = (value2 >> 4) & 0xff;		   //r_port_map
+				printf("%03x:   ", (value >> 16) & 0xfff);	//hash_addr_lu
+				j = (value2 >> 4) & 0xff;	//r_port_map
 				printf("%c", (j & 0x01) ? '1' : '-');
 				printf("%c", (j & 0x02) ? '1' : '-');
 				printf("%c", (j & 0x04) ? '1' : '-');
@@ -989,38 +1088,38 @@
 
 				reg_read(REG_TSRA2_ADDR, &mac2);
 
-				printf("     0x%4x", (mac2 & 0xffff));    //RESP_CNT
-				printf("  0x%2x", ((mac2 >> 16) & 0xff)); //RESP_FLAG
-				printf("  %3d", ((mac2 >> 24) & 0xff));   //RESP_TIMER
-									  //printf(" %4d", (value2 >> 24) & 0xff); //r_age_field
+				printf("     0x%4x", (mac2 & 0xffff));	//RESP_CNT
+				printf("  0x%2x", ((mac2 >> 16) & 0xff));	//RESP_FLAG
+				printf("  %3d", ((mac2 >> 24) & 0xff));	//RESP_TIMER
+				//printf(" %4d", (value2 >> 24) & 0xff); //r_age_field
 				reg_read(REG_TSRA1_ADDR, &mac);
 				ip_to_str(tmpstr, mac);
 				printf("     %s", tmpstr);
-				printf("  0x%8x\n", value2); //ATRD
-							     //printf("%04x", ((mac2 >> 16) & 0xffff));
-							     //printf("     %c\n", (((value2 >> 20) & 0x03)== 0x03)? 'y':'-');
+				printf("  0x%8x\n", value2);	//ATRD
+				//printf("%04x", ((mac2 >> 16) & 0xffff));
+				//printf("     %c\n", (((value2 >> 20) & 0x03)== 0x03)? 'y':'-');
 				if (value & 0x4000) {
 					printf("end of table %d\n", i);
 					return;
 				}
 				break;
-			}
-			else if (value & 0x4000) { //at_table_end
-				printf("found the last entry %d (not ready)\n", i);
+			} else if (value & 0x4000) {	//at_table_end
+				printf("found the last entry %d (not ready)\n",
+				       i);
 				return;
 			}
 			usleep(5000);
 		}
 
-		if(type == GENERAL_TABLE)
-			reg_write(REG_ATC_ADDR, 0x8105); //search for next dip address
+		if (type == GENERAL_TABLE)
+			reg_write(REG_ATC_ADDR, 0x8105);	//search for next dip address
 		else
-			reg_write(REG_ATC_ADDR, 0x811d); //search for next dip address
+			reg_write(REG_ATC_ADDR, 0x811d);	//search for next dip address
 		usleep(5000);
 	}
 }
 
-void dip_dump(void)
+void dip_dump(int argc, char *argv[])
 {
 	dip_dump_internal(GENERAL_TABLE);
 
@@ -1029,7 +1128,7 @@
 void dip_add(int argc, char *argv[])
 {
 	unsigned int value = 0;
-	unsigned int i, j;
+	unsigned int i = 0, j = 0;
 
 	value = 0;
 
@@ -1049,13 +1148,14 @@
 	j = 0;
 	for (i = 0; i < 7; i++) {
 		if (argv[4][i] != '0' && argv[4][i] != '1') {
-			printf("portmap format error, should be of combination of 0 or 1\n");
+			printf
+			    ("portmap format error, should be of combination of 0 or 1\n");
 			return;
 		}
 		j += (argv[4][i] - '0') * (1 << i);
 	}
-	value = j << 4;      //w_port_map
-	value |= (0x3 << 2); //static
+	value = j << 4;		//w_port_map
+	value |= (0x3 << 2);	//static
 
 	reg_write(REG_ATWD_ADDR, value);
 
@@ -1063,14 +1163,14 @@
 	reg_read(REG_ATWD_ADDR, &value);
 	printf("REG_ATWD_ADDR is 0x%x\n\r", value);
 
-	value = 0x8011; //single w_dip_cmd
+	value = 0x8011;		//single w_dip_cmd
 	reg_write(REG_ATC_ADDR, value);
 
 	usleep(1000);
 
 	for (i = 0; i < 20; i++) {
 		reg_read(REG_ATC_ADDR, &value);
-		if ((value & 0x8000) == 0) { //mac address busy
+		if ((value & 0x8000) == 0) {	//mac address busy
 			printf("done.\n");
 			return;
 		}
@@ -1092,15 +1192,15 @@
 	value = 0;
 	reg_write(REG_ATA2_ADDR, value);
 
-	value = 0; //STATUS=0, delete dip
+	value = 0;		//STATUS=0, delete dip
 	reg_write(REG_ATWD_ADDR, value);
 
-	value = 0x8011; //w_dip_cmd
+	value = 0x8011;		//w_dip_cmd
 	reg_write(REG_ATC_ADDR, value);
 
 	for (i = 0; i < 20; i++) {
 		reg_read(REG_ATC_ADDR, &value);
-		if ((value & 0x8000) == 0) { //mac address busy
+		if ((value & 0x8000) == 0) {	//mac address busy
 			if (argv[1] != NULL)
 				printf("done.\n");
 			return;
@@ -1111,12 +1211,12 @@
 		printf("timeout.\n");
 }
 
-void dip_clear(void)
+void dip_clear(int argc, char *argv[])
 {
 
-	unsigned int value;
+	unsigned int value = 0;
 
-	reg_write(REG_ATC_ADDR, 0x8102); //clear all dip
+	reg_write(REG_ATC_ADDR, 0x8102);	//clear all dip
 	usleep(5000);
 	reg_read(REG_ATC_ADDR, &value);
 	printf("REG_ATC_ADDR is 0x%x\n\r", value);
@@ -1124,25 +1224,24 @@
 
 static void sip_dump_internal(int type)
 {
-	unsigned int i, j, value, mac, mac2, value2;
+	unsigned int i = 0, j = 0, value = 0, mac = 0, mac2 = 0, value2 = 0;
 	int table_size = 0;
 	int hit_value1 = 0;
 	int hit_value2 = 0;
-	char tmpstr[16];
+	char tmpstr[16] = { 0 };
 
 	if (type == GENERAL_TABLE) {
 		table_size = 0x800;
-		reg_write(REG_ATC_ADDR, 0x8204); //sip search command
-		}else {
+		reg_write(REG_ATC_ADDR, 0x8204);	//sip search command
+	} else {
 		table_size = 0x40;
-		reg_write(REG_ATC_ADDR, 0x822c); //sip search command
+		reg_write(REG_ATC_ADDR, 0x822c);	//sip search command
 	}
 	printf("hash  port(0:6)   dip-address    sip-address      ATRD\n");
 	for (i = 0; i < table_size; i++) {
-		while (1)
-		{
+		while (1) {
 			reg_read(REG_ATC_ADDR, &value);
-			if(type == GENERAL_TABLE) {
+			if (type == GENERAL_TABLE) {
 				hit_value1 = value & (0x1 << 13);
 				hit_value2 = 1;
 			} else {
@@ -1150,12 +1249,12 @@
 				hit_value2 = value & (0x1 << 28);
 			}
 
-			if (hit_value1 && hit_value2) { //search_rdy
+			if (hit_value1 && hit_value2) {	//search_rdy
 				reg_read(REG_ATRD_ADDR, &value2);
 				//printf("REG_ATRD_ADDR=0x%x\n\r",value2);
 
-				printf("%03x:  ", (value >> 16) & 0xfff); //hash_addr_lu
-				j = (value2 >> 4) & 0xff;		  //r_port_map
+				printf("%03x:  ", (value >> 16) & 0xfff);	//hash_addr_lu
+				j = (value2 >> 4) & 0xff;	//r_port_map
 				printf("%c", (j & 0x01) ? '1' : '-');
 				printf("%c", (j & 0x02) ? '1' : '-');
 				printf("%c", (j & 0x04) ? '1' : '-');
@@ -1181,42 +1280,42 @@
 					return;
 				}
 				break;
-			} else if (value & 0x4000) { //at_table_end
-				printf("found the last entry %d (not ready)\n", i);
+			} else if (value & 0x4000) {	//at_table_end
+				printf("found the last entry %d (not ready)\n",
+				       i);
 				return;
 			}
 			usleep(5000);
 		}
 
-	if(type == GENERAL_TABLE)
-		reg_write(REG_ATC_ADDR, 0x8205); //search for next sip address
-	else
-		reg_write(REG_ATC_ADDR, 0x822d); //search for next sip address
-	usleep(5000);
+		if (type == GENERAL_TABLE)
+			reg_write(REG_ATC_ADDR, 0x8205);	//search for next sip address
+		else
+			reg_write(REG_ATC_ADDR, 0x822d);	//search for next sip address
+		usleep(5000);
 	}
 }
 
-void sip_dump(void)
+void sip_dump(int argc, char *argv[])
 {
 
 	sip_dump_internal(GENERAL_TABLE);
 
 }
 
-
 void sip_add(int argc, char *argv[])
 {
-	unsigned int i, j, value;
+	unsigned int i = 0, j = 0, value = 0;
 
 	value = 0;
-	str_to_ip(&value, argv[3]); //SIP
+	str_to_ip(&value, argv[3]);	//SIP
 
 	reg_write(REG_ATA2_ADDR, value);
 	printf("REG_ATA2_ADDR is 0x%x\n\r", value);
 
 	value = 0;
 
-	str_to_ip(&value, argv[4]); //DIP
+	str_to_ip(&value, argv[4]);	//DIP
 	reg_write(REG_ATA1_ADDR, value);
 	printf("REG_ATA1_ADDR is 0x%x\n\r", value);
 
@@ -1227,13 +1326,14 @@
 	j = 0;
 	for (i = 0; i < 7; i++) {
 		if (argv[5][i] != '0' && argv[5][i] != '1') {
-			printf("portmap format error, should be of combination of 0 or 1\n");
+			printf
+			    ("portmap format error, should be of combination of 0 or 1\n");
 			return;
 		}
 		j += (argv[5][i] - '0') * (1 << i);
 	}
-	value = j << 4;      //w_port_map
-	value |= (0x3 << 2); //static
+	value = j << 4;		//w_port_map
+	value |= (0x3 << 2);	//static
 
 	reg_write(REG_ATWD_ADDR, value);
 
@@ -1241,14 +1341,14 @@
 	reg_read(REG_ATWD_ADDR, &value);
 	printf("REG_ATWD_ADDR is 0x%x\n\r", value);
 
-	value = 0x8021; //single w_sip_cmd
+	value = 0x8021;		//single w_sip_cmd
 	reg_write(REG_ATC_ADDR, value);
 
 	usleep(1000);
 
 	for (i = 0; i < 20; i++) {
 		reg_read(REG_ATC_ADDR, &value);
-		if ((value & 0x8000) == 0) { //mac address busy
+		if ((value & 0x8000) == 0) {	//mac address busy
 			printf("done.\n");
 			return;
 		}
@@ -1260,25 +1360,25 @@
 
 void sip_del(int argc, char *argv[])
 {
-	unsigned int i, value;
+	unsigned int i = 0, value = 0;
 
 	value = 0;
 	str_to_ip(&value, argv[3]);
 
-	reg_write(REG_ATA2_ADDR, value); //SIP
+	reg_write(REG_ATA2_ADDR, value);	//SIP
 
 	str_to_ip(&value, argv[4]);
-	reg_write(REG_ATA1_ADDR, value); //DIP
+	reg_write(REG_ATA1_ADDR, value);	//DIP
 
-	value = 0; //STATUS=0, delete sip
+	value = 0;		//STATUS=0, delete sip
 	reg_write(REG_ATWD_ADDR, value);
 
-	value = 0x8021; //w_sip_cmd
+	value = 0x8021;		//w_sip_cmd
 	reg_write(REG_ATC_ADDR, value);
 
 	for (i = 0; i < 20; i++) {
 		reg_read(REG_ATC_ADDR, &value);
-		if ((value & 0x8000) == 0) { //mac address busy
+		if ((value & 0x8000) == 0) {	//mac address busy
 			if (argv[1] != NULL)
 				printf("done.\n");
 			return;
@@ -1289,11 +1389,11 @@
 		printf("timeout.\n");
 }
 
-void sip_clear(void)
+void sip_clear(int argc, char *argv[])
 {
-	unsigned int value;
+	unsigned int value = 0;
 
-	reg_write(REG_ATC_ADDR, 0x8202); //clear all sip
+	reg_write(REG_ATC_ADDR, 0x8202);	//clear all sip
 	usleep(5000);
 	reg_read(REG_ATC_ADDR, &value);
 	printf("REG_ATC_ADDR is 0x%x\n\r", value);
@@ -1301,13 +1401,13 @@
 
 static void table_dump_internal(int type)
 {
-	unsigned int i, j, value, mac, mac2, value2;
+	unsigned int i = 0, j = 0, value = 0, mac = 0, mac2 = 0, value2 = 0;
 	int table_size = 0;
 	int table_end = 0;
 	int hit_value1 = 0;
 	int hit_value2 = 0;
 
-	if (type == GENERAL_TABLE){
+	if (type == GENERAL_TABLE) {
 		table_size = 0x800;
 		table_end = 0x7FF;
 		reg_write(REG_ATC_ADDR, 0x8004);
@@ -1316,13 +1416,13 @@
 		table_end = 0x3F;
 		reg_write(REG_ATC_ADDR, 0x800C);
 	}
-	printf("hash  port(0:6)   fid   vid  age(s)   mac-address     filter my_mac\n");
+	printf
+	    ("hash  port(0:6)   fid   vid  age(s)   mac-address     filter my_mac\n");
 	for (i = 0; i < table_size; i++) {
-		while (1)
-		{
+		while (1) {
 			reg_read(REG_ATC_ADDR, &value);
 			//printf("ATC =  0x%x\n", value);
-			if(type == GENERAL_TABLE) {
+			if (type == GENERAL_TABLE) {
 				hit_value1 = value & (0x1 << 13);
 				hit_value2 = 1;
 			} else {
@@ -1330,10 +1430,11 @@
 				hit_value2 = value & (0x1 << 28);
 			}
 
-			if (hit_value1 && hit_value2 && (((value >> 15) & 0x1) == 0)) {
+			if (hit_value1 && hit_value2
+			    && (((value >> 15) & 0x1) == 0)) {
 				printf("%03x:   ", (value >> 16) & 0xfff);
 				reg_read(REG_ATRD_ADDR, &value2);
-				j = (value2 >> 4) & 0xff; //r_port_map
+				j = (value2 >> 4) & 0xff;	//r_port_map
 				printf("%c", (j & 0x01) ? '1' : '-');
 				printf("%c", (j & 0x02) ? '1' : '-');
 				printf("%c", (j & 0x04) ? '1' : '-');
@@ -1345,49 +1446,52 @@
 
 				reg_read(REG_TSRA2_ADDR, &mac2);
 
-				printf("   %2d", (mac2 >> 12) & 0x7); //FID
+				printf("   %2d", (mac2 >> 12) & 0x7);	//FID
 				printf("  %4d", (mac2 & 0xfff));
 				if (((value2 >> 24) & 0xff) == 0xFF)
-					printf("   --- "); //r_age_field:static
+					printf("   --- ");	//r_age_field:static
 				else
-					printf(" %5d ", (((value2 >> 24) & 0xff)+1)*2); //r_age_field
+					printf(" %5d ", (((value2 >> 24) & 0xff) + 1) * 2);	//r_age_field
 				reg_read(REG_TSRA1_ADDR, &mac);
 				printf("  %08x", mac);
 				printf("%04x", ((mac2 >> 16) & 0xffff));
-				printf("     %c", (((value2 >> 20) & 0x03) == 0x03) ? 'y' : '-');
-				printf("     %c\n", (((value2 >> 23) & 0x01) == 0x01) ? 'y' : '-');
-				if ((value & 0x4000) && (((value >> 16) & 0xfff) == table_end)) {
+				printf("     %c",
+				       (((value2 >> 20) & 0x03) ==
+					0x03) ? 'y' : '-');
+				printf("     %c\n",
+				       (((value2 >> 23) & 0x01) ==
+					0x01) ? 'y' : '-');
+				if ((value & 0x4000)
+				    && (((value >> 16) & 0xfff) == table_end)) {
 					printf("end of table %d\n", i);
 					return;
 				}
 				break;
-			}
-			else if ((value & 0x4000) && (((value >> 15) & 0x1) == 0) && (((value >> 16) & 0xfff) == table_end)) { //at_table_end
-				printf("found the last entry %d (not ready)\n", i);
+			} else if ((value & 0x4000) && (((value >> 15) & 0x1) == 0) && (((value >> 16) & 0xfff) == table_end)) {	//at_table_end
+				printf("found the last entry %d (not ready)\n",
+				       i);
 				return;
-			}
-			else
+			} else
 				usleep(5);
 		}
 
-	if(type == GENERAL_TABLE)
-		reg_write(REG_ATC_ADDR, 0x8005);//search for next address
-	else
-		reg_write(REG_ATC_ADDR, 0x800d);//search for next address
+		if (type == GENERAL_TABLE)
+			reg_write(REG_ATC_ADDR, 0x8005);	//search for next address
+		else
+			reg_write(REG_ATC_ADDR, 0x800d);	//search for next address
 		usleep(5);
 	}
 }
 
-void table_dump(void)
+void table_dump(int argc, char *argv[])
 {
 	table_dump_internal(GENERAL_TABLE);
 
 }
 
-
 void table_add(int argc, char *argv[])
 {
-	unsigned int i, j, value, is_filter, is_mymac;
+	unsigned int i = 0, j = 0, value = 0, is_filter = 0, is_mymac = 0;
 	char tmpstr[9];
 
 	is_filter = (argv[1][0] == 'f') ? 1 : 0;
@@ -1407,7 +1511,7 @@
 
 	value = strtoul(tmpstr, NULL, 16);
 	value = (value << 16);
-	value |= (1 << 15); //IVL=1
+	value |= (1 << 15);	//IVL=1
 
 	if (argc > 4) {
 		j = strtoul(argv[4], NULL, 0);
@@ -1415,7 +1519,7 @@
 			printf("wrong vid range, should be within 0~4095\n");
 			return;
 		}
-		value |= j; //vid
+		value |= j;	//vid
 	}
 
 	reg_write(REG_ATA2_ADDR, value);
@@ -1432,12 +1536,13 @@
 	j = 0;
 	for (i = 0; i < 7; i++) {
 		if (argv[3][i] != '0' && argv[3][i] != '1') {
-			printf("portmap format error, should be of combination of 0 or 1\n");
+			printf
+			    ("portmap format error, should be of combination of 0 or 1\n");
 			return;
 		}
 		j += (argv[3][i] - '0') * (1 << i);
 	}
-	value = j << 4; //w_port_map
+	value = j << 4;		//w_port_map
 
 	if (argc > 5) {
 		j = strtoul(argv[5], NULL, 0);
@@ -1445,11 +1550,11 @@
 			printf("wrong age range, should be within 1~255\n");
 			return;
 		}
-		value |= (j << 24);  //w_age_field
-		value |= (0x1 << 2); //dynamic
+		value |= (j << 24);	//w_age_field
+		value |= (0x1 << 2);	//dynamic
 	} else {
-		value |= (0xff << 24); //w_age_field
-		value |= (0x3 << 2);   //static
+		value |= (0xff << 24);	//w_age_field
+		value |= (0x3 << 2);	//static
 	}
 
 	if (argc > 6) {
@@ -1458,11 +1563,11 @@
 			printf("wrong eg-tag range, should be within 0~7\n");
 			return;
 		}
-		value |= (j << 13); //EG_TAG
+		value |= (j << 13);	//EG_TAG
 	}
 
 	if (is_filter)
-		value |= (7 << 20); //sa_filter
+		value |= (7 << 20);	//sa_filter
 
 	if (is_mymac)
 		value |= (1 << 23);
@@ -1473,14 +1578,14 @@
 	reg_read(REG_ATWD_ADDR, &value);
 	printf("REG_ATWD_ADDR is 0x%x\n\r", value);
 
-	value = 0x8001; //w_mac_cmd
+	value = 0x8001;		//w_mac_cmd
 	reg_write(REG_ATC_ADDR, value);
 
 	usleep(1000);
 
 	for (i = 0; i < 20; i++) {
 		reg_read(REG_ATC_ADDR, &value);
-		if ((value & 0x8000) == 0) { //mac address busy
+		if ((value & 0x8000) == 0) {	//mac address busy
 			printf("done.\n");
 			return;
 		}
@@ -1492,7 +1597,7 @@
 
 void table_search_mac_vid(int argc, char *argv[])
 {
-	unsigned int i, j, value, mac, mac2, value2;
+	unsigned int i = 0, j = 0, value = 0, mac = 0, mac2 = 0, value2 = 0;
 	char tmpstr[9];
 
 	if (!argv[3] || strlen(argv[3]) != 12) {
@@ -1510,26 +1615,26 @@
 
 	value = strtoul(tmpstr, NULL, 16);
 	value = (value << 16);
-	value |= (1 << 15); //IVL=1
+	value |= (1 << 15);	//IVL=1
 
 	j = strtoul(argv[5], NULL, 0);
 	if (4095 < j) {
 		printf("wrong vid range, should be within 0~4095\n");
 		return;
 	}
-	value |= j; //vid
+	value |= j;		//vid
 
 	reg_write(REG_ATA2_ADDR, value);
 	//printf("REG_ATA2_ADDR is 0x%x\n\r",value);
 
-	value = 0x8000; //w_mac_cmd
+	value = 0x8000;		//w_mac_cmd
 	reg_write(REG_ATC_ADDR, value);
 
 	usleep(1000);
 
 	for (i = 0; i < 20; i++) {
 		reg_read(REG_ATC_ADDR, &value);
-		if ((value & 0x8000) == 0) { //mac address busy
+		if ((value & 0x8000) == 0) {	//mac address busy
 			break;
 		}
 		usleep(1000);
@@ -1545,11 +1650,12 @@
 	}
 
 	printf("search done.\n");
-	printf("hash  port(0:6)   fid   vid  age   mac-address     filter my_mac\n");
+	printf
+	    ("hash  port(0:6)   fid   vid  age   mac-address     filter my_mac\n");
 
-	printf("%03x:   ", (value >> 16) & 0xfff); //hash_addr_lu
+	printf("%03x:   ", (value >> 16) & 0xfff);	//hash_addr_lu
 	reg_read(REG_ATRD_ADDR, &value2);
-	j = (value2 >> 4) & 0xff; //r_port_map
+	j = (value2 >> 4) & 0xff;	//r_port_map
 	printf("%c", (j & 0x01) ? '1' : '-');
 	printf("%c", (j & 0x02) ? '1' : '-');
 	printf("%c", (j & 0x04) ? '1' : '-');
@@ -1561,9 +1667,9 @@
 
 	reg_read(REG_TSRA2_ADDR, &mac2);
 
-	printf("   %2d", (mac2 >> 12) & 0x7); //FID
+	printf("   %2d", (mac2 >> 12) & 0x7);	//FID
 	printf("  %4d", (mac2 & 0xfff));
-	printf(" %4d", (value2 >> 24) & 0xff); //r_age_field
+	printf(" %4d", (value2 >> 24) & 0xff);	//r_age_field
 	reg_read(REG_TSRA1_ADDR, &mac);
 	printf("  %08x", mac);
 	printf("%04x", ((mac2 >> 16) & 0xffff));
@@ -1573,7 +1679,7 @@
 
 void table_search_mac_fid(int argc, char *argv[])
 {
-	unsigned int i, j, value, mac, mac2, value2;
+	unsigned int i = 0, j = 0, value = 0, mac = 0, mac2 = 0, value2 = 0;
 	char tmpstr[9];
 
 	if (!argv[3] || strlen(argv[3]) != 12) {
@@ -1591,26 +1697,26 @@
 
 	value = strtoul(tmpstr, NULL, 16);
 	value = (value << 16);
-	value &= ~(1 << 15); //IVL=0
+	value &= ~(1 << 15);	//IVL=0
 
 	j = strtoul(argv[5], NULL, 0);
 	if (7 < j) {
 		printf("wrong fid range, should be within 0~7\n");
 		return;
 	}
-	value |= (j << 12); //vid
+	value |= (j << 12);	//vid
 
 	reg_write(REG_ATA2_ADDR, value);
 	//printf("REG_ATA2_ADDR is 0x%x\n\r",value);
 
-	value = 0x8000; //w_mac_cmd
+	value = 0x8000;		//w_mac_cmd
 	reg_write(REG_ATC_ADDR, value);
 
 	usleep(1000);
 
 	for (i = 0; i < 20; i++) {
 		reg_read(REG_ATC_ADDR, &value);
-		if ((value & 0x8000) == 0) { //mac address busy
+		if ((value & 0x8000) == 0) {	//mac address busy
 			break;
 		}
 		usleep(1000);
@@ -1626,11 +1732,12 @@
 	}
 
 	printf("search done.\n");
-	printf("hash  port(0:6)   fid   vid  age   mac-address     filter my_mac\n");
+	printf
+	    ("hash  port(0:6)   fid   vid  age   mac-address     filter my_mac\n");
 
-	printf("%03x:   ", (value >> 16) & 0xfff); //hash_addr_lu
+	printf("%03x:   ", (value >> 16) & 0xfff);	//hash_addr_lu
 	reg_read(REG_ATRD_ADDR, &value2);
-	j = (value2 >> 4) & 0xff; //r_port_map
+	j = (value2 >> 4) & 0xff;	//r_port_map
 	printf("%c", (j & 0x01) ? '1' : '-');
 	printf("%c", (j & 0x02) ? '1' : '-');
 	printf("%c", (j & 0x04) ? '1' : '-');
@@ -1642,9 +1749,9 @@
 
 	reg_read(REG_TSRA2_ADDR, &mac2);
 
-	printf("   %2d", (mac2 >> 12) & 0x7); //FID
+	printf("   %2d", (mac2 >> 12) & 0x7);	//FID
 	printf("  %4d", (mac2 & 0xfff));
-	printf(" %4d", (value2 >> 24) & 0xff); //r_age_field
+	printf(" %4d", (value2 >> 24) & 0xff);	//r_age_field
 	reg_read(REG_TSRA1_ADDR, &mac);
 	printf("  %08x", mac);
 	printf("%04x", ((mac2 >> 16) & 0xffff));
@@ -1654,7 +1761,7 @@
 
 void table_del_fid(int argc, char *argv[])
 {
-	unsigned int i, j, value;
+	unsigned int i = 0, j = 0, value = 0;
 	char tmpstr[9];
 
 	if (!argv[3] || strlen(argv[3]) != 12) {
@@ -1676,20 +1783,20 @@
 			printf("wrong fid range, should be within 0~7\n");
 			return;
 		}
-		value |= (j << 12); //fid
+		value |= (j << 12);	/* fid */
 	}
 
 	reg_write(REG_ATA2_ADDR, value);
 
-	value = 0; //STATUS=0, delete mac
+	value = 0;		/* STATUS=0, delete mac */
 	reg_write(REG_ATWD_ADDR, value);
 
-	value = 0x8001; //w_mac_cmd
+	value = 0x8001;		//w_mac_cmd
 	reg_write(REG_ATC_ADDR, value);
 
 	for (i = 0; i < 20; i++) {
 		reg_read(REG_ATC_ADDR, &value);
-		if ((value & 0x8000) == 0) { //mac address busy
+		if ((value & 0x8000) == 0) {	/* mac address busy */
 			if (argv[1] != NULL)
 				printf("done.\n");
 			return;
@@ -1702,7 +1809,7 @@
 
 void table_del_vid(int argc, char *argv[])
 {
-	unsigned int i, j, value;
+	unsigned int i = 0, j = 0, value = 0;
 	char tmpstr[9];
 
 	if (!argv[3] || strlen(argv[3]) != 12) {
@@ -1724,19 +1831,19 @@
 		printf("wrong fid range, should be within 0~4095\n");
 		return;
 	}
-	value |= j; //vid
+	value |= j;		//vid
 	value |= 1 << 15;
 	reg_write(REG_ATA2_ADDR, value);
 
-	value = 0; //STATUS=0, delete mac
+	value = 0;		//STATUS=0, delete mac
 	reg_write(REG_ATWD_ADDR, value);
 
-	value = 0x8001; //w_mac_cmd
+	value = 0x8001;		//w_mac_cmd
 	reg_write(REG_ATC_ADDR, value);
 
 	for (i = 0; i < 20; i++) {
 		reg_read(REG_ATC_ADDR, &value);
-		if ((value & 0x8000) == 0) { //mac address busy
+		if ((value & 0x8000) == 0) {	//mac address busy
 			if (argv[1] != NULL)
 				printf("done.\n");
 			return;
@@ -1747,9 +1854,10 @@
 		printf("timeout.\n");
 }
 
-void table_clear(void)
+void table_clear(int argc, char *argv[])
 {
-	unsigned int value;
+	unsigned int value = 0;
+
 	reg_write(REG_ATC_ADDR, 0x8002);
 	usleep(5000);
 	reg_read(REG_ATC_ADDR, &value);
@@ -1759,8 +1867,8 @@
 
 void set_mirror_to(int argc, char *argv[])
 {
-	unsigned int value;
-	int idx;
+	unsigned int value = 0;
+	int idx = 0;
 
 	idx = strtoul(argv[3], NULL, 0);
 	if (idx < 0 || MAX_PORT < idx) {
@@ -1788,8 +1896,8 @@
 
 void set_mirror_from(int argc, char *argv[])
 {
-	unsigned int offset, value;
-	int idx, mirror;
+	unsigned int offset = 0, value = 0;
+	int idx = 0, mirror = 0;
 
 	idx = strtoul(argv[3], NULL, 0);
 	mirror = strtoul(argv[4], NULL, 0);
@@ -1815,7 +1923,7 @@
 
 void vlan_dump(int argc, char *argv[])
 {
-	unsigned int i, j, value, value2;
+	unsigned int i = 0, j = 0, value = 0, value2 = 0;
 	int eg_tag = 0;
 
 	if (argc == 4) {
@@ -1824,17 +1932,18 @@
 	}
 
 	if (eg_tag)
-		printf("  vid  fid  portmap    s-tag\teg_tag(0:untagged 2:tagged)\n");
+		printf
+		    ("  vid  fid  portmap    s-tag\teg_tag(0:untagged 2:tagged)\n");
 	else
 		printf("  vid  fid  portmap    s-tag\n");
 
 	for (i = 1; i < 4095; i++) {
-		value = (0x80000000 + i); //r_vid_cmd
+		value = (0x80000000 + i);	//r_vid_cmd
 		reg_write(REG_VTCR_ADDR, value);
 
 		for (j = 0; j < 20; j++) {
 			reg_read(REG_VTCR_ADDR, &value);
-			if ((value & 0x80000000) == 0) { //mac address busy
+			if ((value & 0x80000000) == 0) {	//mac address busy
 				break;
 			}
 			usleep(1000);
@@ -1881,7 +1990,7 @@
 			}
 			printf("\n");
 		} else {
-			/*print 16 vid for reference information*/
+			/*print 16 vid for reference information */
 			if (i <= 16) {
 				printf(" %4d  ", i);
 				printf(" %2d ", ((value & 0xe) >> 1));
@@ -1891,7 +2000,6 @@
 	}
 }
 
-
 static long timespec_diff_us(struct timespec start, struct timespec end)
 {
 	struct timespec temp;
@@ -1904,32 +2012,31 @@
 		temp.tv_sec = end.tv_sec - start.tv_sec;
 		temp.tv_nsec = end.tv_nsec - start.tv_nsec;
 	}
-	/* calculate second part*/
+	/* calculate second part */
 	duration += temp.tv_sec * 1000000;
-	/* calculate ns part*/
+	/* calculate ns part */
 	duration += temp.tv_nsec >> 10;
 
 	return duration;
 }
 
-
 void vlan_clear(int argc, char *argv[])
 {
-	unsigned int value;
-	int vid;
+	unsigned int value = 0;
+	int vid = 0;
 	unsigned long duration_us = 0;
 	struct timespec start, end;
 
 	for (vid = 0; vid < 4096; vid++) {
 		clock_gettime(CLOCK_REALTIME, &start);
-		value = 0; //invalid
+		value = 0;	//invalid
 		reg_write(REG_VAWD1_ADDR, value);
 
-		value = (0x80001000 + vid); //w_vid_cmd
+		value = (0x80001000 + vid);	//w_vid_cmd
 		reg_write(REG_VTCR_ADDR, value);
 		while (duration_us <= 1000) {
 			reg_read(REG_VTCR_ADDR, &value);
-			if ((value & 0x80000000) == 0) { //table busy
+			if ((value & 0x80000000) == 0) {	//table busy
 				break;
 			}
 			clock_gettime(CLOCK_REALTIME, &end);
@@ -1945,7 +2052,7 @@
 	unsigned int vlan_mem = 0;
 	unsigned int value = 0;
 	unsigned int value2 = 0;
-	int i, vid, fid;
+	int i = 0, vid = 0, fid = 0;
 	int stag = 0;
 	unsigned long eg_con = 0;
 	unsigned int eg_tag = 0;
@@ -1976,7 +2083,8 @@
 	vlan_mem = 0;
 	for (i = 0; i < 8; i++) {
 		if (argv[5][i] != '0' && argv[5][i] != '1') {
-			printf("portmap format error, should be of combination of 0 or 1\n");
+			printf
+			    ("portmap format error, should be of combination of 0 or 1\n");
 			return;
 		}
 		vlan_mem += (argv[5][i] - '0') * (1 << i);
@@ -1986,7 +2094,8 @@
 	if (argc > 6) {
 		stag = strtoul(argv[6], NULL, 16);
 		if (stag < 0 || 0xfff < stag) {
-			printf("wrong stag id range, should be within 0~4095\n");
+			printf
+			    ("wrong stag id range, should be within 0~4095\n");
 			return;
 		}
 		//printf("STAG is 0x%x\n", stag);
@@ -1994,33 +2103,35 @@
 
 	/* set vlan member */
 	value |= (vlan_mem << 16);
-	value |= (1 << 30);		//IVL=1
-	value |= ((stag & 0xfff) << 4); //stag
-	value |= 1;			//valid
+	value |= (1 << 30);	//IVL=1
+	value |= ((stag & 0xfff) << 4);	//stag
+	value |= 1;		//valid
 
 	if (argc > 7) {
 		eg_con = strtoul(argv[7], NULL, 2);
 		eg_con = !!eg_con;
-		value |= (eg_con << 29); //eg_con
-		value |= (1 << 28);      //eg tag control enable
+		value |= (eg_con << 29);	//eg_con
+		value |= (1 << 28);	//eg tag control enable
 	}
 
 	if (argc > 8 && !eg_con) {
 		if (strlen(argv[8]) != 8) {
-			printf("egtag portmap format error, should be of length 7\n");
+			printf
+			    ("egtag portmap format error, should be of length 7\n");
 			return;
 		}
 
 		for (i = 0; i < 8; i++) {
 			if (argv[8][i] < '0' || argv[8][i] > '3') {
-				printf("egtag portmap format error, should be of combination of 0 or 3\n");
+				printf
+				    ("egtag portmap format error, should be of combination of 0 or 3\n");
 				return;
 			}
 			//eg_tag += (argv[8][i] - '0') * (1 << i * 2);
 			eg_tag |= (argv[8][i] - '0') << (i * 2);
 		}
 
-		value |= (1 << 28);    //eg tag control enable
+		value |= (1 << 28);	//eg tag control enable
 		value2 &= ~(0xffff);
 		value2 |= eg_tag;
 	}
@@ -2028,14 +2139,14 @@
 	reg_write(REG_VAWD2_ADDR, value2);
 	//printf("VAWD1=0x%08x VAWD2=0x%08x ", value, value2);
 
-	value = (0x80001000 + vid); //w_vid_cmd
+	value = (0x80001000 + vid);	//w_vid_cmd
 	reg_write(REG_VTCR_ADDR, value);
 	//printf("VTCR=0x%08x\n", value);
 
 	for (i = 0; i < 300; i++) {
 		usleep(1000);
 		reg_read(REG_VTCR_ADDR, &value);
-		if ((value & 0x80000000) == 0) //table busy
+		if ((value & 0x80000000) == 0)	//table busy
 			break;
 	}
 
@@ -2047,7 +2158,7 @@
 {
 	unsigned int leaky_en = 0;
 	unsigned int wan_num = 4;
-	unsigned int port, offset, value;
+	unsigned int port = 0, offset = 0, value = 0;
 	char cmd[80];
 	int ret;
 
@@ -2074,8 +2185,7 @@
 			reg_write(0x2410, value & (~(1 << 3)));
 			reg_write(REG_ISC_ADDR, 0x01027d01);
 		}
-	}
-	else
+	} else
 		reg_write(REG_ISC_ADDR, 0x10027d60);
 
 	reg_write(0x1c, 0x08100810);
@@ -2086,15 +2196,15 @@
 	reg_write(0x2408, 0xb3ff);
 	reg_write(0x2608, 0xb3ff);
 	/* Enable Port ACL
-	* reg_write(0x2P04, 0xff0403);
-	*/
+	 * reg_write(0x2P04, 0xff0403);
+	 */
 	for (port = 0; port <= 6; port++) {
 		offset = 0x2004 + port * 0x100;
 		reg_read(offset, &value);
 		reg_write(offset, value | (1 << 10));
 	}
 
-	/*IGMP query only p4 -> p5*/
+	/*IGMP query only p4 -> p5 */
 	reg_write(0x94, 0x00ff0002);
 	if (wan_num == 4)
 		reg_write(0x98, 0x000a1008);
@@ -2114,7 +2224,7 @@
 	reg_write(0x98, 0x0);
 	reg_write(0x90, 0x8000b000);
 
-	/*IGMP p5 -> p4*/
+	/*IGMP p5 -> p4 */
 	reg_write(0x94, 0x00ff0002);
 	reg_write(0x98, 0x000a2008);
 	reg_write(0x90, 0x80005002);
@@ -2128,7 +2238,7 @@
 	reg_write(0x98, 0x0);
 	reg_write(0x90, 0x8000b001);
 
-	/*IGMP p0~p3 -> p6*/
+	/*IGMP p0~p3 -> p6 */
 	reg_write(0x94, 0x00ff0002);
 	if (wan_num == 4)
 		reg_write(0x98, 0x000a0f08);
@@ -2142,7 +2252,7 @@
 	reg_write(0x98, 0x0);
 	reg_write(0x90, 0x8000b002);
 
-	/*IGMP query only p6 -> p0~p3*/
+	/*IGMP query only p6 -> p0~p3 */
 	reg_write(0x94, 0x00ff0002);
 	reg_write(0x98, 0x000a4008);
 	reg_write(0x90, 0x80005004);
@@ -2159,18 +2269,21 @@
 	reg_write(0x98, 0x0);
 	reg_write(0x90, 0x8000b003);
 
-	/*Force eth2 to receive all igmp packets*/
-	snprintf(cmd, sizeof(cmd), "echo 2 > /sys/devices/virtual/net/%s/brif/%s/multicast_router", BR_DEVNAME, ETH_DEVNAME);
+	/*Force eth2 to receive all igmp packets */
+	snprintf(cmd, sizeof(cmd),
+		 "echo 2 > /sys/devices/virtual/net/%s/brif/%s/multicast_router",
+		 BR_DEVNAME, ETH_DEVNAME);
 	ret = system(cmd);
 	if (ret)
-		printf("Failed to set /sys/devices/virtual/net/%s/brif/%s/multicast_router\n",
-		       BR_DEVNAME, ETH_DEVNAME);
+		printf
+		    ("Failed to set /sys/devices/virtual/net/%s/brif/%s/multicast_router\n",
+		     BR_DEVNAME, ETH_DEVNAME);
 }
 
 void igmp_disable(int argc, char *argv[])
 {
-	unsigned int reg_offset, value;
-	int port_num;
+	unsigned int reg_offset = 0, value = 0;
+	int port_num = 0;
 
 	if (argc < 4) {
 		printf("insufficient arguments!\n");
@@ -2181,7 +2294,6 @@
 		printf("wrong port range, should be within 0~6\n");
 		return;
 	}
-
 	//set ISC: IGMP Snooping Control Register (offset: 0x0018)
 	reg_offset = 0x2008;
 	reg_offset |= (port_num << 8);
@@ -2192,7 +2304,7 @@
 
 void igmp_enable(int argc, char *argv[])
 {
-	unsigned int reg_offset, value;
+	unsigned int reg_offset = 0, value = 0;
 	int port_num;
 
 	if (argc < 4) {
@@ -2204,7 +2316,6 @@
 		printf("wrong port range, should be within 0~6\n");
 		return;
 	}
-
 	//set ISC: IGMP Snooping Control Register (offset: 0x0018)
 	reg_offset = 0x2008;
 	reg_offset |= (port_num << 8);
@@ -2212,15 +2323,15 @@
 	reg_write(reg_offset, value);
 }
 
-void igmp_off()
+void igmp_off(int argc, char *argv[])
 {
-	unsigned int value;
+	unsigned int value = 0;
 	//set ISC: IGMP Snooping Control Register (offset: 0x0018)
 	reg_read(REG_ISC_ADDR, &value);
-	value &= ~(1 << 18); //disable
+	value &= ~(1 << 18);	//disable
 	reg_write(REG_ISC_ADDR, value);
 
-	/*restore wan port multicast leaky vlan function: default disabled*/
+	/*restore wan port multicast leaky vlan function: default disabled */
 	reg_read(0x2010, &value);
 	reg_write(0x2010, value & (~(1 << 3)));
 	reg_read(0x2410, &value);
@@ -2229,10 +2340,10 @@
 	printf("config igmpsnoop off.\n");
 }
 
-int switch_reset(int argc, char *argv[])
+void switch_reset(int argc, char *argv[])
 {
 	if (chip_name == 0x7988)
-		return -1;
+		return;
 
 	unsigned int value = 0;
 	/*Software Register Reset  and Software System Reset */
@@ -2245,23 +2356,24 @@
 		printf("GPIO Mode (0x7c0c) select value =0x%x  \n", value);
 	}
 	printf("Switch Software Reset !!! \n");
-	return 0;
 }
 
-int phy_set_fc(int argc, char *argv[])
+void phy_set_fc(int argc, char *argv[])
 {
-	unsigned int port, pause_capable;
-	unsigned int phy_value;
+	unsigned int port = 0, pause_capable = 0;
+	unsigned int phy_value = 0;
 
 	port = atoi(argv[3]);
 	pause_capable = atoi(argv[4]);
 
-	/*Check the input parameters is right or not.*/
+	/*Check the input parameters is right or not. */
 	if (port > MAX_PORT - 2 || pause_capable > 1) {
-		printf("Illegal parameter (port:0~4, full_duplex_pause_capable:0|1)\n");
-		return -1;
+		printf
+		    ("Illegal parameter (port:0~4, full_duplex_pause_capable:0|1)\n");
+		return;
 	}
 	printf("port=%d, full_duplex_pause_capable:%d\n", port, pause_capable);
+
 	mii_mgr_read(port, 4, &phy_value);
 	printf("read phy_value:0x%x\r\n", phy_value);
 	phy_value &= (~(0x1 << 10));
@@ -2272,35 +2384,36 @@
 	}
 	mii_mgr_write(port, 4, phy_value);
 	printf("write phy_value:0x%x\r\n", phy_value);
-	return 0;
-} /*end phy_set_fc*/
+	return;
+}				/*end phy_set_fc */
 
-int phy_set_an(int argc, char *argv[])
+void phy_set_an(int argc, char *argv[])
 {
-	unsigned int port, auto_negotiation_en;
-	unsigned int phy_value;
+	unsigned int port = 0, auto_negotiation_en = 0;
+	unsigned int phy_value = 0;
 
 	port = atoi(argv[3]);
 	auto_negotiation_en = atoi(argv[4]);
 
-	/*Check the input parameters is right or not.*/
+	/*Check the input parameters is right or not. */
 	if (port > MAX_PORT - 2 || auto_negotiation_en > 1) {
-		printf("Illegal parameter (port:0~4, auto_negotiation_en:0|1)\n");
-		return -1;
+		printf
+		    ("Illegal parameter (port:0~4, auto_negotiation_en:0|1)\n");
+		return;
 	}
 	printf("port=%d, auto_negotiation_en:%d\n", port, auto_negotiation_en);
+
 	mii_mgr_read(port, 0, &phy_value);
 	printf("read phy_value:0x%x\r\n", phy_value);
 	phy_value &= (~(1 << 12));
 	phy_value |= (auto_negotiation_en << 12);
 	mii_mgr_write(port, 0, phy_value);
 	printf("write phy_value:0x%x\r\n", phy_value);
-	return 0;
-} /*end phy_set_an*/
+}				/*end phy_set_an */
 
-int set_mac_pfc(int argc, char *argv[])
+void set_mac_pfc(int argc, char *argv[])
 {
-	unsigned int value;
+	unsigned int value = 0;
 	int port, enable = 0;
 
 	port = atoi(argv[3]);
@@ -2308,7 +2421,7 @@
 	printf("enable: %d\n", enable);
 	if (port < 0 || port > 6 || enable < 0 || enable > 1) {
 		printf("Illegal parameter (port:0~6, enable|diable:0|1) \n");
-		return -1;
+		return;
 	}
 	if (chip_name == 0x7531 || chip_name == 0x7988) {
 		reg_read(REG_PFC_CTRL_ADDR, &value);
@@ -2316,25 +2429,23 @@
 		value |= (enable << port);
 		printf("write reg: %x, value: %x\n", REG_PFC_CTRL_ADDR, value);
 		reg_write(REG_PFC_CTRL_ADDR, value);
-	}
-	else
+	} else
 		printf("\nCommand not support by this chip.\n");
-	return 0;
 }
 
-int global_set_mac_fc(int argc, char *argv[])
+void global_set_mac_fc(int argc, char *argv[])
 {
 	unsigned char enable = 0;
-	unsigned int value, reg;
+	unsigned int value = 0, reg = 0;
 
 	if (chip_name == 0x7530) {
 		enable = atoi(argv[3]);
 		printf("enable: %d\n", enable);
 
-		/*Check the input parameters is right or not.*/
+		/*Check the input parameters is right or not. */
 		if (enable > 1) {
 			printf(HELP_MACCTL_FC);
-			return -1;
+			return;
 		}
 		reg_write(0x7000, 0x3);
 		reg = REG_GFCCR0_ADDR;
@@ -2345,17 +2456,16 @@
 		reg_write(REG_GFCCR0_ADDR, value);
 	} else
 		printf("\r\nCommand not support by this chip.\n");
-	return 0;
-} /*end mac_set_fc*/
+}				/*end mac_set_fc */
 
-int qos_sch_select(int argc, char *argv[])
+void qos_sch_select(int argc, char *argv[])
 {
-	unsigned char port, queue;
+	unsigned char port = 0, queue = 0;
 	unsigned char type = 0;
-	unsigned int value, reg;
+	unsigned int value = 0, reg = 0;
 
 	if (argc < 7)
-		return -1;
+		return;
 
 	port = atoi(argv[3]);
 	queue = atoi(argv[4]);
@@ -2363,26 +2473,26 @@
 
 	if (port > 6 || queue > 7) {
 		printf("\n Illegal input parameters\n");
-		return -1;
+		return;
 	}
 
 	if ((type != 0 && type != 1 && type != 2)) {
 		printf(HELP_QOS_TYPE);
-		return -1;
+		return;
 	}
 
-	printf("\r\nswitch qos type: %d.\n",type);
+	printf("\r\nswitch qos type: %d.\n", type);
 
 	if (!strncmp(argv[5], "min", 4)) {
 
 		if (type == 0) {
-			/*min sharper-->round roubin, disable min sharper rate limit*/
+			/*min sharper-->round roubin, disable min sharper rate limit */
 			reg = GSW_MMSCR0_Q(queue) + 0x100 * port;
 			reg_read(reg, &value);
 			value = 0x0;
 			reg_write(reg, value);
 		} else if (type == 1) {
-			/*min sharper-->sp, disable min sharper rate limit*/
+			/*min sharper-->sp, disable min sharper rate limit */
 			reg = GSW_MMSCR0_Q(queue) + 0x100 * port;
 			reg_read(reg, &value);
 			value = 0x0;
@@ -2390,75 +2500,72 @@
 			reg_write(reg, value);
 		} else {
 			printf("min sharper only support: rr or sp\n");
-			return -1;
+			return;
 		}
 	} else if (!strncmp(argv[5], "max", 4)) {
 		if (type == 1) {
-			/*max sharper-->sp, disable max sharper rate limit*/
+			/*max sharper-->sp, disable max sharper rate limit */
 			reg = GSW_MMSCR1_Q(queue) + 0x100 * port;
 			reg_read(reg, &value);
 			value = 0x0;
 			value |= (1 << 31);
 			reg_write(reg, value);
 		} else if (type == 2) {
-			/*max sharper-->wfq, disable max sharper rate limit*/
+			/*max sharper-->wfq, disable max sharper rate limit */
 			reg = GSW_MMSCR1_Q(queue) + 0x100 * port;
 			reg_read(reg, &value);
 			value = 0x0;
 			reg_write(reg, value);
 		} else {
 			printf("max sharper only support: wfq or sp\n");
-			return -1;
+			return;
 		}
 	} else {
-		printf("\r\nIllegal sharper:%s\n",argv[5]);
-		return -1;
+		printf("\r\nIllegal sharper:%s\n", argv[5]);
+		return;
 	}
-	printf("reg:0x%x--value:0x%x\n",reg,value);
-
-	return 0;
+	printf("reg:0x%x--value:0x%x\n", reg, value);
 }
 
 void get_upw(unsigned int *value, unsigned char base)
 {
 	*value &= (~((0x7 << 0) | (0x7 << 4) | (0x7 << 8) | (0x7 << 12) |
 		     (0x7 << 16) | (0x7 << 20)));
-	switch (base)
-	{
-		case 0: /* port-based 0x2x40[18:16] */
-			*value |= ((0x2 << 0) | (0x2 << 4) | (0x2 << 8) |
-				(0x2 << 12) | (0x7 << 16) | (0x2 << 20));
-			break;
-		case 1: /* tagged-based 0x2x40[10:8] */
-			*value |= ((0x2 << 0) | (0x2 << 4) | (0x7 << 8) |
-				(0x2 << 12) | (0x2 << 16) | (0x2 << 20));
-			break;
-		case 2: /* DSCP-based 0x2x40[14:12] */
-			*value |= ((0x2 << 0) | (0x2 << 4) | (0x2 << 8) |
-				(0x7 << 12) | (0x2 << 16) | (0x2 << 20));
-			break;
-		case 3: /* acl-based 0x2x40[2:0] */
-			*value |= ((0x7 << 0) | (0x2 << 4) | (0x2 << 8) |
-				(0x2 << 12) | (0x2 << 16) | (0x2 << 20));
-			break;
-		case 4: /* arl-based 0x2x40[22:20] */
-			*value |= ((0x2 << 0) | (0x2 << 4) | (0x2 << 8) |
-				(0x2 << 12) | (0x2 << 16) | (0x7 << 20));
-			break;
-		case 5: /* stag-based 0x2x40[6:4] */
-			*value |= ((0x2 << 0) | (0x7 << 4) | (0x2 << 8) |
-				(0x2 << 12) | (0x2 << 16) | (0x2 << 20));
-			break;
-		default:
-			break;
+	switch (base) {
+	case 0:		/* port-based 0x2x40[18:16] */
+		*value |= ((0x2 << 0) | (0x2 << 4) | (0x2 << 8) |
+			   (0x2 << 12) | (0x7 << 16) | (0x2 << 20));
+		break;
+	case 1:		/* tagged-based 0x2x40[10:8] */
+		*value |= ((0x2 << 0) | (0x2 << 4) | (0x7 << 8) |
+			   (0x2 << 12) | (0x2 << 16) | (0x2 << 20));
+		break;
+	case 2:		/* DSCP-based 0x2x40[14:12] */
+		*value |= ((0x2 << 0) | (0x2 << 4) | (0x2 << 8) |
+			   (0x7 << 12) | (0x2 << 16) | (0x2 << 20));
+		break;
+	case 3:		/* acl-based 0x2x40[2:0] */
+		*value |= ((0x7 << 0) | (0x2 << 4) | (0x2 << 8) |
+			   (0x2 << 12) | (0x2 << 16) | (0x2 << 20));
+		break;
+	case 4:		/* arl-based 0x2x40[22:20] */
+		*value |= ((0x2 << 0) | (0x2 << 4) | (0x2 << 8) |
+			   (0x2 << 12) | (0x2 << 16) | (0x7 << 20));
+		break;
+	case 5:		/* stag-based 0x2x40[6:4] */
+		*value |= ((0x2 << 0) | (0x7 << 4) | (0x2 << 8) |
+			   (0x2 << 12) | (0x2 << 16) | (0x2 << 20));
+		break;
+	default:
+		break;
 	}
 }
 
 void qos_set_base(int argc, char *argv[])
 {
 	unsigned char base = 0;
-	unsigned char port;
-	unsigned int value;
+	unsigned char port = 0;
+	unsigned int value = 0;
 
 	if (argc < 5)
 		return;
@@ -2472,13 +2579,12 @@
 	}
 
 	if (port > 6) {
-		printf("Illegal port index:%d\n",port);
+		printf("Illegal port index:%d\n", port);
 		return;
 	}
 
 	printf("\r\nswitch qos base : %d. (port-based:0, tag-based:1,\
-		dscp-based:2, acl-based:3, arl-based:4, stag-based:5)\n",
-	       base);
+		dscp-based:2, acl-based:3, arl-based:4, stag-based:5)\n", base);
 	if (chip_name == 0x7530) {
 
 		reg_read(0x44, &value);
@@ -2491,7 +2597,7 @@
 		reg_read(GSW_UPW(port), &value);
 		get_upw(&value, base);
 		reg_write(GSW_UPW(port), value);
-		printf("reg:0x%x, value: 0x%x\n",GSW_UPW(port),value);
+		printf("reg:0x%x, value: 0x%x\n", GSW_UPW(port), value);
 
 	} else {
 		printf("unknown switch device");
@@ -2501,9 +2607,9 @@
 
 void qos_wfq_set_weight(int argc, char *argv[])
 {
-	int port, weight[8], i;
-	unsigned char queue;
-	unsigned int reg, value;
+	int port = 0, weight[8], i = 0;
+	unsigned char queue = 0;
+	unsigned int reg = 0, value = 0;
 
 	port = atoi(argv[3]);
 
@@ -2524,14 +2630,12 @@
 		}
 	}
 	printf("port: %x, q0: %x, q1: %x, q2: %x, q3: %x, \
-		q4: %x, q5: %x, q6: %x, q7: %x\n",
-	       port, weight[0], weight[1], weight[2], weight[3], weight[4],
-	       weight[5], weight[6], weight[7]);
+		q4: %x, q5: %x, q6: %x, q7: %x\n", port, weight[0], weight[1], weight[2], weight[3], weight[4], weight[5], weight[6], weight[7]);
 
 	for (queue = 0; queue < 8; queue++) {
 		reg = GSW_MMSCR1_Q(queue) + 0x100 * port;
 		reg_read(reg, &value);
-		value &= (~(0xf << 24)); //bit24~27
+		value &= (~(0xf << 24));	//bit24~27
 		value |= (((weight[queue] - 1) & 0xf) << 24);
 		printf("reg: %x, value: %x\n", reg, value);
 		reg_write(reg, value);
@@ -2540,8 +2644,8 @@
 
 void qos_set_portpri(int argc, char *argv[])
 {
-	unsigned char port, prio;
-	unsigned int value;
+	unsigned char port = 0, prio = 0;
+	unsigned int value = 0;
 
 	port = atoi(argv[3]);
 	prio = atoi(argv[4]);
@@ -2560,8 +2664,8 @@
 
 void qos_set_dscppri(int argc, char *argv[])
 {
-	unsigned char prio, dscp, pim_n, pim_offset;
-	unsigned int reg, value;
+	unsigned char prio = 0, dscp = 0, pim_n = 0, pim_offset = 0;
+	unsigned int value = 0, reg = 0;
 
 	dscp = atoi(argv[3]);
 	prio = atoi(argv[4]);
@@ -2583,8 +2687,8 @@
 
 void qos_pri_mapping_queue(int argc, char *argv[])
 {
-	unsigned char prio, queue, pem_n, port;
-	unsigned int reg, value;
+	unsigned char prio = 0, queue = 0, pem_n = 0, port = 0;
+	unsigned int value = 0, reg = 0;
 
 	if (argc < 6)
 		return;
@@ -2597,6 +2701,7 @@
 		printf(HELP_QOS_PRIO_QMAP);
 		return;
 	}
+
 	if (chip_name == 0x7530) {
 		pem_n = prio / 2;
 		reg = pem_n * 0x4 + 0x48;
@@ -2614,34 +2719,33 @@
 		pem_n = prio / 2;
 		reg = GSW_PEM(pem_n) + 0x100 * port;
 		reg_read(reg, &value);
-		if (prio % 2) { // 1 1
+		if (prio % 2) {	// 1 1
 			value &= (~(0x7 << 25));
 			value |= ((queue & 0x7) << 25);
-		} else { // 0 0
+		} else {	// 0 0
 			value &= (~(0x7 << 9));
 			value |= ((queue & 0x7) << 9);
 		}
 		reg_write(reg, value);
 		printf("write reg: %x, value: %x\n", reg, value);
-	}
-	else {
+	} else {
 		printf("unknown switch device");
 		return;
 	}
 }
 
 static int macMT753xVlanSetVid(unsigned char index, unsigned char active,
-			       unsigned short vid, unsigned char portMap, unsigned char tagPortMap,
-			       unsigned char ivl_en, unsigned char fid, unsigned short stag)
+			       unsigned short vid, unsigned char portMap,
+			       unsigned char tagPortMap, unsigned char ivl_en,
+			       unsigned char fid, unsigned short stag)
 {
 	unsigned int value = 0;
 	unsigned int value2 = 0;
-	unsigned int reg;
-	int i;
+	unsigned int reg = 0;
+	int i = 0;
 
 	printf("index: %x, active: %x, vid: %x, portMap: %x, \
-		tagPortMap: %x, ivl_en: %x, fid: %x, stag: %x\n",
-	       index, active, vid, portMap, tagPortMap, ivl_en, fid, stag);
+		tagPortMap: %x, ivl_en: %x, fid: %x, stag: %x\n", index, active, vid, portMap, tagPortMap, ivl_en, fid, stag);
 
 	value = (portMap << 16);
 	value |= (stag << 4);
@@ -2656,22 +2760,22 @@
 	}
 
 	if (value2)
-		value |= (1 << 28); // eg_tag
+		value |= (1 << 28);	// eg_tag
 
-	reg = 0x98; // VAWD2
+	reg = 0x98;		// VAWD2
 	reg_write(reg, value2);
 
-	reg = 0x94; // VAWD1
+	reg = 0x94;		// VAWD1
 	reg_write(reg, value);
 
-	reg = 0x90; // VTCR
+	reg = 0x90;		// VTCR
 	value = (0x80001000 + vid);
 	reg_write(reg, value);
 
-	reg = 0x90; // VTCR
+	reg = 0x90;		// VTCR
 	while (1) {
 		reg_read(reg, &value);
-		if ((value & 0x80000000) == 0) //table busy
+		if ((value & 0x80000000) == 0)	//table busy
 			break;
 	}
 
@@ -2685,45 +2789,14 @@
 	       index, active, vid, portMap, tagPortMap);
 	return 0;
 
-} /*end macMT753xVlanSetVid*/
-/*
-static int macMT753xVlanGetVtbl(unsigned short index)
-{
-	unsigned int reg, value, vawd1, vawd2;
-
-	reg = 0x90; // VTCR
-	value = (0x80000000 + index);
-
-	reg_write(reg, value);
-
-	reg = 0x90; // VTCR
-	while (1) {
-		reg_read(reg, &value);
-		if ((value & 0x80000000) == 0) //table busy
-			break;
-	}
-
-	reg = 0x94; // VAWD1
-	reg_read(reg, &vawd1);
-
-	reg = 0x98; // VAWD2
-	reg_read(reg, &vawd2);
-
-	if (vawd1 & 0x1) {
-		fprintf(stderr, "%d.%s vid:%d fid:%d portMap:0x%x \
-				tagMap:0x%x stag:0x%x ivl_en:0x%x\r\n",
-			index, (vawd1 & 0x1) ? "on" : "off", index, ((vawd1 & 0xe) >> 1),
-			(vawd1 & 0xff0000) >> 16, vawd2, (vawd1 & 0xfff0) >> 0x4, (vawd1 >> 30) & 0x1);
-	}
-	return 0;
-} */ /*end macMT753xVlanGetVtbl*/
+}				/*end macMT753xVlanSetVid */
 
 static int macMT753xVlanSetPvid(unsigned char port, unsigned short pvid)
 {
-	unsigned int value;
-	unsigned int reg;
+	unsigned int value = 0;
+	unsigned int reg = 0;
 
-	/*Parameters is error*/
+	/*Parameters is error */
 	if (port > 6)
 		return -1;
 
@@ -2742,38 +2815,6 @@
 	printf("SetPVID: port:%d pvid:%d\r\n", port, pvid);
 	return 0;
 }
-/*
-static int macMT753xVlanGetPvid(unsigned char port)
-{
-	unsigned int value;
-	unsigned int reg;
-
-	if (port > 6)
-		return -1;
-	reg = 0x2014 + (port * 0x100);
-	reg_read(reg, &value);
-	return (value & 0xfff);
-} */
-/*
-static int macMT753xVlanDisp(void)
-{
-	unsigned int i = 0;
-	unsigned int reg, value;
-
-	reg = 0x2604;
-	reg_read(reg, &value);
-	value &= 0x30000000;
-
-	fprintf(stderr, "VLAN function is %s\n", value ? ETHCMD_ENABLE : ETHCMD_DISABLE);
-	fprintf(stderr, "PVID e0:%02d e1:%02d e2:%02d e3:%02d e4:%02d e5:%02d e6:%02d\n",
-		macMT753xVlanGetPvid(0), macMT753xVlanGetPvid(1), macMT753xVlanGetPvid(2),
-		macMT753xVlanGetPvid(3), macMT753xVlanGetPvid(4), macMT753xVlanGetPvid(5), macMT753xVlanGetPvid(6));
-
-	for (i = 0; i < MAX_VID_VALUE; i++)
-		macMT753xVlanGetVtbl(i);
-
-	return 0;
-}*/ /*end macMT753xVlanDisp*/
 
 void doVlanSetPvid(int argc, char *argv[])
 {
@@ -2782,7 +2823,7 @@
 
 	port = atoi(argv[3]);
 	pvid = atoi(argv[4]);
-	/*Check the input parameters is right or not.*/
+	/*Check the input parameters is right or not. */
 	if ((port >= SWITCH_MAX_PORT) || (pvid > MAX_VID_VALUE)) {
 		printf(HELP_VLAN_PVID);
 		return;
@@ -2792,7 +2833,7 @@
 
 	printf("port:%d pvid:%d,vlancap: max_port:%d maxvid:%d\r\n",
 	       port, pvid, SWITCH_MAX_PORT, MAX_VID_VALUE);
-} /*end doVlanSetPvid*/
+}				/*end doVlanSetPvid */
 
 void doVlanSetVid(int argc, char *argv[])
 {
@@ -2810,13 +2851,13 @@
 	active = atoi(argv[4]);
 	vid = atoi(argv[5]);
 
-	/*Check the input parameters is right or not.*/
+	/*Check the input parameters is right or not. */
 	if ((index >= MAX_VLAN_RULE) || (vid >= 4096) || (active > ACTIVED)) {
 		printf(HELP_VLAN_VID);
 		return;
 	}
 
-	/*CPU Port is always the membership*/
+	/*CPU Port is always the membership */
 	portMap = atoi(argv[6]);
 	tagPortMap = atoi(argv[7]);
 
@@ -2832,21 +2873,21 @@
 	macMT753xVlanSetVid(index, active, vid, portMap, tagPortMap,
 			    ivl_en, fid, stag);
 	printf("index:%d active:%d vid:%d\r\n", index, active, vid);
-} /*end doVlanSetVid*/
+}				/*end doVlanSetVid */
 
 void doVlanSetAccFrm(int argc, char *argv[])
 {
 	unsigned char port = 0;
 	unsigned char type = 0;
-	unsigned int value;
-	unsigned int reg;
+	unsigned int value = 0;
+	unsigned int reg = 0;
 
 	port = atoi(argv[3]);
 	type = atoi(argv[4]);
 
 	printf("port: %d, type: %d\n", port, type);
 
-	/*Check the input parameters is right or not.*/
+	/*Check the input parameters is right or not. */
 	if ((port > SWITCH_MAX_PORT) || (type > REG_PVC_ACC_FRM_RELMASK)) {
 		printf(HELP_VLAN_ACC_FRM);
 		return;
@@ -2859,21 +2900,21 @@
 
 	printf("write reg: %x, value: %x\n", reg, value);
 	reg_write(reg, value);
-} /*end doVlanSetAccFrm*/
+}				/*end doVlanSetAccFrm */
 
 void doVlanSetPortAttr(int argc, char *argv[])
 {
 	unsigned char port = 0;
 	unsigned char attr = 0;
-	unsigned int value;
-	unsigned int reg;
+	unsigned int value = 0;
+	unsigned int reg = 0;
 
 	port = atoi(argv[3]);
 	attr = atoi(argv[4]);
 
 	printf("port: %x, attr: %x\n", port, attr);
 
-	/*Check the input parameters is right or not.*/
+	/*Check the input parameters is right or not. */
 	if (port > SWITCH_MAX_PORT || attr > 3) {
 		printf(HELP_VLAN_PORT_ATTR);
 		return;
@@ -2892,13 +2933,14 @@
 {
 	unsigned char port = 0;
 	unsigned char mode = 0;
-	unsigned int value;
-	unsigned int reg;
+	unsigned int value = 0;
+	unsigned int reg = 0;
+
 	port = atoi(argv[3]);
 	mode = atoi(argv[4]);
 	printf("port: %x, mode: %x\n", port, mode);
 
-	/*Check the input parameters is right or not.*/
+	/*Check the input parameters is right or not. */
 	if (port > SWITCH_MAX_PORT || mode > 3) {
 		printf(HELP_VLAN_PORT_MODE);
 		return;
@@ -2916,15 +2958,15 @@
 {
 	unsigned char port = 0;
 	unsigned char eg_tag = 0;
-	unsigned int value;
-	unsigned int reg;
+	unsigned int value = 0;
+	unsigned int reg = 0;
 
 	port = atoi(argv[3]);
 	eg_tag = atoi(argv[4]);
 
 	printf("port: %d, eg_tag: %d\n", port, eg_tag);
 
-	/*Check the input parameters is right or not.*/
+	/*Check the input parameters is right or not. */
 	if ((port > SWITCH_MAX_PORT) || (eg_tag > REG_PCR_EG_TAG_RELMASK)) {
 		printf(HELP_VLAN_EGRESS_TAG_PCR);
 		return;
@@ -2938,21 +2980,21 @@
 	printf("write reg: %x, value: %x\n", reg, value);
 	reg_write(reg, value);
 
-} /*end doVlanSetEgressTagPCR*/
+}				/*end doVlanSetEgressTagPCR */
 
 void doVlanSetEgressTagPVC(int argc, char *argv[])
 {
 	unsigned char port = 0;
 	unsigned char eg_tag = 0;
-	unsigned int value;
-	unsigned int reg;
+	unsigned int value = 0;
+	unsigned int reg = 0;
 
 	port = atoi(argv[3]);
 	eg_tag = atoi(argv[4]);
 
 	printf("port: %d, eg_tag: %d\n", port, eg_tag);
 
-	/*Check the input parameters is right or not.*/
+	/*Check the input parameters is right or not. */
 	if ((port > SWITCH_MAX_PORT) || (eg_tag > REG_PVC_EG_TAG_RELMASK)) {
 		printf(HELP_VLAN_EGRESS_TAG_PVC);
 		return;
@@ -2965,19 +3007,19 @@
 
 	printf("write reg: %x, value: %x\n", reg, value);
 	reg_write(reg, value);
-} /*end doVlanSetEgressTagPVC*/
+}				/*end doVlanSetEgressTagPVC */
 
 void doArlAging(int argc, char *argv[])
 {
 	unsigned char aging_en = 0;
-	unsigned int time = 0, aging_cnt = 0, aging_unit = 0, value, reg;
-	;
+	unsigned int time = 0, aging_cnt = 0, aging_unit = 0, value = 0, reg =
+	    0;
 
 	aging_en = atoi(argv[3]);
 	time = atoi(argv[4]);
 	printf("aging_en: %x, aging time: %x\n", aging_en, time);
 
-	/*Check the input parameters is right or not.*/
+	/*Check the input parameters is right or not. */
 	if ((aging_en != 0 && aging_en != 1) || (time <= 0 || time > 65536)) {
 		printf(HELP_ARL_AGING);
 		return;
@@ -3006,16 +3048,16 @@
 
 void doMirrorEn(int argc, char *argv[])
 {
-	unsigned char mirror_en;
-	unsigned char mirror_port;
-	unsigned int value, reg;
+	unsigned char mirror_en = 0;
+	unsigned char mirror_port = 0;
+	unsigned int value = 0, reg = 0;
 
 	mirror_en = atoi(argv[3]);
 	mirror_port = atoi(argv[4]);
 
 	printf("mirror_en: %d, mirror_port: %d\n", mirror_en, mirror_port);
 
-	/*Check the input parameters is right or not.*/
+	/*Check the input parameters is right or not. */
 	if ((mirror_en > 1) || (mirror_port > REG_CFC_MIRROR_PORT_RELMASK)) {
 		printf(HELP_MIRROR_EN);
 		return;
@@ -3031,12 +3073,13 @@
 	printf("write reg: %x, value: %x\n", reg, value);
 	reg_write(reg, value);
 
-} /*end doMirrorEn*/
+}				/*end doMirrorEn */
 
 void doMirrorPortBased(int argc, char *argv[])
 {
-	unsigned char port, port_tx_mir, port_rx_mir, vlan_mis, acl_mir, igmp_mir;
-	unsigned int value, reg;
+	unsigned char port = 0, port_tx_mir = 0, port_rx_mir = 0, vlan_mis =
+	    0, acl_mir = 0, igmp_mir = 0;
+	unsigned int value = 0, reg = 0;
 
 	port = atoi(argv[3]);
 	port_tx_mir = atoi(argv[4]);
@@ -3045,20 +3088,28 @@
 	vlan_mis = atoi(argv[7]);
 	igmp_mir = atoi(argv[8]);
 
-	printf("port:%d, port_tx_mir:%d, port_rx_mir:%d, acl_mir:%d, vlan_mis:%d, igmp_mir:%d\n", port, port_tx_mir, port_rx_mir, acl_mir, vlan_mis, igmp_mir);
+	printf
+	    ("port:%d, port_tx_mir:%d, port_rx_mir:%d, acl_mir:%d, vlan_mis:%d, igmp_mir:%d\n",
+	     port, port_tx_mir, port_rx_mir, acl_mir, vlan_mis, igmp_mir);
 
-	/*Check the input parameters is right or not.*/
+	/*Check the input parameters is right or not. */
 	//if((port >= vlanCap->max_port_no) || (port_tx_mir > 1) || (port_rx_mir > 1) || (acl_mir > 1) || (vlan_mis > 1)){
-	if ((port >= 7) || (port_tx_mir > 1) || (port_rx_mir > 1) || (acl_mir > 1) || (vlan_mis > 1)) { // also allow CPU port (port6)
+	if ((port >= 7) || (port_tx_mir > 1) || (port_rx_mir > 1) || (acl_mir > 1) || (vlan_mis > 1)) {	// also allow CPU port (port6)
 		printf(HELP_MIRROR_PORTBASED);
 		return;
 	}
 
 	reg = REG_PCR_P0_ADDR + port * 0x100;
 	reg_read(reg, &value);
-	value &= ~(REG_PORT_TX_MIR_MASK | REG_PORT_RX_MIR_MASK | REG_PCR_ACL_MIR_MASK | REG_PCR_VLAN_MIS_MASK);
-	value |= (port_tx_mir << REG_PORT_TX_MIR_OFFT) + (port_rx_mir << REG_PORT_RX_MIR_OFFT);
-	value |= (acl_mir << REG_PCR_ACL_MIR_OFFT) + (vlan_mis << REG_PCR_VLAN_MIS_OFFT);
+	value &=
+	    ~(REG_PORT_TX_MIR_MASK | REG_PORT_RX_MIR_MASK | REG_PCR_ACL_MIR_MASK
+	      | REG_PCR_VLAN_MIS_MASK);
+	value |=
+	    (port_tx_mir << REG_PORT_TX_MIR_OFFT) +
+	    (port_rx_mir << REG_PORT_RX_MIR_OFFT);
+	value |=
+	    (acl_mir << REG_PCR_ACL_MIR_OFFT) +
+	    (vlan_mis << REG_PCR_VLAN_MIS_OFFT);
 
 	printf("write reg: %x, value: %x\n", reg, value);
 	reg_write(reg, value);
@@ -3071,15 +3122,15 @@
 	printf("write reg: %x, value: %x\n", reg, value);
 	reg_write(reg, value);
 
-} /*end doMirrorPortBased*/
+}				/*end doMirrorPortBased */
 
 void doStp(int argc, char *argv[])
 {
 	unsigned char port = 0;
 	unsigned char fid = 0;
 	unsigned char state = 0;
-	unsigned int value;
-	unsigned int reg;
+	unsigned int value = 0;
+	unsigned int reg = 0;
 
 	port = atoi(argv[2]);
 	fid = atoi(argv[3]);
@@ -3087,7 +3138,7 @@
 
 	printf("port: %d, fid: %d, state: %d\n", port, fid, state);
 
-	/*Check the input parameters is right or not.*/
+	/*Check the input parameters is right or not. */
 	if ((port > MAX_PORT + 1) || (fid > 7) || (state > 3)) {
 		printf(HELP_STP);
 		return;
@@ -3102,45 +3153,54 @@
 	reg_write(reg, value);
 }
 
-int ingress_rate_set(int on_off, unsigned int port, unsigned int bw)
+void _ingress_rate_set(int on_off, int port, int bw)
 {
-	unsigned int reg, value;
+	unsigned int reg = 0, value = 0;
 
 	reg = 0x1800 + (0x100 * port);
 	value = 0;
-	/*token-bucket*/
+	/*token-bucket */
 	if (on_off == 1) {
 		if (chip_name == 0x7530) {
 			if (bw > 1000000) {
-				printf("\n**Charge rate(%d) is larger than line rate(1000000kbps)**\n",bw);
-				return -1;
+				printf
+				    ("\n**Charge rate(%d) is larger than line rate(1000000kbps)**\n",
+				     bw);
+				return;
 			}
-			value = ((bw / 32) << 16) + (1 << 15) + (7 << 8) + (1 << 7) + 0x0f;
+			value =
+			    ((bw / 32) << 16) + (1 << 15) + (7 << 8) +
+			    (1 << 7) + 0x0f;
 		} else if (chip_name == 0x7531 || chip_name == 0x7988) {
 			if ((chip_name == 0x7531) && (bw > 2500000)) {
-				printf("\n**Charge rate(%d) is larger than line rate(2500000kbps)**\n",bw);
-				return -1;
+				printf
+				    ("\n**Charge rate(%d) is larger than line rate(2500000kbps)**\n",
+				     bw);
+				return;
 			}
 
 			if ((chip_name == 0x7988) && (bw > 4000000)) {
-				printf("\n**Charge rate(%d) is larger than line rate(4000000kbps)**\n",bw);
-				return -1;
+				printf
+				    ("\n**Charge rate(%d) is larger than line rate(4000000kbps)**\n",
+				     bw);
+				return;
 			}
 
-			if (bw/32 >= 65536) //supoort 2.5G case
-				value = ((bw / 32) << 16) + (1 << 15) + (1 << 14) + (1 << 12) + (7 << 8) + 0xf;
+			if (bw / 32 >= 65536)	//supoort 2.5G case
+				value =
+				    ((bw / 32) << 16) + (1 << 15) + (1 << 14) +
+				    (1 << 12) + (7 << 8) + 0xf;
 			else
-				value = ((bw / 32) << 16) + (1 << 15) + (1 << 14) + (7 << 8) + 0xf;
-		}
-		else
+				value =
+				    ((bw / 32) << 16) + (1 << 15) + (1 << 14) +
+				    (7 << 8) + 0xf;
+		} else
 			printf("unknow chip\n");
 	}
-
 #if leaky_bucket
 	reg_read(reg, &value);
 	value &= 0xffff0000;
-	if (on_off == 1)
-	{
+	if (on_off == 1) {
 		value |= on_off << 15;
 		//7530 same as 7531
 		if (bw < 100) {
@@ -3166,39 +3226,71 @@
 	reg_read(reg, &value);
 	value = 0x110104;
 	reg_write(reg, value);
-	return 0;
+
+	if (on_off)
+		printf("switch port=%d, bw=%d\n", port, bw);
+	else
+		printf("switch port=%d ingress rate limit off\n", port);
 }
 
-int egress_rate_set(int on_off, int port, int bw)
+void ingress_rate_set(int argc, char *argv[])
 {
-	unsigned int reg, value;
+	int on_off = 0, port = 0, bw = 0;
+
+	port = strtoul(argv[3], NULL, 0);
+	if (argv[2][1] == 'n') {
+		bw = strtoul(argv[4], NULL, 0);
+		on_off = 1;
+	} else if (argv[2][1] == 'f') {
+		if (argc != 4)
+			return;
+		on_off = 0;
+	}
+
+	_ingress_rate_set(on_off, port, bw);
+}
+
+void _egress_rate_set(int on_off, int port, int bw)
+{
+	unsigned int value = 0, reg = 0;
 
 	reg = 0x1040 + (0x100 * port);
 	value = 0;
-	/*token-bucket*/
+	/*token-bucket */
 	if (on_off == 1) {
 		if (chip_name == 0x7530) {
 			if (bw < 0 || bw > 1000000) {
-				printf("\n**Charge rate(%d) is larger than line rate(1000000kbps)**\n",bw);
-				return -1;
+				printf
+				    ("\n**Charge rate(%d) is larger than line rate(1000000kbps)**\n",
+				     bw);
+				return;
 			}
-			value = ((bw / 32) << 16) + (1 << 15) + (7 << 8) + (1 << 7) + 0xf;
+			value =
+			    ((bw / 32) << 16) + (1 << 15) + (7 << 8) +
+			    (1 << 7) + 0xf;
 		} else if (chip_name == 0x7531 || chip_name == 0x7988) {
 			if ((chip_name == 0x7531) && (bw < 0 || bw > 2500000)) {
-				printf("\n**Charge rate(%d) is larger than line rate(2500000kbps)**\n",bw);
-				return -1;
+				printf
+				    ("\n**Charge rate(%d) is larger than line rate(2500000kbps)**\n",
+				     bw);
+				return;
 			}
 			if ((chip_name == 0x7988) && (bw < 0 || bw > 4000000)) {
-				printf("\n**Charge rate(%d) is larger than line rate(4000000kbps)**\n",bw);
-				return -1;
+				printf
+				    ("\n**Charge rate(%d) is larger than line rate(4000000kbps)**\n",
+				     bw);
+				return;
 			}
 
-			if (bw/32 >= 65536)	//support 2.5G cases
-				value = ((bw / 32) << 16) + (1 << 15) + (1 << 14) + (1 << 12) + (7 << 8) + 0xf;
+			if (bw / 32 >= 65536)	//support 2.5G cases
+				value =
+				    ((bw / 32) << 16) + (1 << 15) + (1 << 14) +
+				    (1 << 12) + (7 << 8) + 0xf;
 			else
-				value = ((bw / 32) << 16) + (1 << 15) + (1 << 14) + (7 << 8) + 0xf;
-		}
-		else
+				value =
+				    ((bw / 32) << 16) + (1 << 15) + (1 << 14) +
+				    (7 << 8) + 0xf;
+		} else
 			printf("unknow chip\n");
 	}
 	reg_write(reg, value);
@@ -3207,7 +3299,28 @@
 	value &= 0x18;
 	reg_write(reg, value);
 
-	return 0;
+	if (on_off)
+		printf("switch port=%d, bw=%d\n", port, bw);
+	else
+		printf("switch port=%d egress rate limit off\n", port);
+}
+
+void egress_rate_set(int argc, char *argv[])
+{
+	unsigned int value = 0, reg = 0;
+	int on_off = 0, port = 0, bw = 0;
+
+	port = strtoul(argv[3], NULL, 0);
+	if (argv[2][1] == 'n') {
+		bw = strtoul(argv[4], NULL, 0);
+		on_off = 1;
+	} else if (argv[2][1] == 'f') {
+		if (argc != 4)
+			return;
+		on_off = 0;
+	}
+
+	_egress_rate_set(on_off, port, bw);
 }
 
 void rate_control(int argc, char *argv[])
@@ -3223,34 +3336,33 @@
 	if (port > 6)
 		return;
 
-	if (dir == 1) //ingress
-		ingress_rate_set(1, port, rate);
-	else if (dir == 0) //egress
-		egress_rate_set(1, port, rate);
+	if (dir == 1)		//ingress
+		_ingress_rate_set(1, port, rate);
+	else if (dir == 0)	//egress
+		_egress_rate_set(1, port, rate);
 	else
 		return;
 }
 
-int collision_pool_enable(int argc, char *argv[])
+void collision_pool_enable(int argc, char *argv[])
 {
 
-	unsigned char enable;
-	unsigned int value, reg;
+	unsigned char enable = 0;
+	unsigned int value = 0, reg = 0;
 
 	enable = atoi(argv[3]);
 
-
 	printf("collision pool enable: %d \n", enable);
 
-	/*Check the input parameters is right or not.*/
+	/*Check the input parameters is right or not. */
 	if (enable > 1) {
 		printf(HELP_COLLISION_POOL_EN);
-		return -1;
+		return;
 	}
 
 	if (chip_name == 0x7531 || chip_name == 0x7988) {
 		reg = REG_CPGC_ADDR;
-		if(enable == 1) {
+		if (enable == 1) {
 			/* active reset */
 			reg_read(reg, &value);
 			value &= (~REG_CPCG_COL_RST_N_MASK);
@@ -3276,7 +3388,7 @@
 
 			reg_read(reg, &value);
 			printf("write reg: %x, value: %x\n", reg, value);
-		}else {
+		} else {
 
 			/* disable collision pool */
 			reg_read(reg, &value);
@@ -3303,70 +3415,67 @@
 			printf("write reg: %x, value: %x\n", reg, value);
 
 		}
-	}else{
+	} else {
 		printf("\nCommand not support by this chip.\n");
-}
-
- return 0;
+	}
 }
 
-void collision_pool_mac_dump()
+void collision_pool_mac_dump(int argc, char *argv[])
 {
-	unsigned int value, reg;
+	unsigned int value = 0, reg = 0;
 
 	if (chip_name == 0x7531 || chip_name == 0x7988) {
 		reg = REG_CPGC_ADDR;
 		reg_read(reg, &value);
-		if(value & REG_CPCG_COL_EN_MASK)
+		if (value & REG_CPCG_COL_EN_MASK)
 			table_dump_internal(COLLISION_TABLE);
 		else
-			printf("\ncollision pool is disabled, please enable it before use this command.\n");
-	}else {
+			printf
+			    ("\ncollision pool is disabled, please enable it before use this command.\n");
+	} else {
 		printf("\nCommand not support by this chip.\n");
 	}
 }
 
-void collision_pool_dip_dump()
+void collision_pool_dip_dump(int argc, char *argv[])
 {
-	unsigned int value, reg;
+	unsigned int value = 0, reg = 0;
 
 	if (chip_name == 0x7531 || chip_name == 0x7988) {
 		reg = REG_CPGC_ADDR;
 		reg_read(reg, &value);
-		if(value & REG_CPCG_COL_EN_MASK)
+		if (value & REG_CPCG_COL_EN_MASK)
 			dip_dump_internal(COLLISION_TABLE);
 		else
-			printf("\ncollision pool is disabled, please enable it before use this command.\n");
-		}else {
+			printf
+			    ("\ncollision pool is disabled, please enable it before use this command.\n");
+	} else {
 		printf("\nCommand not support by this chip.\n");
 	}
-
-
 }
 
-void collision_pool_sip_dump()
+void collision_pool_sip_dump(int argc, char *argv[])
 {
-	unsigned int value, reg;
+	unsigned int value = 0, reg = 0;
 
-	if (chip_name == 0x7531 ||  chip_name == 0x7988) {
+	if (chip_name == 0x7531 || chip_name == 0x7988) {
 		reg = REG_CPGC_ADDR;
 		reg_read(reg, &value);
-		if(value & REG_CPCG_COL_EN_MASK)
+		if (value & REG_CPCG_COL_EN_MASK)
 			sip_dump_internal(COLLISION_TABLE);
 		else
-			printf("\ncollision pool is disabled, please enable it before use this command.\n");
-	}else {
+			printf
+			    ("\ncollision pool is disabled, please enable it before use this command.\n");
+	} else {
 		printf("\nCommand not support by this chip.\n");
 	}
-
-
 }
 
 void pfc_get_rx_counter(int argc, char *argv[])
 {
-	int port;
-	unsigned int value, reg;
-	unsigned int user_pri;
+	int port = 0;
+	unsigned int value = 0, reg = 0;
+	unsigned int user_pri = 0;
 
 	port = strtoul(argv[3], NULL, 0);
 	if (port < 0 || 6 < port) {
@@ -3374,33 +3483,41 @@
 		return;
 	}
 
-	if (chip_name == 0x7531 ||  chip_name == 0x7988) {
-		reg= PFC_RX_COUNTER_L(port);
+	if (chip_name == 0x7531 || chip_name == 0x7988) {
+		reg = PFC_RX_COUNTER_L(port);
 		reg_read(reg, &value);
 		user_pri = value & 0xff;
-		printf("\n port %d rx pfc (up=0)pause on counter is %d.\n", port,user_pri);
+		printf("\n port %d rx pfc (up=0)pause on counter is %d.\n",
+		       port, user_pri);
 		user_pri = (value & 0xff00) >> 8;
-		printf("\n port %d rx pfc (up=1)pause on counter is %d.\n", port,user_pri);
+		printf("\n port %d rx pfc (up=1)pause on counter is %d.\n",
+		       port, user_pri);
 		user_pri = (value & 0xff0000) >> 16;
-		printf("\n port %d rx pfc (up=2)pause on counter is %d.\n", port,user_pri);
+		printf("\n port %d rx pfc (up=2)pause on counter is %d.\n",
+		       port, user_pri);
 		user_pri = (value & 0xff000000) >> 24;
-		printf("\n port %d rx pfc (up=3)pause on counter is %d.\n", port,user_pri);
+		printf("\n port %d rx pfc (up=3)pause on counter is %d.\n",
+		       port, user_pri);
 
-		reg= PFC_RX_COUNTER_H(port);
+		reg = PFC_RX_COUNTER_H(port);
 		reg_read(reg, &value);
 		user_pri = value & 0xff;
-		printf("\n port %d rx pfc (up=4)pause on counter is %d.\n", port,user_pri);
+		printf("\n port %d rx pfc (up=4)pause on counter is %d.\n",
+		       port, user_pri);
 		user_pri = (value & 0xff00) >> 8;
-		printf("\n port %d rx pfc (up=5)pause on counter is %d.\n", port,user_pri);
+		printf("\n port %d rx pfc (up=5)pause on counter is %d.\n",
+		       port, user_pri);
 		user_pri = (value & 0xff0000) >> 16;
-		printf("\n port %d rx pfc (up=6)pause on counter is %d.\n", port,user_pri);
+		printf("\n port %d rx pfc (up=6)pause on counter is %d.\n",
+		       port, user_pri);
 		user_pri = (value & 0xff000000) >> 24;
-		printf("\n port %d rx pfc (up=7)pause on counter is %d.\n", port,user_pri);
+		printf("\n port %d rx pfc (up=7)pause on counter is %d.\n",
+		       port, user_pri);
 
 		/* for rx counter could be updated successfully */
 		reg_read(PMSR_P(port), &value);
 		reg_read(PMSR_P(port), &value);
-	}else {
+	} else {
 		printf("\nCommand not support by this chip.\n");
 	}
 
@@ -3408,9 +3525,9 @@
 
 void pfc_get_tx_counter(int argc, char *argv[])
 {
-	int port;
-	unsigned int value, reg;
-	unsigned int user_pri;
+	int port = 0;
+	unsigned int value = 0, reg = 0;
+	unsigned int user_pri = 0;
 
 	port = strtoul(argv[3], NULL, 0);
 	if (port < 0 || 6 < port) {
@@ -3419,83 +3536,99 @@
 	}
 
 	if (chip_name == 0x7531 || chip_name == 0x7988) {
-		reg= PFC_TX_COUNTER_L(port);
+		reg = PFC_TX_COUNTER_L(port);
 		reg_read(reg, &value);
 		user_pri = value & 0xff;
-		printf("\n port %d tx pfc (up=0)pause on counter is %d.\n", port,user_pri);
+		printf("\n port %d tx pfc (up=0)pause on counter is %d.\n",
+		       port, user_pri);
 		user_pri = (value & 0xff00) >> 8;
-		printf("\n port %d tx pfc (up=1)pause on counter is %d.\n", port,user_pri);
+		printf("\n port %d tx pfc (up=1)pause on counter is %d.\n",
+		       port, user_pri);
 		user_pri = (value & 0xff0000) >> 16;
-		printf("\n port %d tx pfc (up=2)pause on counter is %d.\n", port,user_pri);
+		printf("\n port %d tx pfc (up=2)pause on counter is %d.\n",
+		       port, user_pri);
 		user_pri = (value & 0xff000000) >> 24;
-		printf("\n port %d tx pfc (up=3)pause on counter is %d.\n", port,user_pri);
+		printf("\n port %d tx pfc (up=3)pause on counter is %d.\n",
+		       port, user_pri);
 
-		reg= PFC_TX_COUNTER_H(port);
+		reg = PFC_TX_COUNTER_H(port);
 		reg_read(reg, &value);
 		user_pri = value & 0xff;
-		printf("\n port %d tx pfc (up=4)pause on counter is %d.\n", port,user_pri);
+		printf("\n port %d tx pfc (up=4)pause on counter is %d.\n",
+		       port, user_pri);
 		user_pri = (value & 0xff00) >> 8;
-		printf("\n port %d tx pfc (up=5)pause on counter is %d.\n", port,user_pri);
+		printf("\n port %d tx pfc (up=5)pause on counter is %d.\n",
+		       port, user_pri);
 		user_pri = (value & 0xff0000) >> 16;
-		printf("\n port %d tx pfc (up=6)pause on counter is %d.\n", port,user_pri);
+		printf("\n port %d tx pfc (up=6)pause on counter is %d.\n",
+		       port, user_pri);
 		user_pri = (value & 0xff000000) >> 24;
-		printf("\n port %d tx pfc (up=7)pause on counter is %d.\n", port,user_pri);
+		printf("\n port %d tx pfc (up=7)pause on counter is %d.\n",
+		       port, user_pri);
 
 		/* for tx counter could be updated successfully */
 		reg_read(PMSR_P(port), &value);
 		reg_read(PMSR_P(port), &value);
-	}else {
-		 printf("\nCommand not support by this chip.\n");
+	} else {
+		printf("\nCommand not support by this chip.\n");
 	}
 }
 
-void read_output_queue_counters()
+void read_output_queue_counters(int argc, char *argv[])
 {
-	unsigned int port=0;
-	unsigned int value, output_queue;
-	unsigned int base=0x220;
+	unsigned int port = 0;
+	unsigned int value = 0, output_queue = 0;
+	unsigned int base = 0x220;
 
 	for (port = 0; port < 7; port++) {
-		reg_write(0x7038, base + (port *4));
+		reg_write(0x7038, base + (port * 4));
 		reg_read(0x7034, &value);
 		output_queue = value & 0xff;
-		printf("\n port %d  output queue 0 counter is %d.\n", port,output_queue);
+		printf("\n port %d  output queue 0 counter is %d.\n", port,
+		       output_queue);
 		output_queue = (value & 0xff00) >> 8;
-		printf("\n port %d  output queue 1 counter is %d.\n", port,output_queue);
+		printf("\n port %d  output queue 1 counter is %d.\n", port,
+		       output_queue);
 
-		reg_write(0x7038, base + (port *4) + 1);
+		reg_write(0x7038, base + (port * 4) + 1);
 		reg_read(0x7034, &value);
 		output_queue = value & 0xff;
-		printf("\n port %d  output queue 2 counter is %d.\n", port,output_queue);
+		printf("\n port %d  output queue 2 counter is %d.\n", port,
+		       output_queue);
 		output_queue = (value & 0xff00) >> 8;
-		printf("\n port %d  output queue 3 counter is %d.\n", port,output_queue);
+		printf("\n port %d  output queue 3 counter is %d.\n", port,
+		       output_queue);
 
-		reg_write(0x7038, base + (port *4) + 2);
+		reg_write(0x7038, base + (port * 4) + 2);
 		reg_read(0x7034, &value);
 		output_queue = value & 0xff;
-		printf("\n port %d  output queue 4 counter is %d.\n", port,output_queue);
+		printf("\n port %d  output queue 4 counter is %d.\n", port,
+		       output_queue);
 		output_queue = (value & 0xff00) >> 8;
-		printf("\n port %d  output queue 5 counter is %d.\n", port,output_queue);
+		printf("\n port %d  output queue 5 counter is %d.\n", port,
+		       output_queue);
 
-		reg_write(0x7038, base + (port *4) + 3);
+		reg_write(0x7038, base + (port * 4) + 3);
 		reg_read(0x7034, &value);
 		output_queue = value & 0xff;
-		printf("\n port %d  output queue 6 counter is %d.\n", port,output_queue);
+		printf("\n port %d  output queue 6 counter is %d.\n", port,
+		       output_queue);
 		output_queue = (value & 0xff00) >> 8;
-		printf("\n port %d  output queue 7 counter is %d.\n", port,output_queue);
+		printf("\n port %d  output queue 7 counter is %d.\n", port,
+		       output_queue);
 	}
 }
 
-void read_free_page_counters()
+void read_free_page_counters(int argc, char *argv[])
 {
-	unsigned int value;
-	unsigned int free_page,free_page_last_read;
-	unsigned int fc_free_blk_lothd,fc_free_blk_hithd;
-	unsigned int fc_port_blk_thd,fc_port_blk_hi_thd;
-	unsigned int queue[8]={0};
+	unsigned int value = 0;
+	unsigned int free_page = 0, free_page_last_read = 0;
+	unsigned int fc_free_blk_lothd = 0, fc_free_blk_hithd = 0;
+	unsigned int fc_port_blk_thd = 0, fc_port_blk_hi_thd = 0;
+	unsigned int queue[8] = { 0 };
 
 	if (chip_name == 0x7531 || chip_name == 0x7988) {
-		/* get system free page link counter*/
+		/* get system free page link counter */
 		reg_read(0x1fc0, &value);
 		free_page = value & 0xFFF;
 		free_page_last_read = (value & 0xFFF0000) >> 16;
@@ -3512,17 +3645,17 @@
 
 		/* get queue flow control waterwark */
 		reg_read(0x1fe8, &value);
-		queue[0]= value & 0x3F;
-		queue[1]= (value & 0x3F00) >> 8;
-		queue[2]= (value & 0x3F0000) >> 16;
-		queue[3]= (value & 0x3F000000) >> 24;
+		queue[0] = value & 0x3F;
+		queue[1] = (value & 0x3F00) >> 8;
+		queue[2] = (value & 0x3F0000) >> 16;
+		queue[3] = (value & 0x3F000000) >> 24;
 		reg_read(0x1fec, &value);
-		queue[4]= value & 0x3F;
-		queue[5]= (value & 0x3F00) >> 8;
-		queue[6]= (value & 0x3F0000) >> 16;
-		queue[7]= (value & 0x3F000000) >> 24;
+		queue[4] = value & 0x3F;
+		queue[5] = (value & 0x3F00) >> 8;
+		queue[6] = (value & 0x3F0000) >> 16;
+		queue[7] = (value & 0x3F000000) >> 24;
 	} else {
-		/* get system free page link counter*/
+		/* get system free page link counter */
 		reg_read(0x1fc0, &value);
 		free_page = value & 0x3FF;
 		free_page_last_read = (value & 0x3FF0000) >> 16;
@@ -3540,50 +3673,61 @@
 
 		/* get queue flow control waterwark */
 		reg_read(0x1fe4, &value);
-		queue[0]= value & 0xF;
-		queue[1]= (value & 0xF0) >> 4;
-		queue[2]= (value & 0xF00) >> 8;
-		queue[3]= (value & 0xF000) >>12;
-		queue[4]= (value & 0xF0000) >>16;
-		queue[5]= (value & 0xF00000) >> 20;
-		queue[6]= (value & 0xF000000) >> 24;
-		queue[7]= (value & 0xF0000000) >> 28;
+		queue[0] = value & 0xF;
+		queue[1] = (value & 0xF0) >> 4;
+		queue[2] = (value & 0xF00) >> 8;
+		queue[3] = (value & 0xF000) >> 12;
+		queue[4] = (value & 0xF0000) >> 16;
+		queue[5] = (value & 0xF00000) >> 20;
+		queue[6] = (value & 0xF000000) >> 24;
+		queue[7] = (value & 0xF0000000) >> 28;
 	}
 
-	printf("<===Free Page=======Current=======Last Read access=====> \n ");
-	printf("	                                                 \n ");
-	printf(" page counter      %u                %u               \n ",free_page,free_page_last_read);
-	printf("                                                        \n ");
-	printf("========================================================= \n ");
-	printf("<===Type=======High threshold======Low threshold=========\n ");
-	printf("                                                        \n ");
-	printf("  system:         %u                 %u               \n", fc_free_blk_hithd*2,  fc_free_blk_lothd*2);
-	printf("    port:         %u                 %u               \n", fc_port_blk_hi_thd*2, fc_port_blk_thd*2);
-	printf(" queue 0:         %u                 NA                \n", queue[0]);
-	printf(" queue 1:         %u                 NA                \n", queue[1]);
-	printf(" queue 2:         %u                 NA                 \n", queue[2]);
-	printf(" queue 3:         %u                 NA                \n", queue[3]);
-	printf(" queue 4:         %u                 NA                \n", queue[4]);
-	printf(" queue 5:         %u                 NA                \n", queue[5]);
-	printf(" queue 6:         %u                 NA                \n", queue[6]);
-	printf(" queue 7:         %u                 NA                \n", queue[7]);
-	printf("=========================================================\n ");
+	printf("<===Free Page=======Current=======Last Read access=====>\n");
+	printf("\n");
+	printf(" page counter      %u                %u\n ",
+	       free_page, free_page_last_read);
+	printf("\n ");
+	printf("=========================================================\n");
+	printf("<===Type=======High threshold======Low threshold=========\n");
+	printf("\n ");
+	printf("  system:         %u                 %u\n",
+	       fc_free_blk_hithd * 2, fc_free_blk_lothd * 2);
+	printf("    port:         %u                 %u\n",
+	       fc_port_blk_hi_thd * 2, fc_port_blk_thd * 2);
+	printf(" queue 0:         %u                 NA\n",
+	       queue[0]);
+	printf(" queue 1:         %u                 NA\n",
+	       queue[1]);
+	printf(" queue 2:         %u                 NA\n",
+	       queue[2]);
+	printf(" queue 3:         %u                 NA\n",
+	       queue[3]);
+	printf(" queue 4:         %u                 NA\n",
+	       queue[4]);
+	printf(" queue 5:         %u                 NA\n",
+	       queue[5]);
+	printf(" queue 6:         %u                 NA\n",
+	       queue[6]);
+	printf(" queue 7:         %u                 NA\n",
+	       queue[7]);
+	printf("=========================================================\n");
 }
 
 void eee_enable(int argc, char *argv[])
 {
-	unsigned long enable;
-	unsigned int value;
-	unsigned int eee_cap;
+	unsigned long enable = 0;
+	unsigned int value = 0;
+	unsigned int eee_cap = 0;
 	unsigned int eee_en_bitmap = 0;
-	unsigned long port_map;
+	unsigned long port_map = 0;
 	long port_num = -1;
-	int p;
+	int p = 0;
 
 	if (argc < 3)
 		goto error;
 
-	/*Check the input parameters is right or not.*/
+	/* Check the input parameters is right or not. */
 	if (!strncmp(argv[2], "enable", 7))
 		enable = 1;
 	else if (!strncmp(argv[2], "disable", 8))
@@ -3603,23 +3747,25 @@
 			port_map = 0;
 			for (p = 0; p < MAX_PHY_PORT; p++) {
 				if (argv[3][p] != '0' && argv[3][p] != '1') {
-					printf("portmap format error, should be combination of 0 or 1\n");
+					printf
+					    ("portmap format error, should be combination of 0 or 1\n");
 					goto error;
 				}
 				port_map |= ((argv[3][p] - '0') << p);
 			}
 		} else {
-			printf("port_no or portmap format error, should be length of 1 or 5\n");
+			printf
+			    ("port_no or portmap format error, should be length of 1 or 5\n");
 			goto error;
 		}
 	} else {
 		port_map = 0x1f;
 	}
 
-	eee_cap = (enable)? 6: 0;
+	eee_cap = (enable) ? 6 : 0;
 	for (p = 0; p < MAX_PHY_PORT; p++) {
 		/* port_map describe p0p1p2p3p4 from left to rignt */
-		if(!!(port_map & (1 << p)))
+		if (!!(port_map & (1 << p)))
 			mii_mgr_c45_write(p, 0x7, 0x3c, eee_cap);
 
 		mii_mgr_c45_read(p, 0x7, 0x3c, &value);
@@ -3642,7 +3788,7 @@
 		printf("\nCommand not support by this chip.\n");
 	}
 
-	printf("EEE(802.3az) %s", (enable)? "enable": "disable");
+	printf("EEE(802.3az) %s", (enable) ? "enable" : "disable");
 	if (argc == 4) {
 		if (port_num >= 0)
 			printf(" port%ld", port_num);
@@ -3661,9 +3807,9 @@
 
 void eee_dump(int argc, char *argv[])
 {
-	unsigned int cap, lp_cap;
+	unsigned int cap = 0, lp_cap = 0;
 	long port = -1;
-	int p;
+	int p = 0;
 
 	if (argc > 3) {
 		if (strlen(argv[3]) > 1) {
@@ -3674,7 +3820,7 @@
 		port = strtol(argv[3], (char **)NULL, 0);
 		if (port < 0 || port > MAX_PHY_PORT) {
 			printf("port# format error, should be 0 to %d\n",
-				       MAX_PHY_PORT);
+			       MAX_PHY_PORT);
 			return;
 		}
 	}
@@ -3716,7 +3862,7 @@
 	printf("\n");
 }
 
-void read_mib_counters()
+void read_mib_counters(int argc, char *argv[])
 {
 	printf("===================== %8s %8s %8s %8s %8s %8s %8s\n",
 	       "Port0", "Port1", "Port2", "Port3", "Port4", "Port5", "Port6");
@@ -3760,14 +3906,13 @@
 	dump_each_port(0x408C);
 }
 
-void clear_mib_counters()
+void clear_mib_counters(int argc, char *argv[])
 {
 	reg_write(0x4fe0, 0xf0);
-	read_mib_counters();
+	read_mib_counters(argc, argv);
 	reg_write(0x4fe0, 0x800000f0);
 }
 
-
 void exit_free()
 {
 	free(attres);
diff --git a/feed/app/switch/src/switch_fun.h b/feed/app/switch/src/switch_fun.h
index 70e4d18..cc16c20 100644
--- a/feed/app/switch/src/switch_fun.h
+++ b/feed/app/switch/src/switch_fun.h
@@ -6,6 +6,84 @@
 
 #include <stdbool.h>
 
+void (*pf_chip_func)(int argc, char *argv[]);
+
+struct switch_func_s {
+	void (*pf_table_dump)(int argc, char *argv[]);
+	void (*pf_table_clear)(int argc, char *argv[]);
+	void (*pf_switch_reset)(int argc, char *argv[]);
+	void (*pf_doArlAging)(int argc, char *argv[]);
+	void (*pf_read_mib_counters)(int argc, char *argv[]);
+	void (*pf_clear_mib_counters)(int argc, char *argv[]);
+	void (*pf_read_output_queue_counters)(int argc, char *argv[]);
+	void (*pf_read_free_page_counters)(int argc, char *argv[]);
+	void (*pf_rate_control)(int argc, char *argv[]);
+	void (*pf_igress_rate_set)(int argc, char *argv[]);
+	void (*pf_egress_rate_set)(int argc, char *argv[]);
+	void (*pf_table_add)(int argc, char *argv[]);
+	void (*pf_table_del_fid)(int argc, char *argv[]);
+	void (*pf_table_del_vid)(int argc, char *argv[]);
+	void (*pf_table_search_mac_fid)(int argc, char *argv[]);
+	void (*pf_table_search_mac_vid)(int argc, char *argv[]);
+	void (*pf_global_set_mac_fc)(int argc, char *argv[]);
+	void (*pf_set_mac_pfc)(int argc, char *argv[]);
+	void (*pf_qos_sch_select)(int argc, char *argv[]);
+	void (*pf_qos_set_base)(int argc, char *argv[]);
+	void (*pf_qos_wfq_set_weight)(int argc, char *argv[]);
+	void (*pf_qos_set_portpri)(int argc, char *argv[]);
+	void (*pf_qos_set_dscppri)(int argc, char *argv[]);
+	void (*pf_qos_pri_mapping_queue)(int argc, char *argv[]);
+	void (*pf_doStp)(int argc, char *argv[]);
+	void (*pf_sip_dump)(int argc, char *argv[]);
+	void (*pf_sip_add)(int argc, char *argv[]);
+	void (*pf_sip_del)(int argc, char *argv[]);
+	void (*pf_sip_clear)(int argc, char *argv[]);
+	void (*pf_dip_dump)(int argc, char *argv[]);
+	void (*pf_dip_add)(int argc, char *argv[]);
+	void (*pf_dip_del)(int argc, char *argv[]);
+	void (*pf_dip_clear)(int argc, char *argv[]);
+	void (*pf_set_mirror_to)(int argc, char *argv[]);
+	void (*pf_set_mirror_from)(int argc, char *argv[]);
+	void (*pf_doMirrorEn)(int argc, char *argv[]);
+	void (*pf_doMirrorPortBased)(int argc, char *argv[]);
+	void (*pf_acl_dip_add)(int argc, char *argv[]);
+	void (*pf_acl_dip_modify)(int argc, char *argv[]);
+	void (*pf_acl_dip_pppoe)(int argc, char *argv[]);
+	void (*pf_acl_dip_trtcm)(int argc, char *argv[]);
+	void (*pf_acl_dip_meter)(int argc, char *argv[]);
+	void (*pf_acl_mac_add)(int argc, char *argv[]);
+	void (*pf_acl_ethertype)(int argc, char *argv[]);
+	void (*pf_acl_sp_add)(int argc, char *argv[]);
+	void (*pf_acl_l4_add)(int argc, char *argv[]);
+	void (*pf_acl_port_enable)(int argc, char *argv[]);
+	void (*pf_acl_table_add)(int argc, char *argv[]);
+	void (*pf_acl_mask_table_add)(int argc, char *argv[]);
+	void (*pf_acl_rule_table_add)(int argc, char *argv[]);
+	void (*pf_acl_rate_table_add)(int argc, char *argv[]);
+	void (*pf_vlan_dump)(int argc, char *argv[]);
+	void (*pf_vlan_set)(int argc, char *argv[]);
+	void (*pf_vlan_clear)(int argc, char *argv[]);
+	void (*pf_doVlanSetVid)(int argc, char *argv[]);
+	void (*pf_doVlanSetPvid)(int argc, char *argv[]);
+	void (*pf_doVlanSetAccFrm)(int argc, char *argv[]);
+	void (*pf_doVlanSetPortAttr)(int argc, char *argv[]);
+	void (*pf_doVlanSetPortMode)(int argc, char *argv[]);
+	void (*pf_doVlanSetEgressTagPCR)(int argc, char *argv[]);
+	void (*pf_doVlanSetEgressTagPVC)(int argc, char *argv[]);
+	void (*pf_igmp_on)(int argc, char *argv[]);
+	void (*pf_igmp_off)(int argc, char *argv[]);
+	void (*pf_igmp_enable)(int argc, char *argv[]);
+	void (*pf_igmp_disable)(int argc, char *argv[]);
+	void (*pf_collision_pool_enable)(int argc, char *argv[]);
+	void (*pf_collision_pool_mac_dump)(int argc, char *argv[]);
+	void (*pf_collision_pool_dip_dump)(int argc, char *argv[]);
+	void (*pf_collision_pool_sip_dump)(int argc, char *argv[]);
+	void (*pf_pfc_get_rx_counter)(int argc, char *argv[]);
+	void (*pf_pfc_get_tx_counter)(int argc, char *argv[]);
+	void (*pf_eee_enable)(int argc, char *argv[]);
+	void (*pf_eee_dump)(int argc, char *argv[]);
+};
+
 #define MT7530_T10_TEST_CONTROL 0x145
 
 #define MAX_PORT 6
@@ -15,14 +93,18 @@
 extern int chip_name;
 extern struct mt753x_attr *attres;
 extern bool nl_init_flag;
+extern struct switch_func_s mt753x_switch_func;
+extern struct switch_func_s an8855_switch_func;
 
 /*basic operation*/
 int reg_read(unsigned int offset, unsigned int *value);
 int reg_write(unsigned int offset, unsigned int value);
 int mii_mgr_read(unsigned int port_num, unsigned int reg, unsigned int *value);
 int mii_mgr_write(unsigned int port_num, unsigned int reg, unsigned int value);
-int mii_mgr_c45_read(unsigned int port_num, unsigned int dev, unsigned int reg, unsigned int *value);
-int mii_mgr_c45_write(unsigned int port_num, unsigned int dev, unsigned int reg, unsigned int value);
+int mii_mgr_c45_read(unsigned int port_num, unsigned int dev, unsigned int reg,
+		     unsigned int *value);
+int mii_mgr_c45_write(unsigned int port_num, unsigned int dev, unsigned int reg,
+		      unsigned int value);
 
 /*phy setting*/
 int phy_dump(int phy_addr);
@@ -50,28 +132,28 @@
 void acl_rate_table_add(int argc, char *argv[]);
 
 /*dip table*/
-void dip_dump(void);
+void dip_dump(int argc, char *argv[]);
 void dip_add(int argc, char *argv[]);
 void dip_del(int argc, char *argv[]);
-void dip_clear(void);
+void dip_clear(int argc, char *argv[]);
 
 /*sip table*/
-void sip_dump(void);
+void sip_dump(int argc, char *argv[]);
 void sip_add(int argc, char *argv[]);
 void sip_del(int argc, char *argv[]);
-void sip_clear(void);
+void sip_clear(int argc, char *argv[]);
 
 /*stp*/
 void doStp(int argc, char *argv[]);
 
 /*mac table*/
-void table_dump(void);
+void table_dump(int argc, char *argv[]);
 void table_add(int argc, char *argv[]);
 void table_search_mac_vid(int argc, char *argv[]);
 void table_search_mac_fid(int argc, char *argv[]);
 void table_del_fid(int argc, char *argv[]);
 void table_del_vid(int argc, char *argv[]);
-void table_clear(void);
+void table_clear(int argc, char *argv[]);
 
 /*vlan table*/
 void vlan_dump(int argc, char *argv[]);
@@ -88,7 +170,7 @@
 
 /*igmp function*/
 void igmp_on(int argc, char *argv[]);
-void igmp_off();
+void igmp_off(int argc, char *argv[]);
 void igmp_disable(int argc, char *argv[]);
 void igmp_enable(int argc, char *argv[]);
 
@@ -100,11 +182,11 @@
 
 /*rate control*/
 void rate_control(int argc, char *argv[]);
-int ingress_rate_set(int on_off, unsigned int port, unsigned int bw);
-int egress_rate_set(int on_off, int port, int bw);
+void ingress_rate_set(int argc, char *argv[]);
+void egress_rate_set(int argc, char *argv[]);
 
 /*QoS*/
-int qos_sch_select(int argc, char *argv[]);
+void qos_sch_select(int argc, char *argv[]);
 void qos_set_base(int argc, char *argv[]);
 void qos_wfq_set_weight(int argc, char *argv[]);
 void qos_set_portpri(int argc, char *argv[]);
@@ -112,32 +194,32 @@
 void qos_pri_mapping_queue(int argc, char *argv[]);
 
 /*flow control*/
-int global_set_mac_fc(int argc, char *argv[]);
-int phy_set_fc(int argc, char *argv[]);
-int phy_set_an(int argc, char *argv[]);
+void global_set_mac_fc(int argc, char *argv[]);
+void phy_set_fc(int argc, char *argv[]);
+void phy_set_an(int argc, char *argv[]);
 
 /* collision pool functions */
-int collision_pool_enable(int argc, char *argv[]);
-void collision_pool_mac_dump();
-void collision_pool_dip_dump();
-void collision_pool_sip_dump();
+void collision_pool_enable(int argc, char *argv[]);
+void collision_pool_mac_dump(int argc, char *argv[]);
+void collision_pool_dip_dump(int argc, char *argv[]);
+void collision_pool_sip_dump(int argc, char *argv[]);
 
 /*pfc functions*/
-int set_mac_pfc(int argc, char *argv[]);
+void set_mac_pfc(int argc, char *argv[]);
 void pfc_get_rx_counter(int argc, char *argv[]);
 void pfc_get_tx_counter(int argc, char *argv[]);
 
 /*switch reset*/
-int switch_reset(int argc, char *argv[]);
+void switch_reset(int argc, char *argv[]);
 
 /* EEE(802.3az) function  */
 void eee_enable(int argc, char *argv[]);
 void eee_dump(int argc, char *argv[]);
 
-void read_mib_counters();
-void clear_mib_counters();
-void read_output_queue_counters();
-void read_free_page_counters();
+void read_mib_counters(int argc, char *argv[]);
+void clear_mib_counters(int argc, char *argv[]);
+void read_output_queue_counters(int argc, char *argv[]);
+void read_free_page_counters(int argc, char *argv[]);
 
 void phy_crossover(int argc, char *argv[]);
 void exit_free();
diff --git a/feed/app/switch/src/switch_ioctl.c b/feed/app/switch/src/switch_ioctl.c
index 366079e..f6b97d4 100644
--- a/feed/app/switch/src/switch_ioctl.c
+++ b/feed/app/switch/src/switch_ioctl.c
@@ -235,24 +235,18 @@
 	mii.reg_num = 13;
 	mii.val_in = dev;
 	ret = ioctl(sk, method, &ifr);
-	if (ret < 0)
-		printf("ioctl failed with error %d\n", ret);
 
 	method = RAETH_MII_WRITE;
 	mii.phy_id = port_num;
 	mii.reg_num = 14;
 	mii.val_in = reg;
 	ret = ioctl(sk, method, &ifr);
-	if (ret < 0)
-		printf("ioctl failed with error %d\n", ret);
 
 	method = RAETH_MII_WRITE;
 	mii.phy_id = port_num;
 	mii.reg_num = 13;
 	mii.val_in = (0x6000 | dev);
 	ret = ioctl(sk, method, &ifr);
-	if (ret < 0)
-		printf("ioctl failed with error %d\n", ret);
 
 	usleep(1000);
 
@@ -260,8 +254,6 @@
 	mii.phy_id = port_num;
 	mii.reg_num = 14;
 	ret = ioctl(sk, method, &ifr);
-	if (ret < 0)
-		printf("ioctl failed with error %d\n", ret);
 
 	close(sk);
 	*value = mii.val_out;
@@ -291,24 +283,18 @@
 	mii.reg_num = 13;
 	mii.val_in = dev;
 	ret = ioctl(sk, method, &ifr);
-	if (ret < 0)
-		printf("ioctl failed with error %d\n", ret);
 
 	method = RAETH_MII_WRITE;
 	mii.phy_id = port_num;
 	mii.reg_num = 14;
 	mii.val_in = reg;
 	ret = ioctl(sk, method, &ifr);
-	if (ret < 0)
-		printf("ioctl failed with error %d\n", ret);
 
 	method = RAETH_MII_WRITE;
 	mii.phy_id = port_num;
 	mii.reg_num = 13;
 	mii.val_in = (0x6000 | dev);
 	ret = ioctl(sk, method, &ifr);
-	if (ret < 0)
-		printf("ioctl failed with error %d\n", ret);
 
 	usleep(1000);
 
@@ -317,8 +303,6 @@
 	mii.reg_num = 14;
 	mii.val_in = value;
 	ret = ioctl(sk, method, &ifr);
-	if (ret < 0)
-		printf("ioctl failed with error %d\n", ret);
 
 	close(sk);
 
diff --git a/feed/app/switch/src/switch_netlink.c b/feed/app/switch/src/switch_netlink.c
index 90a4a19..397ebe5 100644
--- a/feed/app/switch/src/switch_netlink.c
+++ b/feed/app/switch/src/switch_netlink.c
@@ -41,10 +41,9 @@
 	if (gnlh->cmd == MT753X_CMD_REPLY) {
 		if (attrs[MT753X_ATTR_TYPE_MESG]) {
 			val->dev_info =
-				nla_get_string(attrs[MT753X_ATTR_TYPE_MESG]);
+			    nla_get_string(attrs[MT753X_ATTR_TYPE_MESG]);
 			printf("register switch dev:\n%s", val->dev_info);
-		}
-		else {
+		} else {
 			fprintf(stderr, "ERROR:No switch dev now\n");
 			goto done;
 		}
@@ -65,13 +64,15 @@
 
 	if (val->op == 'r') {
 		if (val->phy_dev != -1)
-			NLA_PUT_U32(msg, MT753X_ATTR_TYPE_PHY_DEV, val->phy_dev);
+			NLA_PUT_U32(msg, MT753X_ATTR_TYPE_PHY_DEV,
+				    val->phy_dev);
 		if (val->port_num >= 0)
 			NLA_PUT_U32(msg, MT753X_ATTR_TYPE_PHY, val->port_num);
 		NLA_PUT_U32(msg, type, val->reg);
 	} else if (val->op == 'w') {
 		if (val->phy_dev != -1)
-			NLA_PUT_U32(msg, MT753X_ATTR_TYPE_PHY_DEV, val->phy_dev);
+			NLA_PUT_U32(msg, MT753X_ATTR_TYPE_PHY_DEV,
+				    val->phy_dev);
 		if (val->port_num >= 0)
 			NLA_PUT_U32(msg, MT753X_ATTR_TYPE_PHY, val->port_num);
 		NLA_PUT_U32(msg, type, val->reg);
@@ -104,15 +105,12 @@
 				goto done;
 		}
 		if (attrs[MT753X_ATTR_TYPE_REG]) {
-			val->reg =
-			    nla_get_u32(attrs[MT753X_ATTR_TYPE_REG]);
+			val->reg = nla_get_u32(attrs[MT753X_ATTR_TYPE_REG]);
 		}
 		if (attrs[MT753X_ATTR_TYPE_VAL]) {
-			val->value =
-			    nla_get_u32(attrs[MT753X_ATTR_TYPE_VAL]);
+			val->value = nla_get_u32(attrs[MT753X_ATTR_TYPE_VAL]);
 		}
-	}
-	else
+	} else
 		goto done;
 
 	return 0;
@@ -120,7 +118,8 @@
 	return NL_SKIP;
 }
 
-static int mt753x_request_callback(int cmd, int (*spilt)(struct nl_msg *, void *),
+static int mt753x_request_callback(int cmd,
+				   int (*spilt)(struct nl_msg *, void *),
 				   int (*construct)(struct nl_msg *, void *),
 				   void *arg)
 {
@@ -130,7 +129,7 @@
 	int flags = 0;
 	int err;
 
-	/*Allocate an netllink message buffer*/
+	/* Allocate an netllink message buffer */
 	msg = nlmsg_alloc();
 	if (!msg) {
 		fprintf(stderr, "Failed to allocate netlink message\n");
@@ -145,7 +144,7 @@
 	genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, genl_family_get_id(family),
 		    0, flags, cmd, 0);
 
-	/*Fill attaribute of netlink message by construct function*/
+	/* Fill attaribute of netlink message by construct function */
 	if (construct) {
 		err = construct(msg, arg);
 		if (err < 0) {
@@ -154,14 +153,14 @@
 		}
 	}
 
-	/*Allocate an new callback handler*/
+	/* Allocate an new callback handler */
 	callback = nl_cb_alloc(NL_CB_CUSTOM);
 	if (!callback) {
 		fprintf(stderr, "Failed to allocate callback handler\n");
 		exit(1);
 	}
 
-	/*Send netlink message*/
+	/* Send netlink message */
 	err = nl_send_auto_complete(user_sock, msg);
 	if (err < 0) {
 		fprintf(stderr, "nl_send_auto_complete failied:%d\n", err);
@@ -178,12 +177,12 @@
 		nl_cb_set(callback, NL_CB_FINISH, NL_CB_CUSTOM, wait_handler,
 			  &finished);
 
-	/*receive message from kernel request*/
+	/* Receive message from kernel request */
 	err = nl_recvmsgs(user_sock, callback);
 	if (err < 0)
 		goto out;
 
-	/*wait until an ACK is received for the latest not yet acknowledge*/
+	/* Wait until an ACK is received for the latest not yet acknowledge */
 	if (!finished)
 		err = nl_wait_for_ack(user_sock);
 out:
@@ -216,18 +215,18 @@
 	cache = NULL;
 	family = NULL;
 
-	/*Allocate an new netlink socket*/
+	/* Allocate an new netlink socket */
 	user_sock = nl_socket_alloc();
 	if (!user_sock) {
 		fprintf(stderr, "Failed to create user socket\n");
 		goto err;
 	}
-	/*Connetct the genl controller*/
+	/* Connetct the genl controller */
 	if (genl_connect(user_sock)) {
 		fprintf(stderr, "Failed to connetct to generic netlink\n");
 		goto err;
 	}
-	/*Allocate an new nl_cache*/
+	/* Allocate an new nl_cache */
 	ret = genl_ctrl_alloc_cache(user_sock, &cache);
 	if (ret < 0) {
 		fprintf(stderr, "Failed to allocate netlink cache\n");
@@ -237,10 +236,10 @@
 	if (name == NULL)
 		return -EINVAL;
 
-	/*Look up generic netlik family by "mt753x" in the provided cache*/
+	/* Look up generic netlik family by "mt753x" in the provided cache */
 	family = genl_ctrl_search_by_name(cache, name);
 	if (!family) {
-		//fprintf(stderr,"switch(mt753x) API not be prepared\n");
+		/* printf("switch(mt753x) API not be prepared\n"); */
 		goto err;
 	}
 	return 0;
@@ -283,20 +282,19 @@
 	attr->value = -1;
 	attr->type = MT753X_ATTR_TYPE_REG;
 
-	switch (op)
-	{
-		case 'r':
-			attr->op = 'r';
-			ret = mt753x_request(attr, MT753X_CMD_READ);
-			*value = attr->value;
-			break;
-		case 'w':
-			attr->op = 'w';
-			attr->value = *value;
-			ret = mt753x_request(attr, MT753X_CMD_WRITE);
-			break;
-		default:
-			break;
+	switch (op) {
+	case 'r':
+		attr->op = 'r';
+		ret = mt753x_request(attr, MT753X_CMD_READ);
+		*value = attr->value;
+		break;
+	case 'w':
+		attr->op = 'w';
+		attr->value = *value;
+		ret = mt753x_request(attr, MT753X_CMD_WRITE);
+		break;
+	default:
+		break;
 	}
 
 	return ret;
@@ -354,60 +352,66 @@
 {
 	int ret;
 
-	ret = phy_operate_netlink('w', arg, port_num, phy_dev, phy_addr, &value);
+	ret =
+	    phy_operate_netlink('w', arg, port_num, phy_dev, phy_addr, &value);
 	return ret;
 }
 
 void dump_extend_phy_reg(struct mt753x_attr *arg, int port_no, int from,
-			int to, int is_local, int page_no)
+			 int to, int is_local, int page_no)
 {
-        unsigned int temp = 0;
-        int r31 = 0;
-        int i = 0;
+	unsigned int temp = 0;
+	int r31 = 0;
+	int i = 0;
 
-        if (is_local == 0) {
-            printf("\n\nGlobal Register Page %d\n",page_no);
-            printf("===============");
-            r31 |= 0 << 15; //global
-            r31 |= ((page_no&0x7) << 12); //page no
-            phy_cl22_write_netlink(arg, port_no, 31, r31); //select global page x
-            for (i = 16; i < 32; i++) {
-                if(i%8 == 0)
-                    printf("\n");
-		phy_cl22_read_netlink(arg, port_no, i, &temp);
-                printf("%02d: %04X ", i, temp);
-            }
-        } else {
-            printf("\n\nLocal Register Port %d Page %d\n",port_no, page_no);
-            printf("===============");
-            r31 |= 1 << 15; //local
-            r31 |= ((page_no&0x7) << 12); //page no
-            phy_cl22_write_netlink(arg, port_no, 31, r31); //select global page x
-            for (i = 16; i < 32; i++) {
-                if (i%8 == 0) {
-                    printf("\n");
-                }
-		phy_cl22_read_netlink(arg, port_no, i, &temp);
-                printf("%02d: %04X ",i, temp);
-            }
-        }
-        printf("\n");
+	if (is_local == 0) {
+		printf("\n\nGlobal Register Page %d\n", page_no);
+		printf("===============");
+		r31 |= 0 << 15;	/* global */
+		r31 |= ((page_no & 0x7) << 12);	/* page no */
+		phy_cl22_write_netlink(arg, port_no, 31, r31);	/* select global page x */
+		for (i = 16; i < 32; i++) {
+			if (i % 8 == 0)
+				printf("\n");
+			phy_cl22_read_netlink(arg, port_no, i, &temp);
+			printf("%02d: %04X ", i, temp);
+		}
+	} else {
+		printf("\n\nLocal Register Port %d Page %d\n", port_no,
+		       page_no);
+		printf("===============");
+		r31 |= 1 << 15;	/* Local */
+		r31 |= ((page_no & 0x7) << 12);	/* Page no */
+		phy_cl22_write_netlink(arg, port_no, 31, r31);	/* Select global page x */
+		for (i = 16; i < 32; i++) {
+			if (i % 8 == 0)
+				printf("\n");
+			phy_cl22_read_netlink(arg, port_no, i, &temp);
+			printf("%02d: %04X ", i, temp);
+		}
+	}
+	printf("\n");
 }
 
 int phy_dump_netlink(struct mt753x_attr *arg, int phy_addr)
 {
 	int i;
 	int ret;
-	unsigned int offset, value;
+	unsigned int offset, value, phy_base = 0;
+
+	if (chip_name == 0x8855)
+		phy_base = 6;
 
 	if (phy_addr == 32) {
-		/*dump all phy register*/
+		/* Dump all phy register */
 		for (i = 0; i < 5; i++) {
 			printf("\n[Port %d]=============", i);
 			for (offset = 0; offset < 16; offset++) {
 				if (offset % 8 == 0)
 					printf("\n");
-				ret = phy_cl22_read_netlink(arg, i, offset, &value);
+				ret =
+				    phy_cl22_read_netlink(arg, phy_base + i,
+							  offset, &value);
 				printf("%02d: %04X ", offset, value);
 			}
 		}
@@ -416,30 +420,32 @@
 		for (offset = 0; offset < 16; offset++) {
 			if (offset % 8 == 0)
 				printf("\n");
-			ret = phy_cl22_read_netlink(arg, phy_addr, offset, &value);
+			ret =
+			    phy_cl22_read_netlink(arg, phy_addr, offset,
+						  &value);
 			printf("%02d: %04X ", offset, value);
 		}
 	}
 	printf("\n");
-	for (offset = 0; offset < 5; offset++) { //global register  page 0~4
-		if (phy_addr == 32) //dump all phy register
+	for (offset = 0; offset < 5; offset++) {	/* Global register  page 0~4 */
+		if (phy_addr == 32)	/* Dump all phy register */
 			dump_extend_phy_reg(arg, 0, 16, 31, 0, offset);
 		else
 			dump_extend_phy_reg(arg, phy_addr, 16, 31, 0, offset);
 	}
 
-	if (phy_addr == 32) {	//dump all phy register
-		for (offset = 0; offset < 5; offset++) { //local register port 0-port4
-			dump_extend_phy_reg(arg, offset, 16, 31, 1, 0); //dump local page 0
-			dump_extend_phy_reg(arg, offset, 16, 31, 1, 1); //dump local page 1
-			dump_extend_phy_reg(arg, offset, 16, 31, 1, 2); //dump local page 2
-			dump_extend_phy_reg(arg, offset, 16, 31, 1, 3); //dump local page 3
+	if (phy_addr == 32) {	/* Dump all phy register */
+		for (offset = 0; offset < 5; offset++) {	/* Local register port 0-port4 */
+			dump_extend_phy_reg(arg, phy_base + offset, 16, 31, 1, 0);	/* Dump local page 0 */
+			dump_extend_phy_reg(arg, phy_base + offset, 16, 31, 1, 1);	/* Dump local page 1 */
+			dump_extend_phy_reg(arg, phy_base + offset, 16, 31, 1, 2);	/* Dump local page 2 */
+			dump_extend_phy_reg(arg, phy_base + offset, 16, 31, 1, 3);	/* Dump local page 3 */
 		}
 	} else {
-		dump_extend_phy_reg(arg, phy_addr, 16, 31, 1, 0); //dump local page 0
-		dump_extend_phy_reg(arg, phy_addr, 16, 31, 1, 1); //dump local page 1
-		dump_extend_phy_reg(arg, phy_addr, 16, 31, 1, 2); //dump local page 2
-		dump_extend_phy_reg(arg, phy_addr, 16, 31, 1, 3); //dump local page 3
+		dump_extend_phy_reg(arg, phy_addr, 16, 31, 1, 0);	/* Dump local page 0 */
+		dump_extend_phy_reg(arg, phy_addr, 16, 31, 1, 1);	/* Dump local page 1 */
+		dump_extend_phy_reg(arg, phy_addr, 16, 31, 1, 2);	/* Dump local page 2 */
+		dump_extend_phy_reg(arg, phy_addr, 16, 31, 1, 3);	/* Dump local page 3 */
 	}
 	return ret;
 }
diff --git a/feed/app/switch/src/switch_netlink.h b/feed/app/switch/src/switch_netlink.h
index b3f946e..cb812d5 100644
--- a/feed/app/switch/src/switch_netlink.h
+++ b/feed/app/switch/src/switch_netlink.h
@@ -9,12 +9,14 @@
 #define MT753X_GENL_NAME "mt753x"
 #define MT753X_DSA_GENL_NAME "mt753x_dsa"
 #define MT753X_GENL_VERSION 0X1
+#define AN8855_GENL_NAME "an8855"
+#define AN8855_DSA_GENL_NAME "an8855_dsa"
 
 /*add your cmd to here*/
 enum {
-	MT753X_CMD_UNSPEC = 0, /*Reserved*/
-	MT753X_CMD_REQUEST,    /*user->kernelrequest/get-response*/
-	MT753X_CMD_REPLY,      /*kernel->user event*/
+	MT753X_CMD_UNSPEC = 0,	/*Reserved */
+	MT753X_CMD_REQUEST,	/*user->kernelrequest/get-response */
+	MT753X_CMD_REPLY,	/*kernel->user event */
 	MT753X_CMD_READ,
 	MT753X_CMD_WRITE,
 	__MT753X_CMD_MAX,
@@ -22,10 +24,9 @@
 #define MT753X_CMD_MAX (__MT753X_CMD_MAX - 1)
 
 /*define attar types */
-enum
-{
+enum {
 	MT753X_ATTR_TYPE_UNSPEC = 0,
-	MT753X_ATTR_TYPE_MESG, /*MT753X message*/
+	MT753X_ATTR_TYPE_MESG,	/*MT753X message */
 	MT753X_ATTR_TYPE_PHY,
 	MT753X_ATTR_TYPE_PHY_DEV,
 	MT753X_ATTR_TYPE_REG,
@@ -48,6 +49,8 @@
 	int dev_id;
 };
 
+extern int chip_name;
+
 int mt753x_netlink_init(const char *name);
 void mt753x_netlink_free(void);
 void mt753x_list_swdev(struct mt753x_attr *arg, int cmd);