Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/xen use NET[RT]XF_data_validated flag to mark when ...
details: https://anonhg.NetBSD.org/src/rev/cb5b8d25d0af
branches: trunk
changeset: 1008313:cb5b8d25d0af
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Wed Mar 18 19:23:12 2020 +0000
description:
use NET[RT]XF_data_validated flag to mark when Tx packet has valid
checksum; this is used to skip software checksum validation on
xennet Rx side when configured for Rx offloading
in Dom0 assume that checksum is valid when the Tx mbuf has no offload flags
- in that case either it's local packet where checksum has just been
computed in software, or forwarded external packet already
verified when received on Dom0
practical offshot of this is that DomU doesn't re-verify checksum of
packets forwarded from external hosts, e.g. via bridge(4)
diffstat:
sys/arch/xen/include/xennet_checksum.h | 4 +-
sys/arch/xen/xen/if_xennet_xenbus.c | 11 +++---
sys/arch/xen/xen/xennet_checksum.c | 54 +++++++++++++++++++++++++--------
sys/arch/xen/xen/xennetback_xenbus.c | 13 ++++---
4 files changed, 55 insertions(+), 27 deletions(-)
diffs (206 lines):
diff -r a33b1f71c49c -r cb5b8d25d0af sys/arch/xen/include/xennet_checksum.h
--- a/sys/arch/xen/include/xennet_checksum.h Wed Mar 18 19:07:29 2020 +0000
+++ b/sys/arch/xen/include/xennet_checksum.h Wed Mar 18 19:23:12 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xennet_checksum.h,v 1.2 2020/03/16 20:51:36 jdolecek Exp $ */
+/* $NetBSD: xennet_checksum.h,v 1.3 2020/03/18 19:23:12 jdolecek Exp $ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
@@ -32,6 +32,6 @@
struct ifnet;
struct mbuf;
-int xennet_checksum_fill(struct ifnet *, struct mbuf *);
+int xennet_checksum_fill(struct ifnet *, struct mbuf *, bool);
#endif /* !_XEN_XENNET_CHECKSUM_H_ */
diff -r a33b1f71c49c -r cb5b8d25d0af sys/arch/xen/xen/if_xennet_xenbus.c
--- a/sys/arch/xen/xen/if_xennet_xenbus.c Wed Mar 18 19:07:29 2020 +0000
+++ b/sys/arch/xen/xen/if_xennet_xenbus.c Wed Mar 18 19:23:12 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_xennet_xenbus.c,v 1.90 2020/03/16 20:51:36 jdolecek Exp $ */
+/* $NetBSD: if_xennet_xenbus.c,v 1.91 2020/03/18 19:23:13 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.90 2020/03/16 20:51:36 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.91 2020/03/18 19:23:13 jdolecek Exp $");
#include "opt_xen.h"
#include "opt_nfs_boot.h"
@@ -1120,8 +1120,9 @@
m->m_ext.ext_paddr = pa;
m->m_flags |= M_EXT_RW; /* we own the buffer */
}
- if ((rx->flags & NETRXF_csum_blank) != 0) {
- xennet_checksum_fill(ifp, m);
+ if ((rx->flags & (NETRXF_csum_blank|NETRXF_data_validated))) {
+ xennet_checksum_fill(ifp, m,
+ ((rx->flags & NETRXF_data_validated) != 0));
}
/* free req may overwrite *rx, better doing it late */
xennet_rx_free_req(req);
@@ -1231,7 +1232,7 @@
(M_CSUM_TCPv4 | M_CSUM_UDPv4)) != 0) {
txflags = NETTXF_csum_blank;
} else {
- txflags = 0;
+ txflags = NETTXF_data_validated;
}
if (m->m_pkthdr.len != m->m_len ||
diff -r a33b1f71c49c -r cb5b8d25d0af sys/arch/xen/xen/xennet_checksum.c
--- a/sys/arch/xen/xen/xennet_checksum.c Wed Mar 18 19:07:29 2020 +0000
+++ b/sys/arch/xen/xen/xennet_checksum.c Wed Mar 18 19:23:12 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xennet_checksum.c,v 1.6 2020/03/16 20:51:36 jdolecek Exp $ */
+/* $NetBSD: xennet_checksum.c,v 1.7 2020/03/18 19:23:13 jdolecek Exp $ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xennet_checksum.c,v 1.6 2020/03/16 20:51:36 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xennet_checksum.c,v 1.7 2020/03/18 19:23:13 jdolecek Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -46,6 +46,17 @@
#include <xen/xennet_checksum.h>
+static struct evcnt xn_cksum_defer = EVCNT_INITIALIZER(EVCNT_TYPE_MISC,
+ 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);
+
/* ratecheck(9) for checksum validation failures */
static const struct timeval xn_cksum_errintvl = { 600, 0 }; /* 10 min, each */
@@ -66,7 +77,7 @@
* for hw offload to do it
*/
int
-xennet_checksum_fill(struct ifnet *ifp, struct mbuf *m)
+xennet_checksum_fill(struct ifnet *ifp, struct mbuf *m, bool data_validated)
{
const struct ether_header *eh;
struct ip *iph;
@@ -94,8 +105,9 @@
} else {
static struct timeval lasttime;
if (ratecheck(&lasttime, &xn_cksum_errintvl))
- printf("%s: unknown etype %#x passed no checksum\n",
- ifp->if_xname, ntohs(etype));
+ printf("%s: unknown etype %#x passed%s\n",
+ ifp->if_xname, ntohs(etype),
+ data_validated ? "" : " no checksum");
return EINVAL;
}
@@ -127,21 +139,35 @@
{
static struct timeval lasttime;
if (ratecheck(&lasttime, &xn_cksum_errintvl))
- printf("%s: unknown proto %d passed no checksum\n",
- ifp->if_xname, nxt);
+ printf("%s: unknown proto %d passed%s\n",
+ ifp->if_xname, nxt,
+ data_validated ? "" : " no checksum");
error = EINVAL;
goto out;
}
}
- /*
- * Only compute the checksum if impossible to defer.
- */
- sw_csum = m->m_pkthdr.csum_flags & ~ifp->if_csum_flags_rx;
+ if (!data_validated) {
+ /*
+ * Only compute the checksum if impossible to defer.
+ */
+ sw_csum = m->m_pkthdr.csum_flags & ~ifp->if_csum_flags_rx;
+
+ 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));
+ }
- if (sw_csum & (M_CSUM_UDPv4|M_CSUM_TCPv4)) {
- in_undefer_cksum(m, ehlen,
- sw_csum & (M_CSUM_UDPv4|M_CSUM_TCPv4));
+ if (m->m_pkthdr.csum_flags != 0) {
+ xn_cksum_defer.ev_count++;
+#ifdef M_CSUM_BLANK
+ m->m_pkthdr.csum_flags |= M_CSUM_BLANK;
+#endif
+ } else {
+ xn_cksum_undefer.ev_count++;
+ }
+ } else {
+ xn_cksum_valid.ev_count++;
}
out:
diff -r a33b1f71c49c -r cb5b8d25d0af sys/arch/xen/xen/xennetback_xenbus.c
--- a/sys/arch/xen/xen/xennetback_xenbus.c Wed Mar 18 19:07:29 2020 +0000
+++ b/sys/arch/xen/xen/xennetback_xenbus.c Wed Mar 18 19:23:12 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xennetback_xenbus.c,v 1.79 2020/03/17 05:04:10 kre Exp $ */
+/* $NetBSD: xennetback_xenbus.c,v 1.80 2020/03/18 19:23:13 jdolecek Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.79 2020/03/17 05:04:10 kre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.80 2020/03/18 19:23:13 jdolecek Exp $");
#include "opt_xen.h"
@@ -881,8 +881,9 @@
xennetback_tx_response(xneti, txreq.id,
NETIF_RSP_OKAY);
- if ((txreq.flags & NETTXF_csum_blank) != 0) {
- xennet_checksum_fill(ifp, m);
+ if ((txreq.flags & (NETTXF_csum_blank|NETTXF_data_validated))) {
+ xennet_checksum_fill(ifp, m,
+ ((txreq.flags & NETTXF_data_validated) != 0));
}
m_set_rcvif(m, ifp);
@@ -1051,7 +1052,7 @@
(M_CSUM_TCPv4 | M_CSUM_UDPv4)) != 0) {
rxresp->flags = NETRXF_csum_blank;
} else {
- rxresp->flags = 0;
+ rxresp->flags = NETRXF_data_validated;
}
/*
* transfers the page containing the packet to the
@@ -1360,7 +1361,7 @@
(M_CSUM_TCPv4 | M_CSUM_UDPv4)) != 0) {
rxresp->flags = NETRXF_csum_blank;
} else {
- rxresp->flags = 0;
+ rxresp->flags = NETRXF_data_validated;
}
mbufs_sent[i] = m;
Home |
Main Index |
Thread Index |
Old Index