From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Dmitry Fomichev <Dmitry.Fomichev@wdc.com>,
Keith Busch <kbusch@kernel.org>,
Klaus Jensen <k.jensen@samsung.com>,
Kevin Wolf <kwolf@redhat.com>,
Maxim Levitsky <mlevitsk@redhat.com>, Fam Zheng <fam@euphon.net>
Cc: Niklas Cassel <Niklas.Cassel@wdc.com>,
Damien Le Moal <Damien.LeMoal@wdc.com>,
"qemu-block@nongnu.org" <qemu-block@nongnu.org>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
Alistair Francis <Alistair.Francis@wdc.com>,
Matias Bjorling <Matias.Bjorling@wdc.com>
Subject: Re: [PATCH v8 07/11] hw/block/nvme: Support Zoned Namespace Command Set
Date: Tue, 3 Nov 2020 21:37:49 +0100 [thread overview]
Message-ID: <b8d2a80b-4f7f-56eb-39dd-1e40f73c5a9b@redhat.com> (raw)
In-Reply-To: <MN2PR04MB59511341E3622276A993FE7CE1110@MN2PR04MB5951.namprd04.prod.outlook.com>
On 11/3/20 8:48 PM, Dmitry Fomichev wrote:
>> -----Original Message-----
>> From: Philippe Mathieu-Daudé <philmd@redhat.com>
...
>>> typedef struct QEMU_PACKED NvmeCqe {
>>> - uint32_t result;
>>> - uint32_t rsvd;
>>> + union {
>>> + uint64_t result64;
>>> + uint32_t result32;
>>> + };
>>
>> When using packed structure you want to define all fields to
>> avoid alignment confusion (and I'm surprised the compiler doesn't
>> complain...). So this would be:
>>
>> union {
>> uint64_t result64;
>> struct {
>> uint32_t result32;
>> uint32_t rsvd32;
>> };
>> };
>>
>
> IMO, the compiler doesn't complain because it's a union. Smaller
> variants in unions are "padded" to the size of the largest variant
> regardless of whether the struct is packed or not.
>
>> But since the ZNS is still a technical proposal and not in the spec,
>> this doesn't look correct (the spec list this field as 32-bit).
>>
>> What do you think about adding NvmeCqeZNS?
>>
>> Maybe:
>>
>> typedef struct QEMU_PACKED NvmeCqeZNS {
>> uint64_t result;
>> uint16_t sq_head;
>> uint16_t sq_id;
>> uint16_t cid;
>> uint16_t status;
>> } NvmeCqeZNS;
>>
>> Or clever:
>>
>> typedef union QEMU_PACKED NvmeCqeZNS {
>> union {
>> struct {
>> uint64_t result;
>> uint32_t dw2;
>> uint32_t dw3;
>> };
>> NvmeCqe cqe;
>> };
>> } NvmeCqeZNS;
>>
>
> The 1.4 base spec changes Reserved DW1 in CQE to become the
> Command Specific DW1, so it would rather make sense to define
> a command-specific CQE for Zone Append -
>
> In include/block/nvme.h:
>
> typedef struct QEMU_PACKED NvmeCqe {
> uint32_t result;
> - uint32_t rsvd;
> + uint32_t dw1;
> uint16_t sq_head;
> uint16_t sq_id;
> uint16_t cid;
> uint16_t status;
> } NvmeCqe;
>
> +/* Zone Append - specific CQE */
> +typedef struct QEMU_PACKED NvmeCqeZA {
> + uint64_t za_slba;
> + uint16_t sq_head;
> + uint16_t sq_id;
> + uint16_t cid;
> + uint16_t status;
> +} NvmeCqeZA;
>
> ...
>
> + QEMU_BUILD_BUG_ON(sizeof(NvmeCqe) != sizeof(NvmeCqeZA));
>
> This will go away with all CQE unions and it will also allow the returned SLBA
> value to be properly named. What do you think?
This is cleaner, I like it :)
>
>> I wonder what part could go in hw/block/nvme-ns.h or "block/nvme-zns.h".
>
> NvmeCqeZA could simply be defined in include/block/nvme.h next to NvmeCqe.
> The problem with adding include/block/nvme-zns.h is that it would be hard if
> not impossible to separate all ZNS-specific content from block/nvme.h and it
> would become necessary for developers to deal with two files that present
> different parts of ZNS definitions instead of just one.
Got it.
Regards,
Phil.
>
> Best regards,
> Dmitry
next prev parent reply other threads:[~2020-11-03 20:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-30 2:32 [PATCH v8 00/11] hw/block/nvme: Support Namespace Types and Zoned Namespace Command Set Dmitry Fomichev
2020-10-30 2:32 ` [PATCH v8 01/11] hw/block/nvme: Add Commands Supported and Effects log Dmitry Fomichev
2020-10-30 2:32 ` [PATCH v8 02/11] hw/block/nvme: Generate namespace UUIDs Dmitry Fomichev
2020-10-30 2:32 ` [PATCH v8 03/11] hw/block/nvme: Separate read and write handlers Dmitry Fomichev
2020-10-30 2:32 ` [PATCH v8 04/11] hw/block/nvme: Merge nvme_write_zeroes() with nvme_write() Dmitry Fomichev
2020-10-30 2:32 ` [PATCH v8 05/11] hw/block/nvme: Add support for Namespace Types Dmitry Fomichev
2020-10-30 2:32 ` [PATCH v8 06/11] hw/block/nvme: Support allocated CNS command variants Dmitry Fomichev
2020-11-04 7:48 ` Klaus Jensen
2020-10-30 2:32 ` [PATCH v8 07/11] hw/block/nvme: Support Zoned Namespace Command Set Dmitry Fomichev
2020-10-30 7:15 ` Philippe Mathieu-Daudé
2020-11-03 19:48 ` Dmitry Fomichev
2020-11-03 20:37 ` Philippe Mathieu-Daudé [this message]
2020-11-04 7:21 ` Klaus Jensen
2020-10-30 17:18 ` Niklas Cassel
2020-10-30 2:32 ` [PATCH v8 08/11] hw/block/nvme: Introduce max active and open zone limits Dmitry Fomichev
2020-10-30 2:32 ` [PATCH v8 09/11] hw/block/nvme: Support Zone Descriptor Extensions Dmitry Fomichev
2020-10-30 2:32 ` [PATCH v8 10/11] hw/block/nvme: Add injection of Offline/Read-Only zones Dmitry Fomichev
2020-10-30 2:32 ` [PATCH v8 11/11] hw/block/nvme: Document zoned parameters in usage text Dmitry Fomichev
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=b8d2a80b-4f7f-56eb-39dd-1e40f73c5a9b@redhat.com \
--to=philmd@redhat.com \
--cc=Alistair.Francis@wdc.com \
--cc=Damien.LeMoal@wdc.com \
--cc=Dmitry.Fomichev@wdc.com \
--cc=Matias.Bjorling@wdc.com \
--cc=Niklas.Cassel@wdc.com \
--cc=fam@euphon.net \
--cc=k.jensen@samsung.com \
--cc=kbusch@kernel.org \
--cc=kwolf@redhat.com \
--cc=mlevitsk@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).