Source-Changes-HG archive

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

[src/netbsd-8]: src/sys Pull up following revision(s) (requested by knakahara...



details:   https://anonhg.NetBSD.org/src/rev/7ebac58766c8
branches:  netbsd-8
changeset: 434663:7ebac58766c8
user:      snj <snj%NetBSD.org@localhost>
date:      Mon Feb 26 00:25:16 2018 +0000

description:
Pull up following revision(s) (requested by knakahara in ticket #567):
        distrib/sets/lists/comp/mi: 1.2182-1.2183
        sys/dev/pci/if_wm.c: 1.564
        sys/dev/pci/ixgbe/ixgbe.c: 1.122
        sys/dev/pci/ixgbe/ixgbe_rss.h: 1.3
        sys/dev/pci/ixgbe/ixv.c: 1.78
        sys/net/Makefile: 1.35-1.36
        sys/net/files.net: 1.15
        sys/net/rss_config.c: 1.1
        sys/net/rss_config.h: 1.1
Introduce very simple Receive Side Scaling (RSS) utility.
ok by msaitoh@n.o.
--
Apply RSS utility to wm(4).
ok by msaitoh@n.o.
--
Apply RSS utility to ixg(4) and ixv(4).
ok by msaitoh@n.o.
--
Fix build failure, sorry.
--
Currently, it is not necessary to install rss_config.h. Pointed out by msaitoh@n.o.

diffstat:

 sys/dev/pci/if_wm.c           |  48 +++-----------------------
 sys/dev/pci/ixgbe/ixgbe.c     |   7 +++-
 sys/dev/pci/ixgbe/ixgbe_rss.h |  21 +++++++++++
 sys/dev/pci/ixgbe/ixv.c       |   7 +++-
 sys/net/files.net             |   3 +-
 sys/net/rss_config.c          |  76 +++++++++++++++++++++++++++++++++++++++++++
 sys/net/rss_config.h          |  36 ++++++++++++++++++++
 7 files changed, 153 insertions(+), 45 deletions(-)

diffs (truncated from 326 to 300 lines):

diff -r 0039fd035df8 -r 7ebac58766c8 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Mon Feb 26 00:19:44 2018 +0000
+++ b/sys/dev/pci/if_wm.c       Mon Feb 26 00:25:16 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.508.4.14 2018/02/26 00:00:53 snj Exp $     */
+/*     $NetBSD: if_wm.c,v 1.508.4.15 2018/02/26 00:25:16 snj Exp $     */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.14 2018/02/26 00:00:53 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.15 2018/02/26 00:25:16 snj Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -116,6 +116,8 @@
 
 #include <net/bpf.h>
 
+#include <net/rss_config.h>
+
 #include <netinet/in.h>                        /* XXX for struct ip */
 #include <netinet/in_systm.h>          /* XXX for struct ip */
 #include <netinet/ip.h>                        /* XXX for struct ip */
@@ -715,7 +717,6 @@
 static void    wm_reset(struct wm_softc *);
 static int     wm_add_rxbuf(struct wm_rxqueue *, int);
 static void    wm_rxdrain(struct wm_rxqueue *);
-static void    wm_rss_getkey(uint8_t *);
 static void    wm_init_rss(struct wm_softc *);
 static void    wm_adjust_qnum(struct wm_softc *, int);
 static inline bool     wm_is_using_msix(struct wm_softc *);
@@ -4838,43 +4839,6 @@
        }
 }
 
