blob: 34f778424f616d8b294634dd4538b47af58704c3 [file] [log] [blame]
Ralph Campbellf9315512010-05-23 21:44:54 -07001/*
Mike Marciniszyn1dd173b2013-06-15 17:07:14 -04002 * Copyright (c) 2012, 2013 Intel Corporation. All rights reserved.
Mike Marciniszyn1fb9fed2012-07-16 17:11:06 +00003 * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved.
Ralph Campbellf9315512010-05-23 21:44:54 -07004 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 */
34
35#ifndef QIB_VERBS_H
36#define QIB_VERBS_H
37
38#include <linux/types.h>
39#include <linux/spinlock.h>
40#include <linux/kernel.h>
41#include <linux/interrupt.h>
42#include <linux/kref.h>
43#include <linux/workqueue.h>
Mike Marciniszyn85caafe2013-06-04 15:05:37 -040044#include <linux/kthread.h>
Mike Marciniszyn6a826492012-06-27 18:33:12 -040045#include <linux/completion.h>
Ralph Campbellf9315512010-05-23 21:44:54 -070046#include <rdma/ib_pack.h>
47#include <rdma/ib_user_verbs.h>
Dennis Dalessandro2dc05ab2016-01-22 12:44:29 -080048#include <rdma/rdma_vt.h>
Harish Chegondi4bb88e52016-01-22 13:07:36 -080049#include <rdma/rdmavt_cq.h>
Ralph Campbellf9315512010-05-23 21:44:54 -070050
51struct qib_ctxtdata;
52struct qib_pportdata;
53struct qib_devdata;
54struct qib_verbs_txreq;
55
56#define QIB_MAX_RDMA_ATOMIC 16
57#define QIB_GUIDS_PER_PORT 5
58
Ralph Campbellf9315512010-05-23 21:44:54 -070059/*
60 * Increment this value if any changes that break userspace ABI
61 * compatibility are made.
62 */
63#define QIB_UVERBS_ABI_VERSION 2
64
Ralph Campbellf9315512010-05-23 21:44:54 -070065#define IB_SEQ_NAK (3 << 29)
66
67/* AETH NAK opcode values */
68#define IB_RNR_NAK 0x20
69#define IB_NAK_PSN_ERROR 0x60
70#define IB_NAK_INVALID_REQUEST 0x61
71#define IB_NAK_REMOTE_ACCESS_ERROR 0x62
72#define IB_NAK_REMOTE_OPERATIONAL_ERROR 0x63
73#define IB_NAK_INVALID_RD_REQUEST 0x64
74
Ralph Campbellf9315512010-05-23 21:44:54 -070075/* IB Performance Manager status values */
76#define IB_PMA_SAMPLE_STATUS_DONE 0x00
77#define IB_PMA_SAMPLE_STATUS_STARTED 0x01
78#define IB_PMA_SAMPLE_STATUS_RUNNING 0x02
79
80/* Mandatory IB performance counter select values. */
81#define IB_PMA_PORT_XMIT_DATA cpu_to_be16(0x0001)
82#define IB_PMA_PORT_RCV_DATA cpu_to_be16(0x0002)
83#define IB_PMA_PORT_XMIT_PKTS cpu_to_be16(0x0003)
84#define IB_PMA_PORT_RCV_PKTS cpu_to_be16(0x0004)
85#define IB_PMA_PORT_XMIT_WAIT cpu_to_be16(0x0005)
86
87#define QIB_VENDOR_IPG cpu_to_be16(0xFFA0)
88
89#define IB_BTH_REQ_ACK (1 << 31)
90#define IB_BTH_SOLICITED (1 << 23)
91#define IB_BTH_MIG_REQ (1 << 22)
92
93/* XXX Should be defined in ib_verbs.h enum ib_port_cap_flags */
94#define IB_PORT_OTHER_LOCAL_CHANGES_SUP (1 << 26)
95
96#define IB_GRH_VERSION 6
97#define IB_GRH_VERSION_MASK 0xF
98#define IB_GRH_VERSION_SHIFT 28
99#define IB_GRH_TCLASS_MASK 0xFF
100#define IB_GRH_TCLASS_SHIFT 20
101#define IB_GRH_FLOW_MASK 0xFFFFF
102#define IB_GRH_FLOW_SHIFT 0
103#define IB_GRH_NEXT_HDR 0x1B
104
105#define IB_DEFAULT_GID_PREFIX cpu_to_be64(0xfe80000000000000ULL)
106
107/* Values for set/get portinfo VLCap OperationalVLs */
108#define IB_VL_VL0 1
109#define IB_VL_VL0_1 2
110#define IB_VL_VL0_3 3
111#define IB_VL_VL0_7 4
112#define IB_VL_VL0_14 5
113
114static inline int qib_num_vls(int vls)
115{
116 switch (vls) {
117 default:
118 case IB_VL_VL0:
119 return 1;
120 case IB_VL_VL0_1:
121 return 2;
122 case IB_VL_VL0_3:
123 return 4;
124 case IB_VL_VL0_7:
125 return 8;
126 case IB_VL_VL0_14:
127 return 15;
128 }
129}
130
131struct ib_reth {
132 __be64 vaddr;
133 __be32 rkey;
134 __be32 length;
Mike Marciniszyn78a58862013-10-24 11:40:37 -0400135} __packed;
Ralph Campbellf9315512010-05-23 21:44:54 -0700136
137struct ib_atomic_eth {
138 __be32 vaddr[2]; /* unaligned so access as 2 32-bit words */
139 __be32 rkey;
140 __be64 swap_data;
141 __be64 compare_data;
Mike Marciniszyn78a58862013-10-24 11:40:37 -0400142} __packed;
Ralph Campbellf9315512010-05-23 21:44:54 -0700143
144struct qib_other_headers {
145 __be32 bth[3];
146 union {
147 struct {
148 __be32 deth[2];
149 __be32 imm_data;
150 } ud;
151 struct {
152 struct ib_reth reth;
153 __be32 imm_data;
154 } rc;
155 struct {
156 __be32 aeth;
157 __be32 atomic_ack_eth[2];
158 } at;
159 __be32 imm_data;
160 __be32 aeth;
161 struct ib_atomic_eth atomic_eth;
162 } u;
Mike Marciniszyn78a58862013-10-24 11:40:37 -0400163} __packed;
Ralph Campbellf9315512010-05-23 21:44:54 -0700164
165/*
166 * Note that UD packets with a GRH header are 8+40+12+8 = 68 bytes
167 * long (72 w/ imm_data). Only the first 56 bytes of the IB header
168 * will be in the eager header buffer. The remaining 12 or 16 bytes
169 * are in the data buffer.
170 */
171struct qib_ib_header {
172 __be16 lrh[4];
173 union {
174 struct {
175 struct ib_grh grh;
176 struct qib_other_headers oth;
177 } l;
178 struct qib_other_headers oth;
179 } u;
Mike Marciniszyn78a58862013-10-24 11:40:37 -0400180} __packed;
Ralph Campbellf9315512010-05-23 21:44:54 -0700181
182struct qib_pio_header {
183 __le32 pbc[2];
184 struct qib_ib_header hdr;
Mike Marciniszyn78a58862013-10-24 11:40:37 -0400185} __packed;
Ralph Campbellf9315512010-05-23 21:44:54 -0700186
187/*
Dennis Dalessandroffc26902016-01-22 12:45:11 -0800188 * qib specific data structure that will be hidden from rvt after the queue pair
189 * is made common.
190 */
Dennis Dalessandroffc26902016-01-22 12:45:11 -0800191struct qib_qp_priv {
192 struct qib_ib_header *s_hdr; /* next packet header to send */
193 struct list_head iowait; /* link for wait PIO buf */
194 atomic_t s_dma_busy;
195 struct qib_verbs_txreq *s_tx;
196 struct work_struct s_work;
197 wait_queue_head_t wait_dma;
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800198 struct rvt_qp *owner;
Ralph Campbellf9315512010-05-23 21:44:54 -0700199};
200
Ralph Campbellf9315512010-05-23 21:44:54 -0700201#define QIB_PSN_CREDIT 16
202
203/*
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800204 * Since struct rvt_rwqe is not a fixed size, we can't simply index into
205 * struct rvt_rwq.wq. This function does the array index computation.
Ralph Campbellf9315512010-05-23 21:44:54 -0700206 */
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800207static inline struct rvt_rwqe *get_rwqe_ptr(struct rvt_rq *rq, unsigned n)
Ralph Campbellf9315512010-05-23 21:44:54 -0700208{
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800209 return (struct rvt_rwqe *)
Ralph Campbellf9315512010-05-23 21:44:54 -0700210 ((char *) rq->wq->wq +
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800211 (sizeof(struct rvt_rwqe) +
Ralph Campbellf9315512010-05-23 21:44:54 -0700212 rq->max_sge * sizeof(struct ib_sge)) * n);
213}
214
Ralph Campbellf9315512010-05-23 21:44:54 -0700215struct qib_opcode_stats {
216 u64 n_packets; /* number of packets */
217 u64 n_bytes; /* total number of bytes */
218};
219
Mike Marciniszynddb88762013-06-15 17:07:03 -0400220struct qib_opcode_stats_perctx {
221 struct qib_opcode_stats stats[128];
222};
223
Mike Marciniszyn7d7632a2014-03-07 08:40:55 -0500224struct qib_pma_counters {
225 u64 n_unicast_xmit; /* total unicast packets sent */
226 u64 n_unicast_rcv; /* total unicast packets received */
227 u64 n_multicast_xmit; /* total multicast packets sent */
228 u64 n_multicast_rcv; /* total multicast packets received */
229};
230
Ralph Campbellf9315512010-05-23 21:44:54 -0700231struct qib_ibport {
Harish Chegondif24a6d42016-01-22 12:56:02 -0800232 struct rvt_ibport rvp;
Ralph Campbellf9315512010-05-23 21:44:54 -0700233 __be64 guids[QIB_GUIDS_PER_PORT - 1]; /* writable GUIDs */
Mike Marciniszyn7d7632a2014-03-07 08:40:55 -0500234 struct qib_pma_counters __percpu *pmastats;
235 u64 z_unicast_xmit; /* starting count for PMA */
236 u64 z_unicast_rcv; /* starting count for PMA */
237 u64 z_multicast_xmit; /* starting count for PMA */
238 u64 z_multicast_rcv; /* starting count for PMA */
Ralph Campbellf9315512010-05-23 21:44:54 -0700239 u64 z_symbol_error_counter; /* starting count for PMA */
240 u64 z_link_error_recovery_counter; /* starting count for PMA */
241 u64 z_link_downed_counter; /* starting count for PMA */
242 u64 z_port_rcv_errors; /* starting count for PMA */
243 u64 z_port_rcv_remphys_errors; /* starting count for PMA */
244 u64 z_port_xmit_discards; /* starting count for PMA */
245 u64 z_port_xmit_data; /* starting count for PMA */
246 u64 z_port_rcv_data; /* starting count for PMA */
247 u64 z_port_xmit_packets; /* starting count for PMA */
248 u64 z_port_rcv_packets; /* starting count for PMA */
249 u32 z_local_link_integrity_errors; /* starting count for PMA */
250 u32 z_excessive_buffer_overrun_errors; /* starting count for PMA */
251 u32 z_vl15_dropped; /* starting count for PMA */
Ralph Campbellf9315512010-05-23 21:44:54 -0700252 u8 sl_to_vl[16];
Ralph Campbellf9315512010-05-23 21:44:54 -0700253};
254
255struct qib_ibdev {
Dennis Dalessandro2dc05ab2016-01-22 12:44:29 -0800256 struct rvt_dev_info rdi;
Ralph Campbellf9315512010-05-23 21:44:54 -0700257
Ralph Campbellf9315512010-05-23 21:44:54 -0700258 struct list_head piowait; /* list for wait PIO buf */
259 struct list_head dmawait; /* list for wait DMA */
260 struct list_head txwait; /* list for wait qib_verbs_txreq */
261 struct list_head memwait; /* list for wait kernel memory */
262 struct list_head txreq_free;
263 struct timer_list mem_timer;
Ralph Campbellf9315512010-05-23 21:44:54 -0700264 struct qib_pio_header *pio_hdrs;
265 dma_addr_t pio_hdrs_phys;
Mike Marciniszynaf061a62011-09-23 13:16:44 -0400266 u32 qp_rnd; /* random bytes for hash */
Ralph Campbellf9315512010-05-23 21:44:54 -0700267
268 u32 n_piowait;
269 u32 n_txwait;
270
Ralph Campbellf9315512010-05-23 21:44:54 -0700271 u32 n_qps_allocated; /* number of QPs allocated for device */
272 spinlock_t n_qps_lock;
273 u32 n_srqs_allocated; /* number of SRQs allocated for device */
274 spinlock_t n_srqs_lock;
Mike Marciniszynddb88762013-06-15 17:07:03 -0400275#ifdef CONFIG_DEBUG_FS
276 /* per HCA debugfs */
277 struct dentry *qib_ibdev_dbg;
278#endif
Ralph Campbellf9315512010-05-23 21:44:54 -0700279};
280
281struct qib_verbs_counters {
282 u64 symbol_error_counter;
283 u64 link_error_recovery_counter;
284 u64 link_downed_counter;
285 u64 port_rcv_errors;
286 u64 port_rcv_remphys_errors;
287 u64 port_xmit_discards;
288 u64 port_xmit_data;
289 u64 port_rcv_data;
290 u64 port_xmit_packets;
291 u64 port_rcv_packets;
292 u32 local_link_integrity_errors;
293 u32 excessive_buffer_overrun_errors;
294 u32 vl15_dropped;
295};
296
Ralph Campbellf9315512010-05-23 21:44:54 -0700297static inline struct qib_ibdev *to_idev(struct ib_device *ibdev)
298{
Dennis Dalessandro2dc05ab2016-01-22 12:44:29 -0800299 struct rvt_dev_info *rdi;
300
301 rdi = container_of(ibdev, struct rvt_dev_info, ibdev);
302 return container_of(rdi, struct qib_ibdev, rdi);
Ralph Campbellf9315512010-05-23 21:44:54 -0700303}
304
305/*
306 * Send if not busy or waiting for I/O and either
307 * a RC response is pending or we can process send work requests.
308 */
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800309static inline int qib_send_ok(struct rvt_qp *qp)
Ralph Campbellf9315512010-05-23 21:44:54 -0700310{
Harish Chegondi01ba79d2016-01-22 12:56:46 -0800311 return !(qp->s_flags & (RVT_S_BUSY | RVT_S_ANY_WAIT_IO)) &&
312 (qp->s_hdrwords || (qp->s_flags & RVT_S_RESP_PENDING) ||
313 !(qp->s_flags & RVT_S_ANY_WAIT_SEND));
Ralph Campbellf9315512010-05-23 21:44:54 -0700314}
315
Ralph Campbellf9315512010-05-23 21:44:54 -0700316/*
317 * This must be called with s_lock held.
318 */
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800319void qib_schedule_send(struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700320
321static inline int qib_pkey_ok(u16 pkey1, u16 pkey2)
322{
323 u16 p1 = pkey1 & 0x7FFF;
324 u16 p2 = pkey2 & 0x7FFF;
325
326 /*
327 * Low 15 bits must be non-zero and match, and
328 * one of the two must be a full member.
329 */
330 return p1 && p1 == p2 && ((__s16)pkey1 < 0 || (__s16)pkey2 < 0);
331}
332
333void qib_bad_pqkey(struct qib_ibport *ibp, __be16 trap_num, u32 key, u32 sl,
334 u32 qp1, u32 qp2, __be16 lid1, __be16 lid2);
335void qib_cap_mask_chg(struct qib_ibport *ibp);
336void qib_sys_guid_chg(struct qib_ibport *ibp);
337void qib_node_desc_chg(struct qib_ibport *ibp);
338int qib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
Ira Weinya97e2d82015-05-31 17:15:30 -0400339 const struct ib_wc *in_wc, const struct ib_grh *in_grh,
Ira Weiny4cd7c942015-06-06 14:38:31 -0400340 const struct ib_mad_hdr *in, size_t in_mad_size,
341 struct ib_mad_hdr *out, size_t *out_mad_size,
342 u16 *out_mad_pkey_index);
Dennis Dalessandro5196aa92016-01-22 13:07:30 -0800343void qib_notify_create_mad_agent(struct rvt_dev_info *rdi, int port_idx);
344void qib_notify_free_mad_agent(struct rvt_dev_info *rdi, int port_idx);
Ralph Campbellf9315512010-05-23 21:44:54 -0700345
346/*
347 * Compare the lower 24 bits of the two values.
348 * Returns an integer <, ==, or > than zero.
349 */
350static inline int qib_cmp24(u32 a, u32 b)
351{
352 return (((int) a) - ((int) b)) << 8;
353}
354
Ralph Campbellf9315512010-05-23 21:44:54 -0700355int qib_snapshot_counters(struct qib_pportdata *ppd, u64 *swords,
356 u64 *rwords, u64 *spkts, u64 *rpkts,
357 u64 *xmit_wait);
358
359int qib_get_counters(struct qib_pportdata *ppd,
360 struct qib_verbs_counters *cntrs);
361
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800362__be32 qib_compute_aeth(struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700363
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800364struct rvt_qp *qib_lookup_qpn(struct qib_ibport *ibp, u32 qpn);
Ralph Campbellf9315512010-05-23 21:44:54 -0700365
Ralph Campbellf9315512010-05-23 21:44:54 -0700366int qib_destroy_qp(struct ib_qp *ibqp);
367
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800368int qib_error_qp(struct rvt_qp *qp, enum ib_wc_status err);
Ralph Campbellf9315512010-05-23 21:44:54 -0700369
370int qib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
371 int attr_mask, struct ib_udata *udata);
Harish Chegondi47c7ea62016-01-22 12:56:52 -0800372/*
373 * Functions provided by qib driver for rdmavt to use
374 */
375unsigned qib_free_all_qps(struct rvt_dev_info *rdi);
376void *qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp, gfp_t gfp);
377void qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp);
378void notify_qp_reset(struct rvt_qp *qp);
379int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
380 enum ib_qp_type type, u8 port, gfp_t gfp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700381
Mike Marciniszyn1dd173b2013-06-15 17:07:14 -0400382#ifdef CONFIG_DEBUG_FS
383
384struct qib_qp_iter;
385
386struct qib_qp_iter *qib_qp_iter_init(struct qib_ibdev *dev);
387
388int qib_qp_iter_next(struct qib_qp_iter *iter);
389
390void qib_qp_iter_print(struct seq_file *s, struct qib_qp_iter *iter);
391
392#endif
393
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800394void qib_get_credit(struct rvt_qp *qp, u32 aeth);
Ralph Campbellf9315512010-05-23 21:44:54 -0700395
396unsigned qib_pkt_delay(u32 plen, u8 snd_mult, u8 rcv_mult);
397
398void qib_verbs_sdma_desc_avail(struct qib_pportdata *ppd, unsigned avail);
399
400void qib_put_txreq(struct qib_verbs_txreq *tx);
401
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800402int qib_verbs_send(struct rvt_qp *qp, struct qib_ib_header *hdr,
403 u32 hdrwords, struct rvt_sge_state *ss, u32 len);
Ralph Campbellf9315512010-05-23 21:44:54 -0700404
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800405void qib_copy_sge(struct rvt_sge_state *ss, void *data, u32 length,
Ralph Campbellf9315512010-05-23 21:44:54 -0700406 int release);
407
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800408void qib_skip_sge(struct rvt_sge_state *ss, u32 length, int release);
Ralph Campbellf9315512010-05-23 21:44:54 -0700409
410void qib_uc_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800411 int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700412
413void qib_rc_rcv(struct qib_ctxtdata *rcd, struct qib_ib_header *hdr,
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800414 int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700415
416int qib_check_ah(struct ib_device *ibdev, struct ib_ah_attr *ah_attr);
417
Mike Marciniszyn1fb9fed2012-07-16 17:11:06 +0000418struct ib_ah *qib_create_qp0_ah(struct qib_ibport *ibp, u16 dlid);
419
Ralph Campbellf9315512010-05-23 21:44:54 -0700420void qib_rc_rnr_retry(unsigned long arg);
421
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800422void qib_rc_send_complete(struct rvt_qp *qp, struct qib_ib_header *hdr);
Ralph Campbellf9315512010-05-23 21:44:54 -0700423
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800424void qib_rc_error(struct rvt_qp *qp, enum ib_wc_status err);
Ralph Campbellf9315512010-05-23 21:44:54 -0700425
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800426int qib_post_ud_send(struct rvt_qp *qp, struct ib_send_wr *wr);
Ralph Campbellf9315512010-05-23 21:44:54 -0700427
428void qib_ud_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800429 int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700430
431int qib_post_srq_receive(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
432 struct ib_recv_wr **bad_wr);
433
434struct ib_srq *qib_create_srq(struct ib_pd *ibpd,
435 struct ib_srq_init_attr *srq_init_attr,
436 struct ib_udata *udata);
437
438int qib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
439 enum ib_srq_attr_mask attr_mask,
440 struct ib_udata *udata);
441
442int qib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr);
443
444int qib_destroy_srq(struct ib_srq *ibsrq);
445
Mike Marciniszyn8aac4cc2012-06-27 18:33:19 -0400446void mr_rcu_callback(struct rcu_head *list);
447
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800448static inline void qib_put_ss(struct rvt_sge_state *ss)
Mike Marciniszyn6a826492012-06-27 18:33:12 -0400449{
450 while (ss->num_sge) {
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800451 rvt_put_mr(ss->sge.mr);
Mike Marciniszyn6a826492012-06-27 18:33:12 -0400452 if (--ss->num_sge)
453 ss->sge = *ss->sg_list++;
454 }
455}
456
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800457int qib_get_rwqe(struct rvt_qp *qp, int wr_id_only);
Ralph Campbellf9315512010-05-23 21:44:54 -0700458
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800459void qib_migrate_qp(struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700460
461int qib_ruc_check_hdr(struct qib_ibport *ibp, struct qib_ib_header *hdr,
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800462 int has_grh, struct rvt_qp *qp, u32 bth0);
Ralph Campbellf9315512010-05-23 21:44:54 -0700463
464u32 qib_make_grh(struct qib_ibport *ibp, struct ib_grh *hdr,
465 struct ib_global_route *grh, u32 hwords, u32 nwords);
466
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800467void qib_make_ruc_header(struct rvt_qp *qp, struct qib_other_headers *ohdr,
Ralph Campbellf9315512010-05-23 21:44:54 -0700468 u32 bth0, u32 bth2);
469
Harish Chegondidb3ef0e2016-01-22 13:07:42 -0800470void _qib_do_send(struct work_struct *work);
471
472void qib_do_send(struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700473
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800474void qib_send_complete(struct rvt_qp *qp, struct rvt_swqe *wqe,
Ralph Campbellf9315512010-05-23 21:44:54 -0700475 enum ib_wc_status status);
476
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800477void qib_send_rc_ack(struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700478
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800479int qib_make_rc_req(struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700480
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800481int qib_make_uc_req(struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700482
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800483int qib_make_ud_req(struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700484
485int qib_register_ib_device(struct qib_devdata *);
486
487void qib_unregister_ib_device(struct qib_devdata *);
488
489void qib_ib_rcv(struct qib_ctxtdata *, void *, void *, u32);
490
491void qib_ib_piobufavail(struct qib_devdata *);
492
493unsigned qib_get_npkeys(struct qib_devdata *);
494
495unsigned qib_get_pkey(struct qib_ibport *, unsigned);
496
497extern const enum ib_wc_opcode ib_qib_wc_opcode[];
498
499/*
500 * Below HCA-independent IB PhysPortState values, returned
501 * by the f_ibphys_portstate() routine.
502 */
503#define IB_PHYSPORTSTATE_SLEEP 1
504#define IB_PHYSPORTSTATE_POLL 2
505#define IB_PHYSPORTSTATE_DISABLED 3
506#define IB_PHYSPORTSTATE_CFG_TRAIN 4
507#define IB_PHYSPORTSTATE_LINKUP 5
508#define IB_PHYSPORTSTATE_LINK_ERR_RECOVER 6
509#define IB_PHYSPORTSTATE_CFG_DEBOUNCE 8
510#define IB_PHYSPORTSTATE_CFG_IDLE 0xB
511#define IB_PHYSPORTSTATE_RECOVERY_RETRAIN 0xC
512#define IB_PHYSPORTSTATE_RECOVERY_WAITRMT 0xE
513#define IB_PHYSPORTSTATE_RECOVERY_IDLE 0xF
514#define IB_PHYSPORTSTATE_CFG_ENH 0x10
515#define IB_PHYSPORTSTATE_CFG_WAIT_ENH 0x13
516
Harish Chegondidb3ef0e2016-01-22 13:07:42 -0800517extern const int ib_rvt_state_ops[];
Ralph Campbellf9315512010-05-23 21:44:54 -0700518
519extern __be64 ib_qib_sys_image_guid; /* in network order */
520
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800521extern unsigned int ib_rvt_lkey_table_size;
Ralph Campbellf9315512010-05-23 21:44:54 -0700522
523extern unsigned int ib_qib_max_cqes;
524
525extern unsigned int ib_qib_max_cqs;
526
527extern unsigned int ib_qib_max_qp_wrs;
528
529extern unsigned int ib_qib_max_qps;
530
531extern unsigned int ib_qib_max_sges;
532
533extern unsigned int ib_qib_max_mcast_grps;
534
535extern unsigned int ib_qib_max_mcast_qp_attached;
536
537extern unsigned int ib_qib_max_srqs;
538
539extern unsigned int ib_qib_max_srq_sges;
540
541extern unsigned int ib_qib_max_srq_wrs;
542
543extern const u32 ib_qib_rnr_table[];
544
Ralph Campbellf9315512010-05-23 21:44:54 -0700545#endif /* QIB_VERBS_H */