Revert "[Feature][T106_eSDK]update from T106-V2.01.01.02P56U06.AP.15.11_CAP.15.11.01 to T106-V2.01.01.02P56U06.AP.16.08_CAP.16.08.01 -- code"

This reverts commit 39d99118f249054d01992819702e0612dfdfe3b9.

Reason for revert:revert 16.08_patch

Change-Id: Ib9848be6d113db9be3378524981a30d0c3a0c1a5
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..2a8fcc3 100755
--- a/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.c
+++ b/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.c
@@ -8,7 +8,7 @@
 #include "zvnet_dev.h"

 #include "ram_config.h"

 #include <net/netfilter/nf_conntrack.h>

-#include <net/SI/fast_common.h>

+

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

  *                             Macro definitions                               *

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

@@ -72,8 +72,10 @@
 module_param(g_wrap_num, int, 0644);

 unsigned int g_wrap_timeout = 10;

 module_param(g_wrap_timeout, int, 0644);

+/*jb.qi add for debug network package on 20240806 start*/

 unsigned int g_trace_limit = 0;

 module_param(g_trace_limit, int, 0644);

+/*jb.qi add for debug network package on 20240806 end*/

 #endif

 

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

@@ -83,6 +85,7 @@
 extern void v7_dma_map_area(const void *, size_t, int);

 extern void *get_ct_for_ap(struct sk_buff *skb);

 extern void put_ct_for_ap(void *ct);

+extern spinlock_t fast_fw_spinlock;

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

  *					   Local function declarations						*

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

@@ -125,41 +128,38 @@
 	return NULL;

 }

 

-/* Started by AICoder, pid:2fa080381bb2e3d14fbc0aa44091291a60d78e35 */

 void check_skb_test(struct sk_buff *skb)

 {

-    if (skb && vir_addr_ap) {

-        struct sk_buff *tmp_skb;

-        if ((skb->capHead && (virt_to_phys_ap(skb->head) == NULL))

-        || ((skb->capHead == NULL) && virt_to_phys_ap(skb->head))) {

-            dump_stack();

-            panic("capHead err");

-        }

-        skb_queue_walk(&g_zvnet_skb_queue, tmp_skb) {

-            if (tmp_skb == skb) {

-                dump_stack();

-                panic("dup free");

-            }

-        }

-    }

+	if(skb && vir_addr_ap){

+		struct sk_buff *tmp_skb;

+		if((skb->capHead && (virt_to_phys_ap(skb->head) == NULL))

+		|| ((skb->capHead == NULL) && virt_to_phys_ap(skb->head))){

+			dump_stack();

+			msleep(1000);

+			panic("capHead err");

+		}

+		skb_queue_walk(&g_zvnet_skb_queue, tmp_skb) {

+			if(tmp_skb == skb){

+				dump_stack();

+				msleep(1000);

+				panic("dup free");

+			}

+		}

+	}

 }

-/* Ended by AICoder, pid:2fa080381bb2e3d14fbc0aa44091291a60d78e35 */

-

-/* Started by AICoder, pid:z5702yf8bad07ad1448a083e806dc31250b2418f */

+/*jb.qi add for debug network package on 20240806 start*/

 void zvnet_dump_packet(unsigned char * data, int len, int limit_len)

 {

     int i = 0;

-    unsigned char *p = data;

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

+

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

     {

-        printk("0x%04x: %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;

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

+            *(data+i),*(data+i+1),*(data+i+2),*(data+i+3),*(data+i+4),*(data+i+5),*(data+i+6),*(data+i+7),

+            *(data+i+8),*(data+i+9),*(data+i+10),*(data+i+11),*(data+i+12),*(data+i+13),*(data+i+14),*(data+i+15));

     }

 }

-/* Ended by AICoder, pid:z5702yf8bad07ad1448a083e806dc31250b2418f */

-

+/*jb.qi add for debug network package on 20240806 end*/

 int zvnet_get_index_by_netdev(struct net_device *net)

 {

     int i;

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

 	skb_reset_network_header(skb);

 	skb_set_kcov_handle(skb, kcov_common_handle());

+	/*jb.qi add for debug network package on 20240806 start*/

 	if(unlikely(g_trace_limit > 0)){

-		printk("-%s-dump_packet-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_packet-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);

+        }

+	/*jb.qi add for debug network package on 20240806 end*/

 	return skb;

 }

 

@@ -319,38 +321,33 @@
     return 0;

 }

 

