bcc627181298ae0d65418aea2f57f6a10beb3d34
[sfrench/cifs-2.6.git] / drivers / infiniband / hw / qib / qib_verbs.h
1 /*
2  * Copyright (c) 2012, 2013 Intel Corporation.  All rights reserved.
3  * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved.
4  * 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>
44 #include <linux/kthread.h>
45 #include <linux/completion.h>
46 #include <rdma/ib_pack.h>
47 #include <rdma/ib_user_verbs.h>
48 #include <rdma/rdma_vt.h>
49
50 struct qib_ctxtdata;
51 struct qib_pportdata;
52 struct qib_devdata;
53 struct qib_verbs_txreq;
54
55 #define QIB_MAX_RDMA_ATOMIC     16
56 #define QIB_GUIDS_PER_PORT      5
57
58 /*
59  * Increment this value if any changes that break userspace ABI
60  * compatibility are made.
61  */
62 #define QIB_UVERBS_ABI_VERSION       2
63
64 /*
65  * Define an ib_cq_notify value that is not valid so we know when CQ
66  * notifications are armed.
67  */
68 #define IB_CQ_NONE      (IB_CQ_NEXT_COMP + 1)
69
70 #define IB_SEQ_NAK      (3 << 29)
71
72 /* AETH NAK opcode values */
73 #define IB_RNR_NAK                      0x20
74 #define IB_NAK_PSN_ERROR                0x60
75 #define IB_NAK_INVALID_REQUEST          0x61
76 #define IB_NAK_REMOTE_ACCESS_ERROR      0x62
77 #define IB_NAK_REMOTE_OPERATIONAL_ERROR 0x63
78 #define IB_NAK_INVALID_RD_REQUEST       0x64
79
80 /* Flags for checking QP state (see ib_qib_state_ops[]) */
81 #define QIB_POST_SEND_OK                0x01
82 #define QIB_POST_RECV_OK                0x02
83 #define QIB_PROCESS_RECV_OK             0x04
84 #define QIB_PROCESS_SEND_OK             0x08
85 #define QIB_PROCESS_NEXT_SEND_OK        0x10
86 #define QIB_FLUSH_SEND                  0x20
87 #define QIB_FLUSH_RECV                  0x40
88 #define QIB_PROCESS_OR_FLUSH_SEND \
89         (QIB_PROCESS_SEND_OK | QIB_FLUSH_SEND)
90
91 /* IB Performance Manager status values */
92 #define IB_PMA_SAMPLE_STATUS_DONE       0x00
93 #define IB_PMA_SAMPLE_STATUS_STARTED    0x01
94 #define IB_PMA_SAMPLE_STATUS_RUNNING    0x02
95
96 /* Mandatory IB performance counter select values. */
97 #define IB_PMA_PORT_XMIT_DATA   cpu_to_be16(0x0001)
98 #define IB_PMA_PORT_RCV_DATA    cpu_to_be16(0x0002)
99 #define IB_PMA_PORT_XMIT_PKTS   cpu_to_be16(0x0003)
100 #define IB_PMA_PORT_RCV_PKTS    cpu_to_be16(0x0004)
101 #define IB_PMA_PORT_XMIT_WAIT   cpu_to_be16(0x0005)
102
103 #define QIB_VENDOR_IPG          cpu_to_be16(0xFFA0)
104
105 #define IB_BTH_REQ_ACK          (1 << 31)
106 #define IB_BTH_SOLICITED        (1 << 23)
107 #define IB_BTH_MIG_REQ          (1 << 22)
108
109 /* XXX Should be defined in ib_verbs.h enum ib_port_cap_flags */
110 #define IB_PORT_OTHER_LOCAL_CHANGES_SUP (1 << 26)
111
112 #define IB_GRH_VERSION          6
113 #define IB_GRH_VERSION_MASK     0xF
114 #define IB_GRH_VERSION_SHIFT    28
115 #define IB_GRH_TCLASS_MASK      0xFF
116 #define IB_GRH_TCLASS_SHIFT     20
117 #define IB_GRH_FLOW_MASK        0xFFFFF
118 #define IB_GRH_FLOW_SHIFT       0
119 #define IB_GRH_NEXT_HDR         0x1B
120
121 #define IB_DEFAULT_GID_PREFIX   cpu_to_be64(0xfe80000000000000ULL)
122
123 /* Values for set/get portinfo VLCap OperationalVLs */
124 #define IB_VL_VL0       1
125 #define IB_VL_VL0_1     2
126 #define IB_VL_VL0_3     3
127 #define IB_VL_VL0_7     4
128 #define IB_VL_VL0_14    5
129
130 static inline int qib_num_vls(int vls)
131 {
132         switch (vls) {
133         default:
134         case IB_VL_VL0:
135                 return 1;
136         case IB_VL_VL0_1:
137                 return 2;
138         case IB_VL_VL0_3:
139                 return 4;
140         case IB_VL_VL0_7:
141                 return 8;
142         case IB_VL_VL0_14:
143                 return 15;
144         }
145 }
146
147 struct ib_reth {
148         __be64 vaddr;
149         __be32 rkey;
150         __be32 length;
151 } __packed;
152
153 struct ib_atomic_eth {
154         __be32 vaddr[2];        /* unaligned so access as 2 32-bit words */
155         __be32 rkey;
156         __be64 swap_data;
157         __be64 compare_data;
158 } __packed;
159
160 struct qib_other_headers {
161         __be32 bth[3];
162         union {
163                 struct {
164                         __be32 deth[2];
165                         __be32 imm_data;
166                 } ud;
167                 struct {
168                         struct ib_reth reth;
169                         __be32 imm_data;
170                 } rc;
171                 struct {
172                         __be32 aeth;
173                         __be32 atomic_ack_eth[2];
174                 } at;
175                 __be32 imm_data;
176                 __be32 aeth;
177                 struct ib_atomic_eth atomic_eth;
178         } u;
179 } __packed;
180
181 /*
182  * Note that UD packets with a GRH header are 8+40+12+8 = 68 bytes
183  * long (72 w/ imm_data).  Only the first 56 bytes of the IB header
184  * will be in the eager header buffer.  The remaining 12 or 16 bytes
185  * are in the data buffer.
186  */
187 struct qib_ib_header {
188         __be16 lrh[4];
189         union {
190                 struct {
191                         struct ib_grh grh;
192                         struct qib_other_headers oth;
193                 } l;
194                 struct qib_other_headers oth;
195         } u;
196 } __packed;
197
198 struct qib_pio_header {
199         __le32 pbc[2];
200         struct qib_ib_header hdr;
201 } __packed;
202
203 /*
204  * There is one struct qib_mcast for each multicast GID.
205  * All attached QPs are then stored as a list of
206  * struct qib_mcast_qp.
207  */
208 struct qib_mcast_qp {
209         struct list_head list;
210         struct rvt_qp *qp;
211 };
212
213 struct qib_mcast {
214         struct rb_node rb_node;
215         union ib_gid mgid;
216         struct list_head qp_list;
217         wait_queue_head_t wait;
218         atomic_t refcount;
219         int n_attached;
220 };
221
222 /*
223  * This structure is used to contain the head pointer, tail pointer,
224  * and completion queue entries as a single memory allocation so
225  * it can be mmap'ed into user space.
226  */
227 struct qib_cq_wc {
228         u32 head;               /* index of next entry to fill */
229         u32 tail;               /* index of next ib_poll_cq() entry */
230         union {
231                 /* these are actually size ibcq.cqe + 1 */
232                 struct ib_uverbs_wc uqueue[0];
233                 struct ib_wc kqueue[0];
234         };
235 };
236
237 /*
238  * The completion queue structure.
239  */
240 struct qib_cq {
241         struct ib_cq ibcq;
242         struct kthread_work comptask;
243         struct qib_devdata *dd;
244         spinlock_t lock; /* protect changes in this struct */
245         u8 notify;
246         u8 triggered;
247         struct qib_cq_wc *queue;
248         struct rvt_mmap_info *ip;
249 };
250
251 /*
252  * qib specific data structure that will be hidden from rvt after the queue pair
253  * is made common.
254  */
255 struct qib_qp_priv {
256         struct qib_ib_header *s_hdr;    /* next packet header to send */
257         struct list_head iowait;        /* link for wait PIO buf */
258         atomic_t s_dma_busy;
259         struct qib_verbs_txreq *s_tx;
260         struct work_struct s_work;
261         wait_queue_head_t wait_dma;
262         struct rvt_qp *owner;
263 };
264
265 #define QIB_PSN_CREDIT  16
266
267 /*
268  * Since struct rvt_swqe is not a fixed size, we can't simply index into
269  * struct rvt_qp.s_wq.  This function does the array index computation.
270  */
271 static inline struct rvt_swqe *get_swqe_ptr(struct rvt_qp *qp,
272                                             unsigned n)
273 {
274         return (struct rvt_swqe *)((char *)qp->s_wq +
275                                      (sizeof(struct rvt_swqe) +
276                                       qp->s_max_sge *
277                                       sizeof(struct rvt_sge)) * n);
278 }
279
280 /*
281  * Since struct rvt_rwqe is not a fixed size, we can't simply index into
282  * struct rvt_rwq.wq.  This function does the array index computation.
283  */
284 static inline struct rvt_rwqe *get_rwqe_ptr(struct rvt_rq *rq, unsigned n)
285 {
286         return (struct rvt_rwqe *)
287                 ((char *) rq->wq->wq +
288                  (sizeof(struct rvt_rwqe) +
289                   rq->max_sge * sizeof(struct ib_sge)) * n);
290 }
291
292 struct qib_opcode_stats {
293         u64 n_packets;          /* number of packets */
294         u64 n_bytes;            /* total number of bytes */
295 };
296
297 struct qib_opcode_stats_perctx {
298         struct qib_opcode_stats stats[128];
299 };
300
301 struct qib_pma_counters {
302         u64 n_unicast_xmit;     /* total unicast packets sent */
303         u64 n_unicast_rcv;      /* total unicast packets received */
304         u64 n_multicast_xmit;   /* total multicast packets sent */
305         u64 n_multicast_rcv;    /* total multicast packets received */
306 };
307
308 struct qib_ibport {
309         struct rvt_ibport rvp;
310         struct rvt_ah *sm_ah;
311         struct rvt_ah *smi_ah;
312         __be64 guids[QIB_GUIDS_PER_PORT - 1];   /* writable GUIDs */
313         struct qib_pma_counters __percpu *pmastats;
314         u64 z_unicast_xmit;     /* starting count for PMA */
315         u64 z_unicast_rcv;      /* starting count for PMA */
316         u64 z_multicast_xmit;   /* starting count for PMA */
317         u64 z_multicast_rcv;    /* starting count for PMA */
318         u64 z_symbol_error_counter;             /* starting count for PMA */
319         u64 z_link_error_recovery_counter;      /* starting count for PMA */
320         u64 z_link_downed_counter;              /* starting count for PMA */
321         u64 z_port_rcv_errors;                  /* starting count for PMA */
322         u64 z_port_rcv_remphys_errors;          /* starting count for PMA */
323         u64 z_port_xmit_discards;               /* starting count for PMA */
324         u64 z_port_xmit_data;                   /* starting count for PMA */
325         u64 z_port_rcv_data;                    /* starting count for PMA */
326         u64 z_port_xmit_packets;                /* starting count for PMA */
327         u64 z_port_rcv_packets;                 /* starting count for PMA */
328         u32 z_local_link_integrity_errors;      /* starting count for PMA */
329         u32 z_excessive_buffer_overrun_errors;  /* starting count for PMA */
330         u32 z_vl15_dropped;                     /* starting count for PMA */
331         u8 sl_to_vl[16];
332 };
333
334 struct qib_ibdev {
335         struct rvt_dev_info rdi;
336
337         struct list_head piowait;       /* list for wait PIO buf */
338         struct list_head dmawait;       /* list for wait DMA */
339         struct list_head txwait;        /* list for wait qib_verbs_txreq */
340         struct list_head memwait;       /* list for wait kernel memory */
341         struct list_head txreq_free;
342         struct timer_list mem_timer;
343         struct qib_pio_header *pio_hdrs;
344         dma_addr_t pio_hdrs_phys;
345         u32 qp_rnd; /* random bytes for hash */
346
347         u32 n_piowait;
348         u32 n_txwait;
349
350         u32 n_cqs_allocated;    /* number of CQs allocated for device */
351         spinlock_t n_cqs_lock;
352         u32 n_qps_allocated;    /* number of QPs allocated for device */
353         spinlock_t n_qps_lock;
354         u32 n_srqs_allocated;   /* number of SRQs allocated for device */
355         spinlock_t n_srqs_lock;
356         u32 n_mcast_grps_allocated; /* number of mcast groups allocated */
357         spinlock_t n_mcast_grps_lock;
358 #ifdef CONFIG_DEBUG_FS
359         /* per HCA debugfs */
360         struct dentry *qib_ibdev_dbg;
361 #endif
362 };
363
364 struct qib_verbs_counters {
365         u64 symbol_error_counter;
366         u64 link_error_recovery_counter;
367         u64 link_downed_counter;
368         u64 port_rcv_errors;
369         u64 port_rcv_remphys_errors;
370         u64 port_xmit_discards;
371         u64 port_xmit_data;
372         u64 port_rcv_data;
373         u64 port_xmit_packets;
374         u64 port_rcv_packets;
375         u32 local_link_integrity_errors;
376         u32 excessive_buffer_overrun_errors;
377         u32 vl15_dropped;
378 };
379
380 static inline struct qib_cq *to_icq(struct ib_cq *ibcq)
381 {
382         return container_of(ibcq, struct qib_cq, ibcq);
383 }
384
385 static inline struct rvt_qp *to_iqp(struct ib_qp *ibqp)
386 {
387         return container_of(ibqp, struct rvt_qp, ibqp);
388 }
389
390 static inline struct qib_ibdev *to_idev(struct ib_device *ibdev)
391 {
392         struct rvt_dev_info *rdi;
393
394         rdi = container_of(ibdev, struct rvt_dev_info, ibdev);
395         return container_of(rdi, struct qib_ibdev, rdi);
396 }
397
398 /*
399  * Send if not busy or waiting for I/O and either
400  * a RC response is pending or we can process send work requests.
401  */
402 static inline int qib_send_ok(struct rvt_qp *qp)
403 {
404         return !(qp->s_flags & (RVT_S_BUSY | RVT_S_ANY_WAIT_IO)) &&
405                 (qp->s_hdrwords || (qp->s_flags & RVT_S_RESP_PENDING) ||
406                  !(qp->s_flags & RVT_S_ANY_WAIT_SEND));
407 }
408
409 /*
410  * This must be called with s_lock held.
411  */
412 void qib_schedule_send(struct rvt_qp *qp);
413
414 static inline int qib_pkey_ok(u16 pkey1, u16 pkey2)
415 {
416         u16 p1 = pkey1 & 0x7FFF;
417         u16 p2 = pkey2 & 0x7FFF;
418
419         /*
420          * Low 15 bits must be non-zero and match, and
421          * one of the two must be a full member.
422          */
423         return p1 && p1 == p2 && ((__s16)pkey1 < 0 || (__s16)pkey2 < 0);
424 }
425
426 void qib_bad_pqkey(struct qib_ibport *ibp, __be16 trap_num, u32 key, u32 sl,
427                    u32 qp1, u32 qp2, __be16 lid1, __be16 lid2);
428 void qib_cap_mask_chg(struct qib_ibport *ibp);
429 void qib_sys_guid_chg(struct qib_ibport *ibp);
430 void qib_node_desc_chg(struct qib_ibport *ibp);
431 int qib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
432                     const struct ib_wc *in_wc, const struct ib_grh *in_grh,
433                     const struct ib_mad_hdr *in, size_t in_mad_size,
434                     struct ib_mad_hdr *out, size_t *out_mad_size,
435                     u16 *out_mad_pkey_index);
436 int qib_create_agents(struct qib_ibdev *dev);
437 void qib_free_agents(struct qib_ibdev *dev);
438
439 /*
440  * Compare the lower 24 bits of the two values.
441  * Returns an integer <, ==, or > than zero.
442  */
443 static inline int qib_cmp24(u32 a, u32 b)
444 {
445         return (((int) a) - ((int) b)) << 8;
446 }
447
448 struct qib_mcast *qib_mcast_find(struct qib_ibport *ibp, union ib_gid *mgid);
449
450 int qib_snapshot_counters(struct qib_pportdata *ppd, u64 *swords,
451                           u64 *rwords, u64 *spkts, u64 *rpkts,
452                           u64 *xmit_wait);
453
454 int qib_get_counters(struct qib_pportdata *ppd,
455                      struct qib_verbs_counters *cntrs);
456
457 int qib_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
458
459 int qib_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
460
461 int qib_mcast_tree_empty(struct qib_ibport *ibp);
462
463 __be32 qib_compute_aeth(struct rvt_qp *qp);
464
465 struct rvt_qp *qib_lookup_qpn(struct qib_ibport *ibp, u32 qpn);
466
467 int qib_destroy_qp(struct ib_qp *ibqp);
468
469 int qib_error_qp(struct rvt_qp *qp, enum ib_wc_status err);
470
471 int qib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
472                   int attr_mask, struct ib_udata *udata);
473
474 int qib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
475                  int attr_mask, struct ib_qp_init_attr *init_attr);
476 /*
477  * Functions provided by qib driver for rdmavt to use
478  */
479 unsigned qib_free_all_qps(struct rvt_dev_info *rdi);
480 void *qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp, gfp_t gfp);
481 void qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp);
482 void notify_qp_reset(struct rvt_qp *qp);
483 int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
484               enum ib_qp_type type, u8 port, gfp_t gfp);
485
486 #ifdef CONFIG_DEBUG_FS
487
488 struct qib_qp_iter;
489
490 struct qib_qp_iter *qib_qp_iter_init(struct qib_ibdev *dev);
491
492 int qib_qp_iter_next(struct qib_qp_iter *iter);
493
494 void qib_qp_iter_print(struct seq_file *s, struct qib_qp_iter *iter);
495
496 #endif
497
498 void qib_get_credit(struct rvt_qp *qp, u32 aeth);
499
500 unsigned qib_pkt_delay(u32 plen, u8 snd_mult, u8 rcv_mult);
501
502 void qib_verbs_sdma_desc_avail(struct qib_pportdata *ppd, unsigned avail);
503
504 void qib_put_txreq(struct qib_verbs_txreq *tx);
505
506 int qib_verbs_send(struct rvt_qp *qp, struct qib_ib_header *hdr,
507                    u32 hdrwords, struct rvt_sge_state *ss, u32 len);
508
509 void qib_copy_sge(struct rvt_sge_state *ss, void *data, u32 length,
510                   int release);
511
512 void qib_skip_sge(struct rvt_sge_state *ss, u32 length, int release);
513
514 void qib_uc_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
515                 int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
516
517 void qib_rc_rcv(struct qib_ctxtdata *rcd, struct qib_ib_header *hdr,
518                 int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
519
520 int qib_check_ah(struct ib_device *ibdev, struct ib_ah_attr *ah_attr);
521
522 struct ib_ah *qib_create_qp0_ah(struct qib_ibport *ibp, u16 dlid);
523
524 void qib_rc_rnr_retry(unsigned long arg);
525
526 void qib_rc_send_complete(struct rvt_qp *qp, struct qib_ib_header *hdr);
527
528 void qib_rc_error(struct rvt_qp *qp, enum ib_wc_status err);
529
530 int qib_post_ud_send(struct rvt_qp *qp, struct ib_send_wr *wr);
531
532 void qib_ud_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
533                 int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
534
535 int qib_post_srq_receive(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
536                          struct ib_recv_wr **bad_wr);
537
538 struct ib_srq *qib_create_srq(struct ib_pd *ibpd,
539                               struct ib_srq_init_attr *srq_init_attr,
540                               struct ib_udata *udata);
541
542 int qib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
543                    enum ib_srq_attr_mask attr_mask,
544                    struct ib_udata *udata);
545
546 int qib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr);
547
548 int qib_destroy_srq(struct ib_srq *ibsrq);
549
550 int qib_cq_init(struct qib_devdata *dd);
551
552 void qib_cq_exit(struct qib_devdata *dd);
553
554 void qib_cq_enter(struct qib_cq *cq, struct ib_wc *entry, int sig);
555
556 int qib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry);
557
558 struct ib_cq *qib_create_cq(struct ib_device *ibdev,
559                             const struct ib_cq_init_attr *attr,
560                             struct ib_ucontext *context,
561                             struct ib_udata *udata);
562
563 int qib_destroy_cq(struct ib_cq *ibcq);
564
565 int qib_req_notify_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags notify_flags);
566
567 int qib_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata);
568
569 void mr_rcu_callback(struct rcu_head *list);
570
571 static inline void qib_put_ss(struct rvt_sge_state *ss)
572 {
573         while (ss->num_sge) {
574                 rvt_put_mr(ss->sge.mr);
575                 if (--ss->num_sge)
576                         ss->sge = *ss->sg_list++;
577         }
578 }
579
580 int qib_get_rwqe(struct rvt_qp *qp, int wr_id_only);
581
582 void qib_migrate_qp(struct rvt_qp *qp);
583
584 int qib_ruc_check_hdr(struct qib_ibport *ibp, struct qib_ib_header *hdr,
585                       int has_grh, struct rvt_qp *qp, u32 bth0);
586
587 u32 qib_make_grh(struct qib_ibport *ibp, struct ib_grh *hdr,
588                  struct ib_global_route *grh, u32 hwords, u32 nwords);
589
590 void qib_make_ruc_header(struct rvt_qp *qp, struct qib_other_headers *ohdr,
591                          u32 bth0, u32 bth2);
592
593 void qib_do_send(struct work_struct *work);
594
595 void qib_send_complete(struct rvt_qp *qp, struct rvt_swqe *wqe,
596                        enum ib_wc_status status);
597
598 void qib_send_rc_ack(struct rvt_qp *qp);
599
600 int qib_make_rc_req(struct rvt_qp *qp);
601
602 int qib_make_uc_req(struct rvt_qp *qp);
603
604 int qib_make_ud_req(struct rvt_qp *qp);
605
606 int qib_register_ib_device(struct qib_devdata *);
607
608 void qib_unregister_ib_device(struct qib_devdata *);
609
610 void qib_ib_rcv(struct qib_ctxtdata *, void *, void *, u32);
611
612 void qib_ib_piobufavail(struct qib_devdata *);
613
614 unsigned qib_get_npkeys(struct qib_devdata *);
615
616 unsigned qib_get_pkey(struct qib_ibport *, unsigned);
617
618 extern const enum ib_wc_opcode ib_qib_wc_opcode[];
619
620 /*
621  * Below  HCA-independent IB PhysPortState values, returned
622  * by the f_ibphys_portstate() routine.
623  */
624 #define IB_PHYSPORTSTATE_SLEEP 1
625 #define IB_PHYSPORTSTATE_POLL 2
626 #define IB_PHYSPORTSTATE_DISABLED 3
627 #define IB_PHYSPORTSTATE_CFG_TRAIN 4
628 #define IB_PHYSPORTSTATE_LINKUP 5
629 #define IB_PHYSPORTSTATE_LINK_ERR_RECOVER 6
630 #define IB_PHYSPORTSTATE_CFG_DEBOUNCE 8
631 #define IB_PHYSPORTSTATE_CFG_IDLE 0xB
632 #define IB_PHYSPORTSTATE_RECOVERY_RETRAIN 0xC
633 #define IB_PHYSPORTSTATE_RECOVERY_WAITRMT 0xE
634 #define IB_PHYSPORTSTATE_RECOVERY_IDLE 0xF
635 #define IB_PHYSPORTSTATE_CFG_ENH 0x10
636 #define IB_PHYSPORTSTATE_CFG_WAIT_ENH 0x13
637
638 extern const int ib_qib_state_ops[];
639
640 extern __be64 ib_qib_sys_image_guid;    /* in network order */
641
642 extern unsigned int ib_rvt_lkey_table_size;
643
644 extern unsigned int ib_qib_max_cqes;
645
646 extern unsigned int ib_qib_max_cqs;
647
648 extern unsigned int ib_qib_max_qp_wrs;
649
650 extern unsigned int ib_qib_max_qps;
651
652 extern unsigned int ib_qib_max_sges;
653
654 extern unsigned int ib_qib_max_mcast_grps;
655
656 extern unsigned int ib_qib_max_mcast_qp_attached;
657
658 extern unsigned int ib_qib_max_srqs;
659
660 extern unsigned int ib_qib_max_srq_sges;
661
662 extern unsigned int ib_qib_max_srq_wrs;
663
664 extern const u32 ib_qib_rnr_table[];
665
666 #endif                          /* QIB_VERBS_H */