Skip to content

Commit b4e6439

Browse files
Dennis Dalessandrodledford
authored andcommitted
IB/rdmavt: Break rdma_vt main include header file up
Until all functionality is moved over to rdmavt drivers still need to access a number of fields in data structures that are predominantly meant to be used by rdmavt. Once these rdmavt_<ibta_object>.h header files are no longer being touched by drivers their content should be moved to rdmavt/<ibta_object>.h. While here move a couple #defines over to more general IB verbs header files because they fit better. Reviewed-by: Ira Weiny <[email protected]> Reviewed-by: Mike Marciniszyn <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent b036db8 commit b4e6439

File tree

5 files changed

+398
-308
lines changed

5 files changed

+398
-308
lines changed

drivers/infiniband/sw/rdmavt/ah.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ int rvt_check_ah(struct ib_device *ibdev,
7878
if (link != IB_LINK_LAYER_ETHERNET) {
7979
if (ah_attr->dlid == 0)
8080
return -EINVAL;
81-
if (ah_attr->dlid >= RVT_MULTICAST_LID_BASE &&
82-
ah_attr->dlid != RVT_PERMISSIVE_LID &&
81+
if (ah_attr->dlid >= be16_to_cpu(IB_MULTICAST_LID_BASE) &&
82+
ah_attr->dlid != be16_to_cpu(IB_LID_PERMISSIVE) &&
8383
!(ah_attr->ah_flags & IB_AH_GRH))
8484
return -EINVAL;
8585
}

include/rdma/ib_verbs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ enum {
613613
};
614614

615615
#define IB_LID_PERMISSIVE cpu_to_be16(0xFFFF)
616+
#define IB_MULTICAST_LID_BASE cpu_to_be16(0xC000)
616617

617618
enum ib_ah_flags {
618619
IB_AH_GRH = 1

include/rdma/rdma_vt.h

Lines changed: 3 additions & 306 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,9 @@
5555

5656
#include <linux/spinlock.h>
5757
#include <linux/list.h>
58-
#include "ib_verbs.h"
59-
60-
#define RVT_MULTICAST_LID_BASE 0xC000
61-
#define RVT_PERMISSIVE_LID 0xFFFF
58+
#include <rdma/ib_verbs.h>
59+
#include <rdma/rdmavt_mr.h>
60+
#include <rdma/rdmavt_qp.h>
6261

6362
/*
6463
* For some of the IBTA objects there will likely be some
@@ -70,297 +69,6 @@
7069
#define RVT_FLAG_QP_INIT_DRIVER BIT(2)
7170
#define RVT_FLAG_CQ_INIT_DRIVER BIT(3)
7271

73-
/*
74-
* For Memory Regions. This stuff should probably be moved into rdmavt/mr.h once
75-
* drivers no longer need access to the MR directly.
76-
*/
77-
78-
/*
79-
* A segment is a linear region of low physical memory.
80-
* Used by the verbs layer.
81-
*/
82-
struct rvt_seg {
83-
void *vaddr;
84-
size_t length;
85-
};
86-
87-
/* The number of rvt_segs that fit in a page. */
88-
#define RVT_SEGSZ (PAGE_SIZE / sizeof(struct rvt_seg))
89-
90-
struct rvt_segarray {
91-
struct rvt_seg segs[RVT_SEGSZ];
92-
};
93-
94-
struct rvt_mregion {
95-
struct ib_pd *pd; /* shares refcnt of ibmr.pd */
96-
u64 user_base; /* User's address for this region */
97-
u64 iova; /* IB start address of this region */
98-
size_t length;
99-
u32 lkey;
100-
u32 offset; /* offset (bytes) to start of region */
101-
int access_flags;
102-
u32 max_segs; /* number of rvt_segs in all the arrays */
103-
u32 mapsz; /* size of the map array */
104-
u8 page_shift; /* 0 - non unform/non powerof2 sizes */
105-
u8 lkey_published; /* in global table */
106-
struct completion comp; /* complete when refcount goes to zero */
107-
atomic_t refcount;
108-
struct rvt_segarray *map[0]; /* the segments */
109-
};
110-
111-
#define RVT_MAX_LKEY_TABLE_BITS 23
112-
113-
struct rvt_lkey_table {
114-
spinlock_t lock; /* protect changes in this struct */
115-
u32 next; /* next unused index (speeds search) */
116-
u32 gen; /* generation count */
117-
u32 max; /* size of the table */
118-
struct rvt_mregion __rcu **table;
119-
};
120-
121-
/* End Memmory Region */
122-
123-
/*
124-
* Things needed for the Queue Pair definition. Like the MR stuff above the
125-
* following should probably get moved to qp.h once drivers stop trying to make
126-
* and manipulate thier own QPs. For the few instnaces where a driver may need
127-
* to look into a queue pair there should be a pointer to a driver priavte data
128-
* structure that they can look at.
129-
*/
130-
131-
/*
132-
* These keep track of the copy progress within a memory region.
133-
* Used by the verbs layer.
134-
*/
135-
struct rvt_sge {
136-
struct rvt_mregion *mr;
137-
void *vaddr; /* kernel virtual address of segment */
138-
u32 sge_length; /* length of the SGE */
139-
u32 length; /* remaining length of the segment */
140-
u16 m; /* current index: mr->map[m] */
141-
u16 n; /* current index: mr->map[m]->segs[n] */
142-
};
143-
144-
/*
145-
* Send work request queue entry.
146-
* The size of the sg_list is determined when the QP is created and stored
147-
* in qp->s_max_sge.
148-
*/
149-
struct rvt_swqe {
150-
union {
151-
struct ib_send_wr wr; /* don't use wr.sg_list */
152-
struct ib_ud_wr ud_wr;
153-
struct ib_reg_wr reg_wr;
154-
struct ib_rdma_wr rdma_wr;
155-
struct ib_atomic_wr atomic_wr;
156-
};
157-
u32 psn; /* first packet sequence number */
158-
u32 lpsn; /* last packet sequence number */
159-
u32 ssn; /* send sequence number */
160-
u32 length; /* total length of data in sg_list */
161-
struct rvt_sge sg_list[0];
162-
};
163-
164-
/*
165-
* Receive work request queue entry.
166-
* The size of the sg_list is determined when the QP (or SRQ) is created
167-
* and stored in qp->r_rq.max_sge (or srq->rq.max_sge).
168-
*/
169-
struct rvt_rwqe {
170-
u64 wr_id;
171-
u8 num_sge;
172-
struct ib_sge sg_list[0];
173-
};
174-
175-
/*
176-
* This structure is used to contain the head pointer, tail pointer,
177-
* and receive work queue entries as a single memory allocation so
178-
* it can be mmap'ed into user space.
179-
* Note that the wq array elements are variable size so you can't
180-
* just index into the array to get the N'th element;
181-
* use get_rwqe_ptr() instead.
182-
*/
183-
struct rvt_rwq {
184-
u32 head; /* new work requests posted to the head */
185-
u32 tail; /* receives pull requests from here. */
186-
struct rvt_rwqe wq[0];
187-
};
188-
189-
struct rvt_rq {
190-
struct rvt_rwq *wq;
191-
u32 size; /* size of RWQE array */
192-
u8 max_sge;
193-
/* protect changes in this struct */
194-
spinlock_t lock ____cacheline_aligned_in_smp;
195-
};
196-
197-
/*
198-
* This structure is used by rvt_mmap() to validate an offset
199-
* when an mmap() request is made. The vm_area_struct then uses
200-
* this as its vm_private_data.
201-
*/
202-
struct rvt_mmap_info {
203-
struct list_head pending_mmaps;
204-
struct ib_ucontext *context;
205-
void *obj;
206-
__u64 offset;
207-
struct kref ref;
208-
unsigned size;
209-
};
210-
211-
#define RVT_MAX_RDMA_ATOMIC 16
212-
213-
/*
214-
* This structure holds the information that the send tasklet needs
215-
* to send a RDMA read response or atomic operation.
216-
*/
217-
struct rvt_ack_entry {
218-
u8 opcode;
219-
u8 sent;
220-
u32 psn;
221-
u32 lpsn;
222-
union {
223-
struct rvt_sge rdma_sge;
224-
u64 atomic_data;
225-
};
226-
};
227-
228-
struct rvt_sge_state {
229-
struct rvt_sge *sg_list; /* next SGE to be used if any */
230-
struct rvt_sge sge; /* progress state for the current SGE */
231-
u32 total_len;
232-
u8 num_sge;
233-
};
234-
235-
/*
236-
* Variables prefixed with s_ are for the requester (sender).
237-
* Variables prefixed with r_ are for the responder (receiver).
238-
* Variables prefixed with ack_ are for responder replies.
239-
*
240-
* Common variables are protected by both r_rq.lock and s_lock in that order
241-
* which only happens in modify_qp() or changing the QP 'state'.
242-
*/
243-
struct rvt_qp {
244-
struct ib_qp ibqp;
245-
void *priv; /* Driver private data */
246-
/* read mostly fields above and below */
247-
struct ib_ah_attr remote_ah_attr;
248-
struct ib_ah_attr alt_ah_attr;
249-
struct rvt_qp __rcu *next; /* link list for QPN hash table */
250-
struct rvt_swqe *s_wq; /* send work queue */
251-
struct rvt_mmap_info *ip;
252-
253-
unsigned long timeout_jiffies; /* computed from timeout */
254-
255-
enum ib_mtu path_mtu;
256-
int srate_mbps; /* s_srate (below) converted to Mbit/s */
257-
u32 remote_qpn;
258-
u32 pmtu; /* decoded from path_mtu */
259-
u32 qkey; /* QKEY for this QP (for UD or RD) */
260-
u32 s_size; /* send work queue size */
261-
u32 s_rnr_timeout; /* number of milliseconds for RNR timeout */
262-
u32 s_ahgpsn; /* set to the psn in the copy of the header */
263-
264-
u8 state; /* QP state */
265-
u8 allowed_ops; /* high order bits of allowed opcodes */
266-
u8 qp_access_flags;
267-
u8 alt_timeout; /* Alternate path timeout for this QP */
268-
u8 timeout; /* Timeout for this QP */
269-
u8 s_srate;
270-
u8 s_mig_state;
271-
u8 port_num;
272-
u8 s_pkey_index; /* PKEY index to use */
273-
u8 s_alt_pkey_index; /* Alternate path PKEY index to use */
274-
u8 r_max_rd_atomic; /* max number of RDMA read/atomic to receive */
275-
u8 s_max_rd_atomic; /* max number of RDMA read/atomic to send */
276-
u8 s_retry_cnt; /* number of times to retry */
277-
u8 s_rnr_retry_cnt;
278-
u8 r_min_rnr_timer; /* retry timeout value for RNR NAKs */
279-
u8 s_max_sge; /* size of s_wq->sg_list */
280-
u8 s_draining;
281-
282-
/* start of read/write fields */
283-
atomic_t refcount ____cacheline_aligned_in_smp;
284-
wait_queue_head_t wait;
285-
286-
struct rvt_ack_entry s_ack_queue[RVT_MAX_RDMA_ATOMIC + 1]
287-
____cacheline_aligned_in_smp;
288-
struct rvt_sge_state s_rdma_read_sge;
289-
290-
spinlock_t r_lock ____cacheline_aligned_in_smp; /* used for APM */
291-
unsigned long r_aflags;
292-
u64 r_wr_id; /* ID for current receive WQE */
293-
u32 r_ack_psn; /* PSN for next ACK or atomic ACK */
294-
u32 r_len; /* total length of r_sge */
295-
u32 r_rcv_len; /* receive data len processed */
296-
u32 r_psn; /* expected rcv packet sequence number */
297-
u32 r_msn; /* message sequence number */
298-
299-
u8 r_state; /* opcode of last packet received */
300-
u8 r_flags;
301-
u8 r_head_ack_queue; /* index into s_ack_queue[] */
302-
303-
struct list_head rspwait; /* link for waiting to respond */
304-
305-
struct rvt_sge_state r_sge; /* current receive data */
306-
struct rvt_rq r_rq; /* receive work queue */
307-
308-
spinlock_t s_lock ____cacheline_aligned_in_smp;
309-
struct rvt_sge_state *s_cur_sge;
310-
u32 s_flags;
311-
struct rvt_swqe *s_wqe;
312-
struct rvt_sge_state s_sge; /* current send request data */
313-
struct rvt_mregion *s_rdma_mr;
314-
struct sdma_engine *s_sde; /* current sde */
315-
u32 s_cur_size; /* size of send packet in bytes */
316-
u32 s_len; /* total length of s_sge */
317-
u32 s_rdma_read_len; /* total length of s_rdma_read_sge */
318-
u32 s_next_psn; /* PSN for next request */
319-
u32 s_last_psn; /* last response PSN processed */
320-
u32 s_sending_psn; /* lowest PSN that is being sent */
321-
u32 s_sending_hpsn; /* highest PSN that is being sent */
322-
u32 s_psn; /* current packet sequence number */
323-
u32 s_ack_rdma_psn; /* PSN for sending RDMA read responses */
324-
u32 s_ack_psn; /* PSN for acking sends and RDMA writes */
325-
u32 s_head; /* new entries added here */
326-
u32 s_tail; /* next entry to process */
327-
u32 s_cur; /* current work queue entry */
328-
u32 s_acked; /* last un-ACK'ed entry */
329-
u32 s_last; /* last completed entry */
330-
u32 s_ssn; /* SSN of tail entry */
331-
u32 s_lsn; /* limit sequence number (credit) */
332-
u16 s_hdrwords; /* size of s_hdr in 32 bit words */
333-
u16 s_rdma_ack_cnt;
334-
s8 s_ahgidx;
335-
u8 s_state; /* opcode of last packet sent */
336-
u8 s_ack_state; /* opcode of packet to ACK */
337-
u8 s_nak_state; /* non-zero if NAK is pending */
338-
u8 r_nak_state; /* non-zero if NAK is pending */
339-
u8 s_retry; /* requester retry counter */
340-
u8 s_rnr_retry; /* requester RNR retry counter */
341-
u8 s_num_rd_atomic; /* number of RDMA read/atomic pending */
342-
u8 s_tail_ack_queue; /* index into s_ack_queue[] */
343-
344-
struct rvt_sge_state s_ack_rdma_sge;
345-
struct timer_list s_timer;
346-
347-
/*
348-
* This sge list MUST be last. Do not add anything below here.
349-
*/
350-
struct rvt_sge r_sg_list[0] /* verified SGEs */
351-
____cacheline_aligned_in_smp;
352-
};
353-
354-
struct rvt_srq {
355-
struct ib_srq ibsrq;
356-
struct rvt_rq rq;
357-
struct rvt_mmap_info *ip;
358-
/* send signal when number of RWQEs < limit */
359-
u32 limit;
360-
};
361-
362-
/* End QP section */
363-
36472
struct rvt_ibport {
36573
struct rvt_qp __rcu *qp[2];
36674
struct ib_mad_agent *send_agent; /* agent for SMI (traps) */
@@ -554,17 +262,6 @@ static inline struct rvt_dev_info *ib_to_rvt(struct ib_device *ibdev)
554262
return container_of(ibdev, struct rvt_dev_info, ibdev);
555263
}
556264

557-
static inline void rvt_put_mr(struct rvt_mregion *mr)
558-
{
559-
if (unlikely(atomic_dec_and_test(&mr->refcount)))
560-
complete(&mr->comp);
561-
}
562-
563-
static inline void rvt_get_mr(struct rvt_mregion *mr)
564-
{
565-
atomic_inc(&mr->refcount);
566-
}
567-
568265
static inline struct rvt_srq *ibsrq_to_rvtsrq(struct ib_srq *ibsrq)
569266
{
570267
return container_of(ibsrq, struct rvt_srq, ibsrq);

0 commit comments

Comments
 (0)