The branch main has been updated by michaelo:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=acdb2cdcd6ec6738c4f523df09ccd55404c6eb55

commit acdb2cdcd6ec6738c4f523df09ccd55404c6eb55
Author:     Michael Osipov <[email protected]>
AuthorDate: 2026-09-13 19:55:28 +0000
Commit:     Michael Osipov <[email protected]>
CommitDate: 2026-09-16 08:40:55 +0000

    mfiutil(8)/mrsasutil(8): display/parse enclosure by device ID (EID)
    
    mfi_drive_name() built the "Exx:Syy" drive location string using
    struct mfi_pd_info's encl_index field, the enclosure's firmware-
    internal position index. Broadcom's own storcli/MegaCli tooling
    instead leads with the enclosure's Device ID (EID) in its primary
    drive listing; encl_index only shows up as "Position" in a detailed
    per-enclosure view. Both numbers are raw, unmodified firmware values
    already fetched into struct mfi_pd_info/mfi_pd_address, but only
    encl_index was ever displayed or accepted as input, leading to
    confusion when cross-referencing drive locations against storcli
    output.
    
    Switch mfi_drive_name() and mfi_lookup_drive() to use encl_device_id
    instead, aligning FreeBSD's enclosure numbering with Broadcom's own
    utilities. Since mrsasutil(8) is the same binary as mfiutil(8) under
    a different name, this applies to both mfi(4) and mrsas(4) alike.
    
    This is a user-visible behavior change: the numeric value of "xx" in
    "Exx:Syy" now differs from before for any enclosure whose EID and
    position index don't match, affecting anyone scripting against the
    previous numbering.
    
    PR:             294353
    Reviewed by:    imp
    Relnotes:       yes
    Differential Revision:  https://reviews.freebsd.org/D59654
---
 UPDATING                     |  9 +++++++++
 usr.sbin/mfiutil/mfi_drive.c | 15 +++++++--------
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/UPDATING b/UPDATING
index 35c60c5363af..9cccbec2657b 100644
--- a/UPDATING
+++ b/UPDATING
@@ -27,6 +27,15 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 16.x IS SLOW:
        world, or to merely disable the most expensive debugging functionality
        at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
+20260916:
+       mfiutil(8)/mrsasutil(8) now display and parse the Exx:Syy drive
+       location notation using the controller's enclosure device ID (EID)
+       instead of its firmware-internal enclosure position index, aligning
+       with Broadcom's storcli/MegaCli tooling.  This changes the numeric
+       value of "xx" for enclosures where the two differ; scripts relying
+       on the previous numbering should be updated to use "show drives"
+       output or storcli's EID column.
+
 20260914:
        The size of multiple embedded structs have changed and may lead to
        problems (pci_error_handlers in pci_driver, dev_pm_info in struct 
device).
diff --git a/usr.sbin/mfiutil/mfi_drive.c b/usr.sbin/mfiutil/mfi_drive.c
index 88d24623ae27..1f0c40020762 100644
--- a/usr.sbin/mfiutil/mfi_drive.c
+++ b/usr.sbin/mfiutil/mfi_drive.c
@@ -108,10 +108,10 @@ mfi_drive_name(struct mfi_pd_info *pinfo, uint16_t 
device_id, uint32_t def)
                            pinfo->slot_number);
                else if (pinfo->encl_device_id == pinfo->ref.v.device_id)
                        sbuf_printf(&sb, "E%u",
-                           pinfo->encl_index);
+                           pinfo->encl_device_id);
                else
                        sbuf_printf(&sb, "E%u:S%u",
-                           pinfo->encl_index, pinfo->slot_number);
+                           pinfo->encl_device_id, pinfo->slot_number);
        }
        sbuf_finish(&sb);
 
@@ -156,7 +156,8 @@ mfi_lookup_drive(int fd, char *drive, uint16_t *device_id)
        int error;
        u_int i;
        char *cp;
-       uint8_t encl, slot;
+       uint16_t encl;
+       uint8_t slot;
 
        /* Look for a raw device id first. */
        val = strtol(drive, &cp, 0);
@@ -175,14 +176,14 @@ mfi_lookup_drive(int fd, char *drive, uint16_t *device_id)
                if (toupper(drive[0]) == 'E') {
                        cp++;                   /* Eat 'E' */
                        val = strtol(cp, &cp, 0);
-                       if (val < 0 || val > 0xff || *cp != ':')
+                       if (val < 0 || val >= 0xffff || *cp != ':')
                                goto bad;
                        encl = val;
                        cp++;                   /* Eat ':' */
                        if (toupper(*cp) != 'S')
                                goto bad;
                } else
-                       encl = 0xff;
+                       encl = 0xffff;
                cp++;                           /* Eat 'S' */
                if (*cp == '\0')
                        goto bad;
@@ -201,9 +202,7 @@ mfi_lookup_drive(int fd, char *drive, uint16_t *device_id)
                        if (list->addr[i].scsi_dev_type != 0)
                                continue;
 
-                       if (((encl == 0xff &&
-                           list->addr[i].encl_device_id == 0xffff) ||
-                           list->addr[i].encl_index == encl) &&
+                       if (list->addr[i].encl_device_id == encl &&
                            list->addr[i].slot_number == slot) {
                                *device_id = list->addr[i].device_id;
                                free(list);

Reply via email to