device.h 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261
  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. MLX5_EVENT_TYPE_NIC_VPORT_CHANGE = 0xd,
  216. };
  217. enum {
  218. MLX5_PORT_CHANGE_SUBTYPE_DOWN = 1,
  219. MLX5_PORT_CHANGE_SUBTYPE_ACTIVE = 4,
  220. MLX5_PORT_CHANGE_SUBTYPE_INITIALIZED = 5,
  221. MLX5_PORT_CHANGE_SUBTYPE_LID = 6,
  222. MLX5_PORT_CHANGE_SUBTYPE_PKEY = 7,
  223. MLX5_PORT_CHANGE_SUBTYPE_GUID = 8,
  224. MLX5_PORT_CHANGE_SUBTYPE_CLIENT_REREG = 9,
  225. };
  226. enum {
  227. MLX5_DEV_CAP_FLAG_XRC = 1LL << 3,
  228. MLX5_DEV_CAP_FLAG_BAD_PKEY_CNTR = 1LL << 8,
  229. MLX5_DEV_CAP_FLAG_BAD_QKEY_CNTR = 1LL << 9,
  230. MLX5_DEV_CAP_FLAG_APM = 1LL << 17,
  231. MLX5_DEV_CAP_FLAG_ATOMIC = 1LL << 18,
  232. MLX5_DEV_CAP_FLAG_BLOCK_MCAST = 1LL << 23,
  233. MLX5_DEV_CAP_FLAG_ON_DMND_PG = 1LL << 24,
  234. MLX5_DEV_CAP_FLAG_CQ_MODER = 1LL << 29,
  235. MLX5_DEV_CAP_FLAG_RESIZE_CQ = 1LL << 30,
  236. MLX5_DEV_CAP_FLAG_DCT = 1LL << 37,
  237. MLX5_DEV_CAP_FLAG_SIG_HAND_OVER = 1LL << 40,
  238. MLX5_DEV_CAP_FLAG_CMDIF_CSUM = 3LL << 46,
  239. };
  240. enum {
  241. MLX5_OPCODE_NOP = 0x00,
  242. MLX5_OPCODE_SEND_INVAL = 0x01,
  243. MLX5_OPCODE_RDMA_WRITE = 0x08,
  244. MLX5_OPCODE_RDMA_WRITE_IMM = 0x09,
  245. MLX5_OPCODE_SEND = 0x0a,
  246. MLX5_OPCODE_SEND_IMM = 0x0b,
  247. MLX5_OPCODE_LSO = 0x0e,
  248. MLX5_OPCODE_RDMA_READ = 0x10,
  249. MLX5_OPCODE_ATOMIC_CS = 0x11,
  250. MLX5_OPCODE_ATOMIC_FA = 0x12,
  251. MLX5_OPCODE_ATOMIC_MASKED_CS = 0x14,
  252. MLX5_OPCODE_ATOMIC_MASKED_FA = 0x15,
  253. MLX5_OPCODE_BIND_MW = 0x18,
  254. MLX5_OPCODE_CONFIG_CMD = 0x1f,
  255. MLX5_RECV_OPCODE_RDMA_WRITE_IMM = 0x00,
  256. MLX5_RECV_OPCODE_SEND = 0x01,
  257. MLX5_RECV_OPCODE_SEND_IMM = 0x02,
  258. MLX5_RECV_OPCODE_SEND_INVAL = 0x03,
  259. MLX5_CQE_OPCODE_ERROR = 0x1e,
  260. MLX5_CQE_OPCODE_RESIZE = 0x16,
  261. MLX5_OPCODE_SET_PSV = 0x20,
  262. MLX5_OPCODE_GET_PSV = 0x21,
  263. MLX5_OPCODE_CHECK_PSV = 0x22,
  264. MLX5_OPCODE_RGET_PSV = 0x26,
  265. MLX5_OPCODE_RCHECK_PSV = 0x27,
  266. MLX5_OPCODE_UMR = 0x25,
  267. };
  268. enum {
  269. MLX5_SET_PORT_RESET_QKEY = 0,
  270. MLX5_SET_PORT_GUID0 = 16,
  271. MLX5_SET_PORT_NODE_GUID = 17,
  272. MLX5_SET_PORT_SYS_GUID = 18,
  273. MLX5_SET_PORT_GID_TABLE = 19,
  274. MLX5_SET_PORT_PKEY_TABLE = 20,
  275. };
  276. enum {
  277. MLX5_MAX_PAGE_SHIFT = 31
  278. };
  279. enum {
  280. MLX5_ADAPTER_PAGE_SHIFT = 12,
  281. MLX5_ADAPTER_PAGE_SIZE = 1 << MLX5_ADAPTER_PAGE_SHIFT,
  282. };
  283. enum {
  284. MLX5_CAP_OFF_CMDIF_CSUM = 46,
  285. };
  286. struct mlx5_inbox_hdr {
  287. __be16 opcode;
  288. u8 rsvd[4];
  289. __be16 opmod;
  290. };
  291. struct mlx5_outbox_hdr {
  292. u8 status;
  293. u8 rsvd[3];
  294. __be32 syndrome;
  295. };
  296. struct mlx5_cmd_query_adapter_mbox_in {
  297. struct mlx5_inbox_hdr hdr;
  298. u8 rsvd[8];
  299. };
  300. struct mlx5_cmd_query_adapter_mbox_out {
  301. struct mlx5_outbox_hdr hdr;
  302. u8 rsvd0[24];
  303. u8 intapin;
  304. u8 rsvd1[13];
  305. __be16 vsd_vendor_id;
  306. u8 vsd[208];
  307. u8 vsd_psid[16];
  308. };
  309. enum mlx5_odp_transport_cap_bits {
  310. MLX5_ODP_SUPPORT_SEND = 1 << 31,
  311. MLX5_ODP_SUPPORT_RECV = 1 << 30,
  312. MLX5_ODP_SUPPORT_WRITE = 1 << 29,
  313. MLX5_ODP_SUPPORT_READ = 1 << 28,
  314. };
  315. struct mlx5_odp_caps {
  316. char reserved[0x10];
  317. struct {
  318. __be32 rc_odp_caps;
  319. __be32 uc_odp_caps;
  320. __be32 ud_odp_caps;
  321. } per_transport_caps;
  322. char reserved2[0xe4];
  323. };
  324. struct mlx5_cmd_init_hca_mbox_in {
  325. struct mlx5_inbox_hdr hdr;
  326. u8 rsvd0[2];
  327. __be16 profile;
  328. u8 rsvd1[4];
  329. };
  330. struct mlx5_cmd_init_hca_mbox_out {
  331. struct mlx5_outbox_hdr hdr;
  332. u8 rsvd[8];
  333. };
  334. struct mlx5_cmd_teardown_hca_mbox_in {
  335. struct mlx5_inbox_hdr hdr;
  336. u8 rsvd0[2];
  337. __be16 profile;
  338. u8 rsvd1[4];
  339. };
  340. struct mlx5_cmd_teardown_hca_mbox_out {
  341. struct mlx5_outbox_hdr hdr;
  342. u8 rsvd[8];
  343. };
  344. struct mlx5_cmd_layout {
  345. u8 type;
  346. u8 rsvd0[3];
  347. __be32 inlen;
  348. __be64 in_ptr;
  349. __be32 in[4];
  350. __be32 out[4];
  351. __be64 out_ptr;
  352. __be32 outlen;
  353. u8 token;
  354. u8 sig;
  355. u8 rsvd1;
  356. u8 status_own;
  357. };
  358. struct health_buffer {
  359. __be32 assert_var[5];
  360. __be32 rsvd0[3];
  361. __be32 assert_exit_ptr;
  362. __be32 assert_callra;
  363. __be32 rsvd1[2];
  364. __be32 fw_ver;
  365. __be32 hw_id;
  366. __be32 rsvd2;
  367. u8 irisc_index;
  368. u8 synd;
  369. __be16 ext_synd;
  370. };
  371. struct mlx5_init_seg {
  372. __be32 fw_rev;
  373. __be32 cmdif_rev_fw_sub;
  374. __be32 rsvd0[2];
  375. __be32 cmdq_addr_h;
  376. __be32 cmdq_addr_l_sz;
  377. __be32 cmd_dbell;
  378. __be32 rsvd1[120];
  379. __be32 initializing;
  380. struct health_buffer health;
  381. __be32 rsvd2[880];
  382. __be32 internal_timer_h;
  383. __be32 internal_timer_l;
  384. __be32 rsrv3[2];
  385. __be32 health_counter;
  386. __be32 rsvd4[1019];
  387. __be64 ieee1588_clk;
  388. __be32 ieee1588_clk_type;
  389. __be32 clr_intx;
  390. };
  391. struct mlx5_eqe_comp {
  392. __be32 reserved[6];
  393. __be32 cqn;
  394. };
  395. struct mlx5_eqe_qp_srq {
  396. __be32 reserved[6];
  397. __be32 qp_srq_n;
  398. };
  399. struct mlx5_eqe_cq_err {
  400. __be32 cqn;
  401. u8 reserved1[7];
  402. u8 syndrome;
  403. };
  404. struct mlx5_eqe_port_state {
  405. u8 reserved0[8];
  406. u8 port;
  407. };
  408. struct mlx5_eqe_gpio {
  409. __be32 reserved0[2];
  410. __be64 gpio_event;
  411. };
  412. struct mlx5_eqe_congestion {
  413. u8 type;
  414. u8 rsvd0;
  415. u8 congestion_level;
  416. };
  417. struct mlx5_eqe_stall_vl {
  418. u8 rsvd0[3];
  419. u8 port_vl;
  420. };
  421. struct mlx5_eqe_cmd {
  422. __be32 vector;
  423. __be32 rsvd[6];
  424. };
  425. struct mlx5_eqe_page_req {
  426. u8 rsvd0[2];
  427. __be16 func_id;
  428. __be32 num_pages;
  429. __be32 rsvd1[5];
  430. };
  431. struct mlx5_eqe_page_fault {
  432. __be32 bytes_committed;
  433. union {
  434. struct {
  435. u16 reserved1;
  436. __be16 wqe_index;
  437. u16 reserved2;
  438. __be16 packet_length;
  439. u8 reserved3[12];
  440. } __packed wqe;
  441. struct {
  442. __be32 r_key;
  443. u16 reserved1;
  444. __be16 packet_length;
  445. __be32 rdma_op_len;
  446. __be64 rdma_va;
  447. } __packed rdma;
  448. } __packed;
  449. __be32 flags_qpn;
  450. } __packed;
  451. struct mlx5_eqe_vport_change {
  452. u8 rsvd0[2];
  453. __be16 vport_num;
  454. __be32 rsvd1[6];
  455. } __packed;
  456. union ev_data {
  457. __be32 raw[7];
  458. struct mlx5_eqe_cmd cmd;
  459. struct mlx5_eqe_comp comp;
  460. struct mlx5_eqe_qp_srq qp_srq;
  461. struct mlx5_eqe_cq_err cq_err;
  462. struct mlx5_eqe_port_state port;
  463. struct mlx5_eqe_gpio gpio;
  464. struct mlx5_eqe_congestion cong;
  465. struct mlx5_eqe_stall_vl stall_vl;
  466. struct mlx5_eqe_page_req req_pages;
  467. struct mlx5_eqe_page_fault page_fault;
  468. struct mlx5_eqe_vport_change vport_change;
  469. } __packed;
  470. struct mlx5_eqe {
  471. u8 rsvd0;
  472. u8 type;
  473. u8 rsvd1;
  474. u8 sub_type;
  475. __be32 rsvd2[7];
  476. union ev_data data;
  477. __be16 rsvd3;
  478. u8 signature;
  479. u8 owner;
  480. } __packed;
  481. struct mlx5_cmd_prot_block {
  482. u8 data[MLX5_CMD_DATA_BLOCK_SIZE];
  483. u8 rsvd0[48];
  484. __be64 next;
  485. __be32 block_num;
  486. u8 rsvd1;
  487. u8 token;
  488. u8 ctrl_sig;
  489. u8 sig;
  490. };
  491. enum {
  492. MLX5_CQE_SYND_FLUSHED_IN_ERROR = 5,
  493. };
  494. struct mlx5_err_cqe {
  495. u8 rsvd0[32];
  496. __be32 srqn;
  497. u8 rsvd1[18];
  498. u8 vendor_err_synd;
  499. u8 syndrome;
  500. __be32 s_wqe_opcode_qpn;
  501. __be16 wqe_counter;
  502. u8 signature;
  503. u8 op_own;
  504. };
  505. struct mlx5_cqe64 {
  506. u8 rsvd0[4];
  507. u8 lro_tcppsh_abort_dupack;
  508. u8 lro_min_ttl;
  509. __be16 lro_tcp_win;
  510. __be32 lro_ack_seq_num;
  511. __be32 rss_hash_result;
  512. u8 rss_hash_type;
  513. u8 ml_path;
  514. u8 rsvd20[2];
  515. __be16 check_sum;
  516. __be16 slid;
  517. __be32 flags_rqpn;
  518. u8 hds_ip_ext;
  519. u8 l4_hdr_type_etc;
  520. __be16 vlan_info;
  521. __be32 srqn; /* [31:24]: lro_num_seg, [23:0]: srqn */
  522. __be32 imm_inval_pkey;
  523. u8 rsvd40[4];
  524. __be32 byte_cnt;
  525. __be32 timestamp_h;
  526. __be32 timestamp_l;
  527. __be32 sop_drop_qpn;
  528. __be16 wqe_counter;
  529. u8 signature;
  530. u8 op_own;
  531. };
  532. static inline int get_cqe_lro_tcppsh(struct mlx5_cqe64 *cqe)
  533. {
  534. return (cqe->lro_tcppsh_abort_dupack >> 6) & 1;
  535. }
  536. static inline u8 get_cqe_l4_hdr_type(struct mlx5_cqe64 *cqe)
  537. {
  538. return (cqe->l4_hdr_type_etc >> 4) & 0x7;
  539. }
  540. static inline int cqe_has_vlan(struct mlx5_cqe64 *cqe)
  541. {
  542. return !!(cqe->l4_hdr_type_etc & 0x1);
  543. }
  544. static inline u64 get_cqe_ts(struct mlx5_cqe64 *cqe)
  545. {
  546. u32 hi, lo;
  547. hi = be32_to_cpu(cqe->timestamp_h);
  548. lo = be32_to_cpu(cqe->timestamp_l);
  549. return (u64)lo | ((u64)hi << 32);
  550. }
  551. enum {
  552. CQE_L4_HDR_TYPE_NONE = 0x0,
  553. CQE_L4_HDR_TYPE_TCP_NO_ACK = 0x1,
  554. CQE_L4_HDR_TYPE_UDP = 0x2,
  555. CQE_L4_HDR_TYPE_TCP_ACK_NO_DATA = 0x3,
  556. CQE_L4_HDR_TYPE_TCP_ACK_AND_DATA = 0x4,
  557. };
  558. enum {
  559. CQE_RSS_HTYPE_IP = 0x3 << 6,
  560. CQE_RSS_HTYPE_L4 = 0x3 << 2,
  561. };
  562. enum {
  563. CQE_L2_OK = 1 << 0,
  564. CQE_L3_OK = 1 << 1,
  565. CQE_L4_OK = 1 << 2,
  566. };
  567. struct mlx5_sig_err_cqe {
  568. u8 rsvd0[16];
  569. __be32 expected_trans_sig;
  570. __be32 actual_trans_sig;
  571. __be32 expected_reftag;
  572. __be32 actual_reftag;
  573. __be16 syndrome;
  574. u8 rsvd22[2];
  575. __be32 mkey;
  576. __be64 err_offset;
  577. u8 rsvd30[8];
  578. __be32 qpn;
  579. u8 rsvd38[2];
  580. u8 signature;
  581. u8 op_own;
  582. };
  583. struct mlx5_wqe_srq_next_seg {
  584. u8 rsvd0[2];
  585. __be16 next_wqe_index;
  586. u8 signature;
  587. u8 rsvd1[11];
  588. };
  589. union mlx5_ext_cqe {
  590. struct ib_grh grh;
  591. u8 inl[64];
  592. };
  593. struct mlx5_cqe128 {
  594. union mlx5_ext_cqe inl_grh;
  595. struct mlx5_cqe64 cqe64;
  596. };
  597. struct mlx5_srq_ctx {
  598. u8 state_log_sz;
  599. u8 rsvd0[3];
  600. __be32 flags_xrcd;
  601. __be32 pgoff_cqn;
  602. u8 rsvd1[4];
  603. u8 log_pg_sz;
  604. u8 rsvd2[7];
  605. __be32 pd;
  606. __be16 lwm;
  607. __be16 wqe_cnt;
  608. u8 rsvd3[8];
  609. __be64 db_record;
  610. };
  611. struct mlx5_create_srq_mbox_in {
  612. struct mlx5_inbox_hdr hdr;
  613. __be32 input_srqn;
  614. u8 rsvd0[4];
  615. struct mlx5_srq_ctx ctx;
  616. u8 rsvd1[208];
  617. __be64 pas[0];
  618. };
  619. struct mlx5_create_srq_mbox_out {
  620. struct mlx5_outbox_hdr hdr;
  621. __be32 srqn;
  622. u8 rsvd[4];
  623. };
  624. struct mlx5_destroy_srq_mbox_in {
  625. struct mlx5_inbox_hdr hdr;
  626. __be32 srqn;
  627. u8 rsvd[4];
  628. };
  629. struct mlx5_destroy_srq_mbox_out {
  630. struct mlx5_outbox_hdr hdr;
  631. u8 rsvd[8];
  632. };
  633. struct mlx5_query_srq_mbox_in {
  634. struct mlx5_inbox_hdr hdr;
  635. __be32 srqn;
  636. u8 rsvd0[4];
  637. };
  638. struct mlx5_query_srq_mbox_out {
  639. struct mlx5_outbox_hdr hdr;
  640. u8 rsvd0[8];
  641. struct mlx5_srq_ctx ctx;
  642. u8 rsvd1[32];
  643. __be64 pas[0];
  644. };
  645. struct mlx5_arm_srq_mbox_in {
  646. struct mlx5_inbox_hdr hdr;
  647. __be32 srqn;
  648. __be16 rsvd;
  649. __be16 lwm;
  650. };
  651. struct mlx5_arm_srq_mbox_out {
  652. struct mlx5_outbox_hdr hdr;
  653. u8 rsvd[8];
  654. };
  655. struct mlx5_cq_context {
  656. u8 status;
  657. u8 cqe_sz_flags;
  658. u8 st;
  659. u8 rsvd3;
  660. u8 rsvd4[6];
  661. __be16 page_offset;
  662. __be32 log_sz_usr_page;
  663. __be16 cq_period;
  664. __be16 cq_max_count;
  665. __be16 rsvd20;
  666. __be16 c_eqn;
  667. u8 log_pg_sz;
  668. u8 rsvd25[7];
  669. __be32 last_notified_index;
  670. __be32 solicit_producer_index;
  671. __be32 consumer_counter;
  672. __be32 producer_counter;
  673. u8 rsvd48[8];
  674. __be64 db_record_addr;
  675. };
  676. struct mlx5_create_cq_mbox_in {
  677. struct mlx5_inbox_hdr hdr;
  678. __be32 input_cqn;
  679. u8 rsvdx[4];
  680. struct mlx5_cq_context ctx;
  681. u8 rsvd6[192];
  682. __be64 pas[0];
  683. };
  684. struct mlx5_create_cq_mbox_out {
  685. struct mlx5_outbox_hdr hdr;
  686. __be32 cqn;
  687. u8 rsvd0[4];
  688. };
  689. struct mlx5_destroy_cq_mbox_in {
  690. struct mlx5_inbox_hdr hdr;
  691. __be32 cqn;
  692. u8 rsvd0[4];
  693. };
  694. struct mlx5_destroy_cq_mbox_out {
  695. struct mlx5_outbox_hdr hdr;
  696. u8 rsvd0[8];
  697. };
  698. struct mlx5_query_cq_mbox_in {
  699. struct mlx5_inbox_hdr hdr;
  700. __be32 cqn;
  701. u8 rsvd0[4];
  702. };
  703. struct mlx5_query_cq_mbox_out {
  704. struct mlx5_outbox_hdr hdr;
  705. u8 rsvd0[8];
  706. struct mlx5_cq_context ctx;
  707. u8 rsvd6[16];
  708. __be64 pas[0];
  709. };
  710. struct mlx5_modify_cq_mbox_in {
  711. struct mlx5_inbox_hdr hdr;
  712. __be32 cqn;
  713. __be32 field_select;
  714. struct mlx5_cq_context ctx;
  715. u8 rsvd[192];
  716. __be64 pas[0];
  717. };
  718. struct mlx5_modify_cq_mbox_out {
  719. struct mlx5_outbox_hdr hdr;
  720. u8 rsvd[8];
  721. };
  722. struct mlx5_enable_hca_mbox_in {
  723. struct mlx5_inbox_hdr hdr;
  724. u8 rsvd[8];
  725. };
  726. struct mlx5_enable_hca_mbox_out {
  727. struct mlx5_outbox_hdr hdr;
  728. u8 rsvd[8];
  729. };
  730. struct mlx5_disable_hca_mbox_in {
  731. struct mlx5_inbox_hdr hdr;
  732. u8 rsvd[8];
  733. };
  734. struct mlx5_disable_hca_mbox_out {
  735. struct mlx5_outbox_hdr hdr;
  736. u8 rsvd[8];
  737. };
  738. struct mlx5_eq_context {
  739. u8 status;
  740. u8 ec_oi;
  741. u8 st;
  742. u8 rsvd2[7];
  743. __be16 page_pffset;
  744. __be32 log_sz_usr_page;
  745. u8 rsvd3[7];
  746. u8 intr;
  747. u8 log_page_size;
  748. u8 rsvd4[15];
  749. __be32 consumer_counter;
  750. __be32 produser_counter;
  751. u8 rsvd5[16];
  752. };
  753. struct mlx5_create_eq_mbox_in {
  754. struct mlx5_inbox_hdr hdr;
  755. u8 rsvd0[3];
  756. u8 input_eqn;
  757. u8 rsvd1[4];
  758. struct mlx5_eq_context ctx;
  759. u8 rsvd2[8];
  760. __be64 events_mask;
  761. u8 rsvd3[176];
  762. __be64 pas[0];
  763. };
  764. struct mlx5_create_eq_mbox_out {
  765. struct mlx5_outbox_hdr hdr;
  766. u8 rsvd0[3];
  767. u8 eq_number;
  768. u8 rsvd1[4];
  769. };
  770. struct mlx5_destroy_eq_mbox_in {
  771. struct mlx5_inbox_hdr hdr;
  772. u8 rsvd0[3];
  773. u8 eqn;
  774. u8 rsvd1[4];
  775. };
  776. struct mlx5_destroy_eq_mbox_out {
  777. struct mlx5_outbox_hdr hdr;
  778. u8 rsvd[8];
  779. };
  780. struct mlx5_map_eq_mbox_in {
  781. struct mlx5_inbox_hdr hdr;
  782. __be64 mask;
  783. u8 mu;
  784. u8 rsvd0[2];
  785. u8 eqn;
  786. u8 rsvd1[24];
  787. };
  788. struct mlx5_map_eq_mbox_out {
  789. struct mlx5_outbox_hdr hdr;
  790. u8 rsvd[8];
  791. };
  792. struct mlx5_query_eq_mbox_in {
  793. struct mlx5_inbox_hdr hdr;
  794. u8 rsvd0[3];
  795. u8 eqn;
  796. u8 rsvd1[4];
  797. };
  798. struct mlx5_query_eq_mbox_out {
  799. struct mlx5_outbox_hdr hdr;
  800. u8 rsvd[8];
  801. struct mlx5_eq_context ctx;
  802. };
  803. enum {
  804. MLX5_MKEY_STATUS_FREE = 1 << 6,
  805. };
  806. struct mlx5_mkey_seg {
  807. /* This is a two bit field occupying bits 31-30.
  808. * bit 31 is always 0,
  809. * bit 30 is zero for regular MRs and 1 (e.g free) for UMRs that do not have tanslation
  810. */
  811. u8 status;
  812. u8 pcie_control;
  813. u8 flags;
  814. u8 version;
  815. __be32 qpn_mkey7_0;
  816. u8 rsvd1[4];
  817. __be32 flags_pd;
  818. __be64 start_addr;
  819. __be64 len;
  820. __be32 bsfs_octo_size;
  821. u8 rsvd2[16];
  822. __be32 xlt_oct_size;
  823. u8 rsvd3[3];
  824. u8 log2_page_size;
  825. u8 rsvd4[4];
  826. };
  827. struct mlx5_query_special_ctxs_mbox_in {
  828. struct mlx5_inbox_hdr hdr;
  829. u8 rsvd[8];
  830. };
  831. struct mlx5_query_special_ctxs_mbox_out {
  832. struct mlx5_outbox_hdr hdr;
  833. __be32 dump_fill_mkey;
  834. __be32 reserved_lkey;
  835. };
  836. struct mlx5_create_mkey_mbox_in {
  837. struct mlx5_inbox_hdr hdr;
  838. __be32 input_mkey_index;
  839. __be32 flags;
  840. struct mlx5_mkey_seg seg;
  841. u8 rsvd1[16];
  842. __be32 xlat_oct_act_size;
  843. __be32 rsvd2;
  844. u8 rsvd3[168];
  845. __be64 pas[0];
  846. };
  847. struct mlx5_create_mkey_mbox_out {
  848. struct mlx5_outbox_hdr hdr;
  849. __be32 mkey;
  850. u8 rsvd[4];
  851. };
  852. struct mlx5_destroy_mkey_mbox_in {
  853. struct mlx5_inbox_hdr hdr;
  854. __be32 mkey;
  855. u8 rsvd[4];
  856. };
  857. struct mlx5_destroy_mkey_mbox_out {
  858. struct mlx5_outbox_hdr hdr;
  859. u8 rsvd[8];
  860. };
  861. struct mlx5_query_mkey_mbox_in {
  862. struct mlx5_inbox_hdr hdr;
  863. __be32 mkey;
  864. };
  865. struct mlx5_query_mkey_mbox_out {
  866. struct mlx5_outbox_hdr hdr;
  867. __be64 pas[0];
  868. };
  869. struct mlx5_modify_mkey_mbox_in {
  870. struct mlx5_inbox_hdr hdr;
  871. __be32 mkey;
  872. __be64 pas[0];
  873. };
  874. struct mlx5_modify_mkey_mbox_out {
  875. struct mlx5_outbox_hdr hdr;
  876. u8 rsvd[8];
  877. };
  878. struct mlx5_dump_mkey_mbox_in {
  879. struct mlx5_inbox_hdr hdr;
  880. };
  881. struct mlx5_dump_mkey_mbox_out {
  882. struct mlx5_outbox_hdr hdr;
  883. __be32 mkey;
  884. };
  885. struct mlx5_mad_ifc_mbox_in {
  886. struct mlx5_inbox_hdr hdr;
  887. __be16 remote_lid;
  888. u8 rsvd0;
  889. u8 port;
  890. u8 rsvd1[4];
  891. u8 data[256];
  892. };
  893. struct mlx5_mad_ifc_mbox_out {
  894. struct mlx5_outbox_hdr hdr;
  895. u8 rsvd[8];
  896. u8 data[256];
  897. };
  898. struct mlx5_access_reg_mbox_in {
  899. struct mlx5_inbox_hdr hdr;
  900. u8 rsvd0[2];
  901. __be16 register_id;
  902. __be32 arg;
  903. __be32 data[0];
  904. };
  905. struct mlx5_access_reg_mbox_out {
  906. struct mlx5_outbox_hdr hdr;
  907. u8 rsvd[8];
  908. __be32 data[0];
  909. };
  910. #define MLX5_ATTR_EXTENDED_PORT_INFO cpu_to_be16(0xff90)
  911. enum {
  912. MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO = 1 << 0
  913. };
  914. struct mlx5_allocate_psv_in {
  915. struct mlx5_inbox_hdr hdr;
  916. __be32 npsv_pd;
  917. __be32 rsvd_psv0;
  918. };
  919. struct mlx5_allocate_psv_out {
  920. struct mlx5_outbox_hdr hdr;
  921. u8 rsvd[8];
  922. __be32 psv_idx[4];
  923. };
  924. struct mlx5_destroy_psv_in {
  925. struct mlx5_inbox_hdr hdr;
  926. __be32 psv_number;
  927. u8 rsvd[4];
  928. };
  929. struct mlx5_destroy_psv_out {
  930. struct mlx5_outbox_hdr hdr;
  931. u8 rsvd[8];
  932. };
  933. #define MLX5_CMD_OP_MAX 0x920
  934. enum {
  935. VPORT_STATE_DOWN = 0x0,
  936. VPORT_STATE_UP = 0x1,
  937. };
  938. enum {
  939. MLX5_ESW_VPORT_ADMIN_STATE_DOWN = 0x0,
  940. MLX5_ESW_VPORT_ADMIN_STATE_UP = 0x1,
  941. MLX5_ESW_VPORT_ADMIN_STATE_AUTO = 0x2,
  942. };
  943. enum {
  944. MLX5_L3_PROT_TYPE_IPV4 = 0,
  945. MLX5_L3_PROT_TYPE_IPV6 = 1,
  946. };
  947. enum {
  948. MLX5_L4_PROT_TYPE_TCP = 0,
  949. MLX5_L4_PROT_TYPE_UDP = 1,
  950. };
  951. enum {
  952. MLX5_HASH_FIELD_SEL_SRC_IP = 1 << 0,
  953. MLX5_HASH_FIELD_SEL_DST_IP = 1 << 1,
  954. MLX5_HASH_FIELD_SEL_L4_SPORT = 1 << 2,
  955. MLX5_HASH_FIELD_SEL_L4_DPORT = 1 << 3,
  956. MLX5_HASH_FIELD_SEL_IPSEC_SPI = 1 << 4,
  957. };
  958. enum {
  959. MLX5_MATCH_OUTER_HEADERS = 1 << 0,
  960. MLX5_MATCH_MISC_PARAMETERS = 1 << 1,
  961. MLX5_MATCH_INNER_HEADERS = 1 << 2,
  962. };
  963. enum {
  964. MLX5_FLOW_TABLE_TYPE_NIC_RCV = 0,
  965. MLX5_FLOW_TABLE_TYPE_ESWITCH = 4,
  966. };
  967. enum {
  968. MLX5_FLOW_CONTEXT_DEST_TYPE_VPORT = 0,
  969. MLX5_FLOW_CONTEXT_DEST_TYPE_FLOW_TABLE = 1,
  970. MLX5_FLOW_CONTEXT_DEST_TYPE_TIR = 2,
  971. };
  972. enum mlx5_list_type {
  973. MLX5_NVPRT_LIST_TYPE_UC = 0x0,
  974. MLX5_NVPRT_LIST_TYPE_MC = 0x1,
  975. MLX5_NVPRT_LIST_TYPE_VLAN = 0x2,
  976. };
  977. enum {
  978. MLX5_RQC_RQ_TYPE_MEMORY_RQ_INLINE = 0x0,
  979. MLX5_RQC_RQ_TYPE_MEMORY_RQ_RPM = 0x1,
  980. };
  981. /* MLX5 DEV CAPs */
  982. /* TODO: EAT.ME */
  983. enum mlx5_cap_mode {
  984. HCA_CAP_OPMOD_GET_MAX = 0,
  985. HCA_CAP_OPMOD_GET_CUR = 1,
  986. };
  987. enum mlx5_cap_type {
  988. MLX5_CAP_GENERAL = 0,
  989. MLX5_CAP_ETHERNET_OFFLOADS,
  990. MLX5_CAP_ODP,
  991. MLX5_CAP_ATOMIC,
  992. MLX5_CAP_ROCE,
  993. MLX5_CAP_IPOIB_OFFLOADS,
  994. MLX5_CAP_EOIB_OFFLOADS,
  995. MLX5_CAP_FLOW_TABLE,
  996. MLX5_CAP_ESWITCH_FLOW_TABLE,
  997. MLX5_CAP_ESWITCH,
  998. /* NUM OF CAP Types */
  999. MLX5_CAP_NUM
  1000. };
  1001. /* GET Dev Caps macros */
  1002. #define MLX5_CAP_GEN(mdev, cap) \
  1003. MLX5_GET(cmd_hca_cap, mdev->hca_caps_cur[MLX5_CAP_GENERAL], cap)
  1004. #define MLX5_CAP_GEN_MAX(mdev, cap) \
  1005. MLX5_GET(cmd_hca_cap, mdev->hca_caps_max[MLX5_CAP_GENERAL], cap)
  1006. #define MLX5_CAP_ETH(mdev, cap) \
  1007. MLX5_GET(per_protocol_networking_offload_caps,\
  1008. mdev->hca_caps_cur[MLX5_CAP_ETHERNET_OFFLOADS], cap)
  1009. #define MLX5_CAP_ETH_MAX(mdev, cap) \
  1010. MLX5_GET(per_protocol_networking_offload_caps,\
  1011. mdev->hca_caps_max[MLX5_CAP_ETHERNET_OFFLOADS], cap)
  1012. #define MLX5_CAP_ROCE(mdev, cap) \
  1013. MLX5_GET(roce_cap, mdev->hca_caps_cur[MLX5_CAP_ROCE], cap)
  1014. #define MLX5_CAP_ROCE_MAX(mdev, cap) \
  1015. MLX5_GET(roce_cap, mdev->hca_caps_max[MLX5_CAP_ROCE], cap)
  1016. #define MLX5_CAP_ATOMIC(mdev, cap) \
  1017. MLX5_GET(atomic_caps, mdev->hca_caps_cur[MLX5_CAP_ATOMIC], cap)
  1018. #define MLX5_CAP_ATOMIC_MAX(mdev, cap) \
  1019. MLX5_GET(atomic_caps, mdev->hca_caps_max[MLX5_CAP_ATOMIC], cap)
  1020. #define MLX5_CAP_FLOWTABLE(mdev, cap) \
  1021. MLX5_GET(flow_table_nic_cap, mdev->hca_caps_cur[MLX5_CAP_FLOW_TABLE], cap)
  1022. #define MLX5_CAP_FLOWTABLE_MAX(mdev, cap) \
  1023. MLX5_GET(flow_table_nic_cap, mdev->hca_caps_max[MLX5_CAP_FLOW_TABLE], cap)
  1024. #define MLX5_CAP_ESW_FLOWTABLE(mdev, cap) \
  1025. MLX5_GET(flow_table_eswitch_cap, \
  1026. mdev->hca_caps_cur[MLX5_CAP_ESWITCH_FLOW_TABLE], cap)
  1027. #define MLX5_CAP_ESW_FLOWTABLE_MAX(mdev, cap) \
  1028. MLX5_GET(flow_table_eswitch_cap, \
  1029. mdev->hca_caps_max[MLX5_CAP_ESWITCH_FLOW_TABLE], cap)
  1030. #define MLX5_CAP_ESW_FLOWTABLE_FDB(mdev, cap) \
  1031. MLX5_CAP_ESW_FLOWTABLE(mdev, flow_table_properties_nic_esw_fdb.cap)
  1032. #define MLX5_CAP_ESW_FLOWTABLE_FDB_MAX(mdev, cap) \
  1033. MLX5_CAP_ESW_FLOWTABLE_MAX(mdev, flow_table_properties_nic_esw_fdb.cap)
  1034. #define MLX5_CAP_ESW(mdev, cap) \
  1035. MLX5_GET(e_switch_cap, \
  1036. mdev->hca_caps_cur[MLX5_CAP_ESWITCH], cap)
  1037. #define MLX5_CAP_ESW_MAX(mdev, cap) \
  1038. MLX5_GET(e_switch_cap, \
  1039. mdev->hca_caps_max[MLX5_CAP_ESWITCH], cap)
  1040. #define MLX5_CAP_ODP(mdev, cap)\
  1041. MLX5_GET(odp_cap, mdev->hca_caps_cur[MLX5_CAP_ODP], cap)
  1042. enum {
  1043. MLX5_CMD_STAT_OK = 0x0,
  1044. MLX5_CMD_STAT_INT_ERR = 0x1,
  1045. MLX5_CMD_STAT_BAD_OP_ERR = 0x2,
  1046. MLX5_CMD_STAT_BAD_PARAM_ERR = 0x3,
  1047. MLX5_CMD_STAT_BAD_SYS_STATE_ERR = 0x4,
  1048. MLX5_CMD_STAT_BAD_RES_ERR = 0x5,
  1049. MLX5_CMD_STAT_RES_BUSY = 0x6,
  1050. MLX5_CMD_STAT_LIM_ERR = 0x8,
  1051. MLX5_CMD_STAT_BAD_RES_STATE_ERR = 0x9,
  1052. MLX5_CMD_STAT_IX_ERR = 0xa,
  1053. MLX5_CMD_STAT_NO_RES_ERR = 0xf,
  1054. MLX5_CMD_STAT_BAD_INP_LEN_ERR = 0x50,
  1055. MLX5_CMD_STAT_BAD_OUTP_LEN_ERR = 0x51,
  1056. MLX5_CMD_STAT_BAD_QP_STATE_ERR = 0x10,
  1057. MLX5_CMD_STAT_BAD_PKT_ERR = 0x30,
  1058. MLX5_CMD_STAT_BAD_SIZE_OUTS_CQES_ERR = 0x40,
  1059. };
  1060. enum {
  1061. MLX5_IEEE_802_3_COUNTERS_GROUP = 0x0,
  1062. MLX5_RFC_2863_COUNTERS_GROUP = 0x1,
  1063. MLX5_RFC_2819_COUNTERS_GROUP = 0x2,
  1064. MLX5_RFC_3635_COUNTERS_GROUP = 0x3,
  1065. MLX5_ETHERNET_EXTENDED_COUNTERS_GROUP = 0x5,
  1066. MLX5_PER_PRIORITY_COUNTERS_GROUP = 0x10,
  1067. MLX5_PER_TRAFFIC_CLASS_COUNTERS_GROUP = 0x11
  1068. };
  1069. static inline u16 mlx5_to_sw_pkey_sz(int pkey_sz)
  1070. {
  1071. if (pkey_sz > MLX5_MAX_LOG_PKEY_TABLE)
  1072. return 0;
  1073. return MLX5_MIN_PKEY_TABLE_SIZE << pkey_sz;
  1074. }
  1075. #endif /* MLX5_DEVICE_H */