|
root / base / usr / src / cmd / bhyve / common / virtio_net.h
virtio_net.h C 79 lines 1.9 KB
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 *
 * Copyright 2022 OmniOS Community Edition (OmniOSce) Association.
 */

#ifndef _VIRTIO_NET_H_
#define	_VIRTIO_NET_H_

#include "mevent.h"
#include "net_backends.h"

/*
 * This structure appears at the start of each control virtqueue request.
 */
typedef struct virtio_net_ctrl_hdr {
	uint8_t		vnch_class;
	uint8_t		vnch_command;
} __packed virtio_net_ctrl_hdr_t;

/*
 * This structure is used for the mac address tables associated with the
 * VIRTIO_NET_CTRL_MAC class.
 */
typedef struct virtio_net_ctrl_mac {
	uint32_t	vncm_entries;
	ether_addr_t	vncm_mac;
} __packed virtio_net_ctrl_mac_t;

/*
 * This structure is used to pass the number of queues.
 */
typedef struct virtio_net_ctrl_mq {
	uint16_t virtqueue_pairs;
} __packed virtio_net_ctrl_mq_t;

/*
 * Control Queue Classes
 */
#define	VIRTIO_NET_CTRL_RX		0
#define	VIRTIO_NET_CTRL_MAC		1
#define	VIRTIO_NET_CTRL_VLAN		2
#define	VIRTIO_NET_CTRL_ANNOUNCE	3
#define	VIRTIO_NET_CTRL_MQ		4

/*
 * CTRL_RX commands
 */
#define	VIRTIO_NET_CTRL_RX_PROMISC	0
#define	VIRTIO_NET_CTRL_RX_ALLMULTI	1
#define	VIRTIO_NET_CTRL_RX_ALLUNI	2
#define	VIRTIO_NET_CTRL_RX_NOMULTI	3
#define	VIRTIO_NET_CTRL_RX_NOUNI	4
#define	VIRTIO_NET_CTRL_RX_NOBCAST	5

/* CTRL_MAC commands */
#define	VIRTIO_NET_CTRL_MAC_TABLE_SET	0
#define	VIRTIO_NET_CTRL_MAC_ADDR_SET	1

/* CTRL_MQ commands */
#define	VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET	0
#define	VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN	1
#define	VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX	0x8000

/*
 * Control queue ack values
 */
#define	VIRTIO_NET_CQ_OK		0
#define	VIRTIO_NET_CQ_ERR		1

#endif /* _VIRTIO_NET_H_ */