vmxnet3_defs.h 17 KB

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