blob: 38565532d6542e674c4f9302163d3896d7db16c5 [file] [log] [blame]
Cai Huoqing145eba12021-08-23 12:26:22 +08001/* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
Mike Marciniszyn77241052015-07-30 15:17:43 -04002/*
Mitko Haralanova74d5302018-05-02 06:43:24 -07003 * Copyright(c) 2015 - 2018 Intel Corporation.
Mike Marciniszyn77241052015-07-30 15:17:43 -04004 */
5
6#ifndef HFI1_VERBS_H
7#define HFI1_VERBS_H
8
9#include <linux/types.h>
10#include <linux/seqlock.h>
11#include <linux/kernel.h>
12#include <linux/interrupt.h>
13#include <linux/kref.h>
14#include <linux/workqueue.h>
15#include <linux/kthread.h>
16#include <linux/completion.h>
Dennis Dalessandrobb5df5f2016-02-14 12:44:43 -080017#include <linux/slab.h>
Mike Marciniszyn77241052015-07-30 15:17:43 -040018#include <rdma/ib_pack.h>
19#include <rdma/ib_user_verbs.h>
20#include <rdma/ib_mad.h>
Mike Marciniszyn261a4352016-09-06 04:35:05 -070021#include <rdma/ib_hdrs.h>
Dennis Dalessandroec3f2c12016-01-19 14:41:33 -080022#include <rdma/rdma_vt.h>
Dennis Dalessandro54d10c12016-01-19 14:43:01 -080023#include <rdma/rdmavt_qp.h>
Dennis Dalessandroabd712d2016-01-19 14:43:22 -080024#include <rdma/rdmavt_cq.h>
Mike Marciniszyn77241052015-07-30 15:17:43 -040025
26struct hfi1_ctxtdata;
27struct hfi1_pportdata;
28struct hfi1_devdata;
29struct hfi1_packet;
30
31#include "iowait.h"
Mike Marciniszyn5190f052018-11-28 10:22:31 -080032#include "tid_rdma.h"
Mitko Haralanov44e43d92019-01-24 06:09:46 -080033#include "opfn.h"
Mike Marciniszyn77241052015-07-30 15:17:43 -040034
35#define HFI1_MAX_RDMA_ATOMIC 16
Mike Marciniszyn77241052015-07-30 15:17:43 -040036
37/*
38 * Increment this value if any changes that break userspace ABI
39 * compatibility are made.
40 */
41#define HFI1_UVERBS_ABI_VERSION 2
42
Mike Marciniszyn77241052015-07-30 15:17:43 -040043/* IB Performance Manager status values */
44#define IB_PMA_SAMPLE_STATUS_DONE 0x00
45#define IB_PMA_SAMPLE_STATUS_STARTED 0x01
46#define IB_PMA_SAMPLE_STATUS_RUNNING 0x02
47
48/* Mandatory IB performance counter select values. */
49#define IB_PMA_PORT_XMIT_DATA cpu_to_be16(0x0001)
50#define IB_PMA_PORT_RCV_DATA cpu_to_be16(0x0002)
51#define IB_PMA_PORT_XMIT_PKTS cpu_to_be16(0x0003)
52#define IB_PMA_PORT_RCV_PKTS cpu_to_be16(0x0004)
53#define IB_PMA_PORT_XMIT_WAIT cpu_to_be16(0x0005)
54
55#define HFI1_VENDOR_IPG cpu_to_be16(0xFFA0)
56
Mike Marciniszyn77241052015-07-30 15:17:43 -040057#define IB_DEFAULT_GID_PREFIX cpu_to_be64(0xfe80000000000000ULL)
Don Hiatt5786adf32017-08-04 13:54:10 -070058#define OPA_BTH_MIG_REQ BIT(31)
Mike Marciniszyn77241052015-07-30 15:17:43 -040059
Mike Marciniszynb374e062016-09-25 07:40:58 -070060#define RC_OP(x) IB_OPCODE_RC_##x
61#define UC_OP(x) IB_OPCODE_UC_##x
62
Mike Marciniszyn77241052015-07-30 15:17:43 -040063/* flags passed by hfi1_ib_rcv() */
64enum {
65 HFI1_HAS_GRH = (1 << 0),
66};
67
Pankaj Bharadiyac5936422019-12-09 10:31:43 -080068#define LRH_16B_BYTES (sizeof_field(struct hfi1_16b_header, lrh))
Mike Marciniszyn78d36332018-02-01 10:52:35 -080069#define LRH_16B_DWORDS (LRH_16B_BYTES / sizeof(u32))
Pankaj Bharadiyac5936422019-12-09 10:31:43 -080070#define LRH_9B_BYTES (sizeof_field(struct ib_header, lrh))
Mike Marciniszyn78d36332018-02-01 10:52:35 -080071#define LRH_9B_DWORDS (LRH_9B_BYTES / sizeof(u32))
72
Don Hiatt4171a692018-05-15 18:28:07 -070073/* 24Bits for qpn, upper 8Bits reserved */
74struct opa_16b_mgmt {
75 __be32 dest_qpn;
76 __be32 src_qpn;
77};
78
Don Hiatt72c07e22017-08-04 13:53:58 -070079struct hfi1_16b_header {
80 u32 lrh[4];
81 union {
82 struct {
83 struct ib_grh grh;
84 struct ib_other_headers oth;
85 } l;
86 struct ib_other_headers oth;
Don Hiatt4171a692018-05-15 18:28:07 -070087 struct opa_16b_mgmt mgmt;
Don Hiatt72c07e22017-08-04 13:53:58 -070088 } u;
89} __packed;
90
Don Hiatt30e07412017-08-04 13:54:04 -070091struct hfi1_opa_header {
92 union {
93 struct ib_header ibh; /* 9B header */
94 struct hfi1_16b_header opah; /* 16B header */
95 };
96 u8 hdr_type; /* 9B or 16B */
97} __packed;
98
Dasaratharaman Chandramoulia9b6b3b2016-07-25 13:40:16 -070099struct hfi1_ahg_info {
Mike Marciniszyn77241052015-07-30 15:17:43 -0400100 u32 ahgdesc[2];
101 u16 tx_flags;
102 u8 ahgcount;
103 u8 ahgidx;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400104};
105
Don Hiattd4d602e2016-07-25 13:40:22 -0700106struct hfi1_sdma_header {
Mike Marciniszyn77241052015-07-30 15:17:43 -0400107 __le64 pbc;
Don Hiatt30e07412017-08-04 13:54:04 -0700108 struct hfi1_opa_header hdr;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400109} __packed;
110
111/*
Dennis Dalessandro4c6829c2016-01-19 14:42:00 -0800112 * hfi1 specific data structures that will be hidden from rvt after the queue
113 * pair is made common
114 */
Dennis Dalessandro4c6829c2016-01-19 14:42:00 -0800115struct hfi1_qp_priv {
Dasaratharaman Chandramoulia9b6b3b2016-07-25 13:40:16 -0700116 struct hfi1_ahg_info *s_ahg; /* ahg info for next header */
Jubin John721d0422016-02-14 12:45:00 -0800117 struct sdma_engine *s_sde; /* current sde */
118 struct send_context *s_sendcontext; /* current sendcontext */
Mike Marciniszyn5190f052018-11-28 10:22:31 -0800119 struct hfi1_ctxtdata *rcd; /* QP's receive context */
Kaike Wan838b6fd2019-01-23 19:30:07 -0800120 struct page **pages; /* for TID page scan */
Kaike Wan37356e72019-02-05 14:13:13 -0800121 u32 tid_enqueue; /* saved when tid waited */
Jubin John721d0422016-02-14 12:45:00 -0800122 u8 s_sc; /* SC[0..4] for next packet */
Dennis Dalessandro4c6829c2016-01-19 14:42:00 -0800123 struct iowait s_iowait;
Kaike Wan3c759e02019-01-23 21:49:19 -0800124 struct timer_list s_tid_timer; /* for timing tid wait */
Kaike Wan829eaee2019-01-23 21:50:24 -0800125 struct timer_list s_tid_retry_timer; /* for timing tid ack */
Kaike Wan37356e72019-02-05 14:13:13 -0800126 struct list_head tid_wait; /* for queueing tid space */
Kaike Wand22a2072019-01-23 19:20:42 -0800127 struct hfi1_opfn_data opfn;
Kaike Wan37356e72019-02-05 14:13:13 -0800128 struct tid_flow_state flow_state;
Kaike Wand22a2072019-01-23 19:20:42 -0800129 struct tid_rdma_qp_params tid_rdma;
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800130 struct rvt_qp *owner;
Mike Marciniszyn270a9832019-02-26 08:46:16 -0800131 u16 s_running_pkt_size;
Don Hiattd98bb7f2017-08-04 13:54:16 -0700132 u8 hdr_type; /* 9B or 16B */
Kaike Wan6e38fca2019-01-23 21:50:56 -0800133 struct rvt_sge_state tid_ss; /* SGE state pointer for 2nd leg */
Kaike Wan70dcb2e2019-01-23 21:51:07 -0800134 atomic_t n_requests; /* # of TID RDMA requests in the */
135 /* queue */
Kaike Wan9e93e962019-01-23 21:50:14 -0800136 atomic_t n_tid_requests; /* # of sent TID RDMA requests */
Kaike Wand22a2072019-01-23 19:20:42 -0800137 unsigned long tid_timer_timeout_jiffies;
Kaike Wan829eaee2019-01-23 21:50:24 -0800138 unsigned long tid_retry_timeout_jiffies;
Kaike Wan742a3822019-01-23 19:30:40 -0800139
Kaike Wana0b34f72019-01-24 06:36:48 -0800140 /* variables for the TID RDMA SE state machine */
Kaike Wan9e93e962019-01-23 21:50:14 -0800141 u8 s_state;
142 u8 s_retry;
Kaike Wan07b923702019-01-23 21:48:59 -0800143 u8 rnr_nak_state; /* RNR NAK state */
Kaike Wand72fe7d2019-01-23 21:49:51 -0800144 u8 s_nak_state;
145 u32 s_nak_psn;
Kaike Wana0b34f72019-01-24 06:36:48 -0800146 u32 s_flags;
Kaike Wan72a0ea92019-01-23 21:49:31 -0800147 u32 s_tid_cur;
148 u32 s_tid_head;
149 u32 s_tid_tail;
Kaike Wan07b923702019-01-23 21:48:59 -0800150 u32 r_tid_head; /* Most recently added TID RDMA request */
151 u32 r_tid_tail; /* the last completed TID RDMA request */
152 u32 r_tid_ack; /* the TID RDMA request to be ACK'ed */
153 u32 r_tid_alloc; /* Request for which we are allocating resources */
154 u32 pending_tid_w_segs; /* Num of pending tid write segments */
Kaike Wan3c6cb202019-01-23 21:51:39 -0800155 u32 pending_tid_w_resp; /* Num of pending tid write responses */
Kaike Wan07b923702019-01-23 21:48:59 -0800156 u32 alloc_w_segs; /* Number of segments for which write */
157 /* resources have been allocated for this QP */
Kaike Wana0b34f72019-01-24 06:36:48 -0800158
Kaike Wan742a3822019-01-23 19:30:40 -0800159 /* For TID RDMA READ */
Kaike Wan9905bf02019-02-05 14:13:30 -0800160 u32 tid_r_reqs; /* Num of tid reads requested */
161 u32 tid_r_comp; /* Num of tid reads completed */
Kaike Wan742a3822019-01-23 19:30:40 -0800162 u32 pending_tid_r_segs; /* Num of pending tid read segments */
Kaike Wand22a2072019-01-23 19:20:42 -0800163 u16 pkts_ps; /* packets per segment */
164 u8 timeout_shift; /* account for number of packets per segment */
Kaike Wan07b923702019-01-23 21:48:59 -0800165
Kaike Wand72fe7d2019-01-23 21:49:51 -0800166 u32 r_next_psn_kdeth;
Kaike Wan0f75e322019-01-23 21:50:03 -0800167 u32 r_next_psn_kdeth_save;
Kaike Wan9e93e962019-01-23 21:50:14 -0800168 u32 s_resync_psn;
Kaike Wan07b923702019-01-23 21:48:59 -0800169 u8 sync_pt; /* Set when QP reaches sync point */
Kaike Wan0f75e322019-01-23 21:50:03 -0800170 u8 resync;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400171};
172
Kaike Wan07b923702019-01-23 21:48:59 -0800173#define HFI1_QP_WQE_INVALID ((u32)-1)
174
Kaike Wan838b6fd2019-01-23 19:30:07 -0800175struct hfi1_swqe_priv {
176 struct tid_rdma_request tid_req;
Kaike Wan742a3822019-01-23 19:30:40 -0800177 struct rvt_sge_state ss; /* Used for TID RDMA READ Request */
Kaike Wan838b6fd2019-01-23 19:30:07 -0800178};
179
180struct hfi1_ack_priv {
Kaike Wan38d46d32019-01-23 21:49:09 -0800181 struct rvt_sge_state ss; /* used for TID WRITE RESP */
Kaike Wan838b6fd2019-01-23 19:30:07 -0800182 struct tid_rdma_request tid_req;
183};
184
Mike Marciniszyn77241052015-07-30 15:17:43 -0400185/*
Dennis Dalessandrod46e5142015-11-11 00:34:37 -0500186 * This structure is used to hold commonly lookedup and computed values during
187 * the send engine progress.
188 */
Dennis Dalessandro5da0fc92018-09-28 07:17:09 -0700189struct iowait_work;
Dennis Dalessandrod46e5142015-11-11 00:34:37 -0500190struct hfi1_pkt_state {
191 struct hfi1_ibdev *dev;
192 struct hfi1_ibport *ibp;
193 struct hfi1_pportdata *ppd;
Dennis Dalessandrobb5df5f2016-02-14 12:44:43 -0800194 struct verbs_txreq *s_txreq;
Dennis Dalessandro5da0fc92018-09-28 07:17:09 -0700195 struct iowait_work *wait;
Mike Marciniszyn747f4d72016-04-12 10:46:10 -0700196 unsigned long flags;
Mike Marciniszyndd1ed102017-05-04 05:14:10 -0700197 unsigned long timeout;
198 unsigned long timeout_int;
199 int cpu;
Don Hiatt566d53a2017-08-04 13:54:47 -0700200 u8 opcode;
Mike Marciniszyndd1ed102017-05-04 05:14:10 -0700201 bool in_thread;
Kaike Wanbcad2912017-07-24 07:45:37 -0700202 bool pkts_sent;
Dennis Dalessandrod46e5142015-11-11 00:34:37 -0500203};
204
Mike Marciniszyn77241052015-07-30 15:17:43 -0400205#define HFI1_PSN_CREDIT 16
206
Mike Marciniszyn77241052015-07-30 15:17:43 -0400207struct hfi1_opcode_stats {
208 u64 n_packets; /* number of packets */
209 u64 n_bytes; /* total number of bytes */
210};
211
212struct hfi1_opcode_stats_perctx {
213 struct hfi1_opcode_stats stats[256];
214};
215
216static inline void inc_opstats(
217 u32 tlen,
218 struct hfi1_opcode_stats *stats)
219{
220#ifdef CONFIG_DEBUG_FS
221 stats->n_bytes += tlen;
222 stats->n_packets++;
223#endif
224}
225
226struct hfi1_ibport {
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800227 struct rvt_qp __rcu *qp[2];
Dennis Dalessandro4eb06882016-01-19 14:42:39 -0800228 struct rvt_ibport rvp;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400229
Mike Marciniszyn77241052015-07-30 15:17:43 -0400230 /* the first 16 entries are sl_to_vl for !OPA */
231 u8 sl_to_sc[32];
232 u8 sc_to_sl[32];
233};
234
Mike Marciniszyn77241052015-07-30 15:17:43 -0400235struct hfi1_ibdev {
Dennis Dalessandroec3f2c12016-01-19 14:41:33 -0800236 struct rvt_dev_info rdi; /* Must be first */
Mike Marciniszyn77241052015-07-30 15:17:43 -0400237
Mike Marciniszyn77241052015-07-30 15:17:43 -0400238 /* QP numbers are shared by all IB ports */
Mike Marciniszyn4e045572016-10-10 06:14:28 -0700239 /* protect txwait list */
240 seqlock_t txwait_lock ____cacheline_aligned_in_smp;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400241 struct list_head txwait; /* list for wait verbs_txreq */
242 struct list_head memwait; /* list for wait kernel memory */
Mike Marciniszyn77241052015-07-30 15:17:43 -0400243 struct kmem_cache *verbs_txreq_cache;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400244 u64 n_txwait;
245 u64 n_kmem_wait;
Kaike Wan2f16a692019-01-23 19:30:18 -0800246 u64 n_tidwait;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400247
Mike Marciniszyn4e045572016-10-10 06:14:28 -0700248 /* protect iowait lists */
249 seqlock_t iowait_lock ____cacheline_aligned_in_smp;
250 u64 n_piowait;
251 u64 n_piodrain;
252 struct timer_list mem_timer;
253
Mike Marciniszyn77241052015-07-30 15:17:43 -0400254#ifdef CONFIG_DEBUG_FS
255 /* per HFI debugfs */
256 struct dentry *hfi1_ibdev_dbg;
257 /* per HFI symlinks to above */
258 struct dentry *hfi1_ibdev_link;
Don Hiatt0181ce32017-03-20 17:26:14 -0700259#ifdef CONFIG_FAULT_INJECTION
Mitko Haralanova74d5302018-05-02 06:43:24 -0700260 struct fault *fault;
Don Hiatt0181ce32017-03-20 17:26:14 -0700261#endif
Mike Marciniszyn77241052015-07-30 15:17:43 -0400262#endif
263};
264
Mike Marciniszyn77241052015-07-30 15:17:43 -0400265static inline struct hfi1_ibdev *to_idev(struct ib_device *ibdev)
266{
Dennis Dalessandroec3f2c12016-01-19 14:41:33 -0800267 struct rvt_dev_info *rdi;
268
269 rdi = container_of(ibdev, struct rvt_dev_info, ibdev);
270 return container_of(rdi, struct hfi1_ibdev, rdi);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400271}
272
Dennis Dalessandro5da0fc92018-09-28 07:17:09 -0700273static inline struct rvt_qp *iowait_to_qp(struct iowait *s_iowait)
Dennis Dalessandro4c6829c2016-01-19 14:42:00 -0800274{
275 struct hfi1_qp_priv *priv;
276
277 priv = container_of(s_iowait, struct hfi1_qp_priv, s_iowait);
278 return priv->owner;
279}
280
Mike Marciniszyn77241052015-07-30 15:17:43 -0400281/*
Mike Marciniszyn77241052015-07-30 15:17:43 -0400282 * This must be called with s_lock held.
283 */
Dennis Dalessandro13d84912017-05-29 17:22:01 -0700284void hfi1_bad_pkey(struct hfi1_ibport *ibp, u32 key, u32 sl,
Don Hiatt88733e32017-08-04 13:54:23 -0700285 u32 qp1, u32 qp2, u32 lid1, u32 lid2);
Mark Bloch1fb7f892021-03-01 09:04:20 +0200286void hfi1_cap_mask_chg(struct rvt_dev_info *rdi, u32 port_num);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400287void hfi1_sys_guid_chg(struct hfi1_ibport *ibp);
288void hfi1_node_desc_chg(struct hfi1_ibport *ibp);
Mark Bloch1fb7f892021-03-01 09:04:20 +0200289int hfi1_process_mad(struct ib_device *ibdev, int mad_flags, u32 port,
Mike Marciniszyn77241052015-07-30 15:17:43 -0400290 const struct ib_wc *in_wc, const struct ib_grh *in_grh,
Leon Romanovskye26e7b82019-10-29 08:27:45 +0200291 const struct ib_mad *in_mad, struct ib_mad *out_mad,
292 size_t *out_mad_size, u16 *out_mad_pkey_index);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400293
294/*
295 * The PSN_MASK and PSN_SHIFT allow for
296 * 1) comparing two PSNs
297 * 2) returning the PSN with any upper bits masked
298 * 3) returning the difference between to PSNs
299 *
300 * The number of significant bits in the PSN must
301 * necessarily be at least one bit less than
302 * the container holding the PSN.
303 */
Mike Marciniszyn77241052015-07-30 15:17:43 -0400304#define PSN_MASK 0x7FFFFFFF
305#define PSN_SHIFT 1
Mike Marciniszyn77241052015-07-30 15:17:43 -0400306#define PSN_MODIFY_MASK 0xFFFFFF
307
Mike Marciniszyn77241052015-07-30 15:17:43 -0400308/*
Mike Marciniszyn77241052015-07-30 15:17:43 -0400309 * Compare two PSNs
310 * Returns an integer <, ==, or > than zero.
311 */
312static inline int cmp_psn(u32 a, u32 b)
313{
Jubin John50e5dcb2016-02-14 20:19:41 -0800314 return (((int)a) - ((int)b)) << PSN_SHIFT;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400315}
316
317/*
318 * Return masked PSN
319 */
320static inline u32 mask_psn(u32 a)
321{
322 return a & PSN_MASK;
323}
324
325/*
326 * Return delta between two PSNs
327 */
328static inline u32 delta_psn(u32 a, u32 b)
329{
330 return (((int)a - (int)b) << PSN_SHIFT) >> PSN_SHIFT;
331}
332
Kaike Wan742a3822019-01-23 19:30:40 -0800333static inline struct tid_rdma_request *wqe_to_tid_req(struct rvt_swqe *wqe)
334{
335 return &((struct hfi1_swqe_priv *)wqe->priv)->tid_req;
336}
337
Kaike Wand0d564a2019-01-23 19:31:02 -0800338static inline struct tid_rdma_request *ack_to_tid_req(struct rvt_ack_entry *e)
339{
340 return &((struct hfi1_ack_priv *)e->priv)->tid_req;
341}
342
Kaike Wan838b6fd2019-01-23 19:30:07 -0800343/*
344 * Look through all the active flows for a TID RDMA request and find
345 * the one (if it exists) that contains the specified PSN.
346 */
347static inline u32 __full_flow_psn(struct flow_state *state, u32 psn)
348{
349 return mask_psn((state->generation << HFI1_KDETH_BTH_SEQ_SHIFT) |
350 (psn & HFI1_KDETH_BTH_SEQ_MASK));
351}
352
353static inline u32 full_flow_psn(struct tid_rdma_flow *flow, u32 psn)
354{
355 return __full_flow_psn(&flow->flow_state, psn);
356}
357
Mike Marciniszyn77241052015-07-30 15:17:43 -0400358struct verbs_txreq;
359void hfi1_put_txreq(struct verbs_txreq *tx);
360
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800361int hfi1_verbs_send(struct rvt_qp *qp, struct hfi1_pkt_state *ps);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400362
Mike Marciniszyn77241052015-07-30 15:17:43 -0400363void hfi1_cnp_rcv(struct hfi1_packet *packet);
364
365void hfi1_uc_rcv(struct hfi1_packet *packet);
366
367void hfi1_rc_rcv(struct hfi1_packet *packet);
368
369void hfi1_rc_hdrerr(
370 struct hfi1_ctxtdata *rcd,
Don Hiatt90397462017-05-12 09:20:20 -0700371 struct hfi1_packet *packet,
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800372 struct rvt_qp *qp);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400373
Dasaratharaman Chandramouli90898852017-04-29 14:41:18 -0400374u8 ah_to_sc(struct ib_device *ibdev, struct rdma_ah_attr *ah_attr);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400375
Mike Marciniszyn4bb02e92019-06-14 12:32:44 -0400376void hfi1_rc_verbs_aborted(struct rvt_qp *qp, struct hfi1_opa_header *opah);
Don Hiatt30e07412017-08-04 13:54:04 -0700377void hfi1_rc_send_complete(struct rvt_qp *qp, struct hfi1_opa_header *opah);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400378
Mike Marciniszyn77241052015-07-30 15:17:43 -0400379void hfi1_ud_rcv(struct hfi1_packet *packet);
380
381int hfi1_lookup_pkey_idx(struct hfi1_ibport *ibp, u16 pkey);
382
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800383void hfi1_migrate_qp(struct rvt_qp *qp);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400384
Dennis Dalessandroec4274f2016-01-19 14:43:44 -0800385int hfi1_check_modify_qp(struct rvt_qp *qp, struct ib_qp_attr *attr,
386 int attr_mask, struct ib_udata *udata);
387
388void hfi1_modify_qp(struct rvt_qp *qp, struct ib_qp_attr *attr,
389 int attr_mask, struct ib_udata *udata);
Venkata Sandeep Dhanalakota56acbbf2017-02-08 05:27:19 -0800390void hfi1_restart_rc(struct rvt_qp *qp, u32 psn, int wait);
Kaike Wand205a06a2018-09-26 10:26:44 -0700391int hfi1_setup_wqe(struct rvt_qp *qp, struct rvt_swqe *wqe,
392 bool *call_send);
Ira Weiny31e7af12016-02-03 14:33:14 -0800393
Mike Marciniszyn14553ca2016-02-14 12:45:36 -0800394extern const u32 rc_only_opcode;
395extern const u32 uc_only_opcode;
396
Don Hiatt90397462017-05-12 09:20:20 -0700397int hfi1_ruc_check_hdr(struct hfi1_ibport *ibp, struct hfi1_packet *packet);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400398
399u32 hfi1_make_grh(struct hfi1_ibport *ibp, struct ib_grh *hdr,
Dasaratharaman Chandramoulid8966fc2017-04-29 14:41:28 -0400400 const struct ib_global_route *grh, u32 hwords, u32 nwords);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400401
Mike Marciniszyn261a4352016-09-06 04:35:05 -0700402void hfi1_make_ruc_header(struct rvt_qp *qp, struct ib_other_headers *ohdr,
Mitko Haralanov44e43d92019-01-24 06:09:46 -0800403 u32 bth0, u32 bth1, u32 bth2, int middle,
Dennis Dalessandrobb5df5f2016-02-14 12:44:43 -0800404 struct hfi1_pkt_state *ps);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400405
Kaike Wan572f0c32019-01-23 21:51:27 -0800406bool hfi1_schedule_send_yield(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
407 bool tid);
408
Dennis Dalessandro83693bd2016-01-19 14:43:33 -0800409void _hfi1_do_send(struct work_struct *work);
410
Mike Marciniszynb6eac932017-04-09 10:16:35 -0700411void hfi1_do_send_from_rvt(struct rvt_qp *qp);
412
413void hfi1_do_send(struct rvt_qp *qp, bool in_thread);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400414
Sebastian Sanchezbdaf96f2018-02-01 10:46:31 -0800415void hfi1_send_rc_ack(struct hfi1_packet *packet, bool is_fecn);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400416
Dennis Dalessandrobb5df5f2016-02-14 12:44:43 -0800417int hfi1_make_rc_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400418
Dennis Dalessandrobb5df5f2016-02-14 12:44:43 -0800419int hfi1_make_uc_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400420
Dennis Dalessandrobb5df5f2016-02-14 12:44:43 -0800421int hfi1_make_ud_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400422
423int hfi1_register_ib_device(struct hfi1_devdata *);
424
425void hfi1_unregister_ib_device(struct hfi1_devdata *);
426
Kaike Wan22d136d2019-01-24 06:36:34 -0800427void hfi1_kdeth_eager_rcv(struct hfi1_packet *packet);
428
429void hfi1_kdeth_expected_rcv(struct hfi1_packet *packet);
430
Mike Marciniszyn77241052015-07-30 15:17:43 -0400431void hfi1_ib_rcv(struct hfi1_packet *packet);
432
Don Hiatt72c07e22017-08-04 13:53:58 -0700433void hfi1_16B_rcv(struct hfi1_packet *packet);
434
Mike Marciniszyn77241052015-07-30 15:17:43 -0400435unsigned hfi1_get_npkeys(struct hfi1_devdata *);
436
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800437int hfi1_verbs_send_dma(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
Dennis Dalessandrod46e5142015-11-11 00:34:37 -0500438 u64 pbc);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400439
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800440int hfi1_verbs_send_pio(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
Dennis Dalessandrod46e5142015-11-11 00:34:37 -0500441 u64 pbc);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400442
Sebastian Sanchez6d6b8842018-02-01 10:46:23 -0800443static inline bool opa_bth_is_migration(struct ib_other_headers *ohdr)
444{
445 return ohdr->bth[1] & cpu_to_be32(OPA_BTH_MIG_REQ);
446}
447
Kaike Wan838b6fd2019-01-23 19:30:07 -0800448void hfi1_wait_kmem(struct rvt_qp *qp);
449
450static inline void hfi1_trdma_send_complete(struct rvt_qp *qp,
451 struct rvt_swqe *wqe,
452 enum ib_wc_status status)
453{
454 trdma_clean_swqe(qp, wqe);
455 rvt_send_complete(qp, wqe, status);
456}
457
Mike Marciniszyn77241052015-07-30 15:17:43 -0400458extern const enum ib_wc_opcode ib_hfi1_wc_opcode[];
459
460extern const u8 hdr_len_by_opcode[];
461
Dennis Dalessandro83693bd2016-01-19 14:43:33 -0800462extern const int ib_rvt_state_ops[];
Mike Marciniszyn77241052015-07-30 15:17:43 -0400463
464extern __be64 ib_hfi1_sys_image_guid; /* in network order */
465
Mike Marciniszyn77241052015-07-30 15:17:43 -0400466extern unsigned int hfi1_max_cqes;
467
468extern unsigned int hfi1_max_cqs;
469
470extern unsigned int hfi1_max_qp_wrs;
471
472extern unsigned int hfi1_max_qps;
473
474extern unsigned int hfi1_max_sges;
475
476extern unsigned int hfi1_max_mcast_grps;
477
478extern unsigned int hfi1_max_mcast_qp_attached;
479
480extern unsigned int hfi1_max_srqs;
481
482extern unsigned int hfi1_max_srq_sges;
483
484extern unsigned int hfi1_max_srq_wrs;
485
Mike Marciniszyn14553ca2016-02-14 12:45:36 -0800486extern unsigned short piothreshold;
487
Mike Marciniszyn77241052015-07-30 15:17:43 -0400488extern const u32 ib_hfi1_rnr_table[];
489
Mike Marciniszyn77241052015-07-30 15:17:43 -0400490#endif /* HFI1_VERBS_H */