2019-09-04 06:28:05 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/* Copyright(c) 2017 - 2019 Pensando Systems, Inc */
|
|
|
|
|
2019-09-04 06:28:07 +08:00
|
|
|
#include <linux/pci.h>
|
2019-09-04 06:28:05 +08:00
|
|
|
#include <linux/netdevice.h>
|
|
|
|
|
|
|
|
#include "ionic.h"
|
|
|
|
#include "ionic_bus.h"
|
2019-09-04 06:28:07 +08:00
|
|
|
#include "ionic_lif.h"
|
2019-09-04 06:28:05 +08:00
|
|
|
#include "ionic_debugfs.h"
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
|
|
|
|
|
|
static struct dentry *ionic_dir;
|
|
|
|
|
|
|
|
void ionic_debugfs_create(void)
|
|
|
|
{
|
|
|
|
ionic_dir = debugfs_create_dir(IONIC_DRV_NAME, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ionic_debugfs_destroy(void)
|
|
|
|
{
|
|
|
|
debugfs_remove_recursive(ionic_dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ionic_debugfs_add_dev(struct ionic *ionic)
|
|
|
|
{
|
|
|
|
ionic->dentry = debugfs_create_dir(ionic_bus_info(ionic), ionic_dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ionic_debugfs_del_dev(struct ionic *ionic)
|
|
|
|
{
|
|
|
|
debugfs_remove_recursive(ionic->dentry);
|
|
|
|
ionic->dentry = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int identity_show(struct seq_file *seq, void *v)
|
|
|
|
{
|
|
|
|
struct ionic *ionic = seq->private;
|
|
|
|
struct ionic_identity *ident;
|
|
|
|
|
|
|
|
ident = &ionic->ident;
|
|
|
|
|
|
|
|
seq_printf(seq, "nlifs: %d\n", ident->dev.nlifs);
|
|
|
|
seq_printf(seq, "nintrs: %d\n", ident->dev.nintrs);
|
|
|
|
seq_printf(seq, "ndbpgs_per_lif: %d\n", ident->dev.ndbpgs_per_lif);
|
|
|
|
seq_printf(seq, "intr_coal_mult: %d\n", ident->dev.intr_coal_mult);
|
|
|
|
seq_printf(seq, "intr_coal_div: %d\n", ident->dev.intr_coal_div);
|
|
|
|
|
|
|
|
seq_printf(seq, "max_ucast_filters: %d\n", ident->lif.eth.max_ucast_filters);
|
|
|
|
seq_printf(seq, "max_mcast_filters: %d\n", ident->lif.eth.max_mcast_filters);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
DEFINE_SHOW_ATTRIBUTE(identity);
|
|
|
|
|
|
|
|
void ionic_debugfs_add_ident(struct ionic *ionic)
|
|
|
|
{
|
|
|
|
debugfs_create_file("identity", 0400, ionic->dentry,
|
2019-09-18 07:26:16 +08:00
|
|
|
ionic, &identity_fops);
|
2019-09-04 06:28:05 +08:00
|
|
|
}
|
|
|
|
|
2019-09-04 06:28:07 +08:00
|
|
|
void ionic_debugfs_add_sizes(struct ionic *ionic)
|
|
|
|
{
|
|
|
|
debugfs_create_u32("nlifs", 0400, ionic->dentry,
|
|
|
|
(u32 *)&ionic->ident.dev.nlifs);
|
|
|
|
debugfs_create_u32("nintrs", 0400, ionic->dentry, &ionic->nintrs);
|
|
|
|
|
|
|
|
debugfs_create_u32("ntxqs_per_lif", 0400, ionic->dentry,
|
|
|
|
(u32 *)&ionic->ident.lif.eth.config.queue_count[IONIC_QTYPE_TXQ]);
|
|
|
|
debugfs_create_u32("nrxqs_per_lif", 0400, ionic->dentry,
|
|
|
|
(u32 *)&ionic->ident.lif.eth.config.queue_count[IONIC_QTYPE_RXQ]);
|
|
|
|
}
|
|
|
|
|
2019-09-04 06:28:09 +08:00
|
|
|
static int q_tail_show(struct seq_file *seq, void *v)
|
|
|
|
{
|
|
|
|
struct ionic_queue *q = seq->private;
|
|
|
|
|
2020-08-28 07:00:26 +08:00
|
|
|
seq_printf(seq, "%d\n", q->tail_idx);
|
2019-09-04 06:28:09 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
DEFINE_SHOW_ATTRIBUTE(q_tail);
|
|
|
|
|
|
|
|
static int q_head_show(struct seq_file *seq, void *v)
|
|
|
|
{
|
|
|
|
struct ionic_queue *q = seq->private;
|
|
|
|
|
2020-08-28 07:00:26 +08:00
|
|
|
seq_printf(seq, "%d\n", q->head_idx);
|
2019-09-04 06:28:09 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
DEFINE_SHOW_ATTRIBUTE(q_head);
|
|
|
|
|
|
|
|
static int cq_tail_show(struct seq_file *seq, void *v)
|
|
|
|
{
|
|
|
|
struct ionic_cq *cq = seq->private;
|
|
|
|
|
2020-08-28 07:00:26 +08:00
|
|
|
seq_printf(seq, "%d\n", cq->tail_idx);
|
2019-09-04 06:28:09 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
DEFINE_SHOW_ATTRIBUTE(cq_tail);
|
|
|
|
|
|
|
|
static const struct debugfs_reg32 intr_ctrl_regs[] = {
|
|
|
|
{ .name = "coal_init", .offset = 0, },
|
|
|
|
{ .name = "mask", .offset = 4, },
|
|
|
|
{ .name = "credits", .offset = 8, },
|
|
|
|
{ .name = "mask_on_assert", .offset = 12, },
|
|
|
|
{ .name = "coal_timer", .offset = 16, },
|
|
|
|
};
|
|
|
|
|
|
|
|
void ionic_debugfs_add_qcq(struct ionic_lif *lif, struct ionic_qcq *qcq)
|
|
|
|
{
|
2020-08-28 07:00:25 +08:00
|
|
|
struct dentry *qcq_dentry, *q_dentry, *cq_dentry;
|
|
|
|
struct dentry *intr_dentry, *stats_dentry;
|
2019-09-04 06:28:09 +08:00
|
|
|
struct ionic_dev *idev = &lif->ionic->idev;
|
|
|
|
struct debugfs_regset32 *intr_ctrl_regset;
|
|
|
|
struct ionic_intr_info *intr = &qcq->intr;
|
|
|
|
struct debugfs_blob_wrapper *desc_blob;
|
|
|
|
struct device *dev = lif->ionic->dev;
|
|
|
|
struct ionic_queue *q = &qcq->q;
|
|
|
|
struct ionic_cq *cq = &qcq->cq;
|
|
|
|
|
2020-08-28 07:00:25 +08:00
|
|
|
qcq_dentry = debugfs_create_dir(q->name, lif->dentry);
|
|
|
|
if (IS_ERR_OR_NULL(qcq_dentry))
|
|
|
|
return;
|
|
|
|
qcq->dentry = qcq_dentry;
|
2019-09-04 06:28:09 +08:00
|
|
|
|
2020-08-28 07:00:25 +08:00
|
|
|
debugfs_create_x64("q_base_pa", 0400, qcq_dentry, &qcq->q_base_pa);
|
|
|
|
debugfs_create_x32("q_size", 0400, qcq_dentry, &qcq->q_size);
|
|
|
|
debugfs_create_x64("cq_base_pa", 0400, qcq_dentry, &qcq->cq_base_pa);
|
|
|
|
debugfs_create_x32("cq_size", 0400, qcq_dentry, &qcq->cq_size);
|
|
|
|
debugfs_create_x64("sg_base_pa", 0400, qcq_dentry, &qcq->sg_base_pa);
|
|
|
|
debugfs_create_x32("sg_size", 0400, qcq_dentry, &qcq->sg_size);
|
2019-09-04 06:28:09 +08:00
|
|
|
|
|
|
|
q_dentry = debugfs_create_dir("q", qcq->dentry);
|
|
|
|
|
|
|
|
debugfs_create_u32("index", 0400, q_dentry, &q->index);
|
|
|
|
debugfs_create_u32("num_descs", 0400, q_dentry, &q->num_descs);
|
|
|
|
debugfs_create_u32("desc_size", 0400, q_dentry, &q->desc_size);
|
|
|
|
debugfs_create_u32("pid", 0400, q_dentry, &q->pid);
|
|
|
|
debugfs_create_u32("qid", 0400, q_dentry, &q->hw_index);
|
|
|
|
debugfs_create_u32("qtype", 0400, q_dentry, &q->hw_type);
|
|
|
|
debugfs_create_u64("drop", 0400, q_dentry, &q->drop);
|
|
|
|
|
|
|
|
debugfs_create_file("tail", 0400, q_dentry, q, &q_tail_fops);
|
|
|
|
debugfs_create_file("head", 0400, q_dentry, q, &q_head_fops);
|
|
|
|
|
|
|
|
desc_blob = devm_kzalloc(dev, sizeof(*desc_blob), GFP_KERNEL);
|
|
|
|
if (!desc_blob)
|
|
|
|
return;
|
|
|
|
desc_blob->data = q->base;
|
|
|
|
desc_blob->size = (unsigned long)q->num_descs * q->desc_size;
|
|
|
|
debugfs_create_blob("desc_blob", 0400, q_dentry, desc_blob);
|
|
|
|
|
|
|
|
if (qcq->flags & IONIC_QCQ_F_SG) {
|
|
|
|
desc_blob = devm_kzalloc(dev, sizeof(*desc_blob), GFP_KERNEL);
|
|
|
|
if (!desc_blob)
|
|
|
|
return;
|
|
|
|
desc_blob->data = q->sg_base;
|
|
|
|
desc_blob->size = (unsigned long)q->num_descs * q->sg_desc_size;
|
|
|
|
debugfs_create_blob("sg_desc_blob", 0400, q_dentry,
|
|
|
|
desc_blob);
|
|
|
|
}
|
|
|
|
|
|
|
|
cq_dentry = debugfs_create_dir("cq", qcq->dentry);
|
|
|
|
|
|
|
|
debugfs_create_x64("base_pa", 0400, cq_dentry, &cq->base_pa);
|
|
|
|
debugfs_create_u32("num_descs", 0400, cq_dentry, &cq->num_descs);
|
|
|
|
debugfs_create_u32("desc_size", 0400, cq_dentry, &cq->desc_size);
|
2020-05-05 21:28:09 +08:00
|
|
|
debugfs_create_bool("done_color", 0400, cq_dentry, &cq->done_color);
|
2019-09-04 06:28:09 +08:00
|
|
|
|
|
|
|
debugfs_create_file("tail", 0400, cq_dentry, cq, &cq_tail_fops);
|
|
|
|
|
|
|
|
desc_blob = devm_kzalloc(dev, sizeof(*desc_blob), GFP_KERNEL);
|
|
|
|
if (!desc_blob)
|
|
|
|
return;
|
|
|
|
desc_blob->data = cq->base;
|
|
|
|
desc_blob->size = (unsigned long)cq->num_descs * cq->desc_size;
|
|
|
|
debugfs_create_blob("desc_blob", 0400, cq_dentry, desc_blob);
|
|
|
|
|
|
|
|
if (qcq->flags & IONIC_QCQ_F_INTR) {
|
|
|
|
intr_dentry = debugfs_create_dir("intr", qcq->dentry);
|
|
|
|
|
|
|
|
debugfs_create_u32("index", 0400, intr_dentry,
|
|
|
|
&intr->index);
|
|
|
|
debugfs_create_u32("vector", 0400, intr_dentry,
|
|
|
|
&intr->vector);
|
2020-09-16 07:59:03 +08:00
|
|
|
debugfs_create_u32("dim_coal_hw", 0400, intr_dentry,
|
|
|
|
&intr->dim_coal_hw);
|
2019-09-04 06:28:09 +08:00
|
|
|
|
|
|
|
intr_ctrl_regset = devm_kzalloc(dev, sizeof(*intr_ctrl_regset),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!intr_ctrl_regset)
|
|
|
|
return;
|
|
|
|
intr_ctrl_regset->regs = intr_ctrl_regs;
|
|
|
|
intr_ctrl_regset->nregs = ARRAY_SIZE(intr_ctrl_regs);
|
|
|
|
intr_ctrl_regset->base = &idev->intr_ctrl[intr->index];
|
|
|
|
|
|
|
|
debugfs_create_regset32("intr_ctrl", 0400, intr_dentry,
|
|
|
|
intr_ctrl_regset);
|
|
|
|
}
|
2019-09-04 06:28:11 +08:00
|
|
|
|
|
|
|
if (qcq->flags & IONIC_QCQ_F_NOTIFYQ) {
|
|
|
|
stats_dentry = debugfs_create_dir("notifyblock", qcq->dentry);
|
|
|
|
|
|
|
|
debugfs_create_u64("eid", 0400, stats_dentry,
|
|
|
|
(u64 *)&lif->info->status.eid);
|
|
|
|
debugfs_create_u16("link_status", 0400, stats_dentry,
|
|
|
|
(u16 *)&lif->info->status.link_status);
|
|
|
|
debugfs_create_u32("link_speed", 0400, stats_dentry,
|
|
|
|
(u32 *)&lif->info->status.link_speed);
|
|
|
|
debugfs_create_u16("link_down_count", 0400, stats_dentry,
|
|
|
|
(u16 *)&lif->info->status.link_down_count);
|
|
|
|
}
|
2019-09-04 06:28:09 +08:00
|
|
|
}
|
|
|
|
|
2019-09-04 06:28:07 +08:00
|
|
|
static int netdev_show(struct seq_file *seq, void *v)
|
|
|
|
{
|
|
|
|
struct net_device *netdev = seq->private;
|
|
|
|
|
|
|
|
seq_printf(seq, "%s\n", netdev->name);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
DEFINE_SHOW_ATTRIBUTE(netdev);
|
|
|
|
|
2021-10-10 02:45:15 +08:00
|
|
|
static int lif_filters_show(struct seq_file *seq, void *v)
|
|
|
|
{
|
|
|
|
struct ionic_lif *lif = seq->private;
|
|
|
|
struct ionic_rx_filter *f;
|
|
|
|
struct hlist_head *head;
|
|
|
|
struct hlist_node *tmp;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
seq_puts(seq, "id flow state type filter\n");
|
|
|
|
spin_lock_bh(&lif->rx_filters.lock);
|
|
|
|
for (i = 0; i < IONIC_RX_FILTER_HLISTS; i++) {
|
|
|
|
head = &lif->rx_filters.by_id[i];
|
|
|
|
hlist_for_each_entry_safe(f, tmp, head, by_id) {
|
|
|
|
switch (le16_to_cpu(f->cmd.match)) {
|
|
|
|
case IONIC_RX_FILTER_MATCH_VLAN:
|
|
|
|
seq_printf(seq, "0x%04x 0x%08x 0x%02x vlan 0x%04x\n",
|
|
|
|
f->filter_id, f->flow_id, f->state,
|
|
|
|
le16_to_cpu(f->cmd.vlan.vlan));
|
|
|
|
break;
|
|
|
|
case IONIC_RX_FILTER_MATCH_MAC:
|
|
|
|
seq_printf(seq, "0x%04x 0x%08x 0x%02x mac %pM\n",
|
|
|
|
f->filter_id, f->flow_id, f->state,
|
|
|
|
f->cmd.mac.addr);
|
|
|
|
break;
|
|
|
|
case IONIC_RX_FILTER_MATCH_MAC_VLAN:
|
|
|
|
seq_printf(seq, "0x%04x 0x%08x 0x%02x macvl 0x%04x %pM\n",
|
|
|
|
f->filter_id, f->flow_id, f->state,
|
|
|
|
le16_to_cpu(f->cmd.vlan.vlan),
|
|
|
|
f->cmd.mac.addr);
|
|
|
|
break;
|
|
|
|
case IONIC_RX_FILTER_STEER_PKTCLASS:
|
|
|
|
seq_printf(seq, "0x%04x 0x%08x 0x%02x rxstr 0x%llx\n",
|
|
|
|
f->filter_id, f->flow_id, f->state,
|
|
|
|
le64_to_cpu(f->cmd.pkt_class));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock_bh(&lif->rx_filters.lock);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
DEFINE_SHOW_ATTRIBUTE(lif_filters);
|
|
|
|
|
2019-09-04 06:28:07 +08:00
|
|
|
void ionic_debugfs_add_lif(struct ionic_lif *lif)
|
|
|
|
{
|
2020-03-20 10:31:50 +08:00
|
|
|
struct dentry *lif_dentry;
|
|
|
|
|
|
|
|
lif_dentry = debugfs_create_dir(lif->name, lif->ionic->dentry);
|
|
|
|
if (IS_ERR_OR_NULL(lif_dentry))
|
|
|
|
return;
|
|
|
|
lif->dentry = lif_dentry;
|
|
|
|
|
2019-09-04 06:28:07 +08:00
|
|
|
debugfs_create_file("netdev", 0400, lif->dentry,
|
|
|
|
lif->netdev, &netdev_fops);
|
2021-10-10 02:45:15 +08:00
|
|
|
debugfs_create_file("filters", 0400, lif->dentry,
|
|
|
|
lif, &lif_filters_fops);
|
2019-09-04 06:28:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ionic_debugfs_del_lif(struct ionic_lif *lif)
|
|
|
|
{
|
|
|
|
debugfs_remove_recursive(lif->dentry);
|
|
|
|
lif->dentry = NULL;
|
|
|
|
}
|
2019-09-04 06:28:09 +08:00
|
|
|
|
|
|
|
void ionic_debugfs_del_qcq(struct ionic_qcq *qcq)
|
|
|
|
{
|
|
|
|
debugfs_remove_recursive(qcq->dentry);
|
|
|
|
qcq->dentry = NULL;
|
|
|
|
}
|
|
|
|
|
2019-09-04 06:28:05 +08:00
|
|
|
#endif
|