device.h 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588
  1. /*
  2. * Copyright (c) 2006, 2007 Cisco Systems, Inc. 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 MLX4_DEVICE_H
  33. #define MLX4_DEVICE_H
  34. #include <linux/if_ether.h>
  35. #include <linux/pci.h>
  36. #include <linux/completion.h>
  37. #include <linux/radix-tree.h>
  38. #include <linux/cpu_rmap.h>
  39. #include <linux/crash_dump.h>
  40. #include <linux/refcount.h>
  41. #include <linux/timecounter.h>
  42. #define DEFAULT_UAR_PAGE_SHIFT 12
  43. #define MAX_MSIX 128
  44. #define MIN_MSIX_P_PORT 5
  45. #define MLX4_IS_LEGACY_EQ_MODE(dev_cap) ((dev_cap).num_comp_vectors < \
  46. (dev_cap).num_ports * MIN_MSIX_P_PORT)
  47. #define MLX4_MAX_100M_UNITS_VAL 255 /*
  48. * work around: can't set values
  49. * greater then this value when
  50. * using 100 Mbps units.
  51. */
  52. #define MLX4_RATELIMIT_100M_UNITS 3 /* 100 Mbps */
  53. #define MLX4_RATELIMIT_1G_UNITS 4 /* 1 Gbps */
  54. #define MLX4_RATELIMIT_DEFAULT 0x00ff
  55. #define MLX4_ROCE_MAX_GIDS 128
  56. #define MLX4_ROCE_PF_GIDS 16
  57. enum {
  58. MLX4_FLAG_MSI_X = 1 << 0,
  59. MLX4_FLAG_OLD_PORT_CMDS = 1 << 1,
  60. MLX4_FLAG_MASTER = 1 << 2,
  61. MLX4_FLAG_SLAVE = 1 << 3,
  62. MLX4_FLAG_SRIOV = 1 << 4,
  63. MLX4_FLAG_OLD_REG_MAC = 1 << 6,
  64. MLX4_FLAG_BONDED = 1 << 7,
  65. MLX4_FLAG_SECURE_HOST = 1 << 8,
  66. };
  67. enum {
  68. MLX4_PORT_CAP_IS_SM = 1 << 1,
  69. MLX4_PORT_CAP_DEV_MGMT_SUP = 1 << 19,
  70. };
  71. enum {
  72. MLX4_MAX_PORTS = 2,
  73. MLX4_MAX_PORT_PKEYS = 128,
  74. MLX4_MAX_PORT_GIDS = 128
  75. };
  76. /* base qkey for use in sriov tunnel-qp/proxy-qp communication.
  77. * These qkeys must not be allowed for general use. This is a 64k range,
  78. * and to test for violation, we use the mask (protect against future chg).
  79. */
  80. #define MLX4_RESERVED_QKEY_BASE (0xFFFF0000)
  81. #define MLX4_RESERVED_QKEY_MASK (0xFFFF0000)
  82. enum {
  83. MLX4_BOARD_ID_LEN = 64
  84. };
  85. enum {
  86. MLX4_MAX_NUM_PF = 16,
  87. MLX4_MAX_NUM_VF = 126,
  88. MLX4_MAX_NUM_VF_P_PORT = 64,
  89. MLX4_MFUNC_MAX = 128,
  90. MLX4_MAX_EQ_NUM = 1024,
  91. MLX4_MFUNC_EQ_NUM = 4,
  92. MLX4_MFUNC_MAX_EQES = 8,
  93. MLX4_MFUNC_EQE_MASK = (MLX4_MFUNC_MAX_EQES - 1)
  94. };
  95. /* Driver supports 3 different device methods to manage traffic steering:
  96. * -device managed - High level API for ib and eth flow steering. FW is
  97. * managing flow steering tables.
  98. * - B0 steering mode - Common low level API for ib and (if supported) eth.
  99. * - A0 steering mode - Limited low level API for eth. In case of IB,
  100. * B0 mode is in use.
  101. */
  102. enum {
  103. MLX4_STEERING_MODE_A0,
  104. MLX4_STEERING_MODE_B0,
  105. MLX4_STEERING_MODE_DEVICE_MANAGED
  106. };
  107. enum {
  108. MLX4_STEERING_DMFS_A0_DEFAULT,
  109. MLX4_STEERING_DMFS_A0_DYNAMIC,
  110. MLX4_STEERING_DMFS_A0_STATIC,
  111. MLX4_STEERING_DMFS_A0_DISABLE,
  112. MLX4_STEERING_DMFS_A0_NOT_SUPPORTED
  113. };
  114. static inline const char *mlx4_steering_mode_str(int steering_mode)
  115. {
  116. switch (steering_mode) {
  117. case MLX4_STEERING_MODE_A0:
  118. return "A0 steering";
  119. case MLX4_STEERING_MODE_B0:
  120. return "B0 steering";
  121. case MLX4_STEERING_MODE_DEVICE_MANAGED:
  122. return "Device managed flow steering";
  123. default:
  124. return "Unrecognize steering mode";
  125. }
  126. }
  127. enum {
  128. MLX4_TUNNEL_OFFLOAD_MODE_NONE,
  129. MLX4_TUNNEL_OFFLOAD_MODE_VXLAN
  130. };
  131. enum {
  132. MLX4_DEV_CAP_FLAG_RC = 1LL << 0,
  133. MLX4_DEV_CAP_FLAG_UC = 1LL << 1,
  134. MLX4_DEV_CAP_FLAG_UD = 1LL << 2,
  135. MLX4_DEV_CAP_FLAG_XRC = 1LL << 3,
  136. MLX4_DEV_CAP_FLAG_SRQ = 1LL << 6,
  137. MLX4_DEV_CAP_FLAG_IPOIB_CSUM = 1LL << 7,
  138. MLX4_DEV_CAP_FLAG_BAD_PKEY_CNTR = 1LL << 8,
  139. MLX4_DEV_CAP_FLAG_BAD_QKEY_CNTR = 1LL << 9,
  140. MLX4_DEV_CAP_FLAG_DPDP = 1LL << 12,
  141. MLX4_DEV_CAP_FLAG_BLH = 1LL << 15,
  142. MLX4_DEV_CAP_FLAG_MEM_WINDOW = 1LL << 16,
  143. MLX4_DEV_CAP_FLAG_APM = 1LL << 17,
  144. MLX4_DEV_CAP_FLAG_ATOMIC = 1LL << 18,
  145. MLX4_DEV_CAP_FLAG_RAW_MCAST = 1LL << 19,
  146. MLX4_DEV_CAP_FLAG_UD_AV_PORT = 1LL << 20,
  147. MLX4_DEV_CAP_FLAG_UD_MCAST = 1LL << 21,
  148. MLX4_DEV_CAP_FLAG_IBOE = 1LL << 30,
  149. MLX4_DEV_CAP_FLAG_UC_LOOPBACK = 1LL << 32,
  150. MLX4_DEV_CAP_FLAG_FCS_KEEP = 1LL << 34,
  151. MLX4_DEV_CAP_FLAG_WOL_PORT1 = 1LL << 37,
  152. MLX4_DEV_CAP_FLAG_WOL_PORT2 = 1LL << 38,
  153. MLX4_DEV_CAP_FLAG_UDP_RSS = 1LL << 40,
  154. MLX4_DEV_CAP_FLAG_VEP_UC_STEER = 1LL << 41,
  155. MLX4_DEV_CAP_FLAG_VEP_MC_STEER = 1LL << 42,
  156. MLX4_DEV_CAP_FLAG_COUNTERS = 1LL << 48,
  157. MLX4_DEV_CAP_FLAG_RSS_IP_FRAG = 1LL << 52,
  158. MLX4_DEV_CAP_FLAG_SET_ETH_SCHED = 1LL << 53,
  159. MLX4_DEV_CAP_FLAG_SENSE_SUPPORT = 1LL << 55,
  160. MLX4_DEV_CAP_FLAG_PORT_MNG_CHG_EV = 1LL << 59,
  161. MLX4_DEV_CAP_FLAG_64B_EQE = 1LL << 61,
  162. MLX4_DEV_CAP_FLAG_64B_CQE = 1LL << 62
  163. };
  164. enum {
  165. MLX4_DEV_CAP_FLAG2_RSS = 1LL << 0,
  166. MLX4_DEV_CAP_FLAG2_RSS_TOP = 1LL << 1,
  167. MLX4_DEV_CAP_FLAG2_RSS_XOR = 1LL << 2,
  168. MLX4_DEV_CAP_FLAG2_FS_EN = 1LL << 3,
  169. MLX4_DEV_CAP_FLAG2_REASSIGN_MAC_EN = 1LL << 4,
  170. MLX4_DEV_CAP_FLAG2_TS = 1LL << 5,
  171. MLX4_DEV_CAP_FLAG2_VLAN_CONTROL = 1LL << 6,
  172. MLX4_DEV_CAP_FLAG2_FSM = 1LL << 7,
  173. MLX4_DEV_CAP_FLAG2_UPDATE_QP = 1LL << 8,
  174. MLX4_DEV_CAP_FLAG2_DMFS_IPOIB = 1LL << 9,
  175. MLX4_DEV_CAP_FLAG2_VXLAN_OFFLOADS = 1LL << 10,
  176. MLX4_DEV_CAP_FLAG2_MAD_DEMUX = 1LL << 11,
  177. MLX4_DEV_CAP_FLAG2_CQE_STRIDE = 1LL << 12,
  178. MLX4_DEV_CAP_FLAG2_EQE_STRIDE = 1LL << 13,
  179. MLX4_DEV_CAP_FLAG2_ETH_PROT_CTRL = 1LL << 14,
  180. MLX4_DEV_CAP_FLAG2_ETH_BACKPL_AN_REP = 1LL << 15,
  181. MLX4_DEV_CAP_FLAG2_CONFIG_DEV = 1LL << 16,
  182. MLX4_DEV_CAP_FLAG2_SYS_EQS = 1LL << 17,
  183. MLX4_DEV_CAP_FLAG2_80_VFS = 1LL << 18,
  184. MLX4_DEV_CAP_FLAG2_FS_A0 = 1LL << 19,
  185. MLX4_DEV_CAP_FLAG2_RECOVERABLE_ERROR_EVENT = 1LL << 20,
  186. MLX4_DEV_CAP_FLAG2_PORT_REMAP = 1LL << 21,
  187. MLX4_DEV_CAP_FLAG2_QCN = 1LL << 22,
  188. MLX4_DEV_CAP_FLAG2_QP_RATE_LIMIT = 1LL << 23,
  189. MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN = 1LL << 24,
  190. MLX4_DEV_CAP_FLAG2_QOS_VPP = 1LL << 25,
  191. MLX4_DEV_CAP_FLAG2_ETS_CFG = 1LL << 26,
  192. MLX4_DEV_CAP_FLAG2_PORT_BEACON = 1LL << 27,
  193. MLX4_DEV_CAP_FLAG2_IGNORE_FCS = 1LL << 28,
  194. MLX4_DEV_CAP_FLAG2_PHV_EN = 1LL << 29,
  195. MLX4_DEV_CAP_FLAG2_SKIP_OUTER_VLAN = 1LL << 30,
  196. MLX4_DEV_CAP_FLAG2_UPDATE_QP_SRC_CHECK_LB = 1ULL << 31,
  197. MLX4_DEV_CAP_FLAG2_LB_SRC_CHK = 1ULL << 32,
  198. MLX4_DEV_CAP_FLAG2_ROCE_V1_V2 = 1ULL << 33,
  199. MLX4_DEV_CAP_FLAG2_DMFS_UC_MC_SNIFFER = 1ULL << 34,
  200. MLX4_DEV_CAP_FLAG2_DIAG_PER_PORT = 1ULL << 35,
  201. MLX4_DEV_CAP_FLAG2_SVLAN_BY_QP = 1ULL << 36,
  202. MLX4_DEV_CAP_FLAG2_SL_TO_VL_CHANGE_EVENT = 1ULL << 37,
  203. MLX4_DEV_CAP_FLAG2_USER_MAC_EN = 1ULL << 38,
  204. MLX4_DEV_CAP_FLAG2_DRIVER_VERSION_TO_FW = 1ULL << 39,
  205. MLX4_DEV_CAP_FLAG2_SW_CQ_INIT = 1ULL << 40,
  206. };
  207. enum {
  208. MLX4_QUERY_FUNC_FLAGS_BF_RES_QP = 1LL << 0,
  209. MLX4_QUERY_FUNC_FLAGS_A0_RES_QP = 1LL << 1
  210. };
  211. enum {
  212. MLX4_VF_CAP_FLAG_RESET = 1 << 0
  213. };
  214. /* bit enums for an 8-bit flags field indicating special use
  215. * QPs which require special handling in qp_reserve_range.
  216. * Currently, this only includes QPs used by the ETH interface,
  217. * where we expect to use blueflame. These QPs must not have
  218. * bits 6 and 7 set in their qp number.
  219. *
  220. * This enum may use only bits 0..7.
  221. */
  222. enum {
  223. MLX4_RESERVE_A0_QP = 1 << 6,
  224. MLX4_RESERVE_ETH_BF_QP = 1 << 7,
  225. };
  226. enum {
  227. MLX4_DEV_CAP_64B_EQE_ENABLED = 1LL << 0,
  228. MLX4_DEV_CAP_64B_CQE_ENABLED = 1LL << 1,
  229. MLX4_DEV_CAP_CQE_STRIDE_ENABLED = 1LL << 2,
  230. MLX4_DEV_CAP_EQE_STRIDE_ENABLED = 1LL << 3
  231. };
  232. enum {
  233. MLX4_FUNC_CAP_64B_EQE_CQE = 1L << 0,
  234. MLX4_FUNC_CAP_EQE_CQE_STRIDE = 1L << 1,
  235. MLX4_FUNC_CAP_DMFS_A0_STATIC = 1L << 2
  236. };
  237. #define MLX4_ATTR_EXTENDED_PORT_INFO cpu_to_be16(0xff90)
  238. enum {
  239. MLX4_BMME_FLAG_WIN_TYPE_2B = 1 << 1,
  240. MLX4_BMME_FLAG_LOCAL_INV = 1 << 6,
  241. MLX4_BMME_FLAG_REMOTE_INV = 1 << 7,
  242. MLX4_BMME_FLAG_TYPE_2_WIN = 1 << 9,
  243. MLX4_BMME_FLAG_RESERVED_LKEY = 1 << 10,
  244. MLX4_BMME_FLAG_FAST_REG_WR = 1 << 11,
  245. MLX4_BMME_FLAG_ROCE_V1_V2 = 1 << 19,
  246. MLX4_BMME_FLAG_PORT_REMAP = 1 << 24,
  247. MLX4_BMME_FLAG_VSD_INIT2RTR = 1 << 28,
  248. };
  249. enum {
  250. MLX4_FLAG_PORT_REMAP = MLX4_BMME_FLAG_PORT_REMAP,
  251. MLX4_FLAG_ROCE_V1_V2 = MLX4_BMME_FLAG_ROCE_V1_V2
  252. };
  253. enum mlx4_event {
  254. MLX4_EVENT_TYPE_COMP = 0x00,
  255. MLX4_EVENT_TYPE_PATH_MIG = 0x01,
  256. MLX4_EVENT_TYPE_COMM_EST = 0x02,
  257. MLX4_EVENT_TYPE_SQ_DRAINED = 0x03,
  258. MLX4_EVENT_TYPE_SRQ_QP_LAST_WQE = 0x13,
  259. MLX4_EVENT_TYPE_SRQ_LIMIT = 0x14,
  260. MLX4_EVENT_TYPE_CQ_ERROR = 0x04,
  261. MLX4_EVENT_TYPE_WQ_CATAS_ERROR = 0x05,
  262. MLX4_EVENT_TYPE_EEC_CATAS_ERROR = 0x06,
  263. MLX4_EVENT_TYPE_PATH_MIG_FAILED = 0x07,
  264. MLX4_EVENT_TYPE_WQ_INVAL_REQ_ERROR = 0x10,
  265. MLX4_EVENT_TYPE_WQ_ACCESS_ERROR = 0x11,
  266. MLX4_EVENT_TYPE_SRQ_CATAS_ERROR = 0x12,
  267. MLX4_EVENT_TYPE_LOCAL_CATAS_ERROR = 0x08,
  268. MLX4_EVENT_TYPE_PORT_CHANGE = 0x09,
  269. MLX4_EVENT_TYPE_EQ_OVERFLOW = 0x0f,
  270. MLX4_EVENT_TYPE_ECC_DETECT = 0x0e,
  271. MLX4_EVENT_TYPE_CMD = 0x0a,
  272. MLX4_EVENT_TYPE_VEP_UPDATE = 0x19,
  273. MLX4_EVENT_TYPE_COMM_CHANNEL = 0x18,
  274. MLX4_EVENT_TYPE_OP_REQUIRED = 0x1a,
  275. MLX4_EVENT_TYPE_FATAL_WARNING = 0x1b,
  276. MLX4_EVENT_TYPE_FLR_EVENT = 0x1c,
  277. MLX4_EVENT_TYPE_PORT_MNG_CHG_EVENT = 0x1d,
  278. MLX4_EVENT_TYPE_RECOVERABLE_ERROR_EVENT = 0x3e,
  279. MLX4_EVENT_TYPE_NONE = 0xff,
  280. };
  281. enum {
  282. MLX4_PORT_CHANGE_SUBTYPE_DOWN = 1,
  283. MLX4_PORT_CHANGE_SUBTYPE_ACTIVE = 4
  284. };
  285. enum {
  286. MLX4_RECOVERABLE_ERROR_EVENT_SUBTYPE_BAD_CABLE = 1,
  287. MLX4_RECOVERABLE_ERROR_EVENT_SUBTYPE_UNSUPPORTED_CABLE = 2,
  288. };
  289. enum {
  290. MLX4_FATAL_WARNING_SUBTYPE_WARMING = 0,
  291. };
  292. enum slave_port_state {
  293. SLAVE_PORT_DOWN = 0,
  294. SLAVE_PENDING_UP,
  295. SLAVE_PORT_UP,
  296. };
  297. enum slave_port_gen_event {
  298. SLAVE_PORT_GEN_EVENT_DOWN = 0,
  299. SLAVE_PORT_GEN_EVENT_UP,
  300. SLAVE_PORT_GEN_EVENT_NONE,
  301. };
  302. enum slave_port_state_event {
  303. MLX4_PORT_STATE_DEV_EVENT_PORT_DOWN,
  304. MLX4_PORT_STATE_DEV_EVENT_PORT_UP,
  305. MLX4_PORT_STATE_IB_PORT_STATE_EVENT_GID_VALID,
  306. MLX4_PORT_STATE_IB_EVENT_GID_INVALID,
  307. };
  308. enum {
  309. MLX4_PERM_LOCAL_READ = 1 << 10,
  310. MLX4_PERM_LOCAL_WRITE = 1 << 11,
  311. MLX4_PERM_REMOTE_READ = 1 << 12,
  312. MLX4_PERM_REMOTE_WRITE = 1 << 13,
  313. MLX4_PERM_ATOMIC = 1 << 14,
  314. MLX4_PERM_BIND_MW = 1 << 15,
  315. MLX4_PERM_MASK = 0xFC00
  316. };
  317. enum {
  318. MLX4_OPCODE_NOP = 0x00,
  319. MLX4_OPCODE_SEND_INVAL = 0x01,
  320. MLX4_OPCODE_RDMA_WRITE = 0x08,
  321. MLX4_OPCODE_RDMA_WRITE_IMM = 0x09,
  322. MLX4_OPCODE_SEND = 0x0a,
  323. MLX4_OPCODE_SEND_IMM = 0x0b,
  324. MLX4_OPCODE_LSO = 0x0e,
  325. MLX4_OPCODE_RDMA_READ = 0x10,
  326. MLX4_OPCODE_ATOMIC_CS = 0x11,
  327. MLX4_OPCODE_ATOMIC_FA = 0x12,
  328. MLX4_OPCODE_MASKED_ATOMIC_CS = 0x14,
  329. MLX4_OPCODE_MASKED_ATOMIC_FA = 0x15,
  330. MLX4_OPCODE_BIND_MW = 0x18,
  331. MLX4_OPCODE_FMR = 0x19,
  332. MLX4_OPCODE_LOCAL_INVAL = 0x1b,
  333. MLX4_OPCODE_CONFIG_CMD = 0x1f,
  334. MLX4_RECV_OPCODE_RDMA_WRITE_IMM = 0x00,
  335. MLX4_RECV_OPCODE_SEND = 0x01,
  336. MLX4_RECV_OPCODE_SEND_IMM = 0x02,
  337. MLX4_RECV_OPCODE_SEND_INVAL = 0x03,
  338. MLX4_CQE_OPCODE_ERROR = 0x1e,
  339. MLX4_CQE_OPCODE_RESIZE = 0x16,
  340. };
  341. enum {
  342. MLX4_STAT_RATE_OFFSET = 5
  343. };
  344. enum mlx4_protocol {
  345. MLX4_PROT_IB_IPV6 = 0,
  346. MLX4_PROT_ETH,
  347. MLX4_PROT_IB_IPV4,
  348. MLX4_PROT_FCOE
  349. };
  350. enum {
  351. MLX4_MTT_FLAG_PRESENT = 1
  352. };
  353. enum mlx4_qp_region {
  354. MLX4_QP_REGION_FW = 0,
  355. MLX4_QP_REGION_RSS_RAW_ETH,
  356. MLX4_QP_REGION_BOTTOM = MLX4_QP_REGION_RSS_RAW_ETH,
  357. MLX4_QP_REGION_ETH_ADDR,
  358. MLX4_QP_REGION_FC_ADDR,
  359. MLX4_QP_REGION_FC_EXCH,
  360. MLX4_NUM_QP_REGION
  361. };
  362. enum mlx4_port_type {
  363. MLX4_PORT_TYPE_NONE = 0,
  364. MLX4_PORT_TYPE_IB = 1,
  365. MLX4_PORT_TYPE_ETH = 2,
  366. MLX4_PORT_TYPE_AUTO = 3
  367. };
  368. enum mlx4_special_vlan_idx {
  369. MLX4_NO_VLAN_IDX = 0,
  370. MLX4_VLAN_MISS_IDX,
  371. MLX4_VLAN_REGULAR
  372. };
  373. enum mlx4_steer_type {
  374. MLX4_MC_STEER = 0,
  375. MLX4_UC_STEER,
  376. MLX4_NUM_STEERS
  377. };
  378. enum mlx4_resource_usage {
  379. MLX4_RES_USAGE_NONE,
  380. MLX4_RES_USAGE_DRIVER,
  381. MLX4_RES_USAGE_USER_VERBS,
  382. };
  383. enum {
  384. MLX4_NUM_FEXCH = 64 * 1024,
  385. };
  386. enum {
  387. MLX4_MAX_FAST_REG_PAGES = 511,
  388. };
  389. enum {
  390. /*
  391. * Max wqe size for rdma read is 512 bytes, so this
  392. * limits our max_sge_rd as the wqe needs to fit:
  393. * - ctrl segment (16 bytes)
  394. * - rdma segment (16 bytes)
  395. * - scatter elements (16 bytes each)
  396. */
  397. MLX4_MAX_SGE_RD = (512 - 16 - 16) / 16
  398. };
  399. enum {
  400. MLX4_DEV_PMC_SUBTYPE_GUID_INFO = 0x14,
  401. MLX4_DEV_PMC_SUBTYPE_PORT_INFO = 0x15,
  402. MLX4_DEV_PMC_SUBTYPE_PKEY_TABLE = 0x16,
  403. MLX4_DEV_PMC_SUBTYPE_SL_TO_VL_MAP = 0x17,
  404. };
  405. /* Port mgmt change event handling */
  406. enum {
  407. MLX4_EQ_PORT_INFO_MSTR_SM_LID_CHANGE_MASK = 1 << 0,
  408. MLX4_EQ_PORT_INFO_GID_PFX_CHANGE_MASK = 1 << 1,
  409. MLX4_EQ_PORT_INFO_LID_CHANGE_MASK = 1 << 2,
  410. MLX4_EQ_PORT_INFO_CLIENT_REREG_MASK = 1 << 3,
  411. MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK = 1 << 4,
  412. };
  413. union sl2vl_tbl_to_u64 {
  414. u8 sl8[8];
  415. u64 sl64;
  416. };
  417. enum {
  418. MLX4_DEVICE_STATE_UP = 1 << 0,
  419. MLX4_DEVICE_STATE_INTERNAL_ERROR = 1 << 1,
  420. };
  421. enum {
  422. MLX4_INTERFACE_STATE_UP = 1 << 0,
  423. MLX4_INTERFACE_STATE_DELETION = 1 << 1,
  424. MLX4_INTERFACE_STATE_NOWAIT = 1 << 2,
  425. };
  426. #define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \
  427. MLX4_EQ_PORT_INFO_MSTR_SM_LID_CHANGE_MASK)
  428. enum mlx4_module_id {
  429. MLX4_MODULE_ID_SFP = 0x3,
  430. MLX4_MODULE_ID_QSFP = 0xC,
  431. MLX4_MODULE_ID_QSFP_PLUS = 0xD,
  432. MLX4_MODULE_ID_QSFP28 = 0x11,
  433. };
  434. enum { /* rl */
  435. MLX4_QP_RATE_LIMIT_NONE = 0,
  436. MLX4_QP_RATE_LIMIT_KBS = 1,
  437. MLX4_QP_RATE_LIMIT_MBS = 2,
  438. MLX4_QP_RATE_LIMIT_GBS = 3
  439. };
  440. struct mlx4_rate_limit_caps {
  441. u16 num_rates; /* Number of different rates */
  442. u8 min_unit;
  443. u16 min_val;
  444. u8 max_unit;
  445. u16 max_val;
  446. };
  447. static inline u64 mlx4_fw_ver(u64 major, u64 minor, u64 subminor)
  448. {
  449. return (major << 32) | (minor << 16) | subminor;
  450. }
  451. struct mlx4_phys_caps {
  452. u32 gid_phys_table_len[MLX4_MAX_PORTS + 1];
  453. u32 pkey_phys_table_len[MLX4_MAX_PORTS + 1];
  454. u32 num_phys_eqs;
  455. u32 base_sqpn;
  456. u32 base_proxy_sqpn;
  457. u32 base_tunnel_sqpn;
  458. };
  459. struct mlx4_spec_qps {
  460. u32 qp0_qkey;
  461. u32 qp0_proxy;
  462. u32 qp0_tunnel;
  463. u32 qp1_proxy;
  464. u32 qp1_tunnel;
  465. };
  466. struct mlx4_caps {
  467. u64 fw_ver;
  468. u32 function;
  469. int num_ports;
  470. int vl_cap[MLX4_MAX_PORTS + 1];
  471. int ib_mtu_cap[MLX4_MAX_PORTS + 1];
  472. __be32 ib_port_def_cap[MLX4_MAX_PORTS + 1];
  473. u64 def_mac[MLX4_MAX_PORTS + 1];
  474. int eth_mtu_cap[MLX4_MAX_PORTS + 1];
  475. int gid_table_len[MLX4_MAX_PORTS + 1];
  476. int pkey_table_len[MLX4_MAX_PORTS + 1];
  477. int trans_type[MLX4_MAX_PORTS + 1];
  478. int vendor_oui[MLX4_MAX_PORTS + 1];
  479. int wavelength[MLX4_MAX_PORTS + 1];
  480. u64 trans_code[MLX4_MAX_PORTS + 1];
  481. int local_ca_ack_delay;
  482. int num_uars;
  483. u32 uar_page_size;
  484. int bf_reg_size;
  485. int bf_regs_per_page;
  486. int max_sq_sg;
  487. int max_rq_sg;
  488. int num_qps;
  489. int max_wqes;
  490. int max_sq_desc_sz;
  491. int max_rq_desc_sz;
  492. int max_qp_init_rdma;
  493. int max_qp_dest_rdma;
  494. int max_tc_eth;
  495. struct mlx4_spec_qps *spec_qps;
  496. int num_srqs;
  497. int max_srq_wqes;
  498. int max_srq_sge;
  499. int reserved_srqs;
  500. int num_cqs;
  501. int max_cqes;
  502. int reserved_cqs;
  503. int num_sys_eqs;
  504. int num_eqs;
  505. int reserved_eqs;
  506. int num_comp_vectors;
  507. int num_mpts;
  508. int num_mtts;
  509. int fmr_reserved_mtts;
  510. int reserved_mtts;
  511. int reserved_mrws;
  512. int reserved_uars;
  513. int num_mgms;
  514. int num_amgms;
  515. int reserved_mcgs;
  516. int num_qp_per_mgm;
  517. int steering_mode;
  518. int dmfs_high_steer_mode;
  519. int fs_log_max_ucast_qp_range_size;
  520. int num_pds;
  521. int reserved_pds;
  522. int max_xrcds;
  523. int reserved_xrcds;
  524. int mtt_entry_sz;
  525. u32 max_msg_sz;
  526. u32 page_size_cap;
  527. u64 flags;
  528. u64 flags2;
  529. u32 bmme_flags;
  530. u32 reserved_lkey;
  531. u16 stat_rate_support;
  532. u8 port_width_cap[MLX4_MAX_PORTS + 1];
  533. int max_gso_sz;
  534. int max_rss_tbl_sz;
  535. int reserved_qps_cnt[MLX4_NUM_QP_REGION];
  536. int reserved_qps;
  537. int reserved_qps_base[MLX4_NUM_QP_REGION];
  538. int log_num_macs;
  539. int log_num_vlans;
  540. enum mlx4_port_type port_type[MLX4_MAX_PORTS + 1];
  541. u8 supported_type[MLX4_MAX_PORTS + 1];
  542. u8 suggested_type[MLX4_MAX_PORTS + 1];
  543. u8 default_sense[MLX4_MAX_PORTS + 1];
  544. u32 port_mask[MLX4_MAX_PORTS + 1];
  545. enum mlx4_port_type possible_type[MLX4_MAX_PORTS + 1];
  546. u32 max_counters;
  547. u8 port_ib_mtu[MLX4_MAX_PORTS + 1];
  548. u16 sqp_demux;
  549. u32 eqe_size;
  550. u32 cqe_size;
  551. u8 eqe_factor;
  552. u32 userspace_caps; /* userspace must be aware of these */
  553. u32 function_caps; /* VFs must be aware of these */
  554. u16 hca_core_clock;
  555. u64 phys_port_id[MLX4_MAX_PORTS + 1];
  556. int tunnel_offload_mode;
  557. u8 rx_checksum_flags_port[MLX4_MAX_PORTS + 1];
  558. u8 phv_bit[MLX4_MAX_PORTS + 1];
  559. u8 alloc_res_qp_mask;
  560. u32 dmfs_high_rate_qpn_base;
  561. u32 dmfs_high_rate_qpn_range;
  562. u32 vf_caps;
  563. bool wol_port[MLX4_MAX_PORTS + 1];
  564. struct mlx4_rate_limit_caps rl_caps;
  565. u32 health_buffer_addrs;
  566. bool map_clock_to_user;
  567. };
  568. struct mlx4_buf_list {
  569. void *buf;
  570. dma_addr_t map;
  571. };
  572. struct mlx4_buf {
  573. struct mlx4_buf_list direct;
  574. struct mlx4_buf_list *page_list;
  575. int nbufs;
  576. int npages;
  577. int page_shift;
  578. };
  579. struct mlx4_mtt {
  580. u32 offset;
  581. int order;
  582. int page_shift;
  583. };
  584. enum {
  585. MLX4_DB_PER_PAGE = PAGE_SIZE / 4
  586. };
  587. struct mlx4_db_pgdir {
  588. struct list_head list;
  589. DECLARE_BITMAP(order0, MLX4_DB_PER_PAGE);
  590. DECLARE_BITMAP(order1, MLX4_DB_PER_PAGE / 2);
  591. unsigned long *bits[2];
  592. __be32 *db_page;
  593. dma_addr_t db_dma;
  594. };
  595. struct mlx4_ib_user_db_page;
  596. struct mlx4_db {
  597. __be32 *db;
  598. union {
  599. struct mlx4_db_pgdir *pgdir;
  600. struct mlx4_ib_user_db_page *user_page;
  601. } u;
  602. dma_addr_t dma;
  603. int index;
  604. int order;
  605. };
  606. struct mlx4_hwq_resources {
  607. struct mlx4_db db;
  608. struct mlx4_mtt mtt;
  609. struct mlx4_buf buf;
  610. };
  611. struct mlx4_mr {
  612. struct mlx4_mtt mtt;
  613. u64 iova;
  614. u64 size;
  615. u32 key;
  616. u32 pd;
  617. u32 access;
  618. int enabled;
  619. };
  620. enum mlx4_mw_type {
  621. MLX4_MW_TYPE_1 = 1,
  622. MLX4_MW_TYPE_2 = 2,
  623. };
  624. struct mlx4_mw {
  625. u32 key;
  626. u32 pd;
  627. enum mlx4_mw_type type;
  628. int enabled;
  629. };
  630. struct mlx4_uar {
  631. unsigned long pfn;
  632. int index;
  633. struct list_head bf_list;
  634. unsigned free_bf_bmap;
  635. void __iomem *map;
  636. void __iomem *bf_map;
  637. };
  638. struct mlx4_bf {
  639. unsigned int offset;
  640. int buf_size;
  641. struct mlx4_uar *uar;
  642. void __iomem *reg;
  643. };
  644. struct mlx4_cq {
  645. void (*comp) (struct mlx4_cq *);
  646. void (*event) (struct mlx4_cq *, enum mlx4_event);
  647. struct mlx4_uar *uar;
  648. u32 cons_index;
  649. u16 irq;
  650. __be32 *set_ci_db;
  651. __be32 *arm_db;
  652. int arm_sn;
  653. int cqn;
  654. unsigned vector;
  655. refcount_t refcount;
  656. struct completion free;
  657. struct {
  658. struct list_head list;
  659. void (*comp)(struct mlx4_cq *);
  660. void *priv;
  661. } tasklet_ctx;
  662. int reset_notify_added;
  663. struct list_head reset_notify;
  664. u8 usage;
  665. };
  666. struct mlx4_qp {
  667. void (*event) (struct mlx4_qp *, enum mlx4_event);
  668. int qpn;
  669. refcount_t refcount;
  670. struct completion free;
  671. u8 usage;
  672. };
  673. struct mlx4_srq {
  674. void (*event) (struct mlx4_srq *, enum mlx4_event);
  675. int srqn;
  676. int max;
  677. int max_gs;
  678. int wqe_shift;
  679. refcount_t refcount;
  680. struct completion free;
  681. };
  682. struct mlx4_av {
  683. __be32 port_pd;
  684. u8 reserved1;
  685. u8 g_slid;
  686. __be16 dlid;
  687. u8 reserved2;
  688. u8 gid_index;
  689. u8 stat_rate;
  690. u8 hop_limit;
  691. __be32 sl_tclass_flowlabel;
  692. u8 dgid[16];
  693. };
  694. struct mlx4_eth_av {
  695. __be32 port_pd;
  696. u8 reserved1;
  697. u8 smac_idx;
  698. u16 reserved2;
  699. u8 reserved3;
  700. u8 gid_index;
  701. u8 stat_rate;
  702. u8 hop_limit;
  703. __be32 sl_tclass_flowlabel;
  704. u8 dgid[16];
  705. u8 s_mac[6];
  706. u8 reserved4[2];
  707. __be16 vlan;
  708. u8 mac[ETH_ALEN];
  709. };
  710. union mlx4_ext_av {
  711. struct mlx4_av ib;
  712. struct mlx4_eth_av eth;
  713. };
  714. /* Counters should be saturate once they reach their maximum value */
  715. #define ASSIGN_32BIT_COUNTER(counter, value) do { \
  716. if ((value) > U32_MAX) \
  717. counter = cpu_to_be32(U32_MAX); \
  718. else \
  719. counter = cpu_to_be32(value); \
  720. } while (0)
  721. struct mlx4_counter {
  722. u8 reserved1[3];
  723. u8 counter_mode;
  724. __be32 num_ifc;
  725. u32 reserved2[2];
  726. __be64 rx_frames;
  727. __be64 rx_bytes;
  728. __be64 tx_frames;
  729. __be64 tx_bytes;
  730. };
  731. struct mlx4_quotas {
  732. int qp;
  733. int cq;
  734. int srq;
  735. int mpt;
  736. int mtt;
  737. int counter;
  738. int xrcd;
  739. };
  740. struct mlx4_vf_dev {
  741. u8 min_port;
  742. u8 n_ports;
  743. };
  744. struct mlx4_fw_crdump {
  745. bool snapshot_enable;
  746. struct devlink_region *region_crspace;
  747. struct devlink_region *region_fw_health;
  748. };
  749. enum mlx4_pci_status {
  750. MLX4_PCI_STATUS_DISABLED,
  751. MLX4_PCI_STATUS_ENABLED,
  752. };
  753. struct mlx4_dev_persistent {
  754. struct pci_dev *pdev;
  755. struct mlx4_dev *dev;
  756. int nvfs[MLX4_MAX_PORTS + 1];
  757. int num_vfs;
  758. enum mlx4_port_type curr_port_type[MLX4_MAX_PORTS + 1];
  759. enum mlx4_port_type curr_port_poss_type[MLX4_MAX_PORTS + 1];
  760. struct work_struct catas_work;
  761. struct workqueue_struct *catas_wq;
  762. struct mutex device_state_mutex; /* protect HW state */
  763. u8 state;
  764. struct mutex interface_state_mutex; /* protect SW state */
  765. u8 interface_state;
  766. struct mutex pci_status_mutex; /* sync pci state */
  767. enum mlx4_pci_status pci_status;
  768. struct mlx4_fw_crdump crdump;
  769. };
  770. struct mlx4_dev {
  771. struct mlx4_dev_persistent *persist;
  772. unsigned long flags;
  773. unsigned long num_slaves;
  774. struct mlx4_caps caps;
  775. struct mlx4_phys_caps phys_caps;
  776. struct mlx4_quotas quotas;
  777. struct radix_tree_root qp_table_tree;
  778. u8 rev_id;
  779. u8 port_random_macs;
  780. char board_id[MLX4_BOARD_ID_LEN];
  781. int numa_node;
  782. int oper_log_mgm_entry_size;
  783. u64 regid_promisc_array[MLX4_MAX_PORTS + 1];
  784. u64 regid_allmulti_array[MLX4_MAX_PORTS + 1];
  785. struct mlx4_vf_dev *dev_vfs;
  786. u8 uar_page_shift;
  787. };
  788. struct mlx4_clock_params {
  789. u64 offset;
  790. u8 bar;
  791. u8 size;
  792. };
  793. struct mlx4_eqe {
  794. u8 reserved1;
  795. u8 type;
  796. u8 reserved2;
  797. u8 subtype;
  798. union {
  799. u32 raw[6];
  800. struct {
  801. __be32 cqn;
  802. } __packed comp;
  803. struct {
  804. u16 reserved1;
  805. __be16 token;
  806. u32 reserved2;
  807. u8 reserved3[3];
  808. u8 status;
  809. __be64 out_param;
  810. } __packed cmd;
  811. struct {
  812. __be32 qpn;
  813. } __packed qp;
  814. struct {
  815. __be32 srqn;
  816. } __packed srq;
  817. struct {
  818. __be32 cqn;
  819. u32 reserved1;
  820. u8 reserved2[3];
  821. u8 syndrome;
  822. } __packed cq_err;
  823. struct {
  824. u32 reserved1[2];
  825. __be32 port;
  826. } __packed port_change;
  827. struct {
  828. #define COMM_CHANNEL_BIT_ARRAY_SIZE 4
  829. u32 reserved;
  830. u32 bit_vec[COMM_CHANNEL_BIT_ARRAY_SIZE];
  831. } __packed comm_channel_arm;
  832. struct {
  833. u8 port;
  834. u8 reserved[3];
  835. __be64 mac;
  836. } __packed mac_update;
  837. struct {
  838. __be32 slave_id;
  839. } __packed flr_event;
  840. struct {
  841. __be16 current_temperature;
  842. __be16 warning_threshold;
  843. } __packed warming;
  844. struct {
  845. u8 reserved[3];
  846. u8 port;
  847. union {
  848. struct {
  849. __be16 mstr_sm_lid;
  850. __be16 port_lid;
  851. __be32 changed_attr;
  852. u8 reserved[3];
  853. u8 mstr_sm_sl;
  854. __be64 gid_prefix;
  855. } __packed port_info;
  856. struct {
  857. __be32 block_ptr;
  858. __be32 tbl_entries_mask;
  859. } __packed tbl_change_info;
  860. struct {
  861. u8 sl2vl_table[8];
  862. } __packed sl2vl_tbl_change_info;
  863. } params;
  864. } __packed port_mgmt_change;
  865. struct {
  866. u8 reserved[3];
  867. u8 port;
  868. u32 reserved1[5];
  869. } __packed bad_cable;
  870. } event;
  871. u8 slave_id;
  872. u8 reserved3[2];
  873. u8 owner;
  874. } __packed;
  875. struct mlx4_init_port_param {
  876. int set_guid0;
  877. int set_node_guid;
  878. int set_si_guid;
  879. u16 mtu;
  880. int port_width_cap;
  881. u16 vl_cap;
  882. u16 max_gid;
  883. u16 max_pkey;
  884. u64 guid0;
  885. u64 node_guid;
  886. u64 si_guid;
  887. };
  888. #define MAD_IFC_DATA_SZ 192
  889. /* MAD IFC Mailbox */
  890. struct mlx4_mad_ifc {
  891. u8 base_version;
  892. u8 mgmt_class;
  893. u8 class_version;
  894. u8 method;
  895. __be16 status;
  896. __be16 class_specific;
  897. __be64 tid;
  898. __be16 attr_id;
  899. __be16 resv;
  900. __be32 attr_mod;
  901. __be64 mkey;
  902. __be16 dr_slid;
  903. __be16 dr_dlid;
  904. u8 reserved[28];
  905. u8 data[MAD_IFC_DATA_SZ];
  906. } __packed;
  907. #define mlx4_foreach_port(port, dev, type) \
  908. for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++) \
  909. if ((type) == (dev)->caps.port_mask[(port)])
  910. #define mlx4_foreach_ib_transport_port(port, dev) \
  911. for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++) \
  912. if (((dev)->caps.port_mask[port] == MLX4_PORT_TYPE_IB) || \
  913. ((dev)->caps.port_mask[port] == MLX4_PORT_TYPE_ETH))
  914. #define MLX4_INVALID_SLAVE_ID 0xFF
  915. #define MLX4_SINK_COUNTER_INDEX(dev) (dev->caps.max_counters - 1)
  916. void handle_port_mgmt_change_event(struct work_struct *work);
  917. static inline int mlx4_master_func_num(struct mlx4_dev *dev)
  918. {
  919. return dev->caps.function;
  920. }
  921. static inline int mlx4_is_master(struct mlx4_dev *dev)
  922. {
  923. return dev->flags & MLX4_FLAG_MASTER;
  924. }
  925. static inline int mlx4_num_reserved_sqps(struct mlx4_dev *dev)
  926. {
  927. return dev->phys_caps.base_sqpn + 8 +
  928. 16 * MLX4_MFUNC_MAX * !!mlx4_is_master(dev);
  929. }
  930. static inline int mlx4_is_qp_reserved(struct mlx4_dev *dev, u32 qpn)
  931. {
  932. return (qpn < dev->phys_caps.base_sqpn + 8 +
  933. 16 * MLX4_MFUNC_MAX * !!mlx4_is_master(dev) &&
  934. qpn >= dev->phys_caps.base_sqpn) ||
  935. (qpn < dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW]);
  936. }
  937. static inline int mlx4_is_guest_proxy(struct mlx4_dev *dev, int slave, u32 qpn)
  938. {
  939. int guest_proxy_base = dev->phys_caps.base_proxy_sqpn + slave * 8;
  940. if (qpn >= guest_proxy_base && qpn < guest_proxy_base + 8)
  941. return 1;
  942. return 0;
  943. }
  944. static inline int mlx4_is_mfunc(struct mlx4_dev *dev)
  945. {
  946. return dev->flags & (MLX4_FLAG_SLAVE | MLX4_FLAG_MASTER);
  947. }
  948. static inline int mlx4_is_slave(struct mlx4_dev *dev)
  949. {
  950. return dev->flags & MLX4_FLAG_SLAVE;
  951. }
  952. static inline int mlx4_is_eth(struct mlx4_dev *dev, int port)
  953. {
  954. return dev->caps.port_type[port] == MLX4_PORT_TYPE_IB ? 0 : 1;
  955. }
  956. int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct,
  957. struct mlx4_buf *buf);
  958. void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf);
  959. static inline void *mlx4_buf_offset(struct mlx4_buf *buf, int offset)
  960. {
  961. if (buf->nbufs == 1)
  962. return buf->direct.buf + offset;
  963. else
  964. return buf->page_list[offset >> PAGE_SHIFT].buf +
  965. (offset & (PAGE_SIZE - 1));
  966. }
  967. int mlx4_pd_alloc(struct mlx4_dev *dev, u32 *pdn);
  968. void mlx4_pd_free(struct mlx4_dev *dev, u32 pdn);
  969. int mlx4_xrcd_alloc(struct mlx4_dev *dev, u32 *xrcdn);
  970. void mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn);
  971. int mlx4_uar_alloc(struct mlx4_dev *dev, struct mlx4_uar *uar);
  972. void mlx4_uar_free(struct mlx4_dev *dev, struct mlx4_uar *uar);
  973. int mlx4_bf_alloc(struct mlx4_dev *dev, struct mlx4_bf *bf, int node);
  974. void mlx4_bf_free(struct mlx4_dev *dev, struct mlx4_bf *bf);
  975. int mlx4_mtt_init(struct mlx4_dev *dev, int npages, int page_shift,
  976. struct mlx4_mtt *mtt);
  977. void mlx4_mtt_cleanup(struct mlx4_dev *dev, struct mlx4_mtt *mtt);
  978. u64 mlx4_mtt_addr(struct mlx4_dev *dev, struct mlx4_mtt *mtt);
  979. int mlx4_mr_alloc(struct mlx4_dev *dev, u32 pd, u64 iova, u64 size, u32 access,
  980. int npages, int page_shift, struct mlx4_mr *mr);
  981. int mlx4_mr_free(struct mlx4_dev *dev, struct mlx4_mr *mr);
  982. int mlx4_mr_enable(struct mlx4_dev *dev, struct mlx4_mr *mr);
  983. int mlx4_mw_alloc(struct mlx4_dev *dev, u32 pd, enum mlx4_mw_type type,
  984. struct mlx4_mw *mw);
  985. void mlx4_mw_free(struct mlx4_dev *dev, struct mlx4_mw *mw);
  986. int mlx4_mw_enable(struct mlx4_dev *dev, struct mlx4_mw *mw);
  987. int mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
  988. int start_index, int npages, u64 *page_list);
  989. int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
  990. struct mlx4_buf *buf);
  991. int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order);
  992. void mlx4_db_free(struct mlx4_dev *dev, struct mlx4_db *db);
  993. int mlx4_alloc_hwq_res(struct mlx4_dev *dev, struct mlx4_hwq_resources *wqres,
  994. int size);
  995. void mlx4_free_hwq_res(struct mlx4_dev *mdev, struct mlx4_hwq_resources *wqres,
  996. int size);
  997. int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt,
  998. struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq,
  999. unsigned int vector, int collapsed, int timestamp_en,
  1000. void *buf_addr, bool user_cq);
  1001. void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq);
  1002. int mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align,
  1003. int *base, u8 flags, u8 usage);
  1004. void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt);
  1005. int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp);
  1006. void mlx4_qp_free(struct mlx4_dev *dev, struct mlx4_qp *qp);
  1007. int mlx4_srq_alloc(struct mlx4_dev *dev, u32 pdn, u32 cqn, u16 xrcdn,
  1008. struct mlx4_mtt *mtt, u64 db_rec, struct mlx4_srq *srq);
  1009. void mlx4_srq_free(struct mlx4_dev *dev, struct mlx4_srq *srq);
  1010. int mlx4_srq_arm(struct mlx4_dev *dev, struct mlx4_srq *srq, int limit_watermark);
  1011. int mlx4_srq_query(struct mlx4_dev *dev, struct mlx4_srq *srq, int *limit_watermark);
  1012. int mlx4_INIT_PORT(struct mlx4_dev *dev, int port);
  1013. int mlx4_CLOSE_PORT(struct mlx4_dev *dev, int port);
  1014. int mlx4_unicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
  1015. int block_mcast_loopback, enum mlx4_protocol prot);
  1016. int mlx4_unicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
  1017. enum mlx4_protocol prot);
  1018. int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
  1019. u8 port, int block_mcast_loopback,
  1020. enum mlx4_protocol protocol, u64 *reg_id);
  1021. int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
  1022. enum mlx4_protocol protocol, u64 reg_id);
  1023. enum {
  1024. MLX4_DOMAIN_UVERBS = 0x1000,
  1025. MLX4_DOMAIN_ETHTOOL = 0x2000,
  1026. MLX4_DOMAIN_RFS = 0x3000,
  1027. MLX4_DOMAIN_NIC = 0x5000,
  1028. };
  1029. enum mlx4_net_trans_rule_id {
  1030. MLX4_NET_TRANS_RULE_ID_ETH = 0,
  1031. MLX4_NET_TRANS_RULE_ID_IB,
  1032. MLX4_NET_TRANS_RULE_ID_IPV6,
  1033. MLX4_NET_TRANS_RULE_ID_IPV4,
  1034. MLX4_NET_TRANS_RULE_ID_TCP,
  1035. MLX4_NET_TRANS_RULE_ID_UDP,
  1036. MLX4_NET_TRANS_RULE_ID_VXLAN,
  1037. MLX4_NET_TRANS_RULE_NUM, /* should be last */
  1038. };
  1039. extern const u16 __sw_id_hw[];
  1040. static inline int map_hw_to_sw_id(u16 header_id)
  1041. {
  1042. int i;
  1043. for (i = 0; i < MLX4_NET_TRANS_RULE_NUM; i++) {
  1044. if (header_id == __sw_id_hw[i])
  1045. return i;
  1046. }
  1047. return -EINVAL;
  1048. }
  1049. enum mlx4_net_trans_promisc_mode {
  1050. MLX4_FS_REGULAR = 1,
  1051. MLX4_FS_ALL_DEFAULT,
  1052. MLX4_FS_MC_DEFAULT,
  1053. MLX4_FS_MIRROR_RX_PORT,
  1054. MLX4_FS_MIRROR_SX_PORT,
  1055. MLX4_FS_UC_SNIFFER,
  1056. MLX4_FS_MC_SNIFFER,
  1057. MLX4_FS_MODE_NUM, /* should be last */
  1058. };
  1059. struct mlx4_spec_eth {
  1060. u8 dst_mac[ETH_ALEN];
  1061. u8 dst_mac_msk[ETH_ALEN];
  1062. u8 src_mac[ETH_ALEN];
  1063. u8 src_mac_msk[ETH_ALEN];
  1064. u8 ether_type_enable;
  1065. __be16 ether_type;
  1066. __be16 vlan_id_msk;
  1067. __be16 vlan_id;
  1068. };
  1069. struct mlx4_spec_tcp_udp {
  1070. __be16 dst_port;
  1071. __be16 dst_port_msk;
  1072. __be16 src_port;
  1073. __be16 src_port_msk;
  1074. };
  1075. struct mlx4_spec_ipv4 {
  1076. __be32 dst_ip;
  1077. __be32 dst_ip_msk;
  1078. __be32 src_ip;
  1079. __be32 src_ip_msk;
  1080. };
  1081. struct mlx4_spec_ib {
  1082. __be32 l3_qpn;
  1083. __be32 qpn_msk;
  1084. u8 dst_gid[16];
  1085. u8 dst_gid_msk[16];
  1086. };
  1087. struct mlx4_spec_vxlan {
  1088. __be32 vni;
  1089. __be32 vni_mask;
  1090. };
  1091. struct mlx4_spec_list {
  1092. struct list_head list;
  1093. enum mlx4_net_trans_rule_id id;
  1094. union {
  1095. struct mlx4_spec_eth eth;
  1096. struct mlx4_spec_ib ib;
  1097. struct mlx4_spec_ipv4 ipv4;
  1098. struct mlx4_spec_tcp_udp tcp_udp;
  1099. struct mlx4_spec_vxlan vxlan;
  1100. };
  1101. };
  1102. enum mlx4_net_trans_hw_rule_queue {
  1103. MLX4_NET_TRANS_Q_FIFO,
  1104. MLX4_NET_TRANS_Q_LIFO,
  1105. };
  1106. struct mlx4_net_trans_rule {
  1107. struct list_head list;
  1108. enum mlx4_net_trans_hw_rule_queue queue_mode;
  1109. bool exclusive;
  1110. bool allow_loopback;
  1111. enum mlx4_net_trans_promisc_mode promisc_mode;
  1112. u8 port;
  1113. u16 priority;
  1114. u32 qpn;
  1115. };
  1116. struct mlx4_net_trans_rule_hw_ctrl {
  1117. __be16 prio;
  1118. u8 type;
  1119. u8 flags;
  1120. u8 rsvd1;
  1121. u8 funcid;
  1122. u8 vep;
  1123. u8 port;
  1124. __be32 qpn;
  1125. __be32 rsvd2;
  1126. };
  1127. struct mlx4_net_trans_rule_hw_ib {
  1128. u8 size;
  1129. u8 rsvd1;
  1130. __be16 id;
  1131. u32 rsvd2;
  1132. __be32 l3_qpn;
  1133. __be32 qpn_mask;
  1134. u8 dst_gid[16];
  1135. u8 dst_gid_msk[16];
  1136. } __packed;
  1137. struct mlx4_net_trans_rule_hw_eth {
  1138. u8 size;
  1139. u8 rsvd;
  1140. __be16 id;
  1141. u8 rsvd1[6];
  1142. u8 dst_mac[6];
  1143. u16 rsvd2;
  1144. u8 dst_mac_msk[6];
  1145. u16 rsvd3;
  1146. u8 src_mac[6];
  1147. u16 rsvd4;
  1148. u8 src_mac_msk[6];
  1149. u8 rsvd5;
  1150. u8 ether_type_enable;
  1151. __be16 ether_type;
  1152. __be16 vlan_tag_msk;
  1153. __be16 vlan_tag;
  1154. } __packed;
  1155. struct mlx4_net_trans_rule_hw_tcp_udp {
  1156. u8 size;
  1157. u8 rsvd;
  1158. __be16 id;
  1159. __be16 rsvd1[3];
  1160. __be16 dst_port;
  1161. __be16 rsvd2;
  1162. __be16 dst_port_msk;
  1163. __be16 rsvd3;
  1164. __be16 src_port;
  1165. __be16 rsvd4;
  1166. __be16 src_port_msk;
  1167. } __packed;
  1168. struct mlx4_net_trans_rule_hw_ipv4 {
  1169. u8 size;
  1170. u8 rsvd;
  1171. __be16 id;
  1172. __be32 rsvd1;
  1173. __be32 dst_ip;
  1174. __be32 dst_ip_msk;
  1175. __be32 src_ip;
  1176. __be32 src_ip_msk;
  1177. } __packed;
  1178. struct mlx4_net_trans_rule_hw_vxlan {
  1179. u8 size;
  1180. u8 rsvd;
  1181. __be16 id;
  1182. __be32 rsvd1;
  1183. __be32 vni;
  1184. __be32 vni_mask;
  1185. } __packed;
  1186. struct _rule_hw {
  1187. union {
  1188. struct {
  1189. u8 size;
  1190. u8 rsvd;
  1191. __be16 id;
  1192. };
  1193. struct mlx4_net_trans_rule_hw_eth eth;
  1194. struct mlx4_net_trans_rule_hw_ib ib;
  1195. struct mlx4_net_trans_rule_hw_ipv4 ipv4;
  1196. struct mlx4_net_trans_rule_hw_tcp_udp tcp_udp;
  1197. struct mlx4_net_trans_rule_hw_vxlan vxlan;
  1198. };
  1199. };
  1200. enum {
  1201. VXLAN_STEER_BY_OUTER_MAC = 1 << 0,
  1202. VXLAN_STEER_BY_OUTER_VLAN = 1 << 1,
  1203. VXLAN_STEER_BY_VSID_VNI = 1 << 2,
  1204. VXLAN_STEER_BY_INNER_MAC = 1 << 3,
  1205. VXLAN_STEER_BY_INNER_VLAN = 1 << 4,
  1206. };
  1207. enum {
  1208. MLX4_OP_MOD_QUERY_TRANSPORT_CI_ERRORS = 0x2,
  1209. };
  1210. int mlx4_flow_steer_promisc_add(struct mlx4_dev *dev, u8 port, u32 qpn,
  1211. enum mlx4_net_trans_promisc_mode mode);
  1212. int mlx4_flow_steer_promisc_remove(struct mlx4_dev *dev, u8 port,
  1213. enum mlx4_net_trans_promisc_mode mode);
  1214. int mlx4_multicast_promisc_add(struct mlx4_dev *dev, u32 qpn, u8 port);
  1215. int mlx4_multicast_promisc_remove(struct mlx4_dev *dev, u32 qpn, u8 port);
  1216. int mlx4_unicast_promisc_add(struct mlx4_dev *dev, u32 qpn, u8 port);
  1217. int mlx4_unicast_promisc_remove(struct mlx4_dev *dev, u32 qpn, u8 port);
  1218. int mlx4_SET_MCAST_FLTR(struct mlx4_dev *dev, u8 port, u64 mac, u64 clear, u8 mode);
  1219. int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac);
  1220. void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac);
  1221. int mlx4_get_base_qpn(struct mlx4_dev *dev, u8 port);
  1222. int __mlx4_replace_mac(struct mlx4_dev *dev, u8 port, int qpn, u64 new_mac);
  1223. int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu,
  1224. u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx);
  1225. int mlx4_SET_PORT_user_mac(struct mlx4_dev *dev, u8 port, u8 *user_mac);
  1226. int mlx4_SET_PORT_user_mtu(struct mlx4_dev *dev, u8 port, u16 user_mtu);
  1227. int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn,
  1228. u8 promisc);
  1229. int mlx4_SET_PORT_BEACON(struct mlx4_dev *dev, u8 port, u16 time);
  1230. int mlx4_SET_PORT_fcs_check(struct mlx4_dev *dev, u8 port,
  1231. u8 ignore_fcs_value);
  1232. int mlx4_SET_PORT_VXLAN(struct mlx4_dev *dev, u8 port, u8 steering, int enable);
  1233. int set_phv_bit(struct mlx4_dev *dev, u8 port, int new_val);
  1234. int get_phv_bit(struct mlx4_dev *dev, u8 port, int *phv);
  1235. int mlx4_get_is_vlan_offload_disabled(struct mlx4_dev *dev, u8 port,
  1236. bool *vlan_offload_disabled);
  1237. void mlx4_handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
  1238. struct _rule_hw *eth_header);
  1239. int mlx4_find_cached_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *idx);
  1240. int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx);
  1241. int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);
  1242. void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, u16 vlan);
  1243. int mlx4_SYNC_TPT(struct mlx4_dev *dev);
  1244. int mlx4_test_interrupt(struct mlx4_dev *dev, int vector);
  1245. int mlx4_test_async(struct mlx4_dev *dev);
  1246. int mlx4_query_diag_counters(struct mlx4_dev *dev, u8 op_modifier,
  1247. const u32 offset[], u32 value[],
  1248. size_t array_len, u8 port);
  1249. u32 mlx4_get_eqs_per_port(struct mlx4_dev *dev, u8 port);
  1250. bool mlx4_is_eq_vector_valid(struct mlx4_dev *dev, u8 port, int vector);
  1251. struct cpu_rmap *mlx4_get_cpu_rmap(struct mlx4_dev *dev, int port);
  1252. int mlx4_assign_eq(struct mlx4_dev *dev, u8 port, int *vector);
  1253. void mlx4_release_eq(struct mlx4_dev *dev, int vec);
  1254. int mlx4_is_eq_shared(struct mlx4_dev *dev, int vector);
  1255. int mlx4_eq_get_irq(struct mlx4_dev *dev, int vec);
  1256. int mlx4_get_phys_port_id(struct mlx4_dev *dev);
  1257. int mlx4_wol_read(struct mlx4_dev *dev, u64 *config, int port);
  1258. int mlx4_wol_write(struct mlx4_dev *dev, u64 config, int port);
  1259. int mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx, u8 usage);
  1260. void mlx4_counter_free(struct mlx4_dev *dev, u32 idx);
  1261. int mlx4_get_default_counter_index(struct mlx4_dev *dev, int port);
  1262. void mlx4_set_admin_guid(struct mlx4_dev *dev, __be64 guid, int entry,
  1263. int port);
  1264. __be64 mlx4_get_admin_guid(struct mlx4_dev *dev, int entry, int port);
  1265. void mlx4_set_random_admin_guid(struct mlx4_dev *dev, int entry, int port);
  1266. int mlx4_flow_attach(struct mlx4_dev *dev,
  1267. struct mlx4_net_trans_rule *rule, u64 *reg_id);
  1268. int mlx4_flow_detach(struct mlx4_dev *dev, u64 reg_id);
  1269. int mlx4_map_sw_to_hw_steering_mode(struct mlx4_dev *dev,
  1270. enum mlx4_net_trans_promisc_mode flow_type);
  1271. int mlx4_map_sw_to_hw_steering_id(struct mlx4_dev *dev,
  1272. enum mlx4_net_trans_rule_id id);
  1273. int mlx4_hw_rule_sz(struct mlx4_dev *dev, enum mlx4_net_trans_rule_id id);
  1274. int mlx4_tunnel_steer_add(struct mlx4_dev *dev, const unsigned char *addr,
  1275. int port, int qpn, u16 prio, u64 *reg_id);
  1276. void mlx4_sync_pkey_table(struct mlx4_dev *dev, int slave, int port,
  1277. int i, int val);
  1278. int mlx4_get_parav_qkey(struct mlx4_dev *dev, u32 qpn, u32 *qkey);
  1279. int mlx4_is_slave_active(struct mlx4_dev *dev, int slave);
  1280. int mlx4_gen_pkey_eqe(struct mlx4_dev *dev, int slave, u8 port);
  1281. int mlx4_gen_guid_change_eqe(struct mlx4_dev *dev, int slave, u8 port);
  1282. int mlx4_gen_slaves_port_mgt_ev(struct mlx4_dev *dev, u8 port, int attr);
  1283. int mlx4_gen_port_state_change_eqe(struct mlx4_dev *dev, int slave, u8 port, u8 port_subtype_change);
  1284. enum slave_port_state mlx4_get_slave_port_state(struct mlx4_dev *dev, int slave, u8 port);
  1285. int set_and_calc_slave_port_state(struct mlx4_dev *dev, int slave, u8 port, int event, enum slave_port_gen_event *gen_event);
  1286. void mlx4_put_slave_node_guid(struct mlx4_dev *dev, int slave, __be64 guid);
  1287. __be64 mlx4_get_slave_node_guid(struct mlx4_dev *dev, int slave);
  1288. int mlx4_get_slave_from_roce_gid(struct mlx4_dev *dev, int port, u8 *gid,
  1289. int *slave_id);
  1290. int mlx4_get_roce_gid_from_slave(struct mlx4_dev *dev, int port, int slave_id,
  1291. u8 *gid);
  1292. int mlx4_FLOW_STEERING_IB_UC_QP_RANGE(struct mlx4_dev *dev, u32 min_range_qpn,
  1293. u32 max_range_qpn);
  1294. u64 mlx4_read_clock(struct mlx4_dev *dev);
  1295. struct mlx4_active_ports {
  1296. DECLARE_BITMAP(ports, MLX4_MAX_PORTS);
  1297. };
  1298. /* Returns a bitmap of the physical ports which are assigned to slave */
  1299. struct mlx4_active_ports mlx4_get_active_ports(struct mlx4_dev *dev, int slave);
  1300. /* Returns the physical port that represents the virtual port of the slave, */
  1301. /* or a value < 0 in case of an error. If a slave has 2 ports, the identity */
  1302. /* mapping is returned. */
  1303. int mlx4_slave_convert_port(struct mlx4_dev *dev, int slave, int port);
  1304. struct mlx4_slaves_pport {
  1305. DECLARE_BITMAP(slaves, MLX4_MFUNC_MAX);
  1306. };
  1307. /* Returns a bitmap of all slaves that are assigned to port. */
  1308. struct mlx4_slaves_pport mlx4_phys_to_slaves_pport(struct mlx4_dev *dev,
  1309. int port);
  1310. /* Returns a bitmap of all slaves that are assigned exactly to all the */
  1311. /* the ports that are set in crit_ports. */
  1312. struct mlx4_slaves_pport mlx4_phys_to_slaves_pport_actv(
  1313. struct mlx4_dev *dev,
  1314. const struct mlx4_active_ports *crit_ports);
  1315. /* Returns the slave's virtual port that represents the physical port. */
  1316. int mlx4_phys_to_slave_port(struct mlx4_dev *dev, int slave, int port);
  1317. int mlx4_get_base_gid_ix(struct mlx4_dev *dev, int slave, int port);
  1318. int mlx4_config_vxlan_port(struct mlx4_dev *dev, __be16 udp_port);
  1319. int mlx4_disable_rx_port_check(struct mlx4_dev *dev, bool dis);
  1320. int mlx4_config_roce_v2_port(struct mlx4_dev *dev, u16 udp_port);
  1321. int mlx4_virt2phy_port_map(struct mlx4_dev *dev, u32 port1, u32 port2);
  1322. int mlx4_vf_smi_enabled(struct mlx4_dev *dev, int slave, int port);
  1323. int mlx4_vf_get_enable_smi_admin(struct mlx4_dev *dev, int slave, int port);
  1324. int mlx4_vf_set_enable_smi_admin(struct mlx4_dev *dev, int slave, int port,
  1325. int enable);
  1326. struct mlx4_mpt_entry;
  1327. int mlx4_mr_hw_get_mpt(struct mlx4_dev *dev, struct mlx4_mr *mmr,
  1328. struct mlx4_mpt_entry ***mpt_entry);
  1329. int mlx4_mr_hw_write_mpt(struct mlx4_dev *dev, struct mlx4_mr *mmr,
  1330. struct mlx4_mpt_entry **mpt_entry);
  1331. int mlx4_mr_hw_change_pd(struct mlx4_dev *dev, struct mlx4_mpt_entry *mpt_entry,
  1332. u32 pdn);
  1333. int mlx4_mr_hw_change_access(struct mlx4_dev *dev,
  1334. struct mlx4_mpt_entry *mpt_entry,
  1335. u32 access);
  1336. void mlx4_mr_hw_put_mpt(struct mlx4_dev *dev,
  1337. struct mlx4_mpt_entry **mpt_entry);
  1338. void mlx4_mr_rereg_mem_cleanup(struct mlx4_dev *dev, struct mlx4_mr *mr);
  1339. int mlx4_mr_rereg_mem_write(struct mlx4_dev *dev, struct mlx4_mr *mr,
  1340. u64 iova, u64 size, int npages,
  1341. int page_shift, struct mlx4_mpt_entry *mpt_entry);
  1342. int mlx4_get_module_info(struct mlx4_dev *dev, u8 port,
  1343. u16 offset, u16 size, u8 *data);
  1344. int mlx4_max_tc(struct mlx4_dev *dev);
  1345. /* Returns true if running in low memory profile (kdump kernel) */
  1346. static inline bool mlx4_low_memory_profile(void)
  1347. {
  1348. return is_kdump_kernel();
  1349. }
  1350. /* ACCESS REG commands */
  1351. enum mlx4_access_reg_method {
  1352. MLX4_ACCESS_REG_QUERY = 0x1,
  1353. MLX4_ACCESS_REG_WRITE = 0x2,
  1354. };
  1355. /* ACCESS PTYS Reg command */
  1356. enum mlx4_ptys_proto {
  1357. MLX4_PTYS_IB = 1<<0,
  1358. MLX4_PTYS_EN = 1<<2,
  1359. };
  1360. enum mlx4_ptys_flags {
  1361. MLX4_PTYS_AN_DISABLE_CAP = 1 << 5,
  1362. MLX4_PTYS_AN_DISABLE_ADMIN = 1 << 6,
  1363. };
  1364. struct mlx4_ptys_reg {
  1365. u8 flags;
  1366. u8 local_port;
  1367. u8 resrvd2;
  1368. u8 proto_mask;
  1369. __be32 resrvd3[2];
  1370. __be32 eth_proto_cap;
  1371. __be16 ib_width_cap;
  1372. __be16 ib_speed_cap;
  1373. __be32 resrvd4;
  1374. __be32 eth_proto_admin;
  1375. __be16 ib_width_admin;
  1376. __be16 ib_speed_admin;
  1377. __be32 resrvd5;
  1378. __be32 eth_proto_oper;
  1379. __be16 ib_width_oper;
  1380. __be16 ib_speed_oper;
  1381. __be32 resrvd6;
  1382. __be32 eth_proto_lp_adv;
  1383. } __packed;
  1384. int mlx4_ACCESS_PTYS_REG(struct mlx4_dev *dev,
  1385. enum mlx4_access_reg_method method,
  1386. struct mlx4_ptys_reg *ptys_reg);
  1387. int mlx4_get_internal_clock_params(struct mlx4_dev *dev,
  1388. struct mlx4_clock_params *params);
  1389. static inline int mlx4_to_hw_uar_index(struct mlx4_dev *dev, int index)
  1390. {
  1391. return (index << (PAGE_SHIFT - dev->uar_page_shift));
  1392. }
  1393. static inline int mlx4_get_num_reserved_uar(struct mlx4_dev *dev)
  1394. {
  1395. /* The first 128 UARs are used for EQ doorbells */
  1396. return (128 >> (PAGE_SHIFT - dev->uar_page_shift));
  1397. }
  1398. #endif /* MLX4_DEVICE_H */