xref: /illumos-gate/usr/src/cmd/bhyve/common/virtio_net.h (revision 5c4a5fe16715fb423db76577a6883b5bbecdbe45)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  *
11  * Copyright 2022 OmniOS Community Edition (OmniOSce) Association.
12  */
13 
14 #ifndef _VIRTIO_NET_H_
15 #define	_VIRTIO_NET_H_
16 
17 #include "mevent.h"
18 #include "net_backends.h"
19 
20 /*
21  * This structure appears at the start of each control virtqueue request.
22  */
23 typedef struct virtio_net_ctrl_hdr {
24 	uint8_t		vnch_class;
25 	uint8_t		vnch_command;
26 } __packed virtio_net_ctrl_hdr_t;
27 
28 /*
29  * This structure is used for the mac address tables associated with the
30  * VIRTIO_NET_CTRL_MAC class.
31  */
32 typedef struct virtio_net_ctrl_mac {
33 	uint32_t	vncm_entries;
34 	ether_addr_t	vncm_mac;
35 } __packed virtio_net_ctrl_mac_t;
36 
37 /*
38  * Control Queue Classes
39  */
40 #define	VIRTIO_NET_CTRL_RX		0
41 #define	VIRTIO_NET_CTRL_MAC		1
42 
43 /*
44  * CTRL_RX commands
45  */
46 #define	VIRTIO_NET_CTRL_RX_PROMISC	0
47 #define	VIRTIO_NET_CTRL_RX_ALLMULTI	1
48 #define	VIRTIO_NET_CTRL_RX_ALLUNI	2
49 #define	VIRTIO_NET_CTRL_RX_NOMULTI	3
50 #define	VIRTIO_NET_CTRL_RX_NOUNI	4
51 #define	VIRTIO_NET_CTRL_RX_NOBCAST	5
52 
53 /* CTRL_MAC commands */
54 #define	VIRTIO_NET_CTRL_MAC_TABLE_SET	0
55 #define	VIRTIO_NET_CTRL_MAC_ADDR_SET	1
56 
57 /*
58  * Control queue ack values
59  */
60 #define	VIRTIO_NET_CQ_OK		0
61 #define	VIRTIO_NET_CQ_ERR		1
62 
63 #endif /* _VIRTIO_NET_H_ */
64