-
-/*
- * XXX copy from FreeBSD's sys/net/rss_config.c
- */
-/*
- * RSS secret key, intended to prevent attacks on load-balancing.  Its
- * effectiveness may be limited by algorithm choice and available entropy
- * during the boot.
- *
- * XXXRW: And that we don't randomize it yet!
- *
- * This is the default Microsoft RSS specification key which is also
- * the Chelsio T5 firmware default key.
- */
-#define RSS_KEYSIZE 40
-static uint8_t wm_rss_key[RSS_KEYSIZE] = {
-       0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2,
-       0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0,
-       0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4,
-       0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c,
-       0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa,
-};
-
-/*
- * Caller must pass an array of size sizeof(rss_key).
- *
- * XXX
- * As if_ixgbe may use this function, this function should not be
- * if_wm specific function.
- */
-static void
-wm_rss_getkey(uint8_t *key)
-{
-
-       memcpy(key, wm_rss_key, sizeof(wm_rss_key));
-}
-
 /*
  * Setup registers for RSS.
  *
@@ -4886,7 +4850,7 @@
        uint32_t mrqc, reta_reg, rss_key[RSSRK_NUM_REGS];
        int i;
 
-       CTASSERT(sizeof(rss_key) == sizeof(wm_rss_key));
+       CTASSERT(sizeof(rss_key) == RSS_KEYSIZE);
 
        for (i = 0; i < RETA_NUM_ENTRIES; i++) {
                int qid, reta_ent;
@@ -4912,7 +4876,7 @@
                CSR_WRITE(sc, WMREG_RETA_Q(i), reta_reg);
        }
 
-       wm_rss_getkey((uint8_t *)rss_key);
+       rss_getkey((uint8_t *)rss_key);
        for (i = 0; i < RSSRK_NUM_REGS; i++)
                CSR_WRITE(sc, WMREG_RSSRK(i), rss_key[i]);
 
diff -r 0039fd035df8 -r 7ebac58766c8 sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Mon Feb 26 00:19:44 2018 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Mon Feb 26 00:25:16 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.88.2.8 2018/01/13 21:40:01 snj Exp $ */
+/* $NetBSD: ixgbe.c,v 1.88.2.9 2018/02/26 00:25:16 snj Exp $ */
 
 /******************************************************************************
 
@@ -411,6 +411,10 @@
        int             i, j;
        u32             rss_hash_config;
 
+       /* force use default RSS key. */
+#ifdef __NetBSD__
+       rss_getkey((uint8_t *) &rss_key);
+#else
        if (adapter->feat_en & IXGBE_FEATURE_RSS) {
                /* Fetch the configured RSS key */
                rss_getkey((uint8_t *) &rss_key);
@@ -418,6 +422,7 @@
                /* set up random bits */
                cprng_fast(&rss_key, sizeof(rss_key));
        }
+#endif
 
        /* Set multiplier for RETA setup and table size based on MAC */
        index_mult = 0x1;
diff -r 0039fd035df8 -r 7ebac58766c8 sys/dev/pci/ixgbe/ixgbe_rss.h
--- a/sys/dev/pci/ixgbe/ixgbe_rss.h     Mon Feb 26 00:19:44 2018 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe_rss.h     Mon Feb 26 00:25:16 2018 +0000
@@ -35,6 +35,26 @@
 #ifndef _IXGBE_RSS_H_
 #define _IXGBE_RSS_H_
 
+#ifdef __NetBSD__
+#include <net/rss_config.h>
+
+#define RSS_HASHTYPE_RSS_IPV4          (1 << 1)
+#define RSS_HASHTYPE_RSS_TCP_IPV4      (1 << 2)
+#define RSS_HASHTYPE_RSS_IPV6          (1 << 3)
+#define RSS_HASHTYPE_RSS_TCP_IPV6      (1 << 4)
+#define RSS_HASHTYPE_RSS_IPV6_EX       (1 << 5)
+#define RSS_HASHTYPE_RSS_TCP_IPV6_EX   (1 << 6)
+#define RSS_HASHTYPE_RSS_UDP_IPV4      (1 << 7)
+#define RSS_HASHTYPE_RSS_UDP_IPV6      (1 << 9)
+#define RSS_HASHTYPE_RSS_UDP_IPV6_EX   (1 << 10)
+
+#define rss_getcpu(_a) 0
+#define rss_getnumbuckets() 1
+#define rss_get_indirection_to_bucket(_a) 0
+#define rss_gethashconfig() 0x7E
+#define rss_hash2bucket(_a,_b,_c) -1
+
+#else
 #ifdef RSS
 
 #include <net/rss_config.h>
@@ -60,4 +80,5 @@
 #define rss_hash2bucket(_a,_b,_c) -1
 
 #endif
+#endif /* __NetBSD__ */
 #endif /* _IXGBE_RSS_H_ */
