Blame view

include/rdma/rdma_vt.h 14.2 KB
6bf9d8f6f   Leon Romanovsky   RDMA/include: Rep...
1
  /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
0194621b2   Dennis Dalessandro   IB/rdmavt: Create...
2
  /*
d310c4bf8   Michael J. Ruhl   IB/{rdmavt, hfi1,...
3
   * Copyright(c) 2016 - 2019 Intel Corporation.
0194621b2   Dennis Dalessandro   IB/rdmavt: Create...
4
   */
6bf9d8f6f   Leon Romanovsky   RDMA/include: Rep...
5
6
  #ifndef DEF_RDMA_VT_H
  #define DEF_RDMA_VT_H
0194621b2   Dennis Dalessandro   IB/rdmavt: Create...
7
8
9
10
  /*
   * Structure that low level drivers will populate in order to register with the
   * rdmavt layer.
   */
f3d01bbcd   Dennis Dalessandro   IB/rdmavt: Add an...
11
12
  #include <linux/spinlock.h>
  #include <linux/list.h>
3b0b3fb3c   Dennis Dalessandro   IB/rdmavt: Add mo...
13
  #include <linux/hash.h>
b4e64397d   Dennis Dalessandro   IB/rdmavt: Break ...
14
  #include <rdma/ib_verbs.h>
bf90aadd6   Michael J. Ruhl   IB/hfi1: Send MAD...
15
  #include <rdma/ib_mad.h>
b4e64397d   Dennis Dalessandro   IB/rdmavt: Break ...
16
  #include <rdma/rdmavt_mr.h>
f2f342115   Kamal Heib   IB/rdmavt: Add co...
17

38ce2c6f3   Dennis Dalessandro   IB/rdmavt: Add pk...
18
  #define RVT_MAX_PKEY_VALUES 16
bf90aadd6   Michael J. Ruhl   IB/hfi1: Send MAD...
19
  #define RVT_MAX_TRAP_LEN 100 /* Limit pending trap list */
ec0d8b8a6   Kamenee Arumugame   IB/hfi1: Stricter...
20
  #define RVT_MAX_TRAP_LISTS 5 /*((IB_NOTICE_TYPE_INFO & 0x0F) + 1)*/
bf90aadd6   Michael J. Ruhl   IB/hfi1: Send MAD...
21
22
23
24
25
26
  #define RVT_TRAP_TIMEOUT 4096 /* 4.096 usec */
  
  struct trap_list {
  	u32 list_len;
  	struct list_head list;
  };
715ab1a86   Mike Marciniszyn   IB/rdmavt: Fix ab...
27
28
  struct rvt_qp;
  struct rvt_qpn_table;
