IB/hfi1: Add tx_opcode_stats like the opcode_stats

This patch adds tx_opcode_stats to parallel the
(rx)opcode_stats in the debugfs.

Reviewed-by: Kaike Wan <kaike.wan@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
Mike Marciniszyn 2017-10-23 06:06:08 -07:00 committed by Doug Ledford
parent 406310c66d
commit 1b311f8931
4 changed files with 83 additions and 10 deletions

View File

@ -165,6 +165,17 @@ static void _opcode_stats_seq_stop(struct seq_file *s, void *v)
{
}
static int opcode_stats_show(struct seq_file *s, u8 i, u64 packets, u64 bytes)
{
if (!packets && !bytes)
return SEQ_SKIP;
seq_printf(s, "%02x %llu/%llu\n", i,
(unsigned long long)packets,
(unsigned long long)bytes);
return 0;
}
static int _opcode_stats_seq_show(struct seq_file *s, void *v)
{
loff_t *spos = v;
@ -182,19 +193,49 @@ static int _opcode_stats_seq_show(struct seq_file *s, void *v)
}
hfi1_rcd_put(rcd);
}
if (!n_packets && !n_bytes)
return SEQ_SKIP;
seq_printf(s, "%02llx %llu/%llu\n", i,
(unsigned long long)n_packets,
(unsigned long long)n_bytes);
return 0;
return opcode_stats_show(s, i, n_packets, n_bytes);
}
DEBUGFS_SEQ_FILE_OPS(opcode_stats);
DEBUGFS_SEQ_FILE_OPEN(opcode_stats)
DEBUGFS_FILE_OPS(opcode_stats);
static void *_tx_opcode_stats_seq_start(struct seq_file *s, loff_t *pos)
{
return _opcode_stats_seq_start(s, pos);
}
static void *_tx_opcode_stats_seq_next(struct seq_file *s, void *v, loff_t *pos)
{
return _opcode_stats_seq_next(s, v, pos);
}
static void _tx_opcode_stats_seq_stop(struct seq_file *s, void *v)
{
}
static int _tx_opcode_stats_seq_show(struct seq_file *s, void *v)
{
loff_t *spos = v;
loff_t i = *spos;
int j;
u64 n_packets = 0, n_bytes = 0;
struct hfi1_ibdev *ibd = (struct hfi1_ibdev *)s->private;
struct hfi1_devdata *dd = dd_from_dev(ibd);
for_each_possible_cpu(j) {
struct hfi1_opcode_stats_perctx *s =
per_cpu_ptr(dd->tx_opstats, j);
n_packets += s->stats[i].n_packets;
n_bytes += s->stats[i].n_bytes;
}
return opcode_stats_show(s, i, n_packets, n_bytes);
}
DEBUGFS_SEQ_FILE_OPS(tx_opcode_stats);
DEBUGFS_SEQ_FILE_OPEN(tx_opcode_stats)
DEBUGFS_FILE_OPS(tx_opcode_stats);
static void *_ctx_stats_seq_start(struct seq_file *s, loff_t *pos)
{
struct hfi1_ibdev *ibd = (struct hfi1_ibdev *)s->private;
@ -1363,6 +1404,7 @@ void hfi1_dbg_ibdev_init(struct hfi1_ibdev *ibd)
return;
}
DEBUGFS_SEQ_FILE_CREATE(opcode_stats, ibd->hfi1_ibdev_dbg, ibd);
DEBUGFS_SEQ_FILE_CREATE(tx_opcode_stats, ibd->hfi1_ibdev_dbg, ibd);
DEBUGFS_SEQ_FILE_CREATE(ctx_stats, ibd->hfi1_ibdev_dbg, ibd);
DEBUGFS_SEQ_FILE_CREATE(qp_stats, ibd->hfi1_ibdev_dbg, ibd);
DEBUGFS_SEQ_FILE_CREATE(sdes, ibd->hfi1_ibdev_dbg, ibd);

View File

@ -164,9 +164,7 @@ extern const struct pci_error_handlers hfi1_pci_err_handler;
* Below contains all data related to a single context (formerly called port).
*/
#ifdef CONFIG_DEBUG_FS
struct hfi1_opcode_stats_perctx;
#endif
struct ctxt_eager_bufs {
ssize_t size; /* total size of eager buffers */
@ -283,7 +281,7 @@ struct hfi1_ctxtdata {
u64 imask; /* clear interrupt mask */
int ireg; /* clear interrupt register */
unsigned numa_id; /* numa node of this context */
/* verbs stats per CTX */
/* verbs rx_stats per rcd */
struct hfi1_opcode_stats_perctx *opstats;
/* Is ASPM interrupt supported for this context */
@ -1276,6 +1274,8 @@ struct hfi1_devdata {
/* receive context data */
struct hfi1_ctxtdata **rcd;
u64 __percpu *int_counter;
/* verbs tx opcode stats */
struct hfi1_opcode_stats_perctx __percpu *tx_opstats;
/* device (not port) flags, basically device capabilities */
u16 flags;
/* Number of physical ports available */

View File

@ -1217,6 +1217,7 @@ static void __hfi1_free_devdata(struct kobject *kobj)
free_percpu(dd->int_counter);
free_percpu(dd->rcv_limit);
free_percpu(dd->send_schedule);
free_percpu(dd->tx_opstats);
rvt_dealloc_device(&dd->verbs_dev.rdi);
}
@ -1306,6 +1307,12 @@ struct hfi1_devdata *hfi1_alloc_devdata(struct pci_dev *pdev, size_t extra)
goto bail;
}
dd->tx_opstats = alloc_percpu(struct hfi1_opcode_stats_perctx);
if (!dd->tx_opstats) {
ret = -ENOMEM;
goto bail;
}
kobject_init(&dd->kobj, &hfi1_devdata_type);
return dd;

View File

@ -796,6 +796,27 @@ static noinline int build_verbs_ulp_payload(
return ret;
}
/**
* update_tx_opstats - record stats by opcode
* @qp; the qp
* @ps: transmit packet state
* @plen: the plen in dwords
*
* This is a routine to record the tx opstats after a
* packet has been presented to the egress mechanism.
*/
static void update_tx_opstats(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
u32 plen)
{
#ifdef CONFIG_DEBUG_FS
struct hfi1_devdata *dd = dd_from_ibdev(qp->ibqp.device);
struct hfi1_opcode_stats_perctx *s = get_cpu_ptr(dd->tx_opstats);
inc_opstats(plen * 4, &s->stats[ps->opcode]);
put_cpu_ptr(s);
#endif
}
/*
* Build the number of DMA descriptors needed to send length bytes of data.
*
@ -934,6 +955,8 @@ int hfi1_verbs_send_dma(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
goto bail_ecomm;
return ret;
}
update_tx_opstats(qp, ps, plen);
trace_sdma_output_ibhdr(dd_from_ibdev(qp->ibqp.device),
&ps->s_txreq->phdr.hdr, ib_is_sc5(sc5));
return ret;
@ -1127,6 +1150,7 @@ int hfi1_verbs_send_pio(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
seg_pio_copy_end(pbuf);
}
update_tx_opstats(qp, ps, plen);
trace_pio_output_ibhdr(dd_from_ibdev(qp->ibqp.device),
&ps->s_txreq->phdr.hdr, ib_is_sc5(sc5));