[U-Boot] [PATCH] nvme: add accessor to namespace id and eui64
Patrick Wildt
patrick at blueri.se
Thu Oct 3 10:33:36 UTC 2019
On Thu, Oct 03, 2019 at 06:25:53PM +0800, Bin Meng wrote:
> On Thu, Oct 3, 2019 at 5:56 PM Patrick Wildt <patrick at blueri.se> wrote:
> >
> > This adds a function which can be used by e.g. EFI to retrieve
> > the namespace identifier and EUI64. For that it adds the EUI64
> > to its driver internal namespace structure and copies the EUI64
> > during namespace identification.
> >
> > Signed-off-by: Patrick Wildt <patrick at blueri.se>
> >
> > diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
> > index 47f101e280..e9994ae5d4 100644
> > --- a/drivers/nvme/nvme.c
> > +++ b/drivers/nvme/nvme.c
> > @@ -621,6 +621,14 @@ static int nvme_get_info_from_identify(struct nvme_dev *dev)
> > return 0;
> > }
> >
> > +u32 nvme_get_namespace_id(struct udevice *udev, u8 *eui64)
> > +{
> > + struct nvme_ns *ns = dev_get_priv(udev);
> > + if (eui64)
> > + memcpy(eui64, ns->eui64, sizeof(ns->eui64));
> > + return ns->ns_id;
> > +}
> > +
> > int nvme_scan_namespace(void)
> > {
> > struct uclass *uc;
> > @@ -657,6 +665,7 @@ static int nvme_blk_probe(struct udevice *udev)
> > if (nvme_identify(ndev, ns->ns_id, 0, (dma_addr_t)(long)id))
> > return -EIO;
> >
> > + memcpy(&ns->eui64, &id->eui64, sizeof(id->eui64));
> > flbas = id->flbas & NVME_NS_FLBAS_LBA_MASK;
> > ns->flbas = flbas;
> > ns->lba_shift = id->lbaf[flbas].ds;
> > diff --git a/drivers/nvme/nvme.h b/drivers/nvme/nvme.h
> > index 922f7abfe8..0e8cb221a7 100644
> > --- a/drivers/nvme/nvme.h
> > +++ b/drivers/nvme/nvme.h
> > @@ -637,6 +637,7 @@ struct nvme_ns {
> > struct list_head list;
> > struct nvme_dev *dev;
> > unsigned ns_id;
> > + u8 eui64[8];
> > int devnum;
> > int lba_shift;
> > u8 flbas;
> > diff --git a/include/nvme.h b/include/nvme.h
> > index 2c3d14d241..c8fdd44da0 100644
> > --- a/include/nvme.h
> > +++ b/include/nvme.h
> > @@ -78,4 +78,15 @@ int nvme_scan_namespace(void);
> > */
> > int nvme_print_info(struct udevice *udev);
> >
> > +/**
> > + * nvme_get_namespace_id - return namespace identifier
> > + *
> > + * This returns the namespace identifier.
> > + *
> > + * @udev: NVMe controller device
> > + * @eui64: IEEE Extended Unique Identifier
>
> It's actually an output parameter. Please add more descriptions to indicate.
>
> > + * @return: namespace identifier
>
> Perhaps we should make ns_id an output parameter too, and make the
> return value be either 0 on success or -ve on error.
In which case should the function return an error? Or should I specify
that it can return an error, but let the function always return 0?
Best regards,
Patrick
> > + */
> > +u32 nvme_get_namespace_id(struct udevice *udev, u8 *eui64);
> > +
> > #endif /* __NVME_H__ */
>
> BTW: you can send this patch along with the EFI patch as a series.
>
> Regards,
> Bin
More information about the U-Boot
mailing list