From: "Allen Hubbe" <Allen.Hubbe@emc.com>
To: "'Logan Gunthorpe'" <logang@deltatee.com>,
"'Jon Mason'" <jdmason@kudzu.us>,
"'Dave Jiang'" <dave.jiang@intel.com>
Cc: "'Shuah Khan'" <shuahkh@osg.samsung.com>,
"'Sudip Mukherjee'" <sudipm.mukherjee@gmail.com>,
"'Arnd Bergmann'" <arnd@arndb.de>, <linux-kernel@vger.kernel.org>,
<linux-ntb@googlegroups.com>, <linux-kselftest@vger.kernel.org>
Subject: RE: [PATCH v3 08/10] ntb_pingpong: Add a debugfs file to get the ping count
Date: Wed, 15 Jun 2016 17:48:10 -0400 [thread overview]
Message-ID: <007701d1c74f$9cfe2460$d6fa6d20$@emc.com> (raw)
In-Reply-To: <d770c327d028ff794c74602268c469d54526675b.1466025130.git.logang@deltatee.com>
From: Logan Gunthorpe
> This commit adds a debugfs 'count' file to ntb_pingpong. This is so
> testing with ntb_pingpong can be automated beyond just checking the
> logs for pong messages.
>
> The count file returns a number which increments every pong. The
> counter can be cleared by writing a zero.
>
> Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Allen Hubbe <Allen.Hubbe@emc.com>
> ---
> drivers/ntb/test/ntb_pingpong.c | 62 ++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 61 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/ntb/test/ntb_pingpong.c b/drivers/ntb/test/ntb_pingpong.c
> index fe16005..7d31179 100644
> --- a/drivers/ntb/test/ntb_pingpong.c
> +++ b/drivers/ntb/test/ntb_pingpong.c
> @@ -61,6 +61,7 @@
> #include <linux/pci.h>
> #include <linux/slab.h>
> #include <linux/spinlock.h>
> +#include <linux/debugfs.h>
>
> #include <linux/ntb.h>
>
> @@ -96,8 +97,13 @@ struct pp_ctx {
> spinlock_t db_lock;
> struct timer_list db_timer;
> unsigned long db_delay;
> + struct dentry *debugfs_node_dir;
> + struct dentry *debugfs_count;
> + atomic_t count;
> };
>
> +static struct dentry *pp_debugfs_dir;
> +
> static void pp_ping(unsigned long ctx)
> {
> struct pp_ctx *pp = (void *)ctx;
> @@ -171,10 +177,32 @@ static void pp_db_event(void *ctx, int vec)
> dev_dbg(&pp->ntb->dev,
> "Pong vec %d bits %#llx\n",
> vec, db_bits);
> + atomic_inc(&pp->count);
> }
> spin_unlock_irqrestore(&pp->db_lock, irqflags);
> }
>
> +static int pp_debugfs_setup(struct pp_ctx *pp)
> +{
> + struct pci_dev *pdev = pp->ntb->pdev;
> +
> + if (!pp_debugfs_dir)
> + return -ENODEV;
> +
> + pp->debugfs_node_dir = debugfs_create_dir(pci_name(pdev),
> + pp_debugfs_dir);
> + if (!pp->debugfs_node_dir)
> + return -ENODEV;
> +
> + pp->debugfs_count = debugfs_create_atomic_t("count", S_IRUSR | S_IWUSR,
> + pp->debugfs_node_dir,
> + &pp->count);
> + if (!pp->debugfs_count)
> + return -ENODEV;
> +
> + return 0;
> +}
> +
> static const struct ntb_ctx_ops pp_ops = {
> .link_event = pp_link_event,
> .db_event = pp_db_event,
> @@ -210,6 +238,7 @@ static int pp_probe(struct ntb_client *client,
>
> pp->ntb = ntb;
> pp->db_bits = 0;
> + atomic_set(&pp->count, 0);
> spin_lock_init(&pp->db_lock);
> setup_timer(&pp->db_timer, pp_ping, (unsigned long)pp);
> pp->db_delay = msecs_to_jiffies(delay_ms);
> @@ -218,6 +247,10 @@ static int pp_probe(struct ntb_client *client,
> if (rc)
> goto err_ctx;
>
> + rc = pp_debugfs_setup(pp);
> + if (rc)
> + goto err_ctx;
> +
> ntb_link_enable(ntb, NTB_SPEED_AUTO, NTB_WIDTH_AUTO);
> ntb_link_event(ntb);
>
> @@ -234,6 +267,8 @@ static void pp_remove(struct ntb_client *client,
> {
> struct pp_ctx *pp = ntb->ctx;
>
> + debugfs_remove_recursive(pp->debugfs_node_dir);
> +
> ntb_clear_ctx(ntb);
> del_timer_sync(&pp->db_timer);
> ntb_link_disable(ntb);
> @@ -247,4 +282,29 @@ static struct ntb_client pp_client = {
> .remove = pp_remove,
> },
> };
> -module_ntb_client(pp_client);
> +
> +static int __init pp_init(void)
> +{
> + int rc;
> +
> + if (debugfs_initialized())
> + pp_debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
> +
> + rc = ntb_register_client(&pp_client);
> + if (rc)
> + goto err_client;
> +
> + return 0;
> +
> +err_client:
> + debugfs_remove_recursive(pp_debugfs_dir);
> + return rc;
> +}
> +module_init(pp_init);
> +
> +static void __exit pp_exit(void)
> +{
> + ntb_unregister_client(&pp_client);
> + debugfs_remove_recursive(pp_debugfs_dir);
> +}
> +module_exit(pp_exit);
> --
> 2.1.4
next prev parent reply other threads:[~2016-06-15 21:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1466025130.git.logang@deltatee.com>
[not found] ` <b1aa9e9977b992621452812f744ff7827ca4f28c.1466025130.git.logang@deltatee.com>
2016-06-15 21:33 ` [PATCH v3 10/10] ntb_perf: clear link_is_up flag when the link goes down Jiang, Dave
2016-06-15 22:20 ` Logan Gunthorpe
2016-06-15 22:24 ` Jiang, Dave
2016-06-15 23:11 ` Logan Gunthorpe
[not found] ` <d770c327d028ff794c74602268c469d54526675b.1466025130.git.logang@deltatee.com>
2016-06-15 21:48 ` Allen Hubbe [this message]
[not found] ` <32ec8e46e2f76dd74046b34c7b50cc84206090b3.1466025130.git.logang@deltatee.com>
2016-06-15 21:48 ` [PATCH v3 07/10] ntb_tool: Add link status and files to debugfs Allen Hubbe
[not found] ` <a37e02139ad94ab322bfac087524a0394ec0383a.1466025130.git.logang@deltatee.com>
2016-06-15 21:49 ` [PATCH v3 09/10] ntb_test: Add a selftest script for the NTB subsystem Allen Hubbe
2016-06-15 21:54 ` Logan Gunthorpe
2016-06-15 22:17 ` Allen Hubbe
2016-06-15 22:30 ` Logan Gunthorpe
[not found] ` <a87bb21ba21f77a722b66ceea75c20baebf3302f.1466025130.git.logang@deltatee.com>
2016-06-15 21:53 ` [PATCH v3 06/10] ntb_tool: Postpone memory window initialization for the user Allen Hubbe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='007701d1c74f$9cfe2460$d6fa6d20$@emc.com' \
--to=allen.hubbe@emc.com \
--cc=arnd@arndb.de \
--cc=dave.jiang@intel.com \
--cc=jdmason@kudzu.us \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-ntb@googlegroups.com \
--cc=logang@deltatee.com \
--cc=shuahkh@osg.samsung.com \
--cc=sudipm.mukherjee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox