git: bce02a0ea43a - main - mpsutil: Fix device speed reporting.

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Mon, 09 May 2022 22:03:33 UTC
The branch main has been updated by mav:

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

commit bce02a0ea43a0cd4ee9aa23c815189d2ccb83745
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2022-05-09 21:57:29 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2022-05-09 22:03:24 +0000

    mpsutil: Fix device speed reporting.
    
    Report controller SAS phy speed only for directly attached devices.
    For others try to read and report parent expander phy speed.
    
    MFC after:      1 week
---
 usr.sbin/mpsutil/mps_show.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/usr.sbin/mpsutil/mps_show.c b/usr.sbin/mpsutil/mps_show.c
index d293003fc67f..ef20cd942d86 100644
--- a/usr.sbin/mpsutil/mps_show.c
+++ b/usr.sbin/mpsutil/mps_show.c
@@ -577,9 +577,12 @@ show_devices(int ac, char **av)
 
 		type = get_device_type(le32toh(device->DeviceInfo));
 
-		if (device->PhyNum < nphys) {
-			phydata = &sas0->PhyData[device->PhyNum];
-			speed = get_device_speed(phydata->NegotiatedLinkRate);
+		if (device->DeviceInfo & 0x800) {	/* Direct Attached */
+			if (device->PhyNum < nphys) {
+				phydata = &sas0->PhyData[device->PhyNum];
+				speed = get_device_speed(phydata->NegotiatedLinkRate);
+			} else
+				speed = "";
 		} else if (device->ParentDevHandle > 0) {
 			exp1 = mps_read_extended_config_page(fd,
 			    MPI2_CONFIG_EXTPAGETYPE_SAS_EXPANDER,
@@ -597,13 +600,13 @@ show_devices(int ac, char **av)
 					free(device);
 					return (error);
 				}
-				speed = " ";
+				speed = "";
 			} else {
 				speed = get_device_speed(exp1->NegotiatedLinkRate);
 				free(exp1);
 			}
 		} else
-			speed = " ";
+			speed = "";
 
 		if (device->EnclosureHandle != 0) {
 			snprintf(enchandle, sizeof(enchandle), "%04x", le16toh(device->EnclosureHandle));