On Tue, Dec 21, 2021 at 10:48:56AM +0800, Cheng Xu wrote: > Add the main erdma module and debugfs files. The main module provides > interface to infiniband subsytem, and the debugfs module provides a way > to allow user can get the core status of the device and set the preferred > congestion control algorithm. debugfs is for debug - dump various information. It is not the right interface to set configuration properties. > > Signed-off-by: Cheng Xu <chengyou@xxxxxxxxxxxxxxxxx> > --- > drivers/infiniband/hw/erdma/erdma_debug.c | 314 ++++++++++ > drivers/infiniband/hw/erdma/erdma_debug.h | 18 + > drivers/infiniband/hw/erdma/erdma_main.c | 711 ++++++++++++++++++++++ > 3 files changed, 1043 insertions(+) > create mode 100644 drivers/infiniband/hw/erdma/erdma_debug.c > create mode 100644 drivers/infiniband/hw/erdma/erdma_debug.h > create mode 100644 drivers/infiniband/hw/erdma/erdma_main.c > > diff --git a/drivers/infiniband/hw/erdma/erdma_debug.c b/drivers/infiniband/hw/erdma/erdma_debug.c > new file mode 100644 > index 000000000000..3cbed4dde0e2 > --- /dev/null > +++ b/drivers/infiniband/hw/erdma/erdma_debug.c > @@ -0,0 +1,314 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Authors: Cheng Xu <chengyou@xxxxxxxxxxxxxxxxx> > + * Kai Shen <kaishen@xxxxxxxxxxxxxxxxx> > + * Copyright (c) 2020-2021, Alibaba Group. > + */ > +#include <linux/errno.h> > +#include <linux/types.h> > +#include <linux/list.h> > +#include <linux/debugfs.h> > + > +#include <rdma/iw_cm.h> > +#include <rdma/ib_verbs.h> > +#include <rdma/ib_smi.h> > +#include <rdma/ib_user_verbs.h> > + > +#include "erdma.h" > +#include "erdma_cm.h" > +#include "erdma_debug.h" > +#include "erdma_verbs.h" > + > +char *cc_method_string[ERDMA_CC_METHODS_NUM] = { > + [ERDMA_CC_NEWRENO] = "newreno", > + [ERDMA_CC_CUBIC] = "cubic", > + [ERDMA_CC_HPCC_RTT] = "hpcc_rtt", > + [ERDMA_CC_HPCC_ECN] = "hpcc_ecn", > + [ERDMA_CC_HPCC_INT] = "hpcc_int" > +}; > + > +static struct dentry *erdma_debugfs; > + > + > +static int erdma_dbgfs_file_open(struct inode *inode, struct file *fp) > +{ > + fp->private_data = inode->i_private; > + return nonseekable_open(inode, fp); > +} > + > +static ssize_t erdma_show_stats(struct file *fp, char __user *buf, size_t space, > + loff_t *ppos) > +{ > + struct erdma_dev *dev = fp->private_data; > + char *kbuf = NULL; > + int len = 0; > + > + if (*ppos) > + goto out; > + > + kbuf = kmalloc(space, GFP_KERNEL); > + if (!kbuf) > + goto out; > + > + len = snprintf(kbuf, space, "Resource Summary of %s:\n" > + "%s: %d\n%s: %d\n%s: %d\n%s: %d\n%s: %d\n%s: %d\n", > + dev->ibdev.name, > + "ucontext ", atomic_read(&dev->num_ctx), > + "pd ", atomic_read(&dev->num_pd), > + "qp ", atomic_read(&dev->num_qp), > + "cq ", atomic_read(&dev->num_cq), > + "mr ", atomic_read(&dev->num_mr), Why do you need to duplicate "restrack res ..."? > + "cep ", atomic_read(&dev->num_cep)); > + if (len > space) > + len = space; > +out: > + if (len) > + len = simple_read_from_buffer(buf, len, ppos, kbuf, len); > + > + kfree(kbuf); > + return len; > + > +} > + Thanks