]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - platform-intel.h
Create.c: fix uclibc build
[thirdparty/mdadm.git] / platform-intel.h
index 6b4ebd817dde54dc59aa1b5ed3dff48aae5096e8..3c2bc595f7b53e12905e2a0903b04eaf939323cb 100644 (file)
 #include <asm/types.h>
 #include <strings.h>
 
+/* according to GUID format: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" */
+#define GUID_STR_MAX   37
+
 /* The IMSM Capability (IMSM AHCI and ISCU OROM/EFI variable) Version Table definition */
 struct imsm_orom {
        __u8 signature[4];
        #define IMSM_OROM_SIGNATURE "$VER"
        #define IMSM_NVME_OROM_COMPAT_SIGNATURE "$NVM"
+       #define IMSM_VMD_OROM_COMPAT_SIGNATURE "$VMD"
        __u8 table_ver_major; /* Currently 2 (can change with future revs) */
        __u8 table_ver_minor; /* Currently 2 (can change with future revs) */
        __u16 major_ver; /* Example: 8 as in 8.6.0.1020 */
@@ -65,11 +69,13 @@ struct imsm_orom {
        __u16 tds; /* Total Disks Supported */
        #define IMSM_OROM_TOTAL_DISKS 6
        #define IMSM_OROM_TOTAL_DISKS_NVME 12
+       #define IMSM_OROM_TOTAL_DISKS_VMD 48
        __u8 vpa; /* # Volumes Per Array supported */
        #define IMSM_OROM_VOLUMES_PER_ARRAY 2
        __u8 vphba; /* # Volumes Per Host Bus Adapter supported */
        #define IMSM_OROM_VOLUMES_PER_HBA 4
        #define IMSM_OROM_VOLUMES_PER_HBA_NVME 4
+       #define IMSM_OROM_VOLUMES_PER_HBA_VMD 24
        /* Attributes supported. This should map to the
         * attributes in the MPB. Also, lower 16 bits
         * should match/duplicate RLC bits above.
@@ -99,6 +105,8 @@ struct imsm_orom {
        #define IMSM_OROM_CAPABILITIES_Rohi (1 << 5)
        #define IMSM_OROM_CAPABILITIES_ReadPatrol (1 << 6)
        #define IMSM_OROM_CAPABILITIES_XorHw (1 << 7)
+       #define IMSM_OROM_CAPABILITIES_SKUMode ((1 << 8)|(1 << 9))
+       #define IMSM_OROM_CAPABILITIES_TPV (1 << 10)
 } __attribute__((packed));
 
 static inline int imsm_orom_has_raid0(const struct imsm_orom *orom)
@@ -167,17 +175,40 @@ static inline int fls(int x)
                r -= 2;
        }
        if (!(x & 0x80000000u)) {
-               x <<= 1;
                r -= 1;
        }
        return r;
 }
 
+static inline int imsm_orom_is_enterprise(const struct imsm_orom *orom)
+{
+       return !!(orom->driver_features & IMSM_OROM_CAPABILITIES_EnterpriseSystem);
+}
+
+static inline int imsm_orom_is_nvme(const struct imsm_orom *orom)
+{
+       return memcmp(orom->signature, IMSM_NVME_OROM_COMPAT_SIGNATURE,
+                     sizeof(orom->signature)) == 0;
+}
+
+static inline int imsm_orom_is_vmd_without_efi(const struct imsm_orom *orom)
+{
+       return memcmp(orom->signature, IMSM_VMD_OROM_COMPAT_SIGNATURE,
+                     sizeof(orom->signature)) == 0;
+}
+
+static inline int imsm_orom_has_tpv_support(const struct imsm_orom *orom)
+{
+       return !!(orom->driver_features & IMSM_OROM_CAPABILITIES_TPV);
+}
+
 enum sys_dev_type {
        SYS_DEV_UNKNOWN = 0,
        SYS_DEV_SAS,
        SYS_DEV_SATA,
        SYS_DEV_NVME,
+       SYS_DEV_VMD,
+       SYS_DEV_SATA_VMD,
        SYS_DEV_MAX
 };
 
@@ -194,10 +225,23 @@ struct efi_guid {
        __u8 b[16];
 };
 
+struct devid_list {
+       __u16 devid;
+       struct devid_list *next;
+};
+
+struct orom_entry {
+       struct imsm_orom orom;
+       struct devid_list *devid_list;
+       enum sys_dev_type type;
+       struct orom_entry *next;
+};
+
+extern struct orom_entry *orom_entries;
+
 static inline char *guid_str(char *buf, struct efi_guid guid)
 {
-       sprintf(buf, "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-                    "%02x%02x-%02x%02x%02x%02x%02x%02x",
+       snprintf(buf, GUID_STR_MAX, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
                 guid.b[3], guid.b[2], guid.b[1], guid.b[0],
                 guid.b[5], guid.b[4], guid.b[7], guid.b[6],
                 guid.b[8], guid.b[9], guid.b[10], guid.b[11],
@@ -205,14 +249,23 @@ static inline char *guid_str(char *buf, struct efi_guid guid)
        return buf;
 }
 
-char *diskfd_to_devpath(int fd);
+char *get_nvme_multipath_dev_hw_path(const char *dev_path);
+char *diskfd_to_devpath(int fd, int dev_level, char *buf);
+int devpath_to_char(const char *dev_path, const char *entry, char *buf,
+                   int len, int verbose);
+__u16 devpath_to_vendor(const char *dev_path);
 struct sys_dev *find_driver_devices(const char *bus, const char *driver);
 struct sys_dev *find_intel_devices(void);
 const struct imsm_orom *find_imsm_capability(struct sys_dev *hba);
 const struct imsm_orom *find_imsm_orom(void);
 int disk_attached_to_hba(int fd, const char *hba_path);
 int devt_attached_to_hba(dev_t dev, const char *hba_path);
-char *devt_to_devpath(dev_t dev);
+char *devt_to_devpath(dev_t dev, int dev_level, char *buf);
 int path_attached_to_hba(const char *disk_path, const char *hba_path);
-const char *get_sys_dev_type(enum sys_dev_type);
+const struct orom_entry *get_orom_entry_by_device_id(__u16 dev_id);
 const struct imsm_orom *get_orom_by_device_id(__u16 device_id);
+struct sys_dev *device_by_id(__u16 device_id);
+struct sys_dev *device_by_id_and_path(__u16 device_id, const char *path);
+int is_multipath_nvme(int disk_fd);
+int imsm_is_nvme_namespace_supported(int disk_fd, int verbose);
+char *vmd_domain_to_controller(struct sys_dev *hba, char *buf);