[Feature][T106_eSDK]update from T106-V2.01.01.02P56U09.AP.17.09_CAP.17.09.01 to T106-M42-PLXXXX-P56U11.AP.19.00_CAP.19.00.01 -- code

Only Configure: No
Affected branch: master
Affected module: unknow
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No

Change-Id: I5eb7f586f78a987785b0f9885f1300c42bfd6819
diff --git a/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.c b/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.c
index c7da7a4..ffade7e 100755
--- a/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.c
+++ b/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.c
@@ -9,6 +9,8 @@
 #include "ram_config.h"

 #include <net/netfilter/nf_conntrack.h>

 #include <net/SI/fast_common.h>

+#include <pub_debug_info.h>

+

 /*******************************************************************************

  *                             Macro definitions                               *

  ******************************************************************************/

@@ -50,6 +52,18 @@
 	unsigned short flag;

 	struct	T_zvnet_pkt_stats pkt[2];

 };

+struct zvnet_arphdr {

+	unsigned short		ar_hrd;		/* format of hardware address	*/

+	unsigned short		ar_pro;		/* format of protocol address	*/

+	unsigned char		ar_hln;		/* length of hardware address	*/

+	unsigned char		ar_pln;		/* length of protocol address	*/

+	unsigned short		ar_op;		/* ARP opcode (command)		*/

+	unsigned char		ar_sha[ETH_ALEN];	/* sender hardware address	*/

+	unsigned char		ar_sip[4];		/* sender IP address		*/

+	unsigned char		ar_tha[ETH_ALEN];	/* target hardware address	*/

+	unsigned char		ar_tip[4];		/* target IP address		*/

+};

+

 /*******************************************************************************

  *						   Local variable definitions					*

  ******************************************************************************/

@@ -65,6 +79,7 @@
 struct semaphore g_zvnet_free_sem;

 struct semaphore g_zvnet_xmit_sem;

 struct sk_buff_head g_zvnet_skb_xmit_queue;

+atomic_t g_zvnet_pm_flag;

 

 unsigned int g_wrap_packet_size = 1000;

 module_param(g_wrap_packet_size, int, 0644);

@@ -152,7 +167,7 @@
     unsigned char *p = data;

     for(i = 0; i < len && i < limit_len; i+=16)

     {

-        printk("0x%04x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",i,

+        printk("0x%04x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",i,

             p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],

             p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);

         p += 16;

@@ -160,6 +175,11 @@
 }

 /* Ended by AICoder, pid:z5702yf8bad07ad1448a083e806dc31250b2418f */

 

+void zvnet_set_pm_flag(unsigned int flag){

+	if(flag & 0x100000)

+		atomic_set(&g_zvnet_pm_flag, 1);

+}

