From 62f1e1b2bc5cac99525722f70ad160b70087fb5e Mon Sep 17 00:00:00 2001 From: "George V. Neville-Neil" Date: Thu, 14 Nov 2013 19:53:35 +0000 Subject: The FreeBSD Project now has its own, Ogranizationally Unique Identifier, assigned by the IEEE. This file includes documentation on how developers must carve up the space as well as an initial allocation for bhyve. Sponsored by: The FreeBSD Foundation --- sys/net/ieee_oui.h | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 sys/net/ieee_oui.h (limited to 'sys/net') diff --git a/sys/net/ieee_oui.h b/sys/net/ieee_oui.h new file mode 100644 index 000000000000..24a18a7eddde --- /dev/null +++ b/sys/net/ieee_oui.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2013 The FreeBSD Foundation + * 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 AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + * + * Author: George V. Neville-Neil + * + */ + +/* Organizationally Unique Identifier assigned by IEEE 14 Nov 2013 */ +#define OUI_FREEBSD 0x589cfc + +/* + * OUIs are most often used to uniquely identify network interfaces + * and occupy the first 3 bytes of both destination and source MAC + * addresses. The following allocations exist so that various + * software systems associated with FreeBSD can have unique IDs in the + * absence of hardware. The use of OUIs for this purpose is not fully + * fleshed out but is now in common use in virtualization technology. + * + * Allocations from this range are expected to be made using COMMON + * SENSE by developers. Do NOT take a large range just because + * they're currently wide open. Take the smallest useful range for + * your system. We have (2^24 - 2) available addresses (see Reserved + * Values below) but that is far from infinite. + * + * In the event of a conflict arbitration of allocation in this file + * is subject to core@ approval + * + * Applications are differentiated based on the high order bit(s) of + * the remaining three bytes. Our first allocation has all 0s, the + * next allocation has the highest bit set. Allocating in this way + * gives us 254 allocations of 64K addresses. Address blocks can be + * concatenated if necessary. + * + * Reserved Values: 0x000000 and 0xffffff are reserved and MUST NOT BE + * allocated for any reason. + */ + +/* Allocate 64K to bhyve */ +#define OUI_FREEBSD_BHYVE_LOW OUI_FREEBSD + 0x000001 +#define OUI_FREEBSD_BHYVE_HIGH OUI_FREEBSD + 0x00ffff -- cgit v1.2.3 From 868eef3239d6e9a6fc95cc0bc4410c0dddabdf22 Mon Sep 17 00:00:00 2001 From: "George V. Neville-Neil" Date: Thu, 14 Nov 2013 20:07:17 +0000 Subject: Shift our OUI correctly. Pointed out by: emaste --- sys/net/ieee_oui.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sys/net') diff --git a/sys/net/ieee_oui.h b/sys/net/ieee_oui.h index 24a18a7eddde..70f7f1ce69a3 100644 --- a/sys/net/ieee_oui.h +++ b/sys/net/ieee_oui.h @@ -62,5 +62,5 @@ */ /* Allocate 64K to bhyve */ -#define OUI_FREEBSD_BHYVE_LOW OUI_FREEBSD + 0x000001 -#define OUI_FREEBSD_BHYVE_HIGH OUI_FREEBSD + 0x00ffff +#define OUI_FREEBSD_BHYVE_LOW ((OUI_FREEBSD << 3) + 0x000001) +#define OUI_FREEBSD_BHYVE_HIGH ((OUI_FREEBSD << 3) + 0x00ffff) -- cgit v1.2.3 From d4aff8d11ebfcf8cc4ad85088456b9479c5dcc4c Mon Sep 17 00:00:00 2001 From: "George V. Neville-Neil" Date: Thu, 14 Nov 2013 21:57:37 +0000 Subject: Put in the correct bit shifting and add a type to prevent clang from complaining. While here fix up a grammar nit. Pointed out by: Sergey Kandaurov and bz@ respectively. --- sys/net/ieee_oui.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sys/net') diff --git a/sys/net/ieee_oui.h b/sys/net/ieee_oui.h index 70f7f1ce69a3..0898f8a6207a 100644 --- a/sys/net/ieee_oui.h +++ b/sys/net/ieee_oui.h @@ -49,7 +49,7 @@ * Values below) but that is far from infinite. * * In the event of a conflict arbitration of allocation in this file - * is subject to core@ approval + * is subject to core@ approval. * * Applications are differentiated based on the high order bit(s) of * the remaining three bytes. Our first allocation has all 0s, the @@ -62,5 +62,5 @@ */ /* Allocate 64K to bhyve */ -#define OUI_FREEBSD_BHYVE_LOW ((OUI_FREEBSD << 3) + 0x000001) -#define OUI_FREEBSD_BHYVE_HIGH ((OUI_FREEBSD << 3) + 0x00ffff) +#define OUI_FREEBSD_BHYVE_LOW (((uint64_t)OUI_FREEBSD << 24) | 0x000001) +#define OUI_FREEBSD_BHYVE_HIGH (((uint64_t)OUI_FREEBSD << 24) | 0x00ffff) -- cgit v1.2.3 From c72a5d5d89612e51d805a79cf6a5e480f0f92d0c Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Fri, 15 Nov 2013 12:12:50 +0000 Subject: ANSIfy function defintions. --- sys/net/if_gif.c | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) (limited to 'sys/net') diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index 10ff5dfa8d42..6cf04373a4d8 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -153,10 +153,7 @@ static const u_char etherbroadcastaddr[ETHER_ADDR_LEN] = #endif static int -gif_clone_create(ifc, unit, params) - struct if_clone *ifc; - int unit; - caddr_t params; +gif_clone_create(struct if_clone *ifc, int unit, caddr_t params) { struct gif_softc *sc; @@ -200,8 +197,7 @@ gif_clone_create(ifc, unit, params) } static void -gif_clone_destroy(ifp) - struct ifnet *ifp; +gif_clone_destroy(struct ifnet *ifp) { #if defined(INET) || defined(INET6) int err; @@ -247,10 +243,7 @@ VNET_SYSINIT(vnet_gif_init, SI_SUB_PSEUDO, SI_ORDER_MIDDLE, vnet_gif_init, NULL); static int -gifmodevent(mod, type, data) - module_t mod; - int type; - void *data; +gifmodevent(module_t mod, int type, void *data) { switch (type) { @@ -280,11 +273,7 @@ DECLARE_MODULE(if_gif, gif_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); MODULE_VERSION(if_gif, 1); int -gif_encapcheck(m, off, proto, arg) - const struct mbuf *m; - int off; - int proto; - void *arg; +gif_encapcheck(const struct mbuf *m, int off, int proto, void *arg) { struct ip ip; struct gif_softc *sc; @@ -529,10 +518,7 @@ gif_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, } void -gif_input(m, af, ifp) - struct mbuf *m; - int af; - struct ifnet *ifp; +gif_input(struct mbuf *m, int af, struct ifnet *ifp) { int isr, n; struct gif_softc *sc; @@ -669,10 +655,7 @@ gif_input(m, af, ifp) /* XXX how should we handle IPv6 scope on SIOC[GS]IFPHYADDR? */ int -gif_ioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - caddr_t data; +gif_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { struct gif_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq*)data; @@ -914,10 +897,7 @@ gif_ioctl(ifp, cmd, data) * a mutex. */ int -gif_set_tunnel(ifp, src, dst) - struct ifnet *ifp; - struct sockaddr *src; - struct sockaddr *dst; +gif_set_tunnel(struct ifnet *ifp, struct sockaddr *src, struct sockaddr *dst) { struct gif_softc *sc = ifp->if_softc; struct gif_softc *sc2; @@ -1023,8 +1003,7 @@ gif_set_tunnel(ifp, src, dst) } void -gif_delete_tunnel(ifp) - struct ifnet *ifp; +gif_delete_tunnel(struct ifnet *ifp) { struct gif_softc *sc = ifp->if_softc; -- cgit v1.2.3 From 1350c361f66c46ca2b5d965dd6605f52ec573b37 Mon Sep 17 00:00:00 2001 From: "George V. Neville-Neil" Date: Fri, 15 Nov 2013 16:03:32 +0000 Subject: Clean up the macros to avoid using casts. Suggested by: bde and jhb --- sys/net/ieee_oui.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sys/net') diff --git a/sys/net/ieee_oui.h b/sys/net/ieee_oui.h index 0898f8a6207a..3fcb96b597a1 100644 --- a/sys/net/ieee_oui.h +++ b/sys/net/ieee_oui.h @@ -32,7 +32,8 @@ */ /* Organizationally Unique Identifier assigned by IEEE 14 Nov 2013 */ -#define OUI_FREEBSD 0x589cfc +#define OUI_FREEBSD_BASE 0x589cfc000000 +#define OUI_FREEBSD(nic) (OUI_FREEBSD_BASE | (nic)) /* * OUIs are most often used to uniquely identify network interfaces @@ -62,5 +63,5 @@ */ /* Allocate 64K to bhyve */ -#define OUI_FREEBSD_BHYVE_LOW (((uint64_t)OUI_FREEBSD << 24) | 0x000001) -#define OUI_FREEBSD_BHYVE_HIGH (((uint64_t)OUI_FREEBSD << 24) | 0x00ffff) +#define OUI_FREEBSD_BHYVE_LOW OUI_FREEBSD(0x000001) +#define OUI_FREEBSD_BHYVE_HIGH OUI_FREEBSD(0x00ffff) -- cgit v1.2.3 From 4857f5fbbc95def5402ca6176dc605cf9e698519 Mon Sep 17 00:00:00 2001 From: "George V. Neville-Neil" Date: Mon, 18 Nov 2013 22:58:14 +0000 Subject: Allow ethernet drivers to pass in packets connected via the nextpkt pointer. Handling packets in this way allows drivers to amortize work during packet reception. Submitted by: Vijay Singh Sponsored by: NetApp --- sys/net/if_ethersubr.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'sys/net') diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index c4a9125c9f45..04b94defc956 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -708,13 +708,25 @@ static void ether_input(struct ifnet *ifp, struct mbuf *m) { + struct mbuf *mn; + /* - * We will rely on rcvif being set properly in the deferred context, - * so assert it is correct here. + * The drivers are allowed to pass in a chain of packets linked with + * m_nextpkt. We split them up into separate packets here and pass + * them up. This allows the drivers to amortize the receive lock. */ - KASSERT(m->m_pkthdr.rcvif == ifp, ("%s: ifnet mismatch", __func__)); + while (m) { + mn = m->m_nextpkt; + m->m_nextpkt = NULL; - netisr_dispatch(NETISR_ETHER, m); + /* + * We will rely on rcvif being set properly in the deferred context, + * so assert it is correct here. + */ + KASSERT(m->m_pkthdr.rcvif == ifp, ("%s: ifnet mismatch", __func__)); + netisr_dispatch(NETISR_ETHER, m); + m = mn; + } } /* -- cgit v1.2.3