ib_verbs.h 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821
  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 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. * $Id: ib_verbs.h 1349 2004-12-16 21:09:43Z roland $
  39. */
  40. #if !defined(IB_VERBS_H)
  41. #define IB_VERBS_H
  42. #include <linux/types.h>
  43. #include <linux/device.h>
  44. #include <linux/mm.h>
  45. #include <linux/dma-mapping.h>
  46. #include <asm/atomic.h>
  47. #include <asm/scatterlist.h>
  48. #include <asm/uaccess.h>
  49. union ib_gid {
  50. u8 raw[16];
  51. struct {
  52. __be64 subnet_prefix;
  53. __be64 interface_id;
  54. } global;
  55. };
  56. enum rdma_node_type {
  57. /* IB values map to NodeInfo:NodeType. */
  58. RDMA_NODE_IB_CA = 1,
  59. RDMA_NODE_IB_SWITCH,
  60. RDMA_NODE_IB_ROUTER,
  61. RDMA_NODE_RNIC
  62. };
  63. enum rdma_transport_type {
  64. RDMA_TRANSPORT_IB,
  65. RDMA_TRANSPORT_IWARP
  66. };
  67. enum rdma_transport_type
  68. rdma_node_get_transport(enum rdma_node_type node_type) __attribute_const__;
  69. enum ib_device_cap_flags {
  70. IB_DEVICE_RESIZE_MAX_WR = 1,
  71. IB_DEVICE_BAD_PKEY_CNTR = (1<<1),
  72. IB_DEVICE_BAD_QKEY_CNTR = (1<<2),
  73. IB_DEVICE_RAW_MULTI = (1<<3),
  74. IB_DEVICE_AUTO_PATH_MIG = (1<<4),
  75. IB_DEVICE_CHANGE_PHY_PORT = (1<<5),
  76. IB_DEVICE_UD_AV_PORT_ENFORCE = (1<<6),
  77. IB_DEVICE_CURR_QP_STATE_MOD = (1<<7),
  78. IB_DEVICE_SHUTDOWN_PORT = (1<<8),
  79. IB_DEVICE_INIT_TYPE = (1<<9),
  80. IB_DEVICE_PORT_ACTIVE_EVENT = (1<<10),
  81. IB_DEVICE_SYS_IMAGE_GUID = (1<<11),
  82. IB_DEVICE_RC_RNR_NAK_GEN = (1<<12),
  83. IB_DEVICE_SRQ_RESIZE = (1<<13),
  84. IB_DEVICE_N_NOTIFY_CQ = (1<<14),
  85. IB_DEVICE_ZERO_STAG = (1<<15),
  86. IB_DEVICE_SEND_W_INV = (1<<16),
  87. IB_DEVICE_MEM_WINDOW = (1<<17)
  88. };
  89. enum ib_atomic_cap {
  90. IB_ATOMIC_NONE,
  91. IB_ATOMIC_HCA,
  92. IB_ATOMIC_GLOB
  93. };
  94. struct ib_device_attr {
  95. u64 fw_ver;
  96. __be64 sys_image_guid;
  97. u64 max_mr_size;
  98. u64 page_size_cap;
  99. u32 vendor_id;
  100. u32 vendor_part_id;
  101. u32 hw_ver;
  102. int max_qp;
  103. int max_qp_wr;
  104. int device_cap_flags;
  105. int max_sge;
  106. int max_sge_rd;
  107. int max_cq;
  108. int max_cqe;
  109. int max_mr;
  110. int max_pd;
  111. int max_qp_rd_atom;
  112. int max_ee_rd_atom;
  113. int max_res_rd_atom;
  114. int max_qp_init_rd_atom;
  115. int max_ee_init_rd_atom;
  116. enum ib_atomic_cap atomic_cap;
  117. int max_ee;
  118. int max_rdd;
  119. int max_mw;
  120. int max_raw_ipv6_qp;
  121. int max_raw_ethy_qp;
  122. int max_mcast_grp;
  123. int max_mcast_qp_attach;
  124. int max_total_mcast_qp_attach;
  125. int max_ah;
  126. int max_fmr;
  127. int max_map_per_fmr;
  128. int max_srq;
  129. int max_srq_wr;
  130. int max_srq_sge;
  131. u16 max_pkeys;
  132. u8 local_ca_ack_delay;
  133. };
  134. enum ib_mtu {
  135. IB_MTU_256 = 1,
  136. IB_MTU_512 = 2,
  137. IB_MTU_1024 = 3,
  138. IB_MTU_2048 = 4,
  139. IB_MTU_4096 = 5
  140. };
  141. static inline int ib_mtu_enum_to_int(enum ib_mtu mtu)
  142. {
  143. switch (mtu) {
  144. case IB_MTU_256: return 256;
  145. case IB_MTU_512: return 512;
  146. case IB_MTU_1024: return 1024;
  147. case IB_MTU_2048: return 2048;
  148. case IB_MTU_4096: return 4096;
  149. default: return -1;
  150. }
  151. }
  152. enum ib_port_state {
  153. IB_PORT_NOP = 0,
  154. IB_PORT_DOWN = 1,
  155. IB_PORT_INIT = 2,
  156. IB_PORT_ARMED = 3,
  157. IB_PORT_ACTIVE = 4,
  158. IB_PORT_ACTIVE_DEFER = 5
  159. };
  160. enum ib_port_cap_flags {
  161. IB_PORT_SM = 1 << 1,
  162. IB_PORT_NOTICE_SUP = 1 << 2,
  163. IB_PORT_TRAP_SUP = 1 << 3,
  164. IB_PORT_OPT_IPD_SUP = 1 << 4,
  165. IB_PORT_AUTO_MIGR_SUP = 1 << 5,
  166. IB_PORT_SL_MAP_SUP = 1 << 6,
  167. IB_PORT_MKEY_NVRAM = 1 << 7,
  168. IB_PORT_PKEY_NVRAM = 1 << 8,
  169. IB_PORT_LED_INFO_SUP = 1 << 9,
  170. IB_PORT_SM_DISABLED = 1 << 10,
  171. IB_PORT_SYS_IMAGE_GUID_SUP = 1 << 11,
  172. IB_PORT_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12,
  173. IB_PORT_CM_SUP = 1 << 16,
  174. IB_PORT_SNMP_TUNNEL_SUP = 1 << 17,
  175. IB_PORT_REINIT_SUP = 1 << 18,
  176. IB_PORT_DEVICE_MGMT_SUP = 1 << 19,
  177. IB_PORT_VENDOR_CLASS_SUP = 1 << 20,
  178. IB_PORT_DR_NOTICE_SUP = 1 << 21,
  179. IB_PORT_CAP_MASK_NOTICE_SUP = 1 << 22,
  180. IB_PORT_BOOT_MGMT_SUP = 1 << 23,
  181. IB_PORT_LINK_LATENCY_SUP = 1 << 24,
  182. IB_PORT_CLIENT_REG_SUP = 1 << 25
  183. };
  184. enum ib_port_width {
  185. IB_WIDTH_1X = 1,
  186. IB_WIDTH_4X = 2,
  187. IB_WIDTH_8X = 4,
  188. IB_WIDTH_12X = 8
  189. };
  190. static inline int ib_width_enum_to_int(enum ib_port_width width)
  191. {
  192. switch (width) {
  193. case IB_WIDTH_1X: return 1;
  194. case IB_WIDTH_4X: return 4;
  195. case IB_WIDTH_8X: return 8;
  196. case IB_WIDTH_12X: return 12;
  197. default: return -1;
  198. }
  199. }
  200. struct ib_port_attr {
  201. enum ib_port_state state;
  202. enum ib_mtu max_mtu;
  203. enum ib_mtu active_mtu;
  204. int gid_tbl_len;
  205. u32 port_cap_flags;
  206. u32 max_msg_sz;
  207. u32 bad_pkey_cntr;
  208. u32 qkey_viol_cntr;
  209. u16 pkey_tbl_len;
  210. u16 lid;
  211. u16 sm_lid;
  212. u8 lmc;
  213. u8 max_vl_num;
  214. u8 sm_sl;
  215. u8 subnet_timeout;
  216. u8 init_type_reply;
  217. u8 active_width;
  218. u8 active_speed;
  219. u8 phys_state;
  220. };
  221. enum ib_device_modify_flags {
  222. IB_DEVICE_MODIFY_SYS_IMAGE_GUID = 1 << 0,
  223. IB_DEVICE_MODIFY_NODE_DESC = 1 << 1
  224. };
  225. struct ib_device_modify {
  226. u64 sys_image_guid;
  227. char node_desc[64];
  228. };
  229. enum ib_port_modify_flags {
  230. IB_PORT_SHUTDOWN = 1,
  231. IB_PORT_INIT_TYPE = (1<<2),
  232. IB_PORT_RESET_QKEY_CNTR = (1<<3)
  233. };
  234. struct ib_port_modify {
  235. u32 set_port_cap_mask;
  236. u32 clr_port_cap_mask;
  237. u8 init_type;
  238. };
  239. enum ib_event_type {
  240. IB_EVENT_CQ_ERR,
  241. IB_EVENT_QP_FATAL,
  242. IB_EVENT_QP_REQ_ERR,
  243. IB_EVENT_QP_ACCESS_ERR,
  244. IB_EVENT_COMM_EST,
  245. IB_EVENT_SQ_DRAINED,
  246. IB_EVENT_PATH_MIG,
  247. IB_EVENT_PATH_MIG_ERR,
  248. IB_EVENT_DEVICE_FATAL,
  249. IB_EVENT_PORT_ACTIVE,
  250. IB_EVENT_PORT_ERR,
  251. IB_EVENT_LID_CHANGE,
  252. IB_EVENT_PKEY_CHANGE,
  253. IB_EVENT_SM_CHANGE,
  254. IB_EVENT_SRQ_ERR,
  255. IB_EVENT_SRQ_LIMIT_REACHED,
  256. IB_EVENT_QP_LAST_WQE_REACHED,
  257. IB_EVENT_CLIENT_REREGISTER
  258. };
  259. struct ib_event {
  260. struct ib_device *device;
  261. union {
  262. struct ib_cq *cq;
  263. struct ib_qp *qp;
  264. struct ib_srq *srq;
  265. u8 port_num;
  266. } element;
  267. enum ib_event_type event;
  268. };
  269. struct ib_event_handler {
  270. struct ib_device *device;
  271. void (*handler)(struct ib_event_handler *, struct ib_event *);
  272. struct list_head list;
  273. };
  274. #define INIT_IB_EVENT_HANDLER(_ptr, _device, _handler) \
  275. do { \
  276. (_ptr)->device = _device; \
  277. (_ptr)->handler = _handler; \
  278. INIT_LIST_HEAD(&(_ptr)->list); \
  279. } while (0)
  280. struct ib_global_route {
  281. union ib_gid dgid;
  282. u32 flow_label;
  283. u8 sgid_index;
  284. u8 hop_limit;
  285. u8 traffic_class;
  286. };
  287. struct ib_grh {
  288. __be32 version_tclass_flow;
  289. __be16 paylen;
  290. u8 next_hdr;
  291. u8 hop_limit;
  292. union ib_gid sgid;
  293. union ib_gid dgid;
  294. };
  295. enum {
  296. IB_MULTICAST_QPN = 0xffffff
  297. };
  298. #define IB_LID_PERMISSIVE __constant_htons(0xFFFF)
  299. enum ib_ah_flags {
  300. IB_AH_GRH = 1
  301. };
  302. enum ib_rate {
  303. IB_RATE_PORT_CURRENT = 0,
  304. IB_RATE_2_5_GBPS = 2,
  305. IB_RATE_5_GBPS = 5,
  306. IB_RATE_10_GBPS = 3,
  307. IB_RATE_20_GBPS = 6,
  308. IB_RATE_30_GBPS = 4,
  309. IB_RATE_40_GBPS = 7,
  310. IB_RATE_60_GBPS = 8,
  311. IB_RATE_80_GBPS = 9,
  312. IB_RATE_120_GBPS = 10
  313. };
  314. /**
  315. * ib_rate_to_mult - Convert the IB rate enum to a multiple of the
  316. * base rate of 2.5 Gbit/sec. For example, IB_RATE_5_GBPS will be
  317. * converted to 2, since 5 Gbit/sec is 2 * 2.5 Gbit/sec.
  318. * @rate: rate to convert.
  319. */
  320. int ib_rate_to_mult(enum ib_rate rate) __attribute_const__;
  321. /**
  322. * mult_to_ib_rate - Convert a multiple of 2.5 Gbit/sec to an IB rate
  323. * enum.
  324. * @mult: multiple to convert.
  325. */
  326. enum ib_rate mult_to_ib_rate(int mult) __attribute_const__;
  327. struct ib_ah_attr {
  328. struct ib_global_route grh;
  329. u16 dlid;
  330. u8 sl;
  331. u8 src_path_bits;
  332. u8 static_rate;
  333. u8 ah_flags;
  334. u8 port_num;
  335. };
  336. enum ib_wc_status {
  337. IB_WC_SUCCESS,
  338. IB_WC_LOC_LEN_ERR,
  339. IB_WC_LOC_QP_OP_ERR,
  340. IB_WC_LOC_EEC_OP_ERR,
  341. IB_WC_LOC_PROT_ERR,
  342. IB_WC_WR_FLUSH_ERR,
  343. IB_WC_MW_BIND_ERR,
  344. IB_WC_BAD_RESP_ERR,
  345. IB_WC_LOC_ACCESS_ERR,
  346. IB_WC_REM_INV_REQ_ERR,
  347. IB_WC_REM_ACCESS_ERR,
  348. IB_WC_REM_OP_ERR,
  349. IB_WC_RETRY_EXC_ERR,
  350. IB_WC_RNR_RETRY_EXC_ERR,
  351. IB_WC_LOC_RDD_VIOL_ERR,
  352. IB_WC_REM_INV_RD_REQ_ERR,
  353. IB_WC_REM_ABORT_ERR,
  354. IB_WC_INV_EECN_ERR,
  355. IB_WC_INV_EEC_STATE_ERR,
  356. IB_WC_FATAL_ERR,
  357. IB_WC_RESP_TIMEOUT_ERR,
  358. IB_WC_GENERAL_ERR
  359. };
  360. enum ib_wc_opcode {
  361. IB_WC_SEND,
  362. IB_WC_RDMA_WRITE,
  363. IB_WC_RDMA_READ,
  364. IB_WC_COMP_SWAP,
  365. IB_WC_FETCH_ADD,
  366. IB_WC_BIND_MW,
  367. /*
  368. * Set value of IB_WC_RECV so consumers can test if a completion is a
  369. * receive by testing (opcode & IB_WC_RECV).
  370. */
  371. IB_WC_RECV = 1 << 7,
  372. IB_WC_RECV_RDMA_WITH_IMM
  373. };
  374. enum ib_wc_flags {
  375. IB_WC_GRH = 1,
  376. IB_WC_WITH_IMM = (1<<1)
  377. };
  378. struct ib_wc {
  379. u64 wr_id;
  380. enum ib_wc_status status;
  381. enum ib_wc_opcode opcode;
  382. u32 vendor_err;
  383. u32 byte_len;
  384. __be32 imm_data;
  385. u32 qp_num;
  386. u32 src_qp;
  387. int wc_flags;
  388. u16 pkey_index;
  389. u16 slid;
  390. u8 sl;
  391. u8 dlid_path_bits;
  392. u8 port_num; /* valid only for DR SMPs on switches */
  393. };
  394. enum ib_cq_notify {
  395. IB_CQ_SOLICITED,
  396. IB_CQ_NEXT_COMP
  397. };
  398. enum ib_srq_attr_mask {
  399. IB_SRQ_MAX_WR = 1 << 0,
  400. IB_SRQ_LIMIT = 1 << 1,
  401. };
  402. struct ib_srq_attr {
  403. u32 max_wr;
  404. u32 max_sge;
  405. u32 srq_limit;
  406. };
  407. struct ib_srq_init_attr {
  408. void (*event_handler)(struct ib_event *, void *);
  409. void *srq_context;
  410. struct ib_srq_attr attr;
  411. };
  412. struct ib_qp_cap {
  413. u32 max_send_wr;
  414. u32 max_recv_wr;
  415. u32 max_send_sge;
  416. u32 max_recv_sge;
  417. u32 max_inline_data;
  418. };
  419. enum ib_sig_type {
  420. IB_SIGNAL_ALL_WR,
  421. IB_SIGNAL_REQ_WR
  422. };
  423. enum ib_qp_type {
  424. /*
  425. * IB_QPT_SMI and IB_QPT_GSI have to be the first two entries
  426. * here (and in that order) since the MAD layer uses them as
  427. * indices into a 2-entry table.
  428. */
  429. IB_QPT_SMI,
  430. IB_QPT_GSI,
  431. IB_QPT_RC,
  432. IB_QPT_UC,
  433. IB_QPT_UD,
  434. IB_QPT_RAW_IPV6,
  435. IB_QPT_RAW_ETY
  436. };
  437. struct ib_qp_init_attr {
  438. void (*event_handler)(struct ib_event *, void *);
  439. void *qp_context;
  440. struct ib_cq *send_cq;
  441. struct ib_cq *recv_cq;
  442. struct ib_srq *srq;
  443. struct ib_qp_cap cap;
  444. enum ib_sig_type sq_sig_type;
  445. enum ib_qp_type qp_type;
  446. u8 port_num; /* special QP types only */
  447. };
  448. enum ib_rnr_timeout {
  449. IB_RNR_TIMER_655_36 = 0,
  450. IB_RNR_TIMER_000_01 = 1,
  451. IB_RNR_TIMER_000_02 = 2,
  452. IB_RNR_TIMER_000_03 = 3,
  453. IB_RNR_TIMER_000_04 = 4,
  454. IB_RNR_TIMER_000_06 = 5,
  455. IB_RNR_TIMER_000_08 = 6,
  456. IB_RNR_TIMER_000_12 = 7,
  457. IB_RNR_TIMER_000_16 = 8,
  458. IB_RNR_TIMER_000_24 = 9,
  459. IB_RNR_TIMER_000_32 = 10,
  460. IB_RNR_TIMER_000_48 = 11,
  461. IB_RNR_TIMER_000_64 = 12,
  462. IB_RNR_TIMER_000_96 = 13,
  463. IB_RNR_TIMER_001_28 = 14,
  464. IB_RNR_TIMER_001_92 = 15,
  465. IB_RNR_TIMER_002_56 = 16,
  466. IB_RNR_TIMER_003_84 = 17,
  467. IB_RNR_TIMER_005_12 = 18,
  468. IB_RNR_TIMER_007_68 = 19,
  469. IB_RNR_TIMER_010_24 = 20,
  470. IB_RNR_TIMER_015_36 = 21,
  471. IB_RNR_TIMER_020_48 = 22,
  472. IB_RNR_TIMER_030_72 = 23,
  473. IB_RNR_TIMER_040_96 = 24,
  474. IB_RNR_TIMER_061_44 = 25,
  475. IB_RNR_TIMER_081_92 = 26,
  476. IB_RNR_TIMER_122_88 = 27,
  477. IB_RNR_TIMER_163_84 = 28,
  478. IB_RNR_TIMER_245_76 = 29,
  479. IB_RNR_TIMER_327_68 = 30,
  480. IB_RNR_TIMER_491_52 = 31
  481. };
  482. enum ib_qp_attr_mask {
  483. IB_QP_STATE = 1,
  484. IB_QP_CUR_STATE = (1<<1),
  485. IB_QP_EN_SQD_ASYNC_NOTIFY = (1<<2),
  486. IB_QP_ACCESS_FLAGS = (1<<3),
  487. IB_QP_PKEY_INDEX = (1<<4),
  488. IB_QP_PORT = (1<<5),
  489. IB_QP_QKEY = (1<<6),
  490. IB_QP_AV = (1<<7),
  491. IB_QP_PATH_MTU = (1<<8),
  492. IB_QP_TIMEOUT = (1<<9),
  493. IB_QP_RETRY_CNT = (1<<10),
  494. IB_QP_RNR_RETRY = (1<<11),
  495. IB_QP_RQ_PSN = (1<<12),
  496. IB_QP_MAX_QP_RD_ATOMIC = (1<<13),
  497. IB_QP_ALT_PATH = (1<<14),
  498. IB_QP_MIN_RNR_TIMER = (1<<15),
  499. IB_QP_SQ_PSN = (1<<16),
  500. IB_QP_MAX_DEST_RD_ATOMIC = (1<<17),
  501. IB_QP_PATH_MIG_STATE = (1<<18),
  502. IB_QP_CAP = (1<<19),
  503. IB_QP_DEST_QPN = (1<<20)
  504. };
  505. enum ib_qp_state {
  506. IB_QPS_RESET,
  507. IB_QPS_INIT,
  508. IB_QPS_RTR,
  509. IB_QPS_RTS,
  510. IB_QPS_SQD,
  511. IB_QPS_SQE,
  512. IB_QPS_ERR
  513. };
  514. enum ib_mig_state {
  515. IB_MIG_MIGRATED,
  516. IB_MIG_REARM,
  517. IB_MIG_ARMED
  518. };
  519. struct ib_qp_attr {
  520. enum ib_qp_state qp_state;
  521. enum ib_qp_state cur_qp_state;
  522. enum ib_mtu path_mtu;
  523. enum ib_mig_state path_mig_state;
  524. u32 qkey;
  525. u32 rq_psn;
  526. u32 sq_psn;
  527. u32 dest_qp_num;
  528. int qp_access_flags;
  529. struct ib_qp_cap cap;
  530. struct ib_ah_attr ah_attr;
  531. struct ib_ah_attr alt_ah_attr;
  532. u16 pkey_index;
  533. u16 alt_pkey_index;
  534. u8 en_sqd_async_notify;
  535. u8 sq_draining;
  536. u8 max_rd_atomic;
  537. u8 max_dest_rd_atomic;
  538. u8 min_rnr_timer;
  539. u8 port_num;
  540. u8 timeout;
  541. u8 retry_cnt;
  542. u8 rnr_retry;
  543. u8 alt_port_num;
  544. u8 alt_timeout;
  545. };
  546. enum ib_wr_opcode {
  547. IB_WR_RDMA_WRITE,
  548. IB_WR_RDMA_WRITE_WITH_IMM,
  549. IB_WR_SEND,
  550. IB_WR_SEND_WITH_IMM,
  551. IB_WR_RDMA_READ,
  552. IB_WR_ATOMIC_CMP_AND_SWP,
  553. IB_WR_ATOMIC_FETCH_AND_ADD
  554. };
  555. enum ib_send_flags {
  556. IB_SEND_FENCE = 1,
  557. IB_SEND_SIGNALED = (1<<1),
  558. IB_SEND_SOLICITED = (1<<2),
  559. IB_SEND_INLINE = (1<<3)
  560. };
  561. struct ib_sge {
  562. u64 addr;
  563. u32 length;
  564. u32 lkey;
  565. };
  566. struct ib_send_wr {
  567. struct ib_send_wr *next;
  568. u64 wr_id;
  569. struct ib_sge *sg_list;
  570. int num_sge;
  571. enum ib_wr_opcode opcode;
  572. int send_flags;
  573. __be32 imm_data;
  574. union {
  575. struct {
  576. u64 remote_addr;
  577. u32 rkey;
  578. } rdma;
  579. struct {
  580. u64 remote_addr;
  581. u64 compare_add;
  582. u64 swap;
  583. u32 rkey;
  584. } atomic;
  585. struct {
  586. struct ib_ah *ah;
  587. u32 remote_qpn;
  588. u32 remote_qkey;
  589. u16 pkey_index; /* valid for GSI only */
  590. u8 port_num; /* valid for DR SMPs on switch only */
  591. } ud;
  592. } wr;
  593. };
  594. struct ib_recv_wr {
  595. struct ib_recv_wr *next;
  596. u64 wr_id;
  597. struct ib_sge *sg_list;
  598. int num_sge;
  599. };
  600. enum ib_access_flags {
  601. IB_ACCESS_LOCAL_WRITE = 1,
  602. IB_ACCESS_REMOTE_WRITE = (1<<1),
  603. IB_ACCESS_REMOTE_READ = (1<<2),
  604. IB_ACCESS_REMOTE_ATOMIC = (1<<3),
  605. IB_ACCESS_MW_BIND = (1<<4)
  606. };
  607. struct ib_phys_buf {
  608. u64 addr;
  609. u64 size;
  610. };
  611. struct ib_mr_attr {
  612. struct ib_pd *pd;
  613. u64 device_virt_addr;
  614. u64 size;
  615. int mr_access_flags;
  616. u32 lkey;
  617. u32 rkey;
  618. };
  619. enum ib_mr_rereg_flags {
  620. IB_MR_REREG_TRANS = 1,
  621. IB_MR_REREG_PD = (1<<1),
  622. IB_MR_REREG_ACCESS = (1<<2)
  623. };
  624. struct ib_mw_bind {
  625. struct ib_mr *mr;
  626. u64 wr_id;
  627. u64 addr;
  628. u32 length;
  629. int send_flags;
  630. int mw_access_flags;
  631. };
  632. struct ib_fmr_attr {
  633. int max_pages;
  634. int max_maps;
  635. u8 page_shift;
  636. };
  637. struct ib_ucontext {
  638. struct ib_device *device;
  639. struct list_head pd_list;
  640. struct list_head mr_list;
  641. struct list_head mw_list;
  642. struct list_head cq_list;
  643. struct list_head qp_list;
  644. struct list_head srq_list;
  645. struct list_head ah_list;
  646. };
  647. struct ib_uobject {
  648. u64 user_handle; /* handle given to us by userspace */
  649. struct ib_ucontext *context; /* associated user context */
  650. void *object; /* containing object */
  651. struct list_head list; /* link to context's list */
  652. u32 id; /* index into kernel idr */
  653. struct kref ref;
  654. struct rw_semaphore mutex; /* protects .live */
  655. int live;
  656. };
  657. struct ib_umem {
  658. unsigned long user_base;
  659. unsigned long virt_base;
  660. size_t length;
  661. int offset;
  662. int page_size;
  663. int writable;
  664. struct list_head chunk_list;
  665. };
  666. struct ib_umem_chunk {
  667. struct list_head list;
  668. int nents;
  669. int nmap;
  670. struct scatterlist page_list[0];
  671. };
  672. struct ib_udata {
  673. void __user *inbuf;
  674. void __user *outbuf;
  675. size_t inlen;
  676. size_t outlen;
  677. };
  678. #define IB_UMEM_MAX_PAGE_CHUNK \
  679. ((PAGE_SIZE - offsetof(struct ib_umem_chunk, page_list)) / \
  680. ((void *) &((struct ib_umem_chunk *) 0)->page_list[1] - \
  681. (void *) &((struct ib_umem_chunk *) 0)->page_list[0]))
  682. struct ib_umem_object {
  683. struct ib_uobject uobject;
  684. struct ib_umem umem;
  685. };
  686. struct ib_pd {
  687. struct ib_device *device;
  688. struct ib_uobject *uobject;
  689. atomic_t usecnt; /* count all resources */
  690. };
  691. struct ib_ah {
  692. struct ib_device *device;
  693. struct ib_pd *pd;
  694. struct ib_uobject *uobject;
  695. };
  696. typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context);
  697. struct ib_cq {
  698. struct ib_device *device;
  699. struct ib_uobject *uobject;
  700. ib_comp_handler comp_handler;
  701. void (*event_handler)(struct ib_event *, void *);
  702. void * cq_context;
  703. int cqe;
  704. atomic_t usecnt; /* count number of work queues */
  705. };
  706. struct ib_srq {
  707. struct ib_device *device;
  708. struct ib_pd *pd;
  709. struct ib_uobject *uobject;
  710. void (*event_handler)(struct ib_event *, void *);
  711. void *srq_context;
  712. atomic_t usecnt;
  713. };
  714. struct ib_qp {
  715. struct ib_device *device;
  716. struct ib_pd *pd;
  717. struct ib_cq *send_cq;
  718. struct ib_cq *recv_cq;
  719. struct ib_srq *srq;
  720. struct ib_uobject *uobject;
  721. void (*event_handler)(struct ib_event *, void *);
  722. void *qp_context;
  723. u32 qp_num;
  724. enum ib_qp_type qp_type;
  725. };
  726. struct ib_mr {
  727. struct ib_device *device;
  728. struct ib_pd *pd;
  729. struct ib_uobject *uobject;
  730. u32 lkey;
  731. u32 rkey;
  732. atomic_t usecnt; /* count number of MWs */
  733. };
  734. struct ib_mw {
  735. struct ib_device *device;
  736. struct ib_pd *pd;
  737. struct ib_uobject *uobject;
  738. u32 rkey;
  739. };
  740. struct ib_fmr {
  741. struct ib_device *device;
  742. struct ib_pd *pd;
  743. struct list_head list;
  744. u32 lkey;
  745. u32 rkey;
  746. };
  747. struct ib_mad;
  748. struct ib_grh;
  749. enum ib_process_mad_flags {
  750. IB_MAD_IGNORE_MKEY = 1,
  751. IB_MAD_IGNORE_BKEY = 2,
  752. IB_MAD_IGNORE_ALL = IB_MAD_IGNORE_MKEY | IB_MAD_IGNORE_BKEY
  753. };
  754. enum ib_mad_result {
  755. IB_MAD_RESULT_FAILURE = 0, /* (!SUCCESS is the important flag) */
  756. IB_MAD_RESULT_SUCCESS = 1 << 0, /* MAD was successfully processed */
  757. IB_MAD_RESULT_REPLY = 1 << 1, /* Reply packet needs to be sent */
  758. IB_MAD_RESULT_CONSUMED = 1 << 2 /* Packet consumed: stop processing */
  759. };
  760. #define IB_DEVICE_NAME_MAX 64
  761. struct ib_cache {
  762. rwlock_t lock;
  763. struct ib_event_handler event_handler;
  764. struct ib_pkey_cache **pkey_cache;
  765. struct ib_gid_cache **gid_cache;
  766. u8 *lmc_cache;
  767. };
  768. struct ib_dma_mapping_ops {
  769. int (*mapping_error)(struct ib_device *dev,
  770. u64 dma_addr);
  771. u64 (*map_single)(struct ib_device *dev,
  772. void *ptr, size_t size,
  773. enum dma_data_direction direction);
  774. void (*unmap_single)(struct ib_device *dev,
  775. u64 addr, size_t size,
  776. enum dma_data_direction direction);
  777. u64 (*map_page)(struct ib_device *dev,
  778. struct page *page, unsigned long offset,
  779. size_t size,
  780. enum dma_data_direction direction);
  781. void (*unmap_page)(struct ib_device *dev,
  782. u64 addr, size_t size,
  783. enum dma_data_direction direction);
  784. int (*map_sg)(struct ib_device *dev,
  785. struct scatterlist *sg, int nents,
  786. enum dma_data_direction direction);
  787. void (*unmap_sg)(struct ib_device *dev,
  788. struct scatterlist *sg, int nents,
  789. enum dma_data_direction direction);
  790. u64 (*dma_address)(struct ib_device *dev,
  791. struct scatterlist *sg);
  792. unsigned int (*dma_len)(struct ib_device *dev,
  793. struct scatterlist *sg);
  794. void (*sync_single_for_cpu)(struct ib_device *dev,
  795. u64 dma_handle,
  796. size_t size,
  797. enum dma_data_direction dir);
  798. void (*sync_single_for_device)(struct ib_device *dev,
  799. u64 dma_handle,
  800. size_t size,
  801. enum dma_data_direction dir);
  802. void *(*alloc_coherent)(struct ib_device *dev,
  803. size_t size,
  804. u64 *dma_handle,
  805. gfp_t flag);
  806. void (*free_coherent)(struct ib_device *dev,
  807. size_t size, void *cpu_addr,
  808. u64 dma_handle);
  809. };
  810. struct iw_cm_verbs;
  811. struct ib_device {
  812. struct device *dma_device;
  813. char name[IB_DEVICE_NAME_MAX];
  814. struct list_head event_handler_list;
  815. spinlock_t event_handler_lock;
  816. struct list_head core_list;
  817. struct list_head client_data_list;
  818. spinlock_t client_data_lock;
  819. struct ib_cache cache;
  820. u32 flags;
  821. struct iw_cm_verbs *iwcm;
  822. int (*query_device)(struct ib_device *device,
  823. struct ib_device_attr *device_attr);
  824. int (*query_port)(struct ib_device *device,
  825. u8 port_num,
  826. struct ib_port_attr *port_attr);
  827. int (*query_gid)(struct ib_device *device,
  828. u8 port_num, int index,
  829. union ib_gid *gid);
  830. int (*query_pkey)(struct ib_device *device,
  831. u8 port_num, u16 index, u16 *pkey);
  832. int (*modify_device)(struct ib_device *device,
  833. int device_modify_mask,
  834. struct ib_device_modify *device_modify);
  835. int (*modify_port)(struct ib_device *device,
  836. u8 port_num, int port_modify_mask,
  837. struct ib_port_modify *port_modify);
  838. struct ib_ucontext * (*alloc_ucontext)(struct ib_device *device,
  839. struct ib_udata *udata);
  840. int (*dealloc_ucontext)(struct ib_ucontext *context);
  841. int (*mmap)(struct ib_ucontext *context,
  842. struct vm_area_struct *vma);
  843. struct ib_pd * (*alloc_pd)(struct ib_device *device,
  844. struct ib_ucontext *context,
  845. struct ib_udata *udata);
  846. int (*dealloc_pd)(struct ib_pd *pd);
  847. struct ib_ah * (*create_ah)(struct ib_pd *pd,
  848. struct ib_ah_attr *ah_attr);
  849. int (*modify_ah)(struct ib_ah *ah,
  850. struct ib_ah_attr *ah_attr);
  851. int (*query_ah)(struct ib_ah *ah,
  852. struct ib_ah_attr *ah_attr);
  853. int (*destroy_ah)(struct ib_ah *ah);
  854. struct ib_srq * (*create_srq)(struct ib_pd *pd,
  855. struct ib_srq_init_attr *srq_init_attr,
  856. struct ib_udata *udata);
  857. int (*modify_srq)(struct ib_srq *srq,
  858. struct ib_srq_attr *srq_attr,
  859. enum ib_srq_attr_mask srq_attr_mask,
  860. struct ib_udata *udata);
  861. int (*query_srq)(struct ib_srq *srq,
  862. struct ib_srq_attr *srq_attr);
  863. int (*destroy_srq)(struct ib_srq *srq);
  864. int (*post_srq_recv)(struct ib_srq *srq,
  865. struct ib_recv_wr *recv_wr,
  866. struct ib_recv_wr **bad_recv_wr);
  867. struct ib_qp * (*create_qp)(struct ib_pd *pd,
  868. struct ib_qp_init_attr *qp_init_attr,
  869. struct ib_udata *udata);
  870. int (*modify_qp)(struct ib_qp *qp,
  871. struct ib_qp_attr *qp_attr,
  872. int qp_attr_mask,
  873. struct ib_udata *udata);
  874. int (*query_qp)(struct ib_qp *qp,
  875. struct ib_qp_attr *qp_attr,
  876. int qp_attr_mask,
  877. struct ib_qp_init_attr *qp_init_attr);
  878. int (*destroy_qp)(struct ib_qp *qp);
  879. int (*post_send)(struct ib_qp *qp,
  880. struct ib_send_wr *send_wr,
  881. struct ib_send_wr **bad_send_wr);
  882. int (*post_recv)(struct ib_qp *qp,
  883. struct ib_recv_wr *recv_wr,
  884. struct ib_recv_wr **bad_recv_wr);
  885. struct ib_cq * (*create_cq)(struct ib_device *device, int cqe,
  886. struct ib_ucontext *context,
  887. struct ib_udata *udata);
  888. int (*destroy_cq)(struct ib_cq *cq);
  889. int (*resize_cq)(struct ib_cq *cq, int cqe,
  890. struct ib_udata *udata);
  891. int (*poll_cq)(struct ib_cq *cq, int num_entries,
  892. struct ib_wc *wc);
  893. int (*peek_cq)(struct ib_cq *cq, int wc_cnt);
  894. int (*req_notify_cq)(struct ib_cq *cq,
  895. enum ib_cq_notify cq_notify);
  896. int (*req_ncomp_notif)(struct ib_cq *cq,
  897. int wc_cnt);
  898. struct ib_mr * (*get_dma_mr)(struct ib_pd *pd,
  899. int mr_access_flags);
  900. struct ib_mr * (*reg_phys_mr)(struct ib_pd *pd,
  901. struct ib_phys_buf *phys_buf_array,
  902. int num_phys_buf,
  903. int mr_access_flags,
  904. u64 *iova_start);
  905. struct ib_mr * (*reg_user_mr)(struct ib_pd *pd,
  906. struct ib_umem *region,
  907. int mr_access_flags,
  908. struct ib_udata *udata);
  909. int (*query_mr)(struct ib_mr *mr,
  910. struct ib_mr_attr *mr_attr);
  911. int (*dereg_mr)(struct ib_mr *mr);
  912. int (*rereg_phys_mr)(struct ib_mr *mr,
  913. int mr_rereg_mask,
  914. struct ib_pd *pd,
  915. struct ib_phys_buf *phys_buf_array,
  916. int num_phys_buf,
  917. int mr_access_flags,
  918. u64 *iova_start);
  919. struct ib_mw * (*alloc_mw)(struct ib_pd *pd);
  920. int (*bind_mw)(struct ib_qp *qp,
  921. struct ib_mw *mw,
  922. struct ib_mw_bind *mw_bind);
  923. int (*dealloc_mw)(struct ib_mw *mw);
  924. struct ib_fmr * (*alloc_fmr)(struct ib_pd *pd,
  925. int mr_access_flags,
  926. struct ib_fmr_attr *fmr_attr);
  927. int (*map_phys_fmr)(struct ib_fmr *fmr,
  928. u64 *page_list, int list_len,
  929. u64 iova);
  930. int (*unmap_fmr)(struct list_head *fmr_list);
  931. int (*dealloc_fmr)(struct ib_fmr *fmr);
  932. int (*attach_mcast)(struct ib_qp *qp,
  933. union ib_gid *gid,
  934. u16 lid);
  935. int (*detach_mcast)(struct ib_qp *qp,
  936. union ib_gid *gid,
  937. u16 lid);
  938. int (*process_mad)(struct ib_device *device,
  939. int process_mad_flags,
  940. u8 port_num,
  941. struct ib_wc *in_wc,
  942. struct ib_grh *in_grh,
  943. struct ib_mad *in_mad,
  944. struct ib_mad *out_mad);
  945. struct ib_dma_mapping_ops *dma_ops;
  946. struct module *owner;
  947. struct class_device class_dev;
  948. struct kobject ports_parent;
  949. struct list_head port_list;
  950. enum {
  951. IB_DEV_UNINITIALIZED,
  952. IB_DEV_REGISTERED,
  953. IB_DEV_UNREGISTERED
  954. } reg_state;
  955. u64 uverbs_cmd_mask;
  956. int uverbs_abi_ver;
  957. char node_desc[64];
  958. __be64 node_guid;
  959. u8 node_type;
  960. u8 phys_port_cnt;
  961. };
  962. struct ib_client {
  963. char *name;
  964. void (*add) (struct ib_device *);
  965. void (*remove)(struct ib_device *);
  966. struct list_head list;
  967. };
  968. struct ib_device *ib_alloc_device(size_t size);
  969. void ib_dealloc_device(struct ib_device *device);
  970. int ib_register_device (struct ib_device *device);
  971. void ib_unregister_device(struct ib_device *device);
  972. int ib_register_client (struct ib_client *client);
  973. void ib_unregister_client(struct ib_client *client);
  974. void *ib_get_client_data(struct ib_device *device, struct ib_client *client);
  975. void ib_set_client_data(struct ib_device *device, struct ib_client *client,
  976. void *data);
  977. static inline int ib_copy_from_udata(void *dest, struct ib_udata *udata, size_t len)
  978. {
  979. return copy_from_user(dest, udata->inbuf, len) ? -EFAULT : 0;
  980. }
  981. static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len)
  982. {
  983. return copy_to_user(udata->outbuf, src, len) ? -EFAULT : 0;
  984. }
  985. /**
  986. * ib_modify_qp_is_ok - Check that the supplied attribute mask
  987. * contains all required attributes and no attributes not allowed for
  988. * the given QP state transition.
  989. * @cur_state: Current QP state
  990. * @next_state: Next QP state
  991. * @type: QP type
  992. * @mask: Mask of supplied QP attributes
  993. *
  994. * This function is a helper function that a low-level driver's
  995. * modify_qp method can use to validate the consumer's input. It
  996. * checks that cur_state and next_state are valid QP states, that a
  997. * transition from cur_state to next_state is allowed by the IB spec,
  998. * and that the attribute mask supplied is allowed for the transition.
  999. */
  1000. int ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state,
  1001. enum ib_qp_type type, enum ib_qp_attr_mask mask);
  1002. int ib_register_event_handler (struct ib_event_handler *event_handler);
  1003. int ib_unregister_event_handler(struct ib_event_handler *event_handler);
  1004. void ib_dispatch_event(struct ib_event *event);
  1005. int ib_query_device(struct ib_device *device,
  1006. struct ib_device_attr *device_attr);
  1007. int ib_query_port(struct ib_device *device,
  1008. u8 port_num, struct ib_port_attr *port_attr);
  1009. int ib_query_gid(struct ib_device *device,
  1010. u8 port_num, int index, union ib_gid *gid);
  1011. int ib_query_pkey(struct ib_device *device,
  1012. u8 port_num, u16 index, u16 *pkey);
  1013. int ib_modify_device(struct ib_device *device,
  1014. int device_modify_mask,
  1015. struct ib_device_modify *device_modify);
  1016. int ib_modify_port(struct ib_device *device,
  1017. u8 port_num, int port_modify_mask,
  1018. struct ib_port_modify *port_modify);
  1019. /**
  1020. * ib_alloc_pd - Allocates an unused protection domain.
  1021. * @device: The device on which to allocate the protection domain.
  1022. *
  1023. * A protection domain object provides an association between QPs, shared
  1024. * receive queues, address handles, memory regions, and memory windows.
  1025. */
  1026. struct ib_pd *ib_alloc_pd(struct ib_device *device);
  1027. /**
  1028. * ib_dealloc_pd - Deallocates a protection domain.
  1029. * @pd: The protection domain to deallocate.
  1030. */
  1031. int ib_dealloc_pd(struct ib_pd *pd);
  1032. /**
  1033. * ib_create_ah - Creates an address handle for the given address vector.
  1034. * @pd: The protection domain associated with the address handle.
  1035. * @ah_attr: The attributes of the address vector.
  1036. *
  1037. * The address handle is used to reference a local or global destination
  1038. * in all UD QP post sends.
  1039. */
  1040. struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr);
  1041. /**
  1042. * ib_init_ah_from_wc - Initializes address handle attributes from a
  1043. * work completion.
  1044. * @device: Device on which the received message arrived.
  1045. * @port_num: Port on which the received message arrived.
  1046. * @wc: Work completion associated with the received message.
  1047. * @grh: References the received global route header. This parameter is
  1048. * ignored unless the work completion indicates that the GRH is valid.
  1049. * @ah_attr: Returned attributes that can be used when creating an address
  1050. * handle for replying to the message.
  1051. */
  1052. int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
  1053. struct ib_grh *grh, struct ib_ah_attr *ah_attr);
  1054. /**
  1055. * ib_create_ah_from_wc - Creates an address handle associated with the
  1056. * sender of the specified work completion.
  1057. * @pd: The protection domain associated with the address handle.
  1058. * @wc: Work completion information associated with a received message.
  1059. * @grh: References the received global route header. This parameter is
  1060. * ignored unless the work completion indicates that the GRH is valid.
  1061. * @port_num: The outbound port number to associate with the address.
  1062. *
  1063. * The address handle is used to reference a local or global destination
  1064. * in all UD QP post sends.
  1065. */
  1066. struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc,
  1067. struct ib_grh *grh, u8 port_num);
  1068. /**
  1069. * ib_modify_ah - Modifies the address vector associated with an address
  1070. * handle.
  1071. * @ah: The address handle to modify.
  1072. * @ah_attr: The new address vector attributes to associate with the
  1073. * address handle.
  1074. */
  1075. int ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
  1076. /**
  1077. * ib_query_ah - Queries the address vector associated with an address
  1078. * handle.
  1079. * @ah: The address handle to query.
  1080. * @ah_attr: The address vector attributes associated with the address
  1081. * handle.
  1082. */
  1083. int ib_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
  1084. /**
  1085. * ib_destroy_ah - Destroys an address handle.
  1086. * @ah: The address handle to destroy.
  1087. */
  1088. int ib_destroy_ah(struct ib_ah *ah);
  1089. /**
  1090. * ib_create_srq - Creates a SRQ associated with the specified protection
  1091. * domain.
  1092. * @pd: The protection domain associated with the SRQ.
  1093. * @srq_init_attr: A list of initial attributes required to create the
  1094. * SRQ. If SRQ creation succeeds, then the attributes are updated to
  1095. * the actual capabilities of the created SRQ.
  1096. *
  1097. * srq_attr->max_wr and srq_attr->max_sge are read the determine the
  1098. * requested size of the SRQ, and set to the actual values allocated
  1099. * on return. If ib_create_srq() succeeds, then max_wr and max_sge
  1100. * will always be at least as large as the requested values.
  1101. */
  1102. struct ib_srq *ib_create_srq(struct ib_pd *pd,
  1103. struct ib_srq_init_attr *srq_init_attr);
  1104. /**
  1105. * ib_modify_srq - Modifies the attributes for the specified SRQ.
  1106. * @srq: The SRQ to modify.
  1107. * @srq_attr: On input, specifies the SRQ attributes to modify. On output,
  1108. * the current values of selected SRQ attributes are returned.
  1109. * @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ
  1110. * are being modified.
  1111. *
  1112. * The mask may contain IB_SRQ_MAX_WR to resize the SRQ and/or
  1113. * IB_SRQ_LIMIT to set the SRQ's limit and request notification when
  1114. * the number of receives queued drops below the limit.
  1115. */
  1116. int ib_modify_srq(struct ib_srq *srq,
  1117. struct ib_srq_attr *srq_attr,
  1118. enum ib_srq_attr_mask srq_attr_mask);
  1119. /**
  1120. * ib_query_srq - Returns the attribute list and current values for the
  1121. * specified SRQ.
  1122. * @srq: The SRQ to query.
  1123. * @srq_attr: The attributes of the specified SRQ.
  1124. */
  1125. int ib_query_srq(struct ib_srq *srq,
  1126. struct ib_srq_attr *srq_attr);
  1127. /**
  1128. * ib_destroy_srq - Destroys the specified SRQ.
  1129. * @srq: The SRQ to destroy.
  1130. */
  1131. int ib_destroy_srq(struct ib_srq *srq);
  1132. /**
  1133. * ib_post_srq_recv - Posts a list of work requests to the specified SRQ.
  1134. * @srq: The SRQ to post the work request on.
  1135. * @recv_wr: A list of work requests to post on the receive queue.
  1136. * @bad_recv_wr: On an immediate failure, this parameter will reference
  1137. * the work request that failed to be posted on the QP.
  1138. */
  1139. static inline int ib_post_srq_recv(struct ib_srq *srq,
  1140. struct ib_recv_wr *recv_wr,
  1141. struct ib_recv_wr **bad_recv_wr)
  1142. {
  1143. return srq->device->post_srq_recv(srq, recv_wr, bad_recv_wr);
  1144. }
  1145. /**
  1146. * ib_create_qp - Creates a QP associated with the specified protection
  1147. * domain.
  1148. * @pd: The protection domain associated with the QP.
  1149. * @qp_init_attr: A list of initial attributes required to create the
  1150. * QP. If QP creation succeeds, then the attributes are updated to
  1151. * the actual capabilities of the created QP.
  1152. */
  1153. struct ib_qp *ib_create_qp(struct ib_pd *pd,
  1154. struct ib_qp_init_attr *qp_init_attr);
  1155. /**
  1156. * ib_modify_qp - Modifies the attributes for the specified QP and then
  1157. * transitions the QP to the given state.
  1158. * @qp: The QP to modify.
  1159. * @qp_attr: On input, specifies the QP attributes to modify. On output,
  1160. * the current values of selected QP attributes are returned.
  1161. * @qp_attr_mask: A bit-mask used to specify which attributes of the QP
  1162. * are being modified.
  1163. */
  1164. int ib_modify_qp(struct ib_qp *qp,
  1165. struct ib_qp_attr *qp_attr,
  1166. int qp_attr_mask);
  1167. /**
  1168. * ib_query_qp - Returns the attribute list and current values for the
  1169. * specified QP.
  1170. * @qp: The QP to query.
  1171. * @qp_attr: The attributes of the specified QP.
  1172. * @qp_attr_mask: A bit-mask used to select specific attributes to query.
  1173. * @qp_init_attr: Additional attributes of the selected QP.
  1174. *
  1175. * The qp_attr_mask may be used to limit the query to gathering only the
  1176. * selected attributes.
  1177. */
  1178. int ib_query_qp(struct ib_qp *qp,
  1179. struct ib_qp_attr *qp_attr,
  1180. int qp_attr_mask,
  1181. struct ib_qp_init_attr *qp_init_attr);
  1182. /**
  1183. * ib_destroy_qp - Destroys the specified QP.
  1184. * @qp: The QP to destroy.
  1185. */
  1186. int ib_destroy_qp(struct ib_qp *qp);
  1187. /**
  1188. * ib_post_send - Posts a list of work requests to the send queue of
  1189. * the specified QP.
  1190. * @qp: The QP to post the work request on.
  1191. * @send_wr: A list of work requests to post on the send queue.
  1192. * @bad_send_wr: On an immediate failure, this parameter will reference
  1193. * the work request that failed to be posted on the QP.
  1194. */
  1195. static inline int ib_post_send(struct ib_qp *qp,
  1196. struct ib_send_wr *send_wr,
  1197. struct ib_send_wr **bad_send_wr)
  1198. {
  1199. return qp->device->post_send(qp, send_wr, bad_send_wr);
  1200. }
  1201. /**
  1202. * ib_post_recv - Posts a list of work requests to the receive queue of
  1203. * the specified QP.
  1204. * @qp: The QP to post the work request on.
  1205. * @recv_wr: A list of work requests to post on the receive queue.
  1206. * @bad_recv_wr: On an immediate failure, this parameter will reference
  1207. * the work request that failed to be posted on the QP.
  1208. */
  1209. static inline int ib_post_recv(struct ib_qp *qp,
  1210. struct ib_recv_wr *recv_wr,
  1211. struct ib_recv_wr **bad_recv_wr)
  1212. {
  1213. return qp->device->post_recv(qp, recv_wr, bad_recv_wr);
  1214. }
  1215. /**
  1216. * ib_create_cq - Creates a CQ on the specified device.
  1217. * @device: The device on which to create the CQ.
  1218. * @comp_handler: A user-specified callback that is invoked when a
  1219. * completion event occurs on the CQ.
  1220. * @event_handler: A user-specified callback that is invoked when an
  1221. * asynchronous event not associated with a completion occurs on the CQ.
  1222. * @cq_context: Context associated with the CQ returned to the user via
  1223. * the associated completion and event handlers.
  1224. * @cqe: The minimum size of the CQ.
  1225. *
  1226. * Users can examine the cq structure to determine the actual CQ size.
  1227. */
  1228. struct ib_cq *ib_create_cq(struct ib_device *device,
  1229. ib_comp_handler comp_handler,
  1230. void (*event_handler)(struct ib_event *, void *),
  1231. void *cq_context, int cqe);
  1232. /**
  1233. * ib_resize_cq - Modifies the capacity of the CQ.
  1234. * @cq: The CQ to resize.
  1235. * @cqe: The minimum size of the CQ.
  1236. *
  1237. * Users can examine the cq structure to determine the actual CQ size.
  1238. */
  1239. int ib_resize_cq(struct ib_cq *cq, int cqe);
  1240. /**
  1241. * ib_destroy_cq - Destroys the specified CQ.
  1242. * @cq: The CQ to destroy.
  1243. */
  1244. int ib_destroy_cq(struct ib_cq *cq);
  1245. /**
  1246. * ib_poll_cq - poll a CQ for completion(s)
  1247. * @cq:the CQ being polled
  1248. * @num_entries:maximum number of completions to return
  1249. * @wc:array of at least @num_entries &struct ib_wc where completions
  1250. * will be returned
  1251. *
  1252. * Poll a CQ for (possibly multiple) completions. If the return value
  1253. * is < 0, an error occurred. If the return value is >= 0, it is the
  1254. * number of completions returned. If the return value is
  1255. * non-negative and < num_entries, then the CQ was emptied.
  1256. */
  1257. static inline int ib_poll_cq(struct ib_cq *cq, int num_entries,
  1258. struct ib_wc *wc)
  1259. {
  1260. return cq->device->poll_cq(cq, num_entries, wc);
  1261. }
  1262. /**
  1263. * ib_peek_cq - Returns the number of unreaped completions currently
  1264. * on the specified CQ.
  1265. * @cq: The CQ to peek.
  1266. * @wc_cnt: A minimum number of unreaped completions to check for.
  1267. *
  1268. * If the number of unreaped completions is greater than or equal to wc_cnt,
  1269. * this function returns wc_cnt, otherwise, it returns the actual number of
  1270. * unreaped completions.
  1271. */
  1272. int ib_peek_cq(struct ib_cq *cq, int wc_cnt);
  1273. /**
  1274. * ib_req_notify_cq - Request completion notification on a CQ.
  1275. * @cq: The CQ to generate an event for.
  1276. * @cq_notify: If set to %IB_CQ_SOLICITED, completion notification will
  1277. * occur on the next solicited event. If set to %IB_CQ_NEXT_COMP,
  1278. * notification will occur on the next completion.
  1279. */
  1280. static inline int ib_req_notify_cq(struct ib_cq *cq,
  1281. enum ib_cq_notify cq_notify)
  1282. {
  1283. return cq->device->req_notify_cq(cq, cq_notify);
  1284. }
  1285. /**
  1286. * ib_req_ncomp_notif - Request completion notification when there are
  1287. * at least the specified number of unreaped completions on the CQ.
  1288. * @cq: The CQ to generate an event for.
  1289. * @wc_cnt: The number of unreaped completions that should be on the
  1290. * CQ before an event is generated.
  1291. */
  1292. static inline int ib_req_ncomp_notif(struct ib_cq *cq, int wc_cnt)
  1293. {
  1294. return cq->device->req_ncomp_notif ?
  1295. cq->device->req_ncomp_notif(cq, wc_cnt) :
  1296. -ENOSYS;
  1297. }
  1298. /**
  1299. * ib_get_dma_mr - Returns a memory region for system memory that is
  1300. * usable for DMA.
  1301. * @pd: The protection domain associated with the memory region.
  1302. * @mr_access_flags: Specifies the memory access rights.
  1303. *
  1304. * Note that the ib_dma_*() functions defined below must be used
  1305. * to create/destroy addresses used with the Lkey or Rkey returned
  1306. * by ib_get_dma_mr().
  1307. */
  1308. struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
  1309. /**
  1310. * ib_dma_mapping_error - check a DMA addr for error
  1311. * @dev: The device for which the dma_addr was created
  1312. * @dma_addr: The DMA address to check
  1313. */
  1314. static inline int ib_dma_mapping_error(struct ib_device *dev, u64 dma_addr)
  1315. {
  1316. if (dev->dma_ops)
  1317. return dev->dma_ops->mapping_error(dev, dma_addr);
  1318. return dma_mapping_error(dma_addr);
  1319. }
  1320. /**
  1321. * ib_dma_map_single - Map a kernel virtual address to DMA address
  1322. * @dev: The device for which the dma_addr is to be created
  1323. * @cpu_addr: The kernel virtual address
  1324. * @size: The size of the region in bytes
  1325. * @direction: The direction of the DMA
  1326. */
  1327. static inline u64 ib_dma_map_single(struct ib_device *dev,
  1328. void *cpu_addr, size_t size,
  1329. enum dma_data_direction direction)
  1330. {
  1331. if (dev->dma_ops)
  1332. return dev->dma_ops->map_single(dev, cpu_addr, size, direction);
  1333. return dma_map_single(dev->dma_device, cpu_addr, size, direction);
  1334. }
  1335. /**
  1336. * ib_dma_unmap_single - Destroy a mapping created by ib_dma_map_single()
  1337. * @dev: The device for which the DMA address was created
  1338. * @addr: The DMA address
  1339. * @size: The size of the region in bytes
  1340. * @direction: The direction of the DMA
  1341. */
  1342. static inline void ib_dma_unmap_single(struct ib_device *dev,
  1343. u64 addr, size_t size,
  1344. enum dma_data_direction direction)
  1345. {
  1346. if (dev->dma_ops)
  1347. dev->dma_ops->unmap_single(dev, addr, size, direction);
  1348. else
  1349. dma_unmap_single(dev->dma_device, addr, size, direction);
  1350. }
  1351. /**
  1352. * ib_dma_map_page - Map a physical page to DMA address
  1353. * @dev: The device for which the dma_addr is to be created
  1354. * @page: The page to be mapped
  1355. * @offset: The offset within the page
  1356. * @size: The size of the region in bytes
  1357. * @direction: The direction of the DMA
  1358. */
  1359. static inline u64 ib_dma_map_page(struct ib_device *dev,
  1360. struct page *page,
  1361. unsigned long offset,
  1362. size_t size,
  1363. enum dma_data_direction direction)
  1364. {
  1365. if (dev->dma_ops)
  1366. return dev->dma_ops->map_page(dev, page, offset, size, direction);
  1367. return dma_map_page(dev->dma_device, page, offset, size, direction);
  1368. }
  1369. /**
  1370. * ib_dma_unmap_page - Destroy a mapping created by ib_dma_map_page()
  1371. * @dev: The device for which the DMA address was created
  1372. * @addr: The DMA address
  1373. * @size: The size of the region in bytes
  1374. * @direction: The direction of the DMA
  1375. */
  1376. static inline void ib_dma_unmap_page(struct ib_device *dev,
  1377. u64 addr, size_t size,
  1378. enum dma_data_direction direction)
  1379. {
  1380. if (dev->dma_ops)
  1381. dev->dma_ops->unmap_page(dev, addr, size, direction);
  1382. else
  1383. dma_unmap_page(dev->dma_device, addr, size, direction);
  1384. }
  1385. /**
  1386. * ib_dma_map_sg - Map a scatter/gather list to DMA addresses
  1387. * @dev: The device for which the DMA addresses are to be created
  1388. * @sg: The array of scatter/gather entries
  1389. * @nents: The number of scatter/gather entries
  1390. * @direction: The direction of the DMA
  1391. */
  1392. static inline int ib_dma_map_sg(struct ib_device *dev,
  1393. struct scatterlist *sg, int nents,
  1394. enum dma_data_direction direction)
  1395. {
  1396. if (dev->dma_ops)
  1397. return dev->dma_ops->map_sg(dev, sg, nents, direction);
  1398. return dma_map_sg(dev->dma_device, sg, nents, direction);
  1399. }
  1400. /**
  1401. * ib_dma_unmap_sg - Unmap a scatter/gather list of DMA addresses
  1402. * @dev: The device for which the DMA addresses were created
  1403. * @sg: The array of scatter/gather entries
  1404. * @nents: The number of scatter/gather entries
  1405. * @direction: The direction of the DMA
  1406. */
  1407. static inline void ib_dma_unmap_sg(struct ib_device *dev,
  1408. struct scatterlist *sg, int nents,
  1409. enum dma_data_direction direction)
  1410. {
  1411. if (dev->dma_ops)
  1412. dev->dma_ops->unmap_sg(dev, sg, nents, direction);
  1413. else
  1414. dma_unmap_sg(dev->dma_device, sg, nents, direction);
  1415. }
  1416. /**
  1417. * ib_sg_dma_address - Return the DMA address from a scatter/gather entry
  1418. * @dev: The device for which the DMA addresses were created
  1419. * @sg: The scatter/gather entry
  1420. */
  1421. static inline u64 ib_sg_dma_address(struct ib_device *dev,
  1422. struct scatterlist *sg)
  1423. {
  1424. if (dev->dma_ops)
  1425. return dev->dma_ops->dma_address(dev, sg);
  1426. return sg_dma_address(sg);
  1427. }
  1428. /**
  1429. * ib_sg_dma_len - Return the DMA length from a scatter/gather entry
  1430. * @dev: The device for which the DMA addresses were created
  1431. * @sg: The scatter/gather entry
  1432. */
  1433. static inline unsigned int ib_sg_dma_len(struct ib_device *dev,
  1434. struct scatterlist *sg)
  1435. {
  1436. if (dev->dma_ops)
  1437. return dev->dma_ops->dma_len(dev, sg);
  1438. return sg_dma_len(sg);
  1439. }
  1440. /**
  1441. * ib_dma_sync_single_for_cpu - Prepare DMA region to be accessed by CPU
  1442. * @dev: The device for which the DMA address was created
  1443. * @addr: The DMA address
  1444. * @size: The size of the region in bytes
  1445. * @dir: The direction of the DMA
  1446. */
  1447. static inline void ib_dma_sync_single_for_cpu(struct ib_device *dev,
  1448. u64 addr,
  1449. size_t size,
  1450. enum dma_data_direction dir)
  1451. {
  1452. if (dev->dma_ops)
  1453. dev->dma_ops->sync_single_for_cpu(dev, addr, size, dir);
  1454. else
  1455. dma_sync_single_for_cpu(dev->dma_device, addr, size, dir);
  1456. }
  1457. /**
  1458. * ib_dma_sync_single_for_device - Prepare DMA region to be accessed by device
  1459. * @dev: The device for which the DMA address was created
  1460. * @addr: The DMA address
  1461. * @size: The size of the region in bytes
  1462. * @dir: The direction of the DMA
  1463. */
  1464. static inline void ib_dma_sync_single_for_device(struct ib_device *dev,
  1465. u64 addr,
  1466. size_t size,
  1467. enum dma_data_direction dir)
  1468. {
  1469. if (dev->dma_ops)
  1470. dev->dma_ops->sync_single_for_device(dev, addr, size, dir);
  1471. else
  1472. dma_sync_single_for_device(dev->dma_device, addr, size, dir);
  1473. }
  1474. /**
  1475. * ib_dma_alloc_coherent - Allocate memory and map it for DMA
  1476. * @dev: The device for which the DMA address is requested
  1477. * @size: The size of the region to allocate in bytes
  1478. * @dma_handle: A pointer for returning the DMA address of the region
  1479. * @flag: memory allocator flags
  1480. */
  1481. static inline void *ib_dma_alloc_coherent(struct ib_device *dev,
  1482. size_t size,
  1483. u64 *dma_handle,
  1484. gfp_t flag)
  1485. {
  1486. if (dev->dma_ops)
  1487. return dev->dma_ops->alloc_coherent(dev, size, dma_handle, flag);
  1488. else {
  1489. dma_addr_t handle;
  1490. void *ret;
  1491. ret = dma_alloc_coherent(dev->dma_device, size, &handle, flag);
  1492. *dma_handle = handle;
  1493. return ret;
  1494. }
  1495. }
  1496. /**
  1497. * ib_dma_free_coherent - Free memory allocated by ib_dma_alloc_coherent()
  1498. * @dev: The device for which the DMA addresses were allocated
  1499. * @size: The size of the region
  1500. * @cpu_addr: the address returned by ib_dma_alloc_coherent()
  1501. * @dma_handle: the DMA address returned by ib_dma_alloc_coherent()
  1502. */
  1503. static inline void ib_dma_free_coherent(struct ib_device *dev,
  1504. size_t size, void *cpu_addr,
  1505. u64 dma_handle)
  1506. {
  1507. if (dev->dma_ops)
  1508. dev->dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
  1509. else
  1510. dma_free_coherent(dev->dma_device, size, cpu_addr, dma_handle);
  1511. }
  1512. /**
  1513. * ib_reg_phys_mr - Prepares a virtually addressed memory region for use
  1514. * by an HCA.
  1515. * @pd: The protection domain associated assigned to the registered region.
  1516. * @phys_buf_array: Specifies a list of physical buffers to use in the
  1517. * memory region.
  1518. * @num_phys_buf: Specifies the size of the phys_buf_array.
  1519. * @mr_access_flags: Specifies the memory access rights.
  1520. * @iova_start: The offset of the region's starting I/O virtual address.
  1521. */
  1522. struct ib_mr *ib_reg_phys_mr(struct ib_pd *pd,
  1523. struct ib_phys_buf *phys_buf_array,
  1524. int num_phys_buf,
  1525. int mr_access_flags,
  1526. u64 *iova_start);
  1527. /**
  1528. * ib_rereg_phys_mr - Modifies the attributes of an existing memory region.
  1529. * Conceptually, this call performs the functions deregister memory region
  1530. * followed by register physical memory region. Where possible,
  1531. * resources are reused instead of deallocated and reallocated.
  1532. * @mr: The memory region to modify.
  1533. * @mr_rereg_mask: A bit-mask used to indicate which of the following
  1534. * properties of the memory region are being modified.
  1535. * @pd: If %IB_MR_REREG_PD is set in mr_rereg_mask, this field specifies
  1536. * the new protection domain to associated with the memory region,
  1537. * otherwise, this parameter is ignored.
  1538. * @phys_buf_array: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
  1539. * field specifies a list of physical buffers to use in the new
  1540. * translation, otherwise, this parameter is ignored.
  1541. * @num_phys_buf: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
  1542. * field specifies the size of the phys_buf_array, otherwise, this
  1543. * parameter is ignored.
  1544. * @mr_access_flags: If %IB_MR_REREG_ACCESS is set in mr_rereg_mask, this
  1545. * field specifies the new memory access rights, otherwise, this
  1546. * parameter is ignored.
  1547. * @iova_start: The offset of the region's starting I/O virtual address.
  1548. */
  1549. int ib_rereg_phys_mr(struct ib_mr *mr,
  1550. int mr_rereg_mask,
  1551. struct ib_pd *pd,
  1552. struct ib_phys_buf *phys_buf_array,
  1553. int num_phys_buf,
  1554. int mr_access_flags,
  1555. u64 *iova_start);
  1556. /**
  1557. * ib_query_mr - Retrieves information about a specific memory region.
  1558. * @mr: The memory region to retrieve information about.
  1559. * @mr_attr: The attributes of the specified memory region.
  1560. */
  1561. int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr);
  1562. /**
  1563. * ib_dereg_mr - Deregisters a memory region and removes it from the
  1564. * HCA translation table.
  1565. * @mr: The memory region to deregister.
  1566. */
  1567. int ib_dereg_mr(struct ib_mr *mr);
  1568. /**
  1569. * ib_alloc_mw - Allocates a memory window.
  1570. * @pd: The protection domain associated with the memory window.
  1571. */
  1572. struct ib_mw *ib_alloc_mw(struct ib_pd *pd);
  1573. /**
  1574. * ib_bind_mw - Posts a work request to the send queue of the specified
  1575. * QP, which binds the memory window to the given address range and
  1576. * remote access attributes.
  1577. * @qp: QP to post the bind work request on.
  1578. * @mw: The memory window to bind.
  1579. * @mw_bind: Specifies information about the memory window, including
  1580. * its address range, remote access rights, and associated memory region.
  1581. */
  1582. static inline int ib_bind_mw(struct ib_qp *qp,
  1583. struct ib_mw *mw,
  1584. struct ib_mw_bind *mw_bind)
  1585. {
  1586. /* XXX reference counting in corresponding MR? */
  1587. return mw->device->bind_mw ?
  1588. mw->device->bind_mw(qp, mw, mw_bind) :
  1589. -ENOSYS;
  1590. }
  1591. /**
  1592. * ib_dealloc_mw - Deallocates a memory window.
  1593. * @mw: The memory window to deallocate.
  1594. */
  1595. int ib_dealloc_mw(struct ib_mw *mw);
  1596. /**
  1597. * ib_alloc_fmr - Allocates a unmapped fast memory region.
  1598. * @pd: The protection domain associated with the unmapped region.
  1599. * @mr_access_flags: Specifies the memory access rights.
  1600. * @fmr_attr: Attributes of the unmapped region.
  1601. *
  1602. * A fast memory region must be mapped before it can be used as part of
  1603. * a work request.
  1604. */
  1605. struct ib_fmr *ib_alloc_fmr(struct ib_pd *pd,
  1606. int mr_access_flags,
  1607. struct ib_fmr_attr *fmr_attr);
  1608. /**
  1609. * ib_map_phys_fmr - Maps a list of physical pages to a fast memory region.
  1610. * @fmr: The fast memory region to associate with the pages.
  1611. * @page_list: An array of physical pages to map to the fast memory region.
  1612. * @list_len: The number of pages in page_list.
  1613. * @iova: The I/O virtual address to use with the mapped region.
  1614. */
  1615. static inline int ib_map_phys_fmr(struct ib_fmr *fmr,
  1616. u64 *page_list, int list_len,
  1617. u64 iova)
  1618. {
  1619. return fmr->device->map_phys_fmr(fmr, page_list, list_len, iova);
  1620. }
  1621. /**
  1622. * ib_unmap_fmr - Removes the mapping from a list of fast memory regions.
  1623. * @fmr_list: A linked list of fast memory regions to unmap.
  1624. */
  1625. int ib_unmap_fmr(struct list_head *fmr_list);
  1626. /**
  1627. * ib_dealloc_fmr - Deallocates a fast memory region.
  1628. * @fmr: The fast memory region to deallocate.
  1629. */
  1630. int ib_dealloc_fmr(struct ib_fmr *fmr);
  1631. /**
  1632. * ib_attach_mcast - Attaches the specified QP to a multicast group.
  1633. * @qp: QP to attach to the multicast group. The QP must be type
  1634. * IB_QPT_UD.
  1635. * @gid: Multicast group GID.
  1636. * @lid: Multicast group LID in host byte order.
  1637. *
  1638. * In order to send and receive multicast packets, subnet
  1639. * administration must have created the multicast group and configured
  1640. * the fabric appropriately. The port associated with the specified
  1641. * QP must also be a member of the multicast group.
  1642. */
  1643. int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
  1644. /**
  1645. * ib_detach_mcast - Detaches the specified QP from a multicast group.
  1646. * @qp: QP to detach from the multicast group.
  1647. * @gid: Multicast group GID.
  1648. * @lid: Multicast group LID in host byte order.
  1649. */
  1650. int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
  1651. #endif /* IB_VERBS_H */