ib_verbs.h 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263
  1. /*
  2. * Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved.
  3. * Copyright (c) 2004 Infinicon Corporation. All rights reserved.
  4. * Copyright (c) 2004 Intel Corporation. All rights reserved.
  5. * Copyright (c) 2004 Topspin Corporation. All rights reserved.
  6. * Copyright (c) 2004 Voltaire Corporation. All rights reserved.
  7. * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
  8. * Copyright (c) 2005, 2006, 2007 Cisco Systems. All rights reserved.
  9. *
  10. * This software is available to you under a choice of one of two
  11. * licenses. You may choose to be licensed under the terms of the GNU
  12. * General Public License (GPL) Version 2, available from the file
  13. * COPYING in the main directory of this source tree, or the
  14. * OpenIB.org BSD license below:
  15. *
  16. * Redistribution and use in source and binary forms, with or
  17. * without modification, are permitted provided that the following
  18. * conditions are met:
  19. *
  20. * - Redistributions of source code must retain the above
  21. * copyright notice, this list of conditions and the following
  22. * disclaimer.
  23. *
  24. * - Redistributions in binary form must reproduce the above
  25. * copyright notice, this list of conditions and the following
  26. * disclaimer in the documentation and/or other materials
  27. * provided with the distribution.
  28. *
  29. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  30. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  31. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  32. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  33. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  34. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  35. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  36. * SOFTWARE.
  37. */
  38. #if !defined(IB_VERBS_H)
  39. #define IB_VERBS_H
  40. #include <linux/types.h>
  41. #include <linux/device.h>
  42. #include <linux/mm.h>
  43. #include <linux/dma-mapping.h>
  44. #include <linux/kref.h>
  45. #include <linux/list.h>
  46. #include <linux/rwsem.h>
  47. #include <linux/scatterlist.h>
  48. #include <linux/workqueue.h>
  49. #include <linux/atomic.h>
  50. #include <asm/uaccess.h>
  51. extern struct workqueue_struct *ib_wq;
  52. union ib_gid {
  53. u8 raw[16];
  54. struct {
  55. __be64 subnet_prefix;
  56. __be64 interface_id;
  57. } global;
  58. };
  59. enum rdma_node_type {
  60. /* IB values map to NodeInfo:NodeType. */
  61. RDMA_NODE_IB_CA = 1,
  62. RDMA_NODE_IB_SWITCH,
  63. RDMA_NODE_IB_ROUTER,
  64. RDMA_NODE_RNIC
  65. };
  66. enum rdma_transport_type {
  67. RDMA_TRANSPORT_IB,
  68. RDMA_TRANSPORT_IWARP
  69. };
  70. enum rdma_transport_type
  71. rdma_node_get_transport(enum rdma_node_type node_type) __attribute_const__;
  72. enum rdma_link_layer {
  73. IB_LINK_LAYER_UNSPECIFIED,
  74. IB_LINK_LAYER_INFINIBAND,
  75. IB_LINK_LAYER_ETHERNET,
  76. };
  77. enum ib_device_cap_flags {
  78. IB_DEVICE_RESIZE_MAX_WR = 1,
  79. IB_DEVICE_BAD_PKEY_CNTR = (1<<1),
  80. IB_DEVICE_BAD_QKEY_CNTR = (1<<2),
  81. IB_DEVICE_RAW_MULTI = (1<<3),
  82. IB_DEVICE_AUTO_PATH_MIG = (1<<4),
  83. IB_DEVICE_CHANGE_PHY_PORT = (1<<5),
  84. IB_DEVICE_UD_AV_PORT_ENFORCE = (1<<6),
  85. IB_DEVICE_CURR_QP_STATE_MOD = (1<<7),
  86. IB_DEVICE_SHUTDOWN_PORT = (1<<8),
  87. IB_DEVICE_INIT_TYPE = (1<<9),
  88. IB_DEVICE_PORT_ACTIVE_EVENT = (1<<10),
  89. IB_DEVICE_SYS_IMAGE_GUID = (1<<11),
  90. IB_DEVICE_RC_RNR_NAK_GEN = (1<<12),
  91. IB_DEVICE_SRQ_RESIZE = (1<<13),
  92. IB_DEVICE_N_NOTIFY_CQ = (1<<14),
  93. IB_DEVICE_LOCAL_DMA_LKEY = (1<<15),
  94. IB_DEVICE_RESERVED = (1<<16), /* old SEND_W_INV */
  95. IB_DEVICE_MEM_WINDOW = (1<<17),
  96. /*
  97. * Devices should set IB_DEVICE_UD_IP_SUM if they support
  98. * insertion of UDP and TCP checksum on outgoing UD IPoIB
  99. * messages and can verify the validity of checksum for
  100. * incoming messages. Setting this flag implies that the
  101. * IPoIB driver may set NETIF_F_IP_CSUM for datagram mode.
  102. */
  103. IB_DEVICE_UD_IP_CSUM = (1<<18),
  104. IB_DEVICE_UD_TSO = (1<<19),
  105. IB_DEVICE_XRC = (1<<20),
  106. IB_DEVICE_MEM_MGT_EXTENSIONS = (1<<21),
  107. IB_DEVICE_BLOCK_MULTICAST_LOOPBACK = (1<<22),
  108. IB_DEVICE_MEM_WINDOW_TYPE_2A = (1<<23),
  109. IB_DEVICE_MEM_WINDOW_TYPE_2B = (1<<24)
  110. };
  111. enum ib_atomic_cap {
  112. IB_ATOMIC_NONE,
  113. IB_ATOMIC_HCA,
  114. IB_ATOMIC_GLOB
  115. };
  116. struct ib_device_attr {
  117. u64 fw_ver;
  118. __be64 sys_image_guid;
  119. u64 max_mr_size;
  120. u64 page_size_cap;
  121. u32 vendor_id;
  122. u32 vendor_part_id;
  123. u32 hw_ver;
  124. int max_qp;
  125. int max_qp_wr;
  126. int device_cap_flags;
  127. int max_sge;
  128. int max_sge_rd;
  129. int max_cq;
  130. int max_cqe;
  131. int max_mr;
  132. int max_pd;
  133. int max_qp_rd_atom;
  134. int max_ee_rd_atom;
  135. int max_res_rd_atom;
  136. int max_qp_init_rd_atom;
  137. int max_ee_init_rd_atom;
  138. enum ib_atomic_cap atomic_cap;
  139. enum ib_atomic_cap masked_atomic_cap;
  140. int max_ee;
  141. int max_rdd;
  142. int max_mw;
  143. int max_raw_ipv6_qp;
  144. int max_raw_ethy_qp;
  145. int max_mcast_grp;
  146. int max_mcast_qp_attach;
  147. int max_total_mcast_qp_attach;
  148. int max_ah;
  149. int max_fmr;
  150. int max_map_per_fmr;
  151. int max_srq;
  152. int max_srq_wr;
  153. int max_srq_sge;
  154. unsigned int max_fast_reg_page_list_len;
  155. u16 max_pkeys;
  156. u8 local_ca_ack_delay;
  157. };
  158. enum ib_mtu {
  159. IB_MTU_256 = 1,
  160. IB_MTU_512 = 2,
  161. IB_MTU_1024 = 3,
  162. IB_MTU_2048 = 4,
  163. IB_MTU_4096 = 5
  164. };
  165. static inline int ib_mtu_enum_to_int(enum ib_mtu mtu)
  166. {
  167. switch (mtu) {
  168. case IB_MTU_256: return 256;
  169. case IB_MTU_512: return 512;
  170. case IB_MTU_1024: return 1024;
  171. case IB_MTU_2048: return 2048;
  172. case IB_MTU_4096: return 4096;
  173. default: return -1;
  174. }
  175. }
  176. enum ib_port_state {
  177. IB_PORT_NOP = 0,
  178. IB_PORT_DOWN = 1,
  179. IB_PORT_INIT = 2,
  180. IB_PORT_ARMED = 3,
  181. IB_PORT_ACTIVE = 4,
  182. IB_PORT_ACTIVE_DEFER = 5
  183. };
  184. enum ib_port_cap_flags {
  185. IB_PORT_SM = 1 << 1,
  186. IB_PORT_NOTICE_SUP = 1 << 2,
  187. IB_PORT_TRAP_SUP = 1 << 3,
  188. IB_PORT_OPT_IPD_SUP = 1 << 4,
  189. IB_PORT_AUTO_MIGR_SUP = 1 << 5,
  190. IB_PORT_SL_MAP_SUP = 1 << 6,
  191. IB_PORT_MKEY_NVRAM = 1 << 7,
  192. IB_PORT_PKEY_NVRAM = 1 << 8,
  193. IB_PORT_LED_INFO_SUP = 1 << 9,
  194. IB_PORT_SM_DISABLED = 1 << 10,
  195. IB_PORT_SYS_IMAGE_GUID_SUP = 1 << 11,
  196. IB_PORT_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12,
  197. IB_PORT_EXTENDED_SPEEDS_SUP = 1 << 14,
  198. IB_PORT_CM_SUP = 1 << 16,
  199. IB_PORT_SNMP_TUNNEL_SUP = 1 << 17,
  200. IB_PORT_REINIT_SUP = 1 << 18,
  201. IB_PORT_DEVICE_MGMT_SUP = 1 << 19,
  202. IB_PORT_VENDOR_CLASS_SUP = 1 << 20,
  203. IB_PORT_DR_NOTICE_SUP = 1 << 21,
  204. IB_PORT_CAP_MASK_NOTICE_SUP = 1 << 22,
  205. IB_PORT_BOOT_MGMT_SUP = 1 << 23,
  206. IB_PORT_LINK_LATENCY_SUP = 1 << 24,
  207. IB_PORT_CLIENT_REG_SUP = 1 << 25
  208. };
  209. enum ib_port_width {
  210. IB_WIDTH_1X = 1,
  211. IB_WIDTH_4X = 2,
  212. IB_WIDTH_8X = 4,
  213. IB_WIDTH_12X = 8
  214. };
  215. static inline int ib_width_enum_to_int(enum ib_port_width width)
  216. {
  217. switch (width) {
  218. case IB_WIDTH_1X: return 1;
  219. case IB_WIDTH_4X: return 4;
  220. case IB_WIDTH_8X: return 8;
  221. case IB_WIDTH_12X: return 12;
  222. default: return -1;
  223. }
  224. }
  225. enum ib_port_speed {
  226. IB_SPEED_SDR = 1,
  227. IB_SPEED_DDR = 2,
  228. IB_SPEED_QDR = 4,
  229. IB_SPEED_FDR10 = 8,
  230. IB_SPEED_FDR = 16,
  231. IB_SPEED_EDR = 32
  232. };
  233. struct ib_protocol_stats {
  234. /* TBD... */
  235. };
  236. struct iw_protocol_stats {
  237. u64 ipInReceives;
  238. u64 ipInHdrErrors;
  239. u64 ipInTooBigErrors;
  240. u64 ipInNoRoutes;
  241. u64 ipInAddrErrors;
  242. u64 ipInUnknownProtos;
  243. u64 ipInTruncatedPkts;
  244. u64 ipInDiscards;
  245. u64 ipInDelivers;
  246. u64 ipOutForwDatagrams;
  247. u64 ipOutRequests;
  248. u64 ipOutDiscards;
  249. u64 ipOutNoRoutes;
  250. u64 ipReasmTimeout;
  251. u64 ipReasmReqds;
  252. u64 ipReasmOKs;
  253. u64 ipReasmFails;
  254. u64 ipFragOKs;
  255. u64 ipFragFails;
  256. u64 ipFragCreates;
  257. u64 ipInMcastPkts;
  258. u64 ipOutMcastPkts;
  259. u64 ipInBcastPkts;
  260. u64 ipOutBcastPkts;
  261. u64 tcpRtoAlgorithm;
  262. u64 tcpRtoMin;
  263. u64 tcpRtoMax;
  264. u64 tcpMaxConn;
  265. u64 tcpActiveOpens;
  266. u64 tcpPassiveOpens;
  267. u64 tcpAttemptFails;
  268. u64 tcpEstabResets;
  269. u64 tcpCurrEstab;
  270. u64 tcpInSegs;
  271. u64 tcpOutSegs;
  272. u64 tcpRetransSegs;
  273. u64 tcpInErrs;
  274. u64 tcpOutRsts;
  275. };
  276. union rdma_protocol_stats {
  277. struct ib_protocol_stats ib;
  278. struct iw_protocol_stats iw;
  279. };
  280. struct ib_port_attr {
  281. enum ib_port_state state;
  282. enum ib_mtu max_mtu;
  283. enum ib_mtu active_mtu;
  284. int gid_tbl_len;
  285. u32 port_cap_flags;
  286. u32 max_msg_sz;
  287. u32 bad_pkey_cntr;
  288. u32 qkey_viol_cntr;
  289. u16 pkey_tbl_len;
  290. u16 lid;
  291. u16 sm_lid;
  292. u8 lmc;
  293. u8 max_vl_num;
  294. u8 sm_sl;
  295. u8 subnet_timeout;
  296. u8 init_type_reply;
  297. u8 active_width;
  298. u8 active_speed;
  299. u8 phys_state;
  300. };
  301. enum ib_device_modify_flags {
  302. IB_DEVICE_MODIFY_SYS_IMAGE_GUID = 1 << 0,
  303. IB_DEVICE_MODIFY_NODE_DESC = 1 << 1
  304. };
  305. struct ib_device_modify {
  306. u64 sys_image_guid;
  307. char node_desc[64];
  308. };
  309. enum ib_port_modify_flags {
  310. IB_PORT_SHUTDOWN = 1,
  311. IB_PORT_INIT_TYPE = (1<<2),
  312. IB_PORT_RESET_QKEY_CNTR = (1<<3)
  313. };
  314. struct ib_port_modify {
  315. u32 set_port_cap_mask;
  316. u32 clr_port_cap_mask;
  317. u8 init_type;
  318. };
  319. enum ib_event_type {
  320. IB_EVENT_CQ_ERR,
  321. IB_EVENT_QP_FATAL,
  322. IB_EVENT_QP_REQ_ERR,
  323. IB_EVENT_QP_ACCESS_ERR,
  324. IB_EVENT_COMM_EST,
  325. IB_EVENT_SQ_DRAINED,
  326. IB_EVENT_PATH_MIG,
  327. IB_EVENT_PATH_MIG_ERR,
  328. IB_EVENT_DEVICE_FATAL,
  329. IB_EVENT_PORT_ACTIVE,
  330. IB_EVENT_PORT_ERR,
  331. IB_EVENT_LID_CHANGE,
  332. IB_EVENT_PKEY_CHANGE,
  333. IB_EVENT_SM_CHANGE,
  334. IB_EVENT_SRQ_ERR,
  335. IB_EVENT_SRQ_LIMIT_REACHED,
  336. IB_EVENT_QP_LAST_WQE_REACHED,
  337. IB_EVENT_CLIENT_REREGISTER,
  338. IB_EVENT_GID_CHANGE,
  339. };
  340. struct ib_event {
  341. struct ib_device *device;
  342. union {
  343. struct ib_cq *cq;
  344. struct ib_qp *qp;
  345. struct ib_srq *srq;
  346. u8 port_num;
  347. } element;
  348. enum ib_event_type event;
  349. };
  350. struct ib_event_handler {
  351. struct ib_device *device;
  352. void (*handler)(struct ib_event_handler *, struct ib_event *);
  353. struct list_head list;
  354. };
  355. #define INIT_IB_EVENT_HANDLER(_ptr, _device, _handler) \
  356. do { \
  357. (_ptr)->device = _device; \
  358. (_ptr)->handler = _handler; \
  359. INIT_LIST_HEAD(&(_ptr)->list); \
  360. } while (0)
  361. struct ib_global_route {
  362. union ib_gid dgid;
  363. u32 flow_label;
  364. u8 sgid_index;
  365. u8 hop_limit;
  366. u8 traffic_class;
  367. };
  368. struct ib_grh {
  369. __be32 version_tclass_flow;
  370. __be16 paylen;
  371. u8 next_hdr;
  372. u8 hop_limit;
  373. union ib_gid sgid;
  374. union ib_gid dgid;
  375. };
  376. enum {
  377. IB_MULTICAST_QPN = 0xffffff
  378. };
  379. #define IB_LID_PERMISSIVE cpu_to_be16(0xFFFF)
  380. enum ib_ah_flags {
  381. IB_AH_GRH = 1
  382. };
  383. enum ib_rate {
  384. IB_RATE_PORT_CURRENT = 0,
  385. IB_RATE_2_5_GBPS = 2,
  386. IB_RATE_5_GBPS = 5,
  387. IB_RATE_10_GBPS = 3,
  388. IB_RATE_20_GBPS = 6,
  389. IB_RATE_30_GBPS = 4,
  390. IB_RATE_40_GBPS = 7,
  391. IB_RATE_60_GBPS = 8,
  392. IB_RATE_80_GBPS = 9,
  393. IB_RATE_120_GBPS = 10,
  394. IB_RATE_14_GBPS = 11,
  395. IB_RATE_56_GBPS = 12,
  396. IB_RATE_112_GBPS = 13,
  397. IB_RATE_168_GBPS = 14,
  398. IB_RATE_25_GBPS = 15,
  399. IB_RATE_100_GBPS = 16,
  400. IB_RATE_200_GBPS = 17,
  401. IB_RATE_300_GBPS = 18
  402. };
  403. /**
  404. * ib_rate_to_mult - Convert the IB rate enum to a multiple of the
  405. * base rate of 2.5 Gbit/sec. For example, IB_RATE_5_GBPS will be
  406. * converted to 2, since 5 Gbit/sec is 2 * 2.5 Gbit/sec.
  407. * @rate: rate to convert.
  408. */
  409. int ib_rate_to_mult(enum ib_rate rate) __attribute_const__;
  410. /**
  411. * ib_rate_to_mbps - Convert the IB rate enum to Mbps.
  412. * For example, IB_RATE_2_5_GBPS will be converted to 2500.
  413. * @rate: rate to convert.
  414. */
  415. int ib_rate_to_mbps(enum ib_rate rate) __attribute_const__;
  416. /**
  417. * mult_to_ib_rate - Convert a multiple of 2.5 Gbit/sec to an IB rate
  418. * enum.
  419. * @mult: multiple to convert.
  420. */
  421. enum ib_rate mult_to_ib_rate(int mult) __attribute_const__;
  422. struct ib_ah_attr {
  423. struct ib_global_route grh;
  424. u16 dlid;
  425. u8 sl;
  426. u8 src_path_bits;
  427. u8 static_rate;
  428. u8 ah_flags;
  429. u8 port_num;
  430. };
  431. enum ib_wc_status {
  432. IB_WC_SUCCESS,
  433. IB_WC_LOC_LEN_ERR,
  434. IB_WC_LOC_QP_OP_ERR,
  435. IB_WC_LOC_EEC_OP_ERR,
  436. IB_WC_LOC_PROT_ERR,
  437. IB_WC_WR_FLUSH_ERR,
  438. IB_WC_MW_BIND_ERR,
  439. IB_WC_BAD_RESP_ERR,
  440. IB_WC_LOC_ACCESS_ERR,
  441. IB_WC_REM_INV_REQ_ERR,
  442. IB_WC_REM_ACCESS_ERR,
  443. IB_WC_REM_OP_ERR,
  444. IB_WC_RETRY_EXC_ERR,
  445. IB_WC_RNR_RETRY_EXC_ERR,
  446. IB_WC_LOC_RDD_VIOL_ERR,
  447. IB_WC_REM_INV_RD_REQ_ERR,
  448. IB_WC_REM_ABORT_ERR,
  449. IB_WC_INV_EECN_ERR,
  450. IB_WC_INV_EEC_STATE_ERR,
  451. IB_WC_FATAL_ERR,
  452. IB_WC_RESP_TIMEOUT_ERR,
  453. IB_WC_GENERAL_ERR
  454. };
  455. enum ib_wc_opcode {
  456. IB_WC_SEND,
  457. IB_WC_RDMA_WRITE,
  458. IB_WC_RDMA_READ,
  459. IB_WC_COMP_SWAP,
  460. IB_WC_FETCH_ADD,
  461. IB_WC_BIND_MW,
  462. IB_WC_LSO,
  463. IB_WC_LOCAL_INV,
  464. IB_WC_FAST_REG_MR,
  465. IB_WC_MASKED_COMP_SWAP,
  466. IB_WC_MASKED_FETCH_ADD,
  467. /*
  468. * Set value of IB_WC_RECV so consumers can test if a completion is a
  469. * receive by testing (opcode & IB_WC_RECV).
  470. */
  471. IB_WC_RECV = 1 << 7,
  472. IB_WC_RECV_RDMA_WITH_IMM
  473. };
  474. enum ib_wc_flags {
  475. IB_WC_GRH = 1,
  476. IB_WC_WITH_IMM = (1<<1),
  477. IB_WC_WITH_INVALIDATE = (1<<2),
  478. IB_WC_IP_CSUM_OK = (1<<3),
  479. };
  480. struct ib_wc {
  481. u64 wr_id;
  482. enum ib_wc_status status;
  483. enum ib_wc_opcode opcode;
  484. u32 vendor_err;
  485. u32 byte_len;
  486. struct ib_qp *qp;
  487. union {
  488. __be32 imm_data;
  489. u32 invalidate_rkey;
  490. } ex;
  491. u32 src_qp;
  492. int wc_flags;
  493. u16 pkey_index;
  494. u16 slid;
  495. u8 sl;
  496. u8 dlid_path_bits;
  497. u8 port_num; /* valid only for DR SMPs on switches */
  498. };
  499. enum ib_cq_notify_flags {
  500. IB_CQ_SOLICITED = 1 << 0,
  501. IB_CQ_NEXT_COMP = 1 << 1,
  502. IB_CQ_SOLICITED_MASK = IB_CQ_SOLICITED | IB_CQ_NEXT_COMP,
  503. IB_CQ_REPORT_MISSED_EVENTS = 1 << 2,
  504. };
  505. enum ib_srq_type {
  506. IB_SRQT_BASIC,
  507. IB_SRQT_XRC
  508. };
  509. enum ib_srq_attr_mask {
  510. IB_SRQ_MAX_WR = 1 << 0,
  511. IB_SRQ_LIMIT = 1 << 1,
  512. };
  513. struct ib_srq_attr {
  514. u32 max_wr;
  515. u32 max_sge;
  516. u32 srq_limit;
  517. };
  518. struct ib_srq_init_attr {
  519. void (*event_handler)(struct ib_event *, void *);
  520. void *srq_context;
  521. struct ib_srq_attr attr;
  522. enum ib_srq_type srq_type;
  523. union {
  524. struct {
  525. struct ib_xrcd *xrcd;
  526. struct ib_cq *cq;
  527. } xrc;
  528. } ext;
  529. };
  530. struct ib_qp_cap {
  531. u32 max_send_wr;
  532. u32 max_recv_wr;
  533. u32 max_send_sge;
  534. u32 max_recv_sge;
  535. u32 max_inline_data;
  536. };
  537. enum ib_sig_type {
  538. IB_SIGNAL_ALL_WR,
  539. IB_SIGNAL_REQ_WR
  540. };
  541. enum ib_qp_type {
  542. /*
  543. * IB_QPT_SMI and IB_QPT_GSI have to be the first two entries
  544. * here (and in that order) since the MAD layer uses them as
  545. * indices into a 2-entry table.
  546. */
  547. IB_QPT_SMI,
  548. IB_QPT_GSI,
  549. IB_QPT_RC,
  550. IB_QPT_UC,
  551. IB_QPT_UD,
  552. IB_QPT_RAW_IPV6,
  553. IB_QPT_RAW_ETHERTYPE,
  554. IB_QPT_RAW_PACKET = 8,
  555. IB_QPT_XRC_INI = 9,
  556. IB_QPT_XRC_TGT,
  557. IB_QPT_MAX,
  558. /* Reserve a range for qp types internal to the low level driver.
  559. * These qp types will not be visible at the IB core layer, so the
  560. * IB_QPT_MAX usages should not be affected in the core layer
  561. */
  562. IB_QPT_RESERVED1 = 0x1000,
  563. IB_QPT_RESERVED2,
  564. IB_QPT_RESERVED3,
  565. IB_QPT_RESERVED4,
  566. IB_QPT_RESERVED5,
  567. IB_QPT_RESERVED6,
  568. IB_QPT_RESERVED7,
  569. IB_QPT_RESERVED8,
  570. IB_QPT_RESERVED9,
  571. IB_QPT_RESERVED10,
  572. };
  573. enum ib_qp_create_flags {
  574. IB_QP_CREATE_IPOIB_UD_LSO = 1 << 0,
  575. IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK = 1 << 1,
  576. /* reserve bits 26-31 for low level drivers' internal use */
  577. IB_QP_CREATE_RESERVED_START = 1 << 26,
  578. IB_QP_CREATE_RESERVED_END = 1 << 31,
  579. };
  580. struct ib_qp_init_attr {
  581. void (*event_handler)(struct ib_event *, void *);
  582. void *qp_context;
  583. struct ib_cq *send_cq;
  584. struct ib_cq *recv_cq;
  585. struct ib_srq *srq;
  586. struct ib_xrcd *xrcd; /* XRC TGT QPs only */
  587. struct ib_qp_cap cap;
  588. enum ib_sig_type sq_sig_type;
  589. enum ib_qp_type qp_type;
  590. enum ib_qp_create_flags create_flags;
  591. u8 port_num; /* special QP types only */
  592. };
  593. struct ib_qp_open_attr {
  594. void (*event_handler)(struct ib_event *, void *);
  595. void *qp_context;
  596. u32 qp_num;
  597. enum ib_qp_type qp_type;
  598. };
  599. enum ib_rnr_timeout {
  600. IB_RNR_TIMER_655_36 = 0,
  601. IB_RNR_TIMER_000_01 = 1,
  602. IB_RNR_TIMER_000_02 = 2,
  603. IB_RNR_TIMER_000_03 = 3,
  604. IB_RNR_TIMER_000_04 = 4,
  605. IB_RNR_TIMER_000_06 = 5,
  606. IB_RNR_TIMER_000_08 = 6,
  607. IB_RNR_TIMER_000_12 = 7,
  608. IB_RNR_TIMER_000_16 = 8,
  609. IB_RNR_TIMER_000_24 = 9,
  610. IB_RNR_TIMER_000_32 = 10,
  611. IB_RNR_TIMER_000_48 = 11,
  612. IB_RNR_TIMER_000_64 = 12,
  613. IB_RNR_TIMER_000_96 = 13,
  614. IB_RNR_TIMER_001_28 = 14,
  615. IB_RNR_TIMER_001_92 = 15,
  616. IB_RNR_TIMER_002_56 = 16,
  617. IB_RNR_TIMER_003_84 = 17,
  618. IB_RNR_TIMER_005_12 = 18,
  619. IB_RNR_TIMER_007_68 = 19,
  620. IB_RNR_TIMER_010_24 = 20,
  621. IB_RNR_TIMER_015_36 = 21,
  622. IB_RNR_TIMER_020_48 = 22,
  623. IB_RNR_TIMER_030_72 = 23,
  624. IB_RNR_TIMER_040_96 = 24,
  625. IB_RNR_TIMER_061_44 = 25,
  626. IB_RNR_TIMER_081_92 = 26,
  627. IB_RNR_TIMER_122_88 = 27,
  628. IB_RNR_TIMER_163_84 = 28,
  629. IB_RNR_TIMER_245_76 = 29,
  630. IB_RNR_TIMER_327_68 = 30,
  631. IB_RNR_TIMER_491_52 = 31
  632. };
  633. enum ib_qp_attr_mask {
  634. IB_QP_STATE = 1,
  635. IB_QP_CUR_STATE = (1<<1),
  636. IB_QP_EN_SQD_ASYNC_NOTIFY = (1<<2),
  637. IB_QP_ACCESS_FLAGS = (1<<3),
  638. IB_QP_PKEY_INDEX = (1<<4),
  639. IB_QP_PORT = (1<<5),
  640. IB_QP_QKEY = (1<<6),
  641. IB_QP_AV = (1<<7),
  642. IB_QP_PATH_MTU = (1<<8),
  643. IB_QP_TIMEOUT = (1<<9),
  644. IB_QP_RETRY_CNT = (1<<10),
  645. IB_QP_RNR_RETRY = (1<<11),
  646. IB_QP_RQ_PSN = (1<<12),
  647. IB_QP_MAX_QP_RD_ATOMIC = (1<<13),
  648. IB_QP_ALT_PATH = (1<<14),
  649. IB_QP_MIN_RNR_TIMER = (1<<15),
  650. IB_QP_SQ_PSN = (1<<16),
  651. IB_QP_MAX_DEST_RD_ATOMIC = (1<<17),
  652. IB_QP_PATH_MIG_STATE = (1<<18),
  653. IB_QP_CAP = (1<<19),
  654. IB_QP_DEST_QPN = (1<<20)
  655. };
  656. enum ib_qp_state {
  657. IB_QPS_RESET,
  658. IB_QPS_INIT,
  659. IB_QPS_RTR,
  660. IB_QPS_RTS,
  661. IB_QPS_SQD,
  662. IB_QPS_SQE,
  663. IB_QPS_ERR
  664. };
  665. enum ib_mig_state {
  666. IB_MIG_MIGRATED,
  667. IB_MIG_REARM,
  668. IB_MIG_ARMED
  669. };
  670. enum ib_mw_type {
  671. IB_MW_TYPE_1 = 1,
  672. IB_MW_TYPE_2 = 2
  673. };
  674. struct ib_qp_attr {
  675. enum ib_qp_state qp_state;
  676. enum ib_qp_state cur_qp_state;
  677. enum ib_mtu path_mtu;
  678. enum ib_mig_state path_mig_state;
  679. u32 qkey;
  680. u32 rq_psn;
  681. u32 sq_psn;
  682. u32 dest_qp_num;
  683. int qp_access_flags;
  684. struct ib_qp_cap cap;
  685. struct ib_ah_attr ah_attr;
  686. struct ib_ah_attr alt_ah_attr;
  687. u16 pkey_index;
  688. u16 alt_pkey_index;
  689. u8 en_sqd_async_notify;
  690. u8 sq_draining;
  691. u8 max_rd_atomic;
  692. u8 max_dest_rd_atomic;
  693. u8 min_rnr_timer;
  694. u8 port_num;
  695. u8 timeout;
  696. u8 retry_cnt;
  697. u8 rnr_retry;
  698. u8 alt_port_num;
  699. u8 alt_timeout;
  700. };
  701. enum ib_wr_opcode {
  702. IB_WR_RDMA_WRITE,
  703. IB_WR_RDMA_WRITE_WITH_IMM,
  704. IB_WR_SEND,
  705. IB_WR_SEND_WITH_IMM,
  706. IB_WR_RDMA_READ,
  707. IB_WR_ATOMIC_CMP_AND_SWP,
  708. IB_WR_ATOMIC_FETCH_AND_ADD,
  709. IB_WR_LSO,
  710. IB_WR_SEND_WITH_INV,
  711. IB_WR_RDMA_READ_WITH_INV,
  712. IB_WR_LOCAL_INV,
  713. IB_WR_FAST_REG_MR,
  714. IB_WR_MASKED_ATOMIC_CMP_AND_SWP,
  715. IB_WR_MASKED_ATOMIC_FETCH_AND_ADD,
  716. IB_WR_BIND_MW,
  717. /* reserve values for low level drivers' internal use.
  718. * These values will not be used at all in the ib core layer.
  719. */
  720. IB_WR_RESERVED1 = 0xf0,
  721. IB_WR_RESERVED2,
  722. IB_WR_RESERVED3,
  723. IB_WR_RESERVED4,
  724. IB_WR_RESERVED5,
  725. IB_WR_RESERVED6,
  726. IB_WR_RESERVED7,
  727. IB_WR_RESERVED8,
  728. IB_WR_RESERVED9,
  729. IB_WR_RESERVED10,
  730. };
  731. enum ib_send_flags {
  732. IB_SEND_FENCE = 1,
  733. IB_SEND_SIGNALED = (1<<1),
  734. IB_SEND_SOLICITED = (1<<2),
  735. IB_SEND_INLINE = (1<<3),
  736. IB_SEND_IP_CSUM = (1<<4),
  737. /* reserve bits 26-31 for low level drivers' internal use */
  738. IB_SEND_RESERVED_START = (1 << 26),
  739. IB_SEND_RESERVED_END = (1 << 31),
  740. };
  741. struct ib_sge {
  742. u64 addr;
  743. u32 length;
  744. u32 lkey;
  745. };
  746. struct ib_fast_reg_page_list {
  747. struct ib_device *device;
  748. u64 *page_list;
  749. unsigned int max_page_list_len;
  750. };
  751. /**
  752. * struct ib_mw_bind_info - Parameters for a memory window bind operation.
  753. * @mr: A memory region to bind the memory window to.
  754. * @addr: The address where the memory window should begin.
  755. * @length: The length of the memory window, in bytes.
  756. * @mw_access_flags: Access flags from enum ib_access_flags for the window.
  757. *
  758. * This struct contains the shared parameters for type 1 and type 2
  759. * memory window bind operations.
  760. */
  761. struct ib_mw_bind_info {
  762. struct ib_mr *mr;
  763. u64 addr;
  764. u64 length;
  765. int mw_access_flags;
  766. };
  767. struct ib_send_wr {
  768. struct ib_send_wr *next;
  769. u64 wr_id;
  770. struct ib_sge *sg_list;
  771. int num_sge;
  772. enum ib_wr_opcode opcode;
  773. int send_flags;
  774. union {
  775. __be32 imm_data;
  776. u32 invalidate_rkey;
  777. } ex;
  778. union {
  779. struct {
  780. u64 remote_addr;
  781. u32 rkey;
  782. } rdma;
  783. struct {
  784. u64 remote_addr;
  785. u64 compare_add;
  786. u64 swap;
  787. u64 compare_add_mask;
  788. u64 swap_mask;
  789. u32 rkey;
  790. } atomic;
  791. struct {
  792. struct ib_ah *ah;
  793. void *header;
  794. int hlen;
  795. int mss;
  796. u32 remote_qpn;
  797. u32 remote_qkey;
  798. u16 pkey_index; /* valid for GSI only */
  799. u8 port_num; /* valid for DR SMPs on switch only */
  800. } ud;
  801. struct {
  802. u64 iova_start;
  803. struct ib_fast_reg_page_list *page_list;
  804. unsigned int page_shift;
  805. unsigned int page_list_len;
  806. u32 length;
  807. int access_flags;
  808. u32 rkey;
  809. } fast_reg;
  810. struct {
  811. struct ib_mw *mw;
  812. /* The new rkey for the memory window. */
  813. u32 rkey;
  814. struct ib_mw_bind_info bind_info;
  815. } bind_mw;
  816. } wr;
  817. u32 xrc_remote_srq_num; /* XRC TGT QPs only */
  818. };
  819. struct ib_recv_wr {
  820. struct ib_recv_wr *next;
  821. u64 wr_id;
  822. struct ib_sge *sg_list;
  823. int num_sge;
  824. };
  825. enum ib_access_flags {
  826. IB_ACCESS_LOCAL_WRITE = 1,
  827. IB_ACCESS_REMOTE_WRITE = (1<<1),
  828. IB_ACCESS_REMOTE_READ = (1<<2),
  829. IB_ACCESS_REMOTE_ATOMIC = (1<<3),
  830. IB_ACCESS_MW_BIND = (1<<4),
  831. IB_ZERO_BASED = (1<<5)
  832. };
  833. struct ib_phys_buf {
  834. u64 addr;
  835. u64 size;
  836. };
  837. struct ib_mr_attr {
  838. struct ib_pd *pd;
  839. u64 device_virt_addr;
  840. u64 size;
  841. int mr_access_flags;
  842. u32 lkey;
  843. u32 rkey;
  844. };
  845. enum ib_mr_rereg_flags {
  846. IB_MR_REREG_TRANS = 1,
  847. IB_MR_REREG_PD = (1<<1),
  848. IB_MR_REREG_ACCESS = (1<<2)
  849. };
  850. /**
  851. * struct ib_mw_bind - Parameters for a type 1 memory window bind operation.
  852. * @wr_id: Work request id.
  853. * @send_flags: Flags from ib_send_flags enum.
  854. * @bind_info: More parameters of the bind operation.
  855. */
  856. struct ib_mw_bind {
  857. u64 wr_id;
  858. int send_flags;
  859. struct ib_mw_bind_info bind_info;
  860. };
  861. struct ib_fmr_attr {
  862. int max_pages;
  863. int max_maps;
  864. u8 page_shift;
  865. };
  866. struct ib_ucontext {
  867. struct ib_device *device;
  868. struct list_head pd_list;
  869. struct list_head mr_list;
  870. struct list_head mw_list;
  871. struct list_head cq_list;
  872. struct list_head qp_list;
  873. struct list_head srq_list;
  874. struct list_head ah_list;
  875. struct list_head xrcd_list;
  876. int closing;
  877. };
  878. struct ib_uobject {
  879. u64 user_handle; /* handle given to us by userspace */
  880. struct ib_ucontext *context; /* associated user context */
  881. void *object; /* containing object */
  882. struct list_head list; /* link to context's list */
  883. int id; /* index into kernel idr */
  884. struct kref ref;
  885. struct rw_semaphore mutex; /* protects .live */
  886. int live;
  887. };
  888. struct ib_udata {
  889. void __user *inbuf;
  890. void __user *outbuf;
  891. size_t inlen;
  892. size_t outlen;
  893. };
  894. struct ib_pd {
  895. struct ib_device *device;
  896. struct ib_uobject *uobject;
  897. atomic_t usecnt; /* count all resources */
  898. };
  899. struct ib_xrcd {
  900. struct ib_device *device;
  901. atomic_t usecnt; /* count all exposed resources */
  902. struct inode *inode;
  903. struct mutex tgt_qp_mutex;
  904. struct list_head tgt_qp_list;
  905. };
  906. struct ib_ah {
  907. struct ib_device *device;
  908. struct ib_pd *pd;
  909. struct ib_uobject *uobject;
  910. };
  911. typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context);
  912. struct ib_cq {
  913. struct ib_device *device;
  914. struct ib_uobject *uobject;
  915. ib_comp_handler comp_handler;
  916. void (*event_handler)(struct ib_event *, void *);
  917. void *cq_context;
  918. int cqe;
  919. atomic_t usecnt; /* count number of work queues */
  920. };
  921. struct ib_srq {
  922. struct ib_device *device;
  923. struct ib_pd *pd;
  924. struct ib_uobject *uobject;
  925. void (*event_handler)(struct ib_event *, void *);
  926. void *srq_context;
  927. enum ib_srq_type srq_type;
  928. atomic_t usecnt;
  929. union {
  930. struct {
  931. struct ib_xrcd *xrcd;
  932. struct ib_cq *cq;
  933. u32 srq_num;
  934. } xrc;
  935. } ext;
  936. };
  937. struct ib_qp {
  938. struct ib_device *device;
  939. struct ib_pd *pd;
  940. struct ib_cq *send_cq;
  941. struct ib_cq *recv_cq;
  942. struct ib_srq *srq;
  943. struct ib_xrcd *xrcd; /* XRC TGT QPs only */
  944. struct list_head xrcd_list;
  945. atomic_t usecnt; /* count times opened, mcast attaches */
  946. struct list_head open_list;
  947. struct ib_qp *real_qp;
  948. struct ib_uobject *uobject;
  949. void (*event_handler)(struct ib_event *, void *);
  950. void *qp_context;
  951. u32 qp_num;
  952. enum ib_qp_type qp_type;
  953. };
  954. struct ib_mr {
  955. struct ib_device *device;
  956. struct ib_pd *pd;
  957. struct ib_uobject *uobject;
  958. u32 lkey;
  959. u32 rkey;
  960. atomic_t usecnt; /* count number of MWs */
  961. };
  962. struct ib_mw {
  963. struct ib_device *device;
  964. struct ib_pd *pd;
  965. struct ib_uobject *uobject;
  966. u32 rkey;
  967. enum ib_mw_type type;
  968. };
  969. struct ib_fmr {
  970. struct ib_device *device;
  971. struct ib_pd *pd;
  972. struct list_head list;
  973. u32 lkey;
  974. u32 rkey;
  975. };
  976. struct ib_mad;
  977. struct ib_grh;
  978. enum ib_process_mad_flags {
  979. IB_MAD_IGNORE_MKEY = 1,
  980. IB_MAD_IGNORE_BKEY = 2,
  981. IB_MAD_IGNORE_ALL = IB_MAD_IGNORE_MKEY | IB_MAD_IGNORE_BKEY
  982. };
  983. enum ib_mad_result {
  984. IB_MAD_RESULT_FAILURE = 0, /* (!SUCCESS is the important flag) */
  985. IB_MAD_RESULT_SUCCESS = 1 << 0, /* MAD was successfully processed */
  986. IB_MAD_RESULT_REPLY = 1 << 1, /* Reply packet needs to be sent */
  987. IB_MAD_RESULT_CONSUMED = 1 << 2 /* Packet consumed: stop processing */
  988. };
  989. #define IB_DEVICE_NAME_MAX 64
  990. struct ib_cache {
  991. rwlock_t lock;
  992. struct ib_event_handler event_handler;
  993. struct ib_pkey_cache **pkey_cache;
  994. struct ib_gid_cache **gid_cache;
  995. u8 *lmc_cache;
  996. };
  997. struct ib_dma_mapping_ops {
  998. int (*mapping_error)(struct ib_device *dev,
  999. u64 dma_addr);
  1000. u64 (*map_single)(struct ib_device *dev,
  1001. void *ptr, size_t size,
  1002. enum dma_data_direction direction);
  1003. void (*unmap_single)(struct ib_device *dev,
  1004. u64 addr, size_t size,
  1005. enum dma_data_direction direction);
  1006. u64 (*map_page)(struct ib_device *dev,
  1007. struct page *page, unsigned long offset,
  1008. size_t size,
  1009. enum dma_data_direction direction);
  1010. void (*unmap_page)(struct ib_device *dev,
  1011. u64 addr, size_t size,
  1012. enum dma_data_direction direction);
  1013. int (*map_sg)(struct ib_device *dev,
  1014. struct scatterlist *sg, int nents,
  1015. enum dma_data_direction direction);
  1016. void (*unmap_sg)(struct ib_device *dev,
  1017. struct scatterlist *sg, int nents,
  1018. enum dma_data_direction direction);
  1019. u64 (*dma_address)(struct ib_device *dev,
  1020. struct scatterlist *sg);
  1021. unsigned int (*dma_len)(struct ib_device *dev,
  1022. struct scatterlist *sg);
  1023. void (*sync_single_for_cpu)(struct ib_device *dev,
  1024. u64 dma_handle,
  1025. size_t size,
  1026. enum dma_data_direction dir);
  1027. void (*sync_single_for_device)(struct ib_device *dev,
  1028. u64 dma_handle,
  1029. size_t size,
  1030. enum dma_data_direction dir);
  1031. void *(*alloc_coherent)(struct ib_device *dev,
  1032. size_t size,
  1033. u64 *dma_handle,
  1034. gfp_t flag);
  1035. void (*free_coherent)(struct ib_device *dev,
  1036. size_t size, void *cpu_addr,
  1037. u64 dma_handle);
  1038. };
  1039. struct iw_cm_verbs;
  1040. struct ib_device {
  1041. struct device *dma_device;
  1042. char name[IB_DEVICE_NAME_MAX];
  1043. struct list_head event_handler_list;
  1044. spinlock_t event_handler_lock;
  1045. spinlock_t client_data_lock;
  1046. struct list_head core_list;
  1047. struct list_head client_data_list;
  1048. struct ib_cache cache;
  1049. int *pkey_tbl_len;
  1050. int *gid_tbl_len;
  1051. int num_comp_vectors;
  1052. struct iw_cm_verbs *iwcm;
  1053. int (*get_protocol_stats)(struct ib_device *device,
  1054. union rdma_protocol_stats *stats);
  1055. int (*query_device)(struct ib_device *device,
  1056. struct ib_device_attr *device_attr);
  1057. int (*query_port)(struct ib_device *device,
  1058. u8 port_num,
  1059. struct ib_port_attr *port_attr);
  1060. enum rdma_link_layer (*get_link_layer)(struct ib_device *device,
  1061. u8 port_num);
  1062. int (*query_gid)(struct ib_device *device,
  1063. u8 port_num, int index,
  1064. union ib_gid *gid);
  1065. int (*query_pkey)(struct ib_device *device,
  1066. u8 port_num, u16 index, u16 *pkey);
  1067. int (*modify_device)(struct ib_device *device,
  1068. int device_modify_mask,
  1069. struct ib_device_modify *device_modify);
  1070. int (*modify_port)(struct ib_device *device,
  1071. u8 port_num, int port_modify_mask,
  1072. struct ib_port_modify *port_modify);
  1073. struct ib_ucontext * (*alloc_ucontext)(struct ib_device *device,
  1074. struct ib_udata *udata);
  1075. int (*dealloc_ucontext)(struct ib_ucontext *context);
  1076. int (*mmap)(struct ib_ucontext *context,
  1077. struct vm_area_struct *vma);
  1078. struct ib_pd * (*alloc_pd)(struct ib_device *device,
  1079. struct ib_ucontext *context,
  1080. struct ib_udata *udata);
  1081. int (*dealloc_pd)(struct ib_pd *pd);
  1082. struct ib_ah * (*create_ah)(struct ib_pd *pd,
  1083. struct ib_ah_attr *ah_attr);
  1084. int (*modify_ah)(struct ib_ah *ah,
  1085. struct ib_ah_attr *ah_attr);
  1086. int (*query_ah)(struct ib_ah *ah,
  1087. struct ib_ah_attr *ah_attr);
  1088. int (*destroy_ah)(struct ib_ah *ah);
  1089. struct ib_srq * (*create_srq)(struct ib_pd *pd,
  1090. struct ib_srq_init_attr *srq_init_attr,
  1091. struct ib_udata *udata);
  1092. int (*modify_srq)(struct ib_srq *srq,
  1093. struct ib_srq_attr *srq_attr,
  1094. enum ib_srq_attr_mask srq_attr_mask,
  1095. struct ib_udata *udata);
  1096. int (*query_srq)(struct ib_srq *srq,
  1097. struct ib_srq_attr *srq_attr);
  1098. int (*destroy_srq)(struct ib_srq *srq);
  1099. int (*post_srq_recv)(struct ib_srq *srq,
  1100. struct ib_recv_wr *recv_wr,
  1101. struct ib_recv_wr **bad_recv_wr);
  1102. struct ib_qp * (*create_qp)(struct ib_pd *pd,
  1103. struct ib_qp_init_attr *qp_init_attr,
  1104. struct ib_udata *udata);
  1105. int (*modify_qp)(struct ib_qp *qp,
  1106. struct ib_qp_attr *qp_attr,
  1107. int qp_attr_mask,
  1108. struct ib_udata *udata);
  1109. int (*query_qp)(struct ib_qp *qp,
  1110. struct ib_qp_attr *qp_attr,
  1111. int qp_attr_mask,
  1112. struct ib_qp_init_attr *qp_init_attr);
  1113. int (*destroy_qp)(struct ib_qp *qp);
  1114. int (*post_send)(struct ib_qp *qp,
  1115. struct ib_send_wr *send_wr,
  1116. struct ib_send_wr **bad_send_wr);
  1117. int (*post_recv)(struct ib_qp *qp,
  1118. struct ib_recv_wr *recv_wr,
  1119. struct ib_recv_wr **bad_recv_wr);
  1120. struct ib_cq * (*create_cq)(struct ib_device *device, int cqe,
  1121. int comp_vector,
  1122. struct ib_ucontext *context,
  1123. struct ib_udata *udata);
  1124. int (*modify_cq)(struct ib_cq *cq, u16 cq_count,
  1125. u16 cq_period);
  1126. int (*destroy_cq)(struct ib_cq *cq);
  1127. int (*resize_cq)(struct ib_cq *cq, int cqe,
  1128. struct ib_udata *udata);
  1129. int (*poll_cq)(struct ib_cq *cq, int num_entries,
  1130. struct ib_wc *wc);
  1131. int (*peek_cq)(struct ib_cq *cq, int wc_cnt);
  1132. int (*req_notify_cq)(struct ib_cq *cq,
  1133. enum ib_cq_notify_flags flags);
  1134. int (*req_ncomp_notif)(struct ib_cq *cq,
  1135. int wc_cnt);
  1136. struct ib_mr * (*get_dma_mr)(struct ib_pd *pd,
  1137. int mr_access_flags);
  1138. struct ib_mr * (*reg_phys_mr)(struct ib_pd *pd,
  1139. struct ib_phys_buf *phys_buf_array,
  1140. int num_phys_buf,
  1141. int mr_access_flags,
  1142. u64 *iova_start);
  1143. struct ib_mr * (*reg_user_mr)(struct ib_pd *pd,
  1144. u64 start, u64 length,
  1145. u64 virt_addr,
  1146. int mr_access_flags,
  1147. struct ib_udata *udata);
  1148. int (*query_mr)(struct ib_mr *mr,
  1149. struct ib_mr_attr *mr_attr);
  1150. int (*dereg_mr)(struct ib_mr *mr);
  1151. struct ib_mr * (*alloc_fast_reg_mr)(struct ib_pd *pd,
  1152. int max_page_list_len);
  1153. struct ib_fast_reg_page_list * (*alloc_fast_reg_page_list)(struct ib_device *device,
  1154. int page_list_len);
  1155. void (*free_fast_reg_page_list)(struct ib_fast_reg_page_list *page_list);
  1156. int (*rereg_phys_mr)(struct ib_mr *mr,
  1157. int mr_rereg_mask,
  1158. struct ib_pd *pd,
  1159. struct ib_phys_buf *phys_buf_array,
  1160. int num_phys_buf,
  1161. int mr_access_flags,
  1162. u64 *iova_start);
  1163. struct ib_mw * (*alloc_mw)(struct ib_pd *pd,
  1164. enum ib_mw_type type);
  1165. int (*bind_mw)(struct ib_qp *qp,
  1166. struct ib_mw *mw,
  1167. struct ib_mw_bind *mw_bind);
  1168. int (*dealloc_mw)(struct ib_mw *mw);
  1169. struct ib_fmr * (*alloc_fmr)(struct ib_pd *pd,
  1170. int mr_access_flags,
  1171. struct ib_fmr_attr *fmr_attr);
  1172. int (*map_phys_fmr)(struct ib_fmr *fmr,
  1173. u64 *page_list, int list_len,
  1174. u64 iova);
  1175. int (*unmap_fmr)(struct list_head *fmr_list);
  1176. int (*dealloc_fmr)(struct ib_fmr *fmr);
  1177. int (*attach_mcast)(struct ib_qp *qp,
  1178. union ib_gid *gid,
  1179. u16 lid);
  1180. int (*detach_mcast)(struct ib_qp *qp,
  1181. union ib_gid *gid,
  1182. u16 lid);
  1183. int (*process_mad)(struct ib_device *device,
  1184. int process_mad_flags,
  1185. u8 port_num,
  1186. struct ib_wc *in_wc,
  1187. struct ib_grh *in_grh,
  1188. struct ib_mad *in_mad,
  1189. struct ib_mad *out_mad);
  1190. struct ib_xrcd * (*alloc_xrcd)(struct ib_device *device,
  1191. struct ib_ucontext *ucontext,
  1192. struct ib_udata *udata);
  1193. int (*dealloc_xrcd)(struct ib_xrcd *xrcd);
  1194. struct ib_dma_mapping_ops *dma_ops;
  1195. struct module *owner;
  1196. struct device dev;
  1197. struct kobject *ports_parent;
  1198. struct list_head port_list;
  1199. enum {
  1200. IB_DEV_UNINITIALIZED,
  1201. IB_DEV_REGISTERED,
  1202. IB_DEV_UNREGISTERED
  1203. } reg_state;
  1204. int uverbs_abi_ver;
  1205. u64 uverbs_cmd_mask;
  1206. char node_desc[64];
  1207. __be64 node_guid;
  1208. u32 local_dma_lkey;
  1209. u8 node_type;
  1210. u8 phys_port_cnt;
  1211. };
  1212. struct ib_client {
  1213. char *name;
  1214. void (*add) (struct ib_device *);
  1215. void (*remove)(struct ib_device *);
  1216. struct list_head list;
  1217. };
  1218. struct ib_device *ib_alloc_device(size_t size);
  1219. void ib_dealloc_device(struct ib_device *device);
  1220. int ib_register_device(struct ib_device *device,
  1221. int (*port_callback)(struct ib_device *,
  1222. u8, struct kobject *));
  1223. void ib_unregister_device(struct ib_device *device);
  1224. int ib_register_client (struct ib_client *client);
  1225. void ib_unregister_client(struct ib_client *client);
  1226. void *ib_get_client_data(struct ib_device *device, struct ib_client *client);
  1227. void ib_set_client_data(struct ib_device *device, struct ib_client *client,
  1228. void *data);
  1229. static inline int ib_copy_from_udata(void *dest, struct ib_udata *udata, size_t len)
  1230. {
  1231. return copy_from_user(dest, udata->inbuf, len) ? -EFAULT : 0;
  1232. }
  1233. static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len)
  1234. {
  1235. return copy_to_user(udata->outbuf, src, len) ? -EFAULT : 0;
  1236. }
  1237. /**
  1238. * ib_modify_qp_is_ok - Check that the supplied attribute mask
  1239. * contains all required attributes and no attributes not allowed for
  1240. * the given QP state transition.
  1241. * @cur_state: Current QP state
  1242. * @next_state: Next QP state
  1243. * @type: QP type
  1244. * @mask: Mask of supplied QP attributes
  1245. *
  1246. * This function is a helper function that a low-level driver's
  1247. * modify_qp method can use to validate the consumer's input. It
  1248. * checks that cur_state and next_state are valid QP states, that a
  1249. * transition from cur_state to next_state is allowed by the IB spec,
  1250. * and that the attribute mask supplied is allowed for the transition.
  1251. */
  1252. int ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state,
  1253. enum ib_qp_type type, enum ib_qp_attr_mask mask);
  1254. int ib_register_event_handler (struct ib_event_handler *event_handler);
  1255. int ib_unregister_event_handler(struct ib_event_handler *event_handler);
  1256. void ib_dispatch_event(struct ib_event *event);
  1257. int ib_query_device(struct ib_device *device,
  1258. struct ib_device_attr *device_attr);
  1259. int ib_query_port(struct ib_device *device,
  1260. u8 port_num, struct ib_port_attr *port_attr);
  1261. enum rdma_link_layer rdma_port_get_link_layer(struct ib_device *device,
  1262. u8 port_num);
  1263. int ib_query_gid(struct ib_device *device,
  1264. u8 port_num, int index, union ib_gid *gid);
  1265. int ib_query_pkey(struct ib_device *device,
  1266. u8 port_num, u16 index, u16 *pkey);
  1267. int ib_modify_device(struct ib_device *device,
  1268. int device_modify_mask,
  1269. struct ib_device_modify *device_modify);
  1270. int ib_modify_port(struct ib_device *device,
  1271. u8 port_num, int port_modify_mask,
  1272. struct ib_port_modify *port_modify);
  1273. int ib_find_gid(struct ib_device *device, union ib_gid *gid,
  1274. u8 *port_num, u16 *index);
  1275. int ib_find_pkey(struct ib_device *device,
  1276. u8 port_num, u16 pkey, u16 *index);
  1277. /**
  1278. * ib_alloc_pd - Allocates an unused protection domain.
  1279. * @device: The device on which to allocate the protection domain.
  1280. *
  1281. * A protection domain object provides an association between QPs, shared
  1282. * receive queues, address handles, memory regions, and memory windows.
  1283. */
  1284. struct ib_pd *ib_alloc_pd(struct ib_device *device);
  1285. /**
  1286. * ib_dealloc_pd - Deallocates a protection domain.
  1287. * @pd: The protection domain to deallocate.
  1288. */
  1289. int ib_dealloc_pd(struct ib_pd *pd);
  1290. /**
  1291. * ib_create_ah - Creates an address handle for the given address vector.
  1292. * @pd: The protection domain associated with the address handle.
  1293. * @ah_attr: The attributes of the address vector.
  1294. *
  1295. * The address handle is used to reference a local or global destination
  1296. * in all UD QP post sends.
  1297. */
  1298. struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr);
  1299. /**
  1300. * ib_init_ah_from_wc - Initializes address handle attributes from a
  1301. * work completion.
  1302. * @device: Device on which the received message arrived.
  1303. * @port_num: Port on which the received message arrived.
  1304. * @wc: Work completion associated with the received message.
  1305. * @grh: References the received global route header. This parameter is
  1306. * ignored unless the work completion indicates that the GRH is valid.
  1307. * @ah_attr: Returned attributes that can be used when creating an address
  1308. * handle for replying to the message.
  1309. */
  1310. int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
  1311. struct ib_grh *grh, struct ib_ah_attr *ah_attr);
  1312. /**
  1313. * ib_create_ah_from_wc - Creates an address handle associated with the
  1314. * sender of the specified work completion.
  1315. * @pd: The protection domain associated with the address handle.
  1316. * @wc: Work completion information associated with a received message.
  1317. * @grh: References the received global route header. This parameter is
  1318. * ignored unless the work completion indicates that the GRH is valid.
  1319. * @port_num: The outbound port number to associate with the address.
  1320. *
  1321. * The address handle is used to reference a local or global destination
  1322. * in all UD QP post sends.
  1323. */
  1324. struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc,
  1325. struct ib_grh *grh, u8 port_num);
  1326. /**
  1327. * ib_modify_ah - Modifies the address vector associated with an address
  1328. * handle.
  1329. * @ah: The address handle to modify.
  1330. * @ah_attr: The new address vector attributes to associate with the
  1331. * address handle.
  1332. */
  1333. int ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
  1334. /**
  1335. * ib_query_ah - Queries the address vector associated with an address
  1336. * handle.
  1337. * @ah: The address handle to query.
  1338. * @ah_attr: The address vector attributes associated with the address
  1339. * handle.
  1340. */
  1341. int ib_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
  1342. /**
  1343. * ib_destroy_ah - Destroys an address handle.
  1344. * @ah: The address handle to destroy.
  1345. */
  1346. int ib_destroy_ah(struct ib_ah *ah);
  1347. /**
  1348. * ib_create_srq - Creates a SRQ associated with the specified protection
  1349. * domain.
  1350. * @pd: The protection domain associated with the SRQ.
  1351. * @srq_init_attr: A list of initial attributes required to create the
  1352. * SRQ. If SRQ creation succeeds, then the attributes are updated to
  1353. * the actual capabilities of the created SRQ.
  1354. *
  1355. * srq_attr->max_wr and srq_attr->max_sge are read the determine the
  1356. * requested size of the SRQ, and set to the actual values allocated
  1357. * on return. If ib_create_srq() succeeds, then max_wr and max_sge
  1358. * will always be at least as large as the requested values.
  1359. */
  1360. struct ib_srq *ib_create_srq(struct ib_pd *pd,
  1361. struct ib_srq_init_attr *srq_init_attr);
  1362. /**
  1363. * ib_modify_srq - Modifies the attributes for the specified SRQ.
  1364. * @srq: The SRQ to modify.
  1365. * @srq_attr: On input, specifies the SRQ attributes to modify. On output,
  1366. * the current values of selected SRQ attributes are returned.
  1367. * @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ
  1368. * are being modified.
  1369. *
  1370. * The mask may contain IB_SRQ_MAX_WR to resize the SRQ and/or
  1371. * IB_SRQ_LIMIT to set the SRQ's limit and request notification when
  1372. * the number of receives queued drops below the limit.
  1373. */
  1374. int ib_modify_srq(struct ib_srq *srq,
  1375. struct ib_srq_attr *srq_attr,
  1376. enum ib_srq_attr_mask srq_attr_mask);
  1377. /**
  1378. * ib_query_srq - Returns the attribute list and current values for the
  1379. * specified SRQ.
  1380. * @srq: The SRQ to query.
  1381. * @srq_attr: The attributes of the specified SRQ.
  1382. */
  1383. int ib_query_srq(struct ib_srq *srq,
  1384. struct ib_srq_attr *srq_attr);
  1385. /**
  1386. * ib_destroy_srq - Destroys the specified SRQ.
  1387. * @srq: The SRQ to destroy.
  1388. */
  1389. int ib_destroy_srq(struct ib_srq *srq);
  1390. /**
  1391. * ib_post_srq_recv - Posts a list of work requests to the specified SRQ.
  1392. * @srq: The SRQ to post the work request on.
  1393. * @recv_wr: A list of work requests to post on the receive queue.
  1394. * @bad_recv_wr: On an immediate failure, this parameter will reference
  1395. * the work request that failed to be posted on the QP.
  1396. */
  1397. static inline int ib_post_srq_recv(struct ib_srq *srq,
  1398. struct ib_recv_wr *recv_wr,
  1399. struct ib_recv_wr **bad_recv_wr)
  1400. {
  1401. return srq->device->post_srq_recv(srq, recv_wr, bad_recv_wr);
  1402. }
  1403. /**
  1404. * ib_create_qp - Creates a QP associated with the specified protection
  1405. * domain.
  1406. * @pd: The protection domain associated with the QP.
  1407. * @qp_init_attr: A list of initial attributes required to create the
  1408. * QP. If QP creation succeeds, then the attributes are updated to
  1409. * the actual capabilities of the created QP.
  1410. */
  1411. struct ib_qp *ib_create_qp(struct ib_pd *pd,
  1412. struct ib_qp_init_attr *qp_init_attr);
  1413. /**
  1414. * ib_modify_qp - Modifies the attributes for the specified QP and then
  1415. * transitions the QP to the given state.
  1416. * @qp: The QP to modify.
  1417. * @qp_attr: On input, specifies the QP attributes to modify. On output,
  1418. * the current values of selected QP attributes are returned.
  1419. * @qp_attr_mask: A bit-mask used to specify which attributes of the QP
  1420. * are being modified.
  1421. */
  1422. int ib_modify_qp(struct ib_qp *qp,
  1423. struct ib_qp_attr *qp_attr,
  1424. int qp_attr_mask);
  1425. /**
  1426. * ib_query_qp - Returns the attribute list and current values for the
  1427. * specified QP.
  1428. * @qp: The QP to query.
  1429. * @qp_attr: The attributes of the specified QP.
  1430. * @qp_attr_mask: A bit-mask used to select specific attributes to query.
  1431. * @qp_init_attr: Additional attributes of the selected QP.
  1432. *
  1433. * The qp_attr_mask may be used to limit the query to gathering only the
  1434. * selected attributes.
  1435. */
  1436. int ib_query_qp(struct ib_qp *qp,
  1437. struct ib_qp_attr *qp_attr,
  1438. int qp_attr_mask,
  1439. struct ib_qp_init_attr *qp_init_attr);
  1440. /**
  1441. * ib_destroy_qp - Destroys the specified QP.
  1442. * @qp: The QP to destroy.
  1443. */
  1444. int ib_destroy_qp(struct ib_qp *qp);
  1445. /**
  1446. * ib_open_qp - Obtain a reference to an existing sharable QP.
  1447. * @xrcd - XRC domain
  1448. * @qp_open_attr: Attributes identifying the QP to open.
  1449. *
  1450. * Returns a reference to a sharable QP.
  1451. */
  1452. struct ib_qp *ib_open_qp(struct ib_xrcd *xrcd,
  1453. struct ib_qp_open_attr *qp_open_attr);
  1454. /**
  1455. * ib_close_qp - Release an external reference to a QP.
  1456. * @qp: The QP handle to release
  1457. *
  1458. * The opened QP handle is released by the caller. The underlying
  1459. * shared QP is not destroyed until all internal references are released.
  1460. */
  1461. int ib_close_qp(struct ib_qp *qp);
  1462. /**
  1463. * ib_post_send - Posts a list of work requests to the send queue of
  1464. * the specified QP.
  1465. * @qp: The QP to post the work request on.
  1466. * @send_wr: A list of work requests to post on the send queue.
  1467. * @bad_send_wr: On an immediate failure, this parameter will reference
  1468. * the work request that failed to be posted on the QP.
  1469. *
  1470. * While IBA Vol. 1 section 11.4.1.1 specifies that if an immediate
  1471. * error is returned, the QP state shall not be affected,
  1472. * ib_post_send() will return an immediate error after queueing any
  1473. * earlier work requests in the list.
  1474. */
  1475. static inline int ib_post_send(struct ib_qp *qp,
  1476. struct ib_send_wr *send_wr,
  1477. struct ib_send_wr **bad_send_wr)
  1478. {
  1479. return qp->device->post_send(qp, send_wr, bad_send_wr);
  1480. }
  1481. /**
  1482. * ib_post_recv - Posts a list of work requests to the receive queue of
  1483. * the specified QP.
  1484. * @qp: The QP to post the work request on.
  1485. * @recv_wr: A list of work requests to post on the receive queue.
  1486. * @bad_recv_wr: On an immediate failure, this parameter will reference
  1487. * the work request that failed to be posted on the QP.
  1488. */
  1489. static inline int ib_post_recv(struct ib_qp *qp,
  1490. struct ib_recv_wr *recv_wr,
  1491. struct ib_recv_wr **bad_recv_wr)
  1492. {
  1493. return qp->device->post_recv(qp, recv_wr, bad_recv_wr);
  1494. }
  1495. /**
  1496. * ib_create_cq - Creates a CQ on the specified device.
  1497. * @device: The device on which to create the CQ.
  1498. * @comp_handler: A user-specified callback that is invoked when a
  1499. * completion event occurs on the CQ.
  1500. * @event_handler: A user-specified callback that is invoked when an
  1501. * asynchronous event not associated with a completion occurs on the CQ.
  1502. * @cq_context: Context associated with the CQ returned to the user via
  1503. * the associated completion and event handlers.
  1504. * @cqe: The minimum size of the CQ.
  1505. * @comp_vector - Completion vector used to signal completion events.
  1506. * Must be >= 0 and < context->num_comp_vectors.
  1507. *
  1508. * Users can examine the cq structure to determine the actual CQ size.
  1509. */
  1510. struct ib_cq *ib_create_cq(struct ib_device *device,
  1511. ib_comp_handler comp_handler,
  1512. void (*event_handler)(struct ib_event *, void *),
  1513. void *cq_context, int cqe, int comp_vector);
  1514. /**
  1515. * ib_resize_cq - Modifies the capacity of the CQ.
  1516. * @cq: The CQ to resize.
  1517. * @cqe: The minimum size of the CQ.
  1518. *
  1519. * Users can examine the cq structure to determine the actual CQ size.
  1520. */
  1521. int ib_resize_cq(struct ib_cq *cq, int cqe);
  1522. /**
  1523. * ib_modify_cq - Modifies moderation params of the CQ
  1524. * @cq: The CQ to modify.
  1525. * @cq_count: number of CQEs that will trigger an event
  1526. * @cq_period: max period of time in usec before triggering an event
  1527. *
  1528. */
  1529. int ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period);
  1530. /**
  1531. * ib_destroy_cq - Destroys the specified CQ.
  1532. * @cq: The CQ to destroy.
  1533. */
  1534. int ib_destroy_cq(struct ib_cq *cq);
  1535. /**
  1536. * ib_poll_cq - poll a CQ for completion(s)
  1537. * @cq:the CQ being polled
  1538. * @num_entries:maximum number of completions to return
  1539. * @wc:array of at least @num_entries &struct ib_wc where completions
  1540. * will be returned
  1541. *
  1542. * Poll a CQ for (possibly multiple) completions. If the return value
  1543. * is < 0, an error occurred. If the return value is >= 0, it is the
  1544. * number of completions returned. If the return value is
  1545. * non-negative and < num_entries, then the CQ was emptied.
  1546. */
  1547. static inline int ib_poll_cq(struct ib_cq *cq, int num_entries,
  1548. struct ib_wc *wc)
  1549. {
  1550. return cq->device->poll_cq(cq, num_entries, wc);
  1551. }
  1552. /**
  1553. * ib_peek_cq - Returns the number of unreaped completions currently
  1554. * on the specified CQ.
  1555. * @cq: The CQ to peek.
  1556. * @wc_cnt: A minimum number of unreaped completions to check for.
  1557. *
  1558. * If the number of unreaped completions is greater than or equal to wc_cnt,
  1559. * this function returns wc_cnt, otherwise, it returns the actual number of
  1560. * unreaped completions.
  1561. */
  1562. int ib_peek_cq(struct ib_cq *cq, int wc_cnt);
  1563. /**
  1564. * ib_req_notify_cq - Request completion notification on a CQ.
  1565. * @cq: The CQ to generate an event for.
  1566. * @flags:
  1567. * Must contain exactly one of %IB_CQ_SOLICITED or %IB_CQ_NEXT_COMP
  1568. * to request an event on the next solicited event or next work
  1569. * completion at any type, respectively. %IB_CQ_REPORT_MISSED_EVENTS
  1570. * may also be |ed in to request a hint about missed events, as
  1571. * described below.
  1572. *
  1573. * Return Value:
  1574. * < 0 means an error occurred while requesting notification
  1575. * == 0 means notification was requested successfully, and if
  1576. * IB_CQ_REPORT_MISSED_EVENTS was passed in, then no events
  1577. * were missed and it is safe to wait for another event. In
  1578. * this case is it guaranteed that any work completions added
  1579. * to the CQ since the last CQ poll will trigger a completion
  1580. * notification event.
  1581. * > 0 is only returned if IB_CQ_REPORT_MISSED_EVENTS was passed
  1582. * in. It means that the consumer must poll the CQ again to
  1583. * make sure it is empty to avoid missing an event because of a
  1584. * race between requesting notification and an entry being
  1585. * added to the CQ. This return value means it is possible
  1586. * (but not guaranteed) that a work completion has been added
  1587. * to the CQ since the last poll without triggering a
  1588. * completion notification event.
  1589. */
  1590. static inline int ib_req_notify_cq(struct ib_cq *cq,
  1591. enum ib_cq_notify_flags flags)
  1592. {
  1593. return cq->device->req_notify_cq(cq, flags);
  1594. }
  1595. /**
  1596. * ib_req_ncomp_notif - Request completion notification when there are
  1597. * at least the specified number of unreaped completions on the CQ.
  1598. * @cq: The CQ to generate an event for.
  1599. * @wc_cnt: The number of unreaped completions that should be on the
  1600. * CQ before an event is generated.
  1601. */
  1602. static inline int ib_req_ncomp_notif(struct ib_cq *cq, int wc_cnt)
  1603. {
  1604. return cq->device->req_ncomp_notif ?
  1605. cq->device->req_ncomp_notif(cq, wc_cnt) :
  1606. -ENOSYS;
  1607. }
  1608. /**
  1609. * ib_get_dma_mr - Returns a memory region for system memory that is
  1610. * usable for DMA.
  1611. * @pd: The protection domain associated with the memory region.
  1612. * @mr_access_flags: Specifies the memory access rights.
  1613. *
  1614. * Note that the ib_dma_*() functions defined below must be used
  1615. * to create/destroy addresses used with the Lkey or Rkey returned
  1616. * by ib_get_dma_mr().
  1617. */
  1618. struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
  1619. /**
  1620. * ib_dma_mapping_error - check a DMA addr for error
  1621. * @dev: The device for which the dma_addr was created
  1622. * @dma_addr: The DMA address to check
  1623. */
  1624. static inline int ib_dma_mapping_error(struct ib_device *dev, u64 dma_addr)
  1625. {
  1626. if (dev->dma_ops)
  1627. return dev->dma_ops->mapping_error(dev, dma_addr);
  1628. return dma_mapping_error(dev->dma_device, dma_addr);
  1629. }
  1630. /**
  1631. * ib_dma_map_single - Map a kernel virtual address to DMA address
  1632. * @dev: The device for which the dma_addr is to be created
  1633. * @cpu_addr: The kernel virtual address
  1634. * @size: The size of the region in bytes
  1635. * @direction: The direction of the DMA
  1636. */
  1637. static inline u64 ib_dma_map_single(struct ib_device *dev,
  1638. void *cpu_addr, size_t size,
  1639. enum dma_data_direction direction)
  1640. {
  1641. if (dev->dma_ops)
  1642. return dev->dma_ops->map_single(dev, cpu_addr, size, direction);
  1643. return dma_map_single(dev->dma_device, cpu_addr, size, direction);
  1644. }
  1645. /**
  1646. * ib_dma_unmap_single - Destroy a mapping created by ib_dma_map_single()
  1647. * @dev: The device for which the DMA address was created
  1648. * @addr: The DMA address
  1649. * @size: The size of the region in bytes
  1650. * @direction: The direction of the DMA
  1651. */
  1652. static inline void ib_dma_unmap_single(struct ib_device *dev,
  1653. u64 addr, size_t size,
  1654. enum dma_data_direction direction)
  1655. {
  1656. if (dev->dma_ops)
  1657. dev->dma_ops->unmap_single(dev, addr, size, direction);
  1658. else
  1659. dma_unmap_single(dev->dma_device, addr, size, direction);
  1660. }
  1661. static inline u64 ib_dma_map_single_attrs(struct ib_device *dev,
  1662. void *cpu_addr, size_t size,
  1663. enum dma_data_direction direction,
  1664. struct dma_attrs *attrs)
  1665. {
  1666. return dma_map_single_attrs(dev->dma_device, cpu_addr, size,
  1667. direction, attrs);
  1668. }
  1669. static inline void ib_dma_unmap_single_attrs(struct ib_device *dev,
  1670. u64 addr, size_t size,
  1671. enum dma_data_direction direction,
  1672. struct dma_attrs *attrs)
  1673. {
  1674. return dma_unmap_single_attrs(dev->dma_device, addr, size,
  1675. direction, attrs);
  1676. }
  1677. /**
  1678. * ib_dma_map_page - Map a physical page to DMA address
  1679. * @dev: The device for which the dma_addr is to be created
  1680. * @page: The page to be mapped
  1681. * @offset: The offset within the page
  1682. * @size: The size of the region in bytes
  1683. * @direction: The direction of the DMA
  1684. */
  1685. static inline u64 ib_dma_map_page(struct ib_device *dev,
  1686. struct page *page,
  1687. unsigned long offset,
  1688. size_t size,
  1689. enum dma_data_direction direction)
  1690. {
  1691. if (dev->dma_ops)
  1692. return dev->dma_ops->map_page(dev, page, offset, size, direction);
  1693. return dma_map_page(dev->dma_device, page, offset, size, direction);
  1694. }
  1695. /**
  1696. * ib_dma_unmap_page - Destroy a mapping created by ib_dma_map_page()
  1697. * @dev: The device for which the DMA address was created
  1698. * @addr: The DMA address
  1699. * @size: The size of the region in bytes
  1700. * @direction: The direction of the DMA
  1701. */
  1702. static inline void ib_dma_unmap_page(struct ib_device *dev,
  1703. u64 addr, size_t size,
  1704. enum dma_data_direction direction)
  1705. {
  1706. if (dev->dma_ops)
  1707. dev->dma_ops->unmap_page(dev, addr, size, direction);
  1708. else
  1709. dma_unmap_page(dev->dma_device, addr, size, direction);
  1710. }
  1711. /**
  1712. * ib_dma_map_sg - Map a scatter/gather list to DMA addresses
  1713. * @dev: The device for which the DMA addresses are to be created
  1714. * @sg: The array of scatter/gather entries
  1715. * @nents: The number of scatter/gather entries
  1716. * @direction: The direction of the DMA
  1717. */
  1718. static inline int ib_dma_map_sg(struct ib_device *dev,
  1719. struct scatterlist *sg, int nents,
  1720. enum dma_data_direction direction)
  1721. {
  1722. if (dev->dma_ops)
  1723. return dev->dma_ops->map_sg(dev, sg, nents, direction);
  1724. return dma_map_sg(dev->dma_device, sg, nents, direction);
  1725. }
  1726. /**
  1727. * ib_dma_unmap_sg - Unmap a scatter/gather list of DMA addresses
  1728. * @dev: The device for which the DMA addresses were created
  1729. * @sg: The array of scatter/gather entries
  1730. * @nents: The number of scatter/gather entries
  1731. * @direction: The direction of the DMA
  1732. */
  1733. static inline void ib_dma_unmap_sg(struct ib_device *dev,
  1734. struct scatterlist *sg, int nents,
  1735. enum dma_data_direction direction)
  1736. {
  1737. if (dev->dma_ops)
  1738. dev->dma_ops->unmap_sg(dev, sg, nents, direction);
  1739. else
  1740. dma_unmap_sg(dev->dma_device, sg, nents, direction);
  1741. }
  1742. static inline int ib_dma_map_sg_attrs(struct ib_device *dev,
  1743. struct scatterlist *sg, int nents,
  1744. enum dma_data_direction direction,
  1745. struct dma_attrs *attrs)
  1746. {
  1747. return dma_map_sg_attrs(dev->dma_device, sg, nents, direction, attrs);
  1748. }
  1749. static inline void ib_dma_unmap_sg_attrs(struct ib_device *dev,
  1750. struct scatterlist *sg, int nents,
  1751. enum dma_data_direction direction,
  1752. struct dma_attrs *attrs)
  1753. {
  1754. dma_unmap_sg_attrs(dev->dma_device, sg, nents, direction, attrs);
  1755. }
  1756. /**
  1757. * ib_sg_dma_address - Return the DMA address from a scatter/gather entry
  1758. * @dev: The device for which the DMA addresses were created
  1759. * @sg: The scatter/gather entry
  1760. */
  1761. static inline u64 ib_sg_dma_address(struct ib_device *dev,
  1762. struct scatterlist *sg)
  1763. {
  1764. if (dev->dma_ops)
  1765. return dev->dma_ops->dma_address(dev, sg);
  1766. return sg_dma_address(sg);
  1767. }
  1768. /**
  1769. * ib_sg_dma_len - Return the DMA length from a scatter/gather entry
  1770. * @dev: The device for which the DMA addresses were created
  1771. * @sg: The scatter/gather entry
  1772. */
  1773. static inline unsigned int ib_sg_dma_len(struct ib_device *dev,
  1774. struct scatterlist *sg)
  1775. {
  1776. if (dev->dma_ops)
  1777. return dev->dma_ops->dma_len(dev, sg);
  1778. return sg_dma_len(sg);
  1779. }
  1780. /**
  1781. * ib_dma_sync_single_for_cpu - Prepare DMA region to be accessed by CPU
  1782. * @dev: The device for which the DMA address was created
  1783. * @addr: The DMA address
  1784. * @size: The size of the region in bytes
  1785. * @dir: The direction of the DMA
  1786. */
  1787. static inline void ib_dma_sync_single_for_cpu(struct ib_device *dev,
  1788. u64 addr,
  1789. size_t size,
  1790. enum dma_data_direction dir)
  1791. {
  1792. if (dev->dma_ops)
  1793. dev->dma_ops->sync_single_for_cpu(dev, addr, size, dir);
  1794. else
  1795. dma_sync_single_for_cpu(dev->dma_device, addr, size, dir);
  1796. }
  1797. /**
  1798. * ib_dma_sync_single_for_device - Prepare DMA region to be accessed by device
  1799. * @dev: The device for which the DMA address was created
  1800. * @addr: The DMA address
  1801. * @size: The size of the region in bytes
  1802. * @dir: The direction of the DMA
  1803. */
  1804. static inline void ib_dma_sync_single_for_device(struct ib_device *dev,
  1805. u64 addr,
  1806. size_t size,
  1807. enum dma_data_direction dir)
  1808. {
  1809. if (dev->dma_ops)
  1810. dev->dma_ops->sync_single_for_device(dev, addr, size, dir);
  1811. else
  1812. dma_sync_single_for_device(dev->dma_device, addr, size, dir);
  1813. }
  1814. /**
  1815. * ib_dma_alloc_coherent - Allocate memory and map it for DMA
  1816. * @dev: The device for which the DMA address is requested
  1817. * @size: The size of the region to allocate in bytes
  1818. * @dma_handle: A pointer for returning the DMA address of the region
  1819. * @flag: memory allocator flags
  1820. */
  1821. static inline void *ib_dma_alloc_coherent(struct ib_device *dev,
  1822. size_t size,
  1823. u64 *dma_handle,
  1824. gfp_t flag)
  1825. {
  1826. if (dev->dma_ops)
  1827. return dev->dma_ops->alloc_coherent(dev, size, dma_handle, flag);
  1828. else {
  1829. dma_addr_t handle;
  1830. void *ret;
  1831. ret = dma_alloc_coherent(dev->dma_device, size, &handle, flag);
  1832. *dma_handle = handle;
  1833. return ret;
  1834. }
  1835. }
  1836. /**
  1837. * ib_dma_free_coherent - Free memory allocated by ib_dma_alloc_coherent()
  1838. * @dev: The device for which the DMA addresses were allocated
  1839. * @size: The size of the region
  1840. * @cpu_addr: the address returned by ib_dma_alloc_coherent()
  1841. * @dma_handle: the DMA address returned by ib_dma_alloc_coherent()
  1842. */
  1843. static inline void ib_dma_free_coherent(struct ib_device *dev,
  1844. size_t size, void *cpu_addr,
  1845. u64 dma_handle)
  1846. {
  1847. if (dev->dma_ops)
  1848. dev->dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
  1849. else
  1850. dma_free_coherent(dev->dma_device, size, cpu_addr, dma_handle);
  1851. }
  1852. /**
  1853. * ib_reg_phys_mr - Prepares a virtually addressed memory region for use
  1854. * by an HCA.
  1855. * @pd: The protection domain associated assigned to the registered region.
  1856. * @phys_buf_array: Specifies a list of physical buffers to use in the
  1857. * memory region.
  1858. * @num_phys_buf: Specifies the size of the phys_buf_array.
  1859. * @mr_access_flags: Specifies the memory access rights.
  1860. * @iova_start: The offset of the region's starting I/O virtual address.
  1861. */
  1862. struct ib_mr *ib_reg_phys_mr(struct ib_pd *pd,
  1863. struct ib_phys_buf *phys_buf_array,
  1864. int num_phys_buf,
  1865. int mr_access_flags,
  1866. u64 *iova_start);
  1867. /**
  1868. * ib_rereg_phys_mr - Modifies the attributes of an existing memory region.
  1869. * Conceptually, this call performs the functions deregister memory region
  1870. * followed by register physical memory region. Where possible,
  1871. * resources are reused instead of deallocated and reallocated.
  1872. * @mr: The memory region to modify.
  1873. * @mr_rereg_mask: A bit-mask used to indicate which of the following
  1874. * properties of the memory region are being modified.
  1875. * @pd: If %IB_MR_REREG_PD is set in mr_rereg_mask, this field specifies
  1876. * the new protection domain to associated with the memory region,
  1877. * otherwise, this parameter is ignored.
  1878. * @phys_buf_array: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
  1879. * field specifies a list of physical buffers to use in the new
  1880. * translation, otherwise, this parameter is ignored.
  1881. * @num_phys_buf: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
  1882. * field specifies the size of the phys_buf_array, otherwise, this
  1883. * parameter is ignored.
  1884. * @mr_access_flags: If %IB_MR_REREG_ACCESS is set in mr_rereg_mask, this
  1885. * field specifies the new memory access rights, otherwise, this
  1886. * parameter is ignored.
  1887. * @iova_start: The offset of the region's starting I/O virtual address.
  1888. */
  1889. int ib_rereg_phys_mr(struct ib_mr *mr,
  1890. int mr_rereg_mask,
  1891. struct ib_pd *pd,
  1892. struct ib_phys_buf *phys_buf_array,
  1893. int num_phys_buf,
  1894. int mr_access_flags,
  1895. u64 *iova_start);
  1896. /**
  1897. * ib_query_mr - Retrieves information about a specific memory region.
  1898. * @mr: The memory region to retrieve information about.
  1899. * @mr_attr: The attributes of the specified memory region.
  1900. */
  1901. int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr);
  1902. /**
  1903. * ib_dereg_mr - Deregisters a memory region and removes it from the
  1904. * HCA translation table.
  1905. * @mr: The memory region to deregister.
  1906. *
  1907. * This function can fail, if the memory region has memory windows bound to it.
  1908. */
  1909. int ib_dereg_mr(struct ib_mr *mr);
  1910. /**
  1911. * ib_alloc_fast_reg_mr - Allocates memory region usable with the
  1912. * IB_WR_FAST_REG_MR send work request.
  1913. * @pd: The protection domain associated with the region.
  1914. * @max_page_list_len: requested max physical buffer list length to be
  1915. * used with fast register work requests for this MR.
  1916. */
  1917. struct ib_mr *ib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len);
  1918. /**
  1919. * ib_alloc_fast_reg_page_list - Allocates a page list array
  1920. * @device - ib device pointer.
  1921. * @page_list_len - size of the page list array to be allocated.
  1922. *
  1923. * This allocates and returns a struct ib_fast_reg_page_list * and a
  1924. * page_list array that is at least page_list_len in size. The actual
  1925. * size is returned in max_page_list_len. The caller is responsible
  1926. * for initializing the contents of the page_list array before posting
  1927. * a send work request with the IB_WC_FAST_REG_MR opcode.
  1928. *
  1929. * The page_list array entries must be translated using one of the
  1930. * ib_dma_*() functions just like the addresses passed to
  1931. * ib_map_phys_fmr(). Once the ib_post_send() is issued, the struct
  1932. * ib_fast_reg_page_list must not be modified by the caller until the
  1933. * IB_WC_FAST_REG_MR work request completes.
  1934. */
  1935. struct ib_fast_reg_page_list *ib_alloc_fast_reg_page_list(
  1936. struct ib_device *device, int page_list_len);
  1937. /**
  1938. * ib_free_fast_reg_page_list - Deallocates a previously allocated
  1939. * page list array.
  1940. * @page_list - struct ib_fast_reg_page_list pointer to be deallocated.
  1941. */
  1942. void ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list);
  1943. /**
  1944. * ib_update_fast_reg_key - updates the key portion of the fast_reg MR
  1945. * R_Key and L_Key.
  1946. * @mr - struct ib_mr pointer to be updated.
  1947. * @newkey - new key to be used.
  1948. */
  1949. static inline void ib_update_fast_reg_key(struct ib_mr *mr, u8 newkey)
  1950. {
  1951. mr->lkey = (mr->lkey & 0xffffff00) | newkey;
  1952. mr->rkey = (mr->rkey & 0xffffff00) | newkey;
  1953. }
  1954. /**
  1955. * ib_inc_rkey - increments the key portion of the given rkey. Can be used
  1956. * for calculating a new rkey for type 2 memory windows.
  1957. * @rkey - the rkey to increment.
  1958. */
  1959. static inline u32 ib_inc_rkey(u32 rkey)
  1960. {
  1961. const u32 mask = 0x000000ff;
  1962. return ((rkey + 1) & mask) | (rkey & ~mask);
  1963. }
  1964. /**
  1965. * ib_alloc_mw - Allocates a memory window.
  1966. * @pd: The protection domain associated with the memory window.
  1967. * @type: The type of the memory window (1 or 2).
  1968. */
  1969. struct ib_mw *ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type);
  1970. /**
  1971. * ib_bind_mw - Posts a work request to the send queue of the specified
  1972. * QP, which binds the memory window to the given address range and
  1973. * remote access attributes.
  1974. * @qp: QP to post the bind work request on.
  1975. * @mw: The memory window to bind.
  1976. * @mw_bind: Specifies information about the memory window, including
  1977. * its address range, remote access rights, and associated memory region.
  1978. *
  1979. * If there is no immediate error, the function will update the rkey member
  1980. * of the mw parameter to its new value. The bind operation can still fail
  1981. * asynchronously.
  1982. */
  1983. static inline int ib_bind_mw(struct ib_qp *qp,
  1984. struct ib_mw *mw,
  1985. struct ib_mw_bind *mw_bind)
  1986. {
  1987. /* XXX reference counting in corresponding MR? */
  1988. return mw->device->bind_mw ?
  1989. mw->device->bind_mw(qp, mw, mw_bind) :
  1990. -ENOSYS;
  1991. }
  1992. /**
  1993. * ib_dealloc_mw - Deallocates a memory window.
  1994. * @mw: The memory window to deallocate.
  1995. */
  1996. int ib_dealloc_mw(struct ib_mw *mw);
  1997. /**
  1998. * ib_alloc_fmr - Allocates a unmapped fast memory region.
  1999. * @pd: The protection domain associated with the unmapped region.
  2000. * @mr_access_flags: Specifies the memory access rights.
  2001. * @fmr_attr: Attributes of the unmapped region.
  2002. *
  2003. * A fast memory region must be mapped before it can be used as part of
  2004. * a work request.
  2005. */
  2006. struct ib_fmr *ib_alloc_fmr(struct ib_pd *pd,
  2007. int mr_access_flags,
  2008. struct ib_fmr_attr *fmr_attr);
  2009. /**
  2010. * ib_map_phys_fmr - Maps a list of physical pages to a fast memory region.
  2011. * @fmr: The fast memory region to associate with the pages.
  2012. * @page_list: An array of physical pages to map to the fast memory region.
  2013. * @list_len: The number of pages in page_list.
  2014. * @iova: The I/O virtual address to use with the mapped region.
  2015. */
  2016. static inline int ib_map_phys_fmr(struct ib_fmr *fmr,
  2017. u64 *page_list, int list_len,
  2018. u64 iova)
  2019. {
  2020. return fmr->device->map_phys_fmr(fmr, page_list, list_len, iova);
  2021. }
  2022. /**
  2023. * ib_unmap_fmr - Removes the mapping from a list of fast memory regions.
  2024. * @fmr_list: A linked list of fast memory regions to unmap.
  2025. */
  2026. int ib_unmap_fmr(struct list_head *fmr_list);
  2027. /**
  2028. * ib_dealloc_fmr - Deallocates a fast memory region.
  2029. * @fmr: The fast memory region to deallocate.
  2030. */
  2031. int ib_dealloc_fmr(struct ib_fmr *fmr);
  2032. /**
  2033. * ib_attach_mcast - Attaches the specified QP to a multicast group.
  2034. * @qp: QP to attach to the multicast group. The QP must be type
  2035. * IB_QPT_UD.
  2036. * @gid: Multicast group GID.
  2037. * @lid: Multicast group LID in host byte order.
  2038. *
  2039. * In order to send and receive multicast packets, subnet
  2040. * administration must have created the multicast group and configured
  2041. * the fabric appropriately. The port associated with the specified
  2042. * QP must also be a member of the multicast group.
  2043. */
  2044. int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
  2045. /**
  2046. * ib_detach_mcast - Detaches the specified QP from a multicast group.
  2047. * @qp: QP to detach from the multicast group.
  2048. * @gid: Multicast group GID.
  2049. * @lid: Multicast group LID in host byte order.
  2050. */
  2051. int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
  2052. /**
  2053. * ib_alloc_xrcd - Allocates an XRC domain.
  2054. * @device: The device on which to allocate the XRC domain.
  2055. */
  2056. struct ib_xrcd *ib_alloc_xrcd(struct ib_device *device);
  2057. /**
  2058. * ib_dealloc_xrcd - Deallocates an XRC domain.
  2059. * @xrcd: The XRC domain to deallocate.
  2060. */
  2061. int ib_dealloc_xrcd(struct ib_xrcd *xrcd);
  2062. #endif /* IB_VERBS_H */