Xen netback driver rewrite.

share/man/man4/Makefile,
share/man/man4/xnb.4,
sys/dev/xen/netback/netback.c,
sys/dev/xen/netback/netback_unit_tests.c:

	Rewrote the netback driver for xen to attach properly via newbus
	and work properly in both HVM and PVM mode (only HVM is tested).
	Works with the in-tree FreeBSD netfront driver or the Windows
	netfront driver from SuSE.  Has not been extensively tested with
	a Linux netfront driver.  Does not implement LRO, TSO, or
	polling.  Includes unit tests that may be run through sysctl
	after compiling with XNB_DEBUG defined.

sys/dev/xen/blkback/blkback.c,
sys/xen/interface/io/netif.h:

	Comment elaboration.

sys/kern/uipc_mbuf.c:

	Fix page fault in kernel mode when calling m_print() on a
	null mbuf.  Since m_print() is only used for debugging, there
	are no performance concerns for extra error checking code.

sys/kern/subr_scanf.c:

	Add the "hh" and "ll" width specifiers from C99 to scanf().
	A few callers were already using "ll" even though scanf()
	was handling it as "l".

Submitted by:	Alan Somers <alans@spectralogic.com>
Submitted by:	John Suykerbuyk <johns@spectralogic.com>
Sponsored by:	Spectra Logic
MFC after:	1 week
Reviewed by:	ken
This commit is contained in:
Kenneth D. Merry 2012-01-26 16:35:09 +00:00
parent c0e199f61b
commit 7e949c467c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=230587
8 changed files with 5087 additions and 1455 deletions

View File

@ -531,6 +531,7 @@ MAN= aac.4 \
${_xen.4} \
xhci.4 \
xl.4 \
${_xnb.4} \
xpt.4 \
zero.4 \
zyd.4
@ -731,6 +732,7 @@ _urtw.4= urtw.4
_viawd.4= viawd.4
_wpi.4= wpi.4
_xen.4= xen.4
_xnb.4= xnb.4
MLINKS+=lindev.4 full.4
.endif

134
share/man/man4/xnb.4 Normal file
View File

@ -0,0 +1,134 @@
.\" Copyright (c) 2012 Spectra Logic Corporation
.\" 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,
.\" without modification.
.\" 2. Redistributions in binary form must reproduce at minimum a disclaimer
.\" substantially similar to the "NO WARRANTY" disclaimer below
.\" ("Disclaimer") and any redistribution must be conditioned upon
.\" including a substantially similar Disclaimer requirement for further
.\" binary redistribution.
.\"
.\" NO WARRANTY
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
.\" HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
.\"
.\" Authors: Alan Somers (Spectra Logic Corporation)
.\"
.\" $FreeBSD$
.\"
.Dd January 6, 2012
.Dt XNB 4
.Os
.Sh NAME
.Nm xnb
.Nd "Xen Paravirtualized Backend Ethernet Driver"
.Sh SYNOPSIS
To compile this driver into the kernel, place the following lines in your
kernel configuration file:
.Bd -ragged -offset indent
.Cd "options XENHVM"
.Cd "device xenpci"
.Ed
.Sh DESCRIPTION
The
.Nm
driver provides the back half of a paravirtualized
.Xr xen 4
network connection. The netback and netfront drivers appear to their
respective operating systems as Ethernet devices linked by a crossover cable.
Typically,
.Nm
will run on Domain 0 and the netfront driver will run on a guest domain.
However, it is also possible to run
.Nm
on a guest domain. It may be bridged or routed to provide the netfront's
domain access to other guest domains or to a physical network.
.Pp
In most respects, the
.Nm
device appears to the OS as an other Ethernet device. It can be configured at
runtime entirely with
.Xr ifconfig 8
\&. In particular, it supports MAC changing, arbitrary MTU sizes, checksum
offload for IP, UDP, and TCP for both receive and transmit, and TSO. However,
see
.Sx CAVEATS
before enabling txcsum, rxcsum, or tso.
.Sh SYSCTL VARIABLES
The following read-only variables are available via
.Xr sysctl 8 :
.Bl -tag -width indent
.It Va dev.xnb.%d.dump_rings
Displays information about the ring buffers used to pass requests between the
netfront and netback. Mostly useful for debugging, but can also be used to
get traffic statistics.
.It Va dev.xnb.%d.unit_test_results
Runs a builtin suite of unit tests and displays the results. Does not affect
the operation of the driver in any way. Note that the test suite simulates
error conditions; this will result in error messages being printed to the
system system log.
.Sh CAVEATS
Packets sent through Xennet pass over shared memory, so the protocol includes
no form of link-layer checksum or CRC. Furthermore, Xennet drivers always
report to their hosts that they support receive and transmit checksum
offloading. They "offload" the checksum calculation by simply skipping it.
That works fine for packets that are exchanged between two domains on the same
machine. However, when a Xennet interface is bridged to a physical interface,
a correct checksum must be attached to any packets bound for that physical
interface. Currently, FreeBSD lacks any mechanism for an ethernet device to
inform the OS that newly received packets are valid even though their checksums
are not. So if the netfront driver is configured to offload checksum
calculations, it will pass non-checksumed packets to
.Nm
, which must then calculate the checksum in software before passing the packet
to the OS.
.Pp
For this reason, it is recommended that if
.Nm
is bridged to a physcal interface, then transmit checksum offloading should be
disabled on the netfront. The Xennet protocol does not have any mechanism for
the netback to request the netfront to do this; the operator must do it
manually.
.Sh SEE ALSO
.Xr arp 4 ,
.Xr netintro 4 ,
.Xr ng_ether 4 ,
.Xr ifconfig 8 ,
.Xr xen 4
.Sh HISTORY
The
.Nm
device driver first appeared in
.Fx 10.0
.
.Sh AUTHORS
The
.Nm
driver was written by
.An Alan Somers
.Aq alans@spectralogic.com
and
.An John Suykerbuyk
.Aq johns@spectralogic.com
.Sh BUGS
The
.Nm
driver does not properly checksum UDP datagrams that span more than one
Ethernet frame. Nor does it correctly checksum IPv6 packets. To workaround
that bug, disable transmit checksum offloading on the netfront driver.