diff -r 0039fd035df8 -r 7ebac58766c8 sys/dev/pci/ixgbe/ixv.c
--- a/sys/dev/pci/ixgbe/ixv.c   Mon Feb 26 00:19:44 2018 +0000
+++ b/sys/dev/pci/ixgbe/ixv.c   Mon Feb 26 00:25:16 2018 +0000
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.56.2.5 2018/01/13 21:40:01 snj Exp $*/
+/*$NetBSD: ixv.c,v 1.56.2.6 2018/02/26 00:25:16 snj Exp $*/
 
 /******************************************************************************
 
@@ -1527,6 +1527,10 @@
        int             i, j;
        u32             rss_hash_config;
 
+       /* force use default RSS key. */
+#ifdef __NetBSD__
+       rss_getkey((uint8_t *) &rss_key);
+#else
        if (adapter->feat_en & IXGBE_FEATURE_RSS) {
                /* Fetch the configured RSS key */
                rss_getkey((uint8_t *)&rss_key);
@@ -1534,6 +1538,7 @@
                /* set up random bits */
                cprng_fast(&rss_key, sizeof(rss_key));
        }
+#endif
 
        /* Now fill out hash function seeds */
        for (i = 0; i < 10; i++)
diff -r 0039fd035df8 -r 7ebac58766c8 sys/net/files.net
--- a/sys/net/files.net Mon Feb 26 00:19:44 2018 +0000
+++ b/sys/net/files.net Mon Feb 26 00:25:16 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.net,v 1.13.6.1 2018/02/11 21:17:34 snj Exp $
+#      $NetBSD: files.net,v 1.13.6.2 2018/02/26 00:25:16 snj Exp $
 
 # XXX CLEANUP
 define net
@@ -48,6 +48,7 @@
 file   net/raw_cb.c                    net
 file   net/raw_usrreq.c                net
 file   net/route.c                     net
+file   net/rss_config.c                net
 file   net/rtbl.c                      net
 file   net/rtsock.c                    net
 file   net/slcompress.c                sl | ppp | strip | (irip & irip_vj)
diff -r 0039fd035df8 -r 7ebac58766c8 sys/net/rss_config.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/net/rss_config.c      Mon Feb 26 00:25:16 2018 +0000
@@ -0,0 +1,76 @@
+/*     $NetBSD: rss_config.c,v 1.1.2.2 2018/02/26 00:25:16 snj Exp $  */
+
+/*
+ * Copyright (c) 2018 Internet Initiative Japan Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: rss_config.c,v 1.1.2.2 2018/02/26 00:25:16 snj Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+
+#include <net/rss_config.h>
+
+/*
+ * Same as FreeBSD.
+ *
+ * This rss key is assumed for verification suite in many intel Gigabit and
+ * 10 Gigabit Controller specifications.
+ */
+static uint8_t rss_default_key[RSS_KEYSIZE] = {
+       0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2,
+       0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0,
+       0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4,
+       0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c,
+       0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa,
+};
+
+#ifdef NOTYET
+/*
+ * Same as DragonFlyBSD.
+ *
+ * This rss key make rss hash value symmetric, that is, the hash value
+ * calculated by func("source address", "destination address") equals to
+ * the hash value calculated by func("destination address", "source address").
+ */
+static uint8_t rss_symmetric_key[RSS_KEYSIZE] = {
+       0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a,
+       0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a,
+       0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a,
+       0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a,
+};
+#endif
+
+/*
+ * sizeof(key) must be more than or equal to RSS_KEYSIZE.
+ */
+void
+rss_getkey(uint8_t *key)
+{
+
+       memcpy(key, rss_default_key, sizeof(rss_default_key));
+}
diff -r 0039fd035df8 -r 7ebac58766c8 sys/net/rss_config.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/net/rss_config.h      Mon Feb 26 00:25:16 2018 +0000
@@ -0,0 +1,36 @@
+/*     $NetBSD: rss_config.h,v 1.1.2.2 2018/02/26 00:25:16 snj Exp $  */
+
+/*
+ * Copyright (c) 2018 Internet Initiative Japan Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright



Home | Main Index | Thread Index | Old Index