ib_verbs.h 68 KB

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