blob: 818ac871738667c6f9baf81c91a238a5621d28ef [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
75/* Flags for checking QP state (see ib_qib_state_ops[]) */
76#define QIB_POST_SEND_OK 0x01
77#define QIB_POST_RECV_OK 0x02
78#define QIB_PROCESS_RECV_OK 0x04
79#define QIB_PROCESS_SEND_OK 0x08
80#define QIB_PROCESS_NEXT_SEND_OK 0x10
81#define QIB_FLUSH_SEND 0x20
82#define QIB_FLUSH_RECV 0x40
83#define QIB_PROCESS_OR_FLUSH_SEND \
84 (QIB_PROCESS_SEND_OK | QIB_FLUSH_SEND)
85
86/* IB Performance Manager status values */
87#define IB_PMA_SAMPLE_STATUS_DONE 0x00
88#define IB_PMA_SAMPLE_STATUS_STARTED 0x01
89#define IB_PMA_SAMPLE_STATUS_RUNNING 0x02
90
91/* Mandatory IB performance counter select values. */
92#define IB_PMA_PORT_XMIT_DATA cpu_to_be16(0x0001)
93#define IB_PMA_PORT_RCV_DATA cpu_to_be16(0x0002)
94#define IB_PMA_PORT_XMIT_PKTS cpu_to_be16(0x0003)
95#define IB_PMA_PORT_RCV_PKTS cpu_to_be16(0x0004)
96#define IB_PMA_PORT_XMIT_WAIT cpu_to_be16(0x0005)
97
98#define QIB_VENDOR_IPG cpu_to_be16(0xFFA0)
99
100#define IB_BTH_REQ_ACK (1 << 31)
101#define IB_BTH_SOLICITED (1 << 23)
102#define IB_BTH_MIG_REQ (1 << 22)
103
104/* XXX Should be defined in ib_verbs.h enum ib_port_cap_flags */
105#define IB_PORT_OTHER_LOCAL_CHANGES_SUP (1 << 26)
106
107#define IB_GRH_VERSION 6
108#define IB_GRH_VERSION_MASK 0xF
109#define IB_GRH_VERSION_SHIFT 28
110#define IB_GRH_TCLASS_MASK 0xFF
111#define IB_GRH_TCLASS_SHIFT 20
112#define IB_GRH_FLOW_MASK 0xFFFFF
113#define IB_GRH_FLOW_SHIFT 0
114#define IB_GRH_NEXT_HDR 0x1B
115
116#define IB_DEFAULT_GID_PREFIX cpu_to_be64(0xfe80000000000000ULL)
117
118/* Values for set/get portinfo VLCap OperationalVLs */
119#define IB_VL_VL0 1
120#define IB_VL_VL0_1 2
121#define IB_VL_VL0_3 3
122#define IB_VL_VL0_7 4
123#define IB_VL_VL0_14 5
124
125static inline int qib_num_vls(int vls)
126{
127 switch (vls) {
128 default:
129 case IB_VL_VL0:
130 return 1;
131 case IB_VL_VL0_1:
132 return 2;
133 case IB_VL_VL0_3:
134 return 4;
135 case IB_VL_VL0_7:
136 return 8;
137 case IB_VL_VL0_14:
138 return 15;
139 }
140}
141
142struct ib_reth {
143 __be64 vaddr;
144 __be32 rkey;
145 __be32 length;
Mike Marciniszyn78a58862013-10-24 11:40:37 -0400146} __packed;
Ralph Campbellf9315512010-05-23 21:44:54 -0700147
148struct ib_atomic_eth {
149 __be32 vaddr[2]; /* unaligned so access as 2 32-bit words */
150 __be32 rkey;
151 __be64 swap_data;
152 __be64 compare_data;
Mike Marciniszyn78a58862013-10-24 11:40:37 -0400153} __packed;
Ralph Campbellf9315512010-05-23 21:44:54 -0700154
155struct qib_other_headers {
156 __be32 bth[3];
157 union {
158 struct {
159 __be32 deth[2];
160 __be32 imm_data;
161 } ud;
162 struct {
163 struct ib_reth reth;
164 __be32 imm_data;
165 } rc;
166 struct {
167 __be32 aeth;
168 __be32 atomic_ack_eth[2];
169 } at;
170 __be32 imm_data;
171 __be32 aeth;
172 struct ib_atomic_eth atomic_eth;
173 } u;
Mike Marciniszyn78a58862013-10-24 11:40:37 -0400174} __packed;
Ralph Campbellf9315512010-05-23 21:44:54 -0700175
176/*
177 * Note that UD packets with a GRH header are 8+40+12+8 = 68 bytes
178 * long (72 w/ imm_data). Only the first 56 bytes of the IB header
179 * will be in the eager header buffer. The remaining 12 or 16 bytes
180 * are in the data buffer.
181 */
182struct qib_ib_header {
183 __be16 lrh[4];
184 union {
185 struct {
186 struct ib_grh grh;
187 struct qib_other_headers oth;
188 } l;
189 struct qib_other_headers oth;
190 } u;
Mike Marciniszyn78a58862013-10-24 11:40:37 -0400191} __packed;
Ralph Campbellf9315512010-05-23 21:44:54 -0700192
193struct qib_pio_header {
194 __le32 pbc[2];
195 struct qib_ib_header hdr;
Mike Marciniszyn78a58862013-10-24 11:40:37 -0400196} __packed;
Ralph Campbellf9315512010-05-23 21:44:54 -0700197
198/*
199 * There is one struct qib_mcast for each multicast GID.
200 * All attached QPs are then stored as a list of
201 * struct qib_mcast_qp.
202 */
203struct qib_mcast_qp {
204 struct list_head list;
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800205 struct rvt_qp *qp;
Ralph Campbellf9315512010-05-23 21:44:54 -0700206};
207
208struct qib_mcast {
209 struct rb_node rb_node;
210 union ib_gid mgid;
211 struct list_head qp_list;
212 wait_queue_head_t wait;
213 atomic_t refcount;
214 int n_attached;
215};
216
Ralph Campbellf9315512010-05-23 21:44:54 -0700217/*
Dennis Dalessandroffc26902016-01-22 12:45:11 -0800218 * qib specific data structure that will be hidden from rvt after the queue pair
219 * is made common.
220 */
Dennis Dalessandroffc26902016-01-22 12:45:11 -0800221struct qib_qp_priv {
222 struct qib_ib_header *s_hdr; /* next packet header to send */
223 struct list_head iowait; /* link for wait PIO buf */
224 atomic_t s_dma_busy;
225 struct qib_verbs_txreq *s_tx;
226 struct work_struct s_work;
227 wait_queue_head_t wait_dma;
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800228 struct rvt_qp *owner;
Ralph Campbellf9315512010-05-23 21:44:54 -0700229};
230
Ralph Campbellf9315512010-05-23 21:44:54 -0700231#define QIB_PSN_CREDIT 16
232
233/*
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800234 * Since struct rvt_swqe is not a fixed size, we can't simply index into
235 * struct rvt_qp.s_wq. This function does the array index computation.
Ralph Campbellf9315512010-05-23 21:44:54 -0700236 */
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800237static inline struct rvt_swqe *get_swqe_ptr(struct rvt_qp *qp,
238 unsigned n)
Ralph Campbellf9315512010-05-23 21:44:54 -0700239{
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800240 return (struct rvt_swqe *)((char *)qp->s_wq +
241 (sizeof(struct rvt_swqe) +
Ralph Campbellf9315512010-05-23 21:44:54 -0700242 qp->s_max_sge *
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800243 sizeof(struct rvt_sge)) * n);
Ralph Campbellf9315512010-05-23 21:44:54 -0700244}
245
246/*
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800247 * Since struct rvt_rwqe is not a fixed size, we can't simply index into
248 * struct rvt_rwq.wq. This function does the array index computation.
Ralph Campbellf9315512010-05-23 21:44:54 -0700249 */
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800250static inline struct rvt_rwqe *get_rwqe_ptr(struct rvt_rq *rq, unsigned n)
Ralph Campbellf9315512010-05-23 21:44:54 -0700251{
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800252 return (struct rvt_rwqe *)
Ralph Campbellf9315512010-05-23 21:44:54 -0700253 ((char *) rq->wq->wq +
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800254 (sizeof(struct rvt_rwqe) +
Ralph Campbellf9315512010-05-23 21:44:54 -0700255 rq->max_sge * sizeof(struct ib_sge)) * n);
256}
257
Ralph Campbellf9315512010-05-23 21:44:54 -0700258struct qib_opcode_stats {
259 u64 n_packets; /* number of packets */
260 u64 n_bytes; /* total number of bytes */
261};
262
Mike Marciniszynddb88762013-06-15 17:07:03 -0400263struct qib_opcode_stats_perctx {
264 struct qib_opcode_stats stats[128];
265};
266
Mike Marciniszyn7d7632a2014-03-07 08:40:55 -0500267struct qib_pma_counters {
268 u64 n_unicast_xmit; /* total unicast packets sent */
269 u64 n_unicast_rcv; /* total unicast packets received */
270 u64 n_multicast_xmit; /* total multicast packets sent */
271 u64 n_multicast_rcv; /* total multicast packets received */
272};
273
Ralph Campbellf9315512010-05-23 21:44:54 -0700274struct qib_ibport {
Harish Chegondif24a6d42016-01-22 12:56:02 -0800275 struct rvt_ibport rvp;
Ralph Campbellf9315512010-05-23 21:44:54 -0700276 __be64 guids[QIB_GUIDS_PER_PORT - 1]; /* writable GUIDs */
Mike Marciniszyn7d7632a2014-03-07 08:40:55 -0500277 struct qib_pma_counters __percpu *pmastats;
278 u64 z_unicast_xmit; /* starting count for PMA */
279 u64 z_unicast_rcv; /* starting count for PMA */
280 u64 z_multicast_xmit; /* starting count for PMA */
281 u64 z_multicast_rcv; /* starting count for PMA */
Ralph Campbellf9315512010-05-23 21:44:54 -0700282 u64 z_symbol_error_counter; /* starting count for PMA */
283 u64 z_link_error_recovery_counter; /* starting count for PMA */
284 u64 z_link_downed_counter; /* starting count for PMA */
285 u64 z_port_rcv_errors; /* starting count for PMA */
286 u64 z_port_rcv_remphys_errors; /* starting count for PMA */
287 u64 z_port_xmit_discards; /* starting count for PMA */
288 u64 z_port_xmit_data; /* starting count for PMA */
289 u64 z_port_rcv_data; /* starting count for PMA */
290 u64 z_port_xmit_packets; /* starting count for PMA */
291 u64 z_port_rcv_packets; /* starting count for PMA */
292 u32 z_local_link_integrity_errors; /* starting count for PMA */
293 u32 z_excessive_buffer_overrun_errors; /* starting count for PMA */
294 u32 z_vl15_dropped; /* starting count for PMA */
Ralph Campbellf9315512010-05-23 21:44:54 -0700295 u8 sl_to_vl[16];
Ralph Campbellf9315512010-05-23 21:44:54 -0700296};
297
298struct qib_ibdev {
Dennis Dalessandro2dc05ab2016-01-22 12:44:29 -0800299 struct rvt_dev_info rdi;
Ralph Campbellf9315512010-05-23 21:44:54 -0700300
Ralph Campbellf9315512010-05-23 21:44:54 -0700301 struct list_head piowait; /* list for wait PIO buf */
302 struct list_head dmawait; /* list for wait DMA */
303 struct list_head txwait; /* list for wait qib_verbs_txreq */
304 struct list_head memwait; /* list for wait kernel memory */
305 struct list_head txreq_free;
306 struct timer_list mem_timer;
Ralph Campbellf9315512010-05-23 21:44:54 -0700307 struct qib_pio_header *pio_hdrs;
308 dma_addr_t pio_hdrs_phys;
Mike Marciniszynaf061a62011-09-23 13:16:44 -0400309 u32 qp_rnd; /* random bytes for hash */
Ralph Campbellf9315512010-05-23 21:44:54 -0700310
311 u32 n_piowait;
312 u32 n_txwait;
313
Ralph Campbellf9315512010-05-23 21:44:54 -0700314 u32 n_qps_allocated; /* number of QPs allocated for device */
315 spinlock_t n_qps_lock;
316 u32 n_srqs_allocated; /* number of SRQs allocated for device */
317 spinlock_t n_srqs_lock;
318 u32 n_mcast_grps_allocated; /* number of mcast groups allocated */
319 spinlock_t n_mcast_grps_lock;
Mike Marciniszynddb88762013-06-15 17:07:03 -0400320#ifdef CONFIG_DEBUG_FS
321 /* per HCA debugfs */
322 struct dentry *qib_ibdev_dbg;
323#endif
Ralph Campbellf9315512010-05-23 21:44:54 -0700324};
325
326struct qib_verbs_counters {
327 u64 symbol_error_counter;
328 u64 link_error_recovery_counter;
329 u64 link_downed_counter;
330 u64 port_rcv_errors;
331 u64 port_rcv_remphys_errors;
332 u64 port_xmit_discards;
333 u64 port_xmit_data;
334 u64 port_rcv_data;
335 u64 port_xmit_packets;
336 u64 port_rcv_packets;
337 u32 local_link_integrity_errors;
338 u32 excessive_buffer_overrun_errors;
339 u32 vl15_dropped;
340};
341
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800342static inline struct rvt_qp *to_iqp(struct ib_qp *ibqp)
Ralph Campbellf9315512010-05-23 21:44:54 -0700343{
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800344 return container_of(ibqp, struct rvt_qp, ibqp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700345}
346
347static inline struct qib_ibdev *to_idev(struct ib_device *ibdev)
348{
Dennis Dalessandro2dc05ab2016-01-22 12:44:29 -0800349 struct rvt_dev_info *rdi;
350
351 rdi = container_of(ibdev, struct rvt_dev_info, ibdev);
352 return container_of(rdi, struct qib_ibdev, rdi);
Ralph Campbellf9315512010-05-23 21:44:54 -0700353}
354
355/*
356 * Send if not busy or waiting for I/O and either
357 * a RC response is pending or we can process send work requests.
358 */
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800359static inline int qib_send_ok(struct rvt_qp *qp)
Ralph Campbellf9315512010-05-23 21:44:54 -0700360{
Harish Chegondi01ba79d2016-01-22 12:56:46 -0800361 return !(qp->s_flags & (RVT_S_BUSY | RVT_S_ANY_WAIT_IO)) &&
362 (qp->s_hdrwords || (qp->s_flags & RVT_S_RESP_PENDING) ||
363 !(qp->s_flags & RVT_S_ANY_WAIT_SEND));
Ralph Campbellf9315512010-05-23 21:44:54 -0700364}
365
Ralph Campbellf9315512010-05-23 21:44:54 -0700366/*
367 * This must be called with s_lock held.
368 */
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800369void qib_schedule_send(struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700370
371static inline int qib_pkey_ok(u16 pkey1, u16 pkey2)
372{
373 u16 p1 = pkey1 & 0x7FFF;
374 u16 p2 = pkey2 & 0x7FFF;
375
376 /*
377 * Low 15 bits must be non-zero and match, and
378 * one of the two must be a full member.
379 */
380 return p1 && p1 == p2 && ((__s16)pkey1 < 0 || (__s16)pkey2 < 0);
381}
382
383void qib_bad_pqkey(struct qib_ibport *ibp, __be16 trap_num, u32 key, u32 sl,
384 u32 qp1, u32 qp2, __be16 lid1, __be16 lid2);
385void qib_cap_mask_chg(struct qib_ibport *ibp);
386void qib_sys_guid_chg(struct qib_ibport *ibp);
387void qib_node_desc_chg(struct qib_ibport *ibp);
388int qib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
Ira Weinya97e2d82015-05-31 17:15:30 -0400389 const struct ib_wc *in_wc, const struct ib_grh *in_grh,
Ira Weiny4cd7c942015-06-06 14:38:31 -0400390 const struct ib_mad_hdr *in, size_t in_mad_size,
391 struct ib_mad_hdr *out, size_t *out_mad_size,
392 u16 *out_mad_pkey_index);
Dennis Dalessandro5196aa92016-01-22 13:07:30 -0800393void qib_notify_create_mad_agent(struct rvt_dev_info *rdi, int port_idx);
394void qib_notify_free_mad_agent(struct rvt_dev_info *rdi, int port_idx);
Ralph Campbellf9315512010-05-23 21:44:54 -0700395
396/*
397 * Compare the lower 24 bits of the two values.
398 * Returns an integer <, ==, or > than zero.
399 */
400static inline int qib_cmp24(u32 a, u32 b)
401{
402 return (((int) a) - ((int) b)) << 8;
403}
404
405struct qib_mcast *qib_mcast_find(struct qib_ibport *ibp, union ib_gid *mgid);
406
407int qib_snapshot_counters(struct qib_pportdata *ppd, u64 *swords,
408 u64 *rwords, u64 *spkts, u64 *rpkts,
409 u64 *xmit_wait);
410
411int qib_get_counters(struct qib_pportdata *ppd,
412 struct qib_verbs_counters *cntrs);
413
414int qib_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
415
416int qib_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
417
418int qib_mcast_tree_empty(struct qib_ibport *ibp);
419
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800420__be32 qib_compute_aeth(struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700421
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800422struct rvt_qp *qib_lookup_qpn(struct qib_ibport *ibp, u32 qpn);
Ralph Campbellf9315512010-05-23 21:44:54 -0700423
Ralph Campbellf9315512010-05-23 21:44:54 -0700424int qib_destroy_qp(struct ib_qp *ibqp);
425
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800426int qib_error_qp(struct rvt_qp *qp, enum ib_wc_status err);
Ralph Campbellf9315512010-05-23 21:44:54 -0700427
428int qib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
429 int attr_mask, struct ib_udata *udata);
430
431int qib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
432 int attr_mask, struct ib_qp_init_attr *init_attr);
Harish Chegondi47c7ea62016-01-22 12:56:52 -0800433/*
434 * Functions provided by qib driver for rdmavt to use
435 */
436unsigned qib_free_all_qps(struct rvt_dev_info *rdi);
437void *qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp, gfp_t gfp);
438void qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp);
439void notify_qp_reset(struct rvt_qp *qp);
440int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
441 enum ib_qp_type type, u8 port, gfp_t gfp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700442
Mike Marciniszyn1dd173b2013-06-15 17:07:14 -0400443#ifdef CONFIG_DEBUG_FS
444
445struct qib_qp_iter;
446
447struct qib_qp_iter *qib_qp_iter_init(struct qib_ibdev *dev);
448
449int qib_qp_iter_next(struct qib_qp_iter *iter);
450
451void qib_qp_iter_print(struct seq_file *s, struct qib_qp_iter *iter);
452
453#endif
454
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800455void qib_get_credit(struct rvt_qp *qp, u32 aeth);
Ralph Campbellf9315512010-05-23 21:44:54 -0700456
457unsigned qib_pkt_delay(u32 plen, u8 snd_mult, u8 rcv_mult);
458
459void qib_verbs_sdma_desc_avail(struct qib_pportdata *ppd, unsigned avail);
460
461void qib_put_txreq(struct qib_verbs_txreq *tx);
462
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800463int qib_verbs_send(struct rvt_qp *qp, struct qib_ib_header *hdr,
464 u32 hdrwords, struct rvt_sge_state *ss, u32 len);
Ralph Campbellf9315512010-05-23 21:44:54 -0700465
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800466void qib_copy_sge(struct rvt_sge_state *ss, void *data, u32 length,
Ralph Campbellf9315512010-05-23 21:44:54 -0700467 int release);
468
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800469void qib_skip_sge(struct rvt_sge_state *ss, u32 length, int release);
Ralph Campbellf9315512010-05-23 21:44:54 -0700470
471void qib_uc_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800472 int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700473
474void qib_rc_rcv(struct qib_ctxtdata *rcd, struct qib_ib_header *hdr,
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800475 int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700476
477int qib_check_ah(struct ib_device *ibdev, struct ib_ah_attr *ah_attr);
478
Mike Marciniszyn1fb9fed2012-07-16 17:11:06 +0000479struct ib_ah *qib_create_qp0_ah(struct qib_ibport *ibp, u16 dlid);
480
Ralph Campbellf9315512010-05-23 21:44:54 -0700481void qib_rc_rnr_retry(unsigned long arg);
482
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800483void qib_rc_send_complete(struct rvt_qp *qp, struct qib_ib_header *hdr);
Ralph Campbellf9315512010-05-23 21:44:54 -0700484
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800485void qib_rc_error(struct rvt_qp *qp, enum ib_wc_status err);
Ralph Campbellf9315512010-05-23 21:44:54 -0700486
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800487int qib_post_ud_send(struct rvt_qp *qp, struct ib_send_wr *wr);
Ralph Campbellf9315512010-05-23 21:44:54 -0700488
489void qib_ud_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800490 int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700491
492int qib_post_srq_receive(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
493 struct ib_recv_wr **bad_wr);
494
495struct ib_srq *qib_create_srq(struct ib_pd *ibpd,
496 struct ib_srq_init_attr *srq_init_attr,
497 struct ib_udata *udata);
498
499int qib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
500 enum ib_srq_attr_mask attr_mask,
501 struct ib_udata *udata);
502
503int qib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr);
504
505int qib_destroy_srq(struct ib_srq *ibsrq);
506
Mike Marciniszyn8aac4cc2012-06-27 18:33:19 -0400507void mr_rcu_callback(struct rcu_head *list);
508
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800509static inline void qib_put_ss(struct rvt_sge_state *ss)
Mike Marciniszyn6a826492012-06-27 18:33:12 -0400510{
511 while (ss->num_sge) {
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800512 rvt_put_mr(ss->sge.mr);
Mike Marciniszyn6a826492012-06-27 18:33:12 -0400513 if (--ss->num_sge)
514 ss->sge = *ss->sg_list++;
515 }
516}
517
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800518int qib_get_rwqe(struct rvt_qp *qp, int wr_id_only);
Ralph Campbellf9315512010-05-23 21:44:54 -0700519
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800520void qib_migrate_qp(struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700521
522int qib_ruc_check_hdr(struct qib_ibport *ibp, struct qib_ib_header *hdr,
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800523 int has_grh, struct rvt_qp *qp, u32 bth0);
Ralph Campbellf9315512010-05-23 21:44:54 -0700524
525u32 qib_make_grh(struct qib_ibport *ibp, struct ib_grh *hdr,
526 struct ib_global_route *grh, u32 hwords, u32 nwords);
527
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800528void qib_make_ruc_header(struct rvt_qp *qp, struct qib_other_headers *ohdr,
Ralph Campbellf9315512010-05-23 21:44:54 -0700529 u32 bth0, u32 bth2);
530
531void qib_do_send(struct work_struct *work);
532
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800533void qib_send_complete(struct rvt_qp *qp, struct rvt_swqe *wqe,
Ralph Campbellf9315512010-05-23 21:44:54 -0700534 enum ib_wc_status status);
535
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800536void qib_send_rc_ack(struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700537
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800538int qib_make_rc_req(struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700539
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800540int qib_make_uc_req(struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700541
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800542int qib_make_ud_req(struct rvt_qp *qp);
Ralph Campbellf9315512010-05-23 21:44:54 -0700543
544int qib_register_ib_device(struct qib_devdata *);
545
546void qib_unregister_ib_device(struct qib_devdata *);
547
548void qib_ib_rcv(struct qib_ctxtdata *, void *, void *, u32);
549
550void qib_ib_piobufavail(struct qib_devdata *);
551
552unsigned qib_get_npkeys(struct qib_devdata *);
553
554unsigned qib_get_pkey(struct qib_ibport *, unsigned);
555
556extern const enum ib_wc_opcode ib_qib_wc_opcode[];
557
558/*
559 * Below HCA-independent IB PhysPortState values, returned
560 * by the f_ibphys_portstate() routine.
561 */
562#define IB_PHYSPORTSTATE_SLEEP 1
563#define IB_PHYSPORTSTATE_POLL 2
564#define IB_PHYSPORTSTATE_DISABLED 3
565#define IB_PHYSPORTSTATE_CFG_TRAIN 4
566#define IB_PHYSPORTSTATE_LINKUP 5
567#define IB_PHYSPORTSTATE_LINK_ERR_RECOVER 6
568#define IB_PHYSPORTSTATE_CFG_DEBOUNCE 8
569#define IB_PHYSPORTSTATE_CFG_IDLE 0xB
570#define IB_PHYSPORTSTATE_RECOVERY_RETRAIN 0xC
571#define IB_PHYSPORTSTATE_RECOVERY_WAITRMT 0xE
572#define IB_PHYSPORTSTATE_RECOVERY_IDLE 0xF
573#define IB_PHYSPORTSTATE_CFG_ENH 0x10
574#define IB_PHYSPORTSTATE_CFG_WAIT_ENH 0x13
575
576extern const int ib_qib_state_ops[];
577
578extern __be64 ib_qib_sys_image_guid; /* in network order */
579
Dennis Dalessandro7c2e11f2016-01-22 12:45:59 -0800580extern unsigned int ib_rvt_lkey_table_size;
Ralph Campbellf9315512010-05-23 21:44:54 -0700581
582extern unsigned int ib_qib_max_cqes;
583
584extern unsigned int ib_qib_max_cqs;
585
586extern unsigned int ib_qib_max_qp_wrs;
587
588extern unsigned int ib_qib_max_qps;
589
590extern unsigned int ib_qib_max_sges;
591
592extern unsigned int ib_qib_max_mcast_grps;
593
594extern unsigned int ib_qib_max_mcast_qp_attached;
595
596extern unsigned int ib_qib_max_srqs;
597
598extern unsigned int ib_qib_max_srq_sges;
599
600extern unsigned int ib_qib_max_srq_wrs;
601
602extern const u32 ib_qib_rnr_table[];
603
Ralph Campbellf9315512010-05-23 21:44:54 -0700604#endif /* QIB_VERBS_H */