1#ifndef INFINIBAND_OFA_VERBS_H
2#define INFINIBAND_OFA_VERBS_H
3
4struct ibv_srq_init_attr;
5struct ibv_cq;
6struct ibv_pd;
7struct ibv_qp_init_attr;
8struct ibv_qp_attr;
9
10
11#ifdef __GNUC__
12#define DEPRECATED  __attribute__((deprecated))
13#else
14#define DEPRECATED
15#endif
16
17/* XRC compatability layer */
18#define LEGACY_XRC_SRQ_HANDLE 0xffffffff
19
20struct ibv_xrc_domain {
21	struct ibv_context     *context;
22	uint32_t		handle;
23};
24
25struct ibv_srq_legacy {
26	struct ibv_context     *context;
27	void		       *srq_context;
28	struct ibv_pd	       *pd;
29	uint32_t		handle;
30
31	uint32_t		events_completed;
32
33	uint32_t		xrc_srq_num_bin_compat;
34	struct ibv_xrc_domain  *xrc_domain_bin_compat;
35	struct ibv_cq	       *xrc_cq_bin_compat;
36
37	pthread_mutex_t		mutex;
38	pthread_cond_t		cond;
39	/* Here we hook the new one from OFED 2.0 */
40	void 			*ibv_srq;
41	/* Below 3 fields are for legacy source compatibility, reside
42	  * on same offset as of those fields in struct ibv_srq.
43	*/
44	uint32_t	    xrc_srq_num;
45	struct ibv_xrc_domain  *xrc_domain;
46	struct ibv_cq		  *xrc_cq;
47};
48
49/**
50 * ibv_open_xrc_domain - open an XRC domain
51 * Returns a reference to an XRC domain.
52 *
53 * @context: Device context
54 * @fd: descriptor for inode associated with the domain
55 *     If fd == -1, no inode is associated with the domain; in this ca= se,
56 *     the only legal value for oflag is O_CREAT
57 *
58 * @oflag: oflag values are constructed by OR-ing flags from the following list
59 *
60 * O_CREAT
61 *     If a domain belonging to device named by context is already associated
62 *     with the inode, this flag has no effect, except as noted under O_EXCL
63 *     below. Otherwise, a new XRC domain is created and is associated with
64 *     inode specified by fd.
65 *
66 * O_EXCL
67 *     If O_EXCL and O_CREAT are set, open will fail if a domain associated with
68 *     the inode exists. The check for the existence of the domain and creation
69 *     of the domain if it does not exist is atomic with respect to other
70 *     processes executing open with fd naming the same inode.
71 */
72struct ibv_xrc_domain *ibv_open_xrc_domain(struct ibv_context *context,
73					   int fd, int oflag) DEPRECATED;
74
75/**
76 * ibv_create_xrc_srq - Creates a SRQ associated with the specified protection
77 *   domain and xrc domain.
78 * @pd: The protection domain associated with the SRQ.
79 * @xrc_domain: The XRC domain associated with the SRQ.
80 * @xrc_cq: CQ to report completions for XRC packets on.
81 *
82 * @srq_init_attr: A list of initial attributes required to create the SRQ.
83 *
84 * srq_attr->max_wr and srq_attr->max_sge are read the determine the
85 * requested size of the SRQ, and set to the actual values allocated
86 * on return.  If ibv_create_srq() succeeds, then max_wr and max_sge
87 * will always be at least as large as the requested values.
88 */
89struct ibv_srq *ibv_create_xrc_srq(struct ibv_pd *pd,
90				   struct ibv_xrc_domain *xrc_domain,
91				   struct ibv_cq *xrc_cq,
92				   struct ibv_srq_init_attr *srq_init_attr) DEPRECATED;
93
94/**
95 * ibv_close_xrc_domain - close an XRC domain
96 * If this is the last reference, destroys the domain.
97 *
98 * @d: reference to XRC domain to close
99 *
100 * close is implicitly performed at process exit.
101 */
102int ibv_close_xrc_domain(struct ibv_xrc_domain *d) DEPRECATED;
103
104/**
105 * ibv_create_xrc_rcv_qp - creates an XRC QP for serving as a receive-side-only QP,
106 *
107 * This QP is created in kernel space, and persists until the last process
108 * registered for the QP calls ibv_unreg_xrc_rcv_qp() (at which time the QP
109 * is destroyed).
110 *
111 * @init_attr: init attributes to use for QP. xrc domain MUST be included here.
112 *	       All other fields are ignored.
113 *
114 * @xrc_rcv_qpn: qp_num of created QP (if success). To be passed to the
115 *		 remote node (sender). The remote node will use xrc_rcv_qpn
116 *		 in ibv_post_send when sending to XRC SRQ's on this host
117 *		 in the same xrc domain.
118 *
119 * RETURNS: success (0), or a (negative) error value.
120 *
121 * NOTE: this verb also registers the calling user-process with the QP at its
122 *	 creation time (implicit call to ibv_reg_xrc_rcv_qp), to avoid race
123 *	 conditions. The creating process will need to call ibv_unreg_xrc_qp()
124 *	 for the QP to release it from this process.
125 */
126int ibv_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr,
127			  uint32_t *xrc_rcv_qpn) DEPRECATED;
128
129/**
130 * ibv_modify_xrc_rcv_qp - modifies an xrc_rcv qp.
131 *
132 * @xrc_domain: xrc domain the QP belongs to (for verification).
133 * @xrc_qp_num: The (24 bit) number of the XRC QP.
134 * @attr: modify-qp attributes. The following fields must be specified:
135 *		for RESET_2_INIT: qp_state, pkey_index , port, qp_access_flags
136 *		for INIT_2_RTR:   qp_state, path_mtu, dest_qp_num, rq_psn,
137 *				  max_dest_rd_atomic, min_rnr_timer, ah_attr
138 *		The QP need not be brought to RTS for the QP to operate as a
139 *		receive-only QP.
140 * @attr_mask:  bitmap indicating which attributes are provided in the attr
141 *		struct.	Used for validity checking.
142 *		The following bits must be set:
143 *		for RESET_2_INIT: IBV_QP_PKEY_INDEX, IBV_QP_PORT,
144 *				  IBV_QP_ACCESS_FLAGS, IBV_QP_STATE
145 *		for INIT_2_RTR: IBV_QP_AV, IBV_QP_PATH_MTU, IBV_QP_DEST_QPN,
146 *				IBV_QP_RQ_PSN, IBV_QP_MAX_DEST_RD_ATOMIC,
147 *				IBV_QP_MIN_RNR_TIMER, IBV_QP_STATE
148 *
149 * RETURNS: success (0), or a (positive) error value.
150 *
151 */
152int ibv_modify_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
153			  uint32_t xrc_qp_num,
154			  struct ibv_qp_attr *attr, int attr_mask) DEPRECATED;
155
156/**
157 * ibv_query_xrc_rcv_qp - queries an xrc_rcv qp.
158 *
159 * @xrc_domain: xrc domain the QP belongs to (for verification).
160 * @xrc_qp_num: The (24 bit) number of the XRC QP.
161 * @attr: for returning qp attributes.
162 * @attr_mask:  bitmap indicating which attributes to return.
163 * @init_attr: for returning the init attributes
164 *
165 * RETURNS: success (0), or a (positive) error value.
166 *
167 */
168int ibv_query_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, uint32_t xrc_qp_num,
169			 struct ibv_qp_attr *attr, int attr_mask,
170			 struct ibv_qp_init_attr *init_attr) DEPRECATED;
171
172/**
173 * ibv_reg_xrc_rcv_qp: registers a user process with an XRC QP which serves as
174 *         a receive-side only QP.
175 *
176 * @xrc_domain: xrc domain the QP belongs to (for verification).
177 * @xrc_qp_num: The (24 bit) number of the XRC QP.
178 *
179 * RETURNS: success (0),
180 *	or error (EINVAL), if:
181 *		1. There is no such QP_num allocated.
182 *		2. The QP is allocated, but is not an receive XRC QP
183 *		3. The XRC QP does not belong to the given domain.
184 */
185int ibv_reg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
186				uint32_t xrc_qp_num) DEPRECATED;
187
188/**
189 * ibv_unreg_xrc_rcv_qp: detaches a user process from an XRC QP serving as
190 *         a receive-side only QP. If as a result, there are no remaining
191 *	   userspace processes registered for this XRC QP, it is destroyed.
192 *
193 * @xrc_domain: xrc domain the QP belongs to (for verification).
194 * @xrc_qp_num: The (24 bit) number of the XRC QP.
195 *
196 * RETURNS: success (0),
197 *	    or error (EINVAL), if:
198 *		1. There is no such QP_num allocated.
199 *		2. The QP is allocated, but is not an XRC QP
200 *		3. The XRC QP does not belong to the given domain.
201 * NOTE: There is no reason to return a special code if the QP is destroyed.
202 *	 The unregister simply succeeds.
203 */
204int ibv_unreg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
205			 uint32_t xrc_qp_num) DEPRECATED;
206
207
208#endif
209
210
211