xref: /freebsd/sys/net/netmap.h (revision 01c039a19c27a65428e8217f6b1ceae179fca276)
168b8534bSLuigi Rizzo /*
268b8534bSLuigi Rizzo  * Copyright (C) 2011 Matteo Landi, Luigi Rizzo. All rights reserved.
368b8534bSLuigi Rizzo  *
468b8534bSLuigi Rizzo  * Redistribution and use in source and binary forms, with or without
568b8534bSLuigi Rizzo  * modification, are permitted provided that the following conditions are
668b8534bSLuigi Rizzo  * met:
768b8534bSLuigi Rizzo  *
868b8534bSLuigi Rizzo  *   1. Redistributions of source code must retain the above copyright
968b8534bSLuigi Rizzo  *      notice, this list of conditions and the following disclaimer.
1068b8534bSLuigi Rizzo  *
1168b8534bSLuigi Rizzo  *   2. Redistributions in binary form must reproduce the above copyright
1268b8534bSLuigi Rizzo  *      notice, this list of conditions and the following disclaimer in the
1368b8534bSLuigi Rizzo  *      documentation and/or other materials provided with the
1468b8534bSLuigi Rizzo  *      distribution.
1568b8534bSLuigi Rizzo  *
1668b8534bSLuigi Rizzo  *   3. Neither the name of the authors nor the names of their contributors
1768b8534bSLuigi Rizzo  *      may be used to endorse or promote products derived from this
1868b8534bSLuigi Rizzo  *      software without specific prior written permission.
1968b8534bSLuigi Rizzo  *
2068b8534bSLuigi Rizzo  * THIS SOFTWARE IS PROVIDED BY MATTEO LANDI AND CONTRIBUTORS "AS IS" AND
2168b8534bSLuigi Rizzo  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2268b8534bSLuigi Rizzo  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2368b8534bSLuigi Rizzo  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTEO LANDI OR CONTRIBUTORS
2468b8534bSLuigi Rizzo  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2568b8534bSLuigi Rizzo  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2668b8534bSLuigi Rizzo  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2768b8534bSLuigi Rizzo  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2868b8534bSLuigi Rizzo  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2968b8534bSLuigi Rizzo  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
3068b8534bSLuigi Rizzo  * THE POSSIBILITY OF SUCH DAMAGE.
3168b8534bSLuigi Rizzo  */
3268b8534bSLuigi Rizzo 
3368b8534bSLuigi Rizzo /*
3468b8534bSLuigi Rizzo  * $FreeBSD$
35*01c039a1SLuigi Rizzo  * $Id: netmap.h 11997 2013-01-17 21:59:12Z luigi $
3668b8534bSLuigi Rizzo  *
3764ae02c3SLuigi Rizzo  * Definitions of constants and the structures used by the netmap
3864ae02c3SLuigi Rizzo  * framework, for the part visible to both kernel and userspace.
3964ae02c3SLuigi Rizzo  * Detailed info on netmap is available with "man netmap" or at
4064ae02c3SLuigi Rizzo  *
4164ae02c3SLuigi Rizzo  *	http://info.iet.unipi.it/~luigi/netmap/
4268b8534bSLuigi Rizzo  */
4368b8534bSLuigi Rizzo 
4468b8534bSLuigi Rizzo #ifndef _NET_NETMAP_H_
4568b8534bSLuigi Rizzo #define _NET_NETMAP_H_
4668b8534bSLuigi Rizzo 
4768b8534bSLuigi Rizzo /*
4868b8534bSLuigi Rizzo  * --- Netmap data structures ---
4968b8534bSLuigi Rizzo  *
5068b8534bSLuigi Rizzo  * The data structures used by netmap are shown below. Those in
5168b8534bSLuigi Rizzo  * capital letters are in an mmapp()ed area shared with userspace,
5268b8534bSLuigi Rizzo  * while others are private to the kernel.
5364ae02c3SLuigi Rizzo  * Shared structures do not contain pointers but only memory
5468b8534bSLuigi Rizzo  * offsets, so that addressing is portable between kernel and userspace.
5568b8534bSLuigi Rizzo 
5668b8534bSLuigi Rizzo 
5768b8534bSLuigi Rizzo  softc
5868b8534bSLuigi Rizzo +----------------+
5968b8534bSLuigi Rizzo | standard fields|
6068b8534bSLuigi Rizzo | if_pspare[0] ----------+
6168b8534bSLuigi Rizzo +----------------+       |
6268b8534bSLuigi Rizzo                          |
6368b8534bSLuigi Rizzo +----------------+<------+
6468b8534bSLuigi Rizzo |(netmap_adapter)|
6568b8534bSLuigi Rizzo |                |                             netmap_kring
6664ae02c3SLuigi Rizzo | tx_rings *--------------------------------->+---------------+
6764ae02c3SLuigi Rizzo |                |       netmap_kring         | ring    *---------.
6864ae02c3SLuigi Rizzo | rx_rings *--------->+---------------+       | nr_hwcur      |   |
6964ae02c3SLuigi Rizzo +----------------+    | ring    *--------.    | nr_hwavail    |   V
7064ae02c3SLuigi Rizzo                       | nr_hwcur      |  |    | selinfo       |   |
7164ae02c3SLuigi Rizzo                       | nr_hwavail    |  |    +---------------+   .
7264ae02c3SLuigi Rizzo                       | selinfo       |  |    |     ...       |   .
7364ae02c3SLuigi Rizzo                       +---------------+  |    |(ntx+1 entries)|
7468b8534bSLuigi Rizzo                       |    ....       |  |    |               |
7564ae02c3SLuigi Rizzo                       |(nrx+1 entries)|  |    +---------------+
7668b8534bSLuigi Rizzo                       |               |  |
7764ae02c3SLuigi Rizzo    KERNEL             +---------------+  |
7864ae02c3SLuigi Rizzo                                          |
7964ae02c3SLuigi Rizzo   ====================================================================
8064ae02c3SLuigi Rizzo                                          |
8164ae02c3SLuigi Rizzo    USERSPACE                             |      NETMAP_RING
8268b8534bSLuigi Rizzo                                          +---->+-------------+
8368b8534bSLuigi Rizzo                                              / | cur         |
8468b8534bSLuigi Rizzo    NETMAP_IF  (nifp, one per file desc.)    /  | avail       |
8568b8534bSLuigi Rizzo     +---------------+                      /   | buf_ofs     |
86d76bf4ffSLuigi Rizzo     | ni_tx_rings   |                     /    +=============+
87d76bf4ffSLuigi Rizzo     | ni_rx_rings   |                    /     | buf_idx     | slot[0]
8868b8534bSLuigi Rizzo     |               |                   /      | len, flags  |
8968b8534bSLuigi Rizzo     |               |                  /       +-------------+
9068b8534bSLuigi Rizzo     +===============+                 /        | buf_idx     | slot[1]
9168b8534bSLuigi Rizzo     | txring_ofs[0] | (rel.to nifp)--'         | len, flags  |
9268b8534bSLuigi Rizzo     | txring_ofs[1] |                          +-------------+
9368b8534bSLuigi Rizzo   (num_rings+1 entries)                     (nr_num_slots entries)
9468b8534bSLuigi Rizzo     | txring_ofs[n] |                          | buf_idx     | slot[n-1]
9568b8534bSLuigi Rizzo     +---------------+                          | len, flags  |
9668b8534bSLuigi Rizzo     | rxring_ofs[0] |                          +-------------+
9768b8534bSLuigi Rizzo     | rxring_ofs[1] |
9868b8534bSLuigi Rizzo   (num_rings+1 entries)
9968b8534bSLuigi Rizzo     | txring_ofs[n] |
10068b8534bSLuigi Rizzo     +---------------+
10168b8534bSLuigi Rizzo 
10264ae02c3SLuigi Rizzo  * The private descriptor ('softc' or 'adapter') of each interface
10364ae02c3SLuigi Rizzo  * is extended with a "struct netmap_adapter" containing netmap-related
10464ae02c3SLuigi Rizzo  * info (see description in dev/netmap/netmap_kernel.h.
10564ae02c3SLuigi Rizzo  * Among other things, tx_rings and rx_rings point to the arrays of
10664ae02c3SLuigi Rizzo  * "struct netmap_kring" which in turn reache the various
10764ae02c3SLuigi Rizzo  * "struct netmap_ring", shared with userspace.
10864ae02c3SLuigi Rizzo 
10964ae02c3SLuigi Rizzo  * The NETMAP_RING is the userspace-visible replica of the NIC ring.
11068b8534bSLuigi Rizzo  * Each slot has the index of a buffer, its length and some flags.
11168b8534bSLuigi Rizzo  * In user space, the buffer address is computed as
11264ae02c3SLuigi Rizzo  *	(char *)ring + buf_ofs + index*NETMAP_BUF_SIZE
11368b8534bSLuigi Rizzo  * In the kernel, buffers do not necessarily need to be contiguous,
11468b8534bSLuigi Rizzo  * and the virtual and physical addresses are derived through
11564ae02c3SLuigi Rizzo  * a lookup table.
11668b8534bSLuigi Rizzo  *
117*01c039a1SLuigi Rizzo  * struct netmap_slot:
118*01c039a1SLuigi Rizzo  *
119*01c039a1SLuigi Rizzo  * buf_idx	is the index of the buffer associated to the slot.
120*01c039a1SLuigi Rizzo  * len		is the length of the payload
121*01c039a1SLuigi Rizzo  * NS_BUF_CHANGED	must be set whenever userspace wants
122*01c039a1SLuigi Rizzo  *		to change buf_idx (it might be necessary to
123*01c039a1SLuigi Rizzo  *		reprogram the NIC slot)
124*01c039a1SLuigi Rizzo  * NS_REPORT	must be set if we want the NIC to generate an interrupt
125*01c039a1SLuigi Rizzo  *		when this slot is used. Leaving it to 0 improves
126*01c039a1SLuigi Rizzo  *		performance.
127*01c039a1SLuigi Rizzo  * NS_FORWARD	if set on a receive ring, and the device is in
128*01c039a1SLuigi Rizzo  *		transparent mode, buffers released with the flag set
129*01c039a1SLuigi Rizzo  *		will be forwarded to the 'other' side (host stack
130*01c039a1SLuigi Rizzo  *		or NIC, respectively) on the next select() or ioctl()
131*01c039a1SLuigi Rizzo  * NS_NO_LEARN	on a VALE switch, do not 'learn' the source port for
132*01c039a1SLuigi Rizzo  *		this packet.
133*01c039a1SLuigi Rizzo  * NS_PORT_MASK	the high 8 bits of the flag, if not zero, indicate the
134*01c039a1SLuigi Rizzo  *		destination port for the VALE switch, overriding
135*01c039a1SLuigi Rizzo  *		the lookup table.
13668b8534bSLuigi Rizzo  */
137*01c039a1SLuigi Rizzo 
13868b8534bSLuigi Rizzo struct netmap_slot {
13968b8534bSLuigi Rizzo 	uint32_t buf_idx; /* buffer index */
14068b8534bSLuigi Rizzo 	uint16_t len;	/* packet length, to be copied to/from the hw ring */
14168b8534bSLuigi Rizzo 	uint16_t flags;	/* buf changed, etc. */
14268b8534bSLuigi Rizzo #define	NS_BUF_CHANGED	0x0001	/* must resync the map, buffer changed */
14368b8534bSLuigi Rizzo #define	NS_REPORT	0x0002	/* ask the hardware to report results
14468b8534bSLuigi Rizzo 				 * e.g. by generating an interrupt
14568b8534bSLuigi Rizzo 				 */
146*01c039a1SLuigi Rizzo #define	NS_FORWARD	0x0004	/* pass packet to the other endpoint
147*01c039a1SLuigi Rizzo 				 * (host stack or device)
148*01c039a1SLuigi Rizzo 				 */
149*01c039a1SLuigi Rizzo #define	NS_NO_LEARN	0x0008
150*01c039a1SLuigi Rizzo #define	NS_PORT_SHIFT	8
151*01c039a1SLuigi Rizzo #define	NS_PORT_MASK	(0xff << NS_PORT_SHIFT)
15268b8534bSLuigi Rizzo };
15368b8534bSLuigi Rizzo 
15468b8534bSLuigi Rizzo /*
15568b8534bSLuigi Rizzo  * Netmap representation of a TX or RX ring (also known as "queue").
15668b8534bSLuigi Rizzo  * This is a queue implemented as a fixed-size circular array.
15768b8534bSLuigi Rizzo  * At the software level, two fields are important: avail and cur.
15868b8534bSLuigi Rizzo  *
15968b8534bSLuigi Rizzo  * In TX rings:
16068b8534bSLuigi Rizzo  *	avail	indicates the number of slots available for transmission.
16164ae02c3SLuigi Rizzo  *		It is updated by the kernel after every netmap system call.
16264ae02c3SLuigi Rizzo  *		It MUST BE decremented by the application when it appends a
16364ae02c3SLuigi Rizzo  *		packet.
16464ae02c3SLuigi Rizzo  *	cur	indicates the slot to use for the next packet
16568b8534bSLuigi Rizzo  *		to send (i.e. the "tail" of the queue).
16664ae02c3SLuigi Rizzo  *		It MUST BE incremented by the application before
16764ae02c3SLuigi Rizzo  *		netmap system calls to reflect the number of newly
16864ae02c3SLuigi Rizzo  *		sent packets.
16964ae02c3SLuigi Rizzo  *		It is checked by the kernel on netmap system calls
17064ae02c3SLuigi Rizzo  *		(normally unmodified by the kernel unless invalid).
17168b8534bSLuigi Rizzo  *
17268b8534bSLuigi Rizzo  *   The kernel side of netmap uses two additional fields in its own
17368b8534bSLuigi Rizzo  *   private ring structure, netmap_kring:
17468b8534bSLuigi Rizzo  *	nr_hwcur is a copy of nr_cur on an NIOCTXSYNC.
17568b8534bSLuigi Rizzo  *	nr_hwavail is the number of slots known as available by the
17668b8534bSLuigi Rizzo  *		hardware. It is updated on an INTR (inc by the
17768b8534bSLuigi Rizzo  *		number of packets sent) and on a NIOCTXSYNC
17868b8534bSLuigi Rizzo  *		(decrease by nr_cur - nr_hwcur)
17968b8534bSLuigi Rizzo  *		A special case, nr_hwavail is -1 if the transmit
18068b8534bSLuigi Rizzo  *		side is idle (no pending transmits).
18168b8534bSLuigi Rizzo  *
18268b8534bSLuigi Rizzo  * In RX rings:
18368b8534bSLuigi Rizzo  *	avail	is the number of packets available (possibly 0).
18464ae02c3SLuigi Rizzo  *		It MUST BE decremented by the application when it consumes
18564ae02c3SLuigi Rizzo  *		a packet, and it is updated to nr_hwavail on a NIOCRXSYNC
18664ae02c3SLuigi Rizzo  *	cur	indicates the first slot that contains a packet not
18764ae02c3SLuigi Rizzo  *		processed yet (the "head" of the queue).
18864ae02c3SLuigi Rizzo  *		It MUST BE incremented by the software when it consumes
18968b8534bSLuigi Rizzo  *		a packet.
19064ae02c3SLuigi Rizzo  *	reserved	indicates the number of buffers before 'cur'
19164ae02c3SLuigi Rizzo  *		that the application has still in use. Normally 0,
19264ae02c3SLuigi Rizzo  *		it MUST BE incremented by the application when it
19364ae02c3SLuigi Rizzo  *		does not return the buffer immediately, and decremented
19464ae02c3SLuigi Rizzo  *		when the buffer is finally freed.
19568b8534bSLuigi Rizzo  *
19668b8534bSLuigi Rizzo  *   The kernel side of netmap uses two additional fields in the kring:
19768b8534bSLuigi Rizzo  *	nr_hwcur is a copy of nr_cur on an NIOCRXSYNC
19868b8534bSLuigi Rizzo  *	nr_hwavail is the number of packets available. It is updated
19968b8534bSLuigi Rizzo  *		on INTR (inc by the number of new packets arrived)
20068b8534bSLuigi Rizzo  *		and on NIOCRXSYNC (decreased by nr_cur - nr_hwcur).
20168b8534bSLuigi Rizzo  *
20268b8534bSLuigi Rizzo  * DATA OWNERSHIP/LOCKING:
20368b8534bSLuigi Rizzo  *	The netmap_ring is owned by the user program and it is only
20468b8534bSLuigi Rizzo  *	accessed or modified in the upper half of the kernel during
20568b8534bSLuigi Rizzo  *	a system call.
20668b8534bSLuigi Rizzo  *
20768b8534bSLuigi Rizzo  *	The netmap_kring is only modified by the upper half of the kernel.
208*01c039a1SLuigi Rizzo  *
209*01c039a1SLuigi Rizzo  * FLAGS
210*01c039a1SLuigi Rizzo  *	NR_TIMESTAMP	updates the 'ts' field on each syscall. This is
211*01c039a1SLuigi Rizzo  *			a global timestamp for all packets.
212*01c039a1SLuigi Rizzo  *	NR_RX_TSTMP	if set, the last 64 byte in each buffer will
213*01c039a1SLuigi Rizzo  *			contain a timestamp for the frame supplied by
214*01c039a1SLuigi Rizzo  *			the hardware (if supported)
215*01c039a1SLuigi Rizzo  *	NR_FORWARD	if set, the NS_FORWARD flag in each slot of the
216*01c039a1SLuigi Rizzo  *			RX ring is checked, and if set the packet is
217*01c039a1SLuigi Rizzo  *			passed to the other side (host stack or device,
218*01c039a1SLuigi Rizzo  *			respectively). This permits bpf-like behaviour
219*01c039a1SLuigi Rizzo  *			or transparency for selected packets.
22068b8534bSLuigi Rizzo  */
22168b8534bSLuigi Rizzo struct netmap_ring {
22268b8534bSLuigi Rizzo 	/*
22368b8534bSLuigi Rizzo 	 * nr_buf_base_ofs is meant to be used through macros.
22468b8534bSLuigi Rizzo 	 * It contains the offset of the buffer region from this
22568b8534bSLuigi Rizzo 	 * descriptor.
22668b8534bSLuigi Rizzo 	 */
22768b8534bSLuigi Rizzo 	const ssize_t	buf_ofs;
22868b8534bSLuigi Rizzo 	const uint32_t	num_slots;	/* number of slots in the ring. */
22968b8534bSLuigi Rizzo 	uint32_t	avail;		/* number of usable slots */
23068b8534bSLuigi Rizzo 	uint32_t        cur;		/* 'current' r/w position */
23164ae02c3SLuigi Rizzo 	uint32_t	reserved;	/* not refilled before current */
23268b8534bSLuigi Rizzo 
23368b8534bSLuigi Rizzo 	const uint16_t	nr_buf_size;
23468b8534bSLuigi Rizzo 	uint16_t	flags;
23568b8534bSLuigi Rizzo #define	NR_TIMESTAMP	0x0002		/* set timestamp on *sync() */
236*01c039a1SLuigi Rizzo #define	NR_FORWARD	0x0004		/* enable NS_FORWARD for ring */
237*01c039a1SLuigi Rizzo #define	NR_RX_TSTMP	0x0008		/* set rx timestamp in slots */
23868b8534bSLuigi Rizzo 
23968b8534bSLuigi Rizzo 	struct timeval	ts;		/* time of last *sync() */
24068b8534bSLuigi Rizzo 
24168b8534bSLuigi Rizzo 	/* the slots follow. This struct has variable size */
24268b8534bSLuigi Rizzo 	struct netmap_slot slot[0];	/* array of slots. */
24368b8534bSLuigi Rizzo };
24468b8534bSLuigi Rizzo 
24568b8534bSLuigi Rizzo 
24668b8534bSLuigi Rizzo /*
24768b8534bSLuigi Rizzo  * Netmap representation of an interface and its queue(s).
24868b8534bSLuigi Rizzo  * There is one netmap_if for each file descriptor on which we want
24968b8534bSLuigi Rizzo  * to select/poll.  We assume that on each interface has the same number
25068b8534bSLuigi Rizzo  * of receive and transmit queues.
25168b8534bSLuigi Rizzo  * select/poll operates on one or all pairs depending on the value of
25268b8534bSLuigi Rizzo  * nmr_queueid passed on the ioctl.
25368b8534bSLuigi Rizzo  */
25468b8534bSLuigi Rizzo struct netmap_if {
25568b8534bSLuigi Rizzo 	char		ni_name[IFNAMSIZ]; /* name of the interface. */
25668b8534bSLuigi Rizzo 	const u_int	ni_version;	/* API version, currently unused */
257d76bf4ffSLuigi Rizzo 	const u_int	ni_rx_rings;	/* number of rx rings */
258d76bf4ffSLuigi Rizzo 	const u_int	ni_tx_rings;	/* if zero, same as ni_rx_rings */
25968b8534bSLuigi Rizzo 	/*
26064ae02c3SLuigi Rizzo 	 * The following array contains the offset of each netmap ring
26164ae02c3SLuigi Rizzo 	 * from this structure. The first ni_tx_queues+1 entries refer
26264ae02c3SLuigi Rizzo 	 * to the tx rings, the next ni_rx_queues+1 refer to the rx rings
26364ae02c3SLuigi Rizzo 	 * (the last entry in each block refers to the host stack rings).
26468b8534bSLuigi Rizzo 	 * The area is filled up by the kernel on NIOCREG,
26568b8534bSLuigi Rizzo 	 * and then only read by userspace code.
26668b8534bSLuigi Rizzo 	 */
26768b8534bSLuigi Rizzo 	const ssize_t	ring_ofs[0];
26868b8534bSLuigi Rizzo };
26968b8534bSLuigi Rizzo 
27068b8534bSLuigi Rizzo #ifndef NIOCREGIF
27168b8534bSLuigi Rizzo /*
27268b8534bSLuigi Rizzo  * ioctl names and related fields
27368b8534bSLuigi Rizzo  *
27468b8534bSLuigi Rizzo  * NIOCGINFO takes a struct ifreq, the interface name is the input,
27568b8534bSLuigi Rizzo  *	the outputs are number of queues and number of descriptor
27668b8534bSLuigi Rizzo  *	for each queue (useful to set number of threads etc.).
27768b8534bSLuigi Rizzo  *
27868b8534bSLuigi Rizzo  * NIOCREGIF takes an interface name within a struct ifreq,
27968b8534bSLuigi Rizzo  *	and activates netmap mode on the interface (if possible).
28068b8534bSLuigi Rizzo  *
28168b8534bSLuigi Rizzo  * NIOCUNREGIF unregisters the interface associated to the fd.
28268b8534bSLuigi Rizzo  *
28368b8534bSLuigi Rizzo  * NIOCTXSYNC, NIOCRXSYNC synchronize tx or rx queues,
28468b8534bSLuigi Rizzo  *	whose identity is set in NIOCREGIF through nr_ringid
28568b8534bSLuigi Rizzo  */
28668b8534bSLuigi Rizzo 
28768b8534bSLuigi Rizzo /*
28868b8534bSLuigi Rizzo  * struct nmreq overlays a struct ifreq
28968b8534bSLuigi Rizzo  */
29068b8534bSLuigi Rizzo struct nmreq {
29168b8534bSLuigi Rizzo 	char		nr_name[IFNAMSIZ];
29264ae02c3SLuigi Rizzo 	uint32_t	nr_version;	/* API version */
293d76bf4ffSLuigi Rizzo #define	NETMAP_API	3		/* current version */
29468b8534bSLuigi Rizzo 	uint32_t	nr_offset;	/* nifp offset in the shared region */
29568b8534bSLuigi Rizzo 	uint32_t	nr_memsize;	/* size of the shared region */
29664ae02c3SLuigi Rizzo 	uint32_t	nr_tx_slots;	/* slots in tx rings */
29764ae02c3SLuigi Rizzo 	uint32_t	nr_rx_slots;	/* slots in rx rings */
29864ae02c3SLuigi Rizzo 	uint16_t	nr_tx_rings;	/* number of tx rings */
29964ae02c3SLuigi Rizzo 	uint16_t	nr_rx_rings;	/* number of rx rings */
30068b8534bSLuigi Rizzo 	uint16_t	nr_ringid;	/* ring(s) we care about */
30168b8534bSLuigi Rizzo #define NETMAP_HW_RING	0x4000		/* low bits indicate one hw ring */
30264ae02c3SLuigi Rizzo #define NETMAP_SW_RING	0x2000		/* process the sw ring */
30364ae02c3SLuigi Rizzo #define NETMAP_NO_TX_POLL	0x1000	/* no automatic txsync on poll */
30468b8534bSLuigi Rizzo #define NETMAP_RING_MASK 0xfff		/* the ring number */
30564ae02c3SLuigi Rizzo 	uint16_t	spare1;
30664ae02c3SLuigi Rizzo 	uint32_t	spare2[4];
30768b8534bSLuigi Rizzo };
30868b8534bSLuigi Rizzo 
30964ae02c3SLuigi Rizzo /*
31064ae02c3SLuigi Rizzo  * FreeBSD uses the size value embedded in the _IOWR to determine
31164ae02c3SLuigi Rizzo  * how much to copy in/out. So we need it to match the actual
31264ae02c3SLuigi Rizzo  * data structure we pass. We put some spares in the structure
31364ae02c3SLuigi Rizzo  * to ease compatibility with other versions
31464ae02c3SLuigi Rizzo  */
31568b8534bSLuigi Rizzo #define NIOCGINFO	_IOWR('i', 145, struct nmreq) /* return IF info */
31668b8534bSLuigi Rizzo #define NIOCREGIF	_IOWR('i', 146, struct nmreq) /* interface register */
31768b8534bSLuigi Rizzo #define NIOCUNREGIF	_IO('i', 147) /* interface unregister */
31868b8534bSLuigi Rizzo #define NIOCTXSYNC	_IO('i', 148) /* sync tx queues */
31968b8534bSLuigi Rizzo #define NIOCRXSYNC	_IO('i', 149) /* sync rx queues */
32068b8534bSLuigi Rizzo #endif /* !NIOCREGIF */
32168b8534bSLuigi Rizzo 
32268b8534bSLuigi Rizzo #endif /* _NET_NETMAP_H_ */
323