Skip to content

Commit 937488a

Browse files
kwan-intcjgunthorpe
authored andcommitted
IB/hfi1: Dump pio info for non-user send contexts
This patch dumps the pio info for non-user send contexts to assist debugging in the field. Reviewed-by: Mike Marciniczyn <[email protected]> Reviewed-by: Mike Ruhl <[email protected]> Signed-off-by: Kaike Wan <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 81fce62 commit 937488a

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed

drivers/infiniband/hw/hfi1/chip_registers.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,10 @@
935935
#define SEND_CTXT_CREDIT_CTRL_THRESHOLD_MASK 0x7FFull
936936
#define SEND_CTXT_CREDIT_CTRL_THRESHOLD_SHIFT 0
937937
#define SEND_CTXT_CREDIT_CTRL_THRESHOLD_SMASK 0x7FFull
938+
#define SEND_CTXT_CREDIT_STATUS (TXE + 0x000000100018)
939+
#define SEND_CTXT_CREDIT_STATUS_CURRENT_FREE_COUNTER_MASK 0x7FFull
940+
#define SEND_CTXT_CREDIT_STATUS_CURRENT_FREE_COUNTER_SHIFT 32
941+
#define SEND_CTXT_CREDIT_STATUS_LAST_RETURNED_COUNTER_SMASK 0x7FFull
938942
#define SEND_CTXT_CREDIT_FORCE (TXE + 0x000000100028)
939943
#define SEND_CTXT_CREDIT_FORCE_FORCE_RETURN_SMASK 0x1ull
940944
#define SEND_CTXT_CREDIT_RETURN_ADDR (TXE + 0x000000100020)

drivers/infiniband/hw/hfi1/debugfs.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,54 @@ DEBUGFS_SEQ_FILE_OPS(rcds);
407407
DEBUGFS_SEQ_FILE_OPEN(rcds)
408408
DEBUGFS_FILE_OPS(rcds);
409409

410+
static void *_pios_seq_start(struct seq_file *s, loff_t *pos)
411+
{
412+
struct hfi1_ibdev *ibd;
413+
struct hfi1_devdata *dd;
414+
415+
ibd = (struct hfi1_ibdev *)s->private;
416+
dd = dd_from_dev(ibd);
417+
if (!dd->send_contexts || *pos >= dd->num_send_contexts)
418+
return NULL;
419+
return pos;
420+
}
421+
422+
static void *_pios_seq_next(struct seq_file *s, void *v, loff_t *pos)
423+
{
424+
struct hfi1_ibdev *ibd = (struct hfi1_ibdev *)s->private;
425+
struct hfi1_devdata *dd = dd_from_dev(ibd);
426+
427+
++*pos;
428+
if (!dd->send_contexts || *pos >= dd->num_send_contexts)
429+
return NULL;
430+
return pos;
431+
}
432+
433+
static void _pios_seq_stop(struct seq_file *s, void *v)
434+
{
435+
}
436+
437+
static int _pios_seq_show(struct seq_file *s, void *v)
438+
{
439+
struct hfi1_ibdev *ibd = (struct hfi1_ibdev *)s->private;
440+
struct hfi1_devdata *dd = dd_from_dev(ibd);
441+
struct send_context_info *sci;
442+
loff_t *spos = v;
443+
loff_t i = *spos;
444+
unsigned long flags;
445+
446+
spin_lock_irqsave(&dd->sc_lock, flags);
447+
sci = &dd->send_contexts[i];
448+
if (sci && sci->type != SC_USER && sci->allocated && sci->sc)
449+
seqfile_dump_sci(s, i, sci);
450+
spin_unlock_irqrestore(&dd->sc_lock, flags);
451+
return 0;
452+
}
453+
454+
DEBUGFS_SEQ_FILE_OPS(pios);
455+
DEBUGFS_SEQ_FILE_OPEN(pios)
456+
DEBUGFS_FILE_OPS(pios);
457+
410458
/* read the per-device counters */
411459
static ssize_t dev_counters_read(struct file *file, char __user *buf,
412460
size_t count, loff_t *ppos)
@@ -1143,6 +1191,7 @@ void hfi1_dbg_ibdev_init(struct hfi1_ibdev *ibd)
11431191
DEBUGFS_SEQ_FILE_CREATE(qp_stats, ibd->hfi1_ibdev_dbg, ibd);
11441192
DEBUGFS_SEQ_FILE_CREATE(sdes, ibd->hfi1_ibdev_dbg, ibd);
11451193
DEBUGFS_SEQ_FILE_CREATE(rcds, ibd->hfi1_ibdev_dbg, ibd);
1194+
DEBUGFS_SEQ_FILE_CREATE(pios, ibd->hfi1_ibdev_dbg, ibd);
11461195
DEBUGFS_SEQ_FILE_CREATE(sdma_cpu_list, ibd->hfi1_ibdev_dbg, ibd);
11471196
/* dev counter files */
11481197
for (i = 0; i < ARRAY_SIZE(cntr_ops); i++)

drivers/infiniband/hw/hfi1/pio.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,3 +2137,28 @@ void free_credit_return(struct hfi1_devdata *dd)
21372137
kfree(dd->cr_base);
21382138
dd->cr_base = NULL;
21392139
}
2140+
2141+
void seqfile_dump_sci(struct seq_file *s, u32 i,
2142+
struct send_context_info *sci)
2143+
{
2144+
struct send_context *sc = sci->sc;
2145+
u64 reg;
2146+
2147+
seq_printf(s, "SCI %u: type %u base %u credits %u\n",
2148+
i, sci->type, sci->base, sci->credits);
2149+
seq_printf(s, " flags 0x%x sw_inx %u hw_ctxt %u grp %u\n",
2150+
sc->flags, sc->sw_index, sc->hw_context, sc->group);
2151+
seq_printf(s, " sr_size %u credits %u sr_head %u sr_tail %u\n",
2152+
sc->sr_size, sc->credits, sc->sr_head, sc->sr_tail);
2153+
seq_printf(s, " fill %lu free %lu fill_wrap %u alloc_free %lu\n",
2154+
sc->fill, sc->free, sc->fill_wrap, sc->alloc_free);
2155+
seq_printf(s, " credit_intr_count %u credit_ctrl 0x%llx\n",
2156+
sc->credit_intr_count, sc->credit_ctrl);
2157+
reg = read_kctxt_csr(sc->dd, sc->hw_context, SC(CREDIT_STATUS));
2158+
seq_printf(s, " *hw_free %llu CurrentFree %llu LastReturned %llu\n",
2159+
(le64_to_cpu(*sc->hw_free) & CR_COUNTER_SMASK) >>
2160+
CR_COUNTER_SHIFT,
2161+
(reg >> SC(CREDIT_STATUS_CURRENT_FREE_COUNTER_SHIFT)) &
2162+
SC(CREDIT_STATUS_CURRENT_FREE_COUNTER_MASK),
2163+
reg & SC(CREDIT_STATUS_LAST_RETURNED_COUNTER_SMASK));
2164+
}

drivers/infiniband/hw/hfi1/pio.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,4 +329,7 @@ void seg_pio_copy_start(struct pio_buf *pbuf, u64 pbc,
329329
void seg_pio_copy_mid(struct pio_buf *pbuf, const void *from, size_t nbytes);
330330
void seg_pio_copy_end(struct pio_buf *pbuf);
331331

332+
void seqfile_dump_sci(struct seq_file *s, u32 i,
333+
struct send_context_info *sci);
334+
332335
#endif /* _PIO_H */

0 commit comments

Comments
 (0)