View File

@ -3434,6 +3434,10 @@ xbb_shutdown(struct xbb_softc *xbb)
DPRINTF("\n");
/*
* Before unlocking mutex, set this flag to prevent other threads from
* getting into this function
*/
xbb->flags |= XBBF_IN_SHUTDOWN;
mtx_unlock(&xbb->lock);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#define POINTER 0x10 /* weird %p pointer (`fake hex') */
#define NOSKIP 0x20 /* do not skip blanks */
#define QUAD 0x400
#define SHORTSHORT 0x4000 /** hh: char */
/*
* The following are used in numeric conversions only:
@ -160,13 +161,23 @@ again: c = *fmt++;
flags |= SUPPRESS;
goto again;
case 'l':
flags |= LONG;
if (flags & LONG){
flags &= ~LONG;
flags |= QUAD;
} else {
flags |= LONG;
}
goto again;
case 'q':
flags |= QUAD;
goto again;
case 'h':
flags |= SHORT;
if (flags & SHORT){
flags &= ~SHORT;
flags |= SHORTSHORT;
} else {
flags |= SHORT;
}
goto again;
case '0': case '1': case '2': case '3': case '4':
@ -235,7 +246,9 @@ again: c = *fmt++;
nconversions++;
if (flags & SUPPRESS) /* ??? */
continue;
if (flags & SHORT)
if (flags & SHORTSHORT)
*va_arg(ap, char *) = nread;
else if (flags & SHORT)
*va_arg(ap, short *) = nread;
else if (flags & LONG)
*va_arg(ap, long *) = nread;
@ -510,6 +523,8 @@ again: c = *fmt++;
if (flags & POINTER)
*va_arg(ap, void **) =
(void *)(uintptr_t)res;
else if (flags & SHORTSHORT)
*va_arg(ap, char *) = res;
else if (flags & SHORT)
*va_arg(ap, short *) = res;
else if (flags & LONG)

View File

@ -1410,6 +1410,11 @@ m_print(const struct mbuf *m, int maxlen)
int pdata;
const struct mbuf *m2;
if (m == NULL) {
printf("mbuf: %p\n", m);
return;
}
if (m->m_flags & M_PKTHDR)
len = m->m_pkthdr.len;
else

View File

@ -42,7 +42,7 @@
* This is the 'wire' format for packets:
* Request 1: netif_tx_request -- NETTXF_* (any flags)
* [Request 2: netif_tx_extra] (only if request 1 has NETTXF_extra_info)
* [Request 3: netif_tx_extra] (only if request 2 has XEN_NETIF_EXTRA_MORE)
* [Request 3: netif_tx_extra] (only if request 2 has XEN_NETIF_EXTRA_FLAG_MORE)
* Request 4: netif_tx_request -- NETTXF_more_data
* Request 5: netif_tx_request -- NETTXF_more_data
* ...
@ -70,7 +70,9 @@ struct netif_tx_request {
uint16_t offset; /* Offset within buffer page */
uint16_t flags; /* NETTXF_* */
uint16_t id; /* Echoed in response message. */
uint16_t size; /* Packet size in bytes. */
uint16_t size; /* For the first request in a packet, the packet
size in bytes. For subsequent requests, the
size of that request's associated data in bytes*/
};
typedef struct netif_tx_request netif_tx_request_t;
@ -175,7 +177,7 @@ struct netif_rx_response {
uint16_t id;
uint16_t offset; /* Offset in page of start of received packet */
uint16_t flags; /* NETRXF_* */
int16_t status; /* -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */
int16_t status; /* -ve: NETIF_RSP_* ; +ve: Rx'ed response size. */
};
typedef struct netif_rx_response netif_rx_response_t;