1f931551bSRalph Campbell /*
25da0fc9dSDennis Dalessandro  * Copyright (c) 2012 - 2018 Intel Corporation.  All rights reserved.
31fb9fed6SMike Marciniszyn  * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved.
4f931551bSRalph Campbell  * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
5f931551bSRalph Campbell  *
6f931551bSRalph Campbell  * This software is available to you under a choice of one of two
7f931551bSRalph Campbell  * licenses.  You may choose to be licensed under the terms of the GNU
8f931551bSRalph Campbell  * General Public License (GPL) Version 2, available from the file
9f931551bSRalph Campbell  * COPYING in the main directory of this source tree, or the
10f931551bSRalph Campbell  * OpenIB.org BSD license below:
11f931551bSRalph Campbell  *
12f931551bSRalph Campbell  *     Redistribution and use in source and binary forms, with or
13f931551bSRalph Campbell  *     without modification, are permitted provided that the following
14f931551bSRalph Campbell  *     conditions are met:
15f931551bSRalph Campbell  *
16f931551bSRalph Campbell  *      - Redistributions of source code must retain the above
17f931551bSRalph Campbell  *        copyright notice, this list of conditions and the following
18f931551bSRalph Campbell  *        disclaimer.
19f931551bSRalph Campbell  *
20f931551bSRalph Campbell  *      - Redistributions in binary form must reproduce the above
21f931551bSRalph Campbell  *        copyright notice, this list of conditions and the following
22f931551bSRalph Campbell  *        disclaimer in the documentation and/or other materials
23f931551bSRalph Campbell  *        provided with the distribution.
24f931551bSRalph Campbell  *
25f931551bSRalph Campbell  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26f931551bSRalph Campbell  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27f931551bSRalph Campbell  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28f931551bSRalph Campbell  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29f931551bSRalph Campbell  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30f931551bSRalph Campbell  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31f931551bSRalph Campbell  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32f931551bSRalph Campbell  * SOFTWARE.
33f931551bSRalph Campbell  */
34f931551bSRalph Campbell 
35f931551bSRalph Campbell #ifndef QIB_VERBS_H
36f931551bSRalph Campbell #define QIB_VERBS_H
37f931551bSRalph Campbell 
38f931551bSRalph Campbell #include <linux/types.h>
39f931551bSRalph Campbell #include <linux/spinlock.h>
40f931551bSRalph Campbell #include <linux/kernel.h>
41f931551bSRalph Campbell #include <linux/interrupt.h>
42f931551bSRalph Campbell #include <linux/kref.h>
43f931551bSRalph Campbell #include <linux/workqueue.h>
4485caafe3SMike Marciniszyn #include <linux/kthread.h>
456a82649fSMike Marciniszyn #include <linux/completion.h>
46f931551bSRalph Campbell #include <rdma/ib_pack.h>
47f931551bSRalph Campbell #include <rdma/ib_user_verbs.h>
48261a4351SMike Marciniszyn #include <rdma/ib_hdrs.h>
49715ab1a8SMike Marciniszyn #include <rdma/rdmavt_qp.h>
504bb88e5fSHarish Chegondi #include <rdma/rdmavt_cq.h>
51f931551bSRalph Campbell 
52f931551bSRalph Campbell struct qib_ctxtdata;
53f931551bSRalph Campbell struct qib_pportdata;
54f931551bSRalph Campbell struct qib_devdata;
55f931551bSRalph Campbell struct qib_verbs_txreq;
56f931551bSRalph Campbell 
57f931551bSRalph Campbell #define QIB_MAX_RDMA_ATOMIC     16
58f931551bSRalph Campbell #define QIB_GUIDS_PER_PORT	5
5970696ea7SHarish Chegondi #define QIB_PSN_SHIFT		8
60f931551bSRalph Campbell 
61f931551bSRalph Campbell /*
62f931551bSRalph Campbell  * Increment this value if any changes that break userspace ABI
63f931551bSRalph Campbell  * compatibility are made.
64f931551bSRalph Campbell  */
65f931551bSRalph Campbell #define QIB_UVERBS_ABI_VERSION       2
66f931551bSRalph Campbell 
67f931551bSRalph Campbell /* IB Performance Manager status values */
68f931551bSRalph Campbell #define IB_PMA_SAMPLE_STATUS_DONE       0x00
69f931551bSRalph Campbell #define IB_PMA_SAMPLE_STATUS_STARTED    0x01
70f931551bSRalph Campbell #define IB_PMA_SAMPLE_STATUS_RUNNING    0x02
71f931551bSRalph Campbell 
72f931551bSRalph Campbell /* Mandatory IB performance counter select values. */
73f931551bSRalph Campbell #define IB_PMA_PORT_XMIT_DATA   cpu_to_be16(0x0001)
74f931551bSRalph Campbell #define IB_PMA_PORT_RCV_DATA    cpu_to_be16(0x0002)
75f931551bSRalph Campbell #define IB_PMA_PORT_XMIT_PKTS   cpu_to_be16(0x0003)
76f931551bSRalph Campbell #define IB_PMA_PORT_RCV_PKTS    cpu_to_be16(0x0004)
77f931551bSRalph Campbell #define IB_PMA_PORT_XMIT_WAIT   cpu_to_be16(0x0005)
78f931551bSRalph Campbell 
79f931551bSRalph Campbell #define QIB_VENDOR_IPG		cpu_to_be16(0xFFA0)
80f931551bSRalph Campbell 
81f931551bSRalph Campbell #define IB_DEFAULT_GID_PREFIX	cpu_to_be64(0xfe80000000000000ULL)
82f931551bSRalph Campbell 
83f931551bSRalph Campbell /* Values for set/get portinfo VLCap OperationalVLs */
84f931551bSRalph Campbell #define IB_VL_VL0       1
85f931551bSRalph Campbell #define IB_VL_VL0_1     2
86f931551bSRalph Campbell #define IB_VL_VL0_3     3
87f931551bSRalph Campbell #define IB_VL_VL0_7     4
88f931551bSRalph Campbell #define IB_VL_VL0_14    5
89f931551bSRalph Campbell 
qib_num_vls(int vls)90f931551bSRalph Campbell static inline int qib_num_vls(int vls)
91f931551bSRalph Campbell {
92f931551bSRalph Campbell 	switch (vls) {
93f931551bSRalph Campbell 	default:
94f931551bSRalph Campbell 	case IB_VL_VL0:
95f931551bSRalph Campbell 		return 1;
96f931551bSRalph Campbell 	case IB_VL_VL0_1:
97f931551bSRalph Campbell 		return 2;
98f931551bSRalph Campbell 	case IB_VL_VL0_3:
99f931551bSRalph Campbell 		return 4;
100f931551bSRalph Campbell 	case IB_VL_VL0_7:
101f931551bSRalph Campbell 		return 8;
102f931551bSRalph Campbell 	case IB_VL_VL0_14:
103f931551bSRalph Campbell 		return 15;
104f931551bSRalph Campbell 	}
105f931551bSRalph Campbell }
106f931551bSRalph Campbell 
107f931551bSRalph Campbell struct qib_pio_header {
108f931551bSRalph Campbell 	__le32 pbc[2];
109261a4351SMike Marciniszyn 	struct ib_header hdr;
11078a58864SMike Marciniszyn } __packed;
111f931551bSRalph Campbell 
112f931551bSRalph Campbell /*
113ffc26907SDennis Dalessandro  * qib specific data structure that will be hidden from rvt after the queue pair
114ffc26907SDennis Dalessandro  * is made common.
115ffc26907SDennis Dalessandro  */
116ffc26907SDennis Dalessandro struct qib_qp_priv {
117261a4351SMike Marciniszyn 	struct ib_header *s_hdr;        /* next packet header to send */
118ffc26907SDennis Dalessandro 	struct list_head iowait;        /* link for wait PIO buf */
119ffc26907SDennis Dalessandro 	atomic_t s_dma_busy;
120ffc26907SDennis Dalessandro 	struct qib_verbs_txreq *s_tx;
121ffc26907SDennis Dalessandro 	struct work_struct s_work;
122ffc26907SDennis Dalessandro 	wait_queue_head_t wait_dma;
1237c2e11feSDennis Dalessandro 	struct rvt_qp *owner;
124f931551bSRalph Campbell };
125f931551bSRalph Campbell 
126f931551bSRalph Campbell #define QIB_PSN_CREDIT  16
127f931551bSRalph Campbell 
128f931551bSRalph Campbell struct qib_opcode_stats {
129f931551bSRalph Campbell 	u64 n_packets;          /* number of packets */
130f931551bSRalph Campbell 	u64 n_bytes;            /* total number of bytes */
131f931551bSRalph Campbell };
132f931551bSRalph Campbell 
133ddb88765SMike Marciniszyn struct qib_opcode_stats_perctx {
134ddb88765SMike Marciniszyn 	struct qib_opcode_stats stats[128];
135ddb88765SMike Marciniszyn };
136ddb88765SMike Marciniszyn 
1377d7632adSMike Marciniszyn struct qib_pma_counters {
1387d7632adSMike Marciniszyn 	u64 n_unicast_xmit;     /* total unicast packets sent */
1397d7632adSMike Marciniszyn 	u64 n_unicast_rcv;      /* total unicast packets received */
1407d7632adSMike Marciniszyn 	u64 n_multicast_xmit;   /* total multicast packets sent */
1417d7632adSMike Marciniszyn 	u64 n_multicast_rcv;    /* total multicast packets received */
1427d7632adSMike Marciniszyn };
1437d7632adSMike Marciniszyn 
144f931551bSRalph Campbell struct qib_ibport {
145f24a6d48SHarish Chegondi 	struct rvt_ibport rvp;
1464eadd8ffSDennis Dalessandro 	struct rvt_ah *smi_ah;
147f931551bSRalph Campbell 	__be64 guids[QIB_GUIDS_PER_PORT	- 1];	/* writable GUIDs */
1487d7632adSMike Marciniszyn 	struct qib_pma_counters __percpu *pmastats;
1497d7632adSMike Marciniszyn 	u64 z_unicast_xmit;     /* starting count for PMA */
1507d7632adSMike Marciniszyn 	u64 z_unicast_rcv;      /* starting count for PMA */
1517d7632adSMike Marciniszyn 	u64 z_multicast_xmit;   /* starting count for PMA */
1527d7632adSMike Marciniszyn 	u64 z_multicast_rcv;    /* starting count for PMA */
153f931551bSRalph Campbell 	u64 z_symbol_error_counter;             /* starting count for PMA */
154f931551bSRalph Campbell 	u64 z_link_error_recovery_counter;      /* starting count for PMA */
155f931551bSRalph Campbell 	u64 z_link_downed_counter;              /* starting count for PMA */
156f931551bSRalph Campbell 	u64 z_port_rcv_errors;                  /* starting count for PMA */
157f931551bSRalph Campbell 	u64 z_port_rcv_remphys_errors;          /* starting count for PMA */
158f931551bSRalph Campbell 	u64 z_port_xmit_discards;               /* starting count for PMA */
159f931551bSRalph Campbell 	u64 z_port_xmit_data;                   /* starting count for PMA */
160f931551bSRalph Campbell 	u64 z_port_rcv_data;                    /* starting count for PMA */
161f931551bSRalph Campbell 	u64 z_port_xmit_packets;                /* starting count for PMA */
162f931551bSRalph Campbell 	u64 z_port_rcv_packets;                 /* starting count for PMA */
163f931551bSRalph Campbell 	u32 z_local_link_integrity_errors;      /* starting count for PMA */
164f931551bSRalph Campbell 	u32 z_excessive_buffer_overrun_errors;  /* starting count for PMA */
165f931551bSRalph Campbell 	u32 z_vl15_dropped;                     /* starting count for PMA */
166f931551bSRalph Campbell 	u8 sl_to_vl[16];
167f931551bSRalph Campbell };
168f931551bSRalph Campbell 
169f931551bSRalph Campbell struct qib_ibdev {
1702dc05ab5SDennis Dalessandro 	struct rvt_dev_info rdi;
171f931551bSRalph Campbell 
172f931551bSRalph Campbell 	struct list_head piowait;       /* list for wait PIO buf */
173f931551bSRalph Campbell 	struct list_head dmawait;	/* list for wait DMA */
174f931551bSRalph Campbell 	struct list_head txwait;        /* list for wait qib_verbs_txreq */
175f931551bSRalph Campbell 	struct list_head memwait;       /* list for wait kernel memory */
176f931551bSRalph Campbell 	struct list_head txreq_free;
177f931551bSRalph Campbell 	struct timer_list mem_timer;
178f931551bSRalph Campbell 	struct qib_pio_header *pio_hdrs;
179f931551bSRalph Campbell 	dma_addr_t pio_hdrs_phys;
180f931551bSRalph Campbell 
181f931551bSRalph Campbell 	u32 n_piowait;
182f931551bSRalph Campbell 	u32 n_txwait;
183f931551bSRalph Campbell 
184ddb88765SMike Marciniszyn #ifdef CONFIG_DEBUG_FS
185ddb88765SMike Marciniszyn 	/* per HCA debugfs */
186ddb88765SMike Marciniszyn 	struct dentry *qib_ibdev_dbg;
187ddb88765SMike Marciniszyn #endif
188f931551bSRalph Campbell };
189f931551bSRalph Campbell 
190f931551bSRalph Campbell struct qib_verbs_counters {
191f931551bSRalph Campbell 	u64 symbol_error_counter;
192f931551bSRalph Campbell 	u64 link_error_recovery_counter;
193f931551bSRalph Campbell 	u64 link_downed_counter;
194f931551bSRalph Campbell 	u64 port_rcv_errors;
195f931551bSRalph Campbell 	u64 port_rcv_remphys_errors;
196f931551bSRalph Campbell 	u64 port_xmit_discards;
197f931551bSRalph Campbell 	u64 port_xmit_data;
198f931551bSRalph Campbell 	u64 port_rcv_data;
199f931551bSRalph Campbell 	u64 port_xmit_packets;
200f931551bSRalph Campbell 	u64 port_rcv_packets;
201f931551bSRalph Campbell 	u32 local_link_integrity_errors;
202f931551bSRalph Campbell 	u32 excessive_buffer_overrun_errors;
203f931551bSRalph Campbell 	u32 vl15_dropped;
204f931551bSRalph Campbell };
205f931551bSRalph Campbell 
to_idev(struct ib_device * ibdev)206f931551bSRalph Campbell static inline struct qib_ibdev *to_idev(struct ib_device *ibdev)
207f931551bSRalph Campbell {
2082dc05ab5SDennis Dalessandro 	struct rvt_dev_info *rdi;
2092dc05ab5SDennis Dalessandro 
2102dc05ab5SDennis Dalessandro 	rdi = container_of(ibdev, struct rvt_dev_info, ibdev);
2112dc05ab5SDennis Dalessandro 	return container_of(rdi, struct qib_ibdev, rdi);
212f931551bSRalph Campbell }
213f931551bSRalph Campbell 
214f931551bSRalph Campbell /*
215f931551bSRalph Campbell  * Send if not busy or waiting for I/O and either
216f931551bSRalph Campbell  * a RC response is pending or we can process send work requests.
217f931551bSRalph Campbell  */
qib_send_ok(struct rvt_qp * qp)2187c2e11feSDennis Dalessandro static inline int qib_send_ok(struct rvt_qp *qp)
219f931551bSRalph Campbell {
22001ba79d4SHarish Chegondi 	return !(qp->s_flags & (RVT_S_BUSY | RVT_S_ANY_WAIT_IO)) &&
22101ba79d4SHarish Chegondi 		(qp->s_hdrwords || (qp->s_flags & RVT_S_RESP_PENDING) ||
22201ba79d4SHarish Chegondi 		 !(qp->s_flags & RVT_S_ANY_WAIT_SEND));
223f931551bSRalph Campbell }
224f931551bSRalph Campbell 
2255da0fc9dSDennis Dalessandro bool _qib_schedule_send(struct rvt_qp *qp);
2265da0fc9dSDennis Dalessandro bool qib_schedule_send(struct rvt_qp *qp);
227f931551bSRalph Campbell 
qib_pkey_ok(u16 pkey1,u16 pkey2)228f931551bSRalph Campbell static inline int qib_pkey_ok(u16 pkey1, u16 pkey2)
229f931551bSRalph Campbell {
230f931551bSRalph Campbell 	u16 p1 = pkey1 & 0x7FFF;
231f931551bSRalph Campbell 	u16 p2 = pkey2 & 0x7FFF;
232f931551bSRalph Campbell 
233f931551bSRalph Campbell 	/*
234f931551bSRalph Campbell 	 * Low 15 bits must be non-zero and match, and
235f931551bSRalph Campbell 	 * one of the two must be a full member.
236f931551bSRalph Campbell 	 */
237f931551bSRalph Campbell 	return p1 && p1 == p2 && ((__s16)pkey1 < 0 || (__s16)pkey2 < 0);
238f931551bSRalph Campbell }
239f931551bSRalph Campbell 
24013d84914SDennis Dalessandro void qib_bad_pkey(struct qib_ibport *ibp, u32 key, u32 sl,
241f931551bSRalph Campbell 		  u32 qp1, u32 qp2, __be16 lid1, __be16 lid2);
242*1fb7f897SMark Bloch void qib_cap_mask_chg(struct rvt_dev_info *rdi, u32 port_num);
243f931551bSRalph Campbell void qib_sys_guid_chg(struct qib_ibport *ibp);
244f931551bSRalph Campbell void qib_node_desc_chg(struct qib_ibport *ibp);
245*1fb7f897SMark Bloch int qib_process_mad(struct ib_device *ibdev, int mad_flags, u32 port_num,
246a97e2d86SIra Weiny 		    const struct ib_wc *in_wc, const struct ib_grh *in_grh,
247e26e7b88SLeon Romanovsky 		    const struct ib_mad *in, struct ib_mad *out,
248e26e7b88SLeon Romanovsky 		    size_t *out_mad_size, u16 *out_mad_pkey_index);
2495196aa96SDennis Dalessandro void qib_notify_create_mad_agent(struct rvt_dev_info *rdi, int port_idx);
2505196aa96SDennis Dalessandro void qib_notify_free_mad_agent(struct rvt_dev_info *rdi, int port_idx);
251f931551bSRalph Campbell 
252f931551bSRalph Campbell /*
253f931551bSRalph Campbell  * Compare the lower 24 bits of the two values.
254f931551bSRalph Campbell  * Returns an integer <, ==, or > than zero.
255f931551bSRalph Campbell  */
qib_cmp24(u32 a,u32 b)256f931551bSRalph Campbell static inline int qib_cmp24(u32 a, u32 b)
257f931551bSRalph Campbell {
258f931551bSRalph Campbell 	return (((int) a) - ((int) b)) << 8;
259f931551bSRalph Campbell }
260f931551bSRalph Campbell 
261f931551bSRalph Campbell int qib_snapshot_counters(struct qib_pportdata *ppd, u64 *swords,
262f931551bSRalph Campbell 			  u64 *rwords, u64 *spkts, u64 *rpkts,
263f931551bSRalph Campbell 			  u64 *xmit_wait);
264f931551bSRalph Campbell 
265f931551bSRalph Campbell int qib_get_counters(struct qib_pportdata *ppd,
266f931551bSRalph Campbell 		     struct qib_verbs_counters *cntrs);
267f931551bSRalph Campbell 
26847c7ea6dSHarish Chegondi /*
26947c7ea6dSHarish Chegondi  * Functions provided by qib driver for rdmavt to use
27047c7ea6dSHarish Chegondi  */
27147c7ea6dSHarish Chegondi unsigned qib_free_all_qps(struct rvt_dev_info *rdi);
2720f4d027cSLeon Romanovsky void *qib_qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp);
27320f333b6SHarish Chegondi void qib_qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp);
27420f333b6SHarish Chegondi void qib_notify_qp_reset(struct rvt_qp *qp);
27520f333b6SHarish Chegondi int qib_alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
276*1fb7f897SMark Bloch 		  enum ib_qp_type type, u32 port);
277b4238e70SVenkata Sandeep Dhanalakota void qib_restart_rc(struct rvt_qp *qp, u32 psn, int wait);
2781dd173b0SMike Marciniszyn #ifdef CONFIG_DEBUG_FS
2791dd173b0SMike Marciniszyn 
280557fafe1SMike Marciniszyn void qib_qp_iter_print(struct seq_file *s, struct rvt_qp_iter *iter);
2811dd173b0SMike Marciniszyn 
2821dd173b0SMike Marciniszyn #endif
2831dd173b0SMike Marciniszyn 
284f931551bSRalph Campbell unsigned qib_pkt_delay(u32 plen, u8 snd_mult, u8 rcv_mult);
285f931551bSRalph Campbell 
286f931551bSRalph Campbell void qib_verbs_sdma_desc_avail(struct qib_pportdata *ppd, unsigned avail);
287f931551bSRalph Campbell 
288f931551bSRalph Campbell void qib_put_txreq(struct qib_verbs_txreq *tx);
289f931551bSRalph Campbell 
290261a4351SMike Marciniszyn int qib_verbs_send(struct rvt_qp *qp, struct ib_header *hdr,
2917c2e11feSDennis Dalessandro 		   u32 hdrwords, struct rvt_sge_state *ss, u32 len);
292f931551bSRalph Campbell 
293261a4351SMike Marciniszyn void qib_uc_rcv(struct qib_ibport *ibp, struct ib_header *hdr,
2947c2e11feSDennis Dalessandro 		int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
295f931551bSRalph Campbell 
296261a4351SMike Marciniszyn void qib_rc_rcv(struct qib_ctxtdata *rcd, struct ib_header *hdr,
2977c2e11feSDennis Dalessandro 		int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
298f931551bSRalph Campbell 
29990898850SDasaratharaman Chandramouli int qib_check_ah(struct ib_device *ibdev, struct rdma_ah_attr *ah_attr);
300f931551bSRalph Campbell 
3010b79b277SMichael J. Ruhl int qib_check_send_wqe(struct rvt_qp *qp, struct rvt_swqe *wqe,
3020b79b277SMichael J. Ruhl 		       bool *call_send);
30346a80d62SMike Marciniszyn 
3041fb9fed6SMike Marciniszyn struct ib_ah *qib_create_qp0_ah(struct qib_ibport *ibp, u16 dlid);
3051fb9fed6SMike Marciniszyn 
306f931551bSRalph Campbell void qib_rc_rnr_retry(unsigned long arg);
307f931551bSRalph Campbell 
308261a4351SMike Marciniszyn void qib_rc_send_complete(struct rvt_qp *qp, struct ib_header *hdr);
309f931551bSRalph Campbell 
310f696bf6dSBart Van Assche int qib_post_ud_send(struct rvt_qp *qp, const struct ib_send_wr *wr);
311f931551bSRalph Campbell 
312261a4351SMike Marciniszyn void qib_ud_rcv(struct qib_ibport *ibp, struct ib_header *hdr,
3137c2e11feSDennis Dalessandro 		int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
314f931551bSRalph Campbell 
3158aac4cc3SMike Marciniszyn void mr_rcu_callback(struct rcu_head *list);
3168aac4cc3SMike Marciniszyn 
3177c2e11feSDennis Dalessandro void qib_migrate_qp(struct rvt_qp *qp);
318f931551bSRalph Campbell 
319261a4351SMike Marciniszyn int qib_ruc_check_hdr(struct qib_ibport *ibp, struct ib_header *hdr,
3207c2e11feSDennis Dalessandro 		      int has_grh, struct rvt_qp *qp, u32 bth0);
321f931551bSRalph Campbell 
322f931551bSRalph Campbell u32 qib_make_grh(struct qib_ibport *ibp, struct ib_grh *hdr,
323d8966fcdSDasaratharaman Chandramouli 		 const struct ib_global_route *grh, u32 hwords, u32 nwords);
324f931551bSRalph Campbell 
325261a4351SMike Marciniszyn void qib_make_ruc_header(struct rvt_qp *qp, struct ib_other_headers *ohdr,
326f931551bSRalph Campbell 			 u32 bth0, u32 bth2);
327f931551bSRalph Campbell 
328db3ef0ebSHarish Chegondi void _qib_do_send(struct work_struct *work);
329db3ef0ebSHarish Chegondi 
330db3ef0ebSHarish Chegondi void qib_do_send(struct rvt_qp *qp);
331f931551bSRalph Campbell 
3327c2e11feSDennis Dalessandro void qib_send_rc_ack(struct rvt_qp *qp);
333f931551bSRalph Campbell 
334747f4d7aSMike Marciniszyn int qib_make_rc_req(struct rvt_qp *qp, unsigned long *flags);
335f931551bSRalph Campbell 
336747f4d7aSMike Marciniszyn int qib_make_uc_req(struct rvt_qp *qp, unsigned long *flags);
337f931551bSRalph Campbell 
338747f4d7aSMike Marciniszyn int qib_make_ud_req(struct rvt_qp *qp, unsigned long *flags);
339f931551bSRalph Campbell 
340f931551bSRalph Campbell int qib_register_ib_device(struct qib_devdata *);
341f931551bSRalph Campbell 
342f931551bSRalph Campbell void qib_unregister_ib_device(struct qib_devdata *);
343f931551bSRalph Campbell 
344f931551bSRalph Campbell void qib_ib_rcv(struct qib_ctxtdata *, void *, void *, u32);
345f931551bSRalph Campbell 
346f931551bSRalph Campbell void qib_ib_piobufavail(struct qib_devdata *);
347f931551bSRalph Campbell 
348f931551bSRalph Campbell unsigned qib_get_npkeys(struct qib_devdata *);
349f931551bSRalph Campbell 
350f931551bSRalph Campbell unsigned qib_get_pkey(struct qib_ibport *, unsigned);
351f931551bSRalph Campbell 
352f931551bSRalph Campbell extern const enum ib_wc_opcode ib_qib_wc_opcode[];
353f931551bSRalph Campbell 
354f931551bSRalph Campbell /*
355f931551bSRalph Campbell  * Below  HCA-independent IB PhysPortState values, returned
356f931551bSRalph Campbell  * by the f_ibphys_portstate() routine.
357f931551bSRalph Campbell  */
358f931551bSRalph Campbell #define IB_PHYSPORTSTATE_SLEEP 1
359f931551bSRalph Campbell #define IB_PHYSPORTSTATE_POLL 2
360f931551bSRalph Campbell #define IB_PHYSPORTSTATE_DISABLED 3
361f931551bSRalph Campbell #define IB_PHYSPORTSTATE_CFG_TRAIN 4
362f931551bSRalph Campbell #define IB_PHYSPORTSTATE_LINKUP 5
363f931551bSRalph Campbell #define IB_PHYSPORTSTATE_LINK_ERR_RECOVER 6
364f931551bSRalph Campbell #define IB_PHYSPORTSTATE_CFG_DEBOUNCE 8
365f931551bSRalph Campbell #define IB_PHYSPORTSTATE_CFG_IDLE 0xB
366f931551bSRalph Campbell #define IB_PHYSPORTSTATE_RECOVERY_RETRAIN 0xC
367f931551bSRalph Campbell #define IB_PHYSPORTSTATE_RECOVERY_WAITRMT 0xE
368f931551bSRalph Campbell #define IB_PHYSPORTSTATE_RECOVERY_IDLE 0xF
369f931551bSRalph Campbell #define IB_PHYSPORTSTATE_CFG_ENH 0x10
370f931551bSRalph Campbell #define IB_PHYSPORTSTATE_CFG_WAIT_ENH 0x13
371f931551bSRalph Campbell 
372db3ef0ebSHarish Chegondi extern const int ib_rvt_state_ops[];
373f931551bSRalph Campbell 
374f931551bSRalph Campbell extern __be64 ib_qib_sys_image_guid;    /* in network order */
375f931551bSRalph Campbell 
3767c2e11feSDennis Dalessandro extern unsigned int ib_rvt_lkey_table_size;
377f931551bSRalph Campbell 
378f931551bSRalph Campbell extern unsigned int ib_qib_max_cqes;
379f931551bSRalph Campbell 
380f931551bSRalph Campbell extern unsigned int ib_qib_max_cqs;
381f931551bSRalph Campbell 
382f931551bSRalph Campbell extern unsigned int ib_qib_max_qp_wrs;
383f931551bSRalph Campbell 
384f931551bSRalph Campbell extern unsigned int ib_qib_max_qps;
385f931551bSRalph Campbell 
386f931551bSRalph Campbell extern unsigned int ib_qib_max_sges;
387f931551bSRalph Campbell 
388f931551bSRalph Campbell extern unsigned int ib_qib_max_mcast_grps;
389f931551bSRalph Campbell 
390f931551bSRalph Campbell extern unsigned int ib_qib_max_mcast_qp_attached;
391f931551bSRalph Campbell 
392f931551bSRalph Campbell extern unsigned int ib_qib_max_srqs;
393f931551bSRalph Campbell 
394f931551bSRalph Campbell extern unsigned int ib_qib_max_srq_sges;
395f931551bSRalph Campbell 
396f931551bSRalph Campbell extern unsigned int ib_qib_max_srq_wrs;
397f931551bSRalph Campbell 
398f931551bSRalph Campbell extern const u32 ib_qib_rnr_table[];
399f931551bSRalph Campbell 
4009ec4faa3SMike Marciniszyn extern const struct rvt_operation_params qib_post_parms[];
4019ec4faa3SMike Marciniszyn 
402f931551bSRalph Campbell #endif                          /* QIB_VERBS_H */
403