xref: /openbsd/sys/dev/pv/ndis.h (revision 76d0caae)
1 /*-
2  * Copyright (c) 2016 Microsoft Corp.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice unmodified, this list of conditions, and the following
10  *    disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #ifndef _DEV_PV_NDIS_H_
28 #define _DEV_PV_NDIS_H_
29 
30 /*
31  * NDIS protocol version numbers
32  */
33 #define	NDIS_VERSION_5_0			0x00050000
34 #define	NDIS_VERSION_5_1			0x00050001
35 #define	NDIS_VERSION_6_0			0x00060000
36 #define	NDIS_VERSION_6_1			0x00060001
37 #define	NDIS_VERSION_6_30			0x0006001e
38 
39 #define	NDIS_MEDIA_STATE_CONNECTED	0
40 #define	NDIS_MEDIA_STATE_DISCONNECTED	1
41 
42 #define	NDIS_OBJTYPE_DEFAULT		0x80
43 #define	NDIS_OBJTYPE_RSS_CAPS		0x88
44 #define	NDIS_OBJTYPE_RSS_PARAMS		0x89
45 
46 struct ndis_object_hdr {
47 	uint8_t			ndis_type;	/* NDIS_OBJTYPE_ */
48 	uint8_t			ndis_rev;	/* type specific */
49 	uint16_t		ndis_size;	/* incl. this hdr */
50 };
51 
52 /*
53  * OID_TCP_OFFLOAD_PARAMETERS
54  * ndis_type: NDIS_OBJTYPE_DEFAULT
55  */
56 struct ndis_offload_params {
57 	struct ndis_object_hdr	ndis_hdr;
58 	uint8_t			ndis_ip4csum;	/* NDIS_OFFLOAD_PARAM_ */
59 	uint8_t			ndis_tcp4csum;	/* NDIS_OFFLOAD_PARAM_ */
60 	uint8_t			ndis_udp4csum;	/* NDIS_OFFLOAD_PARAM_ */
61 	uint8_t			ndis_tcp6csum;	/* NDIS_OFFLOAD_PARAM_ */
62 	uint8_t			ndis_udp6csum;	/* NDIS_OFFLOAD_PARAM_ */
63 	uint8_t			ndis_lsov1;	/* NDIS_OFFLOAD_PARAM_ */
64 	uint8_t			ndis_ipsecv1;	/* NDIS_OFFLOAD_IPSECV1_ */
65 	uint8_t			ndis_lsov2_ip4;	/* NDIS_OFFLOAD_LSOV2_ */
66 	uint8_t			ndis_lsov2_ip6;	/* NDIS_OFFLOAD_LSOV2_ */
67 	uint8_t			ndis_tcp4conn;	/* 0 */
68 	uint8_t			ndis_tcp6conn;	/* 0 */
69 	uint32_t		ndis_flags;	/* 0 */
70 	/* NDIS >= 6.1 */
71 	uint8_t			ndis_ipsecv2;	/* NDIS_OFFLOAD_IPSECV2_ */
72 	uint8_t			ndis_ipsecv2_ip4;/* NDIS_OFFLOAD_IPSECV2_ */
73 	/* NDIS >= 6.30 */
74 	uint8_t			ndis_rsc_ip4;	/* NDIS_OFFLOAD_RSC_ */
75 	uint8_t			ndis_rsc_ip6;	/* NDIS_OFFLOAD_RSC_ */
76 	uint8_t			ndis_encap;	/* NDIS_OFFLOAD_SET_ */
77 	uint8_t			ndis_encap_types;/* NDIS_ENCAP_TYPE_ */
78 };
79 
80 #define	NDIS_OFFLOAD_PARAMS_SIZE	sizeof(struct ndis_offload_params)
81 #define	NDIS_OFFLOAD_PARAMS_SIZE_6_1	\
82 	offsetof(struct ndis_offload_params, ndis_rsc_ip4)
83 
84 #define	NDIS_OFFLOAD_PARAMS_REV_2	2	/* NDIS 6.1 */
85 #define	NDIS_OFFLOAD_PARAMS_REV_3	3	/* NDIS 6.30 */
86 
87 #define	NDIS_OFFLOAD_PARAM_NOCHG	0	/* common */
88 #define	NDIS_OFFLOAD_PARAM_OFF		1
89 #define	NDIS_OFFLOAD_PARAM_TX		2
90 #define	NDIS_OFFLOAD_PARAM_RX		3
91 #define	NDIS_OFFLOAD_PARAM_TXRX		4
92 
93 /* NDIS_OFFLOAD_PARAM_NOCHG */
94 #define	NDIS_OFFLOAD_LSOV1_OFF		1
95 #define	NDIS_OFFLOAD_LSOV1_ON		2
96 
97 /* NDIS_OFFLOAD_PARAM_NOCHG */
98 #define	NDIS_OFFLOAD_IPSECV1_OFF	1
99 #define	NDIS_OFFLOAD_IPSECV1_AH		2
100 #define	NDIS_OFFLOAD_IPSECV1_ESP	3
101 #define	NDIS_OFFLOAD_IPSECV1_AH_ESP	4
102 
103 /* NDIS_OFFLOAD_PARAM_NOCHG */
104 #define	NDIS_OFFLOAD_LSOV2_OFF		1
105 #define	NDIS_OFFLOAD_LSOV2_ON		2
106 
107 /* NDIS_OFFLOAD_PARAM_NOCHG */
108 #define	NDIS_OFFLOAD_IPSECV2_OFF	1
109 #define	NDIS_OFFLOAD_IPSECV2_AH		2
110 #define	NDIS_OFFLOAD_IPSECV2_ESP	3
111 #define	NDIS_OFFLOAD_IPSECV2_AH_ESP	4
112 
113 /* NDIS_OFFLOAD_PARAM_NOCHG */
114 #define	NDIS_OFFLOAD_RSC_OFF		1
115 #define	NDIS_OFFLOAD_RSC_ON		2
116 
117 /*
118  * Per-packet-info
119  */
120 
121 /* VLAN */
122 #define	NDIS_VLAN_INFO_SIZE		sizeof(uint32_t)
123 #define	NDIS_VLAN_INFO_PRI_MASK		0x0007
124 #define	NDIS_VLAN_INFO_ID_MASK		0xfff0
125 #define	NDIS_VLAN_INFO(id, pri)			\
126 	(((pri) & NDIS_VLAN_INFO_PRI_MASK) | (((id) & 0xfff) << 4))
127 #define	NDIS_VLAN_INFO_ID(inf)		(((inf) & NDIS_VLAN_INFO_ID_MASK) >> 4)
128 #define	NDIS_VLAN_INFO_PRI(inf)		( (inf) & NDIS_VLAN_INFO_PRI_MASK)
129 
130 /* Reception checksum */
131 #define	NDIS_RXCSUM_INFO_SIZE		sizeof(uint32_t)
132 #define	NDIS_RXCSUM_INFO_TCPCS_FAILED	0x0001
133 #define	NDIS_RXCSUM_INFO_UDPCS_FAILED	0x0002
134 #define	NDIS_RXCSUM_INFO_IPCS_FAILED	0x0004
135 #define	NDIS_RXCSUM_INFO_TCPCS_OK	0x0008
136 #define	NDIS_RXCSUM_INFO_UDPCS_OK	0x0010
137 #define	NDIS_RXCSUM_INFO_IPCS_OK	0x0020
138 #define	NDIS_RXCSUM_INFO_LOOPBACK	0x0040
139 #define	NDIS_RXCSUM_INFO_TCPCS_INVAL	0x0080
140 #define	NDIS_RXCSUM_INFO_IPCS_INVAL	0x0100
141 
142 /* Transmission checksum */
143 #define	NDIS_TXCSUM_INFO_SIZE		sizeof(uint32_t)
144 #define	NDIS_TXCSUM_INFO_IPV4		0x00000001
145 #define	NDIS_TXCSUM_INFO_IPV6		0x00000002
146 #define	NDIS_TXCSUM_INFO_TCPCS		0x00000004
147 #define	NDIS_TXCSUM_INFO_UDPCS		0x00000008
148 #define	NDIS_TXCSUM_INFO_IPCS		0x00000010
149 #define	NDIS_TXCSUM_INFO_THOFF		0x03ff0000
150 
151 #endif	/* _DEV_PV_NDIS_H_ */
152