From: Nathan Chancellor <nathan@kernel.org>
To: Huazhong Tan <tanhuazhong@huawei.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
salil.mehta@huawei.com, yisen.zhuang@huawei.com, kuba@kernel.org,
huangdaode@huawei.com, linuxarm@openeuler.org,
Guangbin Huang <huangguangbin2@huawei.com>
Subject: Re: [PATCH V2 net-next 2/2] net: hns3: add debugfs support for tm nodes, priority and qset info
Date: Mon, 1 Feb 2021 14:25:57 -0700 [thread overview]
Message-ID: <20210201212557.GA3126741@localhost> (raw)
In-Reply-To: <1611834696-56207-3-git-send-email-tanhuazhong@huawei.com>
On Thu, Jan 28, 2021 at 07:51:36PM +0800, Huazhong Tan wrote:
> From: Guangbin Huang <huangguangbin2@huawei.com>
>
> In order to query tm info of nodes, priority and qset
> for debugging, adds three debugfs files tm_nodes,
> tm_priority and tm_qset in newly created tm directory.
>
> Unlike previous debugfs commands, these three files
> just support read ops, so they only support to use cat
> command to dump their info.
>
> The new tm file style is acccording to suggestion from
> Jakub Kicinski's opinion as link https://lkml.org/lkml/2020/9/29/2101.
>
> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
> ---
> drivers/net/ethernet/hisilicon/hns3/hnae3.h | 8 ++
> drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 55 +++++++-
> .../ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 153 +++++++++++++++++++++
> .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 1 +
> .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 2 +
> 5 files changed, 218 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
> index a7daf6d..fe09cf6 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
> +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
> @@ -465,6 +465,8 @@ struct hnae3_ae_dev {
> * Delete clsflower rule
> * cls_flower_active
> * Check if any cls flower rule exist
> + * dbg_read_cmd
> + * Execute debugfs read command.
> */
> struct hnae3_ae_ops {
> int (*init_ae_dev)(struct hnae3_ae_dev *ae_dev);
> @@ -620,6 +622,8 @@ struct hnae3_ae_ops {
> int (*add_arfs_entry)(struct hnae3_handle *handle, u16 queue_id,
> u16 flow_id, struct flow_keys *fkeys);
> int (*dbg_run_cmd)(struct hnae3_handle *handle, const char *cmd_buf);
> + int (*dbg_read_cmd)(struct hnae3_handle *handle, const char *cmd_buf,
> + char *buf, int len);
> pci_ers_result_t (*handle_hw_ras_error)(struct hnae3_ae_dev *ae_dev);
> bool (*get_hw_reset_stat)(struct hnae3_handle *handle);
> bool (*ae_dev_resetting)(struct hnae3_handle *handle);
> @@ -777,6 +781,10 @@ struct hnae3_handle {
> #define hnae3_get_bit(origin, shift) \
> hnae3_get_field((origin), (0x1 << (shift)), (shift))
>
> +#define HNAE3_DBG_TM_NODES "tm_nodes"
> +#define HNAE3_DBG_TM_PRI "tm_priority"
> +#define HNAE3_DBG_TM_QSET "tm_qset"
> +
> int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev);
> void hnae3_unregister_ae_dev(struct hnae3_ae_dev *ae_dev);
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
> index 9d4e9c0..6978304 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
> @@ -7,7 +7,7 @@
> #include "hnae3.h"
> #include "hns3_enet.h"
>
> -#define HNS3_DBG_READ_LEN 256
> +#define HNS3_DBG_READ_LEN 65536
> #define HNS3_DBG_WRITE_LEN 1024
>
> static struct dentry *hns3_dbgfs_root;
> @@ -484,6 +484,42 @@ static ssize_t hns3_dbg_cmd_write(struct file *filp, const char __user *buffer,
> return count;
> }
>
> +static ssize_t hns3_dbg_read(struct file *filp, char __user *buffer,
> + size_t count, loff_t *ppos)
> +{
> + struct hnae3_handle *handle = filp->private_data;
> + const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
> + struct hns3_nic_priv *priv = handle->priv;
> + char *cmd_buf, *read_buf;
> + ssize_t size = 0;
> + int ret = 0;
> +
> + if (!filp->f_path.dentry->d_iname)
> + return -EINVAL;
Clang warns this check is pointless:
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c:497:28: warning:
address of array 'filp->f_path.dentry->d_iname' will always evaluate to
'true' [-Wpointer-bool-conversion]
if (!filp->f_path.dentry->d_iname)
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
1 warning generated.
Was it intended to be something else or can it just be removed?
> + read_buf = kzalloc(HNS3_DBG_READ_LEN, GFP_KERNEL);
> + if (!read_buf)
> + return -ENOMEM;
> +
> + cmd_buf = filp->f_path.dentry->d_iname;
> +
> + if (ops->dbg_read_cmd)
> + ret = ops->dbg_read_cmd(handle, cmd_buf, read_buf,
> + HNS3_DBG_READ_LEN);
> +
> + if (ret) {
> + dev_info(priv->dev, "unknown command\n");
> + goto out;
> + }
> +
> + size = simple_read_from_buffer(buffer, count, ppos, read_buf,
> + strlen(read_buf));
> +
> +out:
> + kfree(read_buf);
> + return size;
> +}
Cheers,
Nathan
next prev parent reply other threads:[~2021-02-01 21:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 11:51 [PATCH V2 net-next 0/2] net: hns3: updates for -next Huazhong Tan
2021-01-28 11:51 ` [PATCH V2 net-next 1/2] net: hns3: add interfaces to query information of tm priority/qset Huazhong Tan
2021-01-28 11:51 ` [PATCH V2 net-next 2/2] net: hns3: add debugfs support for tm nodes, priority and qset info Huazhong Tan
2021-02-01 21:25 ` Nathan Chancellor [this message]
2021-02-02 1:26 ` Huazhong Tan
2021-01-30 5:00 ` [PATCH V2 net-next 0/2] net: hns3: updates for -next patchwork-bot+netdevbpf
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=20210201212557.GA3126741@localhost \
--to=nathan@kernel.org \
--cc=davem@davemloft.net \
--cc=huangdaode@huawei.com \
--cc=huangguangbin2@huawei.com \
--cc=kuba@kernel.org \
--cc=linuxarm@openeuler.org \
--cc=netdev@vger.kernel.org \
--cc=salil.mehta@huawei.com \
--cc=tanhuazhong@huawei.com \
--cc=yisen.zhuang@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.