xref: /dflybsd-src/share/man/man4/vale.4 (revision 92db1a3519a8f1d9fdc18e31b3a02d9a64598a06)
1fb578518SFranco Fichtner.\" Copyright (c) 2012-2013 Luigi Rizzo, Universita` di Pisa
2fb578518SFranco Fichtner.\" All rights reserved.
3fb578518SFranco Fichtner.\"
4fb578518SFranco Fichtner.\" Redistribution and use in source and binary forms, with or without
5fb578518SFranco Fichtner.\" modification, are permitted provided that the following conditions
6fb578518SFranco Fichtner.\" are met:
7fb578518SFranco Fichtner.\" 1. Redistributions of source code must retain the above copyright
8fb578518SFranco Fichtner.\"    notice, this list of conditions and the following disclaimer.
9fb578518SFranco Fichtner.\" 2. Redistributions in binary form must reproduce the above copyright
10fb578518SFranco Fichtner.\"    notice, this list of conditions and the following disclaimer in the
11fb578518SFranco Fichtner.\"    documentation and/or other materials provided with the distribution.
12fb578518SFranco Fichtner.\"
13fb578518SFranco Fichtner.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14fb578518SFranco Fichtner.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15fb578518SFranco Fichtner.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16fb578518SFranco Fichtner.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17fb578518SFranco Fichtner.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18fb578518SFranco Fichtner.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19fb578518SFranco Fichtner.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20fb578518SFranco Fichtner.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21fb578518SFranco Fichtner.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22fb578518SFranco Fichtner.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23fb578518SFranco Fichtner.\" SUCH DAMAGE.
24fb578518SFranco Fichtner.\"
25fb578518SFranco Fichtner.\" This document is derived in part from the enet man page (enet.4)
26fb578518SFranco Fichtner.\" distributed with 4.3BSD Unix.
27fb578518SFranco Fichtner.\"
28fb578518SFranco Fichtner.\" $FreeBSD: head/share/man/man4/vale.4 228017 2011-11-27 06:55:57Z gjb $
29fb578518SFranco Fichtner.\"
307c417b37SFranco Fichtner.Dd December 26, 2013
31fb578518SFranco Fichtner.Dt VALE 4
32fb578518SFranco Fichtner.Os
33fb578518SFranco Fichtner.Sh NAME
34fb578518SFranco Fichtner.Nm vale
35fb578518SFranco Fichtner.Nd a very fast Virtual Local Ethernet using the netmap API
36fb578518SFranco Fichtner.Sh SYNOPSIS
37fb578518SFranco Fichtner.Cd device netmap
38fb578518SFranco Fichtner.Sh DESCRIPTION
39fb578518SFranco Fichtner.Nm
40fb578518SFranco Fichtneris a feature of the
417c417b37SFranco Fichtner.Xr netmap 4
427c417b37SFranco Fichtnermodule that implements multiple virtual switches that can
437c417b37SFranco Fichtnerbe used to interconnect
447c417b37SFranco Fichtner.Xr netmap 4
457c417b37SFranco Fichtnerclients, including traffic sources and sinks, packet forwarders,
467c417b37SFranco Fichtneruserspace firewalls, and so on.
47fb578518SFranco Fichtner.Pp
48fb578518SFranco Fichtner.Nm
49fb578518SFranco Fichtneris implemented completely in software, and is extremely fast.
50fb578518SFranco FichtnerOn a modern machine it can move almost 20 Million packets per
51fb578518SFranco Fichtnersecond (Mpps) per core with small frames, and about 70 Gbit/s
52fb578518SFranco Fichtnerwith 1500 byte frames.
53fb578518SFranco Fichtner.Sh OPERATION
54fb578518SFranco Fichtner.Nm
55fb578518SFranco Fichtnerdynamically creates switches and ports as client connect
56fb578518SFranco Fichtnerto it using the
57fb578518SFranco Fichtner.Xr netmap 4
58fb578518SFranco FichtnerAPI.
59fb578518SFranco Fichtner.Pp
60fb578518SFranco Fichtner.Nm
61fb578518SFranco Fichtnerports are named
62fb578518SFranco Fichtner.Pa vale[bdg:][port]
63fb578518SFranco Fichtnerwhere
64fb578518SFranco Fichtner.Pa vale
65fb578518SFranco Fichtneris the prefix indicating a VALE switch rather than a standard interface,
66fb578518SFranco Fichtner.Pa bdg
67fb578518SFranco Fichtnerindicates a specific switch (the colon is a separator),
68fb578518SFranco Fichtnerand
69fb578518SFranco Fichtner.Pa port
70fb578518SFranco Fichtnerindicates a port within the switch.
71fb578518SFranco FichtnerBridge and ports names are arbitrary strings, the only
72fb578518SFranco Fichtnerconstraint being that the full name must fit within 16
73fb578518SFranco Fichtnercharacters.
74fb578518SFranco Fichtner.Pp
75fb578518SFranco Fichtner.Nm
767c417b37SFranco Fichtnerports can be physical network interfaces that support the
77fb578518SFranco Fichtner.Xr netmap 4
78fb578518SFranco FichtnerAPI
79fb578518SFranco Fichtnerby specifying the interface name for
80fb578518SFranco Fichtner.Pa [port] .
81fb578518SFranco FichtnerSee
82fb578518SFranco Fichtner.Xr netmap 4
83fb578518SFranco Fichtnerfor details of the naming rule.
84fb578518SFranco Fichtner.Pp
857c417b37SFranco FichtnerPhysical interfaces are attached using the
867c417b37SFranco Fichtner.Dv NIOCGREGIF
87fb578518SFranco Fichtnercommand of
887c417b37SFranco Fichtner.Xr ioctl 2 ,
89fb578518SFranco Fichtnerand
907c417b37SFranco Fichtner.Dv NETMAP_BDG_ATTACH
917c417b37SFranco Fichtnerfor the
927c417b37SFranco Fichtner.Va nr_cmd
93fb578518SFranco Fichtnerfield in
947c417b37SFranco Fichtner.Vt struct nmreq .
95fb578518SFranco FichtnerThe corresponding host stack can also be attached to the bridge, specifying
967c417b37SFranco Fichtner.Dv NETMAP_BDG_HOST
97fb578518SFranco Fichtnerin
987c417b37SFranco Fichtner.Va nr_arg1 .
99fb578518SFranco FichtnerTo detach the interface from the bridge,
1007c417b37SFranco Fichtner.Dv NETMAP_BDG_DETACH
1017c417b37SFranco Fichtneris used instead of
1027c417b37SFranco Fichtner.Dv NETMAP_BDG_ATTACH .
103fb578518SFranco FichtnerThe host stack is also detached from the bridge at the same
1047c417b37SFranco Fichtnertime if it had been attached.
105fb578518SFranco Fichtner.Pp
1067c417b37SFranco FichtnerPhysical interfaces are treated as a system configuration;
1077c417b37SFranco Fichtnerthey remain attached even after the configuring process died,
1087c417b37SFranco Fichtnerand can be detached by any other process.
109fb578518SFranco Fichtner.Pp
110fb578518SFranco FichtnerOnce a physical interface is attached, this interface is no longer
1117c417b37SFranco Fichtneravailable to be directly accessed by
1127c417b37SFranco Fichtner.Xr netmap 4
1137c417b37SFranco Fichtnerclients (user processes) or to be attached by another bridge.
1147c417b37SFranco FichtnerOn the other hand, when a
1157c417b37SFranco Fichtner.Xr netmap 4
1167c417b37SFranco Fichtnerclient holds the physical interface,
117fb578518SFranco Fichtnerthis interface cannot be attached to a bridge.
118fb578518SFranco Fichtner.Pp
1197c417b37SFranco Fichtner.Va NETMAP_BDG_LIST
1207c417b37SFranco Fichtnersubcommand in
1217c417b37SFranco Fichtner.Va nr_cmd
1227c417b37SFranco Fichtnerof
1237c417b37SFranco Fichtner.Vt struct nmreq
1247c417b37SFranco Fichtneris used to obtain bridge and port information.
1257c417b37SFranco FichtnerThere are two modes of how this works.
126fb578518SFranco FichtnerIf any
1277c417b37SFranco Fichtner.Va nr_name
128fb578518SFranco Fichtnerstarting from non '\\0' is provided,
1297c417b37SFranco Fichtner.Xr ioctl 2
1307c417b37SFranco Fichtnerreturning indicates the position of the named interface.
1317c417b37SFranco FichtnerThis position is represented by an index of the bridge and the port,
1327c417b37SFranco Fichtnerand put into the
1337c417b37SFranco Fichtner.Va nr_arg1
134fb578518SFranco Fichtnerand
1357c417b37SFranco Fichtner.Va nr_arg2
1367c417b37SFranco Fichtnerfields, respectively.
1377c417b37SFranco FichtnerIf the named interface does not exist,
1387c417b37SFranco Fichtner.Xr ioctl 2
139fb578518SFranco Fichtnerreturns
1407c417b37SFranco Fichtner.Dv EINVAL .
141fb578518SFranco Fichtner.Pp
142fb578518SFranco FichtnerIf
1437c417b37SFranco Fichtner.Va nr_name
144fb578518SFranco Fichtnerstarting from '\\0' is provided,
1457c417b37SFranco Fichtner.Xr ioctl 2
146fb578518SFranco Fichtnerreturning indicates the
147fb578518SFranco Fichtnerfirst existing interface on and after the position specified in
1487c417b37SFranco Fichtner.Va nr_arg1
149fb578518SFranco Fichtnerand
1507c417b37SFranco Fichtner.Va nr_arg2 .
151fb578518SFranco FichtnerIf the caller specified a port index greater than the highest
152fb578518SFranco Fichtnerindex of the ports, it is recognized as port index 0 of the
1537c417b37SFranco Fichtnernext bridge (
1547c417b37SFranco Fichtner.Va nr_arg1
155fb578518SFranco Fichtner+ 1,
1567c417b37SFranco Fichtner.Va nr_arg2
157fb578518SFranco Fichtner= 0).
1587c417b37SFranco Fichtner.Xr ioctl 2
159fb578518SFranco Fichtnerreturns
1607c417b37SFranco Fichtner.Dv EINVAL
161fb578518SFranco Fichtnerif the given position is higher than that of
162fb578518SFranco Fichtnerany existing interface.
163fb578518SFranco FichtnerOn successful return of
1647c417b37SFranco Fichtner.Xr ioctl 2 ,
165fb578518SFranco Fichtnerthe interface name is also stored in
1667c417b37SFranco Fichtner.Va nr_name .
1677c417b37SFranco Fichtner.Dv NETMAP_BDG_LIST
1687c417b37SFranco Fichtneris always used with the
1697c417b37SFranco Fichtner.Dv NIOCGINFO
170fb578518SFranco Fichtnercommand of
1717c417b37SFranco Fichtner.Xr ioctl 2 .
172fb578518SFranco Fichtner.Pp
173fb578518SFranco FichtnerBelow is an example of printing all the existing ports walking through
174fb578518SFranco Fichtnerall the bridges.
1757c417b37SFranco Fichtner.Bd -literal
176fb578518SFranco Fichtnerstruct nmreq nmr;
177fb578518SFranco Fichtnerint fd = open("/dev/netmap", O_RDWR);
178fb578518SFranco Fichtner
179fb578518SFranco Fichtnerbzero(&nmr, sizeof(nmr));
180fb578518SFranco Fichtnernmr.nr_version = NETMAP_API;
181fb578518SFranco Fichtnernmr.nr_cmd = NETMAP_BDG_LIST;
182fb578518SFranco Fichtnernmr.nr_arg1 = nmr.nr_arg2 = 0; /* start from bridge:0 port:0 */
183fb578518SFranco Fichtnerfor (; !ioctl(fd, NIOCGINFO, &nmr); nmr.nr_arg2++) {
184fb578518SFranco Fichtner	D("bridge:%d port:%d %s", nmr.nr_arg1, nmr.nr_arg2,
185fb578518SFranco Fichtner	    nmr.nr_name);
186fb578518SFranco Fichtner	nmr.nr_name[0] = '\\0';
187fb578518SFranco Fichtner}
188fb578518SFranco Fichtner.Ed
189fb578518SFranco Fichtner.Ss LIMITS
190fb578518SFranco Fichtner.Nm
191fb578518SFranco Fichtnercurrently supports up to 8 switches, 254 ports per switch,
1927c417b37SFranco Fichtner1024 buffers per port.
1937c417b37SFranco FichtnerThese hard limits will be changed to
1947c417b37SFranco Fichtner.Xr sysctl 8
1957c417b37SFranco Fichtnervariables in future releases.
196fb578518SFranco Fichtner.Pp
197fb578518SFranco FichtnerAttaching the host stack to the bridge imposes significant performance
1987c417b37SFranco Fichtnerdegradation when many packets are forwarded to the host stack.
1997c417b37SFranco FichtnerThis is because each packet forwarded to the host stack causes
2007c417b37SFranco Fichtner.Xr mbuf 9
2017c417b37SFranco Fichtnerallocation in the same thread context.
202fb578518SFranco Fichtner.Sh SYSCTL VARIABLES
203fb578518SFranco Fichtner.Nm
2047c417b37SFranco Fichtneruses the following
2057c417b37SFranco Fichtner.Xr sysctl 8
2067c417b37SFranco Fichtnervariables to control operation:
2077c417b37SFranco Fichtner.Bl -tag -width "dev.netmap.verbose"
208fb578518SFranco Fichtner.It dev.netmap.bridge
209fb578518SFranco FichtnerThe maximum number of packets processed internally
210fb578518SFranco Fichtnerin each iteration.
211fb578518SFranco FichtnerDefaults to 1024, use lower values to trade latency
212fb578518SFranco Fichtnerwith throughput.
213fb578518SFranco Fichtner.It dev.netmap.verbose
214fb578518SFranco FichtnerSet to non-zero values to enable in-kernel diagnostics.
215fb578518SFranco Fichtner.El
216fb578518SFranco Fichtner.Sh EXAMPLES
217fb578518SFranco FichtnerCreate one switch, with a traffic generator connected to one
2187c417b37SFranco Fichtnerport, and a
2197c417b37SFranco Fichtner.Xr netmap 4 Ns -enabled
2207c417b37SFranco Fichtner.Xr tcpdump 1
2217c417b37SFranco Fichtnerinstance on another port:
222fb578518SFranco Fichtner.Bd -literal -offset indent
223fb578518SFranco Fichtnertcpdump -ni vale-a:1 &
224fb578518SFranco Fichtnerpkt-gen  -i vale-a:0 -f tx &
225fb578518SFranco Fichtner.Ed
226fb578518SFranco Fichtner.Pp
227fb578518SFranco FichtnerCreate two switches,
228fb578518SFranco Fichtnereach connected to two qemu machines on different ports.
229fb578518SFranco Fichtner.Bd -literal -offset indent
230fb578518SFranco Fichtnerqemu -net nic -net netmap,ifname=vale-1:a ... &
231fb578518SFranco Fichtnerqemu -net nic -net netmap,ifname=vale-1:b ... &
232fb578518SFranco Fichtnerqemu -net nic -net netmap,ifname=vale-2:c ... &
233fb578518SFranco Fichtnerqemu -net nic -net netmap,ifname=vale-2:d ... &
234fb578518SFranco Fichtner.Ed
235fb578518SFranco Fichtner.Sh SEE ALSO
236fb578518SFranco Fichtner.Xr netmap 4
2377c417b37SFranco Fichtner.Rs
2387c417b37SFranco Fichtner.%A Luigi Rizzo
2397c417b37SFranco Fichtner.%A Giuseppe Lettieri
2407c417b37SFranco Fichtner.%T VALE, a switched ethernet for virtual machines
241*92db1a35SSascha Wildner.%U http://info.iet.unipi.it/~luigi/vale/
2427c417b37SFranco Fichtner.%D June 2012
2437c417b37SFranco Fichtner.Re
244fb578518SFranco Fichtner.Sh AUTHORS
245fb578518SFranco Fichtner.An -nosplit
246fb578518SFranco FichtnerThe
247fb578518SFranco Fichtner.Nm
248fb578518SFranco Fichtnerswitch has been designed and implemented in 2012 by
249fb578518SFranco Fichtner.An Luigi Rizzo
250fb578518SFranco Fichtnerand
251fb578518SFranco Fichtner.An Giuseppe Lettieri
252fb578518SFranco Fichtnerat the Universita` di Pisa.
253fb578518SFranco Fichtner.Pp
254fb578518SFranco Fichtner.Nm
2557c417b37SFranco Fichtnerhas been funded by the European Commission within the FP7 Projects
256fb578518SFranco FichtnerCHANGE (257422) and OPENLAB (287581).
257