On Mon, Sep 28, 2020 at 11:35:19AM +0900, Dmitry Fomichev wrote: > From: Niklas Cassel <niklas.cas...@wdc.com> > > Namespace Types introduce a new command set, "I/O Command Sets", > that allows the host to retrieve the command sets associated with > a namespace. Introduce support for the command set and enable > detection for the NVM Command Set. > > The new workflows for identify commands rely heavily on zero-filled > identify structs. E.g., certain CNS commands are defined to return > a zero-filled identify struct when an inactive namespace NSID > is supplied. > > Add a helper function in order to avoid code duplication when > reporting zero-filled identify structures. > > Signed-off-by: Niklas Cassel <niklas.cas...@wdc.com> > Signed-off-by: Dmitry Fomichev <dmitry.fomic...@wdc.com> > --- > hw/block/nvme-ns.c | 3 + > hw/block/nvme.c | 210 +++++++++++++++++++++++++++++++++++++-------- > 2 files changed, 175 insertions(+), 38 deletions(-) > > diff --git a/hw/block/nvme-ns.c b/hw/block/nvme-ns.c > index bbd7879492..31b7f986c3 100644 > --- a/hw/block/nvme-ns.c > +++ b/hw/block/nvme-ns.c
(snip) > @@ -1597,12 +1667,31 @@ static uint16_t nvme_identify_ns_descr_list(NvmeCtrl > *n, NvmeRequest *req) > * Namespace Identification Descriptor. Add a very basic Namespace UUID > * here. > */ > - ns_descrs->uuid.hdr.nidt = NVME_NIDT_UUID; > - ns_descrs->uuid.hdr.nidl = NVME_NIDL_UUID; > - stl_be_p(&ns_descrs->uuid.v, nsid); > + desc = list_ptr; > + desc->nidt = NVME_NIDT_UUID; > + desc->nidl = NVME_NIDL_UUID; > + list_ptr += sizeof(*desc); > + memcpy(list_ptr, ns->params.uuid.data, NVME_NIDL_UUID); > + list_ptr += NVME_NIDL_UUID; > > - return nvme_dma(n, list, NVME_IDENTIFY_DATA_SIZE, > - DMA_DIRECTION_FROM_DEVICE, req); > + desc = list_ptr; > + desc->nidt = NVME_NIDT_CSI; > + desc->nidl = NVME_NIDL_CSI; > + list_ptr += sizeof(*desc); > + *(uint8_t *)list_ptr = NVME_CSI_NVM; I think that we should use ns->csi/ns->params.csi here rather than NVME_CSI_NVM. You do this change in a later patch, but I think it is more correct to do it here already. (No reason not to, since ns->csi/ns->params.csi should be set to NVME_CSI_NVM for NVM namespace already in this patch.) > + > + return nvme_dma(n, list, data_len, DMA_DIRECTION_FROM_DEVICE, req); > +}