Module Name:    src
Committed By:   jdolecek
Date:           Sun Mar 22 11:20:59 UTC 2020

Modified Files:
        src/sys/arch/xen/include: xennet_checksum.h
        src/sys/arch/xen/xen: if_xennet_xenbus.c xennet_checksum.c
            xennetback_xenbus.c

Log Message:
actually in data_validated case, there is no need to inspect the data for Rx,
simply set the supported csum offload flags to skip the software csum
verification


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/xen/include/xennet_checksum.h
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/xen/xen/if_xennet_xenbus.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/xen/xen/xennet_checksum.c
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/xen/xen/xennetback_xenbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/include/xennet_checksum.h
diff -u src/sys/arch/xen/include/xennet_checksum.h:1.3 src/sys/arch/xen/include/xennet_checksum.h:1.4
--- src/sys/arch/xen/include/xennet_checksum.h:1.3	Wed Mar 18 19:23:12 2020
+++ src/sys/arch/xen/include/xennet_checksum.h	Sun Mar 22 11:20:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: xennet_checksum.h,v 1.3 2020/03/18 19:23:12 jdolecek Exp $	*/
+/*	$NetBSD: xennet_checksum.h,v 1.4 2020/03/22 11:20:59 jdolecek Exp $	*/
 
 /*-
  * Copyright (c)2006 YAMAMOTO Takashi,
@@ -32,6 +32,6 @@
 struct ifnet;
 struct mbuf;
 
-int xennet_checksum_fill(struct ifnet *, struct mbuf *, bool);
+int xennet_checksum_fill(struct ifnet *, struct mbuf *);
 
 #endif /* !_XEN_XENNET_CHECKSUM_H_ */

Index: src/sys/arch/xen/xen/if_xennet_xenbus.c
diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.93 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.94
--- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.93	Sun Mar 22 00:11:02 2020
+++ src/sys/arch/xen/xen/if_xennet_xenbus.c	Sun Mar 22 11:20:59 2020
@@ -1,4 +1,4 @@
-/*      $NetBSD: if_xennet_xenbus.c,v 1.93 2020/03/22 00:11:02 jdolecek Exp $      */
+/*      $NetBSD: if_xennet_xenbus.c,v 1.94 2020/03/22 11:20:59 jdolecek Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -84,7 +84,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.93 2020/03/22 00:11:02 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.94 2020/03/22 11:20:59 jdolecek Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -1128,10 +1128,10 @@ again:
 			m->m_ext.ext_paddr = pa;
 			m->m_flags |= M_EXT_RW; /* we own the buffer */
 		}
-		if ((rx->flags & (NETRXF_csum_blank|NETRXF_data_validated))) {
-			xennet_checksum_fill(ifp, m,
-			    ((rx->flags & NETRXF_data_validated) != 0));
-		}
+		if (rx->flags & NETRXF_csum_blank)
+			xennet_checksum_fill(ifp, m);
+		else if (rx->flags & NETRXF_data_validated)
+			m->m_pkthdr.csum_flags = XN_M_CSUM_SUPPORTED;
 		/* free req may overwrite *rx, better doing it late */
 		xennet_rx_free_req(req);
 

Index: src/sys/arch/xen/xen/xennet_checksum.c
diff -u src/sys/arch/xen/xen/xennet_checksum.c:1.9 src/sys/arch/xen/xen/xennet_checksum.c:1.10
--- src/sys/arch/xen/xen/xennet_checksum.c:1.9	Sun Mar 22 00:11:02 2020
+++ src/sys/arch/xen/xen/xennet_checksum.c	Sun Mar 22 11:20:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: xennet_checksum.c,v 1.9 2020/03/22 00:11:02 jdolecek Exp $	*/
+/*	$NetBSD: xennet_checksum.c,v 1.10 2020/03/22 11:20:59 jdolecek Exp $	*/
 
 /*-
  * Copyright (c)2006 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xennet_checksum.c,v 1.9 2020/03/22 00:11:02 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xennet_checksum.c,v 1.10 2020/03/22 11:20:59 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -56,12 +56,9 @@ static struct evcnt xn_cksum_defer = EVC
     NULL, "xennet", "csum blank");
 static struct evcnt xn_cksum_undefer = EVCNT_INITIALIZER(EVCNT_TYPE_MISC,
     NULL, "xennet", "csum undeferred");
-static struct evcnt xn_cksum_valid = EVCNT_INITIALIZER(EVCNT_TYPE_MISC,
-    NULL, "xennet", "csum data valid");
 
 EVCNT_ATTACH_STATIC(xn_cksum_defer);
 EVCNT_ATTACH_STATIC(xn_cksum_undefer);
-EVCNT_ATTACH_STATIC(xn_cksum_valid);
 
 #ifdef XENNET_DEBUG
 /* ratecheck(9) for checksum validation failures */
