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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
|
/*-
* Copyright (c) 2013 Tsubai Masanari
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: src/sys/dev/pci/if_vmxreg.h,v 1.2 2013/06/12 01:07:33 uebayasi Exp $
*
* $FreeBSD$
*/
#ifndef _IF_VMXREG_H
#define _IF_VMXREG_H
struct UPT1_TxStats {
uint64_t TSO_packets;
uint64_t TSO_bytes;
uint64_t ucast_packets;
uint64_t ucast_bytes;
uint64_t mcast_packets;
uint64_t mcast_bytes;
uint64_t bcast_packets;
uint64_t bcast_bytes;
uint64_t error;
uint64_t discard;
} __packed;
struct UPT1_RxStats {
uint64_t LRO_packets;
uint64_t LRO_bytes;
uint64_t ucast_packets;
uint64_t ucast_bytes;
uint64_t mcast_packets;
uint64_t mcast_bytes;
uint64_t bcast_packets;
uint64_t bcast_bytes;
uint64_t nobuffer;
uint64_t error;
} __packed;
/* Interrupt moderation levels */
#define UPT1_IMOD_NONE 0 /* No moderation */
#define UPT1_IMOD_HIGHEST 7 /* Least interrupts */
#define UPT1_IMOD_ADAPTIVE 8 /* Adaptive interrupt moderation */
/* Hardware features */
#define UPT1_F_CSUM 0x0001 /* Rx checksum verification */
#define UPT1_F_RSS 0x0002 /* Receive side scaling */
#define UPT1_F_VLAN 0x0004 /* VLAN tag stripping */
#define UPT1_F_LRO 0x0008 /* Large receive offloading */
#define VMXNET3_BAR0_IMASK(irq) (0x000 + (irq) * 8) /* Interrupt mask */
#define VMXNET3_BAR0_TXH(q) (0x600 + (q) * 8) /* Tx head */
#define VMXNET3_BAR0_RXH1(q) (0x800 + (q) * 8) /* Ring1 Rx head */
#define VMXNET3_BAR0_RXH2(q) (0xA00 + (q) * 8) /* Ring2 Rx head */
#define VMXNET3_BAR1_VRRS 0x000 /* VMXNET3 revision report selection */
#define VMXNET3_BAR1_UVRS 0x008 /* UPT version report selection */
#define VMXNET3_BAR1_DSL 0x010 /* Driver shared address low */
#define VMXNET3_BAR1_DSH 0x018 /* Driver shared address high */
#define VMXNET3_BAR1_CMD 0x020 /* Command */
#define VMXNET3_BAR1_MACL 0x028 /* MAC address low */
#define VMXNET3_BAR1_MACH 0x030 /* MAC address high */
#define VMXNET3_BAR1_INTR 0x038 /* Interrupt status */
#define VMXNET3_BAR1_EVENT 0x040 /* Event status */
#define VMXNET3_CMD_ENABLE 0xCAFE0000 /* Enable VMXNET3 */
#define VMXNET3_CMD_DISABLE 0xCAFE0001 /* Disable VMXNET3 */
#define VMXNET3_CMD_RESET 0xCAFE0002 /* Reset device */
#define VMXNET3_CMD_SET_RXMODE 0xCAFE0003 /* Set interface flags */
#define VMXNET3_CMD_SET_FILTER 0xCAFE0004 /* Set address filter */
#define VMXNET3_CMD_VLAN_FILTER 0xCAFE0005 /* Set VLAN filter */
#define VMXNET3_CMD_GET_STATUS 0xF00D0000 /* Get queue errors */
#define VMXNET3_CMD_GET_STATS 0xF00D0001 /* Get queue statistics */
#define VMXNET3_CMD_GET_LINK 0xF00D0002 /* Get link status */
#define VMXNET3_CMD_GET_MACL 0xF00D0003 /* Get MAC address low */
#define VMXNET3_CMD_GET_MACH 0xF00D0004 /* Get MAC address high */
#define VMXNET3_CMD_GET_INTRCFG 0xF00D0008 /* Get interrupt config */
#define VMXNET3_DMADESC_ALIGN 128
#define VMXNET3_INIT_GEN 1
struct vmxnet3_txdesc {
uint64_t addr;
uint32_t len:14;
uint32_t gen:1; /* Generation */
uint32_t pad1:1;
uint32_t dtype:1; /* Descriptor type */
uint32_t pad2:1;
uint32_t offload_pos:14; /* Offloading position */
uint32_t hlen:10; /* Header len */
uint32_t offload_mode:2; /* Offloading mode */
uint32_t eop:1; /* End of packet */
uint32_t compreq:1; /* Completion request */
uint32_t pad3:1;
uint32_t vtag_mode:1; /* VLAN tag insertion mode */
uint32_t vtag:16; /* VLAN tag */
} __packed;
/* Offloading modes */
#define VMXNET3_OM_NONE 0
#define VMXNET3_OM_CSUM 2
#define VMXNET3_OM_TSO 3
struct vmxnet3_txcompdesc {
uint32_t eop_idx:12; /* EOP index in Tx ring */
uint32_t pad1:20;
uint32_t pad2:32;
uint32_t pad3:32;
uint32_t rsvd:24;
uint32_t type:7;
uint32_t gen:1;
} __packed;
struct vmxnet3_rxdesc {
uint64_t addr;
uint32_t len:14;
uint32_t btype:1; /* Buffer type */
uint32_t dtype:1; /* Descriptor type */
uint32_t rsvd:15;
uint32_t gen:1;
uint32_t pad1:32;
} __packed;
/* Buffer types */
#define VMXNET3_BTYPE_HEAD 0 /* Head only */
#define VMXNET3_BTYPE_BODY 1 /* Body only */
struct vmxnet3_rxcompdesc {
uint32_t rxd_idx:12; /* Rx descriptor index */
uint32_t pad1:2;
uint32_t eop:1; /* End of packet */
uint32_t sop:1; /* Start of packet */
uint32_t qid:10;
uint32_t rss_type:4;
uint32_t no_csum:1; /* No checksum calculated */
uint32_t pad2:1;
uint32_t rss_hash:32; /* RSS hash value */
uint32_t len:14;
uint32_t error:1;
uint32_t vlan:1; /* 802.1Q VLAN frame */
uint32_t vtag:16; /* VLAN tag */
uint32_t csum:16;
uint32_t csum_ok:1; /* TCP/UDP checksum ok */
uint32_t udp:1;
uint32_t tcp:1;
uint32_t ipcsum_ok:1; /* IP checksum OK */
uint32_t ipv6:1;
uint32_t ipv4:1;
uint32_t fragment:1; /* IP fragment */
uint32_t fcs:1; /* Frame CRC correct */
uint32_t type:7;
uint32_t gen:1;
} __packed;
#define VMXNET3_RCD_RSS_TYPE_NONE 0
#define VMXNET3_RCD_RSS_TYPE_IPV4 1
#define VMXNET3_RCD_RSS_TYPE_TCPIPV4 2
#define VMXNET3_RCD_RSS_TYPE_IPV6 3
#define VMXNET3_RCD_RSS_TYPE_TCPIPV6 4
#define VMXNET3_REV1_MAGIC 0XBABEFEE1
#define VMXNET3_GOS_UNKNOWN 0x00
#define VMXNET3_GOS_LINUX 0x04
#define VMXNET3_GOS_WINDOWS 0x08
#define VMXNET3_GOS_SOLARIS 0x0C
#define VMXNET3_GOS_FREEBSD 0x10
#define VMXNET3_GOS_PXE 0x14
#define VMXNET3_GOS_32BIT 0x01
#define VMXNET3_GOS_64BIT 0x02
#define VMXNET3_MAX_TX_QUEUES 8
#define VMXNET3_MAX_RX_QUEUES 16
#define VMXNET3_MAX_INTRS \
(VMXNET3_MAX_TX_QUEUES + VMXNET3_MAX_RX_QUEUES + 1)
#define VMXNET3_ICTRL_DISABLE_ALL 0x01
#define VMXNET3_RXMODE_UCAST 0x01
#define VMXNET3_RXMODE_MCAST 0x02
#define VMXNET3_RXMODE_BCAST 0x04
#define VMXNET3_RXMODE_ALLMULTI 0x08
#define VMXNET3_RXMODE_PROMISC 0x10
#define VMXNET3_EVENT_RQERROR 0x01
#define VMXNET3_EVENT_TQERROR 0x02
#define VMXNET3_EVENT_LINK 0x04
#define VMXNET3_EVENT_DIC 0x08
#define VMXNET3_EVENT_DEBUG 0x10
#define VMXNET3_MIN_MTU 60
#define VMXNET3_MAX_MTU 9000
/* Interrupt mask mode. */
#define VMXNET3_IMM_AUTO 0x00
#define VMXNET3_IMM_ACTIVE 0x01
#define VMXNET3_IMM_LAZY 0x02
/* Interrupt type. */
#define VMXNET3_IT_AUTO 0x00
#define VMXNET3_IT_LEGACY 0x01
#define VMXNET3_IT_MSI 0x02
#define VMXNET3_IT_MSIX 0x03
struct vmxnet3_driver_shared {
uint32_t magic;
uint32_t pad1;
/* Misc. control */
uint32_t version; /* Driver version */
uint32_t guest; /* Guest OS */
uint32_t vmxnet3_revision; /* Supported VMXNET3 revision */
uint32_t upt_version; /* Supported UPT version */
uint64_t upt_features;
uint64_t driver_data;
uint64_t queue_shared;
uint32_t driver_data_len;
uint32_t queue_shared_len;
uint32_t mtu;
uint16_t nrxsg_max;
uint8_t ntxqueue;
uint8_t nrxqueue;
uint32_t reserved1[4];
/* Interrupt control */
uint8_t automask;
uint8_t nintr;
uint8_t evintr;
uint8_t modlevel[VMXNET3_MAX_INTRS];
uint32_t ictrl;
uint32_t reserved2[2];
/* Receive filter parameters */
uint32_t rxmode;
uint16_t mcast_tablelen;
uint16_t pad2;
uint64_t mcast_table;
uint32_t vlan_filter[4096 / 32];
struct {
uint32_t version;
uint32_t len;
uint64_t paddr;
} rss, pm, plugin;
uint32_t event;
uint32_t reserved3[5];
} __packed;
struct vmxnet3_txq_shared {
/* Control */
uint32_t npending;
uint32_t intr_threshold;
uint64_t reserved1;
/* Config */
uint64_t cmd_ring;
uint64_t data_ring;
uint64_t comp_ring;
uint64_t driver_data;
uint64_t reserved2;
uint32_t cmd_ring_len;
uint32_t data_ring_len;
uint32_t comp_ring_len;
uint32_t driver_data_len;
uint8_t intr_idx;
uint8_t pad1[7];
/* Queue status */
uint8_t stopped;
uint8_t pad2[3];
uint32_t error;
struct UPT1_TxStats stats;
uint8_t pad3[88];
} __packed;
struct vmxnet3_rxq_shared {
uint8_t update_rxhead;
uint8_t pad1[7];
uint64_t reserved1;
uint64_t cmd_ring[2];
uint64_t comp_ring;
uint64_t driver_data;
uint64_t reserved2;
uint32_t cmd_ring_len[2];
uint32_t comp_ring_len;
uint32_t driver_data_len;
uint8_t intr_idx;
uint8_t pad2[7];
uint8_t stopped;
uint8_t pad3[3];
uint32_t error;
struct UPT1_RxStats stats;
uint8_t pad4[88];
} __packed;
#define UPT1_RSS_HASH_TYPE_NONE 0x00
#define UPT1_RSS_HASH_TYPE_IPV4 0x01
#define UPT1_RSS_HASH_TYPE_TCP_IPV4 0x02
#define UPT1_RSS_HASH_TYPE_IPV6 0x04
#define UPT1_RSS_HASH_TYPE_TCP_IPV6 0x08
#define UPT1_RSS_HASH_FUNC_NONE 0x00
#define UPT1_RSS_HASH_FUNC_TOEPLITZ 0x01
#define UPT1_RSS_MAX_KEY_SIZE 40
#define UPT1_RSS_MAX_IND_TABLE_SIZE 128
struct vmxnet3_rss_shared {
uint16_t hash_type;
uint16_t hash_func;
uint16_t hash_key_size;
uint16_t ind_table_size;
uint8_t hash_key[UPT1_RSS_MAX_KEY_SIZE];
uint8_t ind_table[UPT1_RSS_MAX_IND_TABLE_SIZE];
} __packed;
#endif /* _IF_VMXREG_H */
|