-/* Started by AICoder, pid:b001dtf2551fd53146790a57201be3321cf0a682 */

 static void skb_debug_test(struct sk_buff *skb)

 {

     int i;

-    int vcount = skb->len / 10;

-    int rcount = skb->len % 10;

+    int vcount = skb->len/10;

+    int rcount = skb->len%10;

     char tmp[64] = {0};

     char strbuf[64] = {0};

-    const unsigned char *data = skb->data;

 

     zv_info("\n");

-    for (i = 0; i < vcount; i++) {

-        zv_info("%d---%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x\n", i,

-                data[0 + 10 * i], data[1 + 10 * i], data[2 + 10 * i], data[3 + 10 * i],

-                data[4 + 10 * i], data[5 + 10 * i], data[6 + 10 * i], data[7 + 10 * i],

-                data[8 + 10 * i], data[9 + 10 * i]);

+    for(i=0; i<vcount; i++) {

+        zv_info("%d---0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x\n",i,skb->data[0+10*i],skb->data[1+10*i],skb->data[2+10*i],

+                skb->data[3+10*i],skb->data[4+10*i],skb->data[5+10*i],skb->data[6+10*i],skb->data[7+10*i],skb->data[8+10*i],skb->data[9+10*i]);

     }

-    if (vcount > 0) {

-        memset(tmp, 0, sizeof(tmp));

-        sprintf(strbuf, "%d---", vcount);

-        char *p = strbuf + strlen(strbuf);

+    if(vcount > 0) {

+        memset(tmp,0,sizeof(tmp));

+        memset(strbuf,0,sizeof(strbuf));

+        sprintf(strbuf,"%d---",vcount);

 

-        for (i = 0; i < rcount; i++) {

-            sprintf(p, "%02x,", data[10 * vcount + i]);

-            p += strlen(p);

+        for(i=0; i<rcount; i++)

+        {

+            sprintf(tmp,"0x%x,",skb->data[10*vcount + i]);

+            strcat(strbuf,tmp);

         }

-        *(p - 1) = '\0'; // ÒÆ³ý×îºóÒ»¸ö¶ººÅ

-        zv_info("%s ", strbuf);

+        zv_info("%s ",strbuf);

     }

     zv_info("\n");

 }

-/* Ended by AICoder, pid:b001dtf2551fd53146790a57201be3321cf0a682 */

 

 static int zvnet_open(struct net_device *net)

 {

@@ -476,8 +473,8 @@
 		return NET_XMIT_SUCCESS;

 	}

 		

-	if(unlikely(skb->next//|| skb->capHead || skb_headroom(skb) < NET_SKB_PAD

-		|| skb->fclone || skb->cloned || (skb_shinfo(skb)->nr_frags) || skb->sk || (skb->indev == NULL)

+	if(unlikely(skb_headroom(skb) < NET_SKB_PAD || skb->next//|| skb->capHead

+		|| skb->fclone || skb->cloned || (skb_shinfo(skb)->nr_frags) || skb->sk || (skb->indev == NULL) 

 		|| (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) || (skb_has_frag_list(skb)))){

 		int ret_len = skb->len;

 

@@ -635,7 +632,6 @@
     .ndo_get_stats  = zvnet_get_stats,

     .ndo_change_mtu = eth_change_mtu,

     .ndo_validate_addr = eth_validate_addr,

-    .ndo_set_mac_address = eth_mac_addr,

 };

 

 static void v2xnet_init_netdev(struct net_device *net)

@@ -806,32 +802,30 @@
 {

     struct sk_buff *skb;

 #if 0

-/* Started by AICoder, pid:sd1cfsbc2eu87c41445f09652039f525fa147687 */

-int ret_len = 0;

-struct sk_buff *skb;

+    char skb_data[ZVNET_TMP_BUFF_LEN];

+    int ret_len = 0;

 

-ret_len = zvnet_channel_read(chninfo, NULL, 0); // »ñÈ¡ÐèÒª¶ÁÈ¡µÄÊý¾Ý³¤¶È

-if(ret_len <= 0) {

-    zv_err("zvnet_channel_read fail.\n");

-    return NULL;

-}

+    if(NULL == chninfo || NULL == dev) {

+        zv_err("zvnet_channel_read null.\n");

+        return NULL;

+    }

 

-skb = dev_alloc_skb(ret_len + ZVNET_SKB_PAD);

-if (unlikely(!skb)) {

-    zv_err("netdev_alloc_skb fail,len %d",ret_len);

-    return NULL;

-}

+    ret_len = zvnet_channel_read(chninfo, (void *)skb_data, sizeof(skb_data));

 

-ret_len = zvnet_channel_read(chninfo, skb->data, ret_len); // ¶ÁÈ¡Êý¾Ýµ½skb->data

-if(ret_len <= 0) {

-    kfree_skb(skb); // Èç¹û¶Áȡʧ°Ü£¬ÊÍ·ÅÒÑ·ÖÅäµÄskb

-    zv_err("zvnet_channel_read fail.\n");

-    return NULL;

-}

+    if(ret_len <= 0) {

+        zv_err("zvnet_channel_read fail.\n");

+        return NULL;

+    }

 

-skb_put(skb,ret_len);

-skb_reserve(skb, ZVNET_SKB_PAD);

-/* Ended by AICoder, pid:sd1cfsbc2eu87c41445f09652039f525fa147687 */

+    skb = dev_alloc_skb(ret_len + ZVNET_SKB_PAD);

+    if (unlikely(!skb)) {

+        zv_err("netdev_alloc_skb fail,len %d",ret_len);

+        return NULL;

+    }

+

+    skb_put(skb,ret_len);

+    skb_reserve(skb, ZVNET_SKB_PAD);

+    memcpy(skb->data, &skb_data[0], ret_len);

 #else

 	struct T_zvnet_rpmsg buff = {0};

 	int ret_len = 0;

@@ -1105,9 +1099,6 @@
 							.flag = 0};

 	int ret_len = 0;

 	struct nf_conn *ct;

-	fast_entry_t *entry;

-	struct net_device *in;

-	struct net_device *out;

 	

 	while(1) {

 		struct T_zvnet_rpmsg_ctstat buff = {0};

@@ -1124,104 +1115,33 @@
 			panic("err, ret:%d!!!!!!", ret_len);	

 		}

 		ct = (struct nf_conn *)buff.cap_nfct;

+		

 		WARN_ON(atomic_read(&ct->ct_general.use) == 0);

 		if(buff.flag){

-			if(!(buff.pkt[0].pkt || buff.pkt[0].len || buff.pkt[1].pkt || buff.pkt[1].len))

-				continue;

 			BUG_ON(buff.in <= 0 || buff.out <= 0);

-			in = zvnet_dev[buff.in-1].net;

-			out = zvnet_dev[buff.out-1].net;

 			if(buff.pkt[0].pkt && buff.pkt[0].len){

 				zv_info("nf_update %x %s %s %d %d", buff.cap_nfct, ct->indev[0]->name, ct->outdev[0]->name, buff.in, buff.out);

-				in->stats.rx_packets += buff.pkt[0].pkt;

-				in->stats.rx_bytes += buff.pkt[0].len;

-				out->stats.tx_packets += buff.pkt[0].pkt;

-				out->stats.tx_bytes += buff.pkt[0].len;

+				zvnet_dev[buff.in-1].net->stats.rx_packets += buff.pkt[0].pkt;

+				zvnet_dev[buff.in-1].net->stats.rx_bytes += buff.pkt[0].len;

+				zvnet_dev[buff.out-1].net->stats.tx_packets += buff.pkt[0].pkt;

+				zvnet_dev[buff.out-1].net->stats.tx_bytes += buff.pkt[0].len;

 			}

 			if(buff.pkt[1].pkt && buff.pkt[1].len){

 				zv_info("nf_update %x %s %s %d %d", buff.cap_nfct, ct->indev[1]->name, ct->outdev[1]->name, buff.out, buff.in);

-				out->stats.rx_packets += buff.pkt[1].pkt;

-				out->stats.rx_bytes += buff.pkt[1].len;

-				in->stats.tx_packets += buff.pkt[1].pkt;

-				in->stats.tx_bytes += buff.pkt[1].len;

+				zvnet_dev[buff.out-1].net->stats.rx_packets += buff.pkt[1].pkt;

+				zvnet_dev[buff.out-1].net->stats.rx_bytes += buff.pkt[1].len;

+				zvnet_dev[buff.in-1].net->stats.tx_packets += buff.pkt[1].pkt;

+				zvnet_dev[buff.in-1].net->stats.tx_bytes += buff.pkt[1].len;

 			}

 			spin_lock_bh(&fast_fw_spinlock);

-			/*¸üÐÂÁ´½Ó³¬Ê±*/

-			if (IPPROTO_TCP == nf_ct_protonum(ct))

-			{

-				ct->timeout = jiffies + tcp_timeouts[ct->proto.tcp.state];

-			}else if (IPPROTO_UDP == nf_ct_protonum(ct)){

-				/*udp*/

-				if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)){

-					ct->timeout = jiffies + fast_udp_timeout_stream;

-				}else{

-					ct->timeout = jiffies + fast_udp_timeout;

-				}

-			}

-			entry = (fast_entry_t *)ct->fast_entry;

-			if(entry){

-				WARN_ON(entry->ct != ct);

-				mod_timer(&entry->timeout, ct->timeout);

-			}

 			ct->packet_info[IP_CT_DIR_ORIGINAL].bytes += buff.pkt[IP_CT_DIR_ORIGINAL].len;

 			ct->packet_info[IP_CT_DIR_ORIGINAL].packets += buff.pkt[IP_CT_DIR_ORIGINAL].pkt;

 			ct->packet_info[IP_CT_DIR_REPLY].bytes += buff.pkt[IP_CT_DIR_REPLY].len;

 			ct->packet_info[IP_CT_DIR_REPLY].packets += buff.pkt[IP_CT_DIR_REPLY].pkt;

-			if(ct->indev[0] && is_vlan_dev(ct->indev[0])){

-				struct net_device *tmp = vlan_dev_real_dev(ct->indev[0]);

-				struct vlan_pcpu_stats *stats = this_cpu_ptr(vlan_dev_priv(ct->indev[0])->vlan_pcpu_stats);

-

-				if(tmp == in){

-/* Started by AICoder, pid:tbef0151bf4135d1479d0a5d108c870bc756e858 */

-u64_stats_update_begin(&stats->syncp);

-stats->rx_packets += buff.pkt[0].pkt;

-stats->rx_bytes += buff.pkt[0].len;

-stats->tx_packets += buff.pkt[1].pkt;

-stats->tx_bytes += buff.pkt[1].len;

-u64_stats_update_end(&stats->syncp);

-/* Ended by AICoder, pid:tbef0151bf4135d1479d0a5d108c870bc756e858 */

-				}else if(tmp == out){

-/* Started by AICoder, pid:y34f7id6bcs049f144f10bb8a05c9703b196635b */

-u64_stats_update_begin(&stats->syncp);

-stats->tx_packets += buff.pkt[0].pkt;

-stats->tx_bytes += buff.pkt[0].len;

-stats->rx_packets += buff.pkt[1].pkt;

-stats->rx_bytes += buff.pkt[1].len;

-u64_stats_update_end(&stats->syncp);

-/* Ended by AICoder, pid:y34f7id6bcs049f144f10bb8a05c9703b196635b */

-				}else

-					zv_err("nf_update0 %s->%s!=%s-%s", in->name, out->name, tmp->name, ct->indev[0]->name);

-			}

-			if(ct->indev[1] && is_vlan_dev(ct->indev[1])){

-				struct net_device *tmp = vlan_dev_real_dev(ct->indev[1]);

-				struct vlan_pcpu_stats *stats = this_cpu_ptr(vlan_dev_priv(ct->indev[1])->vlan_pcpu_stats);

-

-				if(tmp == in){

-/* Started by AICoder, pid:8bef0t51bfu135d1479d0a5d108c870bc756e858 */

-u64_stats_update_begin(&stats->syncp);

-stats->rx_packets += buff.pkt[0].pkt;

-stats->rx_bytes += buff.pkt[0].len;

-stats->tx_packets += buff.pkt[1].pkt;

-stats->tx_bytes += buff.pkt[1].len;

-u64_stats_update_end(&stats->syncp);

-/* Ended by AICoder, pid:8bef0t51bfu135d1479d0a5d108c870bc756e858 */

-				}else if(tmp == out){

-/* Started by AICoder, pid:934f7zd6bcl049f144f10bb8a05c9703b196635b */

-u64_stats_update_begin(&stats->syncp);

-stats->tx_packets += buff.pkt[0].pkt;

-stats->tx_bytes += buff.pkt[0].len;

-stats->rx_packets += buff.pkt[1].pkt;

-stats->rx_bytes += buff.pkt[1].len;

-u64_stats_update_end(&stats->syncp);

-/* Ended by AICoder, pid:934f7zd6bcl049f144f10bb8a05c9703b196635b */

-				}else

-					zv_err("nf_update1 %s->%s!=%s-%s", in->name, out->name, tmp->name, ct->indev[1]->name);

-			}

 			spin_unlock_bh(&fast_fw_spinlock);

 			zv_info("nf_update %x %d %d %d %d", buff.cap_nfct, buff.pkt[0].pkt, buff.pkt[0].len, buff.pkt[1].pkt, buff.pkt[1].len);

 		}else{

 			zv_info("nf_put %x", buff.cap_nfct);

-			WRITE_ONCE(ct->timeout, nfct_time_stamp);

 			nf_conntrack_put(buff.cap_nfct);

 		}

 	}

@@ -1259,11 +1179,11 @@
             return err;

         }

 

-        //net->needed_headroom += ZVNET_SKB_PAD;//NET_SKB_PAD;

+        net->needed_headroom += ZVNET_SKB_PAD;//NET_SKB_PAD;

         sprintf(net->name, "%s%d", ZVNET_IFNAME_PREFIX, i);

         dev = v2xnet_dev_init(net, zvnetdev);

         v2xnet_init_netdev(net);

-		if(0 == i || i > 8){

+		if(0 == i){

 			net->flags = (net->flags & (~IFF_NOARP));

 		}

         err = register_netdev(net);