From 7e52d75e2cce0eb12bbc284b0c67ab97c535f3e7 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 4 Jun 2026 09:05:07 +0100 Subject: [PATCH 1/2] SES: Correctly interpret element index field when EIIOE=1 --- src/lib/ses.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/ses.c b/src/lib/ses.c index 25901394..38fc8629 100644 --- a/src/lib/ses.c +++ b/src/lib/ses.c @@ -100,7 +100,7 @@ static void print_page10(struct ses_pages *sp) printf("\tDescriptor len (x-1): %d\n", ai[1] + 1); eip = ai[0] & 0x10; if (eip) - printf("\tElement Index: %d\n", ai[3]); + printf("\tElement Index: %d EIIOE: %d\n", ai[3], (ai[2] & 0x3)); len = ai[1] + 2; if ((ai[0] & 0xf) == SCSI_PROTOCOL_SAS) { if (eip) @@ -519,6 +519,13 @@ int ses_get_slots(struct ses_pages *sp, struct ses_slot **out_slots, int *out_sl ((uint64_t)addr_p[19]); slots[j].index = ap[0] & 0x10 ? ap[3] : j; + + // If EIIOE=1, ELEMENT INDEX includes overall elements, otherwise not. + // As (Array) Device Slot elements are always first in the list, there + // will be exactly one overall element that needs to be ignored. + if ((ap[0] & 0x10) && ((ap[2] & 0x3) == 0x01)) + slots[j].index--; + get_led_status(sp, slots[j].index, &slots[j].ibpi_status); } From 2ff6b3ae86044596ac8fe80eadd40316ab2b852a Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 4 Jun 2026 09:14:30 +0100 Subject: [PATCH 2/2] Spaces to tabs --- src/lib/ses.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/ses.c b/src/lib/ses.c index 38fc8629..307ab821 100644 --- a/src/lib/ses.c +++ b/src/lib/ses.c @@ -520,11 +520,11 @@ int ses_get_slots(struct ses_pages *sp, struct ses_slot **out_slots, int *out_sl slots[j].index = ap[0] & 0x10 ? ap[3] : j; - // If EIIOE=1, ELEMENT INDEX includes overall elements, otherwise not. - // As (Array) Device Slot elements are always first in the list, there - // will be exactly one overall element that needs to be ignored. - if ((ap[0] & 0x10) && ((ap[2] & 0x3) == 0x01)) - slots[j].index--; + // If EIIOE=1, ELEMENT INDEX includes overall elements, otherwise not. + // As (Array) Device Slot elements are always first in the list, there + // will be exactly one overall element that needs to be ignored. + if ((ap[0] & 0x10) && ((ap[2] & 0x3) == 0x01)) + slots[j].index--; get_led_status(sp, slots[j].index, &slots[j].ibpi_status); }