xref: /OK3568_Linux_fs/kernel/include/uapi/linux/virtio_net.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun #ifndef _UAPI_LINUX_VIRTIO_NET_H
2*4882a593Smuzhiyun #define _UAPI_LINUX_VIRTIO_NET_H
3*4882a593Smuzhiyun /* This header is BSD licensed so anyone can use the definitions to implement
4*4882a593Smuzhiyun  * compatible drivers/servers.
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * Redistribution and use in source and binary forms, with or without
7*4882a593Smuzhiyun  * modification, are permitted provided that the following conditions
8*4882a593Smuzhiyun  * are met:
9*4882a593Smuzhiyun  * 1. Redistributions of source code must retain the above copyright
10*4882a593Smuzhiyun  *    notice, this list of conditions and the following disclaimer.
11*4882a593Smuzhiyun  * 2. Redistributions in binary form must reproduce the above copyright
12*4882a593Smuzhiyun  *    notice, this list of conditions and the following disclaimer in the
13*4882a593Smuzhiyun  *    documentation and/or other materials provided with the distribution.
14*4882a593Smuzhiyun  * 3. Neither the name of IBM nor the names of its contributors
15*4882a593Smuzhiyun  *    may be used to endorse or promote products derived from this software
16*4882a593Smuzhiyun  *    without specific prior written permission.
17*4882a593Smuzhiyun  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
18*4882a593Smuzhiyun  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19*4882a593Smuzhiyun  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20*4882a593Smuzhiyun  * ARE DISCLAIMED.  IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
21*4882a593Smuzhiyun  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22*4882a593Smuzhiyun  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23*4882a593Smuzhiyun  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24*4882a593Smuzhiyun  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25*4882a593Smuzhiyun  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26*4882a593Smuzhiyun  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27*4882a593Smuzhiyun  * SUCH DAMAGE. */
28*4882a593Smuzhiyun #include <linux/types.h>
29*4882a593Smuzhiyun #include <linux/virtio_ids.h>
30*4882a593Smuzhiyun #include <linux/virtio_config.h>
31*4882a593Smuzhiyun #include <linux/virtio_types.h>
32*4882a593Smuzhiyun #include <linux/if_ether.h>
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun /* The feature bitmap for virtio net */
35*4882a593Smuzhiyun #define VIRTIO_NET_F_CSUM	0	/* Host handles pkts w/ partial csum */
36*4882a593Smuzhiyun #define VIRTIO_NET_F_GUEST_CSUM	1	/* Guest handles pkts w/ partial csum */
37*4882a593Smuzhiyun #define VIRTIO_NET_F_CTRL_GUEST_OFFLOADS 2 /* Dynamic offload configuration. */
38*4882a593Smuzhiyun #define VIRTIO_NET_F_MTU	3	/* Initial MTU advice */
39*4882a593Smuzhiyun #define VIRTIO_NET_F_MAC	5	/* Host has given MAC address. */
40*4882a593Smuzhiyun #define VIRTIO_NET_F_GUEST_TSO4	7	/* Guest can handle TSOv4 in. */
41*4882a593Smuzhiyun #define VIRTIO_NET_F_GUEST_TSO6	8	/* Guest can handle TSOv6 in. */
42*4882a593Smuzhiyun #define VIRTIO_NET_F_GUEST_ECN	9	/* Guest can handle TSO[6] w/ ECN in. */
43*4882a593Smuzhiyun #define VIRTIO_NET_F_GUEST_UFO	10	/* Guest can handle UFO in. */
44*4882a593Smuzhiyun #define VIRTIO_NET_F_HOST_TSO4	11	/* Host can handle TSOv4 in. */
45*4882a593Smuzhiyun #define VIRTIO_NET_F_HOST_TSO6	12	/* Host can handle TSOv6 in. */
46*4882a593Smuzhiyun #define VIRTIO_NET_F_HOST_ECN	13	/* Host can handle TSO[6] w/ ECN in. */
47*4882a593Smuzhiyun #define VIRTIO_NET_F_HOST_UFO	14	/* Host can handle UFO in. */
48*4882a593Smuzhiyun #define VIRTIO_NET_F_MRG_RXBUF	15	/* Host can merge receive buffers. */
49*4882a593Smuzhiyun #define VIRTIO_NET_F_STATUS	16	/* virtio_net_config.status available */
50*4882a593Smuzhiyun #define VIRTIO_NET_F_CTRL_VQ	17	/* Control channel available */
51*4882a593Smuzhiyun #define VIRTIO_NET_F_CTRL_RX	18	/* Control channel RX mode support */
52*4882a593Smuzhiyun #define VIRTIO_NET_F_CTRL_VLAN	19	/* Control channel VLAN filtering */
53*4882a593Smuzhiyun #define VIRTIO_NET_F_CTRL_RX_EXTRA 20	/* Extra RX mode control support */
54*4882a593Smuzhiyun #define VIRTIO_NET_F_GUEST_ANNOUNCE 21	/* Guest can announce device on the
55*4882a593Smuzhiyun 					 * network */
56*4882a593Smuzhiyun #define VIRTIO_NET_F_MQ	22	/* Device supports Receive Flow
57*4882a593Smuzhiyun 					 * Steering */
58*4882a593Smuzhiyun #define VIRTIO_NET_F_CTRL_MAC_ADDR 23	/* Set MAC address */
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun #define VIRTIO_NET_F_HASH_REPORT  57	/* Supports hash report */
61*4882a593Smuzhiyun #define VIRTIO_NET_F_RSS	  60	/* Supports RSS RX steering */
62*4882a593Smuzhiyun #define VIRTIO_NET_F_RSC_EXT	  61	/* extended coalescing info */
63*4882a593Smuzhiyun #define VIRTIO_NET_F_STANDBY	  62	/* Act as standby for another device
64*4882a593Smuzhiyun 					 * with the same MAC.
65*4882a593Smuzhiyun 					 */
66*4882a593Smuzhiyun #define VIRTIO_NET_F_SPEED_DUPLEX 63	/* Device set linkspeed and duplex */
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun #ifndef VIRTIO_NET_NO_LEGACY
69*4882a593Smuzhiyun #define VIRTIO_NET_F_GSO	6	/* Host handles pkts w/ any GSO type */
70*4882a593Smuzhiyun #endif /* VIRTIO_NET_NO_LEGACY */
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun #define VIRTIO_NET_S_LINK_UP	1	/* Link is up */
73*4882a593Smuzhiyun #define VIRTIO_NET_S_ANNOUNCE	2	/* Announcement is needed */
74*4882a593Smuzhiyun 
75*4882a593Smuzhiyun /* supported/enabled hash types */
76*4882a593Smuzhiyun #define VIRTIO_NET_RSS_HASH_TYPE_IPv4          (1 << 0)
77*4882a593Smuzhiyun #define VIRTIO_NET_RSS_HASH_TYPE_TCPv4         (1 << 1)
78*4882a593Smuzhiyun #define VIRTIO_NET_RSS_HASH_TYPE_UDPv4         (1 << 2)
79*4882a593Smuzhiyun #define VIRTIO_NET_RSS_HASH_TYPE_IPv6          (1 << 3)
80*4882a593Smuzhiyun #define VIRTIO_NET_RSS_HASH_TYPE_TCPv6         (1 << 4)
81*4882a593Smuzhiyun #define VIRTIO_NET_RSS_HASH_TYPE_UDPv6         (1 << 5)
82*4882a593Smuzhiyun #define VIRTIO_NET_RSS_HASH_TYPE_IP_EX         (1 << 6)
83*4882a593Smuzhiyun #define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX        (1 << 7)
84*4882a593Smuzhiyun #define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX        (1 << 8)
85*4882a593Smuzhiyun 
86*4882a593Smuzhiyun struct virtio_net_config {
87*4882a593Smuzhiyun 	/* The config defining mac address (if VIRTIO_NET_F_MAC) */
88*4882a593Smuzhiyun 	__u8 mac[ETH_ALEN];
89*4882a593Smuzhiyun 	/* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */
90*4882a593Smuzhiyun 	__virtio16 status;
91*4882a593Smuzhiyun 	/* Maximum number of each of transmit and receive queues;
92*4882a593Smuzhiyun 	 * see VIRTIO_NET_F_MQ and VIRTIO_NET_CTRL_MQ.
93*4882a593Smuzhiyun 	 * Legal values are between 1 and 0x8000
94*4882a593Smuzhiyun 	 */
95*4882a593Smuzhiyun 	__virtio16 max_virtqueue_pairs;
96*4882a593Smuzhiyun 	/* Default maximum transmit unit advice */
97*4882a593Smuzhiyun 	__virtio16 mtu;
98*4882a593Smuzhiyun 	/*
99*4882a593Smuzhiyun 	 * speed, in units of 1Mb. All values 0 to INT_MAX are legal.
100*4882a593Smuzhiyun 	 * Any other value stands for unknown.
101*4882a593Smuzhiyun 	 */
102*4882a593Smuzhiyun 	__le32 speed;
103*4882a593Smuzhiyun 	/*
104*4882a593Smuzhiyun 	 * 0x00 - half duplex
105*4882a593Smuzhiyun 	 * 0x01 - full duplex
106*4882a593Smuzhiyun 	 * Any other value stands for unknown.
107*4882a593Smuzhiyun 	 */
108*4882a593Smuzhiyun 	__u8 duplex;
109*4882a593Smuzhiyun 	/* maximum size of RSS key */
110*4882a593Smuzhiyun 	__u8 rss_max_key_size;
111*4882a593Smuzhiyun 	/* maximum number of indirection table entries */
112*4882a593Smuzhiyun 	__le16 rss_max_indirection_table_length;
113*4882a593Smuzhiyun 	/* bitmask of supported VIRTIO_NET_RSS_HASH_ types */
114*4882a593Smuzhiyun 	__le32 supported_hash_types;
115*4882a593Smuzhiyun } __attribute__((packed));
116*4882a593Smuzhiyun 
117*4882a593Smuzhiyun /*
118*4882a593Smuzhiyun  * This header comes first in the scatter-gather list.  If you don't
119*4882a593Smuzhiyun  * specify GSO or CSUM features, you can simply ignore the header.
120*4882a593Smuzhiyun  *
121*4882a593Smuzhiyun  * This is bitwise-equivalent to the legacy struct virtio_net_hdr_mrg_rxbuf,
122*4882a593Smuzhiyun  * only flattened.
123*4882a593Smuzhiyun  */
124*4882a593Smuzhiyun struct virtio_net_hdr_v1 {
125*4882a593Smuzhiyun #define VIRTIO_NET_HDR_F_NEEDS_CSUM	1	/* Use csum_start, csum_offset */
126*4882a593Smuzhiyun #define VIRTIO_NET_HDR_F_DATA_VALID	2	/* Csum is valid */
127*4882a593Smuzhiyun #define VIRTIO_NET_HDR_F_RSC_INFO	4	/* rsc info in csum_ fields */
128*4882a593Smuzhiyun 	__u8 flags;
129*4882a593Smuzhiyun #define VIRTIO_NET_HDR_GSO_NONE		0	/* Not a GSO frame */
130*4882a593Smuzhiyun #define VIRTIO_NET_HDR_GSO_TCPV4	1	/* GSO frame, IPv4 TCP (TSO) */
131*4882a593Smuzhiyun #define VIRTIO_NET_HDR_GSO_UDP		3	/* GSO frame, IPv4 UDP (UFO) */
132*4882a593Smuzhiyun #define VIRTIO_NET_HDR_GSO_TCPV6	4	/* GSO frame, IPv6 TCP */
133*4882a593Smuzhiyun #define VIRTIO_NET_HDR_GSO_ECN		0x80	/* TCP has ECN set */
134*4882a593Smuzhiyun 	__u8 gso_type;
135*4882a593Smuzhiyun 	__virtio16 hdr_len;	/* Ethernet + IP + tcp/udp hdrs */
136*4882a593Smuzhiyun 	__virtio16 gso_size;	/* Bytes to append to hdr_len per frame */
137*4882a593Smuzhiyun 	union {
138*4882a593Smuzhiyun 		struct {
139*4882a593Smuzhiyun 			__virtio16 csum_start;
140*4882a593Smuzhiyun 			__virtio16 csum_offset;
141*4882a593Smuzhiyun 		};
142*4882a593Smuzhiyun 		/* Checksum calculation */
143*4882a593Smuzhiyun 		struct {
144*4882a593Smuzhiyun 			/* Position to start checksumming from */
145*4882a593Smuzhiyun 			__virtio16 start;
146*4882a593Smuzhiyun 			/* Offset after that to place checksum */
147*4882a593Smuzhiyun 			__virtio16 offset;
148*4882a593Smuzhiyun 		} csum;
149*4882a593Smuzhiyun 		/* Receive Segment Coalescing */
150*4882a593Smuzhiyun 		struct {
151*4882a593Smuzhiyun 			/* Number of coalesced segments */
152*4882a593Smuzhiyun 			__le16 segments;
153*4882a593Smuzhiyun 			/* Number of duplicated acks */
154*4882a593Smuzhiyun 			__le16 dup_acks;
155*4882a593Smuzhiyun 		} rsc;
156*4882a593Smuzhiyun 	};
157*4882a593Smuzhiyun 	__virtio16 num_buffers;	/* Number of merged rx buffers */
158*4882a593Smuzhiyun };
159*4882a593Smuzhiyun 
160*4882a593Smuzhiyun struct virtio_net_hdr_v1_hash {
161*4882a593Smuzhiyun 	struct virtio_net_hdr_v1 hdr;
162*4882a593Smuzhiyun 	__le32 hash_value;
163*4882a593Smuzhiyun #define VIRTIO_NET_HASH_REPORT_NONE            0
164*4882a593Smuzhiyun #define VIRTIO_NET_HASH_REPORT_IPv4            1
165*4882a593Smuzhiyun #define VIRTIO_NET_HASH_REPORT_TCPv4           2
166*4882a593Smuzhiyun #define VIRTIO_NET_HASH_REPORT_UDPv4           3
167*4882a593Smuzhiyun #define VIRTIO_NET_HASH_REPORT_IPv6            4
168*4882a593Smuzhiyun #define VIRTIO_NET_HASH_REPORT_TCPv6           5
169*4882a593Smuzhiyun #define VIRTIO_NET_HASH_REPORT_UDPv6           6
170*4882a593Smuzhiyun #define VIRTIO_NET_HASH_REPORT_IPv6_EX         7
171*4882a593Smuzhiyun #define VIRTIO_NET_HASH_REPORT_TCPv6_EX        8
172*4882a593Smuzhiyun #define VIRTIO_NET_HASH_REPORT_UDPv6_EX        9
173*4882a593Smuzhiyun 	__le16 hash_report;
174*4882a593Smuzhiyun 	__le16 padding;
175*4882a593Smuzhiyun };
176*4882a593Smuzhiyun 
177*4882a593Smuzhiyun #ifndef VIRTIO_NET_NO_LEGACY
178*4882a593Smuzhiyun /* This header comes first in the scatter-gather list.
179*4882a593Smuzhiyun  * For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, it must
180*4882a593Smuzhiyun  * be the first element of the scatter-gather list.  If you don't
181*4882a593Smuzhiyun  * specify GSO or CSUM features, you can simply ignore the header. */
182*4882a593Smuzhiyun struct virtio_net_hdr {
183*4882a593Smuzhiyun 	/* See VIRTIO_NET_HDR_F_* */
184*4882a593Smuzhiyun 	__u8 flags;
185*4882a593Smuzhiyun 	/* See VIRTIO_NET_HDR_GSO_* */
186*4882a593Smuzhiyun 	__u8 gso_type;
187*4882a593Smuzhiyun 	__virtio16 hdr_len;		/* Ethernet + IP + tcp/udp hdrs */
188*4882a593Smuzhiyun 	__virtio16 gso_size;		/* Bytes to append to hdr_len per frame */
189*4882a593Smuzhiyun 	__virtio16 csum_start;	/* Position to start checksumming from */
190*4882a593Smuzhiyun 	__virtio16 csum_offset;	/* Offset after that to place checksum */
191*4882a593Smuzhiyun };
192*4882a593Smuzhiyun 
193*4882a593Smuzhiyun /* This is the version of the header to use when the MRG_RXBUF
194*4882a593Smuzhiyun  * feature has been negotiated. */
195*4882a593Smuzhiyun struct virtio_net_hdr_mrg_rxbuf {
196*4882a593Smuzhiyun 	struct virtio_net_hdr hdr;
197*4882a593Smuzhiyun 	__virtio16 num_buffers;	/* Number of merged rx buffers */
198*4882a593Smuzhiyun };
199*4882a593Smuzhiyun #endif /* ...VIRTIO_NET_NO_LEGACY */
200*4882a593Smuzhiyun 
201*4882a593Smuzhiyun /*
202*4882a593Smuzhiyun  * Control virtqueue data structures
203*4882a593Smuzhiyun  *
204*4882a593Smuzhiyun  * The control virtqueue expects a header in the first sg entry
205*4882a593Smuzhiyun  * and an ack/status response in the last entry.  Data for the
206*4882a593Smuzhiyun  * command goes in between.
207*4882a593Smuzhiyun  */
208*4882a593Smuzhiyun struct virtio_net_ctrl_hdr {
209*4882a593Smuzhiyun 	__u8 class;
210*4882a593Smuzhiyun 	__u8 cmd;
211*4882a593Smuzhiyun } __attribute__((packed));
212*4882a593Smuzhiyun 
213*4882a593Smuzhiyun typedef __u8 virtio_net_ctrl_ack;
214*4882a593Smuzhiyun 
215*4882a593Smuzhiyun #define VIRTIO_NET_OK     0
216*4882a593Smuzhiyun #define VIRTIO_NET_ERR    1
217*4882a593Smuzhiyun 
218*4882a593Smuzhiyun /*
219*4882a593Smuzhiyun  * Control the RX mode, ie. promisucous, allmulti, etc...
220*4882a593Smuzhiyun  * All commands require an "out" sg entry containing a 1 byte
221*4882a593Smuzhiyun  * state value, zero = disable, non-zero = enable.  Commands
222*4882a593Smuzhiyun  * 0 and 1 are supported with the VIRTIO_NET_F_CTRL_RX feature.
223*4882a593Smuzhiyun  * Commands 2-5 are added with VIRTIO_NET_F_CTRL_RX_EXTRA.
224*4882a593Smuzhiyun  */
225*4882a593Smuzhiyun #define VIRTIO_NET_CTRL_RX    0
226*4882a593Smuzhiyun  #define VIRTIO_NET_CTRL_RX_PROMISC      0
227*4882a593Smuzhiyun  #define VIRTIO_NET_CTRL_RX_ALLMULTI     1
228*4882a593Smuzhiyun  #define VIRTIO_NET_CTRL_RX_ALLUNI       2
229*4882a593Smuzhiyun  #define VIRTIO_NET_CTRL_RX_NOMULTI      3
230*4882a593Smuzhiyun  #define VIRTIO_NET_CTRL_RX_NOUNI        4
231*4882a593Smuzhiyun  #define VIRTIO_NET_CTRL_RX_NOBCAST      5
232*4882a593Smuzhiyun 
233*4882a593Smuzhiyun /*
234*4882a593Smuzhiyun  * Control the MAC
235*4882a593Smuzhiyun  *
236*4882a593Smuzhiyun  * The MAC filter table is managed by the hypervisor, the guest should
237*4882a593Smuzhiyun  * assume the size is infinite.  Filtering should be considered
238*4882a593Smuzhiyun  * non-perfect, ie. based on hypervisor resources, the guest may
239*4882a593Smuzhiyun  * received packets from sources not specified in the filter list.
240*4882a593Smuzhiyun  *
241*4882a593Smuzhiyun  * In addition to the class/cmd header, the TABLE_SET command requires
242*4882a593Smuzhiyun  * two out scatterlists.  Each contains a 4 byte count of entries followed
243*4882a593Smuzhiyun  * by a concatenated byte stream of the ETH_ALEN MAC addresses.  The
244*4882a593Smuzhiyun  * first sg list contains unicast addresses, the second is for multicast.
245*4882a593Smuzhiyun  * This functionality is present if the VIRTIO_NET_F_CTRL_RX feature
246*4882a593Smuzhiyun  * is available.
247*4882a593Smuzhiyun  *
248*4882a593Smuzhiyun  * The ADDR_SET command requests one out scatterlist, it contains a
249*4882a593Smuzhiyun  * 6 bytes MAC address. This functionality is present if the
250*4882a593Smuzhiyun  * VIRTIO_NET_F_CTRL_MAC_ADDR feature is available.
251*4882a593Smuzhiyun  */
252*4882a593Smuzhiyun struct virtio_net_ctrl_mac {
253*4882a593Smuzhiyun 	__virtio32 entries;
254*4882a593Smuzhiyun 	__u8 macs[][ETH_ALEN];
255*4882a593Smuzhiyun } __attribute__((packed));
256*4882a593Smuzhiyun 
257*4882a593Smuzhiyun #define VIRTIO_NET_CTRL_MAC    1
258*4882a593Smuzhiyun  #define VIRTIO_NET_CTRL_MAC_TABLE_SET        0
259*4882a593Smuzhiyun  #define VIRTIO_NET_CTRL_MAC_ADDR_SET         1
260*4882a593Smuzhiyun 
261*4882a593Smuzhiyun /*
262*4882a593Smuzhiyun  * Control VLAN filtering
263*4882a593Smuzhiyun  *
264*4882a593Smuzhiyun  * The VLAN filter table is controlled via a simple ADD/DEL interface.
265*4882a593Smuzhiyun  * VLAN IDs not added may be filterd by the hypervisor.  Del is the
266*4882a593Smuzhiyun  * opposite of add.  Both commands expect an out entry containing a 2
267*4882a593Smuzhiyun  * byte VLAN ID.  VLAN filterting is available with the
268*4882a593Smuzhiyun  * VIRTIO_NET_F_CTRL_VLAN feature bit.
269*4882a593Smuzhiyun  */
270*4882a593Smuzhiyun #define VIRTIO_NET_CTRL_VLAN       2
271*4882a593Smuzhiyun  #define VIRTIO_NET_CTRL_VLAN_ADD             0
272*4882a593Smuzhiyun  #define VIRTIO_NET_CTRL_VLAN_DEL             1
273*4882a593Smuzhiyun 
274*4882a593Smuzhiyun /*
275*4882a593Smuzhiyun  * Control link announce acknowledgement
276*4882a593Smuzhiyun  *
277*4882a593Smuzhiyun  * The command VIRTIO_NET_CTRL_ANNOUNCE_ACK is used to indicate that
278*4882a593Smuzhiyun  * driver has recevied the notification; device would clear the
279*4882a593Smuzhiyun  * VIRTIO_NET_S_ANNOUNCE bit in the status field after it receives
280*4882a593Smuzhiyun  * this command.
281*4882a593Smuzhiyun  */
282*4882a593Smuzhiyun #define VIRTIO_NET_CTRL_ANNOUNCE       3
283*4882a593Smuzhiyun  #define VIRTIO_NET_CTRL_ANNOUNCE_ACK         0
284*4882a593Smuzhiyun 
285*4882a593Smuzhiyun /*
286*4882a593Smuzhiyun  * Control Receive Flow Steering
287*4882a593Smuzhiyun  */
288*4882a593Smuzhiyun #define VIRTIO_NET_CTRL_MQ   4
289*4882a593Smuzhiyun /*
290*4882a593Smuzhiyun  * The command VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET
291*4882a593Smuzhiyun  * enables Receive Flow Steering, specifying the number of the transmit and
292*4882a593Smuzhiyun  * receive queues that will be used. After the command is consumed and acked by
293*4882a593Smuzhiyun  * the device, the device will not steer new packets on receive virtqueues
294*4882a593Smuzhiyun  * other than specified nor read from transmit virtqueues other than specified.
295*4882a593Smuzhiyun  * Accordingly, driver should not transmit new packets  on virtqueues other than
296*4882a593Smuzhiyun  * specified.
297*4882a593Smuzhiyun  */
298*4882a593Smuzhiyun struct virtio_net_ctrl_mq {
299*4882a593Smuzhiyun 	__virtio16 virtqueue_pairs;
300*4882a593Smuzhiyun };
301*4882a593Smuzhiyun 
302*4882a593Smuzhiyun  #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET        0
303*4882a593Smuzhiyun  #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN        1
304*4882a593Smuzhiyun  #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX        0x8000
305*4882a593Smuzhiyun 
306*4882a593Smuzhiyun /*
307*4882a593Smuzhiyun  * The command VIRTIO_NET_CTRL_MQ_RSS_CONFIG has the same effect as
308*4882a593Smuzhiyun  * VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET does and additionally configures
309*4882a593Smuzhiyun  * the receive steering to use a hash calculated for incoming packet
310*4882a593Smuzhiyun  * to decide on receive virtqueue to place the packet. The command
311*4882a593Smuzhiyun  * also provides parameters to calculate a hash and receive virtqueue.
312*4882a593Smuzhiyun  */
313*4882a593Smuzhiyun struct virtio_net_rss_config {
314*4882a593Smuzhiyun 	__le32 hash_types;
315*4882a593Smuzhiyun 	__le16 indirection_table_mask;
316*4882a593Smuzhiyun 	__le16 unclassified_queue;
317*4882a593Smuzhiyun 	__le16 indirection_table[1/* + indirection_table_mask */];
318*4882a593Smuzhiyun 	__le16 max_tx_vq;
319*4882a593Smuzhiyun 	__u8 hash_key_length;
320*4882a593Smuzhiyun 	__u8 hash_key_data[/* hash_key_length */];
321*4882a593Smuzhiyun };
322*4882a593Smuzhiyun 
323*4882a593Smuzhiyun  #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG          1
324*4882a593Smuzhiyun 
325*4882a593Smuzhiyun /*
326*4882a593Smuzhiyun  * The command VIRTIO_NET_CTRL_MQ_HASH_CONFIG requests the device
327*4882a593Smuzhiyun  * to include in the virtio header of the packet the value of the
328*4882a593Smuzhiyun  * calculated hash and the report type of hash. It also provides
329*4882a593Smuzhiyun  * parameters for hash calculation. The command requires feature
330*4882a593Smuzhiyun  * VIRTIO_NET_F_HASH_REPORT to be negotiated to extend the
331*4882a593Smuzhiyun  * layout of virtio header as defined in virtio_net_hdr_v1_hash.
332*4882a593Smuzhiyun  */
333*4882a593Smuzhiyun struct virtio_net_hash_config {
334*4882a593Smuzhiyun 	__le32 hash_types;
335*4882a593Smuzhiyun 	/* for compatibility with virtio_net_rss_config */
336*4882a593Smuzhiyun 	__le16 reserved[4];
337*4882a593Smuzhiyun 	__u8 hash_key_length;
338*4882a593Smuzhiyun 	__u8 hash_key_data[/* hash_key_length */];
339*4882a593Smuzhiyun };
340*4882a593Smuzhiyun 
341*4882a593Smuzhiyun  #define VIRTIO_NET_CTRL_MQ_HASH_CONFIG         2
342*4882a593Smuzhiyun 
343*4882a593Smuzhiyun /*
344*4882a593Smuzhiyun  * Control network offloads
345*4882a593Smuzhiyun  *
346*4882a593Smuzhiyun  * Reconfigures the network offloads that Guest can handle.
347*4882a593Smuzhiyun  *
348*4882a593Smuzhiyun  * Available with the VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature bit.
349*4882a593Smuzhiyun  *
350*4882a593Smuzhiyun  * Command data format matches the feature bit mask exactly.
351*4882a593Smuzhiyun  *
352*4882a593Smuzhiyun  * See VIRTIO_NET_F_GUEST_* for the list of offloads
353*4882a593Smuzhiyun  * that can be enabled/disabled.
354*4882a593Smuzhiyun  */
355*4882a593Smuzhiyun #define VIRTIO_NET_CTRL_GUEST_OFFLOADS   5
356*4882a593Smuzhiyun #define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET        0
357*4882a593Smuzhiyun 
358*4882a593Smuzhiyun #endif /* _UAPI_LINUX_VIRTIO_NET_H */
359