+

 int zvnet_get_index_by_netdev(struct net_device *net)

 {

     int i;

@@ -304,11 +324,127 @@
 	/* make sure we initialize shinfo sequentially */

 	skb_reset_network_header(skb);

 	skb_set_kcov_handle(skb, kcov_common_handle());

-	if(unlikely(g_trace_limit > 0)){

-		printk("-%s-dump_packet-start-%d\n", skb->dev->name, skb->len);

+	if(unlikely(g_trace_limit & 1)){

+		printk("-%s-dump_fromap-start-%d\n", skb->dev->name, skb->len);

 		zvnet_dump_packet(skb->data, skb->len, g_trace_limit);

-		printk("-%s-dump_packet-end-\n", skb->dev->name);

+		printk("-%s-dump_fromap-end-\n", skb->dev->name);

 	}

+/* Started by AICoder, pid:j2d34uccf7y1f37146a108290182771184940711 */

+	if (atomic_read(&g_zvnet_pm_flag)) {

+		unsigned short l2_hdr_len = 0;

+		unsigned short h_proto = htons(*(unsigned short *)(skb->data + ETH_ALEN + ETH_ALEN));

+		again:

+		if (l2_hdr_len + ETH_HLEN < skb->len) {

+			switch (h_proto) {

+				case ETH_P_IP: {

+					struct iphdr *iph = (struct iphdr *)(skb->data + ETH_HLEN + l2_hdr_len);

+					if (iph->protocol == IPPROTO_TCP) {

+						struct tcphdr *tcph = (struct tcphdr *)(((unsigned char *)iph) + iph->ihl * 4);

+						char *flag;

+						if (tcph->ack) {

+							if (tcph->fin)

+								flag = "FA";

+							else if (tcph->syn)

+								flag = "SA";

+							else if (tcph->psh)

+								flag = "PA";

+							else

+								flag = "A";

+						} else {

+							if (tcph->fin)

+								flag = "F";

+							else if (tcph->syn)

+								flag = "S";

+							else if (tcph->rst)

+								flag = "R";

+							else

+								flag = "";

+						}

+						sc_debug_info_record("cap_net", "%u-%pI4-%pI4-%u%s %u:%u/%u\n",

+											pbuf_temp->dev, &iph->saddr, &iph->daddr,

+											iph->protocol, flag, ntohs(tcph->source), ntohs(tcph->dest), skb->len);

+					} else if (iph->protocol == IPPROTO_UDP) {

+						struct udphdr *udph = (struct udphdr *)(((unsigned char *)iph) + iph->ihl * 4);

+						sc_debug_info_record("cap_net", "%u-%pI4-%pI4-%u %u:%u/%u\n",

+											pbuf_temp->dev, &iph->saddr, &iph->daddr,

+											iph->protocol, ntohs(udph->source), ntohs(udph->dest), skb->len);

+					} else if (iph->protocol == IPPROTO_ICMP) {

+						struct icmphdr *icmph = (struct icmphdr *)(((unsigned char *)iph) + iph->ihl * 4);

+						sc_debug_info_record("cap_net", "%u-%pI4-%pI4-%u %u:%u/%u\n",

+											pbuf_temp->dev, &iph->saddr, &iph->daddr,

+											iph->protocol, icmph->type, icmph->code, skb->len);

+					} else {

+						sc_debug_info_record("cap_net", "%u-%pI4-%pI4-%u/%u\n",

+											pbuf_temp->dev, &iph->saddr, &iph->daddr,

+											iph->protocol, skb->len);

+					}

+					break;

+				}

+				case ETH_P_IPV6: {

+					struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + ETH_HLEN + l2_hdr_len);

+					if (iph->nexthdr == NEXTHDR_TCP) {

+						struct tcphdr *tcph = (struct tcphdr *)(((unsigned char *)iph) + sizeof(struct ipv6hdr));

+						char *flag;

+						if (tcph->ack) {

+							if (tcph->fin)

+								flag = "FA";

+							else if (tcph->syn)

+								flag = "SA";

+							else if (tcph->psh)

+								flag = "PA";

+							else

+								flag = "A";

+						} else {

+							if (tcph->fin)

+								flag = "F";

+							else if (tcph->syn)

+								flag = "S";

+							else if (tcph->rst)

+								flag = "R";

+							else

+								flag = "";

+						}

+						sc_debug_info_record("cap_net", "%u-%pI6-%pI6-%u%s %u:%u/%u\n",

+											pbuf_temp->dev, iph->saddr.s6_addr32, iph->daddr.s6_addr32,

+											iph->nexthdr, flag, ntohs(tcph->source), ntohs(tcph->dest), skb->len);

+					} else if (iph->nexthdr == NEXTHDR_UDP) {

+						struct udphdr *udph = (struct udphdr *)(((unsigned char *)iph) + sizeof(struct ipv6hdr));

+						sc_debug_info_record("cap_net", "%u-%pI6-%pI6-%u %u:%u/%u\n",

+											pbuf_temp->dev, iph->saddr.s6_addr32, iph->daddr.s6_addr32,

+											iph->nexthdr, ntohs(udph->source), ntohs(udph->dest), skb->len);

+					} else if (iph->nexthdr == NEXTHDR_ICMP) {

+						struct icmp6hdr *icmph = (struct icmp6hdr *)(((unsigned char *)iph) + sizeof(struct ipv6hdr));

+						sc_debug_info_record("cap_net", "%u-%pI6-%pI6-%u %u:%u/%u\n",

+											pbuf_temp->dev, iph->saddr.s6_addr32, iph->daddr.s6_addr32,

+											iph->nexthdr, icmph->icmp6_type, icmph->icmp6_code,skb->len);

+					} else {

+						sc_debug_info_record("cap_net", "%u-%pI6-%pI6-%u/%u\n",

+											pbuf_temp->dev, iph->saddr.s6_addr32, iph->daddr.s6_addr32,

+											iph->nexthdr, skb->len);

+					}

+					break;

+				}

+				case ETH_P_ARP: {

+					struct zvnet_arphdr *arph = (struct zvnet_arphdr *)(skb->data + ETH_HLEN + l2_hdr_len);

+					sc_debug_info_record("cap_net", "%u:%04x-%pI4-%pI4-%u/%u\n",

+										pbuf_temp->dev, h_proto, arph->ar_sip, arph->ar_tip, htons(arph->ar_op), skb->len);

+					break;

+				}

+				case ETH_P_8021Q: {

+					struct vlan_hdr *vlanh = (struct vlan_hdr *)(skb->data + ETH_HLEN + l2_hdr_len);

+					sc_debug_info_record("cap_net", "%u:%04x-%u\n",

+										pbuf_temp->dev, h_proto, htons(vlanh->h_vlan_TCI) & VLAN_VID_MASK);

+					l2_hdr_len += VLAN_HLEN;

+					h_proto = htons(vlanh->h_vlan_encapsulated_proto);

+					goto again;

+				}

+				default:

+					sc_debug_info_record("cap_net", "%u:%04x/%u\n", pbuf_temp->dev, h_proto, skb->len);

+			}

+		}

+		atomic_set(&g_zvnet_pm_flag, 0);

+	}

+/* Ended by AICoder, pid:j2d34uccf7y1f37146a108290182771184940711 */

 	return skb;

 }

 

