device.h 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220
  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. enum {
  286. /*
  287. * Max wqe size for rdma read is 512 bytes, so this
  288. * limits our max_sge_rd as the wqe needs to fit:
  289. * - ctrl segment (16 bytes)
  290. * - rdma segment (16 bytes)
  291. * - scatter elements (16 bytes each)
  292. */
  293. MLX5_MAX_SGE_RD = (512 - 16 - 16) / 16
  294. };
  295. struct mlx5_inbox_hdr {
  296. __be16 opcode;
  297. u8 rsvd[4];
  298. __be16 opmod;
  299. };
  300. struct mlx5_outbox_hdr {
  301. u8 status;
  302. u8 rsvd[3];
  303. __be32 syndrome;
  304. };
  305. struct mlx5_cmd_query_adapter_mbox_in {
  306. struct mlx5_inbox_hdr hdr;
  307. u8 rsvd[8];
  308. };
  309. struct mlx5_cmd_query_adapter_mbox_out {
  310. struct mlx5_outbox_hdr hdr;
  311. u8 rsvd0[24];
  312. u8 intapin;
  313. u8 rsvd1[13];
  314. __be16 vsd_vendor_id;
  315. u8 vsd[208];
  316. u8 vsd_psid[16];
  317. };
  318. enum mlx5_odp_transport_cap_bits {
  319. MLX5_ODP_SUPPORT_SEND = 1 << 31,
  320. MLX5_ODP_SUPPORT_RECV = 1 << 30,
  321. MLX5_ODP_SUPPORT_WRITE = 1 << 29,
  322. MLX5_ODP_SUPPORT_READ = 1 << 28,
  323. };
  324. struct mlx5_odp_caps {
  325. char reserved[0x10];
  326. struct {
  327. __be32 rc_odp_caps;
  328. __be32 uc_odp_caps;
  329. __be32 ud_odp_caps;
  330. } per_transport_caps;
  331. char reserved2[0xe4];
  332. };
  333. struct mlx5_cmd_init_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_init_hca_mbox_out {
  340. struct mlx5_outbox_hdr hdr;
  341. u8 rsvd[8];
  342. };
  343. struct mlx5_cmd_teardown_hca_mbox_in {
  344. struct mlx5_inbox_hdr hdr;
  345. u8 rsvd0[2];
  346. __be16 profile;
  347. u8 rsvd1[4];
  348. };
  349. struct mlx5_cmd_teardown_hca_mbox_out {
  350. struct mlx5_outbox_hdr hdr;
  351. u8 rsvd[8];
  352. };
  353. struct mlx5_cmd_layout {
  354. u8 type;
  355. u8 rsvd0[3];
  356. __be32 inlen;
  357. __be64 in_ptr;
  358. __be32 in[4];
  359. __be32 out[4];
  360. __be64 out_ptr;
  361. __be32 outlen;
  362. u8 token;
  363. u8 sig;
  364. u8 rsvd1;
  365. u8 status_own;
  366. };
  367. struct health_buffer {
  368. __be32 assert_var[5];
  369. __be32 rsvd0[3];
  370. __be32 assert_exit_ptr;
  371. __be32 assert_callra;
  372. __be32 rsvd1[2];
  373. __be32 fw_ver;
  374. __be32 hw_id;
  375. __be32 rsvd2;
  376. u8 irisc_index;
  377. u8 synd;
  378. __be16 ext_synd;
  379. };
  380. struct mlx5_init_seg {
  381. __be32 fw_rev;
  382. __be32 cmdif_rev_fw_sub;
  383. __be32 rsvd0[2];
  384. __be32 cmdq_addr_h;
  385. __be32 cmdq_addr_l_sz;
  386. __be32 cmd_dbell;
  387. __be32 rsvd1[120];
  388. __be32 initializing;
  389. struct health_buffer health;
  390. __be32 rsvd2[884];
  391. __be32 health_counter;
  392. __be32 rsvd3[1019];
  393. __be64 ieee1588_clk;
  394. __be32 ieee1588_clk_type;
  395. __be32 clr_intx;
  396. };
  397. struct mlx5_eqe_comp {
  398. __be32 reserved[6];
  399. __be32 cqn;
  400. };
  401. struct mlx5_eqe_qp_srq {
  402. __be32 reserved[6];
  403. __be32 qp_srq_n;
  404. };
  405. struct mlx5_eqe_cq_err {
  406. __be32 cqn;
  407. u8 reserved1[7];
  408. u8 syndrome;
  409. };
  410. struct mlx5_eqe_port_state {
  411. u8 reserved0[8];
  412. u8 port;
  413. };
  414. struct mlx5_eqe_gpio {
  415. __be32 reserved0[2];
  416. __be64 gpio_event;
  417. };
  418. struct mlx5_eqe_congestion {
  419. u8 type;
  420. u8 rsvd0;
  421. u8 congestion_level;
  422. };
  423. struct mlx5_eqe_stall_vl {
  424. u8 rsvd0[3];
  425. u8 port_vl;
  426. };
  427. struct mlx5_eqe_cmd {
  428. __be32 vector;
  429. __be32 rsvd[6];
  430. };
  431. struct mlx5_eqe_page_req {
  432. u8 rsvd0[2];
  433. __be16 func_id;
  434. __be32 num_pages;
  435. __be32 rsvd1[5];
  436. };
  437. struct mlx5_eqe_page_fault {
  438. __be32 bytes_committed;
  439. union {
  440. struct {
  441. u16 reserved1;
  442. __be16 wqe_index;
  443. u16 reserved2;
  444. __be16 packet_length;
  445. u8 reserved3[12];
  446. } __packed wqe;
  447. struct {
  448. __be32 r_key;
  449. u16 reserved1;
  450. __be16 packet_length;
  451. __be32 rdma_op_len;
  452. __be64 rdma_va;
  453. } __packed rdma;
  454. } __packed;
  455. __be32 flags_qpn;
  456. } __packed;
  457. union ev_data {
  458. __be32 raw[7];
  459. struct mlx5_eqe_cmd cmd;
  460. struct mlx5_eqe_comp comp;
  461. struct mlx5_eqe_qp_srq qp_srq;
  462. struct mlx5_eqe_cq_err cq_err;
  463. struct mlx5_eqe_port_state port;
  464. struct mlx5_eqe_gpio gpio;
  465. struct mlx5_eqe_congestion cong;
  466. struct mlx5_eqe_stall_vl stall_vl;
  467. struct mlx5_eqe_page_req req_pages;
  468. struct mlx5_eqe_page_fault page_fault;
  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. __be64 timestamp;
  526. __be32 sop_drop_qpn;
  527. __be16 wqe_counter;
  528. u8 signature;
  529. u8 op_own;
  530. };
  531. static inline int get_cqe_lro_tcppsh(struct mlx5_cqe64 *cqe)
  532. {
  533. return (cqe->lro_tcppsh_abort_dupack >> 6) & 1;
  534. }
  535. static inline u8 get_cqe_l4_hdr_type(struct mlx5_cqe64 *cqe)
  536. {
  537. return (cqe->l4_hdr_type_etc >> 4) & 0x7;
  538. }
  539. static inline int cqe_has_vlan(struct mlx5_cqe64 *cqe)
  540. {
  541. return !!(cqe->l4_hdr_type_etc & 0x1);
  542. }
  543. enum {
  544. CQE_L4_HDR_TYPE_NONE = 0x0,
  545. CQE_L4_HDR_TYPE_TCP_NO_ACK = 0x1,
  546. CQE_L4_HDR_TYPE_UDP = 0x2,
  547. CQE_L4_HDR_TYPE_TCP_ACK_NO_DATA = 0x3,
  548. CQE_L4_HDR_TYPE_TCP_ACK_AND_DATA = 0x4,
  549. };
  550. enum {
  551. CQE_RSS_HTYPE_IP = 0x3 << 2,
  552. /* cqe->rss_hash_type[3:2] - IP destination selected for hash
  553. * (00 = none, 01 = IPv4, 10 = IPv6, 11 = Reserved)
  554. */
  555. CQE_RSS_HTYPE_L4 = 0x3 << 6,
  556. /* cqe->rss_hash_type[7:6] - L4 destination selected for hash
  557. * (00 = none, 01 = TCP. 10 = UDP, 11 = IPSEC.SPI
  558. */
  559. };
  560. enum {
  561. CQE_L2_OK = 1 << 0,
  562. CQE_L3_OK = 1 << 1,
  563. CQE_L4_OK = 1 << 2,
  564. };
  565. struct mlx5_sig_err_cqe {
  566. u8 rsvd0[16];
  567. __be32 expected_trans_sig;
  568. __be32 actual_trans_sig;
  569. __be32 expected_reftag;
  570. __be32 actual_reftag;
  571. __be16 syndrome;
  572. u8 rsvd22[2];
  573. __be32 mkey;
  574. __be64 err_offset;
  575. u8 rsvd30[8];
  576. __be32 qpn;
  577. u8 rsvd38[2];
  578. u8 signature;
  579. u8 op_own;
  580. };
  581. struct mlx5_wqe_srq_next_seg {
  582. u8 rsvd0[2];
  583. __be16 next_wqe_index;
  584. u8 signature;
  585. u8 rsvd1[11];
  586. };
  587. union mlx5_ext_cqe {
  588. struct ib_grh grh;
  589. u8 inl[64];
  590. };
  591. struct mlx5_cqe128 {
  592. union mlx5_ext_cqe inl_grh;
  593. struct mlx5_cqe64 cqe64;
  594. };
  595. struct mlx5_srq_ctx {
  596. u8 state_log_sz;
  597. u8 rsvd0[3];
  598. __be32 flags_xrcd;
  599. __be32 pgoff_cqn;
  600. u8 rsvd1[4];
  601. u8 log_pg_sz;
  602. u8 rsvd2[7];
  603. __be32 pd;
  604. __be16 lwm;
  605. __be16 wqe_cnt;
  606. u8 rsvd3[8];
  607. __be64 db_record;
  608. };
  609. struct mlx5_create_srq_mbox_in {
  610. struct mlx5_inbox_hdr hdr;
  611. __be32 input_srqn;
  612. u8 rsvd0[4];
  613. struct mlx5_srq_ctx ctx;
  614. u8 rsvd1[208];
  615. __be64 pas[0];
  616. };
  617. struct mlx5_create_srq_mbox_out {
  618. struct mlx5_outbox_hdr hdr;
  619. __be32 srqn;
  620. u8 rsvd[4];
  621. };
  622. struct mlx5_destroy_srq_mbox_in {
  623. struct mlx5_inbox_hdr hdr;
  624. __be32 srqn;
  625. u8 rsvd[4];
  626. };
  627. struct mlx5_destroy_srq_mbox_out {
  628. struct mlx5_outbox_hdr hdr;
  629. u8 rsvd[8];
  630. };
  631. struct mlx5_query_srq_mbox_in {
  632. struct mlx5_inbox_hdr hdr;
  633. __be32 srqn;
  634. u8 rsvd0[4];
  635. };
  636. struct mlx5_query_srq_mbox_out {
  637. struct mlx5_outbox_hdr hdr;
  638. u8 rsvd0[8];
  639. struct mlx5_srq_ctx ctx;
  640. u8 rsvd1[32];
  641. __be64 pas[0];
  642. };
  643. struct mlx5_arm_srq_mbox_in {
  644. struct mlx5_inbox_hdr hdr;
  645. __be32 srqn;
  646. __be16 rsvd;
  647. __be16 lwm;
  648. };
  649. struct mlx5_arm_srq_mbox_out {
  650. struct mlx5_outbox_hdr hdr;
  651. u8 rsvd[8];
  652. };
  653. struct mlx5_cq_context {
  654. u8 status;
  655. u8 cqe_sz_flags;
  656. u8 st;
  657. u8 rsvd3;
  658. u8 rsvd4[6];
  659. __be16 page_offset;
  660. __be32 log_sz_usr_page;
  661. __be16 cq_period;
  662. __be16 cq_max_count;
  663. __be16 rsvd20;
  664. __be16 c_eqn;
  665. u8 log_pg_sz;
  666. u8 rsvd25[7];
  667. __be32 last_notified_index;
  668. __be32 solicit_producer_index;
  669. __be32 consumer_counter;
  670. __be32 producer_counter;
  671. u8 rsvd48[8];
  672. __be64 db_record_addr;
  673. };
  674. struct mlx5_create_cq_mbox_in {
  675. struct mlx5_inbox_hdr hdr;
  676. __be32 input_cqn;
  677. u8 rsvdx[4];
  678. struct mlx5_cq_context ctx;
  679. u8 rsvd6[192];
  680. __be64 pas[0];
  681. };
  682. struct mlx5_create_cq_mbox_out {
  683. struct mlx5_outbox_hdr hdr;
  684. __be32 cqn;
  685. u8 rsvd0[4];
  686. };
  687. struct mlx5_destroy_cq_mbox_in {
  688. struct mlx5_inbox_hdr hdr;
  689. __be32 cqn;
  690. u8 rsvd0[4];
  691. };
  692. struct mlx5_destroy_cq_mbox_out {
  693. struct mlx5_outbox_hdr hdr;
  694. u8 rsvd0[8];
  695. };
  696. struct mlx5_query_cq_mbox_in {
  697. struct mlx5_inbox_hdr hdr;
  698. __be32 cqn;
  699. u8 rsvd0[4];
  700. };
  701. struct mlx5_query_cq_mbox_out {
  702. struct mlx5_outbox_hdr hdr;
  703. u8 rsvd0[8];
  704. struct mlx5_cq_context ctx;
  705. u8 rsvd6[16];
  706. __be64 pas[0];
  707. };
  708. struct mlx5_modify_cq_mbox_in {
  709. struct mlx5_inbox_hdr hdr;
  710. __be32 cqn;
  711. __be32 field_select;
  712. struct mlx5_cq_context ctx;
  713. u8 rsvd[192];
  714. __be64 pas[0];
  715. };
  716. struct mlx5_modify_cq_mbox_out {
  717. struct mlx5_outbox_hdr hdr;
  718. u8 rsvd[8];
  719. };
  720. struct mlx5_enable_hca_mbox_in {
  721. struct mlx5_inbox_hdr hdr;
  722. u8 rsvd[8];
  723. };
  724. struct mlx5_enable_hca_mbox_out {
  725. struct mlx5_outbox_hdr hdr;
  726. u8 rsvd[8];
  727. };
  728. struct mlx5_disable_hca_mbox_in {
  729. struct mlx5_inbox_hdr hdr;
  730. u8 rsvd[8];
  731. };
  732. struct mlx5_disable_hca_mbox_out {
  733. struct mlx5_outbox_hdr hdr;
  734. u8 rsvd[8];
  735. };
  736. struct mlx5_eq_context {
  737. u8 status;
  738. u8 ec_oi;
  739. u8 st;
  740. u8 rsvd2[7];
  741. __be16 page_pffset;
  742. __be32 log_sz_usr_page;
  743. u8 rsvd3[7];
  744. u8 intr;
  745. u8 log_page_size;
  746. u8 rsvd4[15];
  747. __be32 consumer_counter;
  748. __be32 produser_counter;
  749. u8 rsvd5[16];
  750. };
  751. struct mlx5_create_eq_mbox_in {
  752. struct mlx5_inbox_hdr hdr;
  753. u8 rsvd0[3];
  754. u8 input_eqn;
  755. u8 rsvd1[4];
  756. struct mlx5_eq_context ctx;
  757. u8 rsvd2[8];
  758. __be64 events_mask;
  759. u8 rsvd3[176];
  760. __be64 pas[0];
  761. };
  762. struct mlx5_create_eq_mbox_out {
  763. struct mlx5_outbox_hdr hdr;
  764. u8 rsvd0[3];
  765. u8 eq_number;
  766. u8 rsvd1[4];
  767. };
  768. struct mlx5_destroy_eq_mbox_in {
  769. struct mlx5_inbox_hdr hdr;
  770. u8 rsvd0[3];
  771. u8 eqn;
  772. u8 rsvd1[4];
  773. };
  774. struct mlx5_destroy_eq_mbox_out {
  775. struct mlx5_outbox_hdr hdr;
  776. u8 rsvd[8];
  777. };
  778. struct mlx5_map_eq_mbox_in {
  779. struct mlx5_inbox_hdr hdr;
  780. __be64 mask;
  781. u8 mu;
  782. u8 rsvd0[2];
  783. u8 eqn;
  784. u8 rsvd1[24];
  785. };
  786. struct mlx5_map_eq_mbox_out {
  787. struct mlx5_outbox_hdr hdr;
  788. u8 rsvd[8];
  789. };
  790. struct mlx5_query_eq_mbox_in {
  791. struct mlx5_inbox_hdr hdr;
  792. u8 rsvd0[3];
  793. u8 eqn;
  794. u8 rsvd1[4];
  795. };
  796. struct mlx5_query_eq_mbox_out {
  797. struct mlx5_outbox_hdr hdr;
  798. u8 rsvd[8];
  799. struct mlx5_eq_context ctx;
  800. };
  801. enum {
  802. MLX5_MKEY_STATUS_FREE = 1 << 6,
  803. };
  804. struct mlx5_mkey_seg {
  805. /* This is a two bit field occupying bits 31-30.
  806. * bit 31 is always 0,
  807. * bit 30 is zero for regular MRs and 1 (e.g free) for UMRs that do not have tanslation
  808. */
  809. u8 status;
  810. u8 pcie_control;
  811. u8 flags;
  812. u8 version;
  813. __be32 qpn_mkey7_0;
  814. u8 rsvd1[4];
  815. __be32 flags_pd;
  816. __be64 start_addr;
  817. __be64 len;
  818. __be32 bsfs_octo_size;
  819. u8 rsvd2[16];
  820. __be32 xlt_oct_size;
  821. u8 rsvd3[3];
  822. u8 log2_page_size;
  823. u8 rsvd4[4];
  824. };
  825. struct mlx5_query_special_ctxs_mbox_in {
  826. struct mlx5_inbox_hdr hdr;
  827. u8 rsvd[8];
  828. };
  829. struct mlx5_query_special_ctxs_mbox_out {
  830. struct mlx5_outbox_hdr hdr;
  831. __be32 dump_fill_mkey;
  832. __be32 reserved_lkey;
  833. };
  834. struct mlx5_create_mkey_mbox_in {
  835. struct mlx5_inbox_hdr hdr;
  836. __be32 input_mkey_index;
  837. __be32 flags;
  838. struct mlx5_mkey_seg seg;
  839. u8 rsvd1[16];
  840. __be32 xlat_oct_act_size;
  841. __be32 rsvd2;
  842. u8 rsvd3[168];
  843. __be64 pas[0];
  844. };
  845. struct mlx5_create_mkey_mbox_out {
  846. struct mlx5_outbox_hdr hdr;
  847. __be32 mkey;
  848. u8 rsvd[4];
  849. };
  850. struct mlx5_destroy_mkey_mbox_in {
  851. struct mlx5_inbox_hdr hdr;
  852. __be32 mkey;
  853. u8 rsvd[4];
  854. };
  855. struct mlx5_destroy_mkey_mbox_out {
  856. struct mlx5_outbox_hdr hdr;
  857. u8 rsvd[8];
  858. };
  859. struct mlx5_query_mkey_mbox_in {
  860. struct mlx5_inbox_hdr hdr;
  861. __be32 mkey;
  862. };
  863. struct mlx5_query_mkey_mbox_out {
  864. struct mlx5_outbox_hdr hdr;
  865. __be64 pas[0];
  866. };
  867. struct mlx5_modify_mkey_mbox_in {
  868. struct mlx5_inbox_hdr hdr;
  869. __be32 mkey;
  870. __be64 pas[0];
  871. };
  872. struct mlx5_modify_mkey_mbox_out {
  873. struct mlx5_outbox_hdr hdr;
  874. u8 rsvd[8];
  875. };
  876. struct mlx5_dump_mkey_mbox_in {
  877. struct mlx5_inbox_hdr hdr;
  878. };
  879. struct mlx5_dump_mkey_mbox_out {
  880. struct mlx5_outbox_hdr hdr;
  881. __be32 mkey;
  882. };
  883. struct mlx5_mad_ifc_mbox_in {
  884. struct mlx5_inbox_hdr hdr;
  885. __be16 remote_lid;
  886. u8 rsvd0;
  887. u8 port;
  888. u8 rsvd1[4];
  889. u8 data[256];
  890. };
  891. struct mlx5_mad_ifc_mbox_out {
  892. struct mlx5_outbox_hdr hdr;
  893. u8 rsvd[8];
  894. u8 data[256];
  895. };
  896. struct mlx5_access_reg_mbox_in {
  897. struct mlx5_inbox_hdr hdr;
  898. u8 rsvd0[2];
  899. __be16 register_id;
  900. __be32 arg;
  901. __be32 data[0];
  902. };
  903. struct mlx5_access_reg_mbox_out {
  904. struct mlx5_outbox_hdr hdr;
  905. u8 rsvd[8];
  906. __be32 data[0];
  907. };
  908. #define MLX5_ATTR_EXTENDED_PORT_INFO cpu_to_be16(0xff90)
  909. enum {
  910. MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO = 1 << 0
  911. };
  912. struct mlx5_allocate_psv_in {
  913. struct mlx5_inbox_hdr hdr;
  914. __be32 npsv_pd;
  915. __be32 rsvd_psv0;
  916. };
  917. struct mlx5_allocate_psv_out {
  918. struct mlx5_outbox_hdr hdr;
  919. u8 rsvd[8];
  920. __be32 psv_idx[4];
  921. };
  922. struct mlx5_destroy_psv_in {
  923. struct mlx5_inbox_hdr hdr;
  924. __be32 psv_number;
  925. u8 rsvd[4];
  926. };
  927. struct mlx5_destroy_psv_out {
  928. struct mlx5_outbox_hdr hdr;
  929. u8 rsvd[8];
  930. };
  931. #define MLX5_CMD_OP_MAX 0x920
  932. enum {
  933. VPORT_STATE_DOWN = 0x0,
  934. VPORT_STATE_UP = 0x1,
  935. };
  936. enum {
  937. MLX5_L3_PROT_TYPE_IPV4 = 0,
  938. MLX5_L3_PROT_TYPE_IPV6 = 1,
  939. };
  940. enum {
  941. MLX5_L4_PROT_TYPE_TCP = 0,
  942. MLX5_L4_PROT_TYPE_UDP = 1,
  943. };
  944. enum {
  945. MLX5_HASH_FIELD_SEL_SRC_IP = 1 << 0,
  946. MLX5_HASH_FIELD_SEL_DST_IP = 1 << 1,
  947. MLX5_HASH_FIELD_SEL_L4_SPORT = 1 << 2,
  948. MLX5_HASH_FIELD_SEL_L4_DPORT = 1 << 3,
  949. MLX5_HASH_FIELD_SEL_IPSEC_SPI = 1 << 4,
  950. };
  951. enum {
  952. MLX5_MATCH_OUTER_HEADERS = 1 << 0,
  953. MLX5_MATCH_MISC_PARAMETERS = 1 << 1,
  954. MLX5_MATCH_INNER_HEADERS = 1 << 2,
  955. };
  956. enum {
  957. MLX5_FLOW_TABLE_TYPE_NIC_RCV = 0,
  958. MLX5_FLOW_TABLE_TYPE_ESWITCH = 4,
  959. };
  960. enum {
  961. MLX5_FLOW_CONTEXT_DEST_TYPE_VPORT = 0,
  962. MLX5_FLOW_CONTEXT_DEST_TYPE_FLOW_TABLE = 1,
  963. MLX5_FLOW_CONTEXT_DEST_TYPE_TIR = 2,
  964. };
  965. enum {
  966. MLX5_RQC_RQ_TYPE_MEMORY_RQ_INLINE = 0x0,
  967. MLX5_RQC_RQ_TYPE_MEMORY_RQ_RPM = 0x1,
  968. };
  969. /* MLX5 DEV CAPs */
  970. /* TODO: EAT.ME */
  971. enum mlx5_cap_mode {
  972. HCA_CAP_OPMOD_GET_MAX = 0,
  973. HCA_CAP_OPMOD_GET_CUR = 1,
  974. };
  975. enum mlx5_cap_type {
  976. MLX5_CAP_GENERAL = 0,
  977. MLX5_CAP_ETHERNET_OFFLOADS,
  978. MLX5_CAP_ODP,
  979. MLX5_CAP_ATOMIC,
  980. MLX5_CAP_ROCE,
  981. MLX5_CAP_IPOIB_OFFLOADS,
  982. MLX5_CAP_EOIB_OFFLOADS,
  983. MLX5_CAP_FLOW_TABLE,
  984. /* NUM OF CAP Types */
  985. MLX5_CAP_NUM
  986. };
  987. /* GET Dev Caps macros */
  988. #define MLX5_CAP_GEN(mdev, cap) \
  989. MLX5_GET(cmd_hca_cap, mdev->hca_caps_cur[MLX5_CAP_GENERAL], cap)
  990. #define MLX5_CAP_GEN_MAX(mdev, cap) \
  991. MLX5_GET(cmd_hca_cap, mdev->hca_caps_max[MLX5_CAP_GENERAL], cap)
  992. #define MLX5_CAP_ETH(mdev, cap) \
  993. MLX5_GET(per_protocol_networking_offload_caps,\
  994. mdev->hca_caps_cur[MLX5_CAP_ETHERNET_OFFLOADS], cap)
  995. #define MLX5_CAP_ETH_MAX(mdev, cap) \
  996. MLX5_GET(per_protocol_networking_offload_caps,\
  997. mdev->hca_caps_max[MLX5_CAP_ETHERNET_OFFLOADS], cap)
  998. #define MLX5_CAP_ROCE(mdev, cap) \
  999. MLX5_GET(roce_cap, mdev->hca_caps_cur[MLX5_CAP_ROCE], cap)
  1000. #define MLX5_CAP_ROCE_MAX(mdev, cap) \
  1001. MLX5_GET(roce_cap, mdev->hca_caps_max[MLX5_CAP_ROCE], cap)
  1002. #define MLX5_CAP_ATOMIC(mdev, cap) \
  1003. MLX5_GET(atomic_caps, mdev->hca_caps_cur[MLX5_CAP_ATOMIC], cap)
  1004. #define MLX5_CAP_ATOMIC_MAX(mdev, cap) \
  1005. MLX5_GET(atomic_caps, mdev->hca_caps_max[MLX5_CAP_ATOMIC], cap)
  1006. #define MLX5_CAP_FLOWTABLE(mdev, cap) \
  1007. MLX5_GET(flow_table_nic_cap, mdev->hca_caps_cur[MLX5_CAP_FLOW_TABLE], cap)
  1008. #define MLX5_CAP_FLOWTABLE_MAX(mdev, cap) \
  1009. MLX5_GET(flow_table_nic_cap, mdev->hca_caps_max[MLX5_CAP_FLOW_TABLE], cap)
  1010. #define MLX5_CAP_ODP(mdev, cap)\
  1011. MLX5_GET(odp_cap, mdev->hca_caps_cur[MLX5_CAP_ODP], cap)
  1012. enum {
  1013. MLX5_CMD_STAT_OK = 0x0,
  1014. MLX5_CMD_STAT_INT_ERR = 0x1,
  1015. MLX5_CMD_STAT_BAD_OP_ERR = 0x2,
  1016. MLX5_CMD_STAT_BAD_PARAM_ERR = 0x3,
  1017. MLX5_CMD_STAT_BAD_SYS_STATE_ERR = 0x4,
  1018. MLX5_CMD_STAT_BAD_RES_ERR = 0x5,
  1019. MLX5_CMD_STAT_RES_BUSY = 0x6,
  1020. MLX5_CMD_STAT_LIM_ERR = 0x8,
  1021. MLX5_CMD_STAT_BAD_RES_STATE_ERR = 0x9,
  1022. MLX5_CMD_STAT_IX_ERR = 0xa,
  1023. MLX5_CMD_STAT_NO_RES_ERR = 0xf,
  1024. MLX5_CMD_STAT_BAD_INP_LEN_ERR = 0x50,
  1025. MLX5_CMD_STAT_BAD_OUTP_LEN_ERR = 0x51,
  1026. MLX5_CMD_STAT_BAD_QP_STATE_ERR = 0x10,
  1027. MLX5_CMD_STAT_BAD_PKT_ERR = 0x30,
  1028. MLX5_CMD_STAT_BAD_SIZE_OUTS_CQES_ERR = 0x40,
  1029. };
  1030. enum {
  1031. MLX5_IEEE_802_3_COUNTERS_GROUP = 0x0,
  1032. MLX5_RFC_2863_COUNTERS_GROUP = 0x1,
  1033. MLX5_RFC_2819_COUNTERS_GROUP = 0x2,
  1034. MLX5_RFC_3635_COUNTERS_GROUP = 0x3,
  1035. MLX5_ETHERNET_EXTENDED_COUNTERS_GROUP = 0x5,
  1036. MLX5_PER_PRIORITY_COUNTERS_GROUP = 0x10,
  1037. MLX5_PER_TRAFFIC_CLASS_COUNTERS_GROUP = 0x11
  1038. };
  1039. static inline u16 mlx5_to_sw_pkey_sz(int pkey_sz)
  1040. {
  1041. if (pkey_sz > MLX5_MAX_LOG_PKEY_TABLE)
  1042. return 0;
  1043. return MLX5_MIN_PKEY_TABLE_SIZE << pkey_sz;
  1044. }
  1045. #endif /* MLX5_DEVICE_H */