Introduce very simple Receive Side Scaling (RSS) utility.

ok by msaitoh@n.o.
This commit is contained in:
knakahara 2018-02-16 04:48:32 +00:00
parent 18fbadf9f8
commit 4a6a088a32
4 changed files with 116 additions and 3 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.34 2018/01/10 10:56:30 knakahara Exp $
# $NetBSD: Makefile,v 1.35 2018/02/16 04:48:32 knakahara Exp $
INCSDIR= /usr/include/net
@ -8,7 +8,7 @@ INCS= bpf.h bpfjit.h bpfdesc.h dlt.h ethertypes.h if.h if_arc.h if_arp.h \
if_pflog.h if_ppp.h if_pppoe.h if_l2tp.h if_sppp.h if_srt.h if_stf.h \
if_tap.h if_token.h if_tun.h if_types.h if_vlanvar.h net_stats.h \
netisr.h pfil.h pfkeyv2.h pfvar.h ppp-comp.h ppp_defs.h radix.h \
raw_cb.h route.h slcompress.h slip.h zlib.h
raw_cb.h route.h rss_config.h slcompress.h slip.h zlib.h
SUBDIR= agr npf

View File

@ -1,4 +1,4 @@
# $NetBSD: files.net,v 1.14 2018/01/10 10:56:30 knakahara Exp $
# $NetBSD: files.net,v 1.15 2018/02/16 04:48:32 knakahara Exp $
# XXX CLEANUP
define net
@ -48,6 +48,7 @@ file net/radix.c net
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)

76
sys/net/rss_config.c Normal file
View File

@ -0,0 +1,76 @@
/* $NetBSD: rss_config.c,v 1.1 2018/02/16 04:48:32 knakahara 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 2018/02/16 04:48:32 knakahara 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));
}

36
sys/net/rss_config.h Normal file
View File

@ -0,0 +1,36 @@
/* $NetBSD: rss_config.h,v 1.1 2018/02/16 04:48:32 knakahara 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.
*/
#ifndef _NET_RSS_CONFIG_H_
#define _NET_RSS_CONFIG_H_
#define RSS_KEYSIZE 40
void rss_getkey(uint8_t *);
#endif /* _NET_RSS_CONFIG_H_ */