@@ -82,7 +79,7 @@ m_extract(struct mbuf *m, int off, int l
  * for hw offload to do it
  */
 int
-xennet_checksum_fill(struct ifnet *ifp, struct mbuf *m, bool data_validated)
+xennet_checksum_fill(struct ifnet *ifp, struct mbuf *m)
 {
 	const struct ether_header *eh;
 	struct ip *iph = NULL;
@@ -193,51 +190,46 @@ xennet_checksum_fill(struct ifnet *ifp, 
 #ifdef XENNET_DEBUG
 		static struct timeval lasttime;
 		if (ratecheck(&lasttime, &xn_cksum_errintvl))
-			printf("%s: unknown proto %d passed%s\n",
-			    ifp->if_xname, nxt,
-			    data_validated ? "" : " no checksum");
+			printf("%s: unknown proto %d passed no checksum\n",
+			    ifp->if_xname, nxt);
 #endif /* XENNET_DEBUG */
 		error = EINVAL;
 		goto out;
 	    }
 	}
 
-	if (!data_validated) {
-		/*
-		 * Only compute the checksum if impossible to defer.
-		 */
-		sw_csum = m->m_pkthdr.csum_flags & ~ifp->if_csum_flags_rx;
-
-		/*
-		 * Always initialize the sum to 0!  Some HW assisted
-		 * checksumming requires this. in_undefer_cksum()
-		 * also needs it to be zero.
-		 */
-		if (iph != NULL && (m->m_pkthdr.csum_flags & M_CSUM_IPv4))
-			iph->ip_sum = 0;
-
-		if (sw_csum & (M_CSUM_IPv4|M_CSUM_UDPv4|M_CSUM_TCPv4)) {
-			in_undefer_cksum(m, ehlen,
-			    sw_csum & (M_CSUM_IPv4|M_CSUM_UDPv4|M_CSUM_TCPv4));
-		}
+	/*
+	 * Only compute the checksum if impossible to defer.
+	 */
+	sw_csum = m->m_pkthdr.csum_flags & ~ifp->if_csum_flags_rx;
+
+	/*
+	 * Always initialize the sum to 0!  Some HW assisted
+	 * checksumming requires this. in_undefer_cksum()
+	 * also needs it to be zero.
+	 */
+	if (iph != NULL && (m->m_pkthdr.csum_flags & M_CSUM_IPv4))
+		iph->ip_sum = 0;
+
+	if (sw_csum & (M_CSUM_IPv4|M_CSUM_UDPv4|M_CSUM_TCPv4)) {
+		in_undefer_cksum(m, ehlen,
+		    sw_csum & (M_CSUM_IPv4|M_CSUM_UDPv4|M_CSUM_TCPv4));
+	}
 
 #ifdef INET6
-		if (sw_csum & (M_CSUM_UDPv6|M_CSUM_TCPv6)) {
-			in6_undefer_cksum(m, ehlen,
-			    sw_csum & (M_CSUM_UDPv6|M_CSUM_TCPv6));
-		}
+	if (sw_csum & (M_CSUM_UDPv6|M_CSUM_TCPv6)) {
+		in6_undefer_cksum(m, ehlen,
+		    sw_csum & (M_CSUM_UDPv6|M_CSUM_TCPv6));
+	}
 #endif
 
-		if (m->m_pkthdr.csum_flags != 0) {
-			xn_cksum_defer.ev_count++;
+	if (m->m_pkthdr.csum_flags != 0) {
+		xn_cksum_defer.ev_count++;
 #ifdef M_CSUM_BLANK
-			m->m_pkthdr.csum_flags |= M_CSUM_BLANK;
+		m->m_pkthdr.csum_flags |= M_CSUM_BLANK;
 #endif
-		} else {
-			xn_cksum_undefer.ev_count++;
-		}
 	} else {
-		xn_cksum_valid.ev_count++;
+		xn_cksum_undefer.ev_count++;
 	}
 
     out:

Index: src/sys/arch/xen/xen/xennetback_xenbus.c
diff -u src/sys/arch/xen/xen/xennetback_xenbus.c:1.84 src/sys/arch/xen/xen/xennetback_xenbus.c:1.85
--- src/sys/arch/xen/xen/xennetback_xenbus.c:1.84	Sun Mar 22 00:11:02 2020
+++ src/sys/arch/xen/xen/xennetback_xenbus.c	Sun Mar 22 11:20:59 2020
@@ -1,4 +1,4 @@
-/*      $NetBSD: xennetback_xenbus.c,v 1.84 2020/03/22 00:11:02 jdolecek Exp $      */
+/*      $NetBSD: xennetback_xenbus.c,v 1.85 2020/03/22 11:20:59 jdolecek Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.84 2020/03/22 00:11:02 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.85 2020/03/22 11:20:59 jdolecek Exp $");
 
 #include "opt_xen.h"
 
@@ -888,10 +888,10 @@ xennetback_evthandler(void *arg)
 		xennetback_tx_response(xneti, txreq.id,
 		    NETIF_RSP_OKAY);
 
-		if ((txreq.flags & (NETTXF_csum_blank|NETTXF_data_validated))) {
-			xennet_checksum_fill(ifp, m,
-			    ((txreq.flags & NETTXF_data_validated) != 0));
-		}
+		if (txreq.flags & NETTXF_csum_blank)
+			xennet_checksum_fill(ifp, m);
+		else if (txreq.flags & NETTXF_data_validated)
+			m->m_pkthdr.csum_flags = XN_M_CSUM_SUPPORTED;
 		m_set_rcvif(m, ifp);
 
 		if_percpuq_enqueue(ifp->if_percpuq, m);

Reply via email to