@@ -400,6 +536,11 @@
 		buff[i].len = skb->len;

 		buff[i].end_off = skb->end - skb->head;

 		buff[i].dev = zvnet_get_index_by_netdev(skb->dev);

+		if(unlikely(g_trace_limit & 2)){

+			printk("-%s-dump_toap-start-%d\n", skb->dev->name, skb->len);

+			zvnet_dump_packet(skb->data, skb->len, g_trace_limit);

+			printk("-%s-dump_toap-end-\n", skb->dev->name);

+		}

 		if(skb->capHead){

 			buff[i].buff = skb->capHead;

 #ifdef CONFIG_FASTNAT_MODULE

@@ -500,11 +641,11 @@
 	data->dev = net;

 	data->isToap = 1;

 	v7_dma_map_area(data->head, data->end - data->head + sizeof(struct skb_shared_info), DMA_TO_DEVICE);

+	net->stats.tx_packets++;

+	net->stats.tx_bytes += data->len;

 	skb_queue_tail(&g_zvnet_skb_xmit_queue, data);

 	if(data->len < g_wrap_packet_size || g_zvnet_skb_xmit_queue.qlen > g_wrap_num)

 		up(&g_zvnet_xmit_sem);

-	net->stats.tx_packets++;

-	net->stats.tx_bytes += skb->len;

 #else

     struct zvnet *dev = netdev_priv(net);

     struct zvnet_device *zvnetdev = (struct zvnet_device *)dev->dev_priv;

@@ -1240,6 +1381,7 @@
     struct net_device *net = NULL;

     struct zvnet_device *zvnetdev = NULL;

 

+	atomic_set(&g_zvnet_pm_flag, 0);

 #ifdef USE_ZVNET_PACKET

 			skb_queue_head_init(&g_zvnet_skb_xmit_queue);

 			spin_lock_init(&g_zvnet_free_lock);