[rdkb][common][bsp][Refactor and sync kernel from openwrt]

[Description]
9627c280 [CRITICAL][kernel][mt7988][eth][Fix issue of PSE hanging when the internal 2.5G PHY connection is disconnected]
ef2c790d [openwrt][common][config][Add AN8855 dsa and gsw config in alphabetical order]
97f46542 [MAC80211][hnat][Improve ETH to ETH performace in an unbalanced PHY rate test for mt7981/7986]
ab061242 [openwrt][common][bsp][Add support to reset boot count of dual image booting]
dff562ec [openwrt][common][bsp][Refactor dual image related patches]
4041ddc5 [CRITICAL][kernel][mt7988][eth][Increase CDM2 guard band settings to 4KB]
d8bd64af [kernel][mt7981][eth][Fix issue of GMAC RX hanging when internal GPHY connect to a legacy 10M/Half hub]
f8e2de72 [CRITICAL][kernel][mt7988][eth][Fix issue of transmitting abnormal data for SGMII]
84c34a72 [openwrt][mt7988][crypto][Fix 3 PPE issue for IPSec]
2f5b874e [MAC80211][hnat][Fix issue of multiple PPEs unbind for ETH in mt7981/7986]
15456702 [openwrt][common][network][Upgrade lldpd from 1.0.17 release 2 to release 3]
3d01da2e [openwrt][common][app][Fix switch cmd netlink issue on mt7988]
8d49660c [kernel][common][dts][Fix the mt7981 with an8855 syntax error dts]
88339b3b [kernel][common][hnat][Fix HNAT BIND issue with entry index 0x3fff]
9c805693 [openwrt][common][app][Add an8855 switch command support]
4cadd12b [openwrt][common][app][Refactor switch command to support switches with different design]
ba8a98e4 [kernel][common][net][Add AN8855 dsa and gsw driver]
6adb18b9 [kernel][common][hnat][Add PPE config to compare source PSE port as hit condition]
99170889 [kernel][common][eth][Add the new firmware for Aquantia AQR113C and CUX3410]
f634629e [kernel][mt7988][eth][macsec: Remove CK_TOP_NETSYS_TOPS_400M_SEL since it's not relevant]
f868325b [kernel][common][eth][Add Aquantia CUX3410 support]
6f2ddbf0 [openwrt][mt7988][tops][fix 3 PPE feature issue]
ff49cc9f [kernel][common][Refactor network backport patch path]
2c9fda11 [kernel][mtd/spi/nmbm/phy/][Change pending-5.4 & backport-5.4 files to correct folder]

[Release-log]

Change-Id: I793a18f2f96f185687080a0fb6b55379995b0398
diff --git a/recipes-devtools/switch/files/src/switch_netlink.c b/recipes-devtools/switch/files/src/switch_netlink.c
index 90a4a19..397ebe5 100644
--- a/recipes-devtools/switch/files/src/switch_netlink.c
+++ b/recipes-devtools/switch/files/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;
 }