From b4fd80d530fcf601563121ace8802a5542f8ff83 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 12 Apr 2021 17:19:42 -0400 Subject: [PATCH] Support SMMv2 variant of VPD The SMMv2 changed the get VPD command to echo back the reply bytes. For SMMv2, discard the first two bytes of the reply. Change-Id: I31a3c5442cfe15bf44201b5eae594485ac0a3a90 --- pyghmi/ipmi/oem/lenovo/handler.py | 2 +- pyghmi/ipmi/oem/lenovo/nextscale.py | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pyghmi/ipmi/oem/lenovo/handler.py b/pyghmi/ipmi/oem/lenovo/handler.py index b1181627..18a68a02 100755 --- a/pyghmi/ipmi/oem/lenovo/handler.py +++ b/pyghmi/ipmi/oem/lenovo/handler.py @@ -155,7 +155,7 @@ class OEMHandler(generic.OEMHandler): elif self.has_imm: self.immhandler = imm.IMMClient(ipmicmd) elif self.is_fpc: - self.smmhandler = nextscale.SMMClient(ipmicmd) + self.smmhandler = nextscale.SMMClient(ipmicmd, self.is_fpc) elif self.has_tsma: conn = wc.SecureHTTPConnection( ipmicmd.bmc, 443, diff --git a/pyghmi/ipmi/oem/lenovo/nextscale.py b/pyghmi/ipmi/oem/lenovo/nextscale.py index b1f258c3..4ab4bfd9 100644 --- a/pyghmi/ipmi/oem/lenovo/nextscale.py +++ b/pyghmi/ipmi/oem/lenovo/nextscale.py @@ -337,7 +337,8 @@ def get_sensor_reading(name, ipmicmd, sz): class SMMClient(object): - def __init__(self, ipmicmd): + def __init__(self, ipmicmd, variant): + self.smm_variant = variant self.ipmicmd = weakref.proxy(ipmicmd) self.smm = ipmicmd.bmc self.username = ipmicmd.ipmi_session.userid @@ -589,13 +590,17 @@ class SMMClient(object): return savefile def process_fru(self, fru): + smmv1 = self.smm_variant & 0xf0 == 0 # TODO(jjohnson2): can also get EIOM, SMM, and riser data if warranted - fru['Serial Number'] = bytes(self.ipmicmd.xraw_command( - netfn=0x32, command=0xb0, data=(5, 1))['data'][:]).strip( - b' \x00\xff').replace(b'\xff', b'') - fru['Model'] = bytes(self.ipmicmd.xraw_command( - netfn=0x32, command=0xb0, data=(5, 0))['data'][:]).strip( - b' \x00\xff').replace(b'\xff', b'') + snum = bytes(self.ipmicmd.xraw_command( + netfn=0x32, command=0xb0, data=(5, 1))['data'][:]) + mnum = bytes(self.ipmicmd.xraw_command( + netfn=0x32, command=0xb0, data=(5, 0))['data'][:]) + if not smmv1: + snum = snum[2:] + mnum = mnum[2:] + fru['Serial Number'] = snum.strip(b' \x00\xff').replace(b'\xff', b'') + fru['Model'] = mnum.strip(b' \x00\xff').replace(b'\xff', b'') return fru def get_webclient(self):