public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Patrick Wildt <patrick@blueri.se>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] nvme: add accessor to namespace id and eui64
Date: Thu, 3 Oct 2019 12:33:36 +0200	[thread overview]
Message-ID: <20191003103336.GA49768@nox.fritz.box> (raw)
In-Reply-To: <CAEUhbmXZmpQ4K3ffuf3PoTjbSTsf7ORUj3sTWxzawrrpOg8OgQ@mail.gmail.com>

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@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@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

  reply	other threads:[~2019-10-03 10:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-02 21:11 [U-Boot] [PATCH] efi: device path for nvme Patrick Wildt
2019-10-03  3:06 ` Bin Meng
2019-10-03  6:48 ` Heinrich Schuchardt
2019-10-03  9:19   ` Patrick Wildt
2019-10-03  9:21   ` [U-Boot] [PATCH v2] " Patrick Wildt
2019-10-03  9:38     ` Bin Meng
2019-10-03  9:56       ` [U-Boot] [PATCH] nvme: add accessor to namespace id and eui64 Patrick Wildt
2019-10-03 10:25         ` Bin Meng
2019-10-03 10:33           ` Patrick Wildt [this message]
2019-10-03 10:36             ` Bin Meng
2019-10-03 11:01               ` [U-Boot] [PATCH 1/2] " Patrick Wildt
2019-10-03 11:13                 ` Bin Meng
2019-10-03 11:48                   ` [U-Boot] [PATCH v2 " Patrick Wildt
2019-10-03 11:52                     ` Bin Meng
2019-10-03 11:57                   ` [U-Boot] [PATCH v2 2/2] efi: device path for nvme Patrick Wildt
2019-10-03 11:02               ` [U-Boot] [PATCH " Patrick Wildt
2019-10-03 13:12                 ` Heinrich Schuchardt
2019-10-03 13:32                   ` Patrick Wildt
2019-10-03 14:24                   ` [U-Boot] [PATCH v3 " Patrick Wildt
2019-10-04 22:32                     ` Heinrich Schuchardt
2019-10-03  9:57       ` [U-Boot] [PATCH] " Patrick Wildt
2019-10-03 10:29         ` Bin Meng

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=20191003103336.GA49768@nox.fritz.box \
    --to=patrick@blueri.se \
    --cc=u-boot@lists.denx.de \
    /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