]>
Commit | Line | Data |
---|---|---|
d1a890fa SB |
1 | /* |
2 | * Linux driver for VMware's vmxnet3 ethernet NIC. | |
3 | * | |
190af10f | 4 | * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved. |
d1a890fa SB |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; version 2 of the License and no later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but | |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | |
13 | * NON INFRINGEMENT. See the GNU General Public License for more | |
14 | * details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
19 | * | |
20 | * The full GNU General Public License is included in this distribution in | |
21 | * the file called "COPYING". | |
22 | * | |
190af10f | 23 | * Maintained by: pv-drivers@vmware.com |
d1a890fa SB |
24 | * |
25 | */ | |
26 | ||
27 | #ifndef _VMXNET3_DEFS_H_ | |
28 | #define _VMXNET3_DEFS_H_ | |
29 | ||
30 | #include "upt1_defs.h" | |
31 | ||
32 | /* all registers are 32 bit wide */ | |
33 | /* BAR 1 */ | |
34 | enum { | |
35 | VMXNET3_REG_VRRS = 0x0, /* Vmxnet3 Revision Report Selection */ | |
36 | VMXNET3_REG_UVRS = 0x8, /* UPT Version Report Selection */ | |
37 | VMXNET3_REG_DSAL = 0x10, /* Driver Shared Address Low */ | |
38 | VMXNET3_REG_DSAH = 0x18, /* Driver Shared Address High */ | |
39 | VMXNET3_REG_CMD = 0x20, /* Command */ | |
40 | VMXNET3_REG_MACL = 0x28, /* MAC Address Low */ | |
41 | VMXNET3_REG_MACH = 0x30, /* MAC Address High */ | |
42 | VMXNET3_REG_ICR = 0x38, /* Interrupt Cause Register */ | |
43 | VMXNET3_REG_ECR = 0x40 /* Event Cause Register */ | |
44 | }; | |
45 | ||
46 | /* BAR 0 */ | |
47 | enum { | |
48 | VMXNET3_REG_IMR = 0x0, /* Interrupt Mask Register */ | |
49 | VMXNET3_REG_TXPROD = 0x600, /* Tx Producer Index */ | |
50 | VMXNET3_REG_RXPROD = 0x800, /* Rx Producer Index for ring 1 */ | |
51 | VMXNET3_REG_RXPROD2 = 0xA00 /* Rx Producer Index for ring 2 */ | |
52 | }; | |
53 | ||
54 | #define VMXNET3_PT_REG_SIZE 4096 /* BAR 0 */ | |
55 | #define VMXNET3_VD_REG_SIZE 4096 /* BAR 1 */ | |
56 | ||
57 | #define VMXNET3_REG_ALIGN 8 /* All registers are 8-byte aligned. */ | |
58 | #define VMXNET3_REG_ALIGN_MASK 0x7 | |
59 | ||
60 | /* I/O Mapped access to registers */ | |
61 | #define VMXNET3_IO_TYPE_PT 0 | |
62 | #define VMXNET3_IO_TYPE_VD 1 | |
63 | #define VMXNET3_IO_ADDR(type, reg) (((type) << 24) | ((reg) & 0xFFFFFF)) | |
64 | #define VMXNET3_IO_TYPE(addr) ((addr) >> 24) | |
65 | #define VMXNET3_IO_REG(addr) ((addr) & 0xFFFFFF) | |
66 | ||
67 | enum { | |
68 | VMXNET3_CMD_FIRST_SET = 0xCAFE0000, | |
69 | VMXNET3_CMD_ACTIVATE_DEV = VMXNET3_CMD_FIRST_SET, | |
70 | VMXNET3_CMD_QUIESCE_DEV, | |
71 | VMXNET3_CMD_RESET_DEV, | |
72 | VMXNET3_CMD_UPDATE_RX_MODE, | |
73 | VMXNET3_CMD_UPDATE_MAC_FILTERS, | |
74 | VMXNET3_CMD_UPDATE_VLAN_FILTERS, | |
75 | VMXNET3_CMD_UPDATE_RSSIDT, | |
76 | VMXNET3_CMD_UPDATE_IML, | |
77 | VMXNET3_CMD_UPDATE_PMCFG, | |
78 | VMXNET3_CMD_UPDATE_FEATURE, | |
190af10f | 79 | VMXNET3_CMD_RESERVED1, |
d1a890fa | 80 | VMXNET3_CMD_LOAD_PLUGIN, |
190af10f | 81 | VMXNET3_CMD_RESERVED2, |
d1a890fa SB |
82 | |
83 | VMXNET3_CMD_FIRST_GET = 0xF00D0000, | |
84 | VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET, | |
85 | VMXNET3_CMD_GET_STATS, | |
86 | VMXNET3_CMD_GET_LINK, | |
87 | VMXNET3_CMD_GET_PERM_MAC_LO, | |
88 | VMXNET3_CMD_GET_PERM_MAC_HI, | |
89 | VMXNET3_CMD_GET_DID_LO, | |
90 | VMXNET3_CMD_GET_DID_HI, | |
91 | VMXNET3_CMD_GET_DEV_EXTRA_INFO, | |
190af10f SK |
92 | VMXNET3_CMD_GET_CONF_INTR, |
93 | VMXNET3_CMD_GET_RESERVED1, | |
d1a890fa SB |
94 | }; |
95 | ||
115924b6 SB |
96 | /* |
97 | * Little Endian layout of bitfields - | |
98 | * Byte 0 : 7.....len.....0 | |
99 | * Byte 1 : rsvd gen 13.len.8 | |
100 | * Byte 2 : 5.msscof.0 ext1 dtype | |
101 | * Byte 3 : 13...msscof...6 | |
102 | * | |
103 | * Big Endian layout of bitfields - | |
104 | * Byte 0: 13...msscof...6 | |
105 | * Byte 1 : 5.msscof.0 ext1 dtype | |
106 | * Byte 2 : rsvd gen 13.len.8 | |
107 | * Byte 3 : 7.....len.....0 | |
108 | * | |
109 | * Thus, le32_to_cpu on the dword will allow the big endian driver to read | |
110 | * the bit fields correctly. And cpu_to_le32 will convert bitfields | |
111 | * bit fields written by big endian driver to format required by device. | |
112 | */ | |
d1a890fa | 113 | |
115924b6 SB |
114 | struct Vmxnet3_TxDesc { |
115 | __le64 addr; | |
116 | ||
117 | #ifdef __BIG_ENDIAN_BITFIELD | |
118 | u32 msscof:14; /* MSS, checksum offset, flags */ | |
119 | u32 ext1:1; | |
120 | u32 dtype:1; /* descriptor type */ | |
121 | u32 rsvd:1; | |
122 | u32 gen:1; /* generation bit */ | |
123 | u32 len:14; | |
124 | #else | |
125 | u32 len:14; | |
126 | u32 gen:1; /* generation bit */ | |
127 | u32 rsvd:1; | |
128 | u32 dtype:1; /* descriptor type */ | |
129 | u32 ext1:1; | |
130 | u32 msscof:14; /* MSS, checksum offset, flags */ | |
131 | #endif /* __BIG_ENDIAN_BITFIELD */ | |
132 | ||
133 | #ifdef __BIG_ENDIAN_BITFIELD | |
134 | u32 tci:16; /* Tag to Insert */ | |
135 | u32 ti:1; /* VLAN Tag Insertion */ | |
136 | u32 ext2:1; | |
137 | u32 cq:1; /* completion request */ | |
138 | u32 eop:1; /* End Of Packet */ | |
139 | u32 om:2; /* offload mode */ | |
140 | u32 hlen:10; /* header len */ | |
141 | #else | |
142 | u32 hlen:10; /* header len */ | |
143 | u32 om:2; /* offload mode */ | |
144 | u32 eop:1; /* End Of Packet */ | |
145 | u32 cq:1; /* completion request */ | |
146 | u32 ext2:1; | |
147 | u32 ti:1; /* VLAN Tag Insertion */ | |
148 | u32 tci:16; /* Tag to Insert */ | |
149 | #endif /* __BIG_ENDIAN_BITFIELD */ | |
d1a890fa SB |
150 | }; |
151 | ||
152 | /* TxDesc.OM values */ | |
153 | #define VMXNET3_OM_NONE 0 | |
154 | #define VMXNET3_OM_CSUM 2 | |
155 | #define VMXNET3_OM_TSO 3 | |
156 | ||
157 | /* fields in TxDesc we access w/o using bit fields */ | |
158 | #define VMXNET3_TXD_EOP_SHIFT 12 | |
159 | #define VMXNET3_TXD_CQ_SHIFT 13 | |
160 | #define VMXNET3_TXD_GEN_SHIFT 14 | |
115924b6 SB |
161 | #define VMXNET3_TXD_EOP_DWORD_SHIFT 3 |
162 | #define VMXNET3_TXD_GEN_DWORD_SHIFT 2 | |
d1a890fa SB |
163 | |
164 | #define VMXNET3_TXD_CQ (1 << VMXNET3_TXD_CQ_SHIFT) | |
165 | #define VMXNET3_TXD_EOP (1 << VMXNET3_TXD_EOP_SHIFT) | |
166 | #define VMXNET3_TXD_GEN (1 << VMXNET3_TXD_GEN_SHIFT) | |
167 | ||
168 | #define VMXNET3_HDR_COPY_SIZE 128 | |
169 | ||
170 | ||
171 | struct Vmxnet3_TxDataDesc { | |
172 | u8 data[VMXNET3_HDR_COPY_SIZE]; | |
173 | }; | |
174 | ||
115924b6 SB |
175 | #define VMXNET3_TCD_GEN_SHIFT 31 |
176 | #define VMXNET3_TCD_GEN_SIZE 1 | |
177 | #define VMXNET3_TCD_TXIDX_SHIFT 0 | |
178 | #define VMXNET3_TCD_TXIDX_SIZE 12 | |
179 | #define VMXNET3_TCD_GEN_DWORD_SHIFT 3 | |
d1a890fa SB |
180 | |
181 | struct Vmxnet3_TxCompDesc { | |
182 | u32 txdIdx:12; /* Index of the EOP TxDesc */ | |
183 | u32 ext1:20; | |
184 | ||
115924b6 SB |
185 | __le32 ext2; |
186 | __le32 ext3; | |
d1a890fa SB |
187 | |
188 | u32 rsvd:24; | |
189 | u32 type:7; /* completion type */ | |
190 | u32 gen:1; /* generation bit */ | |
191 | }; | |
192 | ||
d1a890fa | 193 | struct Vmxnet3_RxDesc { |
115924b6 | 194 | __le64 addr; |
d1a890fa | 195 | |
115924b6 SB |
196 | #ifdef __BIG_ENDIAN_BITFIELD |
197 | u32 gen:1; /* Generation bit */ | |
198 | u32 rsvd:15; | |
199 | u32 dtype:1; /* Descriptor type */ | |
200 | u32 btype:1; /* Buffer Type */ | |
201 | u32 len:14; | |
202 | #else | |
d1a890fa SB |
203 | u32 len:14; |
204 | u32 btype:1; /* Buffer Type */ | |
205 | u32 dtype:1; /* Descriptor type */ | |
206 | u32 rsvd:15; | |
207 | u32 gen:1; /* Generation bit */ | |
115924b6 | 208 | #endif |
d1a890fa SB |
209 | u32 ext1; |
210 | }; | |
211 | ||
212 | /* values of RXD.BTYPE */ | |
213 | #define VMXNET3_RXD_BTYPE_HEAD 0 /* head only */ | |
214 | #define VMXNET3_RXD_BTYPE_BODY 1 /* body only */ | |
215 | ||
216 | /* fields in RxDesc we access w/o using bit fields */ | |
217 | #define VMXNET3_RXD_BTYPE_SHIFT 14 | |
218 | #define VMXNET3_RXD_GEN_SHIFT 31 | |
219 | ||
d1a890fa | 220 | struct Vmxnet3_RxCompDesc { |
115924b6 SB |
221 | #ifdef __BIG_ENDIAN_BITFIELD |
222 | u32 ext2:1; | |
223 | u32 cnc:1; /* Checksum Not Calculated */ | |
224 | u32 rssType:4; /* RSS hash type used */ | |
225 | u32 rqID:10; /* rx queue/ring ID */ | |
226 | u32 sop:1; /* Start of Packet */ | |
227 | u32 eop:1; /* End of Packet */ | |
228 | u32 ext1:2; | |
229 | u32 rxdIdx:12; /* Index of the RxDesc */ | |
230 | #else | |
d1a890fa SB |
231 | u32 rxdIdx:12; /* Index of the RxDesc */ |
232 | u32 ext1:2; | |
233 | u32 eop:1; /* End of Packet */ | |
234 | u32 sop:1; /* Start of Packet */ | |
235 | u32 rqID:10; /* rx queue/ring ID */ | |
236 | u32 rssType:4; /* RSS hash type used */ | |
237 | u32 cnc:1; /* Checksum Not Calculated */ | |
238 | u32 ext2:1; | |
115924b6 | 239 | #endif /* __BIG_ENDIAN_BITFIELD */ |
d1a890fa | 240 | |
115924b6 | 241 | __le32 rssHash; /* RSS hash value */ |
d1a890fa | 242 | |
115924b6 SB |
243 | #ifdef __BIG_ENDIAN_BITFIELD |
244 | u32 tci:16; /* Tag stripped */ | |
245 | u32 ts:1; /* Tag is stripped */ | |
246 | u32 err:1; /* Error */ | |
247 | u32 len:14; /* data length */ | |
248 | #else | |
d1a890fa SB |
249 | u32 len:14; /* data length */ |
250 | u32 err:1; /* Error */ | |
251 | u32 ts:1; /* Tag is stripped */ | |
252 | u32 tci:16; /* Tag stripped */ | |
115924b6 SB |
253 | #endif /* __BIG_ENDIAN_BITFIELD */ |
254 | ||
d1a890fa | 255 | |
115924b6 SB |
256 | #ifdef __BIG_ENDIAN_BITFIELD |
257 | u32 gen:1; /* generation bit */ | |
258 | u32 type:7; /* completion type */ | |
259 | u32 fcs:1; /* Frame CRC correct */ | |
260 | u32 frg:1; /* IP Fragment */ | |
261 | u32 v4:1; /* IPv4 */ | |
262 | u32 v6:1; /* IPv6 */ | |
263 | u32 ipc:1; /* IP Checksum Correct */ | |
264 | u32 tcp:1; /* TCP packet */ | |
265 | u32 udp:1; /* UDP packet */ | |
266 | u32 tuc:1; /* TCP/UDP Checksum Correct */ | |
267 | u32 csum:16; | |
268 | #else | |
d1a890fa SB |
269 | u32 csum:16; |
270 | u32 tuc:1; /* TCP/UDP Checksum Correct */ | |
271 | u32 udp:1; /* UDP packet */ | |
272 | u32 tcp:1; /* TCP packet */ | |
273 | u32 ipc:1; /* IP Checksum Correct */ | |
274 | u32 v6:1; /* IPv6 */ | |
275 | u32 v4:1; /* IPv4 */ | |
276 | u32 frg:1; /* IP Fragment */ | |
277 | u32 fcs:1; /* Frame CRC correct */ | |
278 | u32 type:7; /* completion type */ | |
279 | u32 gen:1; /* generation bit */ | |
115924b6 | 280 | #endif /* __BIG_ENDIAN_BITFIELD */ |
d1a890fa SB |
281 | }; |
282 | ||
45dac1d6 SB |
283 | struct Vmxnet3_RxCompDescExt { |
284 | __le32 dword1; | |
285 | u8 segCnt; /* Number of aggregated packets */ | |
286 | u8 dupAckCnt; /* Number of duplicate Acks */ | |
287 | __le16 tsDelta; /* TCP timestamp difference */ | |
288 | __le32 dword2; | |
289 | #ifdef __BIG_ENDIAN_BITFIELD | |
290 | u32 gen:1; /* generation bit */ | |
291 | u32 type:7; /* completion type */ | |
292 | u32 fcs:1; /* Frame CRC correct */ | |
293 | u32 frg:1; /* IP Fragment */ | |
294 | u32 v4:1; /* IPv4 */ | |
295 | u32 v6:1; /* IPv6 */ | |
296 | u32 ipc:1; /* IP Checksum Correct */ | |
297 | u32 tcp:1; /* TCP packet */ | |
298 | u32 udp:1; /* UDP packet */ | |
299 | u32 tuc:1; /* TCP/UDP Checksum Correct */ | |
300 | u32 mss:16; | |
301 | #else | |
302 | u32 mss:16; | |
303 | u32 tuc:1; /* TCP/UDP Checksum Correct */ | |
304 | u32 udp:1; /* UDP packet */ | |
305 | u32 tcp:1; /* TCP packet */ | |
306 | u32 ipc:1; /* IP Checksum Correct */ | |
307 | u32 v6:1; /* IPv6 */ | |
308 | u32 v4:1; /* IPv4 */ | |
309 | u32 frg:1; /* IP Fragment */ | |
310 | u32 fcs:1; /* Frame CRC correct */ | |
311 | u32 type:7; /* completion type */ | |
312 | u32 gen:1; /* generation bit */ | |
313 | #endif /* __BIG_ENDIAN_BITFIELD */ | |
314 | }; | |
315 | ||
316 | ||
d1a890fa SB |
317 | /* fields in RxCompDesc we access via Vmxnet3_GenericDesc.dword[3] */ |
318 | #define VMXNET3_RCD_TUC_SHIFT 16 | |
319 | #define VMXNET3_RCD_IPC_SHIFT 19 | |
320 | ||
321 | /* fields in RxCompDesc we access via Vmxnet3_GenericDesc.qword[1] */ | |
322 | #define VMXNET3_RCD_TYPE_SHIFT 56 | |
323 | #define VMXNET3_RCD_GEN_SHIFT 63 | |
324 | ||
325 | /* csum OK for TCP/UDP pkts over IP */ | |
326 | #define VMXNET3_RCD_CSUM_OK (1 << VMXNET3_RCD_TUC_SHIFT | \ | |
327 | 1 << VMXNET3_RCD_IPC_SHIFT) | |
115924b6 SB |
328 | #define VMXNET3_TXD_GEN_SIZE 1 |
329 | #define VMXNET3_TXD_EOP_SIZE 1 | |
d1a890fa SB |
330 | |
331 | /* value of RxCompDesc.rssType */ | |
332 | enum { | |
333 | VMXNET3_RCD_RSS_TYPE_NONE = 0, | |
334 | VMXNET3_RCD_RSS_TYPE_IPV4 = 1, | |
335 | VMXNET3_RCD_RSS_TYPE_TCPIPV4 = 2, | |
336 | VMXNET3_RCD_RSS_TYPE_IPV6 = 3, | |
337 | VMXNET3_RCD_RSS_TYPE_TCPIPV6 = 4, | |
338 | }; | |
339 | ||
340 | ||
341 | /* a union for accessing all cmd/completion descriptors */ | |
342 | union Vmxnet3_GenericDesc { | |
115924b6 SB |
343 | __le64 qword[2]; |
344 | __le32 dword[4]; | |
345 | __le16 word[8]; | |
d1a890fa SB |
346 | struct Vmxnet3_TxDesc txd; |
347 | struct Vmxnet3_RxDesc rxd; | |
348 | struct Vmxnet3_TxCompDesc tcd; | |
349 | struct Vmxnet3_RxCompDesc rcd; | |
45dac1d6 | 350 | struct Vmxnet3_RxCompDescExt rcdExt; |
d1a890fa SB |
351 | }; |
352 | ||
353 | #define VMXNET3_INIT_GEN 1 | |
354 | ||
355 | /* Max size of a single tx buffer */ | |
356 | #define VMXNET3_MAX_TX_BUF_SIZE (1 << 14) | |
357 | ||
358 | /* # of tx desc needed for a tx buffer size */ | |
359 | #define VMXNET3_TXD_NEEDED(size) (((size) + VMXNET3_MAX_TX_BUF_SIZE - 1) / \ | |
360 | VMXNET3_MAX_TX_BUF_SIZE) | |
361 | ||
362 | /* max # of tx descs for a non-tso pkt */ | |
363 | #define VMXNET3_MAX_TXD_PER_PKT 16 | |
364 | ||
365 | /* Max size of a single rx buffer */ | |
366 | #define VMXNET3_MAX_RX_BUF_SIZE ((1 << 14) - 1) | |
367 | /* Minimum size of a type 0 buffer */ | |
368 | #define VMXNET3_MIN_T0_BUF_SIZE 128 | |
369 | #define VMXNET3_MAX_CSUM_OFFSET 1024 | |
370 | ||
371 | /* Ring base address alignment */ | |
372 | #define VMXNET3_RING_BA_ALIGN 512 | |
373 | #define VMXNET3_RING_BA_MASK (VMXNET3_RING_BA_ALIGN - 1) | |
374 | ||
375 | /* Ring size must be a multiple of 32 */ | |
376 | #define VMXNET3_RING_SIZE_ALIGN 32 | |
377 | #define VMXNET3_RING_SIZE_MASK (VMXNET3_RING_SIZE_ALIGN - 1) | |
378 | ||
379 | /* Max ring size */ | |
380 | #define VMXNET3_TX_RING_MAX_SIZE 4096 | |
381 | #define VMXNET3_TC_RING_MAX_SIZE 4096 | |
382 | #define VMXNET3_RX_RING_MAX_SIZE 4096 | |
14112ca5 | 383 | #define VMXNET3_RX_RING2_MAX_SIZE 4096 |
d1a890fa SB |
384 | #define VMXNET3_RC_RING_MAX_SIZE 8192 |
385 | ||
386 | /* a list of reasons for queue stop */ | |
387 | ||
388 | enum { | |
389 | VMXNET3_ERR_NOEOP = 0x80000000, /* cannot find the EOP desc of a pkt */ | |
390 | VMXNET3_ERR_TXD_REUSE = 0x80000001, /* reuse TxDesc before tx completion */ | |
391 | VMXNET3_ERR_BIG_PKT = 0x80000002, /* too many TxDesc for a pkt */ | |
392 | VMXNET3_ERR_DESC_NOT_SPT = 0x80000003, /* descriptor type not supported */ | |
393 | VMXNET3_ERR_SMALL_BUF = 0x80000004, /* type 0 buffer too small */ | |
394 | VMXNET3_ERR_STRESS = 0x80000005, /* stress option firing in vmkernel */ | |
395 | VMXNET3_ERR_SWITCH = 0x80000006, /* mode switch failure */ | |
396 | VMXNET3_ERR_TXD_INVALID = 0x80000007, /* invalid TxDesc */ | |
397 | }; | |
398 | ||
399 | /* completion descriptor types */ | |
400 | #define VMXNET3_CDTYPE_TXCOMP 0 /* Tx Completion Descriptor */ | |
401 | #define VMXNET3_CDTYPE_RXCOMP 3 /* Rx Completion Descriptor */ | |
45dac1d6 | 402 | #define VMXNET3_CDTYPE_RXCOMP_LRO 4 /* Rx Completion Descriptor for LRO */ |
d1a890fa SB |
403 | |
404 | enum { | |
405 | VMXNET3_GOS_BITS_UNK = 0, /* unknown */ | |
406 | VMXNET3_GOS_BITS_32 = 1, | |
407 | VMXNET3_GOS_BITS_64 = 2, | |
408 | }; | |
409 | ||
410 | #define VMXNET3_GOS_TYPE_LINUX 1 | |
411 | ||
412 | ||
413 | struct Vmxnet3_GOSInfo { | |
115924b6 SB |
414 | #ifdef __BIG_ENDIAN_BITFIELD |
415 | u32 gosMisc:10; /* other info about gos */ | |
416 | u32 gosVer:16; /* gos version */ | |
417 | u32 gosType:4; /* which guest */ | |
418 | u32 gosBits:2; /* 32-bit or 64-bit? */ | |
419 | #else | |
420 | u32 gosBits:2; /* 32-bit or 64-bit? */ | |
421 | u32 gosType:4; /* which guest */ | |
422 | u32 gosVer:16; /* gos version */ | |
423 | u32 gosMisc:10; /* other info about gos */ | |
424 | #endif /* __BIG_ENDIAN_BITFIELD */ | |
d1a890fa SB |
425 | }; |
426 | ||
d1a890fa | 427 | struct Vmxnet3_DriverInfo { |
115924b6 | 428 | __le32 version; |
d1a890fa | 429 | struct Vmxnet3_GOSInfo gos; |
115924b6 SB |
430 | __le32 vmxnet3RevSpt; |
431 | __le32 uptVerSpt; | |
d1a890fa SB |
432 | }; |
433 | ||
434 | ||
dd83829e | 435 | #define VMXNET3_REV1_MAGIC 3133079265u |
d1a890fa SB |
436 | |
437 | /* | |
438 | * QueueDescPA must be 128 bytes aligned. It points to an array of | |
439 | * Vmxnet3_TxQueueDesc followed by an array of Vmxnet3_RxQueueDesc. | |
440 | * The number of Vmxnet3_TxQueueDesc/Vmxnet3_RxQueueDesc are specified by | |
441 | * Vmxnet3_MiscConf.numTxQueues/numRxQueues, respectively. | |
442 | */ | |
443 | #define VMXNET3_QUEUE_DESC_ALIGN 128 | |
444 | ||
445 | ||
446 | struct Vmxnet3_MiscConf { | |
447 | struct Vmxnet3_DriverInfo driverInfo; | |
115924b6 SB |
448 | __le64 uptFeatures; |
449 | __le64 ddPA; /* driver data PA */ | |
450 | __le64 queueDescPA; /* queue descriptor table PA */ | |
451 | __le32 ddLen; /* driver data len */ | |
452 | __le32 queueDescLen; /* queue desc. table len in bytes */ | |
453 | __le32 mtu; | |
454 | __le16 maxNumRxSG; | |
d1a890fa SB |
455 | u8 numTxQueues; |
456 | u8 numRxQueues; | |
115924b6 | 457 | __le32 reserved[4]; |
d1a890fa SB |
458 | }; |
459 | ||
460 | ||
461 | struct Vmxnet3_TxQueueConf { | |
115924b6 SB |
462 | __le64 txRingBasePA; |
463 | __le64 dataRingBasePA; | |
464 | __le64 compRingBasePA; | |
465 | __le64 ddPA; /* driver data */ | |
466 | __le64 reserved; | |
467 | __le32 txRingSize; /* # of tx desc */ | |
468 | __le32 dataRingSize; /* # of data desc */ | |
469 | __le32 compRingSize; /* # of comp desc */ | |
470 | __le32 ddLen; /* size of driver data */ | |
d1a890fa SB |
471 | u8 intrIdx; |
472 | u8 _pad[7]; | |
473 | }; | |
474 | ||
475 | ||
476 | struct Vmxnet3_RxQueueConf { | |
115924b6 SB |
477 | __le64 rxRingBasePA[2]; |
478 | __le64 compRingBasePA; | |
479 | __le64 ddPA; /* driver data */ | |
480 | __le64 reserved; | |
481 | __le32 rxRingSize[2]; /* # of rx desc */ | |
482 | __le32 compRingSize; /* # of rx comp desc */ | |
483 | __le32 ddLen; /* size of driver data */ | |
d1a890fa SB |
484 | u8 intrIdx; |
485 | u8 _pad[7]; | |
486 | }; | |
487 | ||
488 | ||
489 | enum vmxnet3_intr_mask_mode { | |
490 | VMXNET3_IMM_AUTO = 0, | |
491 | VMXNET3_IMM_ACTIVE = 1, | |
492 | VMXNET3_IMM_LAZY = 2 | |
493 | }; | |
494 | ||
495 | enum vmxnet3_intr_type { | |
496 | VMXNET3_IT_AUTO = 0, | |
497 | VMXNET3_IT_INTX = 1, | |
498 | VMXNET3_IT_MSI = 2, | |
499 | VMXNET3_IT_MSIX = 3 | |
500 | }; | |
501 | ||
502 | #define VMXNET3_MAX_TX_QUEUES 8 | |
503 | #define VMXNET3_MAX_RX_QUEUES 16 | |
504 | /* addition 1 for events */ | |
505 | #define VMXNET3_MAX_INTRS 25 | |
506 | ||
6929fe8a RZ |
507 | /* value of intrCtrl */ |
508 | #define VMXNET3_IC_DISABLE_ALL 0x1 /* bit 0 */ | |
509 | ||
d1a890fa SB |
510 | |
511 | struct Vmxnet3_IntrConf { | |
512 | bool autoMask; | |
513 | u8 numIntrs; /* # of interrupts */ | |
514 | u8 eventIntrIdx; | |
515 | u8 modLevels[VMXNET3_MAX_INTRS]; /* moderation level for | |
516 | * each intr */ | |
6929fe8a RZ |
517 | __le32 intrCtrl; |
518 | __le32 reserved[2]; | |
d1a890fa SB |
519 | }; |
520 | ||
521 | /* one bit per VLAN ID, the size is in the units of u32 */ | |
522 | #define VMXNET3_VFT_SIZE (4096 / (sizeof(u32) * 8)) | |
523 | ||
524 | ||
525 | struct Vmxnet3_QueueStatus { | |
526 | bool stopped; | |
527 | u8 _pad[3]; | |
115924b6 | 528 | __le32 error; |
d1a890fa SB |
529 | }; |
530 | ||
531 | ||
532 | struct Vmxnet3_TxQueueCtrl { | |
115924b6 SB |
533 | __le32 txNumDeferred; |
534 | __le32 txThreshold; | |
535 | __le64 reserved; | |
d1a890fa SB |
536 | }; |
537 | ||
538 | ||
539 | struct Vmxnet3_RxQueueCtrl { | |
540 | bool updateRxProd; | |
541 | u8 _pad[7]; | |
115924b6 | 542 | __le64 reserved; |
d1a890fa SB |
543 | }; |
544 | ||
545 | enum { | |
546 | VMXNET3_RXM_UCAST = 0x01, /* unicast only */ | |
547 | VMXNET3_RXM_MCAST = 0x02, /* multicast passing the filters */ | |
548 | VMXNET3_RXM_BCAST = 0x04, /* broadcast only */ | |
549 | VMXNET3_RXM_ALL_MULTI = 0x08, /* all multicast */ | |
550 | VMXNET3_RXM_PROMISC = 0x10 /* promiscuous */ | |
551 | }; | |
552 | ||
553 | struct Vmxnet3_RxFilterConf { | |
115924b6 SB |
554 | __le32 rxMode; /* VMXNET3_RXM_xxx */ |
555 | __le16 mfTableLen; /* size of the multicast filter table */ | |
556 | __le16 _pad1; | |
557 | __le64 mfTablePA; /* PA of the multicast filters table */ | |
558 | __le32 vfTable[VMXNET3_VFT_SIZE]; /* vlan filter */ | |
d1a890fa SB |
559 | }; |
560 | ||
561 | ||
562 | #define VMXNET3_PM_MAX_FILTERS 6 | |
563 | #define VMXNET3_PM_MAX_PATTERN_SIZE 128 | |
564 | #define VMXNET3_PM_MAX_MASK_SIZE (VMXNET3_PM_MAX_PATTERN_SIZE / 8) | |
565 | ||
3843e515 HH |
566 | #define VMXNET3_PM_WAKEUP_MAGIC cpu_to_le16(0x01) /* wake up on magic pkts */ |
567 | #define VMXNET3_PM_WAKEUP_FILTER cpu_to_le16(0x02) /* wake up on pkts matching | |
568 | * filters */ | |
d1a890fa SB |
569 | |
570 | ||
571 | struct Vmxnet3_PM_PktFilter { | |
572 | u8 maskSize; | |
573 | u8 patternSize; | |
574 | u8 mask[VMXNET3_PM_MAX_MASK_SIZE]; | |
575 | u8 pattern[VMXNET3_PM_MAX_PATTERN_SIZE]; | |
576 | u8 pad[6]; | |
577 | }; | |
578 | ||
579 | ||
580 | struct Vmxnet3_PMConf { | |
115924b6 | 581 | __le16 wakeUpEvents; /* VMXNET3_PM_WAKEUP_xxx */ |
d1a890fa SB |
582 | u8 numFilters; |
583 | u8 pad[5]; | |
584 | struct Vmxnet3_PM_PktFilter filters[VMXNET3_PM_MAX_FILTERS]; | |
585 | }; | |
586 | ||
587 | ||
588 | struct Vmxnet3_VariableLenConfDesc { | |
115924b6 SB |
589 | __le32 confVer; |
590 | __le32 confLen; | |
591 | __le64 confPA; | |
d1a890fa SB |
592 | }; |
593 | ||
594 | ||
595 | struct Vmxnet3_TxQueueDesc { | |
596 | struct Vmxnet3_TxQueueCtrl ctrl; | |
597 | struct Vmxnet3_TxQueueConf conf; | |
598 | ||
599 | /* Driver read after a GET command */ | |
600 | struct Vmxnet3_QueueStatus status; | |
601 | struct UPT1_TxStats stats; | |
602 | u8 _pad[88]; /* 128 aligned */ | |
603 | }; | |
604 | ||
605 | ||
606 | struct Vmxnet3_RxQueueDesc { | |
607 | struct Vmxnet3_RxQueueCtrl ctrl; | |
608 | struct Vmxnet3_RxQueueConf conf; | |
609 | /* Driver read after a GET commad */ | |
610 | struct Vmxnet3_QueueStatus status; | |
611 | struct UPT1_RxStats stats; | |
612 | u8 __pad[88]; /* 128 aligned */ | |
613 | }; | |
614 | ||
615 | ||
616 | struct Vmxnet3_DSDevRead { | |
617 | /* read-only region for device, read by dev in response to a SET cmd */ | |
618 | struct Vmxnet3_MiscConf misc; | |
619 | struct Vmxnet3_IntrConf intrConf; | |
620 | struct Vmxnet3_RxFilterConf rxFilterConf; | |
621 | struct Vmxnet3_VariableLenConfDesc rssConfDesc; | |
622 | struct Vmxnet3_VariableLenConfDesc pmConfDesc; | |
623 | struct Vmxnet3_VariableLenConfDesc pluginConfDesc; | |
624 | }; | |
625 | ||
626 | /* All structures in DriverShared are padded to multiples of 8 bytes */ | |
627 | struct Vmxnet3_DriverShared { | |
115924b6 | 628 | __le32 magic; |
d1a890fa | 629 | /* make devRead start at 64bit boundaries */ |
115924b6 SB |
630 | __le32 pad; |
631 | struct Vmxnet3_DSDevRead devRead; | |
632 | __le32 ecr; | |
633 | __le32 reserved[5]; | |
d1a890fa SB |
634 | }; |
635 | ||
636 | ||
637 | #define VMXNET3_ECR_RQERR (1 << 0) | |
638 | #define VMXNET3_ECR_TQERR (1 << 1) | |
639 | #define VMXNET3_ECR_LINK (1 << 2) | |
640 | #define VMXNET3_ECR_DIC (1 << 3) | |
641 | #define VMXNET3_ECR_DEBUG (1 << 4) | |
642 | ||
643 | /* flip the gen bit of a ring */ | |
644 | #define VMXNET3_FLIP_RING_GEN(gen) ((gen) = (gen) ^ 0x1) | |
645 | ||
646 | /* only use this if moving the idx won't affect the gen bit */ | |
647 | #define VMXNET3_INC_RING_IDX_ONLY(idx, ring_size) \ | |
648 | do {\ | |
649 | (idx)++;\ | |
650 | if (unlikely((idx) == (ring_size))) {\ | |
651 | (idx) = 0;\ | |
652 | } \ | |
653 | } while (0) | |
654 | ||
655 | #define VMXNET3_SET_VFTABLE_ENTRY(vfTable, vid) \ | |
656 | (vfTable[vid >> 5] |= (1 << (vid & 31))) | |
657 | #define VMXNET3_CLEAR_VFTABLE_ENTRY(vfTable, vid) \ | |
658 | (vfTable[vid >> 5] &= ~(1 << (vid & 31))) | |
659 | ||
660 | #define VMXNET3_VFTABLE_ENTRY_IS_SET(vfTable, vid) \ | |
661 | ((vfTable[vid >> 5] & (1 << (vid & 31))) != 0) | |
662 | ||
663 | #define VMXNET3_MAX_MTU 9000 | |
664 | #define VMXNET3_MIN_MTU 60 | |
665 | ||
666 | #define VMXNET3_LINK_UP (10000 << 16 | 1) /* 10 Gbps, up */ | |
667 | #define VMXNET3_LINK_DOWN 0 | |
668 | ||
669 | #endif /* _VMXNET3_DEFS_H_ */ |