Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/xen/xen pass and use feature-ipv6-csum-offload for ...



details:   https://anonhg.NetBSD.org/src/rev/018746207199
branches:  trunk
changeset: 1008955:018746207199
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Mon Apr 06 19:52:38 2020 +0000

description:
pass and use feature-ipv6-csum-offload for ipv6 csum support, matches
Linux Dom0/DomU

diffstat:

 sys/arch/xen/xen/if_xennet_xenbus.c  |  23 ++++++++++++++++++++---
 sys/arch/xen/xen/xennetback_xenbus.c |  12 ++++++++++--
 2 files changed, 30 insertions(+), 5 deletions(-)

diffs (105 lines):

diff -r bcaaaef04df8 -r 018746207199 sys/arch/xen/xen/if_xennet_xenbus.c
--- a/sys/arch/xen/xen/if_xennet_xenbus.c       Mon Apr 06 19:28:21 2020 +0000
+++ b/sys/arch/xen/xen/if_xennet_xenbus.c       Mon Apr 06 19:52:38 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: if_xennet_xenbus.c,v 1.106 2020/04/06 18:23:21 jdolecek Exp $      */
+/*      $NetBSD: if_xennet_xenbus.c,v 1.107 2020/04/06 19:52:38 jdolecek Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -81,7 +81,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.106 2020/04/06 18:23:21 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.107 2020/04/06 19:52:38 jdolecek Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -207,6 +207,7 @@
 #define BEST_DISCONNECTED      1
 #define BEST_CONNECTED         2
 #define BEST_SUSPENDED         3
+       bool sc_ipv6_csum;      /* whether backend support IPv6 csum offload */
        krndsource_t sc_rnd_source;
 };
 #define SC_NLIVEREQ(sc) ((sc)->sc_rx_ring.req_prod_pvt - \
@@ -268,6 +269,7 @@
        netif_rx_sring_t *rx_ring;
        RING_IDX i;
        char *val, *e, *p;
+       unsigned long uval;
        extern int ifqmaxlen; /* XXX */
 #ifdef XENNET_DEBUG
        char **dir;
@@ -338,7 +340,7 @@
        }
 
        /* read mac address */
-       err = xenbus_read(NULL, xa->xa_xbusd->xbusd_path, "mac", NULL, &val);
+       err = xenbus_read(NULL, sc->sc_xbusd->xbusd_path, "mac", NULL, &val);
        if (err) {
                aprint_error_dev(self, "can't read mac address, err %d\n", err);
                return;
@@ -356,6 +358,12 @@
        free(val, M_DEVBUF);
        aprint_normal_dev(self, "MAC address %s\n",
            ether_sprintf(sc->sc_enaddr));
+
+       /* read ipv6 csum support flag */
+       err = xenbus_read_ul(NULL, sc->sc_xbusd->xbusd_otherend,
+           "feature-ipv6-csum-offload", &uval, 10);
+       sc->sc_ipv6_csum = (!err && uval == 1);
+
        /* Initialize ifnet structure and attach interface */
        strlcpy(ifp->if_xname, device_xname(self), IFNAMSIZ);
        sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU;
@@ -377,6 +385,15 @@
                M_CSUM_TCPv4 | M_CSUM_UDPv4 | M_CSUM_IPv4       \
                | M_CSUM_TCPv6 | M_CSUM_UDPv6                   \
        )
+       if (!sc->sc_ipv6_csum) {
+               /*
+                * If backend doesn't support IPv6 csum offloading, we must
+                * provide valid IPv6 csum for Tx packets, but can still
+                * skip validation for Rx packets.
+                */
+               ifp->if_capabilities &=
+                   ~(IFCAP_CSUM_UDPv6_Tx | IFCAP_CSUM_TCPv6_Tx);
+       }
 
        IFQ_SET_READY(&ifp->if_snd);
        if_attach(ifp);
diff -r bcaaaef04df8 -r 018746207199 sys/arch/xen/xen/xennetback_xenbus.c
--- a/sys/arch/xen/xen/xennetback_xenbus.c      Mon Apr 06 19:28:21 2020 +0000
+++ b/sys/arch/xen/xen/xennetback_xenbus.c      Mon Apr 06 19:52:38 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: xennetback_xenbus.c,v 1.92 2020/04/05 17:26:46 jdolecek Exp $      */
+/*      $NetBSD: xennetback_xenbus.c,v 1.93 2020/04/06 19:52:38 jdolecek Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.92 2020/04/05 17:26:46 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.93 2020/04/06 19:52:38 jdolecek Exp $");
 
 #include "opt_xen.h"
 
@@ -289,6 +289,14 @@
                            xbusd->xbusd_path, err);
                        goto abort_xbt;
                }
+               err = xenbus_printf(xbt, xbusd->xbusd_path,
+                   "feature-ipv6-csum-offload", "%d", 1);
+               if (err) {
+                       aprint_error_ifnet(ifp,
+                           "failed to write %s/feature-ipv6-csum-offload: %d\n",
+                           xbusd->xbusd_path, err);
+                       goto abort_xbt;
+               }
        } while ((err = xenbus_transaction_end(xbt, 0)) == EAGAIN);
        if (err) {
                aprint_error_ifnet(ifp,



Home | Main Index | Thread Index | Old Index