blob: a26a69df0e3daa0d2a6da290fed3a861b4145928 [file] [log] [blame]
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -07001/*
2 * Linux driver for VMware's vmxnet3 ethernet NIC.
3 *
Shrikrishna Khare190af102016-06-16 10:51:53 -07004 * Copyright (C) 2008-2016, VMware, Inc. All Rights Reserved.
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -07005 *
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 *
Shrikrishna Khare190af102016-06-16 10:51:53 -070023 * Maintained by: pv-drivers@vmware.com
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -070024 *
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 */
34enum {
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 */
47enum {
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
67enum {
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,
Shrikrishna Khare190af102016-06-16 10:51:53 -070079 VMXNET3_CMD_RESERVED1,
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -070080 VMXNET3_CMD_LOAD_PLUGIN,
Shrikrishna Khare190af102016-06-16 10:51:53 -070081 VMXNET3_CMD_RESERVED2,
Shrikrishna Kharef35c7482016-06-16 10:51:54 -070082 VMXNET3_CMD_RESERVED3,
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -070083
84 VMXNET3_CMD_FIRST_GET = 0xF00D0000,
85 VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
86 VMXNET3_CMD_GET_STATS,
87 VMXNET3_CMD_GET_LINK,
88 VMXNET3_CMD_GET_PERM_MAC_LO,
89 VMXNET3_CMD_GET_PERM_MAC_HI,
90 VMXNET3_CMD_GET_DID_LO,
91 VMXNET3_CMD_GET_DID_HI,
92 VMXNET3_CMD_GET_DEV_EXTRA_INFO,
Shrikrishna Khare190af102016-06-16 10:51:53 -070093 VMXNET3_CMD_GET_CONF_INTR,
94 VMXNET3_CMD_GET_RESERVED1,
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -070095};
96
Shreyas Bhatewara115924b2009-11-16 13:41:33 +000097/*
98 * Little Endian layout of bitfields -
99 * Byte 0 : 7.....len.....0
100 * Byte 1 : rsvd gen 13.len.8
101 * Byte 2 : 5.msscof.0 ext1 dtype
102 * Byte 3 : 13...msscof...6
103 *
104 * Big Endian layout of bitfields -
105 * Byte 0: 13...msscof...6
106 * Byte 1 : 5.msscof.0 ext1 dtype
107 * Byte 2 : rsvd gen 13.len.8
108 * Byte 3 : 7.....len.....0
109 *
110 * Thus, le32_to_cpu on the dword will allow the big endian driver to read
111 * the bit fields correctly. And cpu_to_le32 will convert bitfields
112 * bit fields written by big endian driver to format required by device.
113 */
114
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700115struct Vmxnet3_TxDesc {
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000116 __le64 addr;
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700117
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000118#ifdef __BIG_ENDIAN_BITFIELD
119 u32 msscof:14; /* MSS, checksum offset, flags */
120 u32 ext1:1;
121 u32 dtype:1; /* descriptor type */
122 u32 rsvd:1;
123 u32 gen:1; /* generation bit */
124 u32 len:14;
125#else
126 u32 len:14;
127 u32 gen:1; /* generation bit */
128 u32 rsvd:1;
129 u32 dtype:1; /* descriptor type */
130 u32 ext1:1;
131 u32 msscof:14; /* MSS, checksum offset, flags */
132#endif /* __BIG_ENDIAN_BITFIELD */
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700133
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000134#ifdef __BIG_ENDIAN_BITFIELD
135 u32 tci:16; /* Tag to Insert */
136 u32 ti:1; /* VLAN Tag Insertion */
137 u32 ext2:1;
138 u32 cq:1; /* completion request */
139 u32 eop:1; /* End Of Packet */
140 u32 om:2; /* offload mode */
141 u32 hlen:10; /* header len */
142#else
143 u32 hlen:10; /* header len */
144 u32 om:2; /* offload mode */
145 u32 eop:1; /* End Of Packet */
146 u32 cq:1; /* completion request */
147 u32 ext2:1;
148 u32 ti:1; /* VLAN Tag Insertion */
149 u32 tci:16; /* Tag to Insert */
150#endif /* __BIG_ENDIAN_BITFIELD */
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700151};
152
153/* TxDesc.OM values */
154#define VMXNET3_OM_NONE 0
155#define VMXNET3_OM_CSUM 2
156#define VMXNET3_OM_TSO 3
157
158/* fields in TxDesc we access w/o using bit fields */
159#define VMXNET3_TXD_EOP_SHIFT 12
160#define VMXNET3_TXD_CQ_SHIFT 13
161#define VMXNET3_TXD_GEN_SHIFT 14
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000162#define VMXNET3_TXD_EOP_DWORD_SHIFT 3
163#define VMXNET3_TXD_GEN_DWORD_SHIFT 2
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700164
165#define VMXNET3_TXD_CQ (1 << VMXNET3_TXD_CQ_SHIFT)
166#define VMXNET3_TXD_EOP (1 << VMXNET3_TXD_EOP_SHIFT)
167#define VMXNET3_TXD_GEN (1 << VMXNET3_TXD_GEN_SHIFT)
168
169#define VMXNET3_HDR_COPY_SIZE 128
170
171
172struct Vmxnet3_TxDataDesc {
173 u8 data[VMXNET3_HDR_COPY_SIZE];
174};
175
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000176#define VMXNET3_TCD_GEN_SHIFT 31
177#define VMXNET3_TCD_GEN_SIZE 1
178#define VMXNET3_TCD_TXIDX_SHIFT 0
179#define VMXNET3_TCD_TXIDX_SIZE 12
180#define VMXNET3_TCD_GEN_DWORD_SHIFT 3
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700181
182struct Vmxnet3_TxCompDesc {
183 u32 txdIdx:12; /* Index of the EOP TxDesc */
184 u32 ext1:20;
185
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000186 __le32 ext2;
187 __le32 ext3;
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700188
189 u32 rsvd:24;
190 u32 type:7; /* completion type */
191 u32 gen:1; /* generation bit */
192};
193
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700194struct Vmxnet3_RxDesc {
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000195 __le64 addr;
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700196
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000197#ifdef __BIG_ENDIAN_BITFIELD
198 u32 gen:1; /* Generation bit */
199 u32 rsvd:15;
200 u32 dtype:1; /* Descriptor type */
201 u32 btype:1; /* Buffer Type */
202 u32 len:14;
203#else
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700204 u32 len:14;
205 u32 btype:1; /* Buffer Type */
206 u32 dtype:1; /* Descriptor type */
207 u32 rsvd:15;
208 u32 gen:1; /* Generation bit */
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000209#endif
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700210 u32 ext1;
211};
212
213/* values of RXD.BTYPE */
214#define VMXNET3_RXD_BTYPE_HEAD 0 /* head only */
215#define VMXNET3_RXD_BTYPE_BODY 1 /* body only */
216
217/* fields in RxDesc we access w/o using bit fields */
218#define VMXNET3_RXD_BTYPE_SHIFT 14
219#define VMXNET3_RXD_GEN_SHIFT 31
220
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700221struct Vmxnet3_RxCompDesc {
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000222#ifdef __BIG_ENDIAN_BITFIELD
223 u32 ext2:1;
224 u32 cnc:1; /* Checksum Not Calculated */
225 u32 rssType:4; /* RSS hash type used */
226 u32 rqID:10; /* rx queue/ring ID */
227 u32 sop:1; /* Start of Packet */
228 u32 eop:1; /* End of Packet */
229 u32 ext1:2;
230 u32 rxdIdx:12; /* Index of the RxDesc */
231#else
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700232 u32 rxdIdx:12; /* Index of the RxDesc */
233 u32 ext1:2;
234 u32 eop:1; /* End of Packet */
235 u32 sop:1; /* Start of Packet */
236 u32 rqID:10; /* rx queue/ring ID */
237 u32 rssType:4; /* RSS hash type used */
238 u32 cnc:1; /* Checksum Not Calculated */
239 u32 ext2:1;
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000240#endif /* __BIG_ENDIAN_BITFIELD */
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700241
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000242 __le32 rssHash; /* RSS hash value */
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700243
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000244#ifdef __BIG_ENDIAN_BITFIELD
245 u32 tci:16; /* Tag stripped */
246 u32 ts:1; /* Tag is stripped */
247 u32 err:1; /* Error */
248 u32 len:14; /* data length */
249#else
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700250 u32 len:14; /* data length */
251 u32 err:1; /* Error */
252 u32 ts:1; /* Tag is stripped */
253 u32 tci:16; /* Tag stripped */
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000254#endif /* __BIG_ENDIAN_BITFIELD */
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700255
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000256
257#ifdef __BIG_ENDIAN_BITFIELD
258 u32 gen:1; /* generation bit */
259 u32 type:7; /* completion type */
260 u32 fcs:1; /* Frame CRC correct */
261 u32 frg:1; /* IP Fragment */
262 u32 v4:1; /* IPv4 */
263 u32 v6:1; /* IPv6 */
264 u32 ipc:1; /* IP Checksum Correct */
265 u32 tcp:1; /* TCP packet */
266 u32 udp:1; /* UDP packet */
267 u32 tuc:1; /* TCP/UDP Checksum Correct */
268 u32 csum:16;
269#else
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700270 u32 csum:16;
271 u32 tuc:1; /* TCP/UDP Checksum Correct */
272 u32 udp:1; /* UDP packet */
273 u32 tcp:1; /* TCP packet */
274 u32 ipc:1; /* IP Checksum Correct */
275 u32 v6:1; /* IPv6 */
276 u32 v4:1; /* IPv4 */
277 u32 frg:1; /* IP Fragment */
278 u32 fcs:1; /* Frame CRC correct */
279 u32 type:7; /* completion type */
280 u32 gen:1; /* generation bit */
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000281#endif /* __BIG_ENDIAN_BITFIELD */
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700282};
283
Shreyas Bhatewara45dac1d2015-06-19 13:38:29 -0700284struct Vmxnet3_RxCompDescExt {
285 __le32 dword1;
286 u8 segCnt; /* Number of aggregated packets */
287 u8 dupAckCnt; /* Number of duplicate Acks */
288 __le16 tsDelta; /* TCP timestamp difference */
289 __le32 dword2;
290#ifdef __BIG_ENDIAN_BITFIELD
291 u32 gen:1; /* generation bit */
292 u32 type:7; /* completion type */
293 u32 fcs:1; /* Frame CRC correct */
294 u32 frg:1; /* IP Fragment */
295 u32 v4:1; /* IPv4 */
296 u32 v6:1; /* IPv6 */
297 u32 ipc:1; /* IP Checksum Correct */
298 u32 tcp:1; /* TCP packet */
299 u32 udp:1; /* UDP packet */
300 u32 tuc:1; /* TCP/UDP Checksum Correct */
301 u32 mss:16;
302#else
303 u32 mss:16;
304 u32 tuc:1; /* TCP/UDP Checksum Correct */
305 u32 udp:1; /* UDP packet */
306 u32 tcp:1; /* TCP packet */
307 u32 ipc:1; /* IP Checksum Correct */
308 u32 v6:1; /* IPv6 */
309 u32 v4:1; /* IPv4 */
310 u32 frg:1; /* IP Fragment */
311 u32 fcs:1; /* Frame CRC correct */
312 u32 type:7; /* completion type */
313 u32 gen:1; /* generation bit */
314#endif /* __BIG_ENDIAN_BITFIELD */
315};
316
317
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700318/* fields in RxCompDesc we access via Vmxnet3_GenericDesc.dword[3] */
319#define VMXNET3_RCD_TUC_SHIFT 16
320#define VMXNET3_RCD_IPC_SHIFT 19
321
322/* fields in RxCompDesc we access via Vmxnet3_GenericDesc.qword[1] */
323#define VMXNET3_RCD_TYPE_SHIFT 56
324#define VMXNET3_RCD_GEN_SHIFT 63
325
326/* csum OK for TCP/UDP pkts over IP */
327#define VMXNET3_RCD_CSUM_OK (1 << VMXNET3_RCD_TUC_SHIFT | \
328 1 << VMXNET3_RCD_IPC_SHIFT)
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000329#define VMXNET3_TXD_GEN_SIZE 1
330#define VMXNET3_TXD_EOP_SIZE 1
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700331
332/* value of RxCompDesc.rssType */
333enum {
334 VMXNET3_RCD_RSS_TYPE_NONE = 0,
335 VMXNET3_RCD_RSS_TYPE_IPV4 = 1,
336 VMXNET3_RCD_RSS_TYPE_TCPIPV4 = 2,
337 VMXNET3_RCD_RSS_TYPE_IPV6 = 3,
338 VMXNET3_RCD_RSS_TYPE_TCPIPV6 = 4,
339};
340
341
342/* a union for accessing all cmd/completion descriptors */
343union Vmxnet3_GenericDesc {
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000344 __le64 qword[2];
345 __le32 dword[4];
346 __le16 word[8];
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700347 struct Vmxnet3_TxDesc txd;
348 struct Vmxnet3_RxDesc rxd;
349 struct Vmxnet3_TxCompDesc tcd;
350 struct Vmxnet3_RxCompDesc rcd;
Shreyas Bhatewara45dac1d2015-06-19 13:38:29 -0700351 struct Vmxnet3_RxCompDescExt rcdExt;
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700352};
353
354#define VMXNET3_INIT_GEN 1
355
356/* Max size of a single tx buffer */
357#define VMXNET3_MAX_TX_BUF_SIZE (1 << 14)
358
359/* # of tx desc needed for a tx buffer size */
360#define VMXNET3_TXD_NEEDED(size) (((size) + VMXNET3_MAX_TX_BUF_SIZE - 1) / \
361 VMXNET3_MAX_TX_BUF_SIZE)
362
363/* max # of tx descs for a non-tso pkt */
364#define VMXNET3_MAX_TXD_PER_PKT 16
365
366/* Max size of a single rx buffer */
367#define VMXNET3_MAX_RX_BUF_SIZE ((1 << 14) - 1)
368/* Minimum size of a type 0 buffer */
369#define VMXNET3_MIN_T0_BUF_SIZE 128
370#define VMXNET3_MAX_CSUM_OFFSET 1024
371
372/* Ring base address alignment */
373#define VMXNET3_RING_BA_ALIGN 512
374#define VMXNET3_RING_BA_MASK (VMXNET3_RING_BA_ALIGN - 1)
375
376/* Ring size must be a multiple of 32 */
377#define VMXNET3_RING_SIZE_ALIGN 32
378#define VMXNET3_RING_SIZE_MASK (VMXNET3_RING_SIZE_ALIGN - 1)
379
380/* Max ring size */
381#define VMXNET3_TX_RING_MAX_SIZE 4096
382#define VMXNET3_TC_RING_MAX_SIZE 4096
383#define VMXNET3_RX_RING_MAX_SIZE 4096
Shrikrishna Khare14112ca2016-02-19 11:19:52 -0800384#define VMXNET3_RX_RING2_MAX_SIZE 4096
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700385#define VMXNET3_RC_RING_MAX_SIZE 8192
386
387/* a list of reasons for queue stop */
388
389enum {
390 VMXNET3_ERR_NOEOP = 0x80000000, /* cannot find the EOP desc of a pkt */
391 VMXNET3_ERR_TXD_REUSE = 0x80000001, /* reuse TxDesc before tx completion */
392 VMXNET3_ERR_BIG_PKT = 0x80000002, /* too many TxDesc for a pkt */
393 VMXNET3_ERR_DESC_NOT_SPT = 0x80000003, /* descriptor type not supported */
394 VMXNET3_ERR_SMALL_BUF = 0x80000004, /* type 0 buffer too small */
395 VMXNET3_ERR_STRESS = 0x80000005, /* stress option firing in vmkernel */
396 VMXNET3_ERR_SWITCH = 0x80000006, /* mode switch failure */
397 VMXNET3_ERR_TXD_INVALID = 0x80000007, /* invalid TxDesc */
398};
399
400/* completion descriptor types */
401#define VMXNET3_CDTYPE_TXCOMP 0 /* Tx Completion Descriptor */
402#define VMXNET3_CDTYPE_RXCOMP 3 /* Rx Completion Descriptor */
Shreyas Bhatewara45dac1d2015-06-19 13:38:29 -0700403#define VMXNET3_CDTYPE_RXCOMP_LRO 4 /* Rx Completion Descriptor for LRO */
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700404
405enum {
406 VMXNET3_GOS_BITS_UNK = 0, /* unknown */
407 VMXNET3_GOS_BITS_32 = 1,
408 VMXNET3_GOS_BITS_64 = 2,
409};
410
411#define VMXNET3_GOS_TYPE_LINUX 1
412
413
414struct Vmxnet3_GOSInfo {
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000415#ifdef __BIG_ENDIAN_BITFIELD
416 u32 gosMisc:10; /* other info about gos */
417 u32 gosVer:16; /* gos version */
418 u32 gosType:4; /* which guest */
419 u32 gosBits:2; /* 32-bit or 64-bit? */
420#else
421 u32 gosBits:2; /* 32-bit or 64-bit? */
422 u32 gosType:4; /* which guest */
423 u32 gosVer:16; /* gos version */
424 u32 gosMisc:10; /* other info about gos */
425#endif /* __BIG_ENDIAN_BITFIELD */
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700426};
427
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700428struct Vmxnet3_DriverInfo {
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000429 __le32 version;
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700430 struct Vmxnet3_GOSInfo gos;
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000431 __le32 vmxnet3RevSpt;
432 __le32 uptVerSpt;
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700433};
434
435
Shrikrishna Kharedd838292015-02-06 13:48:28 -0800436#define VMXNET3_REV1_MAGIC 3133079265u
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700437
438/*
439 * QueueDescPA must be 128 bytes aligned. It points to an array of
440 * Vmxnet3_TxQueueDesc followed by an array of Vmxnet3_RxQueueDesc.
441 * The number of Vmxnet3_TxQueueDesc/Vmxnet3_RxQueueDesc are specified by
442 * Vmxnet3_MiscConf.numTxQueues/numRxQueues, respectively.
443 */
444#define VMXNET3_QUEUE_DESC_ALIGN 128
445
446
447struct Vmxnet3_MiscConf {
448 struct Vmxnet3_DriverInfo driverInfo;
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000449 __le64 uptFeatures;
450 __le64 ddPA; /* driver data PA */
451 __le64 queueDescPA; /* queue descriptor table PA */
452 __le32 ddLen; /* driver data len */
453 __le32 queueDescLen; /* queue desc. table len in bytes */
454 __le32 mtu;
455 __le16 maxNumRxSG;
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700456 u8 numTxQueues;
457 u8 numRxQueues;
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000458 __le32 reserved[4];
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700459};
460
461
462struct Vmxnet3_TxQueueConf {
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000463 __le64 txRingBasePA;
464 __le64 dataRingBasePA;
465 __le64 compRingBasePA;
466 __le64 ddPA; /* driver data */
467 __le64 reserved;
468 __le32 txRingSize; /* # of tx desc */
469 __le32 dataRingSize; /* # of data desc */
470 __le32 compRingSize; /* # of comp desc */
471 __le32 ddLen; /* size of driver data */
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700472 u8 intrIdx;
473 u8 _pad[7];
474};
475
476
477struct Vmxnet3_RxQueueConf {
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000478 __le64 rxRingBasePA[2];
479 __le64 compRingBasePA;
480 __le64 ddPA; /* driver data */
481 __le64 reserved;
482 __le32 rxRingSize[2]; /* # of rx desc */
483 __le32 compRingSize; /* # of rx comp desc */
484 __le32 ddLen; /* size of driver data */
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700485 u8 intrIdx;
486 u8 _pad[7];
487};
488
489
490enum vmxnet3_intr_mask_mode {
491 VMXNET3_IMM_AUTO = 0,
492 VMXNET3_IMM_ACTIVE = 1,
493 VMXNET3_IMM_LAZY = 2
494};
495
496enum vmxnet3_intr_type {
497 VMXNET3_IT_AUTO = 0,
498 VMXNET3_IT_INTX = 1,
499 VMXNET3_IT_MSI = 2,
500 VMXNET3_IT_MSIX = 3
501};
502
503#define VMXNET3_MAX_TX_QUEUES 8
504#define VMXNET3_MAX_RX_QUEUES 16
505/* addition 1 for events */
506#define VMXNET3_MAX_INTRS 25
507
Ronghua Zang6929fe82010-07-15 22:18:47 -0700508/* value of intrCtrl */
509#define VMXNET3_IC_DISABLE_ALL 0x1 /* bit 0 */
510
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700511
512struct Vmxnet3_IntrConf {
513 bool autoMask;
514 u8 numIntrs; /* # of interrupts */
515 u8 eventIntrIdx;
516 u8 modLevels[VMXNET3_MAX_INTRS]; /* moderation level for
517 * each intr */
Ronghua Zang6929fe82010-07-15 22:18:47 -0700518 __le32 intrCtrl;
519 __le32 reserved[2];
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700520};
521
522/* one bit per VLAN ID, the size is in the units of u32 */
523#define VMXNET3_VFT_SIZE (4096 / (sizeof(u32) * 8))
524
525
526struct Vmxnet3_QueueStatus {
527 bool stopped;
528 u8 _pad[3];
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000529 __le32 error;
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700530};
531
532
533struct Vmxnet3_TxQueueCtrl {
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000534 __le32 txNumDeferred;
535 __le32 txThreshold;
536 __le64 reserved;
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700537};
538
539
540struct Vmxnet3_RxQueueCtrl {
541 bool updateRxProd;
542 u8 _pad[7];
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000543 __le64 reserved;
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700544};
545
546enum {
547 VMXNET3_RXM_UCAST = 0x01, /* unicast only */
548 VMXNET3_RXM_MCAST = 0x02, /* multicast passing the filters */
549 VMXNET3_RXM_BCAST = 0x04, /* broadcast only */
550 VMXNET3_RXM_ALL_MULTI = 0x08, /* all multicast */
551 VMXNET3_RXM_PROMISC = 0x10 /* promiscuous */
552};
553
554struct Vmxnet3_RxFilterConf {
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000555 __le32 rxMode; /* VMXNET3_RXM_xxx */
556 __le16 mfTableLen; /* size of the multicast filter table */
557 __le16 _pad1;
558 __le64 mfTablePA; /* PA of the multicast filters table */
559 __le32 vfTable[VMXNET3_VFT_SIZE]; /* vlan filter */
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700560};
561
562
563#define VMXNET3_PM_MAX_FILTERS 6
564#define VMXNET3_PM_MAX_PATTERN_SIZE 128
565#define VMXNET3_PM_MAX_MASK_SIZE (VMXNET3_PM_MAX_PATTERN_SIZE / 8)
566
Harvey Harrison3843e512010-10-21 18:05:32 +0000567#define VMXNET3_PM_WAKEUP_MAGIC cpu_to_le16(0x01) /* wake up on magic pkts */
568#define VMXNET3_PM_WAKEUP_FILTER cpu_to_le16(0x02) /* wake up on pkts matching
569 * filters */
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700570
571
572struct Vmxnet3_PM_PktFilter {
573 u8 maskSize;
574 u8 patternSize;
575 u8 mask[VMXNET3_PM_MAX_MASK_SIZE];
576 u8 pattern[VMXNET3_PM_MAX_PATTERN_SIZE];
577 u8 pad[6];
578};
579
580
581struct Vmxnet3_PMConf {
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000582 __le16 wakeUpEvents; /* VMXNET3_PM_WAKEUP_xxx */
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700583 u8 numFilters;
584 u8 pad[5];
585 struct Vmxnet3_PM_PktFilter filters[VMXNET3_PM_MAX_FILTERS];
586};
587
588
589struct Vmxnet3_VariableLenConfDesc {
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000590 __le32 confVer;
591 __le32 confLen;
592 __le64 confPA;
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700593};
594
595
596struct Vmxnet3_TxQueueDesc {
597 struct Vmxnet3_TxQueueCtrl ctrl;
598 struct Vmxnet3_TxQueueConf conf;
599
600 /* Driver read after a GET command */
601 struct Vmxnet3_QueueStatus status;
602 struct UPT1_TxStats stats;
603 u8 _pad[88]; /* 128 aligned */
604};
605
606
607struct Vmxnet3_RxQueueDesc {
608 struct Vmxnet3_RxQueueCtrl ctrl;
609 struct Vmxnet3_RxQueueConf conf;
610 /* Driver read after a GET commad */
611 struct Vmxnet3_QueueStatus status;
612 struct UPT1_RxStats stats;
613 u8 __pad[88]; /* 128 aligned */
614};
615
Shrikrishna Kharef35c7482016-06-16 10:51:54 -0700616struct Vmxnet3_SetPolling {
617 u8 enablePolling;
618};
619
620/* If the command data <= 16 bytes, use the shared memory directly.
621 * otherwise, use variable length configuration descriptor.
622 */
623union Vmxnet3_CmdInfo {
624 struct Vmxnet3_VariableLenConfDesc varConf;
625 struct Vmxnet3_SetPolling setPolling;
626 __le64 data[2];
627};
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700628
629struct Vmxnet3_DSDevRead {
630 /* read-only region for device, read by dev in response to a SET cmd */
631 struct Vmxnet3_MiscConf misc;
632 struct Vmxnet3_IntrConf intrConf;
633 struct Vmxnet3_RxFilterConf rxFilterConf;
634 struct Vmxnet3_VariableLenConfDesc rssConfDesc;
635 struct Vmxnet3_VariableLenConfDesc pmConfDesc;
636 struct Vmxnet3_VariableLenConfDesc pluginConfDesc;
637};
638
639/* All structures in DriverShared are padded to multiples of 8 bytes */
640struct Vmxnet3_DriverShared {
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000641 __le32 magic;
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700642 /* make devRead start at 64bit boundaries */
Shreyas Bhatewara115924b2009-11-16 13:41:33 +0000643 __le32 pad;
644 struct Vmxnet3_DSDevRead devRead;
645 __le32 ecr;
Shrikrishna Kharef35c7482016-06-16 10:51:54 -0700646 __le32 reserved;
647 union {
648 __le32 reserved1[4];
649 union Vmxnet3_CmdInfo cmdInfo; /* only valid in the context of
650 * executing the relevant
651 * command
652 */
653 } cu;
Shreyas Bhatewarad1a890fa2009-10-13 00:15:51 -0700654};
655
656
657#define VMXNET3_ECR_RQERR (1 << 0)
658#define VMXNET3_ECR_TQERR (1 << 1)
659#define VMXNET3_ECR_LINK (1 << 2)
660#define VMXNET3_ECR_DIC (1 << 3)
661#define VMXNET3_ECR_DEBUG (1 << 4)
662
663/* flip the gen bit of a ring */
664#define VMXNET3_FLIP_RING_GEN(gen) ((gen) = (gen) ^ 0x1)
665
666/* only use this if moving the idx won't affect the gen bit */
667#define VMXNET3_INC_RING_IDX_ONLY(idx, ring_size) \
668 do {\
669 (idx)++;\
670 if (unlikely((idx) == (ring_size))) {\
671 (idx) = 0;\
672 } \
673 } while (0)
674
675#define VMXNET3_SET_VFTABLE_ENTRY(vfTable, vid) \
676 (vfTable[vid >> 5] |= (1 << (vid & 31)))
677#define VMXNET3_CLEAR_VFTABLE_ENTRY(vfTable, vid) \
678 (vfTable[vid >> 5] &= ~(1 << (vid & 31)))
679
680#define VMXNET3_VFTABLE_ENTRY_IS_SET(vfTable, vid) \
681 ((vfTable[vid >> 5] & (1 << (vid & 31))) != 0)
682
683#define VMXNET3_MAX_MTU 9000
684#define VMXNET3_MIN_MTU 60
685
686#define VMXNET3_LINK_UP (10000 << 16 | 1) /* 10 Gbps, up */
687#define VMXNET3_LINK_DOWN 0
688
689#endif /* _VMXNET3_DEFS_H_ */