From: Chaitanya Kulkarni <chaitanyak@nvidia.com>
To: Martin Belanger <nitram_67@hotmail.com>
Cc: "kbusch@kernel.org" <kbusch@kernel.org>,
"hare@suse.de" <hare@suse.de>, "axboe@fb.com" <axboe@fb.com>,
"hch@lst.de" <hch@lst.de>, "sagi@grimberg.me" <sagi@grimberg.me>,
"stuart_hayes@dell.com" <stuart_hayes@dell.com>,
"charles_rose@dell.com" <charles_rose@dell.com>,
Martin Belanger <martin.belanger@dell.com>,
"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>
Subject: Re: [PATCHv3 2/2] nvme: Expose cntrltype and dctype through sysfs
Date: Tue, 8 Feb 2022 23:21:22 +0000 [thread overview]
Message-ID: <890f6817-7880-79cd-3651-2f91e4454e28@nvidia.com> (raw)
In-Reply-To: <BL0PR13MB4291B3A6C98BA5EB5ACD8A129C2D9@BL0PR13MB4291.namprd13.prod.outlook.com>
> +static ssize_t cntrltype_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + static const char * const type[] = {
nit:- static cost char *const type[] ...
> + [NVME_CTRL_IO] = "io\n",
> + [NVME_CTRL_DISC] = "discovery\n",
> + [NVME_CTRL_ADMIN] = "admin\n",
> + };
> + struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
> +
> + if (ctrl->cntrltype > NVME_CTRL_ADMIN || !type[ctrl->cntrltype])
> + return sysfs_emit(buf, "reserved\n");
> +
> + return sysfs_emit(buf, type[ctrl->cntrltype]);
> +}
> +static DEVICE_ATTR_RO(cntrltype);
> +
> +static ssize_t dctype_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + static const char * const type[] = {
nit:- static cost char *const typep[] ...
> + [NVME_DCTYPE_NOT_REPORTED] = "none\n",
> + [NVME_DCTYPE_DDC] = "ddc\n",
> + [NVME_DCTYPE_CDC] = "cdc\n",
> + };
> + struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
> +
> + if (ctrl->dctype > NVME_DCTYPE_CDC || !type[ctrl->dctype])
> + return sysfs_emit(buf, "reserved\n");
> +
> + return sysfs_emit(buf, type[ctrl->dctype]);
> +}
> +static DEVICE_ATTR_RO(dctype);
> +
> static struct attribute *nvme_dev_attrs[] = {
> &dev_attr_reset_controller.attr,
> &dev_attr_rescan_controller.attr,
> @@ -3544,6 +3581,8 @@ static struct attribute *nvme_dev_attrs[] = {
> &dev_attr_reconnect_delay.attr,
> &dev_attr_fast_io_fail_tmo.attr,
> &dev_attr_kato.attr,
> + &dev_attr_cntrltype.attr,
> + &dev_attr_dctype.attr,
> NULL
> };
>
> diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
> index a162f6c6da6e..e30626c00791 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -349,6 +349,9 @@ struct nvme_ctrl {
> unsigned long discard_page_busy;
>
> struct nvme_fault_inject fault_inject;
> +
> + enum nvme_ctrl_type cntrltype;
> + enum nvme_dctype dctype;
> };
>
> enum nvme_iopolicy {
> diff --git a/include/linux/nvme.h b/include/linux/nvme.h
> index 855dd9b3e84b..21e92e97ca88 100644
> --- a/include/linux/nvme.h
> +++ b/include/linux/nvme.h
> @@ -43,6 +43,12 @@ enum nvme_ctrl_type {
> NVME_CTRL_ADMIN = 3, /* Administrative controller */
> };
>
> +enum nvme_dctype {
> + NVME_DCTYPE_NOT_REPORTED = 0,
> + NVME_DCTYPE_DDC = 1, /* Direct Discovery Controller */
> + NVME_DCTYPE_CDC = 2, /* Central Discovery Controller */
> +};
> +
> /* Address Family codes for Discovery Log Page entry ADRFAM field */
> enum {
> NVMF_ADDR_FAMILY_PCI = 0, /* PCIe */
> @@ -320,7 +326,9 @@ struct nvme_id_ctrl {
> __le16 icdoff;
> __u8 ctrattr;
> __u8 msdbd;
> - __u8 rsvd1804[244];
> + __u8 rsvd1804[2];
> + __u8 dctype;
> + __u8 rsvd1807[241];
> struct nvme_id_power_state psd[32];
> __u8 vs[1024];
> };
>
next prev parent reply other threads:[~2022-02-08 23:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220208193346.22580-1-nitram_67@hotmail.com>
2022-02-08 19:33 ` [PATCHv3 1/2] nvme: send uevent on connection up Martin Belanger
2022-02-15 15:41 ` John Meneghini
2022-02-16 8:01 ` Christoph Hellwig
2022-02-08 19:33 ` [PATCHv3 2/2] nvme: Expose cntrltype and dctype through sysfs Martin Belanger
2022-02-08 23:18 ` Chaitanya Kulkarni
2022-02-08 23:21 ` Chaitanya Kulkarni [this message]
2022-02-08 23:53 ` Belanger, Martin
2022-02-08 23:57 ` Chaitanya Kulkarni
2022-02-09 6:40 ` Hannes Reinecke
2022-02-15 15:06 ` Hannes Reinecke
2022-02-15 15:44 ` John Meneghini
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=890f6817-7880-79cd-3651-2f91e4454e28@nvidia.com \
--to=chaitanyak@nvidia.com \
--cc=axboe@fb.com \
--cc=charles_rose@dell.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=martin.belanger@dell.com \
--cc=nitram_67@hotmail.com \
--cc=sagi@grimberg.me \
--cc=stuart_hayes@dell.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