]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi: device path for nvme
authorPatrick Wildt <patrick@blueri.se>
Thu, 3 Oct 2019 14:24:17 +0000 (16:24 +0200)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Sun, 6 Oct 2019 14:02:37 +0000 (16:02 +0200)
This allows our EFI API to create a device path node for NVMe
devices.  It adds the necessary device path struct, uses the
nvme namespace accessor to retrieve the id and eui64, and also
provides support for the device path text protocol.

Signed-off-by: Patrick Wildt <patrick@blueri.se>
Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
include/efi_api.h
lib/efi_loader/efi_device_path.c
lib/efi_loader/efi_device_path_to_text.c

index 37e56da46030883010d55ba524cf74c198ca9cc9..22396172e15f258155b6b3d9093985c10e85fd58 100644 (file)
@@ -422,6 +422,7 @@ struct efi_device_path_acpi_path {
 #  define DEVICE_PATH_SUB_TYPE_MSG_USB         0x05
 #  define DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR    0x0b
 #  define DEVICE_PATH_SUB_TYPE_MSG_USB_CLASS   0x0f
+#  define DEVICE_PATH_SUB_TYPE_MSG_NVME                0x17
 #  define DEVICE_PATH_SUB_TYPE_MSG_SD          0x1a
 #  define DEVICE_PATH_SUB_TYPE_MSG_MMC         0x1d
 
@@ -464,6 +465,12 @@ struct efi_device_path_sd_mmc_path {
        u8 slot_number;
 } __packed;
 
+struct efi_device_path_nvme {
+       struct efi_device_path dp;
+       u32 ns_id;
+       u8 eui64[8];
+} __packed;
+
 #define DEVICE_PATH_TYPE_MEDIA_DEVICE          0x04
 #  define DEVICE_PATH_SUB_TYPE_HARD_DRIVE_PATH 0x01
 #  define DEVICE_PATH_SUB_TYPE_CDROM_PATH      0x02
index 86297bb7c1166537a9625adbbfd32355013fc575..897fc1b2e8ac38f57819ab8157da4b968ea7428e 100644 (file)
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <usb.h>
 #include <mmc.h>
+#include <nvme.h>
 #include <efi_loader.h>
 #include <part.h>
 #include <sandboxblockdev.h>
@@ -451,6 +452,11 @@ static unsigned dp_size(struct udevice *dev)
                        return dp_size(dev->parent) +
                                sizeof(struct efi_device_path_sd_mmc_path);
 #endif
+#if defined(CONFIG_NVME)
+               case UCLASS_NVME:
+                       return dp_size(dev->parent) +
+                               sizeof(struct efi_device_path_nvme);
+#endif
 #ifdef CONFIG_SANDBOX
                case UCLASS_ROOT:
                         /*
@@ -583,6 +589,20 @@ static void *dp_fill(void *buf, struct udevice *dev)
                        sddp->slot_number = dev->seq;
                        return &sddp[1];
                        }
+#endif
+#if defined(CONFIG_NVME)
+               case UCLASS_NVME: {
+                       struct efi_device_path_nvme *dp =
+                               dp_fill(buf, dev->parent);
+                       u32 ns_id;
+
+                       dp->dp.type     = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
+                       dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_NVME;
+                       dp->dp.length   = sizeof(*dp);
+                       nvme_get_namespace_id(dev, &ns_id, dp->eui64);
+                       memcpy(&dp->ns_id, &ns_id, sizeof(ns_id));
+                       return &dp[1];
+                       }
 #endif
                default:
                        debug("%s(%u) %s: unhandled parent class: %s (%u)\n",
index 0f3796b373bb8707902d90d13b9d75d75fcbaa3c..af1adbb71efebf40a2264ff3cf5e66087164a934 100644 (file)
@@ -148,6 +148,21 @@ static char *dp_msging(char *s, struct efi_device_path *dp)
 
                break;
        }
+       case DEVICE_PATH_SUB_TYPE_MSG_NVME: {
+               struct efi_device_path_nvme *ndp =
+                       (struct efi_device_path_nvme *)dp;
+               u32 ns_id;
+               int i;
+
+               memcpy(&ns_id, &ndp->ns_id, sizeof(ns_id));
+               s += sprintf(s, "NVMe(0x%x,", ns_id);
+               for (i = 0; i < sizeof(ndp->eui64); ++i)
+                       s += sprintf(s, "%s%02x", i ? "-" : "",
+                                    ndp->eui64[i]);
+               s += sprintf(s, ")");
+
+               break;
+       }
        case DEVICE_PATH_SUB_TYPE_MSG_SD:
        case DEVICE_PATH_SUB_TYPE_MSG_MMC: {
                const char *typename =