ib_verbs.h 36 KB

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