device.h 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346
  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_ST_SZ_QW(typ) (sizeof(struct mlx5_ifc_##typ##_bits) / 64)
  58. #define MLX5_UN_SZ_BYTES(typ) (sizeof(union mlx5_ifc_##typ##_bits) / 8)
  59. #define MLX5_UN_SZ_DW(typ) (sizeof(union mlx5_ifc_##typ##_bits) / 32)
  60. #define MLX5_BYTE_OFF(typ, fld) (__mlx5_bit_off(typ, fld) / 8)
  61. #define MLX5_ADDR_OF(typ, p, fld) ((char *)(p) + MLX5_BYTE_OFF(typ, fld))
  62. /* insert a value to a struct */
  63. #define MLX5_SET(typ, p, fld, v) do { \
  64. BUILD_BUG_ON(__mlx5_st_sz_bits(typ) % 32); \
  65. *((__be32 *)(p) + __mlx5_dw_off(typ, fld)) = \
  66. cpu_to_be32((be32_to_cpu(*((__be32 *)(p) + __mlx5_dw_off(typ, fld))) & \
  67. (~__mlx5_dw_mask(typ, fld))) | (((v) & __mlx5_mask(typ, fld)) \
  68. << __mlx5_dw_bit_off(typ, fld))); \
  69. } while (0)
  70. #define MLX5_SET_TO_ONES(typ, p, fld) do { \
  71. BUILD_BUG_ON(__mlx5_st_sz_bits(typ) % 32); \
  72. *((__be32 *)(p) + __mlx5_dw_off(typ, fld)) = \
  73. cpu_to_be32((be32_to_cpu(*((__be32 *)(p) + __mlx5_dw_off(typ, fld))) & \
  74. (~__mlx5_dw_mask(typ, fld))) | ((__mlx5_mask(typ, fld)) \
  75. << __mlx5_dw_bit_off(typ, fld))); \
  76. } while (0)
  77. #define MLX5_GET(typ, p, fld) ((be32_to_cpu(*((__be32 *)(p) +\
  78. __mlx5_dw_off(typ, fld))) >> __mlx5_dw_bit_off(typ, fld)) & \
  79. __mlx5_mask(typ, fld))
  80. #define MLX5_GET_PR(typ, p, fld) ({ \
  81. u32 ___t = MLX5_GET(typ, p, fld); \
  82. pr_debug(#fld " = 0x%x\n", ___t); \
  83. ___t; \
  84. })
  85. #define MLX5_SET64(typ, p, fld, v) do { \
  86. BUILD_BUG_ON(__mlx5_bit_sz(typ, fld) != 64); \
  87. BUILD_BUG_ON(__mlx5_bit_off(typ, fld) % 64); \
  88. *((__be64 *)(p) + __mlx5_64_off(typ, fld)) = cpu_to_be64(v); \
  89. } while (0)
  90. #define MLX5_GET64(typ, p, fld) be64_to_cpu(*((__be64 *)(p) + __mlx5_64_off(typ, fld)))
  91. #define MLX5_GET64_PR(typ, p, fld) ({ \
  92. u64 ___t = MLX5_GET64(typ, p, fld); \
  93. pr_debug(#fld " = 0x%llx\n", ___t); \
  94. ___t; \
  95. })
  96. /* Big endian getters */
  97. #define MLX5_GET64_BE(typ, p, fld) (*((__be64 *)(p) +\
  98. __mlx5_64_off(typ, fld)))
  99. #define MLX5_GET_BE(type_t, typ, p, fld) ({ \
  100. type_t tmp; \
  101. switch (sizeof(tmp)) { \
  102. case sizeof(u8): \
  103. tmp = (__force type_t)MLX5_GET(typ, p, fld); \
  104. break; \
  105. case sizeof(u16): \
  106. tmp = (__force type_t)cpu_to_be16(MLX5_GET(typ, p, fld)); \
  107. break; \
  108. case sizeof(u32): \
  109. tmp = (__force type_t)cpu_to_be32(MLX5_GET(typ, p, fld)); \
  110. break; \
  111. case sizeof(u64): \
  112. tmp = (__force type_t)MLX5_GET64_BE(typ, p, fld); \
  113. break; \
  114. } \
  115. tmp; \
  116. })
  117. enum mlx5_inline_modes {
  118. MLX5_INLINE_MODE_NONE,
  119. MLX5_INLINE_MODE_L2,
  120. MLX5_INLINE_MODE_IP,
  121. MLX5_INLINE_MODE_TCP_UDP,
  122. };
  123. enum {
  124. MLX5_MAX_COMMANDS = 32,
  125. MLX5_CMD_DATA_BLOCK_SIZE = 512,
  126. MLX5_PCI_CMD_XPORT = 7,
  127. MLX5_MKEY_BSF_OCTO_SIZE = 4,
  128. MLX5_MAX_PSVS = 4,
  129. };
  130. enum {
  131. MLX5_EXTENDED_UD_AV = 0x80000000,
  132. };
  133. enum {
  134. MLX5_CQ_STATE_ARMED = 9,
  135. MLX5_CQ_STATE_ALWAYS_ARMED = 0xb,
  136. MLX5_CQ_STATE_FIRED = 0xa,
  137. };
  138. enum {
  139. MLX5_STAT_RATE_OFFSET = 5,
  140. };
  141. enum {
  142. MLX5_INLINE_SEG = 0x80000000,
  143. };
  144. enum {
  145. MLX5_HW_START_PADDING = MLX5_INLINE_SEG,
  146. };
  147. enum {
  148. MLX5_MIN_PKEY_TABLE_SIZE = 128,
  149. MLX5_MAX_LOG_PKEY_TABLE = 5,
  150. };
  151. enum {
  152. MLX5_MKEY_INBOX_PG_ACCESS = 1 << 31
  153. };
  154. enum {
  155. MLX5_PFAULT_SUBTYPE_WQE = 0,
  156. MLX5_PFAULT_SUBTYPE_RDMA = 1,
  157. };
  158. enum {
  159. MLX5_PERM_LOCAL_READ = 1 << 2,
  160. MLX5_PERM_LOCAL_WRITE = 1 << 3,
  161. MLX5_PERM_REMOTE_READ = 1 << 4,
  162. MLX5_PERM_REMOTE_WRITE = 1 << 5,
  163. MLX5_PERM_ATOMIC = 1 << 6,
  164. MLX5_PERM_UMR_EN = 1 << 7,
  165. };
  166. enum {
  167. MLX5_PCIE_CTRL_SMALL_FENCE = 1 << 0,
  168. MLX5_PCIE_CTRL_RELAXED_ORDERING = 1 << 2,
  169. MLX5_PCIE_CTRL_NO_SNOOP = 1 << 3,
  170. MLX5_PCIE_CTRL_TLP_PROCE_EN = 1 << 6,
  171. MLX5_PCIE_CTRL_TPH_MASK = 3 << 4,
  172. };
  173. enum {
  174. MLX5_ACCESS_MODE_PA = 0,
  175. MLX5_ACCESS_MODE_MTT = 1,
  176. MLX5_ACCESS_MODE_KLM = 2
  177. };
  178. enum {
  179. MLX5_MKEY_REMOTE_INVAL = 1 << 24,
  180. MLX5_MKEY_FLAG_SYNC_UMR = 1 << 29,
  181. MLX5_MKEY_BSF_EN = 1 << 30,
  182. MLX5_MKEY_LEN64 = 1 << 31,
  183. };
  184. enum {
  185. MLX5_EN_RD = (u64)1,
  186. MLX5_EN_WR = (u64)2
  187. };
  188. enum {
  189. MLX5_BF_REGS_PER_PAGE = 4,
  190. MLX5_MAX_UAR_PAGES = 1 << 8,
  191. MLX5_NON_FP_BF_REGS_PER_PAGE = 2,
  192. MLX5_MAX_UUARS = MLX5_MAX_UAR_PAGES * MLX5_NON_FP_BF_REGS_PER_PAGE,
  193. };
  194. enum {
  195. MLX5_MKEY_MASK_LEN = 1ull << 0,
  196. MLX5_MKEY_MASK_PAGE_SIZE = 1ull << 1,
  197. MLX5_MKEY_MASK_START_ADDR = 1ull << 6,
  198. MLX5_MKEY_MASK_PD = 1ull << 7,
  199. MLX5_MKEY_MASK_EN_RINVAL = 1ull << 8,
  200. MLX5_MKEY_MASK_EN_SIGERR = 1ull << 9,
  201. MLX5_MKEY_MASK_BSF_EN = 1ull << 12,
  202. MLX5_MKEY_MASK_KEY = 1ull << 13,
  203. MLX5_MKEY_MASK_QPN = 1ull << 14,
  204. MLX5_MKEY_MASK_LR = 1ull << 17,
  205. MLX5_MKEY_MASK_LW = 1ull << 18,
  206. MLX5_MKEY_MASK_RR = 1ull << 19,
  207. MLX5_MKEY_MASK_RW = 1ull << 20,
  208. MLX5_MKEY_MASK_A = 1ull << 21,
  209. MLX5_MKEY_MASK_SMALL_FENCE = 1ull << 23,
  210. MLX5_MKEY_MASK_FREE = 1ull << 29,
  211. };
  212. enum {
  213. MLX5_UMR_TRANSLATION_OFFSET_EN = (1 << 4),
  214. MLX5_UMR_CHECK_NOT_FREE = (1 << 5),
  215. MLX5_UMR_CHECK_FREE = (2 << 5),
  216. MLX5_UMR_INLINE = (1 << 7),
  217. };
  218. #define MLX5_UMR_MTT_ALIGNMENT 0x40
  219. #define MLX5_UMR_MTT_MASK (MLX5_UMR_MTT_ALIGNMENT - 1)
  220. #define MLX5_UMR_MTT_MIN_CHUNK_SIZE MLX5_UMR_MTT_ALIGNMENT
  221. #define MLX5_USER_INDEX_LEN (MLX5_FLD_SZ_BYTES(qpc, user_index) * 8)
  222. enum {
  223. MLX5_EVENT_QUEUE_TYPE_QP = 0,
  224. MLX5_EVENT_QUEUE_TYPE_RQ = 1,
  225. MLX5_EVENT_QUEUE_TYPE_SQ = 2,
  226. };
  227. enum mlx5_event {
  228. MLX5_EVENT_TYPE_COMP = 0x0,
  229. MLX5_EVENT_TYPE_PATH_MIG = 0x01,
  230. MLX5_EVENT_TYPE_COMM_EST = 0x02,
  231. MLX5_EVENT_TYPE_SQ_DRAINED = 0x03,
  232. MLX5_EVENT_TYPE_SRQ_LAST_WQE = 0x13,
  233. MLX5_EVENT_TYPE_SRQ_RQ_LIMIT = 0x14,
  234. MLX5_EVENT_TYPE_CQ_ERROR = 0x04,
  235. MLX5_EVENT_TYPE_WQ_CATAS_ERROR = 0x05,
  236. MLX5_EVENT_TYPE_PATH_MIG_FAILED = 0x07,
  237. MLX5_EVENT_TYPE_WQ_INVAL_REQ_ERROR = 0x10,
  238. MLX5_EVENT_TYPE_WQ_ACCESS_ERROR = 0x11,
  239. MLX5_EVENT_TYPE_SRQ_CATAS_ERROR = 0x12,
  240. MLX5_EVENT_TYPE_INTERNAL_ERROR = 0x08,
  241. MLX5_EVENT_TYPE_PORT_CHANGE = 0x09,
  242. MLX5_EVENT_TYPE_GPIO_EVENT = 0x15,
  243. MLX5_EVENT_TYPE_REMOTE_CONFIG = 0x19,
  244. MLX5_EVENT_TYPE_DB_BF_CONGESTION = 0x1a,
  245. MLX5_EVENT_TYPE_STALL_EVENT = 0x1b,
  246. MLX5_EVENT_TYPE_CMD = 0x0a,
  247. MLX5_EVENT_TYPE_PAGE_REQUEST = 0xb,
  248. MLX5_EVENT_TYPE_PAGE_FAULT = 0xc,
  249. MLX5_EVENT_TYPE_NIC_VPORT_CHANGE = 0xd,
  250. };
  251. enum {
  252. MLX5_PORT_CHANGE_SUBTYPE_DOWN = 1,
  253. MLX5_PORT_CHANGE_SUBTYPE_ACTIVE = 4,
  254. MLX5_PORT_CHANGE_SUBTYPE_INITIALIZED = 5,
  255. MLX5_PORT_CHANGE_SUBTYPE_LID = 6,
  256. MLX5_PORT_CHANGE_SUBTYPE_PKEY = 7,
  257. MLX5_PORT_CHANGE_SUBTYPE_GUID = 8,
  258. MLX5_PORT_CHANGE_SUBTYPE_CLIENT_REREG = 9,
  259. };
  260. enum {
  261. MLX5_DEV_CAP_FLAG_XRC = 1LL << 3,
  262. MLX5_DEV_CAP_FLAG_BAD_PKEY_CNTR = 1LL << 8,
  263. MLX5_DEV_CAP_FLAG_BAD_QKEY_CNTR = 1LL << 9,
  264. MLX5_DEV_CAP_FLAG_APM = 1LL << 17,
  265. MLX5_DEV_CAP_FLAG_ATOMIC = 1LL << 18,
  266. MLX5_DEV_CAP_FLAG_BLOCK_MCAST = 1LL << 23,
  267. MLX5_DEV_CAP_FLAG_ON_DMND_PG = 1LL << 24,
  268. MLX5_DEV_CAP_FLAG_CQ_MODER = 1LL << 29,
  269. MLX5_DEV_CAP_FLAG_RESIZE_CQ = 1LL << 30,
  270. MLX5_DEV_CAP_FLAG_DCT = 1LL << 37,
  271. MLX5_DEV_CAP_FLAG_SIG_HAND_OVER = 1LL << 40,
  272. MLX5_DEV_CAP_FLAG_CMDIF_CSUM = 3LL << 46,
  273. };
  274. enum {
  275. MLX5_ROCE_VERSION_1 = 0,
  276. MLX5_ROCE_VERSION_2 = 2,
  277. };
  278. enum {
  279. MLX5_ROCE_VERSION_1_CAP = 1 << MLX5_ROCE_VERSION_1,
  280. MLX5_ROCE_VERSION_2_CAP = 1 << MLX5_ROCE_VERSION_2,
  281. };
  282. enum {
  283. MLX5_ROCE_L3_TYPE_IPV4 = 0,
  284. MLX5_ROCE_L3_TYPE_IPV6 = 1,
  285. };
  286. enum {
  287. MLX5_ROCE_L3_TYPE_IPV4_CAP = 1 << 1,
  288. MLX5_ROCE_L3_TYPE_IPV6_CAP = 1 << 2,
  289. };
  290. enum {
  291. MLX5_OPCODE_NOP = 0x00,
  292. MLX5_OPCODE_SEND_INVAL = 0x01,
  293. MLX5_OPCODE_RDMA_WRITE = 0x08,
  294. MLX5_OPCODE_RDMA_WRITE_IMM = 0x09,
  295. MLX5_OPCODE_SEND = 0x0a,
  296. MLX5_OPCODE_SEND_IMM = 0x0b,
  297. MLX5_OPCODE_LSO = 0x0e,
  298. MLX5_OPCODE_RDMA_READ = 0x10,
  299. MLX5_OPCODE_ATOMIC_CS = 0x11,
  300. MLX5_OPCODE_ATOMIC_FA = 0x12,
  301. MLX5_OPCODE_ATOMIC_MASKED_CS = 0x14,
  302. MLX5_OPCODE_ATOMIC_MASKED_FA = 0x15,
  303. MLX5_OPCODE_BIND_MW = 0x18,
  304. MLX5_OPCODE_CONFIG_CMD = 0x1f,
  305. MLX5_RECV_OPCODE_RDMA_WRITE_IMM = 0x00,
  306. MLX5_RECV_OPCODE_SEND = 0x01,
  307. MLX5_RECV_OPCODE_SEND_IMM = 0x02,
  308. MLX5_RECV_OPCODE_SEND_INVAL = 0x03,
  309. MLX5_CQE_OPCODE_ERROR = 0x1e,
  310. MLX5_CQE_OPCODE_RESIZE = 0x16,
  311. MLX5_OPCODE_SET_PSV = 0x20,
  312. MLX5_OPCODE_GET_PSV = 0x21,
  313. MLX5_OPCODE_CHECK_PSV = 0x22,
  314. MLX5_OPCODE_RGET_PSV = 0x26,
  315. MLX5_OPCODE_RCHECK_PSV = 0x27,
  316. MLX5_OPCODE_UMR = 0x25,
  317. };
  318. enum {
  319. MLX5_SET_PORT_RESET_QKEY = 0,
  320. MLX5_SET_PORT_GUID0 = 16,
  321. MLX5_SET_PORT_NODE_GUID = 17,
  322. MLX5_SET_PORT_SYS_GUID = 18,
  323. MLX5_SET_PORT_GID_TABLE = 19,
  324. MLX5_SET_PORT_PKEY_TABLE = 20,
  325. };
  326. enum {
  327. MLX5_BW_NO_LIMIT = 0,
  328. MLX5_100_MBPS_UNIT = 3,
  329. MLX5_GBPS_UNIT = 4,
  330. };
  331. enum {
  332. MLX5_MAX_PAGE_SHIFT = 31
  333. };
  334. enum {
  335. MLX5_ADAPTER_PAGE_SHIFT = 12,
  336. MLX5_ADAPTER_PAGE_SIZE = 1 << MLX5_ADAPTER_PAGE_SHIFT,
  337. };
  338. enum {
  339. MLX5_CAP_OFF_CMDIF_CSUM = 46,
  340. };
  341. enum {
  342. /*
  343. * Max wqe size for rdma read is 512 bytes, so this
  344. * limits our max_sge_rd as the wqe needs to fit:
  345. * - ctrl segment (16 bytes)
  346. * - rdma segment (16 bytes)
  347. * - scatter elements (16 bytes each)
  348. */
  349. MLX5_MAX_SGE_RD = (512 - 16 - 16) / 16
  350. };
  351. struct mlx5_inbox_hdr {
  352. __be16 opcode;
  353. u8 rsvd[4];
  354. __be16 opmod;
  355. };
  356. struct mlx5_outbox_hdr {
  357. u8 status;
  358. u8 rsvd[3];
  359. __be32 syndrome;
  360. };
  361. struct mlx5_cmd_query_adapter_mbox_in {
  362. struct mlx5_inbox_hdr hdr;
  363. u8 rsvd[8];
  364. };
  365. struct mlx5_cmd_query_adapter_mbox_out {
  366. struct mlx5_outbox_hdr hdr;
  367. u8 rsvd0[24];
  368. u8 intapin;
  369. u8 rsvd1[13];
  370. __be16 vsd_vendor_id;
  371. u8 vsd[208];
  372. u8 vsd_psid[16];
  373. };
  374. enum mlx5_odp_transport_cap_bits {
  375. MLX5_ODP_SUPPORT_SEND = 1 << 31,
  376. MLX5_ODP_SUPPORT_RECV = 1 << 30,
  377. MLX5_ODP_SUPPORT_WRITE = 1 << 29,
  378. MLX5_ODP_SUPPORT_READ = 1 << 28,
  379. };
  380. struct mlx5_odp_caps {
  381. char reserved[0x10];
  382. struct {
  383. __be32 rc_odp_caps;
  384. __be32 uc_odp_caps;
  385. __be32 ud_odp_caps;
  386. } per_transport_caps;
  387. char reserved2[0xe4];
  388. };
  389. struct mlx5_cmd_layout {
  390. u8 type;
  391. u8 rsvd0[3];
  392. __be32 inlen;
  393. __be64 in_ptr;
  394. __be32 in[4];
  395. __be32 out[4];
  396. __be64 out_ptr;
  397. __be32 outlen;
  398. u8 token;
  399. u8 sig;
  400. u8 rsvd1;
  401. u8 status_own;
  402. };
  403. struct health_buffer {
  404. __be32 assert_var[5];
  405. __be32 rsvd0[3];
  406. __be32 assert_exit_ptr;
  407. __be32 assert_callra;
  408. __be32 rsvd1[2];
  409. __be32 fw_ver;
  410. __be32 hw_id;
  411. __be32 rsvd2;
  412. u8 irisc_index;
  413. u8 synd;
  414. __be16 ext_synd;
  415. };
  416. struct mlx5_init_seg {
  417. __be32 fw_rev;
  418. __be32 cmdif_rev_fw_sub;
  419. __be32 rsvd0[2];
  420. __be32 cmdq_addr_h;
  421. __be32 cmdq_addr_l_sz;
  422. __be32 cmd_dbell;
  423. __be32 rsvd1[120];
  424. __be32 initializing;
  425. struct health_buffer health;
  426. __be32 rsvd2[880];
  427. __be32 internal_timer_h;
  428. __be32 internal_timer_l;
  429. __be32 rsvd3[2];
  430. __be32 health_counter;
  431. __be32 rsvd4[1019];
  432. __be64 ieee1588_clk;
  433. __be32 ieee1588_clk_type;
  434. __be32 clr_intx;
  435. };
  436. struct mlx5_eqe_comp {
  437. __be32 reserved[6];
  438. __be32 cqn;
  439. };
  440. struct mlx5_eqe_qp_srq {
  441. __be32 reserved1[5];
  442. u8 type;
  443. u8 reserved2[3];
  444. __be32 qp_srq_n;
  445. };
  446. struct mlx5_eqe_cq_err {
  447. __be32 cqn;
  448. u8 reserved1[7];
  449. u8 syndrome;
  450. };
  451. struct mlx5_eqe_port_state {
  452. u8 reserved0[8];
  453. u8 port;
  454. };
  455. struct mlx5_eqe_gpio {
  456. __be32 reserved0[2];
  457. __be64 gpio_event;
  458. };
  459. struct mlx5_eqe_congestion {
  460. u8 type;
  461. u8 rsvd0;
  462. u8 congestion_level;
  463. };
  464. struct mlx5_eqe_stall_vl {
  465. u8 rsvd0[3];
  466. u8 port_vl;
  467. };
  468. struct mlx5_eqe_cmd {
  469. __be32 vector;
  470. __be32 rsvd[6];
  471. };
  472. struct mlx5_eqe_page_req {
  473. u8 rsvd0[2];
  474. __be16 func_id;
  475. __be32 num_pages;
  476. __be32 rsvd1[5];
  477. };
  478. struct mlx5_eqe_page_fault {
  479. __be32 bytes_committed;
  480. union {
  481. struct {
  482. u16 reserved1;
  483. __be16 wqe_index;
  484. u16 reserved2;
  485. __be16 packet_length;
  486. u8 reserved3[12];
  487. } __packed wqe;
  488. struct {
  489. __be32 r_key;
  490. u16 reserved1;
  491. __be16 packet_length;
  492. __be32 rdma_op_len;
  493. __be64 rdma_va;
  494. } __packed rdma;
  495. } __packed;
  496. __be32 flags_qpn;
  497. } __packed;
  498. struct mlx5_eqe_vport_change {
  499. u8 rsvd0[2];
  500. __be16 vport_num;
  501. __be32 rsvd1[6];
  502. } __packed;
  503. union ev_data {
  504. __be32 raw[7];
  505. struct mlx5_eqe_cmd cmd;
  506. struct mlx5_eqe_comp comp;
  507. struct mlx5_eqe_qp_srq qp_srq;
  508. struct mlx5_eqe_cq_err cq_err;
  509. struct mlx5_eqe_port_state port;
  510. struct mlx5_eqe_gpio gpio;
  511. struct mlx5_eqe_congestion cong;
  512. struct mlx5_eqe_stall_vl stall_vl;
  513. struct mlx5_eqe_page_req req_pages;
  514. struct mlx5_eqe_page_fault page_fault;
  515. struct mlx5_eqe_vport_change vport_change;
  516. } __packed;
  517. struct mlx5_eqe {
  518. u8 rsvd0;
  519. u8 type;
  520. u8 rsvd1;
  521. u8 sub_type;
  522. __be32 rsvd2[7];
  523. union ev_data data;
  524. __be16 rsvd3;
  525. u8 signature;
  526. u8 owner;
  527. } __packed;
  528. struct mlx5_cmd_prot_block {
  529. u8 data[MLX5_CMD_DATA_BLOCK_SIZE];
  530. u8 rsvd0[48];
  531. __be64 next;
  532. __be32 block_num;
  533. u8 rsvd1;
  534. u8 token;
  535. u8 ctrl_sig;
  536. u8 sig;
  537. };
  538. enum {
  539. MLX5_CQE_SYND_FLUSHED_IN_ERROR = 5,
  540. };
  541. struct mlx5_err_cqe {
  542. u8 rsvd0[32];
  543. __be32 srqn;
  544. u8 rsvd1[18];
  545. u8 vendor_err_synd;
  546. u8 syndrome;
  547. __be32 s_wqe_opcode_qpn;
  548. __be16 wqe_counter;
  549. u8 signature;
  550. u8 op_own;
  551. };
  552. struct mlx5_cqe64 {
  553. u8 outer_l3_tunneled;
  554. u8 rsvd0;
  555. __be16 wqe_id;
  556. u8 lro_tcppsh_abort_dupack;
  557. u8 lro_min_ttl;
  558. __be16 lro_tcp_win;
  559. __be32 lro_ack_seq_num;
  560. __be32 rss_hash_result;
  561. u8 rss_hash_type;
  562. u8 ml_path;
  563. u8 rsvd20[2];
  564. __be16 check_sum;
  565. __be16 slid;
  566. __be32 flags_rqpn;
  567. u8 hds_ip_ext;
  568. u8 l4_l3_hdr_type;
  569. __be16 vlan_info;
  570. __be32 srqn; /* [31:24]: lro_num_seg, [23:0]: srqn */
  571. __be32 imm_inval_pkey;
  572. u8 rsvd40[4];
  573. __be32 byte_cnt;
  574. __be32 timestamp_h;
  575. __be32 timestamp_l;
  576. __be32 sop_drop_qpn;
  577. __be16 wqe_counter;
  578. u8 signature;
  579. u8 op_own;
  580. };
  581. struct mlx5_mini_cqe8 {
  582. union {
  583. __be32 rx_hash_result;
  584. struct {
  585. __be16 checksum;
  586. __be16 rsvd;
  587. };
  588. struct {
  589. __be16 wqe_counter;
  590. u8 s_wqe_opcode;
  591. u8 reserved;
  592. } s_wqe_info;
  593. };
  594. __be32 byte_cnt;
  595. };
  596. enum {
  597. MLX5_NO_INLINE_DATA,
  598. MLX5_INLINE_DATA32_SEG,
  599. MLX5_INLINE_DATA64_SEG,
  600. MLX5_COMPRESSED,
  601. };
  602. enum {
  603. MLX5_CQE_FORMAT_CSUM = 0x1,
  604. };
  605. #define MLX5_MINI_CQE_ARRAY_SIZE 8
  606. static inline int mlx5_get_cqe_format(struct mlx5_cqe64 *cqe)
  607. {
  608. return (cqe->op_own >> 2) & 0x3;
  609. }
  610. static inline int get_cqe_lro_tcppsh(struct mlx5_cqe64 *cqe)
  611. {
  612. return (cqe->lro_tcppsh_abort_dupack >> 6) & 1;
  613. }
  614. static inline u8 get_cqe_l4_hdr_type(struct mlx5_cqe64 *cqe)
  615. {
  616. return (cqe->l4_l3_hdr_type >> 4) & 0x7;
  617. }
  618. static inline u8 get_cqe_l3_hdr_type(struct mlx5_cqe64 *cqe)
  619. {
  620. return (cqe->l4_l3_hdr_type >> 2) & 0x3;
  621. }
  622. static inline u8 cqe_is_tunneled(struct mlx5_cqe64 *cqe)
  623. {
  624. return cqe->outer_l3_tunneled & 0x1;
  625. }
  626. static inline int cqe_has_vlan(struct mlx5_cqe64 *cqe)
  627. {
  628. return !!(cqe->l4_l3_hdr_type & 0x1);
  629. }
  630. static inline u64 get_cqe_ts(struct mlx5_cqe64 *cqe)
  631. {
  632. u32 hi, lo;
  633. hi = be32_to_cpu(cqe->timestamp_h);
  634. lo = be32_to_cpu(cqe->timestamp_l);
  635. return (u64)lo | ((u64)hi << 32);
  636. }
  637. struct mpwrq_cqe_bc {
  638. __be16 filler_consumed_strides;
  639. __be16 byte_cnt;
  640. };
  641. static inline u16 mpwrq_get_cqe_byte_cnt(struct mlx5_cqe64 *cqe)
  642. {
  643. struct mpwrq_cqe_bc *bc = (struct mpwrq_cqe_bc *)&cqe->byte_cnt;
  644. return be16_to_cpu(bc->byte_cnt);
  645. }
  646. static inline u16 mpwrq_get_cqe_bc_consumed_strides(struct mpwrq_cqe_bc *bc)
  647. {
  648. return 0x7fff & be16_to_cpu(bc->filler_consumed_strides);
  649. }
  650. static inline u16 mpwrq_get_cqe_consumed_strides(struct mlx5_cqe64 *cqe)
  651. {
  652. struct mpwrq_cqe_bc *bc = (struct mpwrq_cqe_bc *)&cqe->byte_cnt;
  653. return mpwrq_get_cqe_bc_consumed_strides(bc);
  654. }
  655. static inline bool mpwrq_is_filler_cqe(struct mlx5_cqe64 *cqe)
  656. {
  657. struct mpwrq_cqe_bc *bc = (struct mpwrq_cqe_bc *)&cqe->byte_cnt;
  658. return 0x8000 & be16_to_cpu(bc->filler_consumed_strides);
  659. }
  660. static inline u16 mpwrq_get_cqe_stride_index(struct mlx5_cqe64 *cqe)
  661. {
  662. return be16_to_cpu(cqe->wqe_counter);
  663. }
  664. enum {
  665. CQE_L4_HDR_TYPE_NONE = 0x0,
  666. CQE_L4_HDR_TYPE_TCP_NO_ACK = 0x1,
  667. CQE_L4_HDR_TYPE_UDP = 0x2,
  668. CQE_L4_HDR_TYPE_TCP_ACK_NO_DATA = 0x3,
  669. CQE_L4_HDR_TYPE_TCP_ACK_AND_DATA = 0x4,
  670. };
  671. enum {
  672. CQE_RSS_HTYPE_IP = 0x3 << 6,
  673. CQE_RSS_HTYPE_L4 = 0x3 << 2,
  674. };
  675. enum {
  676. MLX5_CQE_ROCE_L3_HEADER_TYPE_GRH = 0x0,
  677. MLX5_CQE_ROCE_L3_HEADER_TYPE_IPV6 = 0x1,
  678. MLX5_CQE_ROCE_L3_HEADER_TYPE_IPV4 = 0x2,
  679. };
  680. enum {
  681. CQE_L2_OK = 1 << 0,
  682. CQE_L3_OK = 1 << 1,
  683. CQE_L4_OK = 1 << 2,
  684. };
  685. struct mlx5_sig_err_cqe {
  686. u8 rsvd0[16];
  687. __be32 expected_trans_sig;
  688. __be32 actual_trans_sig;
  689. __be32 expected_reftag;
  690. __be32 actual_reftag;
  691. __be16 syndrome;
  692. u8 rsvd22[2];
  693. __be32 mkey;
  694. __be64 err_offset;
  695. u8 rsvd30[8];
  696. __be32 qpn;
  697. u8 rsvd38[2];
  698. u8 signature;
  699. u8 op_own;
  700. };
  701. struct mlx5_wqe_srq_next_seg {
  702. u8 rsvd0[2];
  703. __be16 next_wqe_index;
  704. u8 signature;
  705. u8 rsvd1[11];
  706. };
  707. union mlx5_ext_cqe {
  708. struct ib_grh grh;
  709. u8 inl[64];
  710. };
  711. struct mlx5_cqe128 {
  712. union mlx5_ext_cqe inl_grh;
  713. struct mlx5_cqe64 cqe64;
  714. };
  715. struct mlx5_srq_ctx {
  716. u8 state_log_sz;
  717. u8 rsvd0[3];
  718. __be32 flags_xrcd;
  719. __be32 pgoff_cqn;
  720. u8 rsvd1[4];
  721. u8 log_pg_sz;
  722. u8 rsvd2[7];
  723. __be32 pd;
  724. __be16 lwm;
  725. __be16 wqe_cnt;
  726. u8 rsvd3[8];
  727. __be64 db_record;
  728. };
  729. struct mlx5_create_srq_mbox_in {
  730. struct mlx5_inbox_hdr hdr;
  731. __be32 input_srqn;
  732. u8 rsvd0[4];
  733. struct mlx5_srq_ctx ctx;
  734. u8 rsvd1[208];
  735. __be64 pas[0];
  736. };
  737. struct mlx5_create_srq_mbox_out {
  738. struct mlx5_outbox_hdr hdr;
  739. __be32 srqn;
  740. u8 rsvd[4];
  741. };
  742. struct mlx5_destroy_srq_mbox_in {
  743. struct mlx5_inbox_hdr hdr;
  744. __be32 srqn;
  745. u8 rsvd[4];
  746. };
  747. struct mlx5_destroy_srq_mbox_out {
  748. struct mlx5_outbox_hdr hdr;
  749. u8 rsvd[8];
  750. };
  751. struct mlx5_query_srq_mbox_in {
  752. struct mlx5_inbox_hdr hdr;
  753. __be32 srqn;
  754. u8 rsvd0[4];
  755. };
  756. struct mlx5_query_srq_mbox_out {
  757. struct mlx5_outbox_hdr hdr;
  758. u8 rsvd0[8];
  759. struct mlx5_srq_ctx ctx;
  760. u8 rsvd1[32];
  761. __be64 pas[0];
  762. };
  763. struct mlx5_arm_srq_mbox_in {
  764. struct mlx5_inbox_hdr hdr;
  765. __be32 srqn;
  766. __be16 rsvd;
  767. __be16 lwm;
  768. };
  769. struct mlx5_arm_srq_mbox_out {
  770. struct mlx5_outbox_hdr hdr;
  771. u8 rsvd[8];
  772. };
  773. struct mlx5_cq_context {
  774. u8 status;
  775. u8 cqe_sz_flags;
  776. u8 st;
  777. u8 rsvd3;
  778. u8 rsvd4[6];
  779. __be16 page_offset;
  780. __be32 log_sz_usr_page;
  781. __be16 cq_period;
  782. __be16 cq_max_count;
  783. __be16 rsvd20;
  784. __be16 c_eqn;
  785. u8 log_pg_sz;
  786. u8 rsvd25[7];
  787. __be32 last_notified_index;
  788. __be32 solicit_producer_index;
  789. __be32 consumer_counter;
  790. __be32 producer_counter;
  791. u8 rsvd48[8];
  792. __be64 db_record_addr;
  793. };
  794. struct mlx5_create_cq_mbox_in {
  795. struct mlx5_inbox_hdr hdr;
  796. __be32 input_cqn;
  797. u8 rsvdx[4];
  798. struct mlx5_cq_context ctx;
  799. u8 rsvd6[192];
  800. __be64 pas[0];
  801. };
  802. struct mlx5_create_cq_mbox_out {
  803. struct mlx5_outbox_hdr hdr;
  804. __be32 cqn;
  805. u8 rsvd0[4];
  806. };
  807. struct mlx5_destroy_cq_mbox_in {
  808. struct mlx5_inbox_hdr hdr;
  809. __be32 cqn;
  810. u8 rsvd0[4];
  811. };
  812. struct mlx5_destroy_cq_mbox_out {
  813. struct mlx5_outbox_hdr hdr;
  814. u8 rsvd0[8];
  815. };
  816. struct mlx5_query_cq_mbox_in {
  817. struct mlx5_inbox_hdr hdr;
  818. __be32 cqn;
  819. u8 rsvd0[4];
  820. };
  821. struct mlx5_query_cq_mbox_out {
  822. struct mlx5_outbox_hdr hdr;
  823. u8 rsvd0[8];
  824. struct mlx5_cq_context ctx;
  825. u8 rsvd6[16];
  826. __be64 pas[0];
  827. };
  828. struct mlx5_modify_cq_mbox_in {
  829. struct mlx5_inbox_hdr hdr;
  830. __be32 cqn;
  831. __be32 field_select;
  832. struct mlx5_cq_context ctx;
  833. u8 rsvd[192];
  834. __be64 pas[0];
  835. };
  836. struct mlx5_modify_cq_mbox_out {
  837. struct mlx5_outbox_hdr hdr;
  838. u8 rsvd[8];
  839. };
  840. struct mlx5_enable_hca_mbox_in {
  841. struct mlx5_inbox_hdr hdr;
  842. u8 rsvd[8];
  843. };
  844. struct mlx5_enable_hca_mbox_out {
  845. struct mlx5_outbox_hdr hdr;
  846. u8 rsvd[8];
  847. };
  848. struct mlx5_disable_hca_mbox_in {
  849. struct mlx5_inbox_hdr hdr;
  850. u8 rsvd[8];
  851. };
  852. struct mlx5_disable_hca_mbox_out {
  853. struct mlx5_outbox_hdr hdr;
  854. u8 rsvd[8];
  855. };
  856. enum {
  857. MLX5_MKEY_STATUS_FREE = 1 << 6,
  858. };
  859. struct mlx5_mkey_seg {
  860. /* This is a two bit field occupying bits 31-30.
  861. * bit 31 is always 0,
  862. * bit 30 is zero for regular MRs and 1 (e.g free) for UMRs that do not have tanslation
  863. */
  864. u8 status;
  865. u8 pcie_control;
  866. u8 flags;
  867. u8 version;
  868. __be32 qpn_mkey7_0;
  869. u8 rsvd1[4];
  870. __be32 flags_pd;
  871. __be64 start_addr;
  872. __be64 len;
  873. __be32 bsfs_octo_size;
  874. u8 rsvd2[16];
  875. __be32 xlt_oct_size;
  876. u8 rsvd3[3];
  877. u8 log2_page_size;
  878. u8 rsvd4[4];
  879. };
  880. struct mlx5_query_special_ctxs_mbox_in {
  881. struct mlx5_inbox_hdr hdr;
  882. u8 rsvd[8];
  883. };
  884. struct mlx5_query_special_ctxs_mbox_out {
  885. struct mlx5_outbox_hdr hdr;
  886. __be32 dump_fill_mkey;
  887. __be32 reserved_lkey;
  888. };
  889. struct mlx5_create_mkey_mbox_in {
  890. struct mlx5_inbox_hdr hdr;
  891. __be32 input_mkey_index;
  892. __be32 flags;
  893. struct mlx5_mkey_seg seg;
  894. u8 rsvd1[16];
  895. __be32 xlat_oct_act_size;
  896. __be32 rsvd2;
  897. u8 rsvd3[168];
  898. __be64 pas[0];
  899. };
  900. struct mlx5_create_mkey_mbox_out {
  901. struct mlx5_outbox_hdr hdr;
  902. __be32 mkey;
  903. u8 rsvd[4];
  904. };
  905. struct mlx5_destroy_mkey_mbox_in {
  906. struct mlx5_inbox_hdr hdr;
  907. __be32 mkey;
  908. u8 rsvd[4];
  909. };
  910. struct mlx5_destroy_mkey_mbox_out {
  911. struct mlx5_outbox_hdr hdr;
  912. u8 rsvd[8];
  913. };
  914. struct mlx5_query_mkey_mbox_in {
  915. struct mlx5_inbox_hdr hdr;
  916. __be32 mkey;
  917. };
  918. struct mlx5_query_mkey_mbox_out {
  919. struct mlx5_outbox_hdr hdr;
  920. __be64 pas[0];
  921. };
  922. struct mlx5_modify_mkey_mbox_in {
  923. struct mlx5_inbox_hdr hdr;
  924. __be32 mkey;
  925. __be64 pas[0];
  926. };
  927. struct mlx5_modify_mkey_mbox_out {
  928. struct mlx5_outbox_hdr hdr;
  929. u8 rsvd[8];
  930. };
  931. struct mlx5_dump_mkey_mbox_in {
  932. struct mlx5_inbox_hdr hdr;
  933. };
  934. struct mlx5_dump_mkey_mbox_out {
  935. struct mlx5_outbox_hdr hdr;
  936. __be32 mkey;
  937. };
  938. #define MLX5_ATTR_EXTENDED_PORT_INFO cpu_to_be16(0xff90)
  939. enum {
  940. MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO = 1 << 0
  941. };
  942. struct mlx5_allocate_psv_in {
  943. struct mlx5_inbox_hdr hdr;
  944. __be32 npsv_pd;
  945. __be32 rsvd_psv0;
  946. };
  947. struct mlx5_allocate_psv_out {
  948. struct mlx5_outbox_hdr hdr;
  949. u8 rsvd[8];
  950. __be32 psv_idx[4];
  951. };
  952. struct mlx5_destroy_psv_in {
  953. struct mlx5_inbox_hdr hdr;
  954. __be32 psv_number;
  955. u8 rsvd[4];
  956. };
  957. struct mlx5_destroy_psv_out {
  958. struct mlx5_outbox_hdr hdr;
  959. u8 rsvd[8];
  960. };
  961. enum {
  962. VPORT_STATE_DOWN = 0x0,
  963. VPORT_STATE_UP = 0x1,
  964. };
  965. enum {
  966. MLX5_ESW_VPORT_ADMIN_STATE_DOWN = 0x0,
  967. MLX5_ESW_VPORT_ADMIN_STATE_UP = 0x1,
  968. MLX5_ESW_VPORT_ADMIN_STATE_AUTO = 0x2,
  969. };
  970. enum {
  971. MLX5_L3_PROT_TYPE_IPV4 = 0,
  972. MLX5_L3_PROT_TYPE_IPV6 = 1,
  973. };
  974. enum {
  975. MLX5_L4_PROT_TYPE_TCP = 0,
  976. MLX5_L4_PROT_TYPE_UDP = 1,
  977. };
  978. enum {
  979. MLX5_HASH_FIELD_SEL_SRC_IP = 1 << 0,
  980. MLX5_HASH_FIELD_SEL_DST_IP = 1 << 1,
  981. MLX5_HASH_FIELD_SEL_L4_SPORT = 1 << 2,
  982. MLX5_HASH_FIELD_SEL_L4_DPORT = 1 << 3,
  983. MLX5_HASH_FIELD_SEL_IPSEC_SPI = 1 << 4,
  984. };
  985. enum {
  986. MLX5_MATCH_OUTER_HEADERS = 1 << 0,
  987. MLX5_MATCH_MISC_PARAMETERS = 1 << 1,
  988. MLX5_MATCH_INNER_HEADERS = 1 << 2,
  989. };
  990. enum {
  991. MLX5_FLOW_TABLE_TYPE_NIC_RCV = 0,
  992. MLX5_FLOW_TABLE_TYPE_ESWITCH = 4,
  993. };
  994. enum {
  995. MLX5_FLOW_CONTEXT_DEST_TYPE_VPORT = 0,
  996. MLX5_FLOW_CONTEXT_DEST_TYPE_FLOW_TABLE = 1,
  997. MLX5_FLOW_CONTEXT_DEST_TYPE_TIR = 2,
  998. };
  999. enum mlx5_list_type {
  1000. MLX5_NVPRT_LIST_TYPE_UC = 0x0,
  1001. MLX5_NVPRT_LIST_TYPE_MC = 0x1,
  1002. MLX5_NVPRT_LIST_TYPE_VLAN = 0x2,
  1003. };
  1004. enum {
  1005. MLX5_RQC_RQ_TYPE_MEMORY_RQ_INLINE = 0x0,
  1006. MLX5_RQC_RQ_TYPE_MEMORY_RQ_RPM = 0x1,
  1007. };
  1008. enum mlx5_wol_mode {
  1009. MLX5_WOL_DISABLE = 0,
  1010. MLX5_WOL_SECURED_MAGIC = 1 << 1,
  1011. MLX5_WOL_MAGIC = 1 << 2,
  1012. MLX5_WOL_ARP = 1 << 3,
  1013. MLX5_WOL_BROADCAST = 1 << 4,
  1014. MLX5_WOL_MULTICAST = 1 << 5,
  1015. MLX5_WOL_UNICAST = 1 << 6,
  1016. MLX5_WOL_PHY_ACTIVITY = 1 << 7,
  1017. };
  1018. /* MLX5 DEV CAPs */
  1019. /* TODO: EAT.ME */
  1020. enum mlx5_cap_mode {
  1021. HCA_CAP_OPMOD_GET_MAX = 0,
  1022. HCA_CAP_OPMOD_GET_CUR = 1,
  1023. };
  1024. enum mlx5_cap_type {
  1025. MLX5_CAP_GENERAL = 0,
  1026. MLX5_CAP_ETHERNET_OFFLOADS,
  1027. MLX5_CAP_ODP,
  1028. MLX5_CAP_ATOMIC,
  1029. MLX5_CAP_ROCE,
  1030. MLX5_CAP_IPOIB_OFFLOADS,
  1031. MLX5_CAP_EOIB_OFFLOADS,
  1032. MLX5_CAP_FLOW_TABLE,
  1033. MLX5_CAP_ESWITCH_FLOW_TABLE,
  1034. MLX5_CAP_ESWITCH,
  1035. MLX5_CAP_RESERVED,
  1036. MLX5_CAP_VECTOR_CALC,
  1037. MLX5_CAP_QOS,
  1038. /* NUM OF CAP Types */
  1039. MLX5_CAP_NUM
  1040. };
  1041. /* GET Dev Caps macros */
  1042. #define MLX5_CAP_GEN(mdev, cap) \
  1043. MLX5_GET(cmd_hca_cap, mdev->hca_caps_cur[MLX5_CAP_GENERAL], cap)
  1044. #define MLX5_CAP_GEN_MAX(mdev, cap) \
  1045. MLX5_GET(cmd_hca_cap, mdev->hca_caps_max[MLX5_CAP_GENERAL], cap)
  1046. #define MLX5_CAP_ETH(mdev, cap) \
  1047. MLX5_GET(per_protocol_networking_offload_caps,\
  1048. mdev->hca_caps_cur[MLX5_CAP_ETHERNET_OFFLOADS], cap)
  1049. #define MLX5_CAP_ETH_MAX(mdev, cap) \
  1050. MLX5_GET(per_protocol_networking_offload_caps,\
  1051. mdev->hca_caps_max[MLX5_CAP_ETHERNET_OFFLOADS], cap)
  1052. #define MLX5_CAP_ROCE(mdev, cap) \
  1053. MLX5_GET(roce_cap, mdev->hca_caps_cur[MLX5_CAP_ROCE], cap)
  1054. #define MLX5_CAP_ROCE_MAX(mdev, cap) \
  1055. MLX5_GET(roce_cap, mdev->hca_caps_max[MLX5_CAP_ROCE], cap)
  1056. #define MLX5_CAP_ATOMIC(mdev, cap) \
  1057. MLX5_GET(atomic_caps, mdev->hca_caps_cur[MLX5_CAP_ATOMIC], cap)
  1058. #define MLX5_CAP_ATOMIC_MAX(mdev, cap) \
  1059. MLX5_GET(atomic_caps, mdev->hca_caps_max[MLX5_CAP_ATOMIC], cap)
  1060. #define MLX5_CAP_FLOWTABLE(mdev, cap) \
  1061. MLX5_GET(flow_table_nic_cap, mdev->hca_caps_cur[MLX5_CAP_FLOW_TABLE], cap)
  1062. #define MLX5_CAP_FLOWTABLE_MAX(mdev, cap) \
  1063. MLX5_GET(flow_table_nic_cap, mdev->hca_caps_max[MLX5_CAP_FLOW_TABLE], cap)
  1064. #define MLX5_CAP_FLOWTABLE_NIC_RX(mdev, cap) \
  1065. MLX5_CAP_FLOWTABLE(mdev, flow_table_properties_nic_receive.cap)
  1066. #define MLX5_CAP_FLOWTABLE_NIC_RX_MAX(mdev, cap) \
  1067. MLX5_CAP_FLOWTABLE_MAX(mdev, flow_table_properties_nic_receive.cap)
  1068. #define MLX5_CAP_ESW_FLOWTABLE(mdev, cap) \
  1069. MLX5_GET(flow_table_eswitch_cap, \
  1070. mdev->hca_caps_cur[MLX5_CAP_ESWITCH_FLOW_TABLE], cap)
  1071. #define MLX5_CAP_ESW_FLOWTABLE_MAX(mdev, cap) \
  1072. MLX5_GET(flow_table_eswitch_cap, \
  1073. mdev->hca_caps_max[MLX5_CAP_ESWITCH_FLOW_TABLE], cap)
  1074. #define MLX5_CAP_ESW_FLOWTABLE_FDB(mdev, cap) \
  1075. MLX5_CAP_ESW_FLOWTABLE(mdev, flow_table_properties_nic_esw_fdb.cap)
  1076. #define MLX5_CAP_ESW_FLOWTABLE_FDB_MAX(mdev, cap) \
  1077. MLX5_CAP_ESW_FLOWTABLE_MAX(mdev, flow_table_properties_nic_esw_fdb.cap)
  1078. #define MLX5_CAP_ESW_EGRESS_ACL(mdev, cap) \
  1079. MLX5_CAP_ESW_FLOWTABLE(mdev, flow_table_properties_esw_acl_egress.cap)
  1080. #define MLX5_CAP_ESW_EGRESS_ACL_MAX(mdev, cap) \
  1081. MLX5_CAP_ESW_FLOWTABLE_MAX(mdev, flow_table_properties_esw_acl_egress.cap)
  1082. #define MLX5_CAP_ESW_INGRESS_ACL(mdev, cap) \
  1083. MLX5_CAP_ESW_FLOWTABLE(mdev, flow_table_properties_esw_acl_ingress.cap)
  1084. #define MLX5_CAP_ESW_INGRESS_ACL_MAX(mdev, cap) \
  1085. MLX5_CAP_ESW_FLOWTABLE_MAX(mdev, flow_table_properties_esw_acl_ingress.cap)
  1086. #define MLX5_CAP_ESW(mdev, cap) \
  1087. MLX5_GET(e_switch_cap, \
  1088. mdev->hca_caps_cur[MLX5_CAP_ESWITCH], cap)
  1089. #define MLX5_CAP_ESW_MAX(mdev, cap) \
  1090. MLX5_GET(e_switch_cap, \
  1091. mdev->hca_caps_max[MLX5_CAP_ESWITCH], cap)
  1092. #define MLX5_CAP_ODP(mdev, cap)\
  1093. MLX5_GET(odp_cap, mdev->hca_caps_cur[MLX5_CAP_ODP], cap)
  1094. #define MLX5_CAP_VECTOR_CALC(mdev, cap) \
  1095. MLX5_GET(vector_calc_cap, \
  1096. mdev->hca_caps_cur[MLX5_CAP_VECTOR_CALC], cap)
  1097. #define MLX5_CAP_QOS(mdev, cap)\
  1098. MLX5_GET(qos_cap, mdev->hca_caps_cur[MLX5_CAP_QOS], cap)
  1099. enum {
  1100. MLX5_CMD_STAT_OK = 0x0,
  1101. MLX5_CMD_STAT_INT_ERR = 0x1,
  1102. MLX5_CMD_STAT_BAD_OP_ERR = 0x2,
  1103. MLX5_CMD_STAT_BAD_PARAM_ERR = 0x3,
  1104. MLX5_CMD_STAT_BAD_SYS_STATE_ERR = 0x4,
  1105. MLX5_CMD_STAT_BAD_RES_ERR = 0x5,
  1106. MLX5_CMD_STAT_RES_BUSY = 0x6,
  1107. MLX5_CMD_STAT_LIM_ERR = 0x8,
  1108. MLX5_CMD_STAT_BAD_RES_STATE_ERR = 0x9,
  1109. MLX5_CMD_STAT_IX_ERR = 0xa,
  1110. MLX5_CMD_STAT_NO_RES_ERR = 0xf,
  1111. MLX5_CMD_STAT_BAD_INP_LEN_ERR = 0x50,
  1112. MLX5_CMD_STAT_BAD_OUTP_LEN_ERR = 0x51,
  1113. MLX5_CMD_STAT_BAD_QP_STATE_ERR = 0x10,
  1114. MLX5_CMD_STAT_BAD_PKT_ERR = 0x30,
  1115. MLX5_CMD_STAT_BAD_SIZE_OUTS_CQES_ERR = 0x40,
  1116. };
  1117. enum {
  1118. MLX5_IEEE_802_3_COUNTERS_GROUP = 0x0,
  1119. MLX5_RFC_2863_COUNTERS_GROUP = 0x1,
  1120. MLX5_RFC_2819_COUNTERS_GROUP = 0x2,
  1121. MLX5_RFC_3635_COUNTERS_GROUP = 0x3,
  1122. MLX5_ETHERNET_EXTENDED_COUNTERS_GROUP = 0x5,
  1123. MLX5_PER_PRIORITY_COUNTERS_GROUP = 0x10,
  1124. MLX5_PER_TRAFFIC_CLASS_COUNTERS_GROUP = 0x11,
  1125. MLX5_PHYSICAL_LAYER_COUNTERS_GROUP = 0x12,
  1126. MLX5_INFINIBAND_PORT_COUNTERS_GROUP = 0x20,
  1127. };
  1128. static inline u16 mlx5_to_sw_pkey_sz(int pkey_sz)
  1129. {
  1130. if (pkey_sz > MLX5_MAX_LOG_PKEY_TABLE)
  1131. return 0;
  1132. return MLX5_MIN_PKEY_TABLE_SIZE << pkey_sz;
  1133. }
  1134. #define MLX5_BY_PASS_NUM_REGULAR_PRIOS 8
  1135. #define MLX5_BY_PASS_NUM_DONT_TRAP_PRIOS 8
  1136. #define MLX5_BY_PASS_NUM_MULTICAST_PRIOS 1
  1137. #define MLX5_BY_PASS_NUM_PRIOS (MLX5_BY_PASS_NUM_REGULAR_PRIOS +\
  1138. MLX5_BY_PASS_NUM_DONT_TRAP_PRIOS +\
  1139. MLX5_BY_PASS_NUM_MULTICAST_PRIOS)
  1140. #endif /* MLX5_DEVICE_H */