ib_verbs.h 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252
  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. *
  8. * This software is available to you under a choice of one of two
  9. * licenses. You may choose to be licensed under the terms of the GNU
  10. * General Public License (GPL) Version 2, available from the file
  11. * COPYING in the main directory of this source tree, or the
  12. * OpenIB.org BSD license below:
  13. *
  14. * Redistribution and use in source and binary forms, with or
  15. * without modification, are permitted provided that the following
  16. * conditions are met:
  17. *
  18. * - Redistributions of source code must retain the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer.
  21. *
  22. * - Redistributions in binary form must reproduce the above
  23. * copyright notice, this list of conditions and the following
  24. * disclaimer in the documentation and/or other materials
  25. * provided with the distribution.
  26. *
  27. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  28. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  29. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  30. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  31. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  32. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  33. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  34. * SOFTWARE.
  35. *
  36. * $Id: ib_verbs.h 1349 2004-12-16 21:09:43Z roland $
  37. */
  38. #if !defined(IB_VERBS_H)
  39. #define IB_VERBS_H
  40. #include <linux/types.h>
  41. #include <linux/device.h>
  42. #include <asm/atomic.h>
  43. union ib_gid {
  44. u8 raw[16];
  45. struct {
  46. u64 subnet_prefix;
  47. u64 interface_id;
  48. } global;
  49. };
  50. enum ib_node_type {
  51. IB_NODE_CA = 1,
  52. IB_NODE_SWITCH,
  53. IB_NODE_ROUTER
  54. };
  55. enum ib_device_cap_flags {
  56. IB_DEVICE_RESIZE_MAX_WR = 1,
  57. IB_DEVICE_BAD_PKEY_CNTR = (1<<1),
  58. IB_DEVICE_BAD_QKEY_CNTR = (1<<2),
  59. IB_DEVICE_RAW_MULTI = (1<<3),
  60. IB_DEVICE_AUTO_PATH_MIG = (1<<4),
  61. IB_DEVICE_CHANGE_PHY_PORT = (1<<5),
  62. IB_DEVICE_UD_AV_PORT_ENFORCE = (1<<6),
  63. IB_DEVICE_CURR_QP_STATE_MOD = (1<<7),
  64. IB_DEVICE_SHUTDOWN_PORT = (1<<8),
  65. IB_DEVICE_INIT_TYPE = (1<<9),
  66. IB_DEVICE_PORT_ACTIVE_EVENT = (1<<10),
  67. IB_DEVICE_SYS_IMAGE_GUID = (1<<11),
  68. IB_DEVICE_RC_RNR_NAK_GEN = (1<<12),
  69. IB_DEVICE_SRQ_RESIZE = (1<<13),
  70. IB_DEVICE_N_NOTIFY_CQ = (1<<14),
  71. };
  72. enum ib_atomic_cap {
  73. IB_ATOMIC_NONE,
  74. IB_ATOMIC_HCA,
  75. IB_ATOMIC_GLOB
  76. };
  77. struct ib_device_attr {
  78. u64 fw_ver;
  79. u64 node_guid;
  80. u64 sys_image_guid;
  81. u64 max_mr_size;
  82. u64 page_size_cap;
  83. u32 vendor_id;
  84. u32 vendor_part_id;
  85. u32 hw_ver;
  86. int max_qp;
  87. int max_qp_wr;
  88. int device_cap_flags;
  89. int max_sge;
  90. int max_sge_rd;
  91. int max_cq;
  92. int max_cqe;
  93. int max_mr;
  94. int max_pd;
  95. int max_qp_rd_atom;
  96. int max_ee_rd_atom;
  97. int max_res_rd_atom;
  98. int max_qp_init_rd_atom;
  99. int max_ee_init_rd_atom;
  100. enum ib_atomic_cap atomic_cap;
  101. int max_ee;
  102. int max_rdd;
  103. int max_mw;
  104. int max_raw_ipv6_qp;
  105. int max_raw_ethy_qp;
  106. int max_mcast_grp;
  107. int max_mcast_qp_attach;
  108. int max_total_mcast_qp_attach;
  109. int max_ah;
  110. int max_fmr;
  111. int max_map_per_fmr;
  112. int max_srq;
  113. int max_srq_wr;
  114. int max_srq_sge;
  115. u16 max_pkeys;
  116. u8 local_ca_ack_delay;
  117. };
  118. enum ib_mtu {
  119. IB_MTU_256 = 1,
  120. IB_MTU_512 = 2,
  121. IB_MTU_1024 = 3,
  122. IB_MTU_2048 = 4,
  123. IB_MTU_4096 = 5
  124. };
  125. static inline int ib_mtu_enum_to_int(enum ib_mtu mtu)
  126. {
  127. switch (mtu) {
  128. case IB_MTU_256: return 256;
  129. case IB_MTU_512: return 512;
  130. case IB_MTU_1024: return 1024;
  131. case IB_MTU_2048: return 2048;
  132. case IB_MTU_4096: return 4096;
  133. default: return -1;
  134. }
  135. }
  136. enum ib_port_state {
  137. IB_PORT_NOP = 0,
  138. IB_PORT_DOWN = 1,
  139. IB_PORT_INIT = 2,
  140. IB_PORT_ARMED = 3,
  141. IB_PORT_ACTIVE = 4,
  142. IB_PORT_ACTIVE_DEFER = 5
  143. };
  144. enum ib_port_cap_flags {
  145. IB_PORT_SM = 1 << 1,
  146. IB_PORT_NOTICE_SUP = 1 << 2,
  147. IB_PORT_TRAP_SUP = 1 << 3,
  148. IB_PORT_OPT_IPD_SUP = 1 << 4,
  149. IB_PORT_AUTO_MIGR_SUP = 1 << 5,
  150. IB_PORT_SL_MAP_SUP = 1 << 6,
  151. IB_PORT_MKEY_NVRAM = 1 << 7,
  152. IB_PORT_PKEY_NVRAM = 1 << 8,
  153. IB_PORT_LED_INFO_SUP = 1 << 9,
  154. IB_PORT_SM_DISABLED = 1 << 10,
  155. IB_PORT_SYS_IMAGE_GUID_SUP = 1 << 11,
  156. IB_PORT_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12,
  157. IB_PORT_CM_SUP = 1 << 16,
  158. IB_PORT_SNMP_TUNNEL_SUP = 1 << 17,
  159. IB_PORT_REINIT_SUP = 1 << 18,
  160. IB_PORT_DEVICE_MGMT_SUP = 1 << 19,
  161. IB_PORT_VENDOR_CLASS_SUP = 1 << 20,
  162. IB_PORT_DR_NOTICE_SUP = 1 << 21,
  163. IB_PORT_CAP_MASK_NOTICE_SUP = 1 << 22,
  164. IB_PORT_BOOT_MGMT_SUP = 1 << 23,
  165. IB_PORT_LINK_LATENCY_SUP = 1 << 24,
  166. IB_PORT_CLIENT_REG_SUP = 1 << 25
  167. };
  168. enum ib_port_width {
  169. IB_WIDTH_1X = 1,
  170. IB_WIDTH_4X = 2,
  171. IB_WIDTH_8X = 4,
  172. IB_WIDTH_12X = 8
  173. };
  174. static inline int ib_width_enum_to_int(enum ib_port_width width)
  175. {
  176. switch (width) {
  177. case IB_WIDTH_1X: return 1;
  178. case IB_WIDTH_4X: return 4;
  179. case IB_WIDTH_8X: return 8;
  180. case IB_WIDTH_12X: return 12;
  181. default: return -1;
  182. }
  183. }
  184. struct ib_port_attr {
  185. enum ib_port_state state;
  186. enum ib_mtu max_mtu;
  187. enum ib_mtu active_mtu;
  188. int gid_tbl_len;
  189. u32 port_cap_flags;
  190. u32 max_msg_sz;
  191. u32 bad_pkey_cntr;
  192. u32 qkey_viol_cntr;
  193. u16 pkey_tbl_len;
  194. u16 lid;
  195. u16 sm_lid;
  196. u8 lmc;
  197. u8 max_vl_num;
  198. u8 sm_sl;
  199. u8 subnet_timeout;
  200. u8 init_type_reply;
  201. u8 active_width;
  202. u8 active_speed;
  203. u8 phys_state;
  204. };
  205. enum ib_device_modify_flags {
  206. IB_DEVICE_MODIFY_SYS_IMAGE_GUID = 1
  207. };
  208. struct ib_device_modify {
  209. u64 sys_image_guid;
  210. };
  211. enum ib_port_modify_flags {
  212. IB_PORT_SHUTDOWN = 1,
  213. IB_PORT_INIT_TYPE = (1<<2),
  214. IB_PORT_RESET_QKEY_CNTR = (1<<3)
  215. };
  216. struct ib_port_modify {
  217. u32 set_port_cap_mask;
  218. u32 clr_port_cap_mask;
  219. u8 init_type;
  220. };
  221. enum ib_event_type {
  222. IB_EVENT_CQ_ERR,
  223. IB_EVENT_QP_FATAL,
  224. IB_EVENT_QP_REQ_ERR,
  225. IB_EVENT_QP_ACCESS_ERR,
  226. IB_EVENT_COMM_EST,
  227. IB_EVENT_SQ_DRAINED,
  228. IB_EVENT_PATH_MIG,
  229. IB_EVENT_PATH_MIG_ERR,
  230. IB_EVENT_DEVICE_FATAL,
  231. IB_EVENT_PORT_ACTIVE,
  232. IB_EVENT_PORT_ERR,
  233. IB_EVENT_LID_CHANGE,
  234. IB_EVENT_PKEY_CHANGE,
  235. IB_EVENT_SM_CHANGE
  236. };
  237. struct ib_event {
  238. struct ib_device *device;
  239. union {
  240. struct ib_cq *cq;
  241. struct ib_qp *qp;
  242. u8 port_num;
  243. } element;
  244. enum ib_event_type event;
  245. };
  246. struct ib_event_handler {
  247. struct ib_device *device;
  248. void (*handler)(struct ib_event_handler *, struct ib_event *);
  249. struct list_head list;
  250. };
  251. #define INIT_IB_EVENT_HANDLER(_ptr, _device, _handler) \
  252. do { \
  253. (_ptr)->device = _device; \
  254. (_ptr)->handler = _handler; \
  255. INIT_LIST_HEAD(&(_ptr)->list); \
  256. } while (0)
  257. struct ib_global_route {
  258. union ib_gid dgid;
  259. u32 flow_label;
  260. u8 sgid_index;
  261. u8 hop_limit;
  262. u8 traffic_class;
  263. };
  264. enum {
  265. IB_MULTICAST_QPN = 0xffffff
  266. };
  267. enum ib_ah_flags {
  268. IB_AH_GRH = 1
  269. };
  270. struct ib_ah_attr {
  271. struct ib_global_route grh;
  272. u16 dlid;
  273. u8 sl;
  274. u8 src_path_bits;
  275. u8 static_rate;
  276. u8 ah_flags;
  277. u8 port_num;
  278. };
  279. enum ib_wc_status {
  280. IB_WC_SUCCESS,
  281. IB_WC_LOC_LEN_ERR,
  282. IB_WC_LOC_QP_OP_ERR,
  283. IB_WC_LOC_EEC_OP_ERR,
  284. IB_WC_LOC_PROT_ERR,
  285. IB_WC_WR_FLUSH_ERR,
  286. IB_WC_MW_BIND_ERR,
  287. IB_WC_BAD_RESP_ERR,
  288. IB_WC_LOC_ACCESS_ERR,
  289. IB_WC_REM_INV_REQ_ERR,
  290. IB_WC_REM_ACCESS_ERR,
  291. IB_WC_REM_OP_ERR,
  292. IB_WC_RETRY_EXC_ERR,
  293. IB_WC_RNR_RETRY_EXC_ERR,
  294. IB_WC_LOC_RDD_VIOL_ERR,
  295. IB_WC_REM_INV_RD_REQ_ERR,
  296. IB_WC_REM_ABORT_ERR,
  297. IB_WC_INV_EECN_ERR,
  298. IB_WC_INV_EEC_STATE_ERR,
  299. IB_WC_FATAL_ERR,
  300. IB_WC_RESP_TIMEOUT_ERR,
  301. IB_WC_GENERAL_ERR
  302. };
  303. enum ib_wc_opcode {
  304. IB_WC_SEND,
  305. IB_WC_RDMA_WRITE,
  306. IB_WC_RDMA_READ,
  307. IB_WC_COMP_SWAP,
  308. IB_WC_FETCH_ADD,
  309. IB_WC_BIND_MW,
  310. /*
  311. * Set value of IB_WC_RECV so consumers can test if a completion is a
  312. * receive by testing (opcode & IB_WC_RECV).
  313. */
  314. IB_WC_RECV = 1 << 7,
  315. IB_WC_RECV_RDMA_WITH_IMM
  316. };
  317. enum ib_wc_flags {
  318. IB_WC_GRH = 1,
  319. IB_WC_WITH_IMM = (1<<1)
  320. };
  321. struct ib_wc {
  322. u64 wr_id;
  323. enum ib_wc_status status;
  324. enum ib_wc_opcode opcode;
  325. u32 vendor_err;
  326. u32 byte_len;
  327. __be32 imm_data;
  328. u32 qp_num;
  329. u32 src_qp;
  330. int wc_flags;
  331. u16 pkey_index;
  332. u16 slid;
  333. u8 sl;
  334. u8 dlid_path_bits;
  335. u8 port_num; /* valid only for DR SMPs on switches */
  336. };
  337. enum ib_cq_notify {
  338. IB_CQ_SOLICITED,
  339. IB_CQ_NEXT_COMP
  340. };
  341. struct ib_qp_cap {
  342. u32 max_send_wr;
  343. u32 max_recv_wr;
  344. u32 max_send_sge;
  345. u32 max_recv_sge;
  346. u32 max_inline_data;
  347. };
  348. enum ib_sig_type {
  349. IB_SIGNAL_ALL_WR,
  350. IB_SIGNAL_REQ_WR
  351. };
  352. enum ib_qp_type {
  353. /*
  354. * IB_QPT_SMI and IB_QPT_GSI have to be the first two entries
  355. * here (and in that order) since the MAD layer uses them as
  356. * indices into a 2-entry table.
  357. */
  358. IB_QPT_SMI,
  359. IB_QPT_GSI,
  360. IB_QPT_RC,
  361. IB_QPT_UC,
  362. IB_QPT_UD,
  363. IB_QPT_RAW_IPV6,
  364. IB_QPT_RAW_ETY
  365. };
  366. struct ib_qp_init_attr {
  367. void (*event_handler)(struct ib_event *, void *);
  368. void *qp_context;
  369. struct ib_cq *send_cq;
  370. struct ib_cq *recv_cq;
  371. struct ib_srq *srq;
  372. struct ib_qp_cap cap;
  373. enum ib_sig_type sq_sig_type;
  374. enum ib_qp_type qp_type;
  375. u8 port_num; /* special QP types only */
  376. };
  377. enum ib_rnr_timeout {
  378. IB_RNR_TIMER_655_36 = 0,
  379. IB_RNR_TIMER_000_01 = 1,
  380. IB_RNR_TIMER_000_02 = 2,
  381. IB_RNR_TIMER_000_03 = 3,
  382. IB_RNR_TIMER_000_04 = 4,
  383. IB_RNR_TIMER_000_06 = 5,
  384. IB_RNR_TIMER_000_08 = 6,
  385. IB_RNR_TIMER_000_12 = 7,
  386. IB_RNR_TIMER_000_16 = 8,
  387. IB_RNR_TIMER_000_24 = 9,
  388. IB_RNR_TIMER_000_32 = 10,
  389. IB_RNR_TIMER_000_48 = 11,
  390. IB_RNR_TIMER_000_64 = 12,
  391. IB_RNR_TIMER_000_96 = 13,
  392. IB_RNR_TIMER_001_28 = 14,
  393. IB_RNR_TIMER_001_92 = 15,
  394. IB_RNR_TIMER_002_56 = 16,
  395. IB_RNR_TIMER_003_84 = 17,
  396. IB_RNR_TIMER_005_12 = 18,
  397. IB_RNR_TIMER_007_68 = 19,
  398. IB_RNR_TIMER_010_24 = 20,
  399. IB_RNR_TIMER_015_36 = 21,
  400. IB_RNR_TIMER_020_48 = 22,
  401. IB_RNR_TIMER_030_72 = 23,
  402. IB_RNR_TIMER_040_96 = 24,
  403. IB_RNR_TIMER_061_44 = 25,
  404. IB_RNR_TIMER_081_92 = 26,
  405. IB_RNR_TIMER_122_88 = 27,
  406. IB_RNR_TIMER_163_84 = 28,
  407. IB_RNR_TIMER_245_76 = 29,
  408. IB_RNR_TIMER_327_68 = 30,
  409. IB_RNR_TIMER_491_52 = 31
  410. };
  411. enum ib_qp_attr_mask {
  412. IB_QP_STATE = 1,
  413. IB_QP_CUR_STATE = (1<<1),
  414. IB_QP_EN_SQD_ASYNC_NOTIFY = (1<<2),
  415. IB_QP_ACCESS_FLAGS = (1<<3),
  416. IB_QP_PKEY_INDEX = (1<<4),
  417. IB_QP_PORT = (1<<5),
  418. IB_QP_QKEY = (1<<6),
  419. IB_QP_AV = (1<<7),
  420. IB_QP_PATH_MTU = (1<<8),
  421. IB_QP_TIMEOUT = (1<<9),
  422. IB_QP_RETRY_CNT = (1<<10),
  423. IB_QP_RNR_RETRY = (1<<11),
  424. IB_QP_RQ_PSN = (1<<12),
  425. IB_QP_MAX_QP_RD_ATOMIC = (1<<13),
  426. IB_QP_ALT_PATH = (1<<14),
  427. IB_QP_MIN_RNR_TIMER = (1<<15),
  428. IB_QP_SQ_PSN = (1<<16),
  429. IB_QP_MAX_DEST_RD_ATOMIC = (1<<17),
  430. IB_QP_PATH_MIG_STATE = (1<<18),
  431. IB_QP_CAP = (1<<19),
  432. IB_QP_DEST_QPN = (1<<20)
  433. };
  434. enum ib_qp_state {
  435. IB_QPS_RESET,
  436. IB_QPS_INIT,
  437. IB_QPS_RTR,
  438. IB_QPS_RTS,
  439. IB_QPS_SQD,
  440. IB_QPS_SQE,
  441. IB_QPS_ERR
  442. };
  443. enum ib_mig_state {
  444. IB_MIG_MIGRATED,
  445. IB_MIG_REARM,
  446. IB_MIG_ARMED
  447. };
  448. struct ib_qp_attr {
  449. enum ib_qp_state qp_state;
  450. enum ib_qp_state cur_qp_state;
  451. enum ib_mtu path_mtu;
  452. enum ib_mig_state path_mig_state;
  453. u32 qkey;
  454. u32 rq_psn;
  455. u32 sq_psn;
  456. u32 dest_qp_num;
  457. int qp_access_flags;
  458. struct ib_qp_cap cap;
  459. struct ib_ah_attr ah_attr;
  460. struct ib_ah_attr alt_ah_attr;
  461. u16 pkey_index;
  462. u16 alt_pkey_index;
  463. u8 en_sqd_async_notify;
  464. u8 sq_draining;
  465. u8 max_rd_atomic;
  466. u8 max_dest_rd_atomic;
  467. u8 min_rnr_timer;
  468. u8 port_num;
  469. u8 timeout;
  470. u8 retry_cnt;
  471. u8 rnr_retry;
  472. u8 alt_port_num;
  473. u8 alt_timeout;
  474. };
  475. enum ib_wr_opcode {
  476. IB_WR_RDMA_WRITE,
  477. IB_WR_RDMA_WRITE_WITH_IMM,
  478. IB_WR_SEND,
  479. IB_WR_SEND_WITH_IMM,
  480. IB_WR_RDMA_READ,
  481. IB_WR_ATOMIC_CMP_AND_SWP,
  482. IB_WR_ATOMIC_FETCH_AND_ADD
  483. };
  484. enum ib_send_flags {
  485. IB_SEND_FENCE = 1,
  486. IB_SEND_SIGNALED = (1<<1),
  487. IB_SEND_SOLICITED = (1<<2),
  488. IB_SEND_INLINE = (1<<3)
  489. };
  490. struct ib_sge {
  491. u64 addr;
  492. u32 length;
  493. u32 lkey;
  494. };
  495. struct ib_send_wr {
  496. struct ib_send_wr *next;
  497. u64 wr_id;
  498. struct ib_sge *sg_list;
  499. int num_sge;
  500. enum ib_wr_opcode opcode;
  501. int send_flags;
  502. u32 imm_data;
  503. union {
  504. struct {
  505. u64 remote_addr;
  506. u32 rkey;
  507. } rdma;
  508. struct {
  509. u64 remote_addr;
  510. u64 compare_add;
  511. u64 swap;
  512. u32 rkey;
  513. } atomic;
  514. struct {
  515. struct ib_ah *ah;
  516. struct ib_mad_hdr *mad_hdr;
  517. u32 remote_qpn;
  518. u32 remote_qkey;
  519. int timeout_ms; /* valid for MADs only */
  520. u16 pkey_index; /* valid for GSI only */
  521. u8 port_num; /* valid for DR SMPs on switch only */
  522. } ud;
  523. } wr;
  524. };
  525. struct ib_recv_wr {
  526. struct ib_recv_wr *next;
  527. u64 wr_id;
  528. struct ib_sge *sg_list;
  529. int num_sge;
  530. };
  531. enum ib_access_flags {
  532. IB_ACCESS_LOCAL_WRITE = 1,
  533. IB_ACCESS_REMOTE_WRITE = (1<<1),
  534. IB_ACCESS_REMOTE_READ = (1<<2),
  535. IB_ACCESS_REMOTE_ATOMIC = (1<<3),
  536. IB_ACCESS_MW_BIND = (1<<4)
  537. };
  538. struct ib_phys_buf {
  539. u64 addr;
  540. u64 size;
  541. };
  542. struct ib_mr_attr {
  543. struct ib_pd *pd;
  544. u64 device_virt_addr;
  545. u64 size;
  546. int mr_access_flags;
  547. u32 lkey;
  548. u32 rkey;
  549. };
  550. enum ib_mr_rereg_flags {
  551. IB_MR_REREG_TRANS = 1,
  552. IB_MR_REREG_PD = (1<<1),
  553. IB_MR_REREG_ACCESS = (1<<2)
  554. };
  555. struct ib_mw_bind {
  556. struct ib_mr *mr;
  557. u64 wr_id;
  558. u64 addr;
  559. u32 length;
  560. int send_flags;
  561. int mw_access_flags;
  562. };
  563. struct ib_fmr_attr {
  564. int max_pages;
  565. int max_maps;
  566. u8 page_size;
  567. };
  568. struct ib_pd {
  569. struct ib_device *device;
  570. atomic_t usecnt; /* count all resources */
  571. };
  572. struct ib_ah {
  573. struct ib_device *device;
  574. struct ib_pd *pd;
  575. };
  576. typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context);
  577. struct ib_cq {
  578. struct ib_device *device;
  579. ib_comp_handler comp_handler;
  580. void (*event_handler)(struct ib_event *, void *);
  581. void * cq_context;
  582. int cqe;
  583. atomic_t usecnt; /* count number of work queues */
  584. };
  585. struct ib_srq {
  586. struct ib_device *device;
  587. struct ib_pd *pd;
  588. void *srq_context;
  589. atomic_t usecnt;
  590. };
  591. struct ib_qp {
  592. struct ib_device *device;
  593. struct ib_pd *pd;
  594. struct ib_cq *send_cq;
  595. struct ib_cq *recv_cq;
  596. struct ib_srq *srq;
  597. void (*event_handler)(struct ib_event *, void *);
  598. void *qp_context;
  599. u32 qp_num;
  600. enum ib_qp_type qp_type;
  601. };
  602. struct ib_mr {
  603. struct ib_device *device;
  604. struct ib_pd *pd;
  605. u32 lkey;
  606. u32 rkey;
  607. atomic_t usecnt; /* count number of MWs */
  608. };
  609. struct ib_mw {
  610. struct ib_device *device;
  611. struct ib_pd *pd;
  612. u32 rkey;
  613. };
  614. struct ib_fmr {
  615. struct ib_device *device;
  616. struct ib_pd *pd;
  617. struct list_head list;
  618. u32 lkey;
  619. u32 rkey;
  620. };
  621. struct ib_mad;
  622. struct ib_grh;
  623. enum ib_process_mad_flags {
  624. IB_MAD_IGNORE_MKEY = 1,
  625. IB_MAD_IGNORE_BKEY = 2,
  626. IB_MAD_IGNORE_ALL = IB_MAD_IGNORE_MKEY | IB_MAD_IGNORE_BKEY
  627. };
  628. enum ib_mad_result {
  629. IB_MAD_RESULT_FAILURE = 0, /* (!SUCCESS is the important flag) */
  630. IB_MAD_RESULT_SUCCESS = 1 << 0, /* MAD was successfully processed */
  631. IB_MAD_RESULT_REPLY = 1 << 1, /* Reply packet needs to be sent */
  632. IB_MAD_RESULT_CONSUMED = 1 << 2 /* Packet consumed: stop processing */
  633. };
  634. #define IB_DEVICE_NAME_MAX 64
  635. struct ib_cache {
  636. rwlock_t lock;
  637. struct ib_event_handler event_handler;
  638. struct ib_pkey_cache **pkey_cache;
  639. struct ib_gid_cache **gid_cache;
  640. };
  641. struct ib_device {
  642. struct device *dma_device;
  643. char name[IB_DEVICE_NAME_MAX];
  644. struct list_head event_handler_list;
  645. spinlock_t event_handler_lock;
  646. struct list_head core_list;
  647. struct list_head client_data_list;
  648. spinlock_t client_data_lock;
  649. struct ib_cache cache;
  650. u32 flags;
  651. int (*query_device)(struct ib_device *device,
  652. struct ib_device_attr *device_attr);
  653. int (*query_port)(struct ib_device *device,
  654. u8 port_num,
  655. struct ib_port_attr *port_attr);
  656. int (*query_gid)(struct ib_device *device,
  657. u8 port_num, int index,
  658. union ib_gid *gid);
  659. int (*query_pkey)(struct ib_device *device,
  660. u8 port_num, u16 index, u16 *pkey);
  661. int (*modify_device)(struct ib_device *device,
  662. int device_modify_mask,
  663. struct ib_device_modify *device_modify);
  664. int (*modify_port)(struct ib_device *device,
  665. u8 port_num, int port_modify_mask,
  666. struct ib_port_modify *port_modify);
  667. struct ib_pd * (*alloc_pd)(struct ib_device *device);
  668. int (*dealloc_pd)(struct ib_pd *pd);
  669. struct ib_ah * (*create_ah)(struct ib_pd *pd,
  670. struct ib_ah_attr *ah_attr);
  671. int (*modify_ah)(struct ib_ah *ah,
  672. struct ib_ah_attr *ah_attr);
  673. int (*query_ah)(struct ib_ah *ah,
  674. struct ib_ah_attr *ah_attr);
  675. int (*destroy_ah)(struct ib_ah *ah);
  676. struct ib_qp * (*create_qp)(struct ib_pd *pd,
  677. struct ib_qp_init_attr *qp_init_attr);
  678. int (*modify_qp)(struct ib_qp *qp,
  679. struct ib_qp_attr *qp_attr,
  680. int qp_attr_mask);
  681. int (*query_qp)(struct ib_qp *qp,
  682. struct ib_qp_attr *qp_attr,
  683. int qp_attr_mask,
  684. struct ib_qp_init_attr *qp_init_attr);
  685. int (*destroy_qp)(struct ib_qp *qp);
  686. int (*post_send)(struct ib_qp *qp,
  687. struct ib_send_wr *send_wr,
  688. struct ib_send_wr **bad_send_wr);
  689. int (*post_recv)(struct ib_qp *qp,
  690. struct ib_recv_wr *recv_wr,
  691. struct ib_recv_wr **bad_recv_wr);
  692. struct ib_cq * (*create_cq)(struct ib_device *device,
  693. int cqe);
  694. int (*destroy_cq)(struct ib_cq *cq);
  695. int (*resize_cq)(struct ib_cq *cq, int *cqe);
  696. int (*poll_cq)(struct ib_cq *cq, int num_entries,
  697. struct ib_wc *wc);
  698. int (*peek_cq)(struct ib_cq *cq, int wc_cnt);
  699. int (*req_notify_cq)(struct ib_cq *cq,
  700. enum ib_cq_notify cq_notify);
  701. int (*req_ncomp_notif)(struct ib_cq *cq,
  702. int wc_cnt);
  703. struct ib_mr * (*get_dma_mr)(struct ib_pd *pd,
  704. int mr_access_flags);
  705. struct ib_mr * (*reg_phys_mr)(struct ib_pd *pd,
  706. struct ib_phys_buf *phys_buf_array,
  707. int num_phys_buf,
  708. int mr_access_flags,
  709. u64 *iova_start);
  710. int (*query_mr)(struct ib_mr *mr,
  711. struct ib_mr_attr *mr_attr);
  712. int (*dereg_mr)(struct ib_mr *mr);
  713. int (*rereg_phys_mr)(struct ib_mr *mr,
  714. int mr_rereg_mask,
  715. struct ib_pd *pd,
  716. struct ib_phys_buf *phys_buf_array,
  717. int num_phys_buf,
  718. int mr_access_flags,
  719. u64 *iova_start);
  720. struct ib_mw * (*alloc_mw)(struct ib_pd *pd);
  721. int (*bind_mw)(struct ib_qp *qp,
  722. struct ib_mw *mw,
  723. struct ib_mw_bind *mw_bind);
  724. int (*dealloc_mw)(struct ib_mw *mw);
  725. struct ib_fmr * (*alloc_fmr)(struct ib_pd *pd,
  726. int mr_access_flags,
  727. struct ib_fmr_attr *fmr_attr);
  728. int (*map_phys_fmr)(struct ib_fmr *fmr,
  729. u64 *page_list, int list_len,
  730. u64 iova);
  731. int (*unmap_fmr)(struct list_head *fmr_list);
  732. int (*dealloc_fmr)(struct ib_fmr *fmr);
  733. int (*attach_mcast)(struct ib_qp *qp,
  734. union ib_gid *gid,
  735. u16 lid);
  736. int (*detach_mcast)(struct ib_qp *qp,
  737. union ib_gid *gid,
  738. u16 lid);
  739. int (*process_mad)(struct ib_device *device,
  740. int process_mad_flags,
  741. u8 port_num,
  742. struct ib_wc *in_wc,
  743. struct ib_grh *in_grh,
  744. struct ib_mad *in_mad,
  745. struct ib_mad *out_mad);
  746. struct class_device class_dev;
  747. struct kobject ports_parent;
  748. struct list_head port_list;
  749. enum {
  750. IB_DEV_UNINITIALIZED,
  751. IB_DEV_REGISTERED,
  752. IB_DEV_UNREGISTERED
  753. } reg_state;
  754. u8 node_type;
  755. u8 phys_port_cnt;
  756. };
  757. struct ib_client {
  758. char *name;
  759. void (*add) (struct ib_device *);
  760. void (*remove)(struct ib_device *);
  761. struct list_head list;
  762. };
  763. struct ib_device *ib_alloc_device(size_t size);
  764. void ib_dealloc_device(struct ib_device *device);
  765. int ib_register_device (struct ib_device *device);
  766. void ib_unregister_device(struct ib_device *device);
  767. int ib_register_client (struct ib_client *client);
  768. void ib_unregister_client(struct ib_client *client);
  769. void *ib_get_client_data(struct ib_device *device, struct ib_client *client);
  770. void ib_set_client_data(struct ib_device *device, struct ib_client *client,
  771. void *data);
  772. int ib_register_event_handler (struct ib_event_handler *event_handler);
  773. int ib_unregister_event_handler(struct ib_event_handler *event_handler);
  774. void ib_dispatch_event(struct ib_event *event);
  775. int ib_query_device(struct ib_device *device,
  776. struct ib_device_attr *device_attr);
  777. int ib_query_port(struct ib_device *device,
  778. u8 port_num, struct ib_port_attr *port_attr);
  779. int ib_query_gid(struct ib_device *device,
  780. u8 port_num, int index, union ib_gid *gid);
  781. int ib_query_pkey(struct ib_device *device,
  782. u8 port_num, u16 index, u16 *pkey);
  783. int ib_modify_device(struct ib_device *device,
  784. int device_modify_mask,
  785. struct ib_device_modify *device_modify);
  786. int ib_modify_port(struct ib_device *device,
  787. u8 port_num, int port_modify_mask,
  788. struct ib_port_modify *port_modify);
  789. /**
  790. * ib_alloc_pd - Allocates an unused protection domain.
  791. * @device: The device on which to allocate the protection domain.
  792. *
  793. * A protection domain object provides an association between QPs, shared
  794. * receive queues, address handles, memory regions, and memory windows.
  795. */
  796. struct ib_pd *ib_alloc_pd(struct ib_device *device);
  797. /**
  798. * ib_dealloc_pd - Deallocates a protection domain.
  799. * @pd: The protection domain to deallocate.
  800. */
  801. int ib_dealloc_pd(struct ib_pd *pd);
  802. /**
  803. * ib_create_ah - Creates an address handle for the given address vector.
  804. * @pd: The protection domain associated with the address handle.
  805. * @ah_attr: The attributes of the address vector.
  806. *
  807. * The address handle is used to reference a local or global destination
  808. * in all UD QP post sends.
  809. */
  810. struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr);
  811. /**
  812. * ib_modify_ah - Modifies the address vector associated with an address
  813. * handle.
  814. * @ah: The address handle to modify.
  815. * @ah_attr: The new address vector attributes to associate with the
  816. * address handle.
  817. */
  818. int ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
  819. /**
  820. * ib_query_ah - Queries the address vector associated with an address
  821. * handle.
  822. * @ah: The address handle to query.
  823. * @ah_attr: The address vector attributes associated with the address
  824. * handle.
  825. */
  826. int ib_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
  827. /**
  828. * ib_destroy_ah - Destroys an address handle.
  829. * @ah: The address handle to destroy.
  830. */
  831. int ib_destroy_ah(struct ib_ah *ah);
  832. /**
  833. * ib_create_qp - Creates a QP associated with the specified protection
  834. * domain.
  835. * @pd: The protection domain associated with the QP.
  836. * @qp_init_attr: A list of initial attributes required to create the QP.
  837. */
  838. struct ib_qp *ib_create_qp(struct ib_pd *pd,
  839. struct ib_qp_init_attr *qp_init_attr);
  840. /**
  841. * ib_modify_qp - Modifies the attributes for the specified QP and then
  842. * transitions the QP to the given state.
  843. * @qp: The QP to modify.
  844. * @qp_attr: On input, specifies the QP attributes to modify. On output,
  845. * the current values of selected QP attributes are returned.
  846. * @qp_attr_mask: A bit-mask used to specify which attributes of the QP
  847. * are being modified.
  848. */
  849. int ib_modify_qp(struct ib_qp *qp,
  850. struct ib_qp_attr *qp_attr,
  851. int qp_attr_mask);
  852. /**
  853. * ib_query_qp - Returns the attribute list and current values for the
  854. * specified QP.
  855. * @qp: The QP to query.
  856. * @qp_attr: The attributes of the specified QP.
  857. * @qp_attr_mask: A bit-mask used to select specific attributes to query.
  858. * @qp_init_attr: Additional attributes of the selected QP.
  859. *
  860. * The qp_attr_mask may be used to limit the query to gathering only the
  861. * selected attributes.
  862. */
  863. int ib_query_qp(struct ib_qp *qp,
  864. struct ib_qp_attr *qp_attr,
  865. int qp_attr_mask,
  866. struct ib_qp_init_attr *qp_init_attr);
  867. /**
  868. * ib_destroy_qp - Destroys the specified QP.
  869. * @qp: The QP to destroy.
  870. */
  871. int ib_destroy_qp(struct ib_qp *qp);
  872. /**
  873. * ib_post_send - Posts a list of work requests to the send queue of
  874. * the specified QP.
  875. * @qp: The QP to post the work request on.
  876. * @send_wr: A list of work requests to post on the send queue.
  877. * @bad_send_wr: On an immediate failure, this parameter will reference
  878. * the work request that failed to be posted on the QP.
  879. */
  880. static inline int ib_post_send(struct ib_qp *qp,
  881. struct ib_send_wr *send_wr,
  882. struct ib_send_wr **bad_send_wr)
  883. {
  884. return qp->device->post_send(qp, send_wr, bad_send_wr);
  885. }
  886. /**
  887. * ib_post_recv - Posts a list of work requests to the receive queue of
  888. * the specified QP.
  889. * @qp: The QP to post the work request on.
  890. * @recv_wr: A list of work requests to post on the receive queue.
  891. * @bad_recv_wr: On an immediate failure, this parameter will reference
  892. * the work request that failed to be posted on the QP.
  893. */
  894. static inline int ib_post_recv(struct ib_qp *qp,
  895. struct ib_recv_wr *recv_wr,
  896. struct ib_recv_wr **bad_recv_wr)
  897. {
  898. return qp->device->post_recv(qp, recv_wr, bad_recv_wr);
  899. }
  900. /**
  901. * ib_create_cq - Creates a CQ on the specified device.
  902. * @device: The device on which to create the CQ.
  903. * @comp_handler: A user-specified callback that is invoked when a
  904. * completion event occurs on the CQ.
  905. * @event_handler: A user-specified callback that is invoked when an
  906. * asynchronous event not associated with a completion occurs on the CQ.
  907. * @cq_context: Context associated with the CQ returned to the user via
  908. * the associated completion and event handlers.
  909. * @cqe: The minimum size of the CQ.
  910. *
  911. * Users can examine the cq structure to determine the actual CQ size.
  912. */
  913. struct ib_cq *ib_create_cq(struct ib_device *device,
  914. ib_comp_handler comp_handler,
  915. void (*event_handler)(struct ib_event *, void *),
  916. void *cq_context, int cqe);
  917. /**
  918. * ib_resize_cq - Modifies the capacity of the CQ.
  919. * @cq: The CQ to resize.
  920. * @cqe: The minimum size of the CQ.
  921. *
  922. * Users can examine the cq structure to determine the actual CQ size.
  923. */
  924. int ib_resize_cq(struct ib_cq *cq, int cqe);
  925. /**
  926. * ib_destroy_cq - Destroys the specified CQ.
  927. * @cq: The CQ to destroy.
  928. */
  929. int ib_destroy_cq(struct ib_cq *cq);
  930. /**
  931. * ib_poll_cq - poll a CQ for completion(s)
  932. * @cq:the CQ being polled
  933. * @num_entries:maximum number of completions to return
  934. * @wc:array of at least @num_entries &struct ib_wc where completions
  935. * will be returned
  936. *
  937. * Poll a CQ for (possibly multiple) completions. If the return value
  938. * is < 0, an error occurred. If the return value is >= 0, it is the
  939. * number of completions returned. If the return value is
  940. * non-negative and < num_entries, then the CQ was emptied.
  941. */
  942. static inline int ib_poll_cq(struct ib_cq *cq, int num_entries,
  943. struct ib_wc *wc)
  944. {
  945. return cq->device->poll_cq(cq, num_entries, wc);
  946. }
  947. /**
  948. * ib_peek_cq - Returns the number of unreaped completions currently
  949. * on the specified CQ.
  950. * @cq: The CQ to peek.
  951. * @wc_cnt: A minimum number of unreaped completions to check for.
  952. *
  953. * If the number of unreaped completions is greater than or equal to wc_cnt,
  954. * this function returns wc_cnt, otherwise, it returns the actual number of
  955. * unreaped completions.
  956. */
  957. int ib_peek_cq(struct ib_cq *cq, int wc_cnt);
  958. /**
  959. * ib_req_notify_cq - Request completion notification on a CQ.
  960. * @cq: The CQ to generate an event for.
  961. * @cq_notify: If set to %IB_CQ_SOLICITED, completion notification will
  962. * occur on the next solicited event. If set to %IB_CQ_NEXT_COMP,
  963. * notification will occur on the next completion.
  964. */
  965. static inline int ib_req_notify_cq(struct ib_cq *cq,
  966. enum ib_cq_notify cq_notify)
  967. {
  968. return cq->device->req_notify_cq(cq, cq_notify);
  969. }
  970. /**
  971. * ib_req_ncomp_notif - Request completion notification when there are
  972. * at least the specified number of unreaped completions on the CQ.
  973. * @cq: The CQ to generate an event for.
  974. * @wc_cnt: The number of unreaped completions that should be on the
  975. * CQ before an event is generated.
  976. */
  977. static inline int ib_req_ncomp_notif(struct ib_cq *cq, int wc_cnt)
  978. {
  979. return cq->device->req_ncomp_notif ?
  980. cq->device->req_ncomp_notif(cq, wc_cnt) :
  981. -ENOSYS;
  982. }
  983. /**
  984. * ib_get_dma_mr - Returns a memory region for system memory that is
  985. * usable for DMA.
  986. * @pd: The protection domain associated with the memory region.
  987. * @mr_access_flags: Specifies the memory access rights.
  988. */
  989. struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
  990. /**
  991. * ib_reg_phys_mr - Prepares a virtually addressed memory region for use
  992. * by an HCA.
  993. * @pd: The protection domain associated assigned to the registered region.
  994. * @phys_buf_array: Specifies a list of physical buffers to use in the
  995. * memory region.
  996. * @num_phys_buf: Specifies the size of the phys_buf_array.
  997. * @mr_access_flags: Specifies the memory access rights.
  998. * @iova_start: The offset of the region's starting I/O virtual address.
  999. */
  1000. struct ib_mr *ib_reg_phys_mr(struct ib_pd *pd,
  1001. struct ib_phys_buf *phys_buf_array,
  1002. int num_phys_buf,
  1003. int mr_access_flags,
  1004. u64 *iova_start);
  1005. /**
  1006. * ib_rereg_phys_mr - Modifies the attributes of an existing memory region.
  1007. * Conceptually, this call performs the functions deregister memory region
  1008. * followed by register physical memory region. Where possible,
  1009. * resources are reused instead of deallocated and reallocated.
  1010. * @mr: The memory region to modify.
  1011. * @mr_rereg_mask: A bit-mask used to indicate which of the following
  1012. * properties of the memory region are being modified.
  1013. * @pd: If %IB_MR_REREG_PD is set in mr_rereg_mask, this field specifies
  1014. * the new protection domain to associated with the memory region,
  1015. * otherwise, this parameter is ignored.
  1016. * @phys_buf_array: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
  1017. * field specifies a list of physical buffers to use in the new
  1018. * translation, otherwise, this parameter is ignored.
  1019. * @num_phys_buf: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
  1020. * field specifies the size of the phys_buf_array, otherwise, this
  1021. * parameter is ignored.
  1022. * @mr_access_flags: If %IB_MR_REREG_ACCESS is set in mr_rereg_mask, this
  1023. * field specifies the new memory access rights, otherwise, this
  1024. * parameter is ignored.
  1025. * @iova_start: The offset of the region's starting I/O virtual address.
  1026. */
  1027. int ib_rereg_phys_mr(struct ib_mr *mr,
  1028. int mr_rereg_mask,
  1029. struct ib_pd *pd,
  1030. struct ib_phys_buf *phys_buf_array,
  1031. int num_phys_buf,
  1032. int mr_access_flags,
  1033. u64 *iova_start);
  1034. /**
  1035. * ib_query_mr - Retrieves information about a specific memory region.
  1036. * @mr: The memory region to retrieve information about.
  1037. * @mr_attr: The attributes of the specified memory region.
  1038. */
  1039. int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr);
  1040. /**
  1041. * ib_dereg_mr - Deregisters a memory region and removes it from the
  1042. * HCA translation table.
  1043. * @mr: The memory region to deregister.
  1044. */
  1045. int ib_dereg_mr(struct ib_mr *mr);
  1046. /**
  1047. * ib_alloc_mw - Allocates a memory window.
  1048. * @pd: The protection domain associated with the memory window.
  1049. */
  1050. struct ib_mw *ib_alloc_mw(struct ib_pd *pd);
  1051. /**
  1052. * ib_bind_mw - Posts a work request to the send queue of the specified
  1053. * QP, which binds the memory window to the given address range and
  1054. * remote access attributes.
  1055. * @qp: QP to post the bind work request on.
  1056. * @mw: The memory window to bind.
  1057. * @mw_bind: Specifies information about the memory window, including
  1058. * its address range, remote access rights, and associated memory region.
  1059. */
  1060. static inline int ib_bind_mw(struct ib_qp *qp,
  1061. struct ib_mw *mw,
  1062. struct ib_mw_bind *mw_bind)
  1063. {
  1064. /* XXX reference counting in corresponding MR? */
  1065. return mw->device->bind_mw ?
  1066. mw->device->bind_mw(qp, mw, mw_bind) :
  1067. -ENOSYS;
  1068. }
  1069. /**
  1070. * ib_dealloc_mw - Deallocates a memory window.
  1071. * @mw: The memory window to deallocate.
  1072. */
  1073. int ib_dealloc_mw(struct ib_mw *mw);
  1074. /**
  1075. * ib_alloc_fmr - Allocates a unmapped fast memory region.
  1076. * @pd: The protection domain associated with the unmapped region.
  1077. * @mr_access_flags: Specifies the memory access rights.
  1078. * @fmr_attr: Attributes of the unmapped region.
  1079. *
  1080. * A fast memory region must be mapped before it can be used as part of
  1081. * a work request.
  1082. */
  1083. struct ib_fmr *ib_alloc_fmr(struct ib_pd *pd,
  1084. int mr_access_flags,
  1085. struct ib_fmr_attr *fmr_attr);
  1086. /**
  1087. * ib_map_phys_fmr - Maps a list of physical pages to a fast memory region.
  1088. * @fmr: The fast memory region to associate with the pages.
  1089. * @page_list: An array of physical pages to map to the fast memory region.
  1090. * @list_len: The number of pages in page_list.
  1091. * @iova: The I/O virtual address to use with the mapped region.
  1092. */
  1093. static inline int ib_map_phys_fmr(struct ib_fmr *fmr,
  1094. u64 *page_list, int list_len,
  1095. u64 iova)
  1096. {
  1097. return fmr->device->map_phys_fmr(fmr, page_list, list_len, iova);
  1098. }
  1099. /**
  1100. * ib_unmap_fmr - Removes the mapping from a list of fast memory regions.
  1101. * @fmr_list: A linked list of fast memory regions to unmap.
  1102. */
  1103. int ib_unmap_fmr(struct list_head *fmr_list);
  1104. /**
  1105. * ib_dealloc_fmr - Deallocates a fast memory region.
  1106. * @fmr: The fast memory region to deallocate.
  1107. */
  1108. int ib_dealloc_fmr(struct ib_fmr *fmr);
  1109. /**
  1110. * ib_attach_mcast - Attaches the specified QP to a multicast group.
  1111. * @qp: QP to attach to the multicast group. The QP must be type
  1112. * IB_QPT_UD.
  1113. * @gid: Multicast group GID.
  1114. * @lid: Multicast group LID in host byte order.
  1115. *
  1116. * In order to send and receive multicast packets, subnet
  1117. * administration must have created the multicast group and configured
  1118. * the fabric appropriately. The port associated with the specified
  1119. * QP must also be a member of the multicast group.
  1120. */
  1121. int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
  1122. /**
  1123. * ib_detach_mcast - Detaches the specified QP from a multicast group.
  1124. * @qp: QP to detach from the multicast group.
  1125. * @gid: Multicast group GID.
  1126. * @lid: Multicast group LID in host byte order.
  1127. */
  1128. int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
  1129. #endif /* IB_VERBS_H */