Skip to content

Commit f3d01bb

Browse files
Dennis Dalessandrodledford
authored andcommitted
IB/rdmavt: Add an ibport data structure to rdmavt
Converge the ibport data structures of qib and hfi1 into a common ib port structure. Also provides a place to keep track of these ports in case rdmavt needs it. Along with this goes an attach and detach function for drivers to use to notify rdmavt of the ports. Reviewed-by: Ira Weiny <[email protected]> Reviewed-by: Harish Chegondi <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent 70a1a35 commit f3d01bb

File tree

2 files changed

+89
-1
lines changed

2 files changed

+89
-1
lines changed

drivers/infiniband/sw/rdmavt/vt.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,19 @@ int rvt_register_device(struct rvt_dev_info *rdi)
300300
spin_lock_init(&rdi->n_pds_lock);
301301
rdi->n_pds_allocated = 0;
302302

303+
if (rdi->dparms.nports) {
304+
rdi->ports = kcalloc(rdi->dparms.nports,
305+
sizeof(struct rvt_ibport **),
306+
GFP_KERNEL);
307+
if (!rdi->ports) {
308+
rvt_pr_err(rdi, "Could not allocate port mem.\n");
309+
ret = -ENOMEM;
310+
goto bail_mr;
311+
}
312+
} else {
313+
rvt_pr_warn(rdi, "Driver says it has no ports.\n");
314+
}
315+
303316
/* We are now good to announce we exist */
304317
ret = ib_register_device(&rdi->ibdev, rdi->driver_f.port_callback);
305318
if (ret) {
@@ -327,3 +340,14 @@ void rvt_unregister_device(struct rvt_dev_info *rdi)
327340
rvt_mr_exit(rdi);
328341
}
329342
EXPORT_SYMBOL(rvt_unregister_device);
343+
344+
/*
345+
* Keep track of a list of ports. No need to have a detach port.
346+
* They persist until the driver goes away.
347+
*/
348+
void rvt_attach_port(struct rvt_dev_info *rdi, struct rvt_ibport *port,
349+
int portnum)
350+
{
351+
rdi->ports[portnum] = port;
352+
}
353+
EXPORT_SYMBOL(rvt_attach_port);

include/rdma/rdma_vt.h

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
* rdmavt layer.
5454
*/
5555

56+
#include <linux/spinlock.h>
57+
#include <linux/list.h>
5658
#include "ib_verbs.h"
5759

5860
#define RVT_MULTICAST_LID_BASE 0xC000
@@ -359,6 +361,65 @@ struct rvt_srq {
359361

360362
/* End QP section */
361363

364+
struct rvt_ibport {
365+
struct rvt_qp __rcu *qp[2];
366+
struct ib_mad_agent *send_agent; /* agent for SMI (traps) */
367+
struct rb_root mcast_tree;
368+
spinlock_t lock; /* protect changes in this struct */
369+
370+
/* non-zero when timer is set */
371+
unsigned long mkey_lease_timeout;
372+
unsigned long trap_timeout;
373+
__be64 gid_prefix; /* in network order */
374+
__be64 mkey;
375+
u64 tid;
376+
u32 port_cap_flags;
377+
u32 pma_sample_start;
378+
u32 pma_sample_interval;
379+
__be16 pma_counter_select[5];
380+
u16 pma_tag;
381+
u16 mkey_lease_period;
382+
u16 sm_lid;
383+
u8 sm_sl;
384+
u8 mkeyprot;
385+
u8 subnet_timeout;
386+
u8 vl_high_limit;
387+
388+
/*
389+
* Driver is expected to keep these up to date. These
390+
* counters are informational only and not required to be
391+
* completely accurate.
392+
*/
393+
u64 n_rc_resends;
394+
u64 n_seq_naks;
395+
u64 n_rdma_seq;
396+
u64 n_rnr_naks;
397+
u64 n_other_naks;
398+
u64 n_loop_pkts;
399+
u64 n_pkt_drops;
400+
u64 n_vl15_dropped;
401+
u64 n_rc_timeouts;
402+
u64 n_dmawait;
403+
u64 n_unaligned;
404+
u64 n_rc_dupreq;
405+
u64 n_rc_seqnak;
406+
u16 pkey_violations;
407+
u16 qkey_violations;
408+
u16 mkey_violations;
409+
410+
/* Hot-path per CPU counters to avoid cacheline trading to update */
411+
u64 z_rc_acks;
412+
u64 z_rc_qacks;
413+
u64 z_rc_delayed_comp;
414+
u64 __percpu *rc_acks;
415+
u64 __percpu *rc_qacks;
416+
u64 __percpu *rc_delayed_comp;
417+
418+
void *priv; /* driver private data */
419+
420+
/* TODO: Move sm_ah and smi_ah into here as well*/
421+
};
422+
362423
/*
363424
* Things that are driver specific, module parameters in hfi1 and qib
364425
*/
@@ -403,6 +464,7 @@ struct rvt_driver_params {
403464
* For instance special module parameters. Goes here.
404465
*/
405466
unsigned int lkey_table_size;
467+
int nports;
406468
};
407469

408470
/*
@@ -465,6 +527,7 @@ struct rvt_dev_info {
465527
spinlock_t n_ahs_lock; /* Protect ah allocated count */
466528

467529
int flags;
530+
struct rvt_ibport **ports;
468531
};
469532

470533
static inline struct rvt_pd *ibpd_to_rvtpd(struct ib_pd *ibpd)
@@ -501,9 +564,10 @@ static inline struct rvt_srq *ibsrq_to_rvtsrq(struct ib_srq *ibsrq)
501564
int rvt_register_device(struct rvt_dev_info *rvd);
502565
void rvt_unregister_device(struct rvt_dev_info *rvd);
503566
int rvt_check_ah(struct ib_device *ibdev, struct ib_ah_attr *ah_attr);
567+
void rvt_attach_port(struct rvt_dev_info *rdi, struct rvt_ibport *port,
568+
int portnum);
504569
int rvt_rkey_ok(struct rvt_qp *qp, struct rvt_sge *sge,
505570
u32 len, u64 vaddr, u32 rkey, int acc);
506571
int rvt_lkey_ok(struct rvt_lkey_table *rkt, struct rvt_pd *pd,
507572
struct rvt_sge *isge, struct ib_sge *sge, int acc);
508-
509573
#endif /* DEF_RDMA_VT_H */

0 commit comments

Comments
 (0)