vmxnet3_defs.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  1. /*
  2. * Linux driver for VMware's vmxnet3 ethernet NIC.
  3. *
  4. * Copyright (C) 2008-2022, 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: [email protected]
  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. VMXNET3_REG_DCR = 0x48, /* Device capability register,
  42. * from 0x48 to 0x80
  43. */
  44. VMXNET3_REG_PTCR = 0x88, /* Passthru capbility register
  45. * from 0x88 to 0xb0
  46. */
  47. };
  48. /* BAR 0 */
  49. enum {
  50. VMXNET3_REG_IMR = 0x0, /* Interrupt Mask Register */
  51. VMXNET3_REG_TXPROD = 0x600, /* Tx Producer Index */
  52. VMXNET3_REG_RXPROD = 0x800, /* Rx Producer Index for ring 1 */
  53. VMXNET3_REG_RXPROD2 = 0xA00 /* Rx Producer Index for ring 2 */
  54. };
  55. /* For Large PT BAR, the following offset to DB register */
  56. enum {
  57. VMXNET3_REG_LB_TXPROD = 0x1000, /* Tx Producer Index */
  58. VMXNET3_REG_LB_RXPROD = 0x1400, /* Rx Producer Index for ring 1 */
  59. VMXNET3_REG_LB_RXPROD2 = 0x1800, /* Rx Producer Index for ring 2 */
  60. };
  61. #define VMXNET3_PT_REG_SIZE 4096 /* BAR 0 */
  62. #define VMXNET3_LARGE_PT_REG_SIZE 8192 /* large PT pages */
  63. #define VMXNET3_VD_REG_SIZE 4096 /* BAR 1 */
  64. #define VMXNET3_LARGE_BAR0_REG_SIZE (4096 * 4096) /* LARGE BAR 0 */
  65. #define VMXNET3_OOB_REG_SIZE (4094 * 4096) /* OOB pages */
  66. #define VMXNET3_REG_ALIGN 8 /* All registers are 8-byte aligned. */
  67. #define VMXNET3_REG_ALIGN_MASK 0x7
  68. /* I/O Mapped access to registers */
  69. #define VMXNET3_IO_TYPE_PT 0
  70. #define VMXNET3_IO_TYPE_VD 1
  71. #define VMXNET3_IO_ADDR(type, reg) (((type) << 24) | ((reg) & 0xFFFFFF))
  72. #define VMXNET3_IO_TYPE(addr) ((addr) >> 24)
  73. #define VMXNET3_IO_REG(addr) ((addr) & 0xFFFFFF)
  74. enum {
  75. VMXNET3_CMD_FIRST_SET = 0xCAFE0000,
  76. VMXNET3_CMD_ACTIVATE_DEV = VMXNET3_CMD_FIRST_SET,
  77. VMXNET3_CMD_QUIESCE_DEV,
  78. VMXNET3_CMD_RESET_DEV,
  79. VMXNET3_CMD_UPDATE_RX_MODE,
  80. VMXNET3_CMD_UPDATE_MAC_FILTERS,
  81. VMXNET3_CMD_UPDATE_VLAN_FILTERS,
  82. VMXNET3_CMD_UPDATE_RSSIDT,
  83. VMXNET3_CMD_UPDATE_IML,
  84. VMXNET3_CMD_UPDATE_PMCFG,
  85. VMXNET3_CMD_UPDATE_FEATURE,
  86. VMXNET3_CMD_RESERVED1,
  87. VMXNET3_CMD_LOAD_PLUGIN,
  88. VMXNET3_CMD_RESERVED2,
  89. VMXNET3_CMD_RESERVED3,
  90. VMXNET3_CMD_SET_COALESCE,
  91. VMXNET3_CMD_REGISTER_MEMREGS,
  92. VMXNET3_CMD_SET_RSS_FIELDS,
  93. VMXNET3_CMD_RESERVED4,
  94. VMXNET3_CMD_RESERVED5,
  95. VMXNET3_CMD_SET_RING_BUFFER_SIZE,
  96. VMXNET3_CMD_FIRST_GET = 0xF00D0000,
  97. VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
  98. VMXNET3_CMD_GET_STATS,
  99. VMXNET3_CMD_GET_LINK,
  100. VMXNET3_CMD_GET_PERM_MAC_LO,
  101. VMXNET3_CMD_GET_PERM_MAC_HI,
  102. VMXNET3_CMD_GET_DID_LO,
  103. VMXNET3_CMD_GET_DID_HI,
  104. VMXNET3_CMD_GET_DEV_EXTRA_INFO,
  105. VMXNET3_CMD_GET_CONF_INTR,
  106. VMXNET3_CMD_GET_RESERVED1,
  107. VMXNET3_CMD_GET_TXDATA_DESC_SIZE,
  108. VMXNET3_CMD_GET_COALESCE,
  109. VMXNET3_CMD_GET_RSS_FIELDS,
  110. VMXNET3_CMD_GET_RESERVED2,
  111. VMXNET3_CMD_GET_RESERVED3,
  112. VMXNET3_CMD_GET_MAX_QUEUES_CONF,
  113. VMXNET3_CMD_GET_RESERVED4,
  114. VMXNET3_CMD_GET_MAX_CAPABILITIES,
  115. VMXNET3_CMD_GET_DCR0_REG,
  116. };
  117. /*
  118. * Little Endian layout of bitfields -
  119. * Byte 0 : 7.....len.....0
  120. * Byte 1 : oco gen 13.len.8
  121. * Byte 2 : 5.msscof.0 ext1 dtype
  122. * Byte 3 : 13...msscof...6
  123. *
  124. * Big Endian layout of bitfields -
  125. * Byte 0: 13...msscof...6
  126. * Byte 1 : 5.msscof.0 ext1 dtype
  127. * Byte 2 : oco gen 13.len.8
  128. * Byte 3 : 7.....len.....0
  129. *
  130. * Thus, le32_to_cpu on the dword will allow the big endian driver to read
  131. * the bit fields correctly. And cpu_to_le32 will convert bitfields
  132. * bit fields written by big endian driver to format required by device.
  133. */
  134. struct Vmxnet3_TxDesc {
  135. __le64 addr;
  136. #ifdef __BIG_ENDIAN_BITFIELD
  137. u32 msscof:14; /* MSS, checksum offset, flags */
  138. u32 ext1:1; /* set to 1 to indicate inner csum/tso, vmxnet3 v7 */
  139. u32 dtype:1; /* descriptor type */
  140. u32 oco:1; /* Outer csum offload */
  141. u32 gen:1; /* generation bit */
  142. u32 len:14;
  143. #else
  144. u32 len:14;
  145. u32 gen:1; /* generation bit */
  146. u32 oco:1; /* Outer csum offload */
  147. u32 dtype:1; /* descriptor type */
  148. u32 ext1:1; /* set to 1 to indicate inner csum/tso, vmxnet3 v7 */
  149. u32 msscof:14; /* MSS, checksum offset, flags */
  150. #endif /* __BIG_ENDIAN_BITFIELD */
  151. #ifdef __BIG_ENDIAN_BITFIELD
  152. u32 tci:16; /* Tag to Insert */
  153. u32 ti:1; /* VLAN Tag Insertion */
  154. u32 ext2:1;
  155. u32 cq:1; /* completion request */
  156. u32 eop:1; /* End Of Packet */
  157. u32 om:2; /* offload mode */
  158. u32 hlen:10; /* header len */
  159. #else
  160. u32 hlen:10; /* header len */
  161. u32 om:2; /* offload mode */
  162. u32 eop:1; /* End Of Packet */
  163. u32 cq:1; /* completion request */
  164. u32 ext2:1;
  165. u32 ti:1; /* VLAN Tag Insertion */
  166. u32 tci:16; /* Tag to Insert */
  167. #endif /* __BIG_ENDIAN_BITFIELD */
  168. };
  169. /* TxDesc.OM values */
  170. #define VMXNET3_OM_NONE 0
  171. #define VMXNET3_OM_ENCAP 1
  172. #define VMXNET3_OM_CSUM 2
  173. #define VMXNET3_OM_TSO 3
  174. /* fields in TxDesc we access w/o using bit fields */
  175. #define VMXNET3_TXD_EOP_SHIFT 12
  176. #define VMXNET3_TXD_CQ_SHIFT 13
  177. #define VMXNET3_TXD_GEN_SHIFT 14
  178. #define VMXNET3_TXD_EOP_DWORD_SHIFT 3
  179. #define VMXNET3_TXD_GEN_DWORD_SHIFT 2
  180. #define VMXNET3_TXD_CQ (1 << VMXNET3_TXD_CQ_SHIFT)
  181. #define VMXNET3_TXD_EOP (1 << VMXNET3_TXD_EOP_SHIFT)
  182. #define VMXNET3_TXD_GEN (1 << VMXNET3_TXD_GEN_SHIFT)
  183. #define VMXNET3_HDR_COPY_SIZE 128
  184. struct Vmxnet3_TxDataDesc {
  185. u8 data[VMXNET3_HDR_COPY_SIZE];
  186. };
  187. typedef u8 Vmxnet3_RxDataDesc;
  188. #define VMXNET3_TCD_GEN_SHIFT 31
  189. #define VMXNET3_TCD_GEN_SIZE 1
  190. #define VMXNET3_TCD_TXIDX_SHIFT 0
  191. #define VMXNET3_TCD_TXIDX_SIZE 12
  192. #define VMXNET3_TCD_GEN_DWORD_SHIFT 3
  193. struct Vmxnet3_TxCompDesc {
  194. u32 txdIdx:12; /* Index of the EOP TxDesc */
  195. u32 ext1:20;
  196. __le32 ext2;
  197. __le32 ext3;
  198. u32 rsvd:24;
  199. u32 type:7; /* completion type */
  200. u32 gen:1; /* generation bit */
  201. };
  202. struct Vmxnet3_RxDesc {
  203. __le64 addr;
  204. #ifdef __BIG_ENDIAN_BITFIELD
  205. u32 gen:1; /* Generation bit */
  206. u32 rsvd:15;
  207. u32 dtype:1; /* Descriptor type */
  208. u32 btype:1; /* Buffer Type */
  209. u32 len:14;
  210. #else
  211. u32 len:14;
  212. u32 btype:1; /* Buffer Type */
  213. u32 dtype:1; /* Descriptor type */
  214. u32 rsvd:15;
  215. u32 gen:1; /* Generation bit */
  216. #endif
  217. u32 ext1;
  218. };
  219. /* values of RXD.BTYPE */
  220. #define VMXNET3_RXD_BTYPE_HEAD 0 /* head only */
  221. #define VMXNET3_RXD_BTYPE_BODY 1 /* body only */
  222. /* fields in RxDesc we access w/o using bit fields */
  223. #define VMXNET3_RXD_BTYPE_SHIFT 14
  224. #define VMXNET3_RXD_GEN_SHIFT 31
  225. #define VMXNET3_RCD_HDR_INNER_SHIFT 13
  226. struct Vmxnet3_RxCompDesc {
  227. #ifdef __BIG_ENDIAN_BITFIELD
  228. u32 ext2:1;
  229. u32 cnc:1; /* Checksum Not Calculated */
  230. u32 rssType:4; /* RSS hash type used */
  231. u32 rqID:10; /* rx queue/ring ID */
  232. u32 sop:1; /* Start of Packet */
  233. u32 eop:1; /* End of Packet */
  234. u32 ext1:2; /* bit 0: indicating v4/v6/.. is for inner header */
  235. /* bit 1: indicating rssType is based on inner header */
  236. u32 rxdIdx:12; /* Index of the RxDesc */
  237. #else
  238. u32 rxdIdx:12; /* Index of the RxDesc */
  239. u32 ext1:2; /* bit 0: indicating v4/v6/.. is for inner header */
  240. /* bit 1: indicating rssType is based on inner header */
  241. u32 eop:1; /* End of Packet */
  242. u32 sop:1; /* Start of Packet */
  243. u32 rqID:10; /* rx queue/ring ID */
  244. u32 rssType:4; /* RSS hash type used */
  245. u32 cnc:1; /* Checksum Not Calculated */
  246. u32 ext2:1;
  247. #endif /* __BIG_ENDIAN_BITFIELD */
  248. __le32 rssHash; /* RSS hash value */
  249. #ifdef __BIG_ENDIAN_BITFIELD
  250. u32 tci:16; /* Tag stripped */
  251. u32 ts:1; /* Tag is stripped */
  252. u32 err:1; /* Error */
  253. u32 len:14; /* data length */
  254. #else
  255. u32 len:14; /* data length */
  256. u32 err:1; /* Error */
  257. u32 ts:1; /* Tag is stripped */
  258. u32 tci:16; /* Tag stripped */
  259. #endif /* __BIG_ENDIAN_BITFIELD */
  260. #ifdef __BIG_ENDIAN_BITFIELD
  261. u32 gen:1; /* generation bit */
  262. u32 type:7; /* completion type */
  263. u32 fcs:1; /* Frame CRC correct */
  264. u32 frg:1; /* IP Fragment */
  265. u32 v4:1; /* IPv4 */
  266. u32 v6:1; /* IPv6 */
  267. u32 ipc:1; /* IP Checksum Correct */
  268. u32 tcp:1; /* TCP packet */
  269. u32 udp:1; /* UDP packet */
  270. u32 tuc:1; /* TCP/UDP Checksum Correct */
  271. u32 csum:16;
  272. #else
  273. u32 csum:16;
  274. u32 tuc:1; /* TCP/UDP Checksum Correct */
  275. u32 udp:1; /* UDP packet */
  276. u32 tcp:1; /* TCP packet */
  277. u32 ipc:1; /* IP Checksum Correct */
  278. u32 v6:1; /* IPv6 */
  279. u32 v4:1; /* IPv4 */
  280. u32 frg:1; /* IP Fragment */
  281. u32 fcs:1; /* Frame CRC correct */
  282. u32 type:7; /* completion type */
  283. u32 gen:1; /* generation bit */
  284. #endif /* __BIG_ENDIAN_BITFIELD */
  285. };
  286. struct Vmxnet3_RxCompDescExt {
  287. __le32 dword1;
  288. u8 segCnt; /* Number of aggregated packets */
  289. u8 dupAckCnt; /* Number of duplicate Acks */
  290. __le16 tsDelta; /* TCP timestamp difference */
  291. __le32 dword2;
  292. #ifdef __BIG_ENDIAN_BITFIELD
  293. u32 gen:1; /* generation bit */
  294. u32 type:7; /* completion type */
  295. u32 fcs:1; /* Frame CRC correct */
  296. u32 frg:1; /* IP Fragment */
  297. u32 v4:1; /* IPv4 */
  298. u32 v6:1; /* IPv6 */
  299. u32 ipc:1; /* IP Checksum Correct */
  300. u32 tcp:1; /* TCP packet */
  301. u32 udp:1; /* UDP packet */
  302. u32 tuc:1; /* TCP/UDP Checksum Correct */
  303. u32 mss:16;
  304. #else
  305. u32 mss:16;
  306. u32 tuc:1; /* TCP/UDP Checksum Correct */
  307. u32 udp:1; /* UDP packet */
  308. u32 tcp:1; /* TCP packet */
  309. u32 ipc:1; /* IP Checksum Correct */
  310. u32 v6:1; /* IPv6 */
  311. u32 v4:1; /* IPv4 */
  312. u32 frg:1; /* IP Fragment */
  313. u32 fcs:1; /* Frame CRC correct */
  314. u32 type:7; /* completion type */
  315. u32 gen:1; /* generation bit */
  316. #endif /* __BIG_ENDIAN_BITFIELD */
  317. };
  318. /* 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. /* 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. /* csum OK for TCP/UDP pkts over IP */
  325. #define VMXNET3_RCD_CSUM_OK (1 << VMXNET3_RCD_TUC_SHIFT | \
  326. 1 << VMXNET3_RCD_IPC_SHIFT)
  327. #define VMXNET3_TXD_GEN_SIZE 1
  328. #define VMXNET3_TXD_EOP_SIZE 1
  329. /* value of RxCompDesc.rssType */
  330. #define VMXNET3_RCD_RSS_TYPE_NONE 0
  331. #define VMXNET3_RCD_RSS_TYPE_IPV4 1
  332. #define VMXNET3_RCD_RSS_TYPE_TCPIPV4 2
  333. #define VMXNET3_RCD_RSS_TYPE_IPV6 3
  334. #define VMXNET3_RCD_RSS_TYPE_TCPIPV6 4
  335. #define VMXNET3_RCD_RSS_TYPE_UDPIPV4 5
  336. #define VMXNET3_RCD_RSS_TYPE_UDPIPV6 6
  337. #define VMXNET3_RCD_RSS_TYPE_ESPIPV4 7
  338. #define VMXNET3_RCD_RSS_TYPE_ESPIPV6 8
  339. /* a union for accessing all cmd/completion descriptors */
  340. union Vmxnet3_GenericDesc {
  341. __le64 qword[2];
  342. __le32 dword[4];
  343. __le16 word[8];
  344. struct Vmxnet3_TxDesc txd;
  345. struct Vmxnet3_RxDesc rxd;
  346. struct Vmxnet3_TxCompDesc tcd;
  347. struct Vmxnet3_RxCompDesc rcd;
  348. struct Vmxnet3_RxCompDescExt rcdExt;
  349. };
  350. #define VMXNET3_INIT_GEN 1
  351. /* Max size of a single tx buffer */
  352. #define VMXNET3_MAX_TX_BUF_SIZE (1 << 14)
  353. /* # of tx desc needed for a tx buffer size */
  354. #define VMXNET3_TXD_NEEDED(size) (((size) + VMXNET3_MAX_TX_BUF_SIZE - 1) / \
  355. VMXNET3_MAX_TX_BUF_SIZE)
  356. /* max # of tx descs for a non-tso pkt */
  357. #define VMXNET3_MAX_TXD_PER_PKT 16
  358. /* max # of tx descs for a tso pkt */
  359. #define VMXNET3_MAX_TSO_TXD_PER_PKT 24
  360. /* Max size of a single rx buffer */
  361. #define VMXNET3_MAX_RX_BUF_SIZE ((1 << 14) - 1)
  362. /* Minimum size of a type 0 buffer */
  363. #define VMXNET3_MIN_T0_BUF_SIZE 128
  364. #define VMXNET3_MAX_CSUM_OFFSET 1024
  365. /* Ring base address alignment */
  366. #define VMXNET3_RING_BA_ALIGN 512
  367. #define VMXNET3_RING_BA_MASK (VMXNET3_RING_BA_ALIGN - 1)
  368. /* Ring size must be a multiple of 32 */
  369. #define VMXNET3_RING_SIZE_ALIGN 32
  370. #define VMXNET3_RING_SIZE_MASK (VMXNET3_RING_SIZE_ALIGN - 1)
  371. /* Tx Data Ring buffer size must be a multiple of 64 */
  372. #define VMXNET3_TXDATA_DESC_SIZE_ALIGN 64
  373. #define VMXNET3_TXDATA_DESC_SIZE_MASK (VMXNET3_TXDATA_DESC_SIZE_ALIGN - 1)
  374. /* Rx Data Ring buffer size must be a multiple of 64 */
  375. #define VMXNET3_RXDATA_DESC_SIZE_ALIGN 64
  376. #define VMXNET3_RXDATA_DESC_SIZE_MASK (VMXNET3_RXDATA_DESC_SIZE_ALIGN - 1)
  377. /* Max ring size */
  378. #define VMXNET3_TX_RING_MAX_SIZE 4096
  379. #define VMXNET3_TC_RING_MAX_SIZE 4096
  380. #define VMXNET3_RX_RING_MAX_SIZE 4096
  381. #define VMXNET3_RX_RING2_MAX_SIZE 4096
  382. #define VMXNET3_RC_RING_MAX_SIZE 8192
  383. #define VMXNET3_TXDATA_DESC_MIN_SIZE 128
  384. #define VMXNET3_TXDATA_DESC_MAX_SIZE 2048
  385. #define VMXNET3_RXDATA_DESC_MAX_SIZE 2048
  386. /* a list of reasons for queue stop */
  387. enum {
  388. VMXNET3_ERR_NOEOP = 0x80000000, /* cannot find the EOP desc of a pkt */
  389. VMXNET3_ERR_TXD_REUSE = 0x80000001, /* reuse TxDesc before tx completion */
  390. VMXNET3_ERR_BIG_PKT = 0x80000002, /* too many TxDesc for a pkt */
  391. VMXNET3_ERR_DESC_NOT_SPT = 0x80000003, /* descriptor type not supported */
  392. VMXNET3_ERR_SMALL_BUF = 0x80000004, /* type 0 buffer too small */
  393. VMXNET3_ERR_STRESS = 0x80000005, /* stress option firing in vmkernel */
  394. VMXNET3_ERR_SWITCH = 0x80000006, /* mode switch failure */
  395. VMXNET3_ERR_TXD_INVALID = 0x80000007, /* invalid TxDesc */
  396. };
  397. /* completion descriptor types */
  398. #define VMXNET3_CDTYPE_TXCOMP 0 /* Tx Completion Descriptor */
  399. #define VMXNET3_CDTYPE_RXCOMP 3 /* Rx Completion Descriptor */
  400. #define VMXNET3_CDTYPE_RXCOMP_LRO 4 /* Rx Completion Descriptor for LRO */
  401. enum {
  402. VMXNET3_GOS_BITS_UNK = 0, /* unknown */
  403. VMXNET3_GOS_BITS_32 = 1,
  404. VMXNET3_GOS_BITS_64 = 2,
  405. };
  406. #define VMXNET3_GOS_TYPE_LINUX 1
  407. struct Vmxnet3_GOSInfo {
  408. #ifdef __BIG_ENDIAN_BITFIELD
  409. u32 gosMisc:10; /* other info about gos */
  410. u32 gosVer:16; /* gos version */
  411. u32 gosType:4; /* which guest */
  412. u32 gosBits:2; /* 32-bit or 64-bit? */
  413. #else
  414. u32 gosBits:2; /* 32-bit or 64-bit? */
  415. u32 gosType:4; /* which guest */
  416. u32 gosVer:16; /* gos version */
  417. u32 gosMisc:10; /* other info about gos */
  418. #endif /* __BIG_ENDIAN_BITFIELD */
  419. };
  420. struct Vmxnet3_DriverInfo {
  421. __le32 version;
  422. struct Vmxnet3_GOSInfo gos;
  423. __le32 vmxnet3RevSpt;
  424. __le32 uptVerSpt;
  425. };
  426. #define VMXNET3_REV1_MAGIC 3133079265u
  427. /*
  428. * QueueDescPA must be 128 bytes aligned. It points to an array of
  429. * Vmxnet3_TxQueueDesc followed by an array of Vmxnet3_RxQueueDesc.
  430. * The number of Vmxnet3_TxQueueDesc/Vmxnet3_RxQueueDesc are specified by
  431. * Vmxnet3_MiscConf.numTxQueues/numRxQueues, respectively.
  432. */
  433. #define VMXNET3_QUEUE_DESC_ALIGN 128
  434. struct Vmxnet3_MiscConf {
  435. struct Vmxnet3_DriverInfo driverInfo;
  436. __le64 uptFeatures;
  437. __le64 ddPA; /* driver data PA */
  438. __le64 queueDescPA; /* queue descriptor table PA */
  439. __le32 ddLen; /* driver data len */
  440. __le32 queueDescLen; /* queue desc. table len in bytes */
  441. __le32 mtu;
  442. __le16 maxNumRxSG;
  443. u8 numTxQueues;
  444. u8 numRxQueues;
  445. __le32 reserved[4];
  446. };
  447. struct Vmxnet3_TxQueueConf {
  448. __le64 txRingBasePA;
  449. __le64 dataRingBasePA;
  450. __le64 compRingBasePA;
  451. __le64 ddPA; /* driver data */
  452. __le64 reserved;
  453. __le32 txRingSize; /* # of tx desc */
  454. __le32 dataRingSize; /* # of data desc */
  455. __le32 compRingSize; /* # of comp desc */
  456. __le32 ddLen; /* size of driver data */
  457. u8 intrIdx;
  458. u8 _pad1[1];
  459. __le16 txDataRingDescSize;
  460. u8 _pad2[4];
  461. };
  462. struct Vmxnet3_RxQueueConf {
  463. __le64 rxRingBasePA[2];
  464. __le64 compRingBasePA;
  465. __le64 ddPA; /* driver data */
  466. __le64 rxDataRingBasePA;
  467. __le32 rxRingSize[2]; /* # of rx desc */
  468. __le32 compRingSize; /* # of rx comp desc */
  469. __le32 ddLen; /* size of driver data */
  470. u8 intrIdx;
  471. u8 _pad1[1];
  472. __le16 rxDataRingDescSize; /* size of rx data ring buffer */
  473. u8 _pad2[4];
  474. };
  475. enum vmxnet3_intr_mask_mode {
  476. VMXNET3_IMM_AUTO = 0,
  477. VMXNET3_IMM_ACTIVE = 1,
  478. VMXNET3_IMM_LAZY = 2
  479. };
  480. enum vmxnet3_intr_type {
  481. VMXNET3_IT_AUTO = 0,
  482. VMXNET3_IT_INTX = 1,
  483. VMXNET3_IT_MSI = 2,
  484. VMXNET3_IT_MSIX = 3
  485. };
  486. #define VMXNET3_MAX_TX_QUEUES 8
  487. #define VMXNET3_MAX_RX_QUEUES 16
  488. /* addition 1 for events */
  489. #define VMXNET3_MAX_INTRS 25
  490. /* Version 6 and later will use below macros */
  491. #define VMXNET3_EXT_MAX_TX_QUEUES 32
  492. #define VMXNET3_EXT_MAX_RX_QUEUES 32
  493. /* addition 1 for events */
  494. #define VMXNET3_EXT_MAX_INTRS 65
  495. #define VMXNET3_FIRST_SET_INTRS 64
  496. /* value of intrCtrl */
  497. #define VMXNET3_IC_DISABLE_ALL 0x1 /* bit 0 */
  498. struct Vmxnet3_IntrConf {
  499. bool autoMask;
  500. u8 numIntrs; /* # of interrupts */
  501. u8 eventIntrIdx;
  502. u8 modLevels[VMXNET3_MAX_INTRS]; /* moderation level for
  503. * each intr */
  504. __le32 intrCtrl;
  505. __le32 reserved[2];
  506. };
  507. struct Vmxnet3_IntrConfExt {
  508. u8 autoMask;
  509. u8 numIntrs; /* # of interrupts */
  510. u8 eventIntrIdx;
  511. u8 reserved;
  512. __le32 intrCtrl;
  513. __le32 reserved1;
  514. u8 modLevels[VMXNET3_EXT_MAX_INTRS]; /* moderation level for
  515. * each intr
  516. */
  517. u8 reserved2[3];
  518. };
  519. /* one bit per VLAN ID, the size is in the units of u32 */
  520. #define VMXNET3_VFT_SIZE (4096 / (sizeof(u32) * 8))
  521. struct Vmxnet3_QueueStatus {
  522. bool stopped;
  523. u8 _pad[3];
  524. __le32 error;
  525. };
  526. struct Vmxnet3_TxQueueCtrl {
  527. __le32 txNumDeferred;
  528. __le32 txThreshold;
  529. __le64 reserved;
  530. };
  531. struct Vmxnet3_RxQueueCtrl {
  532. bool updateRxProd;
  533. u8 _pad[7];
  534. __le64 reserved;
  535. };
  536. enum {
  537. VMXNET3_RXM_UCAST = 0x01, /* unicast only */
  538. VMXNET3_RXM_MCAST = 0x02, /* multicast passing the filters */
  539. VMXNET3_RXM_BCAST = 0x04, /* broadcast only */
  540. VMXNET3_RXM_ALL_MULTI = 0x08, /* all multicast */
  541. VMXNET3_RXM_PROMISC = 0x10 /* promiscuous */
  542. };
  543. struct Vmxnet3_RxFilterConf {
  544. __le32 rxMode; /* VMXNET3_RXM_xxx */
  545. __le16 mfTableLen; /* size of the multicast filter table */
  546. __le16 _pad1;
  547. __le64 mfTablePA; /* PA of the multicast filters table */
  548. __le32 vfTable[VMXNET3_VFT_SIZE]; /* vlan filter */
  549. };
  550. #define VMXNET3_PM_MAX_FILTERS 6
  551. #define VMXNET3_PM_MAX_PATTERN_SIZE 128
  552. #define VMXNET3_PM_MAX_MASK_SIZE (VMXNET3_PM_MAX_PATTERN_SIZE / 8)
  553. #define VMXNET3_PM_WAKEUP_MAGIC cpu_to_le16(0x01) /* wake up on magic pkts */
  554. #define VMXNET3_PM_WAKEUP_FILTER cpu_to_le16(0x02) /* wake up on pkts matching
  555. * filters */
  556. struct Vmxnet3_PM_PktFilter {
  557. u8 maskSize;
  558. u8 patternSize;
  559. u8 mask[VMXNET3_PM_MAX_MASK_SIZE];
  560. u8 pattern[VMXNET3_PM_MAX_PATTERN_SIZE];
  561. u8 pad[6];
  562. };
  563. struct Vmxnet3_PMConf {
  564. __le16 wakeUpEvents; /* VMXNET3_PM_WAKEUP_xxx */
  565. u8 numFilters;
  566. u8 pad[5];
  567. struct Vmxnet3_PM_PktFilter filters[VMXNET3_PM_MAX_FILTERS];
  568. };
  569. struct Vmxnet3_VariableLenConfDesc {
  570. __le32 confVer;
  571. __le32 confLen;
  572. __le64 confPA;
  573. };
  574. struct Vmxnet3_TxQueueDesc {
  575. struct Vmxnet3_TxQueueCtrl ctrl;
  576. struct Vmxnet3_TxQueueConf conf;
  577. /* Driver read after a GET command */
  578. struct Vmxnet3_QueueStatus status;
  579. struct UPT1_TxStats stats;
  580. u8 _pad[88]; /* 128 aligned */
  581. };
  582. struct Vmxnet3_RxQueueDesc {
  583. struct Vmxnet3_RxQueueCtrl ctrl;
  584. struct Vmxnet3_RxQueueConf conf;
  585. /* Driver read after a GET commad */
  586. struct Vmxnet3_QueueStatus status;
  587. struct UPT1_RxStats stats;
  588. u8 __pad[88]; /* 128 aligned */
  589. };
  590. struct Vmxnet3_SetPolling {
  591. u8 enablePolling;
  592. };
  593. #define VMXNET3_COAL_STATIC_MAX_DEPTH 128
  594. #define VMXNET3_COAL_RBC_MIN_RATE 100
  595. #define VMXNET3_COAL_RBC_MAX_RATE 100000
  596. enum Vmxnet3_CoalesceMode {
  597. VMXNET3_COALESCE_DISABLED = 0,
  598. VMXNET3_COALESCE_ADAPT = 1,
  599. VMXNET3_COALESCE_STATIC = 2,
  600. VMXNET3_COALESCE_RBC = 3
  601. };
  602. struct Vmxnet3_CoalesceRbc {
  603. u32 rbc_rate;
  604. };
  605. struct Vmxnet3_CoalesceStatic {
  606. u32 tx_depth;
  607. u32 tx_comp_depth;
  608. u32 rx_depth;
  609. };
  610. struct Vmxnet3_CoalesceScheme {
  611. enum Vmxnet3_CoalesceMode coalMode;
  612. union {
  613. struct Vmxnet3_CoalesceRbc coalRbc;
  614. struct Vmxnet3_CoalesceStatic coalStatic;
  615. } coalPara;
  616. };
  617. struct Vmxnet3_MemoryRegion {
  618. __le64 startPA;
  619. __le32 length;
  620. __le16 txQueueBits;
  621. __le16 rxQueueBits;
  622. };
  623. #define MAX_MEMORY_REGION_PER_QUEUE 16
  624. #define MAX_MEMORY_REGION_PER_DEVICE 256
  625. struct Vmxnet3_MemRegs {
  626. __le16 numRegs;
  627. __le16 pad[3];
  628. struct Vmxnet3_MemoryRegion memRegs[1];
  629. };
  630. enum Vmxnet3_RSSField {
  631. VMXNET3_RSS_FIELDS_TCPIP4 = 0x0001,
  632. VMXNET3_RSS_FIELDS_TCPIP6 = 0x0002,
  633. VMXNET3_RSS_FIELDS_UDPIP4 = 0x0004,
  634. VMXNET3_RSS_FIELDS_UDPIP6 = 0x0008,
  635. VMXNET3_RSS_FIELDS_ESPIP4 = 0x0010,
  636. VMXNET3_RSS_FIELDS_ESPIP6 = 0x0020,
  637. };
  638. struct Vmxnet3_RingBufferSize {
  639. __le16 ring1BufSizeType0;
  640. __le16 ring1BufSizeType1;
  641. __le16 ring2BufSizeType1;
  642. __le16 pad;
  643. };
  644. /* If the command data <= 16 bytes, use the shared memory directly.
  645. * otherwise, use variable length configuration descriptor.
  646. */
  647. union Vmxnet3_CmdInfo {
  648. struct Vmxnet3_VariableLenConfDesc varConf;
  649. struct Vmxnet3_SetPolling setPolling;
  650. enum Vmxnet3_RSSField setRssFields;
  651. struct Vmxnet3_RingBufferSize ringBufSize;
  652. __le64 data[2];
  653. };
  654. struct Vmxnet3_DSDevRead {
  655. /* read-only region for device, read by dev in response to a SET cmd */
  656. struct Vmxnet3_MiscConf misc;
  657. struct Vmxnet3_IntrConf intrConf;
  658. struct Vmxnet3_RxFilterConf rxFilterConf;
  659. struct Vmxnet3_VariableLenConfDesc rssConfDesc;
  660. struct Vmxnet3_VariableLenConfDesc pmConfDesc;
  661. struct Vmxnet3_VariableLenConfDesc pluginConfDesc;
  662. };
  663. struct Vmxnet3_DSDevReadExt {
  664. /* read-only region for device, read by dev in response to a SET cmd */
  665. struct Vmxnet3_IntrConfExt intrConfExt;
  666. };
  667. /* All structures in DriverShared are padded to multiples of 8 bytes */
  668. struct Vmxnet3_DriverShared {
  669. __le32 magic;
  670. /* make devRead start at 64bit boundaries */
  671. __le32 size; /* size of DriverShared */
  672. struct Vmxnet3_DSDevRead devRead;
  673. __le32 ecr;
  674. __le32 reserved;
  675. union {
  676. __le32 reserved1[4];
  677. union Vmxnet3_CmdInfo cmdInfo; /* only valid in the context of
  678. * executing the relevant
  679. * command
  680. */
  681. } cu;
  682. struct Vmxnet3_DSDevReadExt devReadExt;
  683. };
  684. #define VMXNET3_ECR_RQERR (1 << 0)
  685. #define VMXNET3_ECR_TQERR (1 << 1)
  686. #define VMXNET3_ECR_LINK (1 << 2)
  687. #define VMXNET3_ECR_DIC (1 << 3)
  688. #define VMXNET3_ECR_DEBUG (1 << 4)
  689. /* flip the gen bit of a ring */
  690. #define VMXNET3_FLIP_RING_GEN(gen) ((gen) = (gen) ^ 0x1)
  691. /* only use this if moving the idx won't affect the gen bit */
  692. #define VMXNET3_INC_RING_IDX_ONLY(idx, ring_size) \
  693. do {\
  694. (idx)++;\
  695. if (unlikely((idx) == (ring_size))) {\
  696. (idx) = 0;\
  697. } \
  698. } while (0)
  699. #define VMXNET3_SET_VFTABLE_ENTRY(vfTable, vid) \
  700. (vfTable[vid >> 5] |= (1 << (vid & 31)))
  701. #define VMXNET3_CLEAR_VFTABLE_ENTRY(vfTable, vid) \
  702. (vfTable[vid >> 5] &= ~(1 << (vid & 31)))
  703. #define VMXNET3_VFTABLE_ENTRY_IS_SET(vfTable, vid) \
  704. ((vfTable[vid >> 5] & (1 << (vid & 31))) != 0)
  705. #define VMXNET3_MAX_MTU 9000
  706. #define VMXNET3_V6_MAX_MTU 9190
  707. #define VMXNET3_MIN_MTU 60
  708. #define VMXNET3_LINK_UP (10000 << 16 | 1) /* 10 Gbps, up */
  709. #define VMXNET3_LINK_DOWN 0
  710. #define VMXNET3_DCR_ERROR 31 /* error when bit 31 of DCR is set */
  711. #define VMXNET3_CAP_UDP_RSS 0 /* bit 0 of DCR 0 */
  712. #define VMXNET3_CAP_ESP_RSS_IPV4 1 /* bit 1 of DCR 0 */
  713. #define VMXNET3_CAP_GENEVE_CHECKSUM_OFFLOAD 2 /* bit 2 of DCR 0 */
  714. #define VMXNET3_CAP_GENEVE_TSO 3 /* bit 3 of DCR 0 */
  715. #define VMXNET3_CAP_VXLAN_CHECKSUM_OFFLOAD 4 /* bit 4 of DCR 0 */
  716. #define VMXNET3_CAP_VXLAN_TSO 5 /* bit 5 of DCR 0 */
  717. #define VMXNET3_CAP_GENEVE_OUTER_CHECKSUM_OFFLOAD 6 /* bit 6 of DCR 0 */
  718. #define VMXNET3_CAP_VXLAN_OUTER_CHECKSUM_OFFLOAD 7 /* bit 7 of DCR 0 */
  719. #define VMXNET3_CAP_PKT_STEERING_IPV4 8 /* bit 8 of DCR 0 */
  720. #define VMXNET3_CAP_VERSION_4_MAX VMXNET3_CAP_PKT_STEERING_IPV4
  721. #define VMXNET3_CAP_ESP_RSS_IPV6 9 /* bit 9 of DCR 0 */
  722. #define VMXNET3_CAP_VERSION_5_MAX VMXNET3_CAP_ESP_RSS_IPV6
  723. #define VMXNET3_CAP_ESP_OVER_UDP_RSS 10 /* bit 10 of DCR 0 */
  724. #define VMXNET3_CAP_INNER_RSS 11 /* bit 11 of DCR 0 */
  725. #define VMXNET3_CAP_INNER_ESP_RSS 12 /* bit 12 of DCR 0 */
  726. #define VMXNET3_CAP_CRC32_HASH_FUNC 13 /* bit 13 of DCR 0 */
  727. #define VMXNET3_CAP_VERSION_6_MAX VMXNET3_CAP_CRC32_HASH_FUNC
  728. #define VMXNET3_CAP_OAM_FILTER 14 /* bit 14 of DCR 0 */
  729. #define VMXNET3_CAP_ESP_QS 15 /* bit 15 of DCR 0 */
  730. #define VMXNET3_CAP_LARGE_BAR 16 /* bit 16 of DCR 0 */
  731. #define VMXNET3_CAP_OOORX_COMP 17 /* bit 17 of DCR 0 */
  732. #define VMXNET3_CAP_VERSION_7_MAX 18
  733. /* when new capability is introduced, update VMXNET3_CAP_MAX */
  734. #define VMXNET3_CAP_MAX VMXNET3_CAP_VERSION_7_MAX
  735. #endif /* _VMXNET3_DEFS_H_ */