Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci initial port rss_getkey() from freebsd, and use ...
details: https://anonhg.NetBSD.org/src/rev/8d68c2b3c87b
branches: trunk
changeset: 341157:8d68c2b3c87b
user: knakahara <knakahara%NetBSD.org@localhost>
date: Thu Oct 22 06:01:41 2015 +0000
description:
initial port rss_getkey() from freebsd, and use it instead of random().
diffstat:
sys/dev/pci/if_wm.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 42 insertions(+), 4 deletions(-)
diffs (89 lines):
diff -r 0d8b088f32b6 -r 8d68c2b3c87b sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c Thu Oct 22 00:29:58 2015 +0000
+++ b/sys/dev/pci/if_wm.c Thu Oct 22 06:01:41 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wm.c,v 1.371 2015/10/14 07:16:04 msaitoh Exp $ */
+/* $NetBSD: if_wm.c,v 1.372 2015/10/22 06:01:41 knakahara 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.371 2015/10/14 07:16:04 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.372 2015/10/22 06:01:41 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@@ -565,6 +565,7 @@
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 *);
#ifdef WM_MSI_MSIX
static void wm_adjust_qnum(struct wm_softc *, int);
@@ -4047,6 +4048,42 @@
}
}
+
+/*
+ * 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.
*
@@ -4055,7 +4092,7 @@
static void
wm_init_rss(struct wm_softc *sc)
{
- uint32_t mrqc, reta_reg;
+ uint32_t mrqc, reta_reg, rss_key[RSSRK_NUM_REGS];
int i;
for (i = 0; i < RETA_NUM_ENTRIES; i++) {
@@ -4082,8 +4119,9 @@
CSR_WRITE(sc, WMREG_RETA_Q(i), reta_reg);
}
+ wm_rss_getkey((uint8_t *)rss_key);
for (i = 0; i < RSSRK_NUM_REGS; i++)
- CSR_WRITE(sc, WMREG_RSSRK(i), (uint32_t)random());
+ CSR_WRITE(sc, WMREG_RSSRK(i), rss_key[i]);
if (sc->sc_type == WM_T_82574)
mrqc = MRQC_ENABLE_RSS_MQ_82574;
Home |
Main Index |
Thread Index |
Old Index