1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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 <rdma/ib_pack.h>
45#include <rdma/ib_user_verbs.h>
46
47struct qib_ctxtdata;
48struct qib_pportdata;
49struct qib_devdata;
50struct qib_verbs_txreq;
51
52#define QIB_MAX_RDMA_ATOMIC 16
53#define QIB_GUIDS_PER_PORT 5
54
55#define QPN_MAX (1 << 24)
56#define QPNMAP_ENTRIES (QPN_MAX / PAGE_SIZE / BITS_PER_BYTE)
57
58
59
60
61
62#define QIB_UVERBS_ABI_VERSION 2
63
64
65
66
67
68#define IB_CQ_NONE (IB_CQ_NEXT_COMP + 1)
69
70#define IB_SEQ_NAK (3 << 29)
71
72
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
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
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
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
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
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
130static 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
147struct ib_reth {
148 __be64 vaddr;
149 __be32 rkey;
150 __be32 length;
151} __attribute__ ((packed));
152
153struct ib_atomic_eth {
154 __be32 vaddr[2];
155 __be32 rkey;
156 __be64 swap_data;
157 __be64 compare_data;
158} __attribute__ ((packed));
159
160struct 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} __attribute__ ((packed));
180
181
182
183
184
185
186
187struct 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} __attribute__ ((packed));
197
198struct qib_pio_header {
199 __le32 pbc[2];
200 struct qib_ib_header hdr;
201} __attribute__ ((packed));
202
203
204
205
206
207
208struct qib_mcast_qp {
209 struct list_head list;
210 struct qib_qp *qp;
211};
212
213struct 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
223struct qib_pd {
224 struct ib_pd ibpd;
225 int user;
226};
227
228
229struct qib_ah {
230 struct ib_ah ibah;
231 struct ib_ah_attr attr;
232 atomic_t refcount;
233};
234
235
236
237
238
239
240struct qib_mmap_info {
241 struct list_head pending_mmaps;
242 struct ib_ucontext *context;
243 void *obj;
244 __u64 offset;
245 struct kref ref;
246 unsigned size;
247};
248
249
250
251
252
253
254struct qib_cq_wc {
255 u32 head;
256 u32 tail;
257 union {
258
259 struct ib_uverbs_wc uqueue[0];
260 struct ib_wc kqueue[0];
261 };
262};
263
264
265
266
267struct qib_cq {
268 struct ib_cq ibcq;
269 struct work_struct comptask;
270 spinlock_t lock;
271 u8 notify;
272 u8 triggered;
273 struct qib_cq_wc *queue;
274 struct qib_mmap_info *ip;
275};
276
277
278
279
280
281
282struct qib_seg {
283 void *vaddr;
284 size_t length;
285};
286
287
288#define QIB_SEGSZ (PAGE_SIZE / sizeof(struct qib_seg))
289
290struct qib_segarray {
291 struct qib_seg segs[QIB_SEGSZ];
292};
293
294struct qib_mregion {
295 struct ib_pd *pd;
296 u64 user_base;
297 u64 iova;
298 size_t length;
299 u32 lkey;
300 u32 offset;
301 int access_flags;
302 u32 max_segs;
303 u32 mapsz;
304 u8 page_shift;
305 atomic_t refcount;
306 struct qib_segarray *map[0];
307};
308
309
310
311
312
313struct qib_sge {
314 struct qib_mregion *mr;
315 void *vaddr;
316 u32 sge_length;
317 u32 length;
318 u16 m;
319 u16 n;
320};
321
322
323struct qib_mr {
324 struct ib_mr ibmr;
325 struct ib_umem *umem;
326 struct qib_mregion mr;
327};
328
329
330
331
332
333
334struct qib_swqe {
335 struct ib_send_wr wr;
336 u32 psn;
337 u32 lpsn;
338 u32 ssn;
339 u32 length;
340 struct qib_sge sg_list[0];
341};
342
343
344
345
346
347
348struct qib_rwqe {
349 u64 wr_id;
350 u8 num_sge;
351 struct ib_sge sg_list[0];
352};
353
354
355
356
357
358
359
360
361
362struct qib_rwq {
363 u32 head;
364 u32 tail;
365 struct qib_rwqe wq[0];
366};
367
368struct qib_rq {
369 struct qib_rwq *wq;
370 spinlock_t lock;
371 u32 size;
372 u8 max_sge;
373};
374
375struct qib_srq {
376 struct ib_srq ibsrq;
377 struct qib_rq rq;
378 struct qib_mmap_info *ip;
379
380 u32 limit;
381};
382
383struct qib_sge_state {
384 struct qib_sge *sg_list;
385 struct qib_sge sge;
386 u32 total_len;
387 u8 num_sge;
388};
389
390
391
392
393
394struct qib_ack_entry {
395 u8 opcode;
396 u8 sent;
397 u32 psn;
398 u32 lpsn;
399 union {
400 struct qib_sge rdma_sge;
401 u64 atomic_data;
402 };
403};
404
405
406
407
408
409
410
411
412
413struct qib_qp {
414 struct ib_qp ibqp;
415 struct qib_qp *next;
416 struct qib_qp *timer_next;
417 struct list_head iowait;
418 struct list_head rspwait;
419 struct ib_ah_attr remote_ah_attr;
420 struct ib_ah_attr alt_ah_attr;
421 struct qib_ib_header s_hdr;
422 atomic_t refcount;
423 wait_queue_head_t wait;
424 wait_queue_head_t wait_dma;
425 struct timer_list s_timer;
426 struct work_struct s_work;
427 struct qib_mmap_info *ip;
428 struct qib_sge_state *s_cur_sge;
429 struct qib_verbs_txreq *s_tx;
430 struct qib_mregion *s_rdma_mr;
431 struct qib_sge_state s_sge;
432 struct qib_ack_entry s_ack_queue[QIB_MAX_RDMA_ATOMIC + 1];
433 struct qib_sge_state s_ack_rdma_sge;
434 struct qib_sge_state s_rdma_read_sge;
435 struct qib_sge_state r_sge;
436 spinlock_t r_lock;
437 spinlock_t s_lock;
438 atomic_t s_dma_busy;
439 u32 s_flags;
440 u32 s_cur_size;
441 u32 s_len;
442 u32 s_rdma_read_len;
443 u32 s_next_psn;
444 u32 s_last_psn;
445 u32 s_sending_psn;
446 u32 s_sending_hpsn;
447 u32 s_psn;
448 u32 s_ack_rdma_psn;
449 u32 s_ack_psn;
450 u32 s_rnr_timeout;
451 u32 r_ack_psn;
452 u64 r_wr_id;
453 unsigned long r_aflags;
454 u32 r_len;
455 u32 r_rcv_len;
456 u32 r_psn;
457 u32 r_msn;
458 u16 s_hdrwords;
459 u16 s_rdma_ack_cnt;
460 u8 state;
461 u8 s_state;
462 u8 s_ack_state;
463 u8 s_nak_state;
464 u8 r_state;
465 u8 r_nak_state;
466 u8 r_min_rnr_timer;
467 u8 r_flags;
468 u8 r_max_rd_atomic;
469 u8 r_head_ack_queue;
470 u8 qp_access_flags;
471 u8 s_max_sge;
472 u8 s_retry_cnt;
473 u8 s_rnr_retry_cnt;
474 u8 s_retry;
475 u8 s_rnr_retry;
476 u8 s_pkey_index;
477 u8 s_alt_pkey_index;
478 u8 s_max_rd_atomic;
479 u8 s_num_rd_atomic;
480 u8 s_tail_ack_queue;
481 u8 s_srate;
482 u8 s_draining;
483 u8 s_mig_state;
484 u8 timeout;
485 u8 alt_timeout;
486 u8 port_num;
487 enum ib_mtu path_mtu;
488 u32 pmtu;
489 u32 remote_qpn;
490 u32 qkey;
491 u32 s_size;
492 u32 s_head;
493 u32 s_tail;
494 u32 s_cur;
495 u32 s_acked;
496 u32 s_last;
497 u32 s_ssn;
498 u32 s_lsn;
499 unsigned long timeout_jiffies;
500 struct qib_swqe *s_wq;
501 struct qib_swqe *s_wqe;
502 struct qib_rq r_rq;
503 struct qib_sge r_sg_list[0];
504};
505
506
507
508
509#define QIB_R_WRID_VALID 0
510#define QIB_R_REWIND_SGE 1
511
512
513
514
515#define QIB_R_REUSE_SGE 0x01
516#define QIB_R_RDMAR_SEQ 0x02
517#define QIB_R_RSP_NAK 0x04
518#define QIB_R_RSP_SEND 0x08
519#define QIB_R_COMM_EST 0x10
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544#define QIB_S_SIGNAL_REQ_WR 0x0001
545#define QIB_S_BUSY 0x0002
546#define QIB_S_TIMER 0x0004
547#define QIB_S_RESP_PENDING 0x0008
548#define QIB_S_ACK_PENDING 0x0010
549#define QIB_S_WAIT_FENCE 0x0020
550#define QIB_S_WAIT_RDMAR 0x0040
551#define QIB_S_WAIT_RNR 0x0080
552#define QIB_S_WAIT_SSN_CREDIT 0x0100
553#define QIB_S_WAIT_DMA 0x0200
554#define QIB_S_WAIT_PIO 0x0400
555#define QIB_S_WAIT_TX 0x0800
556#define QIB_S_WAIT_DMA_DESC 0x1000
557#define QIB_S_WAIT_KMEM 0x2000
558#define QIB_S_WAIT_PSN 0x4000
559#define QIB_S_WAIT_ACK 0x8000
560#define QIB_S_SEND_ONE 0x10000
561#define QIB_S_UNLIMITED_CREDIT 0x20000
562
563
564
565
566#define QIB_S_ANY_WAIT_IO (QIB_S_WAIT_PIO | QIB_S_WAIT_TX | \
567 QIB_S_WAIT_DMA_DESC | QIB_S_WAIT_KMEM)
568
569
570
571
572#define QIB_S_ANY_WAIT_SEND (QIB_S_WAIT_FENCE | QIB_S_WAIT_RDMAR | \
573 QIB_S_WAIT_RNR | QIB_S_WAIT_SSN_CREDIT | QIB_S_WAIT_DMA | \
574 QIB_S_WAIT_PSN | QIB_S_WAIT_ACK)
575
576#define QIB_S_ANY_WAIT (QIB_S_ANY_WAIT_IO | QIB_S_ANY_WAIT_SEND)
577
578#define QIB_PSN_CREDIT 16
579
580
581
582
583
584static inline struct qib_swqe *get_swqe_ptr(struct qib_qp *qp,
585 unsigned n)
586{
587 return (struct qib_swqe *)((char *)qp->s_wq +
588 (sizeof(struct qib_swqe) +
589 qp->s_max_sge *
590 sizeof(struct qib_sge)) * n);
591}
592
593
594
595
596
597static inline struct qib_rwqe *get_rwqe_ptr(struct qib_rq *rq, unsigned n)
598{
599 return (struct qib_rwqe *)
600 ((char *) rq->wq->wq +
601 (sizeof(struct qib_rwqe) +
602 rq->max_sge * sizeof(struct ib_sge)) * n);
603}
604
605
606
607
608
609
610struct qpn_map {
611 void *page;
612};
613
614struct qib_qpn_table {
615 spinlock_t lock;
616 unsigned flags;
617 u32 last;
618 u32 nmaps;
619 u16 limit;
620 u16 mask;
621
622 struct qpn_map map[QPNMAP_ENTRIES];
623};
624
625struct qib_lkey_table {
626 spinlock_t lock;
627 u32 next;
628 u32 gen;
629 u32 max;
630 struct qib_mregion **table;
631};
632
633struct qib_opcode_stats {
634 u64 n_packets;
635 u64 n_bytes;
636};
637
638struct qib_ibport {
639 struct qib_qp *qp0;
640 struct qib_qp *qp1;
641 struct ib_mad_agent *send_agent;
642 struct qib_ah *sm_ah;
643 struct qib_ah *smi_ah;
644 struct rb_root mcast_tree;
645 spinlock_t lock;
646
647
648 unsigned long mkey_lease_timeout;
649 unsigned long trap_timeout;
650 __be64 gid_prefix;
651 __be64 mkey;
652 __be64 guids[QIB_GUIDS_PER_PORT - 1];
653 u64 tid;
654 u64 n_unicast_xmit;
655 u64 n_unicast_rcv;
656 u64 n_multicast_xmit;
657 u64 n_multicast_rcv;
658 u64 z_symbol_error_counter;
659 u64 z_link_error_recovery_counter;
660 u64 z_link_downed_counter;
661 u64 z_port_rcv_errors;
662 u64 z_port_rcv_remphys_errors;
663 u64 z_port_xmit_discards;
664 u64 z_port_xmit_data;
665 u64 z_port_rcv_data;
666 u64 z_port_xmit_packets;
667 u64 z_port_rcv_packets;
668 u32 z_local_link_integrity_errors;
669 u32 z_excessive_buffer_overrun_errors;
670 u32 z_vl15_dropped;
671 u32 n_rc_resends;
672 u32 n_rc_acks;
673 u32 n_rc_qacks;
674 u32 n_rc_delayed_comp;
675 u32 n_seq_naks;
676 u32 n_rdma_seq;
677 u32 n_rnr_naks;
678 u32 n_other_naks;
679 u32 n_loop_pkts;
680 u32 n_pkt_drops;
681 u32 n_vl15_dropped;
682 u32 n_rc_timeouts;
683 u32 n_dmawait;
684 u32 n_unaligned;
685 u32 n_rc_dupreq;
686 u32 n_rc_seqnak;
687 u32 port_cap_flags;
688 u32 pma_sample_start;
689 u32 pma_sample_interval;
690 __be16 pma_counter_select[5];
691 u16 pma_tag;
692 u16 pkey_violations;
693 u16 qkey_violations;
694 u16 mkey_violations;
695 u16 mkey_lease_period;
696 u16 sm_lid;
697 u16 repress_traps;
698 u8 sm_sl;
699 u8 mkeyprot;
700 u8 subnet_timeout;
701 u8 vl_high_limit;
702 u8 sl_to_vl[16];
703
704 struct qib_opcode_stats opstats[128];
705};
706
707struct qib_ibdev {
708 struct ib_device ibdev;
709 struct list_head pending_mmaps;
710 spinlock_t mmap_offset_lock;
711 u32 mmap_offset;
712 struct qib_mregion *dma_mr;
713
714
715 struct qib_qpn_table qpn_table;
716 struct qib_lkey_table lk_table;
717 struct list_head piowait;
718 struct list_head dmawait;
719 struct list_head txwait;
720 struct list_head memwait;
721 struct list_head txreq_free;
722 struct timer_list mem_timer;
723 struct qib_qp **qp_table;
724 struct qib_pio_header *pio_hdrs;
725 dma_addr_t pio_hdrs_phys;
726
727 spinlock_t pending_lock;
728 u32 qp_table_size;
729 u32 qp_rnd;
730 spinlock_t qpt_lock;
731
732 u32 n_piowait;
733 u32 n_txwait;
734
735 u32 n_pds_allocated;
736 spinlock_t n_pds_lock;
737 u32 n_ahs_allocated;
738 spinlock_t n_ahs_lock;
739 u32 n_cqs_allocated;
740 spinlock_t n_cqs_lock;
741 u32 n_qps_allocated;
742 spinlock_t n_qps_lock;
743 u32 n_srqs_allocated;
744 spinlock_t n_srqs_lock;
745 u32 n_mcast_grps_allocated;
746 spinlock_t n_mcast_grps_lock;
747};
748
749struct qib_verbs_counters {
750 u64 symbol_error_counter;
751 u64 link_error_recovery_counter;
752 u64 link_downed_counter;
753 u64 port_rcv_errors;
754 u64 port_rcv_remphys_errors;
755 u64 port_xmit_discards;
756 u64 port_xmit_data;
757 u64 port_rcv_data;
758 u64 port_xmit_packets;
759 u64 port_rcv_packets;
760 u32 local_link_integrity_errors;
761 u32 excessive_buffer_overrun_errors;
762 u32 vl15_dropped;
763};
764
765static inline struct qib_mr *to_imr(struct ib_mr *ibmr)
766{
767 return container_of(ibmr, struct qib_mr, ibmr);
768}
769
770static inline struct qib_pd *to_ipd(struct ib_pd *ibpd)
771{
772 return container_of(ibpd, struct qib_pd, ibpd);
773}
774
775static inline struct qib_ah *to_iah(struct ib_ah *ibah)
776{
777 return container_of(ibah, struct qib_ah, ibah);
778}
779
780static inline struct qib_cq *to_icq(struct ib_cq *ibcq)
781{
782 return container_of(ibcq, struct qib_cq, ibcq);
783}
784
785static inline struct qib_srq *to_isrq(struct ib_srq *ibsrq)
786{
787 return container_of(ibsrq, struct qib_srq, ibsrq);
788}
789
790static inline struct qib_qp *to_iqp(struct ib_qp *ibqp)
791{
792 return container_of(ibqp, struct qib_qp, ibqp);
793}
794
795static inline struct qib_ibdev *to_idev(struct ib_device *ibdev)
796{
797 return container_of(ibdev, struct qib_ibdev, ibdev);
798}
799
800
801
802
803
804static inline int qib_send_ok(struct qib_qp *qp)
805{
806 return !(qp->s_flags & (QIB_S_BUSY | QIB_S_ANY_WAIT_IO)) &&
807 (qp->s_hdrwords || (qp->s_flags & QIB_S_RESP_PENDING) ||
808 !(qp->s_flags & QIB_S_ANY_WAIT_SEND));
809}
810
811extern struct workqueue_struct *qib_cq_wq;
812
813
814
815
816static inline void qib_schedule_send(struct qib_qp *qp)
817{
818 if (qib_send_ok(qp))
819 queue_work(ib_wq, &qp->s_work);
820}
821
822static inline int qib_pkey_ok(u16 pkey1, u16 pkey2)
823{
824 u16 p1 = pkey1 & 0x7FFF;
825 u16 p2 = pkey2 & 0x7FFF;
826
827
828
829
830
831 return p1 && p1 == p2 && ((__s16)pkey1 < 0 || (__s16)pkey2 < 0);
832}
833
834void qib_bad_pqkey(struct qib_ibport *ibp, __be16 trap_num, u32 key, u32 sl,
835 u32 qp1, u32 qp2, __be16 lid1, __be16 lid2);
836void qib_cap_mask_chg(struct qib_ibport *ibp);
837void qib_sys_guid_chg(struct qib_ibport *ibp);
838void qib_node_desc_chg(struct qib_ibport *ibp);
839int qib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
840 struct ib_wc *in_wc, struct ib_grh *in_grh,
841 struct ib_mad *in_mad, struct ib_mad *out_mad);
842int qib_create_agents(struct qib_ibdev *dev);
843void qib_free_agents(struct qib_ibdev *dev);
844
845
846
847
848
849static inline int qib_cmp24(u32 a, u32 b)
850{
851 return (((int) a) - ((int) b)) << 8;
852}
853
854struct qib_mcast *qib_mcast_find(struct qib_ibport *ibp, union ib_gid *mgid);
855
856int qib_snapshot_counters(struct qib_pportdata *ppd, u64 *swords,
857 u64 *rwords, u64 *spkts, u64 *rpkts,
858 u64 *xmit_wait);
859
860int qib_get_counters(struct qib_pportdata *ppd,
861 struct qib_verbs_counters *cntrs);
862
863int qib_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
864
865int qib_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
866
867int qib_mcast_tree_empty(struct qib_ibport *ibp);
868
869__be32 qib_compute_aeth(struct qib_qp *qp);
870
871struct qib_qp *qib_lookup_qpn(struct qib_ibport *ibp, u32 qpn);
872
873struct ib_qp *qib_create_qp(struct ib_pd *ibpd,
874 struct ib_qp_init_attr *init_attr,
875 struct ib_udata *udata);
876
877int qib_destroy_qp(struct ib_qp *ibqp);
878
879int qib_error_qp(struct qib_qp *qp, enum ib_wc_status err);
880
881int qib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
882 int attr_mask, struct ib_udata *udata);
883
884int qib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
885 int attr_mask, struct ib_qp_init_attr *init_attr);
886
887unsigned qib_free_all_qps(struct qib_devdata *dd);
888
889void qib_init_qpn_table(struct qib_devdata *dd, struct qib_qpn_table *qpt);
890
891void qib_free_qpn_table(struct qib_qpn_table *qpt);
892
893void qib_get_credit(struct qib_qp *qp, u32 aeth);
894
895unsigned qib_pkt_delay(u32 plen, u8 snd_mult, u8 rcv_mult);
896
897void qib_verbs_sdma_desc_avail(struct qib_pportdata *ppd, unsigned avail);
898
899void qib_put_txreq(struct qib_verbs_txreq *tx);
900
901int qib_verbs_send(struct qib_qp *qp, struct qib_ib_header *hdr,
902 u32 hdrwords, struct qib_sge_state *ss, u32 len);
903
904void qib_copy_sge(struct qib_sge_state *ss, void *data, u32 length,
905 int release);
906
907void qib_skip_sge(struct qib_sge_state *ss, u32 length, int release);
908
909void qib_uc_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
910 int has_grh, void *data, u32 tlen, struct qib_qp *qp);
911
912void qib_rc_rcv(struct qib_ctxtdata *rcd, struct qib_ib_header *hdr,
913 int has_grh, void *data, u32 tlen, struct qib_qp *qp);
914
915int qib_check_ah(struct ib_device *ibdev, struct ib_ah_attr *ah_attr);
916
917void qib_rc_rnr_retry(unsigned long arg);
918
919void qib_rc_send_complete(struct qib_qp *qp, struct qib_ib_header *hdr);
920
921void qib_rc_error(struct qib_qp *qp, enum ib_wc_status err);
922
923int qib_post_ud_send(struct qib_qp *qp, struct ib_send_wr *wr);
924
925void qib_ud_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
926 int has_grh, void *data, u32 tlen, struct qib_qp *qp);
927
928int qib_alloc_lkey(struct qib_lkey_table *rkt, struct qib_mregion *mr);
929
930int qib_free_lkey(struct qib_ibdev *dev, struct qib_mregion *mr);
931
932int qib_lkey_ok(struct qib_lkey_table *rkt, struct qib_pd *pd,
933 struct qib_sge *isge, struct ib_sge *sge, int acc);
934
935int qib_rkey_ok(struct qib_qp *qp, struct qib_sge *sge,
936 u32 len, u64 vaddr, u32 rkey, int acc);
937
938int qib_post_srq_receive(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
939 struct ib_recv_wr **bad_wr);
940
941struct ib_srq *qib_create_srq(struct ib_pd *ibpd,
942 struct ib_srq_init_attr *srq_init_attr,
943 struct ib_udata *udata);
944
945int qib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
946 enum ib_srq_attr_mask attr_mask,
947 struct ib_udata *udata);
948
949int qib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr);
950
951int qib_destroy_srq(struct ib_srq *ibsrq);
952
953void qib_cq_enter(struct qib_cq *cq, struct ib_wc *entry, int sig);
954
955int qib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry);
956
957struct ib_cq *qib_create_cq(struct ib_device *ibdev, int entries,
958 int comp_vector, struct ib_ucontext *context,
959 struct ib_udata *udata);
960
961int qib_destroy_cq(struct ib_cq *ibcq);
962
963int qib_req_notify_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags notify_flags);
964
965int qib_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata);
966
967struct ib_mr *qib_get_dma_mr(struct ib_pd *pd, int acc);
968
969struct ib_mr *qib_reg_phys_mr(struct ib_pd *pd,
970 struct ib_phys_buf *buffer_list,
971 int num_phys_buf, int acc, u64 *iova_start);
972
973struct ib_mr *qib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
974 u64 virt_addr, int mr_access_flags,
975 struct ib_udata *udata);
976
977int qib_dereg_mr(struct ib_mr *ibmr);
978
979struct ib_mr *qib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len);
980
981struct ib_fast_reg_page_list *qib_alloc_fast_reg_page_list(
982 struct ib_device *ibdev, int page_list_len);
983
984void qib_free_fast_reg_page_list(struct ib_fast_reg_page_list *pl);
985
986int qib_fast_reg_mr(struct qib_qp *qp, struct ib_send_wr *wr);
987
988struct ib_fmr *qib_alloc_fmr(struct ib_pd *pd, int mr_access_flags,
989 struct ib_fmr_attr *fmr_attr);
990
991int qib_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
992 int list_len, u64 iova);
993
994int qib_unmap_fmr(struct list_head *fmr_list);
995
996int qib_dealloc_fmr(struct ib_fmr *ibfmr);
997
998void qib_release_mmap_info(struct kref *ref);
999
1000struct qib_mmap_info *qib_create_mmap_info(struct qib_ibdev *dev, u32 size,
1001 struct ib_ucontext *context,
1002 void *obj);
1003
1004void qib_update_mmap_info(struct qib_ibdev *dev, struct qib_mmap_info *ip,
1005 u32 size, void *obj);
1006
1007int qib_mmap(struct ib_ucontext *context, struct vm_area_struct *vma);
1008
1009int qib_get_rwqe(struct qib_qp *qp, int wr_id_only);
1010
1011void qib_migrate_qp(struct qib_qp *qp);
1012
1013int qib_ruc_check_hdr(struct qib_ibport *ibp, struct qib_ib_header *hdr,
1014 int has_grh, struct qib_qp *qp, u32 bth0);
1015
1016u32 qib_make_grh(struct qib_ibport *ibp, struct ib_grh *hdr,
1017 struct ib_global_route *grh, u32 hwords, u32 nwords);
1018
1019void qib_make_ruc_header(struct qib_qp *qp, struct qib_other_headers *ohdr,
1020 u32 bth0, u32 bth2);
1021
1022void qib_do_send(struct work_struct *work);
1023
1024void qib_send_complete(struct qib_qp *qp, struct qib_swqe *wqe,
1025 enum ib_wc_status status);
1026
1027void qib_send_rc_ack(struct qib_qp *qp);
1028
1029int qib_make_rc_req(struct qib_qp *qp);
1030
1031int qib_make_uc_req(struct qib_qp *qp);
1032
1033int qib_make_ud_req(struct qib_qp *qp);
1034
1035int qib_register_ib_device(struct qib_devdata *);
1036
1037void qib_unregister_ib_device(struct qib_devdata *);
1038
1039void qib_ib_rcv(struct qib_ctxtdata *, void *, void *, u32);
1040
1041void qib_ib_piobufavail(struct qib_devdata *);
1042
1043unsigned qib_get_npkeys(struct qib_devdata *);
1044
1045unsigned qib_get_pkey(struct qib_ibport *, unsigned);
1046
1047extern const enum ib_wc_opcode ib_qib_wc_opcode[];
1048
1049
1050
1051
1052
1053#define IB_PHYSPORTSTATE_SLEEP 1
1054#define IB_PHYSPORTSTATE_POLL 2
1055#define IB_PHYSPORTSTATE_DISABLED 3
1056#define IB_PHYSPORTSTATE_CFG_TRAIN 4
1057#define IB_PHYSPORTSTATE_LINKUP 5
1058#define IB_PHYSPORTSTATE_LINK_ERR_RECOVER 6
1059#define IB_PHYSPORTSTATE_CFG_DEBOUNCE 8
1060#define IB_PHYSPORTSTATE_CFG_IDLE 0xB
1061#define IB_PHYSPORTSTATE_RECOVERY_RETRAIN 0xC
1062#define IB_PHYSPORTSTATE_RECOVERY_WAITRMT 0xE
1063#define IB_PHYSPORTSTATE_RECOVERY_IDLE 0xF
1064#define IB_PHYSPORTSTATE_CFG_ENH 0x10
1065#define IB_PHYSPORTSTATE_CFG_WAIT_ENH 0x13
1066
1067extern const int ib_qib_state_ops[];
1068
1069extern __be64 ib_qib_sys_image_guid;
1070
1071extern unsigned int ib_qib_lkey_table_size;
1072
1073extern unsigned int ib_qib_max_cqes;
1074
1075extern unsigned int ib_qib_max_cqs;
1076
1077extern unsigned int ib_qib_max_qp_wrs;
1078
1079extern unsigned int ib_qib_max_qps;
1080
1081extern unsigned int ib_qib_max_sges;
1082
1083extern unsigned int ib_qib_max_mcast_grps;
1084
1085extern unsigned int ib_qib_max_mcast_qp_attached;
1086
1087extern unsigned int ib_qib_max_srqs;
1088
1089extern unsigned int ib_qib_max_srq_sges;
1090
1091extern unsigned int ib_qib_max_srq_wrs;
1092
1093extern const u32 ib_qib_rnr_table[];
1094
1095extern struct ib_dma_mapping_ops qib_dma_mapping_ops;
1096
1097#endif
1098