device.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209
  1. /*
  2. * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and/or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. */
  32. #ifndef MLX5_DEVICE_H
  33. #define MLX5_DEVICE_H
  34. #include <linux/types.h>
  35. #include <rdma/ib_verbs.h>
  36. #include <linux/mlx5/mlx5_ifc.h>
  37. #if defined(__LITTLE_ENDIAN)
  38. #define MLX5_SET_HOST_ENDIANNESS 0
  39. #elif defined(__BIG_ENDIAN)
  40. #define MLX5_SET_HOST_ENDIANNESS 0x80
  41. #else
  42. #error Host endianness not defined
  43. #endif
  44. /* helper macros */
  45. #define __mlx5_nullp(typ) ((struct mlx5_ifc_##typ##_bits *)0)
  46. #define __mlx5_bit_sz(typ, fld) sizeof(__mlx5_nullp(typ)->fld)
  47. #define __mlx5_bit_off(typ, fld) ((unsigned)(unsigned long)(&(__mlx5_nullp(typ)->fld)))
  48. #define __mlx5_dw_off(typ, fld) (__mlx5_bit_off(typ, fld) / 32)
  49. #define __mlx5_64_off(typ, fld) (__mlx5_bit_off(typ, fld) / 64)
  50. #define __mlx5_dw_bit_off(typ, fld) (32 - __mlx5_bit_sz(typ, fld) - (__mlx5_bit_off(typ, fld) & 0x1f))
  51. #define __mlx5_mask(typ, fld) ((u32)((1ull << __mlx5_bit_sz(typ, fld)) - 1))
  52. #define __mlx5_dw_mask(typ, fld) (__mlx5_mask(typ, fld) << __mlx5_dw_bit_off(typ, fld))
  53. #define __mlx5_st_sz_bits(typ) sizeof(struct mlx5_ifc_##typ##_bits)
  54. #define MLX5_FLD_SZ_BYTES(typ, fld) (__mlx5_bit_sz(typ, fld) / 8)
  55. #define MLX5_ST_SZ_BYTES(typ) (sizeof(struct mlx5_ifc_##typ##_bits) / 8)
  56. #define MLX5_ST_SZ_DW(typ) (sizeof(struct mlx5_ifc_##typ##_bits) / 32)
  57. #define MLX5_UN_SZ_BYTES(typ) (sizeof(union mlx5_ifc_##typ##_bits) / 8)
  58. #define MLX5_UN_SZ_DW(typ) (sizeof(union mlx5_ifc_##typ##_bits) / 32)
  59. #define MLX5_BYTE_OFF(typ, fld) (__mlx5_bit_off(typ, fld) / 8)
  60. #define MLX5_ADDR_OF(typ, p, fld) ((char *)(p) + MLX5_BYTE_OFF(typ, fld))
  61. /* insert a value to a struct */
  62. #define MLX5_SET(typ, p, fld, v) do { \
  63. BUILD_BUG_ON(__mlx5_st_sz_bits(typ) % 32); \
  64. *((__be32 *)(p) + __mlx5_dw_off(typ, fld)) = \
  65. cpu_to_be32((be32_to_cpu(*((__be32 *)(p) + __mlx5_dw_off(typ, fld))) & \
  66. (~__mlx5_dw_mask(typ, fld))) | (((v) & __mlx5_mask(typ, fld)) \
  67. << __mlx5_dw_bit_off(typ, fld))); \
  68. } while (0)
  69. #define MLX5_SET_TO_ONES(typ, p, fld) do { \
  70. BUILD_BUG_ON(__mlx5_st_sz_bits(typ) % 32); \
  71. *((__be32 *)(p) + __mlx5_dw_off(typ, fld)) = \
  72. cpu_to_be32((be32_to_cpu(*((__be32 *)(p) + __mlx5_dw_off(typ, fld))) & \
  73. (~__mlx5_dw_mask(typ, fld))) | ((__mlx5_mask(typ, fld)) \
  74. << __mlx5_dw_bit_off(typ, fld))); \
  75. } while (0)
  76. #define MLX5_GET(typ, p, fld) ((be32_to_cpu(*((__be32 *)(p) +\
  77. __mlx5_dw_off(typ, fld))) >> __mlx5_dw_bit_off(typ, fld)) & \
  78. __mlx5_mask(typ, fld))
  79. #define MLX5_GET_PR(typ, p, fld) ({ \
  80. u32 ___t = MLX5_GET(typ, p, fld); \
  81. pr_debug(#fld " = 0x%x\n", ___t); \
  82. ___t; \
  83. })
  84. #define MLX5_SET64(typ, p, fld, v) do { \
  85. BUILD_BUG_ON(__mlx5_bit_sz(typ, fld) != 64); \
  86. BUILD_BUG_ON(__mlx5_bit_off(typ, fld) % 64); \
  87. *((__be64 *)(p) + __mlx5_64_off(typ, fld)) = cpu_to_be64(v); \
  88. } while (0)
  89. #define MLX5_GET64(typ, p, fld) be64_to_cpu(*((__be64 *)(p) + __mlx5_64_off(typ, fld)))
  90. #define MLX5_GET64_PR(typ, p, fld) ({ \
  91. u64 ___t = MLX5_GET64(typ, p, fld); \
  92. pr_debug(#fld " = 0x%llx\n", ___t); \
  93. ___t; \
  94. })
  95. enum {
  96. MLX5_MAX_COMMANDS = 32,
  97. MLX5_CMD_DATA_BLOCK_SIZE = 512,
  98. MLX5_PCI_CMD_XPORT = 7,
  99. MLX5_MKEY_BSF_OCTO_SIZE = 4,
  100. MLX5_MAX_PSVS = 4,
  101. };
  102. enum {
  103. MLX5_EXTENDED_UD_AV = 0x80000000,
  104. };
  105. enum {
  106. MLX5_CQ_STATE_ARMED = 9,
  107. MLX5_CQ_STATE_ALWAYS_ARMED = 0xb,
  108. MLX5_CQ_STATE_FIRED = 0xa,
  109. };
  110. enum {
  111. MLX5_STAT_RATE_OFFSET = 5,
  112. };
  113. enum {
  114. MLX5_INLINE_SEG = 0x80000000,
  115. };
  116. enum {
  117. MLX5_HW_START_PADDING = MLX5_INLINE_SEG,
  118. };
  119. enum {
  120. MLX5_MIN_PKEY_TABLE_SIZE = 128,
  121. MLX5_MAX_LOG_PKEY_TABLE = 5,
  122. };
  123. enum {
  124. MLX5_MKEY_INBOX_PG_ACCESS = 1 << 31
  125. };
  126. enum {
  127. MLX5_PFAULT_SUBTYPE_WQE = 0,
  128. MLX5_PFAULT_SUBTYPE_RDMA = 1,
  129. };
  130. enum {
  131. MLX5_PERM_LOCAL_READ = 1 << 2,
  132. MLX5_PERM_LOCAL_WRITE = 1 << 3,
  133. MLX5_PERM_REMOTE_READ = 1 << 4,
  134. MLX5_PERM_REMOTE_WRITE = 1 << 5,
  135. MLX5_PERM_ATOMIC = 1 << 6,
  136. MLX5_PERM_UMR_EN = 1 << 7,
  137. };
  138. enum {
  139. MLX5_PCIE_CTRL_SMALL_FENCE = 1 << 0,
  140. MLX5_PCIE_CTRL_RELAXED_ORDERING = 1 << 2,
  141. MLX5_PCIE_CTRL_NO_SNOOP = 1 << 3,
  142. MLX5_PCIE_CTRL_TLP_PROCE_EN = 1 << 6,
  143. MLX5_PCIE_CTRL_TPH_MASK = 3 << 4,
  144. };
  145. enum {
  146. MLX5_ACCESS_MODE_PA = 0,
  147. MLX5_ACCESS_MODE_MTT = 1,
  148. MLX5_ACCESS_MODE_KLM = 2
  149. };
  150. enum {
  151. MLX5_MKEY_REMOTE_INVAL = 1 << 24,
  152. MLX5_MKEY_FLAG_SYNC_UMR = 1 << 29,
  153. MLX5_MKEY_BSF_EN = 1 << 30,
  154. MLX5_MKEY_LEN64 = 1 << 31,
  155. };
  156. enum {
  157. MLX5_EN_RD = (u64)1,
  158. MLX5_EN_WR = (u64)2
  159. };
  160. enum {
  161. MLX5_BF_REGS_PER_PAGE = 4,
  162. MLX5_MAX_UAR_PAGES = 1 << 8,
  163. MLX5_NON_FP_BF_REGS_PER_PAGE = 2,
  164. MLX5_MAX_UUARS = MLX5_MAX_UAR_PAGES * MLX5_NON_FP_BF_REGS_PER_PAGE,
  165. };
  166. enum {
  167. MLX5_MKEY_MASK_LEN = 1ull << 0,
  168. MLX5_MKEY_MASK_PAGE_SIZE = 1ull << 1,
  169. MLX5_MKEY_MASK_START_ADDR = 1ull << 6,
  170. MLX5_MKEY_MASK_PD = 1ull << 7,
  171. MLX5_MKEY_MASK_EN_RINVAL = 1ull << 8,
  172. MLX5_MKEY_MASK_EN_SIGERR = 1ull << 9,
  173. MLX5_MKEY_MASK_BSF_EN = 1ull << 12,
  174. MLX5_MKEY_MASK_KEY = 1ull << 13,
  175. MLX5_MKEY_MASK_QPN = 1ull << 14,
  176. MLX5_MKEY_MASK_LR = 1ull << 17,
  177. MLX5_MKEY_MASK_LW = 1ull << 18,
  178. MLX5_MKEY_MASK_RR = 1ull << 19,
  179. MLX5_MKEY_MASK_RW = 1ull << 20,
  180. MLX5_MKEY_MASK_A = 1ull << 21,
  181. MLX5_MKEY_MASK_SMALL_FENCE = 1ull << 23,
  182. MLX5_MKEY_MASK_FREE = 1ull << 29,
  183. };
  184. enum {
  185. MLX5_UMR_TRANSLATION_OFFSET_EN = (1 << 4),
  186. MLX5_UMR_CHECK_NOT_FREE = (1 << 5),
  187. MLX5_UMR_CHECK_FREE = (2 << 5),
  188. MLX5_UMR_INLINE = (1 << 7),
  189. };
  190. #define MLX5_UMR_MTT_ALIGNMENT 0x40
  191. #define MLX5_UMR_MTT_MASK (MLX5_UMR_MTT_ALIGNMENT - 1)
  192. #define MLX5_UMR_MTT_MIN_CHUNK_SIZE MLX5_UMR_MTT_ALIGNMENT
  193. enum mlx5_event {
  194. MLX5_EVENT_TYPE_COMP = 0x0,
  195. MLX5_EVENT_TYPE_PATH_MIG = 0x01,
  196. MLX5_EVENT_TYPE_COMM_EST = 0x02,
  197. MLX5_EVENT_TYPE_SQ_DRAINED = 0x03,
  198. MLX5_EVENT_TYPE_SRQ_LAST_WQE = 0x13,
  199. MLX5_EVENT_TYPE_SRQ_RQ_LIMIT = 0x14,
  200. MLX5_EVENT_TYPE_CQ_ERROR = 0x04,
  201. MLX5_EVENT_TYPE_WQ_CATAS_ERROR = 0x05,
  202. MLX5_EVENT_TYPE_PATH_MIG_FAILED = 0x07,
  203. MLX5_EVENT_TYPE_WQ_INVAL_REQ_ERROR = 0x10,
  204. MLX5_EVENT_TYPE_WQ_ACCESS_ERROR = 0x11,
  205. MLX5_EVENT_TYPE_SRQ_CATAS_ERROR = 0x12,
  206. MLX5_EVENT_TYPE_INTERNAL_ERROR = 0x08,
  207. MLX5_EVENT_TYPE_PORT_CHANGE = 0x09,
  208. MLX5_EVENT_TYPE_GPIO_EVENT = 0x15,
  209. MLX5_EVENT_TYPE_REMOTE_CONFIG = 0x19,
  210. MLX5_EVENT_TYPE_DB_BF_CONGESTION = 0x1a,
  211. MLX5_EVENT_TYPE_STALL_EVENT = 0x1b,
  212. MLX5_EVENT_TYPE_CMD = 0x0a,
  213. MLX5_EVENT_TYPE_PAGE_REQUEST = 0xb,
  214. MLX5_EVENT_TYPE_PAGE_FAULT = 0xc,
  215. };
  216. enum {
  217. MLX5_PORT_CHANGE_SUBTYPE_DOWN = 1,
  218. MLX5_PORT_CHANGE_SUBTYPE_ACTIVE = 4,
  219. MLX5_PORT_CHANGE_SUBTYPE_INITIALIZED = 5,
  220. MLX5_PORT_CHANGE_SUBTYPE_LID = 6,
  221. MLX5_PORT_CHANGE_SUBTYPE_PKEY = 7,
  222. MLX5_PORT_CHANGE_SUBTYPE_GUID = 8,
  223. MLX5_PORT_CHANGE_SUBTYPE_CLIENT_REREG = 9,
  224. };
  225. enum {
  226. MLX5_DEV_CAP_FLAG_XRC = 1LL << 3,
  227. MLX5_DEV_CAP_FLAG_BAD_PKEY_CNTR = 1LL << 8,
  228. MLX5_DEV_CAP_FLAG_BAD_QKEY_CNTR = 1LL << 9,
  229. MLX5_DEV_CAP_FLAG_APM = 1LL << 17,
  230. MLX5_DEV_CAP_FLAG_ATOMIC = 1LL << 18,
  231. MLX5_DEV_CAP_FLAG_BLOCK_MCAST = 1LL << 23,
  232. MLX5_DEV_CAP_FLAG_ON_DMND_PG = 1LL << 24,
  233. MLX5_DEV_CAP_FLAG_CQ_MODER = 1LL << 29,
  234. MLX5_DEV_CAP_FLAG_RESIZE_CQ = 1LL << 30,
  235. MLX5_DEV_CAP_FLAG_DCT = 1LL << 37,
  236. MLX5_DEV_CAP_FLAG_SIG_HAND_OVER = 1LL << 40,
  237. MLX5_DEV_CAP_FLAG_CMDIF_CSUM = 3LL << 46,
  238. };
  239. enum {
  240. MLX5_OPCODE_NOP = 0x00,
  241. MLX5_OPCODE_SEND_INVAL = 0x01,
  242. MLX5_OPCODE_RDMA_WRITE = 0x08,
  243. MLX5_OPCODE_RDMA_WRITE_IMM = 0x09,
  244. MLX5_OPCODE_SEND = 0x0a,
  245. MLX5_OPCODE_SEND_IMM = 0x0b,
  246. MLX5_OPCODE_LSO = 0x0e,
  247. MLX5_OPCODE_RDMA_READ = 0x10,
  248. MLX5_OPCODE_ATOMIC_CS = 0x11,
  249. MLX5_OPCODE_ATOMIC_FA = 0x12,
  250. MLX5_OPCODE_ATOMIC_MASKED_CS = 0x14,
  251. MLX5_OPCODE_ATOMIC_MASKED_FA = 0x15,
  252. MLX5_OPCODE_BIND_MW = 0x18,
  253. MLX5_OPCODE_CONFIG_CMD = 0x1f,
  254. MLX5_RECV_OPCODE_RDMA_WRITE_IMM = 0x00,
  255. MLX5_RECV_OPCODE_SEND = 0x01,
  256. MLX5_RECV_OPCODE_SEND_IMM = 0x02,
  257. MLX5_RECV_OPCODE_SEND_INVAL = 0x03,
  258. MLX5_CQE_OPCODE_ERROR = 0x1e,
  259. MLX5_CQE_OPCODE_RESIZE = 0x16,
  260. MLX5_OPCODE_SET_PSV = 0x20,
  261. MLX5_OPCODE_GET_PSV = 0x21,
  262. MLX5_OPCODE_CHECK_PSV = 0x22,
  263. MLX5_OPCODE_RGET_PSV = 0x26,
  264. MLX5_OPCODE_RCHECK_PSV = 0x27,
  265. MLX5_OPCODE_UMR = 0x25,
  266. };
  267. enum {
  268. MLX5_SET_PORT_RESET_QKEY = 0,
  269. MLX5_SET_PORT_GUID0 = 16,
  270. MLX5_SET_PORT_NODE_GUID = 17,
  271. MLX5_SET_PORT_SYS_GUID = 18,
  272. MLX5_SET_PORT_GID_TABLE = 19,
  273. MLX5_SET_PORT_PKEY_TABLE = 20,
  274. };
  275. enum {
  276. MLX5_MAX_PAGE_SHIFT = 31
  277. };
  278. enum {
  279. MLX5_ADAPTER_PAGE_SHIFT = 12,
  280. MLX5_ADAPTER_PAGE_SIZE = 1 << MLX5_ADAPTER_PAGE_SHIFT,
  281. };
  282. enum {
  283. MLX5_CAP_OFF_CMDIF_CSUM = 46,
  284. };
  285. struct mlx5_inbox_hdr {
  286. __be16 opcode;
  287. u8 rsvd[4];
  288. __be16 opmod;
  289. };
  290. struct mlx5_outbox_hdr {
  291. u8 status;
  292. u8 rsvd[3];
  293. __be32 syndrome;
  294. };
  295. struct mlx5_cmd_query_adapter_mbox_in {
  296. struct mlx5_inbox_hdr hdr;
  297. u8 rsvd[8];
  298. };
  299. struct mlx5_cmd_query_adapter_mbox_out {
  300. struct mlx5_outbox_hdr hdr;
  301. u8 rsvd0[24];
  302. u8 intapin;
  303. u8 rsvd1[13];
  304. __be16 vsd_vendor_id;
  305. u8 vsd[208];
  306. u8 vsd_psid[16];
  307. };
  308. enum mlx5_odp_transport_cap_bits {
  309. MLX5_ODP_SUPPORT_SEND = 1 << 31,
  310. MLX5_ODP_SUPPORT_RECV = 1 << 30,
  311. MLX5_ODP_SUPPORT_WRITE = 1 << 29,
  312. MLX5_ODP_SUPPORT_READ = 1 << 28,
  313. };
  314. struct mlx5_odp_caps {
  315. char reserved[0x10];
  316. struct {
  317. __be32 rc_odp_caps;
  318. __be32 uc_odp_caps;
  319. __be32 ud_odp_caps;
  320. } per_transport_caps;
  321. char reserved2[0xe4];
  322. };
  323. struct mlx5_cmd_init_hca_mbox_in {
  324. struct mlx5_inbox_hdr hdr;
  325. u8 rsvd0[2];
  326. __be16 profile;
  327. u8 rsvd1[4];
  328. };
  329. struct mlx5_cmd_init_hca_mbox_out {
  330. struct mlx5_outbox_hdr hdr;
  331. u8 rsvd[8];
  332. };
  333. struct mlx5_cmd_teardown_hca_mbox_in {
  334. struct mlx5_inbox_hdr hdr;
  335. u8 rsvd0[2];
  336. __be16 profile;
  337. u8 rsvd1[4];
  338. };
  339. struct mlx5_cmd_teardown_hca_mbox_out {
  340. struct mlx5_outbox_hdr hdr;
  341. u8 rsvd[8];
  342. };
  343. struct mlx5_cmd_layout {
  344. u8 type;
  345. u8 rsvd0[3];
  346. __be32 inlen;
  347. __be64 in_ptr;
  348. __be32 in[4];
  349. __be32 out[4];
  350. __be64 out_ptr;
  351. __be32 outlen;
  352. u8 token;
  353. u8 sig;
  354. u8 rsvd1;
  355. u8 status_own;
  356. };
  357. struct health_buffer {
  358. __be32 assert_var[5];
  359. __be32 rsvd0[3];
  360. __be32 assert_exit_ptr;
  361. __be32 assert_callra;
  362. __be32 rsvd1[2];
  363. __be32 fw_ver;
  364. __be32 hw_id;
  365. __be32 rsvd2;
  366. u8 irisc_index;
  367. u8 synd;
  368. __be16 ext_synd;
  369. };
  370. struct mlx5_init_seg {
  371. __be32 fw_rev;
  372. __be32 cmdif_rev_fw_sub;
  373. __be32 rsvd0[2];
  374. __be32 cmdq_addr_h;
  375. __be32 cmdq_addr_l_sz;
  376. __be32 cmd_dbell;
  377. __be32 rsvd1[120];
  378. __be32 initializing;
  379. struct health_buffer health;
  380. __be32 rsvd2[884];
  381. __be32 health_counter;
  382. __be32 rsvd3[1019];
  383. __be64 ieee1588_clk;
  384. __be32 ieee1588_clk_type;
  385. __be32 clr_intx;
  386. };
  387. struct mlx5_eqe_comp {
  388. __be32 reserved[6];
  389. __be32 cqn;
  390. };
  391. struct mlx5_eqe_qp_srq {
  392. __be32 reserved[6];
  393. __be32 qp_srq_n;
  394. };
  395. struct mlx5_eqe_cq_err {
  396. __be32 cqn;
  397. u8 reserved1[7];
  398. u8 syndrome;
  399. };
  400. struct mlx5_eqe_port_state {
  401. u8 reserved0[8];
  402. u8 port;
  403. };
  404. struct mlx5_eqe_gpio {
  405. __be32 reserved0[2];
  406. __be64 gpio_event;
  407. };
  408. struct mlx5_eqe_congestion {
  409. u8 type;
  410. u8 rsvd0;
  411. u8 congestion_level;
  412. };
  413. struct mlx5_eqe_stall_vl {
  414. u8 rsvd0[3];
  415. u8 port_vl;
  416. };
  417. struct mlx5_eqe_cmd {
  418. __be32 vector;
  419. __be32 rsvd[6];
  420. };
  421. struct mlx5_eqe_page_req {
  422. u8 rsvd0[2];
  423. __be16 func_id;
  424. __be32 num_pages;
  425. __be32 rsvd1[5];
  426. };
  427. struct mlx5_eqe_page_fault {
  428. __be32 bytes_committed;
  429. union {
  430. struct {
  431. u16 reserved1;
  432. __be16 wqe_index;
  433. u16 reserved2;
  434. __be16 packet_length;
  435. u8 reserved3[12];
  436. } __packed wqe;
  437. struct {
  438. __be32 r_key;
  439. u16 reserved1;
  440. __be16 packet_length;
  441. __be32 rdma_op_len;
  442. __be64 rdma_va;
  443. } __packed rdma;
  444. } __packed;
  445. __be32 flags_qpn;
  446. } __packed;
  447. union ev_data {
  448. __be32 raw[7];
  449. struct mlx5_eqe_cmd cmd;
  450. struct mlx5_eqe_comp comp;
  451. struct mlx5_eqe_qp_srq qp_srq;
  452. struct mlx5_eqe_cq_err cq_err;
  453. struct mlx5_eqe_port_state port;
  454. struct mlx5_eqe_gpio gpio;
  455. struct mlx5_eqe_congestion cong;
  456. struct mlx5_eqe_stall_vl stall_vl;
  457. struct mlx5_eqe_page_req req_pages;
  458. struct mlx5_eqe_page_fault page_fault;
  459. } __packed;
  460. struct mlx5_eqe {
  461. u8 rsvd0;
  462. u8 type;
  463. u8 rsvd1;
  464. u8 sub_type;
  465. __be32 rsvd2[7];
  466. union ev_data data;
  467. __be16 rsvd3;
  468. u8 signature;
  469. u8 owner;
  470. } __packed;
  471. struct mlx5_cmd_prot_block {
  472. u8 data[MLX5_CMD_DATA_BLOCK_SIZE];
  473. u8 rsvd0[48];
  474. __be64 next;
  475. __be32 block_num;
  476. u8 rsvd1;
  477. u8 token;
  478. u8 ctrl_sig;
  479. u8 sig;
  480. };
  481. enum {
  482. MLX5_CQE_SYND_FLUSHED_IN_ERROR = 5,
  483. };
  484. struct mlx5_err_cqe {
  485. u8 rsvd0[32];
  486. __be32 srqn;
  487. u8 rsvd1[18];
  488. u8 vendor_err_synd;
  489. u8 syndrome;
  490. __be32 s_wqe_opcode_qpn;
  491. __be16 wqe_counter;
  492. u8 signature;
  493. u8 op_own;
  494. };
  495. struct mlx5_cqe64 {
  496. u8 rsvd0[4];
  497. u8 lro_tcppsh_abort_dupack;
  498. u8 lro_min_ttl;
  499. __be16 lro_tcp_win;
  500. __be32 lro_ack_seq_num;
  501. __be32 rss_hash_result;
  502. u8 rss_hash_type;
  503. u8 ml_path;
  504. u8 rsvd20[2];
  505. __be16 check_sum;
  506. __be16 slid;
  507. __be32 flags_rqpn;
  508. u8 hds_ip_ext;
  509. u8 l4_hdr_type_etc;
  510. __be16 vlan_info;
  511. __be32 srqn; /* [31:24]: lro_num_seg, [23:0]: srqn */
  512. __be32 imm_inval_pkey;
  513. u8 rsvd40[4];
  514. __be32 byte_cnt;
  515. __be64 timestamp;
  516. __be32 sop_drop_qpn;
  517. __be16 wqe_counter;
  518. u8 signature;
  519. u8 op_own;
  520. };
  521. static inline int get_cqe_lro_tcppsh(struct mlx5_cqe64 *cqe)
  522. {
  523. return (cqe->lro_tcppsh_abort_dupack >> 6) & 1;
  524. }
  525. static inline u8 get_cqe_l4_hdr_type(struct mlx5_cqe64 *cqe)
  526. {
  527. return (cqe->l4_hdr_type_etc >> 4) & 0x7;
  528. }
  529. static inline int cqe_has_vlan(struct mlx5_cqe64 *cqe)
  530. {
  531. return !!(cqe->l4_hdr_type_etc & 0x1);
  532. }
  533. enum {
  534. CQE_L4_HDR_TYPE_NONE = 0x0,
  535. CQE_L4_HDR_TYPE_TCP_NO_ACK = 0x1,
  536. CQE_L4_HDR_TYPE_UDP = 0x2,
  537. CQE_L4_HDR_TYPE_TCP_ACK_NO_DATA = 0x3,
  538. CQE_L4_HDR_TYPE_TCP_ACK_AND_DATA = 0x4,
  539. };
  540. enum {
  541. CQE_RSS_HTYPE_IP = 0x3 << 6,
  542. CQE_RSS_HTYPE_L4 = 0x3 << 2,
  543. };
  544. enum {
  545. MLX5_CQE_ROCE_L3_HEADER_TYPE_GRH = 0x0,
  546. MLX5_CQE_ROCE_L3_HEADER_TYPE_IPV6 = 0x1,
  547. MLX5_CQE_ROCE_L3_HEADER_TYPE_IPV4 = 0x2,
  548. };
  549. enum {
  550. CQE_L2_OK = 1 << 0,
  551. CQE_L3_OK = 1 << 1,
  552. CQE_L4_OK = 1 << 2,
  553. };
  554. struct mlx5_sig_err_cqe {
  555. u8 rsvd0[16];
  556. __be32 expected_trans_sig;
  557. __be32 actual_trans_sig;
  558. __be32 expected_reftag;
  559. __be32 actual_reftag;
  560. __be16 syndrome;
  561. u8 rsvd22[2];
  562. __be32 mkey;
  563. __be64 err_offset;
  564. u8 rsvd30[8];
  565. __be32 qpn;
  566. u8 rsvd38[2];
  567. u8 signature;
  568. u8 op_own;
  569. };
  570. struct mlx5_wqe_srq_next_seg {
  571. u8 rsvd0[2];
  572. __be16 next_wqe_index;
  573. u8 signature;
  574. u8 rsvd1[11];
  575. };
  576. union mlx5_ext_cqe {
  577. struct ib_grh grh;
  578. u8 inl[64];
  579. };
  580. struct mlx5_cqe128 {
  581. union mlx5_ext_cqe inl_grh;
  582. struct mlx5_cqe64 cqe64;
  583. };
  584. struct mlx5_srq_ctx {
  585. u8 state_log_sz;
  586. u8 rsvd0[3];
  587. __be32 flags_xrcd;
  588. __be32 pgoff_cqn;
  589. u8 rsvd1[4];
  590. u8 log_pg_sz;
  591. u8 rsvd2[7];
  592. __be32 pd;
  593. __be16 lwm;
  594. __be16 wqe_cnt;
  595. u8 rsvd3[8];
  596. __be64 db_record;
  597. };
  598. struct mlx5_create_srq_mbox_in {
  599. struct mlx5_inbox_hdr hdr;
  600. __be32 input_srqn;
  601. u8 rsvd0[4];
  602. struct mlx5_srq_ctx ctx;
  603. u8 rsvd1[208];
  604. __be64 pas[0];
  605. };
  606. struct mlx5_create_srq_mbox_out {
  607. struct mlx5_outbox_hdr hdr;
  608. __be32 srqn;
  609. u8 rsvd[4];
  610. };
  611. struct mlx5_destroy_srq_mbox_in {
  612. struct mlx5_inbox_hdr hdr;
  613. __be32 srqn;
  614. u8 rsvd[4];
  615. };
  616. struct mlx5_destroy_srq_mbox_out {
  617. struct mlx5_outbox_hdr hdr;
  618. u8 rsvd[8];
  619. };
  620. struct mlx5_query_srq_mbox_in {
  621. struct mlx5_inbox_hdr hdr;
  622. __be32 srqn;
  623. u8 rsvd0[4];
  624. };
  625. struct mlx5_query_srq_mbox_out {
  626. struct mlx5_outbox_hdr hdr;
  627. u8 rsvd0[8];
  628. struct mlx5_srq_ctx ctx;
  629. u8 rsvd1[32];
  630. __be64 pas[0];
  631. };
  632. struct mlx5_arm_srq_mbox_in {
  633. struct mlx5_inbox_hdr hdr;
  634. __be32 srqn;
  635. __be16 rsvd;
  636. __be16 lwm;
  637. };
  638. struct mlx5_arm_srq_mbox_out {
  639. struct mlx5_outbox_hdr hdr;
  640. u8 rsvd[8];
  641. };
  642. struct mlx5_cq_context {
  643. u8 status;
  644. u8 cqe_sz_flags;
  645. u8 st;
  646. u8 rsvd3;
  647. u8 rsvd4[6];
  648. __be16 page_offset;
  649. __be32 log_sz_usr_page;
  650. __be16 cq_period;
  651. __be16 cq_max_count;
  652. __be16 rsvd20;
  653. __be16 c_eqn;
  654. u8 log_pg_sz;
  655. u8 rsvd25[7];
  656. __be32 last_notified_index;
  657. __be32 solicit_producer_index;
  658. __be32 consumer_counter;
  659. __be32 producer_counter;
  660. u8 rsvd48[8];
  661. __be64 db_record_addr;
  662. };
  663. struct mlx5_create_cq_mbox_in {
  664. struct mlx5_inbox_hdr hdr;
  665. __be32 input_cqn;
  666. u8 rsvdx[4];
  667. struct mlx5_cq_context ctx;
  668. u8 rsvd6[192];
  669. __be64 pas[0];
  670. };
  671. struct mlx5_create_cq_mbox_out {
  672. struct mlx5_outbox_hdr hdr;
  673. __be32 cqn;
  674. u8 rsvd0[4];
  675. };
  676. struct mlx5_destroy_cq_mbox_in {
  677. struct mlx5_inbox_hdr hdr;
  678. __be32 cqn;
  679. u8 rsvd0[4];
  680. };
  681. struct mlx5_destroy_cq_mbox_out {
  682. struct mlx5_outbox_hdr hdr;
  683. u8 rsvd0[8];
  684. };
  685. struct mlx5_query_cq_mbox_in {
  686. struct mlx5_inbox_hdr hdr;
  687. __be32 cqn;
  688. u8 rsvd0[4];
  689. };
  690. struct mlx5_query_cq_mbox_out {
  691. struct mlx5_outbox_hdr hdr;
  692. u8 rsvd0[8];
  693. struct mlx5_cq_context ctx;
  694. u8 rsvd6[16];
  695. __be64 pas[0];
  696. };
  697. struct mlx5_modify_cq_mbox_in {
  698. struct mlx5_inbox_hdr hdr;
  699. __be32 cqn;
  700. __be32 field_select;
  701. struct mlx5_cq_context ctx;
  702. u8 rsvd[192];
  703. __be64 pas[0];
  704. };
  705. struct mlx5_modify_cq_mbox_out {
  706. struct mlx5_outbox_hdr hdr;
  707. u8 rsvd[8];
  708. };
  709. struct mlx5_enable_hca_mbox_in {
  710. struct mlx5_inbox_hdr hdr;
  711. u8 rsvd[8];
  712. };
  713. struct mlx5_enable_hca_mbox_out {
  714. struct mlx5_outbox_hdr hdr;
  715. u8 rsvd[8];
  716. };
  717. struct mlx5_disable_hca_mbox_in {
  718. struct mlx5_inbox_hdr hdr;
  719. u8 rsvd[8];
  720. };
  721. struct mlx5_disable_hca_mbox_out {
  722. struct mlx5_outbox_hdr hdr;
  723. u8 rsvd[8];
  724. };
  725. struct mlx5_eq_context {
  726. u8 status;
  727. u8 ec_oi;
  728. u8 st;
  729. u8 rsvd2[7];
  730. __be16 page_pffset;
  731. __be32 log_sz_usr_page;
  732. u8 rsvd3[7];
  733. u8 intr;
  734. u8 log_page_size;
  735. u8 rsvd4[15];
  736. __be32 consumer_counter;
  737. __be32 produser_counter;
  738. u8 rsvd5[16];
  739. };
  740. struct mlx5_create_eq_mbox_in {
  741. struct mlx5_inbox_hdr hdr;
  742. u8 rsvd0[3];
  743. u8 input_eqn;
  744. u8 rsvd1[4];
  745. struct mlx5_eq_context ctx;
  746. u8 rsvd2[8];
  747. __be64 events_mask;
  748. u8 rsvd3[176];
  749. __be64 pas[0];
  750. };
  751. struct mlx5_create_eq_mbox_out {
  752. struct mlx5_outbox_hdr hdr;
  753. u8 rsvd0[3];
  754. u8 eq_number;
  755. u8 rsvd1[4];
  756. };
  757. struct mlx5_destroy_eq_mbox_in {
  758. struct mlx5_inbox_hdr hdr;
  759. u8 rsvd0[3];
  760. u8 eqn;
  761. u8 rsvd1[4];
  762. };
  763. struct mlx5_destroy_eq_mbox_out {
  764. struct mlx5_outbox_hdr hdr;
  765. u8 rsvd[8];
  766. };
  767. struct mlx5_map_eq_mbox_in {
  768. struct mlx5_inbox_hdr hdr;
  769. __be64 mask;
  770. u8 mu;
  771. u8 rsvd0[2];
  772. u8 eqn;
  773. u8 rsvd1[24];
  774. };
  775. struct mlx5_map_eq_mbox_out {
  776. struct mlx5_outbox_hdr hdr;
  777. u8 rsvd[8];
  778. };
  779. struct mlx5_query_eq_mbox_in {
  780. struct mlx5_inbox_hdr hdr;
  781. u8 rsvd0[3];
  782. u8 eqn;
  783. u8 rsvd1[4];
  784. };
  785. struct mlx5_query_eq_mbox_out {
  786. struct mlx5_outbox_hdr hdr;
  787. u8 rsvd[8];
  788. struct mlx5_eq_context ctx;
  789. };
  790. enum {
  791. MLX5_MKEY_STATUS_FREE = 1 << 6,
  792. };
  793. struct mlx5_mkey_seg {
  794. /* This is a two bit field occupying bits 31-30.
  795. * bit 31 is always 0,
  796. * bit 30 is zero for regular MRs and 1 (e.g free) for UMRs that do not have tanslation
  797. */
  798. u8 status;
  799. u8 pcie_control;
  800. u8 flags;
  801. u8 version;
  802. __be32 qpn_mkey7_0;
  803. u8 rsvd1[4];
  804. __be32 flags_pd;
  805. __be64 start_addr;
  806. __be64 len;
  807. __be32 bsfs_octo_size;
  808. u8 rsvd2[16];
  809. __be32 xlt_oct_size;
  810. u8 rsvd3[3];
  811. u8 log2_page_size;
  812. u8 rsvd4[4];
  813. };
  814. struct mlx5_query_special_ctxs_mbox_in {
  815. struct mlx5_inbox_hdr hdr;
  816. u8 rsvd[8];
  817. };
  818. struct mlx5_query_special_ctxs_mbox_out {
  819. struct mlx5_outbox_hdr hdr;
  820. __be32 dump_fill_mkey;
  821. __be32 reserved_lkey;
  822. };
  823. struct mlx5_create_mkey_mbox_in {
  824. struct mlx5_inbox_hdr hdr;
  825. __be32 input_mkey_index;
  826. __be32 flags;
  827. struct mlx5_mkey_seg seg;
  828. u8 rsvd1[16];
  829. __be32 xlat_oct_act_size;
  830. __be32 rsvd2;
  831. u8 rsvd3[168];
  832. __be64 pas[0];
  833. };
  834. struct mlx5_create_mkey_mbox_out {
  835. struct mlx5_outbox_hdr hdr;
  836. __be32 mkey;
  837. u8 rsvd[4];
  838. };
  839. struct mlx5_destroy_mkey_mbox_in {
  840. struct mlx5_inbox_hdr hdr;
  841. __be32 mkey;
  842. u8 rsvd[4];
  843. };
  844. struct mlx5_destroy_mkey_mbox_out {
  845. struct mlx5_outbox_hdr hdr;
  846. u8 rsvd[8];
  847. };
  848. struct mlx5_query_mkey_mbox_in {
  849. struct mlx5_inbox_hdr hdr;
  850. __be32 mkey;
  851. };
  852. struct mlx5_query_mkey_mbox_out {
  853. struct mlx5_outbox_hdr hdr;
  854. __be64 pas[0];
  855. };
  856. struct mlx5_modify_mkey_mbox_in {
  857. struct mlx5_inbox_hdr hdr;
  858. __be32 mkey;
  859. __be64 pas[0];
  860. };
  861. struct mlx5_modify_mkey_mbox_out {
  862. struct mlx5_outbox_hdr hdr;
  863. u8 rsvd[8];
  864. };
  865. struct mlx5_dump_mkey_mbox_in {
  866. struct mlx5_inbox_hdr hdr;
  867. };
  868. struct mlx5_dump_mkey_mbox_out {
  869. struct mlx5_outbox_hdr hdr;
  870. __be32 mkey;
  871. };
  872. struct mlx5_mad_ifc_mbox_in {
  873. struct mlx5_inbox_hdr hdr;
  874. __be16 remote_lid;
  875. u8 rsvd0;
  876. u8 port;
  877. u8 rsvd1[4];
  878. u8 data[256];
  879. };
  880. struct mlx5_mad_ifc_mbox_out {
  881. struct mlx5_outbox_hdr hdr;
  882. u8 rsvd[8];
  883. u8 data[256];
  884. };
  885. struct mlx5_access_reg_mbox_in {
  886. struct mlx5_inbox_hdr hdr;
  887. u8 rsvd0[2];
  888. __be16 register_id;
  889. __be32 arg;
  890. __be32 data[0];
  891. };
  892. struct mlx5_access_reg_mbox_out {
  893. struct mlx5_outbox_hdr hdr;
  894. u8 rsvd[8];
  895. __be32 data[0];
  896. };
  897. #define MLX5_ATTR_EXTENDED_PORT_INFO cpu_to_be16(0xff90)
  898. enum {
  899. MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO = 1 << 0
  900. };
  901. struct mlx5_allocate_psv_in {
  902. struct mlx5_inbox_hdr hdr;
  903. __be32 npsv_pd;
  904. __be32 rsvd_psv0;
  905. };
  906. struct mlx5_allocate_psv_out {
  907. struct mlx5_outbox_hdr hdr;
  908. u8 rsvd[8];
  909. __be32 psv_idx[4];
  910. };
  911. struct mlx5_destroy_psv_in {
  912. struct mlx5_inbox_hdr hdr;
  913. __be32 psv_number;
  914. u8 rsvd[4];
  915. };
  916. struct mlx5_destroy_psv_out {
  917. struct mlx5_outbox_hdr hdr;
  918. u8 rsvd[8];
  919. };
  920. #define MLX5_CMD_OP_MAX 0x920
  921. enum {
  922. VPORT_STATE_DOWN = 0x0,
  923. VPORT_STATE_UP = 0x1,
  924. };
  925. enum {
  926. MLX5_L3_PROT_TYPE_IPV4 = 0,
  927. MLX5_L3_PROT_TYPE_IPV6 = 1,
  928. };
  929. enum {
  930. MLX5_L4_PROT_TYPE_TCP = 0,
  931. MLX5_L4_PROT_TYPE_UDP = 1,
  932. };
  933. enum {
  934. MLX5_HASH_FIELD_SEL_SRC_IP = 1 << 0,
  935. MLX5_HASH_FIELD_SEL_DST_IP = 1 << 1,
  936. MLX5_HASH_FIELD_SEL_L4_SPORT = 1 << 2,
  937. MLX5_HASH_FIELD_SEL_L4_DPORT = 1 << 3,
  938. MLX5_HASH_FIELD_SEL_IPSEC_SPI = 1 << 4,
  939. };
  940. enum {
  941. MLX5_MATCH_OUTER_HEADERS = 1 << 0,
  942. MLX5_MATCH_MISC_PARAMETERS = 1 << 1,
  943. MLX5_MATCH_INNER_HEADERS = 1 << 2,
  944. };
  945. enum {
  946. MLX5_FLOW_TABLE_TYPE_NIC_RCV = 0,
  947. MLX5_FLOW_TABLE_TYPE_ESWITCH = 4,
  948. };
  949. enum {
  950. MLX5_FLOW_CONTEXT_DEST_TYPE_VPORT = 0,
  951. MLX5_FLOW_CONTEXT_DEST_TYPE_FLOW_TABLE = 1,
  952. MLX5_FLOW_CONTEXT_DEST_TYPE_TIR = 2,
  953. };
  954. enum {
  955. MLX5_RQC_RQ_TYPE_MEMORY_RQ_INLINE = 0x0,
  956. MLX5_RQC_RQ_TYPE_MEMORY_RQ_RPM = 0x1,
  957. };
  958. /* MLX5 DEV CAPs */
  959. /* TODO: EAT.ME */
  960. enum mlx5_cap_mode {
  961. HCA_CAP_OPMOD_GET_MAX = 0,
  962. HCA_CAP_OPMOD_GET_CUR = 1,
  963. };
  964. enum mlx5_cap_type {
  965. MLX5_CAP_GENERAL = 0,
  966. MLX5_CAP_ETHERNET_OFFLOADS,
  967. MLX5_CAP_ODP,
  968. MLX5_CAP_ATOMIC,
  969. MLX5_CAP_ROCE,
  970. MLX5_CAP_IPOIB_OFFLOADS,
  971. MLX5_CAP_EOIB_OFFLOADS,
  972. MLX5_CAP_FLOW_TABLE,
  973. /* NUM OF CAP Types */
  974. MLX5_CAP_NUM
  975. };
  976. /* GET Dev Caps macros */
  977. #define MLX5_CAP_GEN(mdev, cap) \
  978. MLX5_GET(cmd_hca_cap, mdev->hca_caps_cur[MLX5_CAP_GENERAL], cap)
  979. #define MLX5_CAP_GEN_MAX(mdev, cap) \
  980. MLX5_GET(cmd_hca_cap, mdev->hca_caps_max[MLX5_CAP_GENERAL], cap)
  981. #define MLX5_CAP_ETH(mdev, cap) \
  982. MLX5_GET(per_protocol_networking_offload_caps,\
  983. mdev->hca_caps_cur[MLX5_CAP_ETHERNET_OFFLOADS], cap)
  984. #define MLX5_CAP_ETH_MAX(mdev, cap) \
  985. MLX5_GET(per_protocol_networking_offload_caps,\
  986. mdev->hca_caps_max[MLX5_CAP_ETHERNET_OFFLOADS], cap)
  987. #define MLX5_CAP_ROCE(mdev, cap) \
  988. MLX5_GET(roce_cap, mdev->hca_caps_cur[MLX5_CAP_ROCE], cap)
  989. #define MLX5_CAP_ROCE_MAX(mdev, cap) \
  990. MLX5_GET(roce_cap, mdev->hca_caps_max[MLX5_CAP_ROCE], cap)
  991. #define MLX5_CAP_ATOMIC(mdev, cap) \
  992. MLX5_GET(atomic_caps, mdev->hca_caps_cur[MLX5_CAP_ATOMIC], cap)
  993. #define MLX5_CAP_ATOMIC_MAX(mdev, cap) \
  994. MLX5_GET(atomic_caps, mdev->hca_caps_max[MLX5_CAP_ATOMIC], cap)
  995. #define MLX5_CAP_FLOWTABLE(mdev, cap) \
  996. MLX5_GET(flow_table_nic_cap, mdev->hca_caps_cur[MLX5_CAP_FLOW_TABLE], cap)
  997. #define MLX5_CAP_FLOWTABLE_MAX(mdev, cap) \
  998. MLX5_GET(flow_table_nic_cap, mdev->hca_caps_max[MLX5_CAP_FLOW_TABLE], cap)
  999. #define MLX5_CAP_ODP(mdev, cap)\
  1000. MLX5_GET(odp_cap, mdev->hca_caps_cur[MLX5_CAP_ODP], cap)
  1001. enum {
  1002. MLX5_CMD_STAT_OK = 0x0,
  1003. MLX5_CMD_STAT_INT_ERR = 0x1,
  1004. MLX5_CMD_STAT_BAD_OP_ERR = 0x2,
  1005. MLX5_CMD_STAT_BAD_PARAM_ERR = 0x3,
  1006. MLX5_CMD_STAT_BAD_SYS_STATE_ERR = 0x4,
  1007. MLX5_CMD_STAT_BAD_RES_ERR = 0x5,
  1008. MLX5_CMD_STAT_RES_BUSY = 0x6,
  1009. MLX5_CMD_STAT_LIM_ERR = 0x8,
  1010. MLX5_CMD_STAT_BAD_RES_STATE_ERR = 0x9,
  1011. MLX5_CMD_STAT_IX_ERR = 0xa,
  1012. MLX5_CMD_STAT_NO_RES_ERR = 0xf,
  1013. MLX5_CMD_STAT_BAD_INP_LEN_ERR = 0x50,
  1014. MLX5_CMD_STAT_BAD_OUTP_LEN_ERR = 0x51,
  1015. MLX5_CMD_STAT_BAD_QP_STATE_ERR = 0x10,
  1016. MLX5_CMD_STAT_BAD_PKT_ERR = 0x30,
  1017. MLX5_CMD_STAT_BAD_SIZE_OUTS_CQES_ERR = 0x40,
  1018. };
  1019. enum {
  1020. MLX5_IEEE_802_3_COUNTERS_GROUP = 0x0,
  1021. MLX5_RFC_2863_COUNTERS_GROUP = 0x1,
  1022. MLX5_RFC_2819_COUNTERS_GROUP = 0x2,
  1023. MLX5_RFC_3635_COUNTERS_GROUP = 0x3,
  1024. MLX5_ETHERNET_EXTENDED_COUNTERS_GROUP = 0x5,
  1025. MLX5_PER_PRIORITY_COUNTERS_GROUP = 0x10,
  1026. MLX5_PER_TRAFFIC_CLASS_COUNTERS_GROUP = 0x11
  1027. };
  1028. static inline u16 mlx5_to_sw_pkey_sz(int pkey_sz)
  1029. {
  1030. if (pkey_sz > MLX5_MAX_LOG_PKEY_TABLE)
  1031. return 0;
  1032. return MLX5_MIN_PKEY_TABLE_SIZE << pkey_sz;
  1033. }
  1034. #endif /* MLX5_DEVICE_H */