aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/vmxnet3/vmxnet3_defs.h
diff options
context:
space:
mode:
authorShreyas Bhatewara <sbhatewara@vmware.com>2009-11-16 08:41:33 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-17 07:08:50 -0500
commit115924b6bdc7cc6bf7da5b933b09281e1f4e17a9 (patch)
tree8d883a13b6dc2b29caa77a6e178e921e4843db1c /drivers/net/vmxnet3/vmxnet3_defs.h
parent649300b9278dc9fc9c7dfaaa3719ead70882e726 (diff)
net: Getting rid of the x86 dependency to built vmxnet3
This patch removes config dependency on x86 to build vmxnet3 driver. Thus the driver can be built on big endian architectures now. Although vmxnet3 is not supported on VMs other than x86 architecture, all this code goes in to ensure correctness. If the code is not dependent on x86, it should not assume little endian architecture in any of its operations. Signed-off-by: Shreyas Bhatewara <sbhatewara@vmware.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/vmxnet3/vmxnet3_defs.h')
-rw-r--r--drivers/net/vmxnet3/vmxnet3_defs.h246
1 files changed, 168 insertions, 78 deletions
diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h b/drivers/net/vmxnet3/vmxnet3_defs.h
index dc8ee4438a4f..b4889e6c4a57 100644
--- a/drivers/net/vmxnet3/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/vmxnet3_defs.h
@@ -90,23 +90,60 @@ enum {
90 VMXNET3_CMD_GET_CONF_INTR 90 VMXNET3_CMD_GET_CONF_INTR
91}; 91};
92 92
93struct Vmxnet3_TxDesc { 93/*
94 u64 addr; 94 * Little Endian layout of bitfields -
95 * Byte 0 : 7.....len.....0
96 * Byte 1 : rsvd gen 13.len.8
97 * Byte 2 : 5.msscof.0 ext1 dtype
98 * Byte 3 : 13...msscof...6
99 *
100 * Big Endian layout of bitfields -
101 * Byte 0: 13...msscof...6
102 * Byte 1 : 5.msscof.0 ext1 dtype
103 * Byte 2 : rsvd gen 13.len.8
104 * Byte 3 : 7.....len.....0
105 *
106 * Thus, le32_to_cpu on the dword will allow the big endian driver to read
107 * the bit fields correctly. And cpu_to_le32 will convert bitfields
108 * bit fields written by big endian driver to format required by device.
109 */
95 110
96 u32 len:14; 111struct Vmxnet3_TxDesc {
97 u32 gen:1; /* generation bit */ 112 __le64 addr;
98 u32 rsvd:1; 113
99 u32 dtype:1; /* descriptor type */ 114#ifdef __BIG_ENDIAN_BITFIELD
100 u32 ext1:1; 115 u32 msscof:14; /* MSS, checksum offset, flags */
101 u32 msscof:14; /* MSS, checksum offset, flags */ 116 u32 ext1:1;
102 117 u32 dtype:1; /* descriptor type */
103 u32 hlen:10; /* header len */ 118 u32 rsvd:1;
104 u32 om:2; /* offload mode */ 119 u32 gen:1; /* generation bit */
105 u32 eop:1; /* End Of Packet */ 120 u32 len:14;
106 u32 cq:1; /* completion request */ 121#else
107 u32 ext2:1; 122 u32 len:14;
108 u32 ti:1; /* VLAN Tag Insertion */ 123 u32 gen:1; /* generation bit */
109 u32 tci:16; /* Tag to Insert */ 124 u32 rsvd:1;
125 u32 dtype:1; /* descriptor type */
126 u32 ext1:1;
127 u32 msscof:14; /* MSS, checksum offset, flags */
128#endif /* __BIG_ENDIAN_BITFIELD */
129
130#ifdef __BIG_ENDIAN_BITFIELD
131 u32 tci:16; /* Tag to Insert */
132 u32 ti:1; /* VLAN Tag Insertion */
133 u32 ext2:1;
134 u32 cq:1; /* completion request */
135 u32 eop:1; /* End Of Packet */
136 u32 om:2; /* offload mode */
137 u32 hlen:10; /* header len */
138#else
139 u32 hlen:10; /* header len */
140 u32 om:2; /* offload mode */
141 u32 eop:1; /* End Of Packet */
142 u32 cq:1; /* completion request */
143 u32 ext2:1;
144 u32 ti:1; /* VLAN Tag Insertion */
145 u32 tci:16; /* Tag to Insert */
146#endif /* __BIG_ENDIAN_BITFIELD */
110}; 147};
111 148
112/* TxDesc.OM values */ 149/* TxDesc.OM values */
@@ -118,6 +155,8 @@ struct Vmxnet3_TxDesc {
118#define VMXNET3_TXD_EOP_SHIFT 12 155#define VMXNET3_TXD_EOP_SHIFT 12
119#define VMXNET3_TXD_CQ_SHIFT 13 156#define VMXNET3_TXD_CQ_SHIFT 13
120#define VMXNET3_TXD_GEN_SHIFT 14 157#define VMXNET3_TXD_GEN_SHIFT 14
158#define VMXNET3_TXD_EOP_DWORD_SHIFT 3
159#define VMXNET3_TXD_GEN_DWORD_SHIFT 2
121 160
122#define VMXNET3_TXD_CQ (1 << VMXNET3_TXD_CQ_SHIFT) 161#define VMXNET3_TXD_CQ (1 << VMXNET3_TXD_CQ_SHIFT)
123#define VMXNET3_TXD_EOP (1 << VMXNET3_TXD_EOP_SHIFT) 162#define VMXNET3_TXD_EOP (1 << VMXNET3_TXD_EOP_SHIFT)
@@ -130,29 +169,40 @@ struct Vmxnet3_TxDataDesc {
130 u8 data[VMXNET3_HDR_COPY_SIZE]; 169 u8 data[VMXNET3_HDR_COPY_SIZE];
131}; 170};
132 171
172#define VMXNET3_TCD_GEN_SHIFT 31
173#define VMXNET3_TCD_GEN_SIZE 1
174#define VMXNET3_TCD_TXIDX_SHIFT 0
175#define VMXNET3_TCD_TXIDX_SIZE 12
176#define VMXNET3_TCD_GEN_DWORD_SHIFT 3
133 177
134struct Vmxnet3_TxCompDesc { 178struct Vmxnet3_TxCompDesc {
135 u32 txdIdx:12; /* Index of the EOP TxDesc */ 179 u32 txdIdx:12; /* Index of the EOP TxDesc */
136 u32 ext1:20; 180 u32 ext1:20;
137 181
138 u32 ext2; 182 __le32 ext2;
139 u32 ext3; 183 __le32 ext3;
140 184
141 u32 rsvd:24; 185 u32 rsvd:24;
142 u32 type:7; /* completion type */ 186 u32 type:7; /* completion type */
143 u32 gen:1; /* generation bit */ 187 u32 gen:1; /* generation bit */
144}; 188};
145 189
146
147struct Vmxnet3_RxDesc { 190struct Vmxnet3_RxDesc {
148 u64 addr; 191 __le64 addr;
149 192
193#ifdef __BIG_ENDIAN_BITFIELD
194 u32 gen:1; /* Generation bit */
195 u32 rsvd:15;
196 u32 dtype:1; /* Descriptor type */
197 u32 btype:1; /* Buffer Type */
198 u32 len:14;
199#else
150 u32 len:14; 200 u32 len:14;
151 u32 btype:1; /* Buffer Type */ 201 u32 btype:1; /* Buffer Type */
152 u32 dtype:1; /* Descriptor type */ 202 u32 dtype:1; /* Descriptor type */
153 u32 rsvd:15; 203 u32 rsvd:15;
154 u32 gen:1; /* Generation bit */ 204 u32 gen:1; /* Generation bit */
155 205#endif
156 u32 ext1; 206 u32 ext1;
157}; 207};
158 208
@@ -164,8 +214,17 @@ struct Vmxnet3_RxDesc {
164#define VMXNET3_RXD_BTYPE_SHIFT 14 214#define VMXNET3_RXD_BTYPE_SHIFT 14
165#define VMXNET3_RXD_GEN_SHIFT 31 215#define VMXNET3_RXD_GEN_SHIFT 31
166 216
167
168struct Vmxnet3_RxCompDesc { 217struct Vmxnet3_RxCompDesc {
218#ifdef __BIG_ENDIAN_BITFIELD
219 u32 ext2:1;
220 u32 cnc:1; /* Checksum Not Calculated */
221 u32 rssType:4; /* RSS hash type used */
222 u32 rqID:10; /* rx queue/ring ID */
223 u32 sop:1; /* Start of Packet */
224 u32 eop:1; /* End of Packet */
225 u32 ext1:2;
226 u32 rxdIdx:12; /* Index of the RxDesc */
227#else
169 u32 rxdIdx:12; /* Index of the RxDesc */ 228 u32 rxdIdx:12; /* Index of the RxDesc */
170 u32 ext1:2; 229 u32 ext1:2;
171 u32 eop:1; /* End of Packet */ 230 u32 eop:1; /* End of Packet */
@@ -174,14 +233,36 @@ struct Vmxnet3_RxCompDesc {
174 u32 rssType:4; /* RSS hash type used */ 233 u32 rssType:4; /* RSS hash type used */
175 u32 cnc:1; /* Checksum Not Calculated */ 234 u32 cnc:1; /* Checksum Not Calculated */
176 u32 ext2:1; 235 u32 ext2:1;
236#endif /* __BIG_ENDIAN_BITFIELD */
177 237
178 u32 rssHash; /* RSS hash value */ 238 __le32 rssHash; /* RSS hash value */
179 239
240#ifdef __BIG_ENDIAN_BITFIELD
241 u32 tci:16; /* Tag stripped */
242 u32 ts:1; /* Tag is stripped */
243 u32 err:1; /* Error */
244 u32 len:14; /* data length */
245#else
180 u32 len:14; /* data length */ 246 u32 len:14; /* data length */
181 u32 err:1; /* Error */ 247 u32 err:1; /* Error */
182 u32 ts:1; /* Tag is stripped */ 248 u32 ts:1; /* Tag is stripped */
183 u32 tci:16; /* Tag stripped */ 249 u32 tci:16; /* Tag stripped */
250#endif /* __BIG_ENDIAN_BITFIELD */
251
184 252
253#ifdef __BIG_ENDIAN_BITFIELD
254 u32 gen:1; /* generation bit */
255 u32 type:7; /* completion type */
256 u32 fcs:1; /* Frame CRC correct */
257 u32 frg:1; /* IP Fragment */
258 u32 v4:1; /* IPv4 */
259 u32 v6:1; /* IPv6 */
260 u32 ipc:1; /* IP Checksum Correct */
261 u32 tcp:1; /* TCP packet */
262 u32 udp:1; /* UDP packet */
263 u32 tuc:1; /* TCP/UDP Checksum Correct */
264 u32 csum:16;
265#else
185 u32 csum:16; 266 u32 csum:16;
186 u32 tuc:1; /* TCP/UDP Checksum Correct */ 267 u32 tuc:1; /* TCP/UDP Checksum Correct */
187 u32 udp:1; /* UDP packet */ 268 u32 udp:1; /* UDP packet */
@@ -193,6 +274,7 @@ struct Vmxnet3_RxCompDesc {
193 u32 fcs:1; /* Frame CRC correct */ 274 u32 fcs:1; /* Frame CRC correct */
194 u32 type:7; /* completion type */ 275 u32 type:7; /* completion type */
195 u32 gen:1; /* generation bit */ 276 u32 gen:1; /* generation bit */
277#endif /* __BIG_ENDIAN_BITFIELD */
196}; 278};
197 279
198/* fields in RxCompDesc we access via Vmxnet3_GenericDesc.dword[3] */ 280/* fields in RxCompDesc we access via Vmxnet3_GenericDesc.dword[3] */
@@ -206,6 +288,8 @@ struct Vmxnet3_RxCompDesc {
206/* csum OK for TCP/UDP pkts over IP */ 288/* csum OK for TCP/UDP pkts over IP */
207#define VMXNET3_RCD_CSUM_OK (1 << VMXNET3_RCD_TUC_SHIFT | \ 289#define VMXNET3_RCD_CSUM_OK (1 << VMXNET3_RCD_TUC_SHIFT | \
208 1 << VMXNET3_RCD_IPC_SHIFT) 290 1 << VMXNET3_RCD_IPC_SHIFT)
291#define VMXNET3_TXD_GEN_SIZE 1
292#define VMXNET3_TXD_EOP_SIZE 1
209 293
210/* value of RxCompDesc.rssType */ 294/* value of RxCompDesc.rssType */
211enum { 295enum {
@@ -219,9 +303,9 @@ enum {
219 303
220/* a union for accessing all cmd/completion descriptors */ 304/* a union for accessing all cmd/completion descriptors */
221union Vmxnet3_GenericDesc { 305union Vmxnet3_GenericDesc {
222 u64 qword[2]; 306 __le64 qword[2];
223 u32 dword[4]; 307 __le32 dword[4];
224 u16 word[8]; 308 __le16 word[8];
225 struct Vmxnet3_TxDesc txd; 309 struct Vmxnet3_TxDesc txd;
226 struct Vmxnet3_RxDesc rxd; 310 struct Vmxnet3_RxDesc rxd;
227 struct Vmxnet3_TxCompDesc tcd; 311 struct Vmxnet3_TxCompDesc tcd;
@@ -287,18 +371,24 @@ enum {
287 371
288 372
289struct Vmxnet3_GOSInfo { 373struct Vmxnet3_GOSInfo {
290 u32 gosBits:2; /* 32-bit or 64-bit? */ 374#ifdef __BIG_ENDIAN_BITFIELD
291 u32 gosType:4; /* which guest */ 375 u32 gosMisc:10; /* other info about gos */
292 u32 gosVer:16; /* gos version */ 376 u32 gosVer:16; /* gos version */
293 u32 gosMisc:10; /* other info about gos */ 377 u32 gosType:4; /* which guest */
378 u32 gosBits:2; /* 32-bit or 64-bit? */
379#else
380 u32 gosBits:2; /* 32-bit or 64-bit? */
381 u32 gosType:4; /* which guest */
382 u32 gosVer:16; /* gos version */
383 u32 gosMisc:10; /* other info about gos */
384#endif /* __BIG_ENDIAN_BITFIELD */
294}; 385};
295 386
296
297struct Vmxnet3_DriverInfo { 387struct Vmxnet3_DriverInfo {
298 u32 version; 388 __le32 version;
299 struct Vmxnet3_GOSInfo gos; 389 struct Vmxnet3_GOSInfo gos;
300 u32 vmxnet3RevSpt; 390 __le32 vmxnet3RevSpt;
301 u32 uptVerSpt; 391 __le32 uptVerSpt;
302}; 392};
303 393
304 394
@@ -315,42 +405,42 @@ struct Vmxnet3_DriverInfo {
315 405
316struct Vmxnet3_MiscConf { 406struct Vmxnet3_MiscConf {
317 struct Vmxnet3_DriverInfo driverInfo; 407 struct Vmxnet3_DriverInfo driverInfo;
318 u64 uptFeatures; 408 __le64 uptFeatures;
319 u64 ddPA; /* driver data PA */ 409 __le64 ddPA; /* driver data PA */
320 u64 queueDescPA; /* queue descriptor table PA */ 410 __le64 queueDescPA; /* queue descriptor table PA */
321 u32 ddLen; /* driver data len */ 411 __le32 ddLen; /* driver data len */
322 u32 queueDescLen; /* queue desc. table len in bytes */ 412 __le32 queueDescLen; /* queue desc. table len in bytes */
323 u32 mtu; 413 __le32 mtu;
324 u16 maxNumRxSG; 414 __le16 maxNumRxSG;
325 u8 numTxQueues; 415 u8 numTxQueues;
326 u8 numRxQueues; 416 u8 numRxQueues;
327 u32 reserved[4]; 417 __le32 reserved[4];
328}; 418};
329 419
330 420
331struct Vmxnet3_TxQueueConf { 421struct Vmxnet3_TxQueueConf {
332 u64 txRingBasePA; 422 __le64 txRingBasePA;
333 u64 dataRingBasePA; 423 __le64 dataRingBasePA;
334 u64 compRingBasePA; 424 __le64 compRingBasePA;
335 u64 ddPA; /* driver data */ 425 __le64 ddPA; /* driver data */
336 u64 reserved; 426 __le64 reserved;
337 u32 txRingSize; /* # of tx desc */ 427 __le32 txRingSize; /* # of tx desc */
338 u32 dataRingSize; /* # of data desc */ 428 __le32 dataRingSize; /* # of data desc */
339 u32 compRingSize; /* # of comp desc */ 429 __le32 compRingSize; /* # of comp desc */
340 u32 ddLen; /* size of driver data */ 430 __le32 ddLen; /* size of driver data */
341 u8 intrIdx; 431 u8 intrIdx;
342 u8 _pad[7]; 432 u8 _pad[7];
343}; 433};
344 434
345 435
346struct Vmxnet3_RxQueueConf { 436struct Vmxnet3_RxQueueConf {
347 u64 rxRingBasePA[2]; 437 __le64 rxRingBasePA[2];
348 u64 compRingBasePA; 438 __le64 compRingBasePA;
349 u64 ddPA; /* driver data */ 439 __le64 ddPA; /* driver data */
350 u64 reserved; 440 __le64 reserved;
351 u32 rxRingSize[2]; /* # of rx desc */ 441 __le32 rxRingSize[2]; /* # of rx desc */
352 u32 compRingSize; /* # of rx comp desc */ 442 __le32 compRingSize; /* # of rx comp desc */
353 u32 ddLen; /* size of driver data */ 443 __le32 ddLen; /* size of driver data */
354 u8 intrIdx; 444 u8 intrIdx;
355 u8 _pad[7]; 445 u8 _pad[7];
356}; 446};
@@ -381,7 +471,7 @@ struct Vmxnet3_IntrConf {
381 u8 eventIntrIdx; 471 u8 eventIntrIdx;
382 u8 modLevels[VMXNET3_MAX_INTRS]; /* moderation level for 472 u8 modLevels[VMXNET3_MAX_INTRS]; /* moderation level for
383 * each intr */ 473 * each intr */
384 u32 reserved[3]; 474 __le32 reserved[3];
385}; 475};
386 476
387/* one bit per VLAN ID, the size is in the units of u32 */ 477/* one bit per VLAN ID, the size is in the units of u32 */
@@ -391,21 +481,21 @@ struct Vmxnet3_IntrConf {
391struct Vmxnet3_QueueStatus { 481struct Vmxnet3_QueueStatus {
392 bool stopped; 482 bool stopped;
393 u8 _pad[3]; 483 u8 _pad[3];
394 u32 error; 484 __le32 error;
395}; 485};
396 486
397 487
398struct Vmxnet3_TxQueueCtrl { 488struct Vmxnet3_TxQueueCtrl {
399 u32 txNumDeferred; 489 __le32 txNumDeferred;
400 u32 txThreshold; 490 __le32 txThreshold;
401 u64 reserved; 491 __le64 reserved;
402}; 492};
403 493
404 494
405struct Vmxnet3_RxQueueCtrl { 495struct Vmxnet3_RxQueueCtrl {
406 bool updateRxProd; 496 bool updateRxProd;
407 u8 _pad[7]; 497 u8 _pad[7];
408 u64 reserved; 498 __le64 reserved;
409}; 499};
410 500
411enum { 501enum {
@@ -417,11 +507,11 @@ enum {
417}; 507};
418 508
419struct Vmxnet3_RxFilterConf { 509struct Vmxnet3_RxFilterConf {
420 u32 rxMode; /* VMXNET3_RXM_xxx */ 510 __le32 rxMode; /* VMXNET3_RXM_xxx */
421 u16 mfTableLen; /* size of the multicast filter table */ 511 __le16 mfTableLen; /* size of the multicast filter table */
422 u16 _pad1; 512 __le16 _pad1;
423 u64 mfTablePA; /* PA of the multicast filters table */ 513 __le64 mfTablePA; /* PA of the multicast filters table */
424 u32 vfTable[VMXNET3_VFT_SIZE]; /* vlan filter */ 514 __le32 vfTable[VMXNET3_VFT_SIZE]; /* vlan filter */
425}; 515};
426 516
427 517
@@ -444,7 +534,7 @@ struct Vmxnet3_PM_PktFilter {
444 534
445 535
446struct Vmxnet3_PMConf { 536struct Vmxnet3_PMConf {
447 u16 wakeUpEvents; /* VMXNET3_PM_WAKEUP_xxx */ 537 __le16 wakeUpEvents; /* VMXNET3_PM_WAKEUP_xxx */
448 u8 numFilters; 538 u8 numFilters;
449 u8 pad[5]; 539 u8 pad[5];
450 struct Vmxnet3_PM_PktFilter filters[VMXNET3_PM_MAX_FILTERS]; 540 struct Vmxnet3_PM_PktFilter filters[VMXNET3_PM_MAX_FILTERS];
@@ -452,9 +542,9 @@ struct Vmxnet3_PMConf {
452 542
453 543
454struct Vmxnet3_VariableLenConfDesc { 544struct Vmxnet3_VariableLenConfDesc {
455 u32 confVer; 545 __le32 confVer;
456 u32 confLen; 546 __le32 confLen;
457 u64 confPA; 547 __le64 confPA;
458}; 548};
459 549
460 550
@@ -491,12 +581,12 @@ struct Vmxnet3_DSDevRead {
491 581
492/* All structures in DriverShared are padded to multiples of 8 bytes */ 582/* All structures in DriverShared are padded to multiples of 8 bytes */
493struct Vmxnet3_DriverShared { 583struct Vmxnet3_DriverShared {
494 u32 magic; 584 __le32 magic;
495 /* make devRead start at 64bit boundaries */ 585 /* make devRead start at 64bit boundaries */
496 u32 pad; 586 __le32 pad;
497 struct Vmxnet3_DSDevRead devRead; 587 struct Vmxnet3_DSDevRead devRead;
498 u32 ecr; 588 __le32 ecr;
499 u32 reserved[5]; 589 __le32 reserved[5];
500}; 590};
501 591
502 592