f3d01bbcd   Dennis Dalessandro   IB/rdmavt: Add an...
29
30
31
32
33
34
35
36
37
38
39
40
41
  struct rvt_ibport {
  	struct rvt_qp __rcu *qp[2];
  	struct ib_mad_agent *send_agent;	/* agent for SMI (traps) */
  	struct rb_root mcast_tree;
  	spinlock_t lock;		/* protect changes in this struct */
  
  	/* non-zero when timer is set */
  	unsigned long mkey_lease_timeout;
  	unsigned long trap_timeout;
  	__be64 gid_prefix;      /* in network order */
  	__be64 mkey;
  	u64 tid;
  	u32 port_cap_flags;
cb49366f3   Vishwanathapura, Niranjana   IB/core,rdmavt,hf...
42
  	u16 port_cap3_flags;
f3d01bbcd   Dennis Dalessandro   IB/rdmavt: Add an...
43
44
45
46
47
  	u32 pma_sample_start;
  	u32 pma_sample_interval;
  	__be16 pma_counter_select[5];
  	u16 pma_tag;
  	u16 mkey_lease_period;
51e658f5d   Dasaratharaman Chandramouli   IB/rdmavt, hfi1, ...
48
  	u32 sm_lid;
f3d01bbcd   Dennis Dalessandro   IB/rdmavt: Add an...
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
  	u8 sm_sl;
  	u8 mkeyprot;
  	u8 subnet_timeout;
  	u8 vl_high_limit;
  
  	/*
  	 * Driver is expected to keep these up to date. These
  	 * counters are informational only and not required to be
  	 * completely accurate.
  	 */
  	u64 n_rc_resends;
  	u64 n_seq_naks;
  	u64 n_rdma_seq;
  	u64 n_rnr_naks;
  	u64 n_other_naks;
  	u64 n_loop_pkts;
  	u64 n_pkt_drops;
  	u64 n_vl15_dropped;
  	u64 n_rc_timeouts;
  	u64 n_dmawait;
  	u64 n_unaligned;
  	u64 n_rc_dupreq;
  	u64 n_rc_seqnak;
719943541   Kaike Wan   IB/{rdmavt, hfi1,...
72
  	u64 n_rc_crwaits;
f3d01bbcd   Dennis Dalessandro   IB/rdmavt: Add an...
73
74
75
76
77
78
79
80
81
82
83
84
85
  	u16 pkey_violations;
  	u16 qkey_violations;
  	u16 mkey_violations;
  
  	/* Hot-path per CPU counters to avoid cacheline trading to update */
  	u64 z_rc_acks;
  	u64 z_rc_qacks;
  	u64 z_rc_delayed_comp;
  	u64 __percpu *rc_acks;
  	u64 __percpu *rc_qacks;
  	u64 __percpu *rc_delayed_comp;
  
  	void *priv; /* driver private data */
38ce2c6f3   Dennis Dalessandro   IB/rdmavt: Add pk...
86
87
88
89
90
91
92
  	/*
  	 * The pkey table is allocated and maintained by the driver. Drivers
  	 * need to have access to this before registering with rdmav. However
  	 * rdmavt will need access to it so drivers need to proviee this during
  	 * the attach port API call.
  	 */
  	u16 *pkey_table;
3711baf27   Dennis Dalessandro   IB/rdmavt: Add ma...
93
  	struct rvt_ah *sm_ah;
bf90aadd6   Michael J. Ruhl   IB/hfi1: Send MAD...
94
95
96
97
98
99
100
  
  	/*
  	 * Keep a list of traps that have not been repressed.  They will be
  	 * resent based on trap_timer.
  	 */
  	struct trap_list trap_lists[RVT_MAX_TRAP_LISTS];
  	struct timer_list trap_timer;
f3d01bbcd   Dennis Dalessandro   IB/rdmavt: Add an...
101
  };
6f6387ae7   Dennis Dalessandro   IB/rdmavt: Add co...
102
  #define RVT_CQN_MAX 16 /* maximum length of cq name */
019f118b9   Brian Welty   IB/{hfi1, qib, rd...
103
104
105
  #define RVT_SGE_COPY_MEMCPY	0
  #define RVT_SGE_COPY_CACHELESS	1
  #define RVT_SGE_COPY_ADAPTIVE	2
ca889e8ad   Dennis Dalessandro   IB/rdmavt: Add qu...
106
  /*
8afd32eb5   Dennis Dalessandro   IB/rdmavt: Add pr...
107
108
109
   * Things that are driver specific, module parameters in hfi1 and qib
   */
  struct rvt_driver_params {
b1070a7a4   Dennis Dalessandro   IB/rdmavt: Add ib...
110
111
112
  	struct ib_device_attr props;
  
  	/*
b1070a7a4   Dennis Dalessandro   IB/rdmavt: Add ib...
113
114
115
  	 * Anything driver specific that is not covered by props
  	 * For instance special module parameters. Goes here.
  	 */
7b1e2099a   Dennis Dalessandro   IB/rdmavt: Move m...
116
  	unsigned int lkey_table_size;
0acb0cc7e   Dennis Dalessandro   IB/rdmavt: Initia...
117
  	unsigned int qp_table_size;
019f118b9   Brian Welty   IB/{hfi1, qib, rd...
118
119
120
  	unsigned int sge_copy_mode;
  	unsigned int wss_threshold;
  	unsigned int wss_clean_period;
0acb0cc7e   Dennis Dalessandro   IB/rdmavt: Initia...
121
122
123
124
  	int qpn_start;
  	int qpn_inc;
  	int qpn_res_start;
  	int qpn_res_end;
f3d01bbcd   Dennis Dalessandro   IB/rdmavt: Add an...
125
  	int nports;
38ce2c6f3   Dennis Dalessandro   IB/rdmavt: Add pk...
126
  	int npkeys;
6f6387ae7   Dennis Dalessandro   IB/rdmavt: Add co...
127
  	int node;
3b0b3fb3c   Dennis Dalessandro   IB/rdmavt: Add mo...
128
129
130
  	int psn_mask;
  	int psn_shift;
  	int psn_modify_mask;
61a650c14   Harish Chegondi   IB/rdmavt: Add su...
131
132
  	u32 core_cap_flags;
  	u32 max_mad_size;
4c0b65333   Mike Marciniszyn   IB/rdmavt: Max at...
133
134
  	u8 qos_shift;
  	u8 max_rdma_atomic;
ddf922c31   Kaike Wan   IB/hfi1, IB/rdmav...
135
  	u8 extra_rdma_atomic;
856cc4c23   Mike Marciniszyn   IB/hfi1: Add the ...
136
  	u8 reserved_operations;
8afd32eb5   Dennis Dalessandro   IB/rdmavt: Add pr...
137
  };
899444505   Shamir Rabinovitch   IB/{hw,sw}: Remov...
138
139
140
141
  /* User context */
  struct rvt_ucontext {
  	struct ib_ucontext ibucontext;
  };
b036db83c   Dennis Dalessandro   IB/rdmavt: Add dr...
142
143
144
  /* Protection domain */
  struct rvt_pd {
  	struct ib_pd ibpd;
0128fceaf   Brian Welty   IB/hfi1, rdmavt: ...
145
  	bool user;
b036db83c   Dennis Dalessandro   IB/rdmavt: Add dr...
146
147
148
149
150
  };
  
  /* Address handle */
  struct rvt_ah {
  	struct ib_ah ibah;
90898850e   Dasaratharaman Chandramouli   IB/core: Rename s...
151
  	struct rdma_ah_attr attr;
b036db83c   Dennis Dalessandro   IB/rdmavt: Add dr...
152
153
154
  	u8 vl;
  	u8 log_pmtu;
  };
715ab1a86   Mike Marciniszyn   IB/rdmavt: Fix ab...
155
156
157
158
159
160
161
162
163
164
165
166
167
  /*
   * This structure is used by rvt_mmap() to validate an offset
   * when an mmap() request is made.  The vm_area_struct then uses
   * this as its vm_private_data.
   */
  struct rvt_mmap_info {
  	struct list_head pending_mmaps;
  	struct ib_ucontext *context;
  	void *obj;
  	__u64 offset;
  	struct kref ref;
  	u32 size;
  };
019f118b9   Brian Welty   IB/{hfi1, qib, rd...
168
169
170
171
172
173
174
175
176
177
178
179
  /* memory working set size */
  struct rvt_wss {
  	unsigned long *entries;
  	atomic_t total_count;
  	atomic_t clean_counter;
  	atomic_t clean_entry;
  
  	int threshold;
  	int num_entries;
  	long pages_mask;
  	unsigned int clean_period;
  };
b534875d5   Dennis Dalessandro   IB/rdmavt: Add de...
180
  struct rvt_dev_info;
46a80d62e   Mike Marciniszyn   IB/qib, staging/r...
181
  struct rvt_swqe;
aec577877   Dennis Dalessandro   IB/rdmavt: Move d...
182
183
  struct rvt_driver_provided {
  	/*
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
184
185
186
  	 * Which functions are required depends on which verbs rdmavt is
  	 * providing and which verbs the driver is overriding. See
  	 * check_support() for details.
aec577877   Dennis Dalessandro   IB/rdmavt: Move d...
187
  	 */
b036db83c   Dennis Dalessandro   IB/rdmavt: Add dr...
188

be5d740bd   Mike Marciniszyn   IB/rdmvat: Organi...
189
190
191
192
193
194
195
196
197
  	/* hot path calldowns in a single cacheline */
  
  	/*
  	 * Give the driver a notice that there is send work to do. It is up to
  	 * the driver to generally push the packets out, this just queues the
  	 * work with the driver. There are two variants here. The no_lock
  	 * version requires the s_lock not to be held. The other assumes the
  	 * s_lock is held.
  	 */
5da0fc9db   Dennis Dalessandro   IB/hfi1: Prepare ...
198
199
  	bool (*schedule_send)(struct rvt_qp *qp);
  	bool (*schedule_send_no_lock)(struct rvt_qp *qp);
be5d740bd   Mike Marciniszyn   IB/rdmvat: Organi...
200

0b79b2774   Michael J. Ruhl   IB/{hfi1, qib, rd...
201
  	/*
d205a06a1   Kaike Wan   IB/rdmavt: Rename...
202
203
204
205
206
  	 * Driver specific work request setup and checking.
  	 * This function is allowed to perform any setup, checks, or
  	 * adjustments required to the SWQE in order to be usable by
  	 * underlying protocols. This includes private data structure
  	 * allocations.
0b79b2774   Michael J. Ruhl   IB/{hfi1, qib, rd...
207
  	 */
d205a06a1   Kaike Wan   IB/rdmavt: Rename...
208
209
  	int (*setup_wqe)(struct rvt_qp *qp, struct rvt_swqe *wqe,
  			 bool *call_send);
be5d740bd   Mike Marciniszyn   IB/rdmvat: Organi...
210
211
212
213
214
215
  
  	/*
  	 * Sometimes rdmavt needs to kick the driver's send progress. That is
  	 * done by this call back.
  	 */
  	void (*do_send)(struct rvt_qp *qp);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
216
  	/*
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
217
218
219
220
  	 * Returns a pointer to the undelying hardware's PCI device. This is
  	 * used to display information as to what hardware is being referenced
  	 * in an output message
  	 */
b534875d5   Dennis Dalessandro   IB/rdmavt: Add de...
221
  	struct pci_dev * (*get_pci_dev)(struct rvt_dev_info *rdi);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
222
223
224
  
  	/*
  	 * Allocate a private queue pair data structure for driver specific
c755f4afa   Mike Marciniszyn   IB/rdmavt: Correc...
225
226
227
  	 * information which is opaque to rdmavt.  Errors are returned via
  	 * ERR_PTR(err).  The driver is free to return NULL or a valid
  	 * pointer.
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
228
  	 */
0f4d027c3   Leon Romanovsky   IB/{rdmavt, qib, ...
229
  	void * (*qp_priv_alloc)(struct rvt_dev_info *rdi, struct rvt_qp *qp);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
230
231
  
  	/*
5190f052a   Mike Marciniszyn   IB/hfi1: Allow th...
232
233
234
235
236
237
238
  	 * Init a struture allocated with qp_priv_alloc(). This should be
  	 * called after all qp fields have been initialized in rdmavt.
  	 */
  	int (*qp_priv_init)(struct rvt_dev_info *rdi, struct rvt_qp *qp,
  			    struct ib_qp_init_attr *init_attr);
  
  	/*
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
239
240
  	 * Free the driver's private qp structure.
  	 */
515667f8f   Dennis Dalessandro   IB/rdmavt: Add cr...
241
  	void (*qp_priv_free)(struct rvt_dev_info *rdi, struct rvt_qp *qp);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
242
243
244
245
246
  
  	/*
  	 * Inform the driver the particular qp in quesiton has been reset so
  	 * that it can clean up anything it needs to.
  	 */
515667f8f   Dennis Dalessandro   IB/rdmavt: Add cr...
247
  	void (*notify_qp_reset)(struct rvt_qp *qp);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
248
249
  
  	/*
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
250
251
  	 * Get a path mtu from the driver based on qp attributes.
  	 */
3b0b3fb3c   Dennis Dalessandro   IB/rdmavt: Add mo...
252
253
  	int (*get_pmtu_from_attr)(struct rvt_dev_info *rdi, struct rvt_qp *qp,
  				  struct ib_qp_attr *attr);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
254
255
256
257
258
  
  	/*
  	 * Notify driver that it needs to flush any outstanding IO requests that
  	 * are waiting on a qp.
  	 */
3b0b3fb3c   Dennis Dalessandro   IB/rdmavt: Add mo...
259
  	void (*flush_qp_waiters)(struct rvt_qp *qp);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
260
261
262
263
264
  
  	/*
  	 * Notify driver to stop its queue of sending packets. Nothing else
  	 * should be posted to the queue pair after this has been called.
  	 */
3b0b3fb3c   Dennis Dalessandro   IB/rdmavt: Add mo...
265
  	void (*stop_send_queue)(struct rvt_qp *qp);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
266
267
268
269
  
  	/*
  	 * Have the drivr drain any in progress operations
  	 */
3b0b3fb3c   Dennis Dalessandro   IB/rdmavt: Add mo...
270
  	void (*quiesce_qp)(struct rvt_qp *qp);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
271
272
273
274
  
  	/*
  	 * Inform the driver a qp has went to error state.
  	 */
3b0b3fb3c   Dennis Dalessandro   IB/rdmavt: Add mo...
275
  	void (*notify_error_qp)(struct rvt_qp *qp);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
276
277
278
279
  
  	/*
  	 * Get an MTU for a qp.
  	 */
3b0b3fb3c   Dennis Dalessandro   IB/rdmavt: Add mo...
280
281
  	u32 (*mtu_from_qp)(struct rvt_dev_info *rdi, struct rvt_qp *qp,
  			   u32 pmtu);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
282
283
284
  	/*
  	 * Convert an mtu to a path mtu
  	 */
3b0b3fb3c   Dennis Dalessandro   IB/rdmavt: Add mo...
285
  	int (*mtu_to_path_mtu)(u32 mtu);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
286
287
288
289
  
  	/*
  	 * Get the guid of a port in big endian byte order
  	 */
1f024992e   Dennis Dalessandro   IB/rdmavt: Add qu...
290
291
  	int (*get_guid_be)(struct rvt_dev_info *rdi, struct rvt_ibport *rvp,
  			   int guid_index, __be64 *guid);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
292
293
294
295
  
  	/*
  	 * Query driver for the state of the port.
  	 */
61a650c14   Harish Chegondi   IB/rdmavt: Add su...
296
297
  	int (*query_port_state)(struct rvt_dev_info *rdi, u8 port_num,
  				struct ib_port_attr *props);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
298
299
300
301
  
  	/*
  	 * Tell driver to shutdown a port
  	 */
61a650c14   Harish Chegondi   IB/rdmavt: Add su...
302
  	int (*shut_down_port)(struct rvt_dev_info *rdi, u8 port_num);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
303
304
  
  	/* Tell driver to send a trap for changed  port capabilities */
61a650c14   Harish Chegondi   IB/rdmavt: Add su...
305
  	void (*cap_mask_chg)(struct rvt_dev_info *rdi, u8 port_num);
aec577877   Dennis Dalessandro   IB/rdmavt: Move d...
306

1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
307
308
309
310
311
312
313
314
315
316
  	/*
  	 * The following functions can be safely ignored completely. Any use of
  	 * these is checked for NULL before blindly calling. Rdmavt should also
  	 * be functional if drivers omit these.
  	 */
  
  	/* Called to inform the driver that all qps should now be freed. */
  	unsigned (*free_all_qps)(struct rvt_dev_info *rdi);
  
  	/* Driver specific AH validation */
90898850e   Dasaratharaman Chandramouli   IB/core: Rename s...
317
  	int (*check_ah)(struct ib_device *, struct rdma_ah_attr *);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
318
319
  
  	/* Inform the driver a new AH has been created */
90898850e   Dasaratharaman Chandramouli   IB/core: Rename s...
320
  	void (*notify_new_ah)(struct ib_device *, struct rdma_ah_attr *,
b036db83c   Dennis Dalessandro   IB/rdmavt: Add dr...
321
  			      struct rvt_ah *);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
322
323
  
  	/* Let the driver pick the next queue pair number*/
515667f8f   Dennis Dalessandro   IB/rdmavt: Add cr...
324
  	int (*alloc_qpn)(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
0f4d027c3   Leon Romanovsky   IB/{rdmavt, qib, ...
325
  			 enum ib_qp_type type, u8 port_num);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
326
327
  
  	/* Determine if its safe or allowed to modify the qp */
e85ec33d8   Ira Weiny   IB/rdmavt: add mo...
328
329
  	int (*check_modify_qp)(struct rvt_qp *qp, struct ib_qp_attr *attr,
  			       int attr_mask, struct ib_udata *udata);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
330
331
  
  	/* Driver specific QP modification/notification-of */
e85ec33d8   Ira Weiny   IB/rdmavt: add mo...
332
333
  	void (*modify_qp)(struct rvt_qp *qp, struct ib_qp_attr *attr,
  			  int attr_mask, struct ib_udata *udata);
3711baf27   Dennis Dalessandro   IB/rdmavt: Add ma...
334

1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
335
  	/* Notify driver a mad agent has been created */
3711baf27   Dennis Dalessandro   IB/rdmavt: Add ma...
336
  	void (*notify_create_mad_agent)(struct rvt_dev_info *rdi, int port_idx);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
337
338
  
  	/* Notify driver a mad agent has been removed */
3711baf27   Dennis Dalessandro   IB/rdmavt: Add ma...
339
  	void (*notify_free_mad_agent)(struct rvt_dev_info *rdi, int port_idx);
1348d706f   Dennis Dalessandro   IB/rdmavt: Add pe...
340

11a10d4bc   Venkata Sandeep Dhanalakota   IB/rdmavt: Adding...
341
342
  	/* Notify driver to restart rc */
  	void (*notify_restart_rc)(struct rvt_qp *qp, u32 psn, int wait);
5d18ee67d   Sebastian Sanchez   IB/{hfi1, rdmavt,...
343
344
345
  
  	/* Get and return CPU to pin CQ processing thread */
  	int (*comp_vect_cpu_lookup)(struct rvt_dev_info *rdi, int comp_vect);
119a8e708   Kamal Heib   IB/rdmavt: Add AH...
346
  };
0194621b2   Dennis Dalessandro   IB/rdmavt: Create...
347
  struct rvt_dev_info {
7b1e2099a   Dennis Dalessandro   IB/rdmavt: Move m...
348
  	struct ib_device ibdev; /* Keep this first. Nothing above here */
b1070a7a4   Dennis Dalessandro   IB/rdmavt: Add ib...
349
350
351
352
353
  	/*
  	 * Prior to calling for registration the driver will be responsible for
  	 * allocating space for this structure.
  	 *
  	 * The driver will also be responsible for filling in certain members of
feaeb6e26   Harish Chegondi   IB/rdmavt: Add su...
354
355
356
357
  	 * dparms.props. The driver needs to fill in dparms exactly as it would
  	 * want values reported to a ULP. This will be returned to the caller
  	 * in rdmavt's device. The driver should also therefore refrain from
  	 * modifying this directly after registration with rdmavt.
b1070a7a4   Dennis Dalessandro   IB/rdmavt: Add ib...
358
  	 */
8afd32eb5   Dennis Dalessandro   IB/rdmavt: Add pr...
359

b1070a7a4   Dennis Dalessandro   IB/rdmavt: Add ib...
360
  	/* Driver specific properties */
8afd32eb5   Dennis Dalessandro   IB/rdmavt: Add pr...
361
  	struct rvt_driver_params dparms;
b1070a7a4   Dennis Dalessandro   IB/rdmavt: Add ib...
362

afcf8f764   Mike Marciniszyn   IB/rdmavt: Add da...
363
364
  	/* post send table */
  	const struct rvt_operation_params *post_parms;
116aa0330   Venkata Sandeep Dhanalakota   IB/{hfi1, qib, rd...
365
366
  	/* opcode translation table */
  	const enum ib_wc_opcode *wc_opcode;
aec577877   Dennis Dalessandro   IB/rdmavt: Move d...
367
368
  	/* Driver specific helper functions */
  	struct rvt_driver_provided driver_f;
0194621b2   Dennis Dalessandro   IB/rdmavt: Create...
369

be5d740bd   Mike Marciniszyn   IB/rdmvat: Organi...
370
371
  	struct rvt_mregion __rcu *dma_mr;
  	struct rvt_lkey_table lkey_table;
8afd32eb5   Dennis Dalessandro   IB/rdmavt: Add pr...
372
373
374
  	/* Internal use */
  	int n_pds_allocated;
  	spinlock_t n_pds_lock; /* Protect pd allocated count */
0b8a8aae0   Dennis Dalessandro   IB/rdmavt: Add th...
375

119a8e708   Kamal Heib   IB/rdmavt: Add AH...
376
377
  	int n_ahs_allocated;
  	spinlock_t n_ahs_lock; /* Protect ah allocated count */
b8f881b91   Jubin John   IB/rdmavt: Add sr...
378
379
  	u32 n_srqs_allocated;
  	spinlock_t n_srqs_lock; /* Protect srqs allocated count */
0b8a8aae0   Dennis Dalessandro   IB/rdmavt: Add th...
380
  	int flags;
f3d01bbcd   Dennis Dalessandro   IB/rdmavt: Add an...
381
  	struct rvt_ibport **ports;
0acb0cc7e   Dennis Dalessandro   IB/rdmavt: Initia...
382

515667f8f   Dennis Dalessandro   IB/rdmavt: Add cr...
383
  	/* QP */
0acb0cc7e   Dennis Dalessandro   IB/rdmavt: Initia...
384
  	struct rvt_qp_ibdev *qp_dev;
515667f8f   Dennis Dalessandro   IB/rdmavt: Add cr...
385
  	u32 n_qps_allocated;    /* number of QPs allocated for device */
bfee5e32e   Vennila Megavannan   IB/rdmavt, stagin...
386
387
388
  	u32 n_rc_qps;		/* number of RC QPs allocated for device */
  	u32 busy_jiffies;	/* timeout scaling based on RC QP count */
  	spinlock_t n_qps_lock;	/* protect qps, rc qps and busy jiffy counts */
822514d75   Dennis Dalessandro   IB/rdmavt: Add mm...
389
390
391
392
393
394
  
  	/* memory maps */
  	struct list_head pending_mmaps;
  	spinlock_t mmap_offset_lock; /* protect mmap_offset */
  	u32 mmap_offset;
  	spinlock_t pending_lock; /* protect pending mmap list */
6f6387ae7   Dennis Dalessandro   IB/rdmavt: Add co...
395
396
  
  	/* CQ */
6f6387ae7   Dennis Dalessandro   IB/rdmavt: Add co...
397
398
  	u32 n_cqs_allocated;    /* number of CQs allocated for device */
  	spinlock_t n_cqs_lock; /* protect count of in use cqs */
4e74080b2   Dennis Dalessandro   IB/rdmavt: Add mu...
399
400
401
402
  
  	/* Multicast */
  	u32 n_mcast_grps_allocated; /* number of mcast groups allocated */
  	spinlock_t n_mcast_grps_lock;
019f118b9   Brian Welty   IB/{hfi1, qib, rd...
403
404
  	/* Memory Working Set Size */
  	struct rvt_wss *wss;
0194621b2   Dennis Dalessandro   IB/rdmavt: Create...
405
  };
5084c8ff2   Michael J. Ruhl   IB/{rdmavt, hfi1,...
406
407
408
409
410
411
412
413
414
415
  /**
   * rvt_set_ibdev_name - Craft an IB device name from client info
   * @rdi: pointer to the client rvt_dev_info structure
   * @name: client specific name
   * @unit: client specific unit number.
   */
  static inline void rvt_set_ibdev_name(struct rvt_dev_info *rdi,
  				      const char *fmt, const char *name,
  				      const int unit)
  {
e349f858d   Jason Gunthorpe   RDMA: Fully setup...
416
417
418
419
420
421
422
423
  	/*
  	 * FIXME: rvt and its users want to touch the ibdev before
  	 * registration and have things like the name work. We don't have the
  	 * infrastructure in the core to support this directly today, hack it
  	 * to work by setting the name manually here.
  	 */
  	dev_set_name(&rdi->ibdev.dev, fmt, name, unit);
  	strlcpy(rdi->ibdev.name, dev_name(&rdi->ibdev.dev), IB_DEVICE_NAME_MAX);
5084c8ff2   Michael J. Ruhl   IB/{rdmavt, hfi1,...
424
  }
06f2597f7   Michael J. Ruhl   IB/{rdmavt, hfi1,...
425
426
427
428
429
430
431
432
  /**
   * rvt_get_ibdev_name - return the IB name
   * @rdi: rdmavt device
   *
   * Return the registered name of the device.
   */
  static inline const char *rvt_get_ibdev_name(const struct rvt_dev_info *rdi)
  {
6c8541118   Jason Gunthorpe   RDMA/ulp: Use dev...
433
  	return dev_name(&rdi->ibdev.dev);
06f2597f7   Michael J. Ruhl   IB/{rdmavt, hfi1,...
434
  }
8afd32eb5   Dennis Dalessandro   IB/rdmavt: Add pr...
435
436
437
438
  static inline struct rvt_pd *ibpd_to_rvtpd(struct ib_pd *ibpd)
  {
  	return container_of(ibpd, struct rvt_pd, ibpd);
  }
119a8e708   Kamal Heib   IB/rdmavt: Add AH...
439
440
441
442
  static inline struct rvt_ah *ibah_to_rvtah(struct ib_ah *ibah)
  {
  	return container_of(ibah, struct rvt_ah, ibah);
  }
8afd32eb5   Dennis Dalessandro   IB/rdmavt: Add pr...
443
444
445
446
  static inline struct rvt_dev_info *ib_to_rvt(struct ib_device *ibdev)
  {
  	return  container_of(ibdev, struct rvt_dev_info, ibdev);
  }
38ce2c6f3   Dennis Dalessandro   IB/rdmavt: Add pk...
447
448
449
450
451
452
453
454
455
  static inline unsigned rvt_get_npkeys(struct rvt_dev_info *rdi)
  {
  	/*
  	 * All ports have same number of pkeys.
  	 */
  	return rdi->dparms.npkeys;
  }
  
  /*
8b103e9cd   Mike Marciniszyn   IB/rdamvt: Fix rd...
456
457
458
459
460
   * Return the max atomic suitable for determining
   * the size of the ack ring buffer in a QP.
   */
  static inline unsigned int rvt_max_atomic(struct rvt_dev_info *rdi)
  {
ddf922c31   Kaike Wan   IB/hfi1, IB/rdmav...
461
462
463
464
465
466
467
468
  	return rdi->dparms.max_rdma_atomic +
  		rdi->dparms.extra_rdma_atomic + 1;
  }
  
  static inline unsigned int rvt_size_atomic(struct rvt_dev_info *rdi)
  {
  	return rdi->dparms.max_rdma_atomic +
  		rdi->dparms.extra_rdma_atomic;
8b103e9cd   Mike Marciniszyn   IB/rdamvt: Fix rd...
469
470
471
  }
  
  /*
38ce2c6f3   Dennis Dalessandro   IB/rdmavt: Add pk...
472
473
474
475
476
477
478
479
480
481
482
   * Return the indexed PKEY from the port PKEY table.
   */
  static inline u16 rvt_get_pkey(struct rvt_dev_info *rdi,
  			       int port_index,
  			       unsigned index)
  {
  	if (index >= rvt_get_npkeys(rdi))
  		return 0;
  	else
  		return rdi->ports[port_index]->pkey_table[index];
  }
ff6acd695   Dennis Dalessandro   IB/rdmavt: Add de...
483
  struct rvt_dev_info *rvt_alloc_device(size_t size, int nports);
ea0e4ce3b   Jubin John   IB/rdmavt,hfi1,qi...
484
  void rvt_dealloc_device(struct rvt_dev_info *rdi);
b9560a419   Jason Gunthorpe   RDMA: Move driver...
485
  int rvt_register_device(struct rvt_dev_info *rvd);
0194621b2   Dennis Dalessandro   IB/rdmavt: Create...
486
  void rvt_unregister_device(struct rvt_dev_info *rvd);
90898850e   Dasaratharaman Chandramouli   IB/core: Rename s...
487
  int rvt_check_ah(struct ib_device *ibdev, struct rdma_ah_attr *ah_attr);
38ce2c6f3   Dennis Dalessandro   IB/rdmavt: Add pk...
488
  int rvt_init_port(struct rvt_dev_info *rdi, struct rvt_ibport *port,
f1badc716   Dennis Dalessandro   IB/rdmavt: Clean ...
489
  		  int port_index, u16 *pkey_table);
e8f8b098a   Jianxin Xiong   IB/rdmavt: Add me...
490
491
492
  int rvt_fast_reg_mr(struct rvt_qp *qp, struct ib_mr *ibmr, u32 key,
  		    int access);
  int rvt_invalidate_rkey(struct rvt_qp *qp, u32 rkey);
7b1e2099a   Dennis Dalessandro   IB/rdmavt: Move m...
493
494
495
  int rvt_rkey_ok(struct rvt_qp *qp, struct rvt_sge *sge,
  		u32 len, u64 vaddr, u32 rkey, int acc);
  int rvt_lkey_ok(struct rvt_lkey_table *rkt, struct rvt_pd *pd,
14fe13fcd   Mike Marciniszyn   IB/rdmavt: Compre...
496
497
  		struct rvt_sge *isge, struct rvt_sge *last_sge,
  		struct ib_sge *sge, int acc);
aad9ff97d   Michael J. Ruhl   IB/rdmavt/hfi1/qi...
498
499
  struct rvt_mcast *rvt_mcast_find(struct rvt_ibport *ibp, union ib_gid *mgid,
  				 u16 lid);
822514d75   Dennis Dalessandro   IB/rdmavt: Add mm...
500

0194621b2   Dennis Dalessandro   IB/rdmavt: Create...
501
  #endif          /* DEF_RDMA_VT_H */