Display retimer version of the FPGA device

This commit provides the retimer version of the FPGA device in
the host device query output.

Tests:
 Verified that retimer version is displayed when FPGA device exists.

Story: 2008972
Task: 43610

Change-Id: Ic16eab80146cf9ddd2237e2c51097fe014e2be88
Signed-off-by: Teresa Ho <teresa.ho@windriver.com>
This commit is contained in:
Teresa Ho 2021-10-12 21:17:40 -04:00
parent 52e78df5b1
commit ff3463978a
11 changed files with 85 additions and 0 deletions

View File

@ -4928,6 +4928,8 @@ itemNotFound (404)
"bitstream_id (optional) ", "plain", "xsd:string", "The bitstream id of the FPGA device."
"bmc_build_version (optional) ", "plain", "xsd:string", "The BMC build version of the FPGA device."
"bmc_fw_version (optional) ", "plain", "xsd:string", "The BMC firmware version of the FPGA device."
"retimer_a_version (optional) ", "plain", "xsd:string", "The retimer A version of the FPGA device."
"retimer_b_version (optional) ", "plain", "xsd:string", "The retimer B version of the FPGA device."
::
@ -5346,6 +5348,8 @@ itemNotFound (404)
"root_key": null,
"host_uuid": "35436a7d-ce05-4e5f-87ac-706fe7513ece",
"bmc_build_version": null,
"retimer_a_version": null,
"retimer_b_version": null,
"name": "pci_0000_b3_00_0",
"revoked_key_ids": null,
"numa_node": 1,

View File

@ -46,10 +46,12 @@ def _print_device_show(device):
fields += ['root_key', 'revoked_key_ids',
'boot_page', 'bitstream_id',
'bmc_build_version', 'bmc_fw_version',
'retimer_a_version', 'retimer_b_version',
'driver', 'sriov_vf_driver']
labels += ['root_key', 'revoked_key_ids',
'boot_page', 'bitstream_id',
'bmc_build_version', 'bmc_fw_version',
'retimer_a_version', 'retimer_b_version',
'driver', 'sriov_vf_driver']
data = [(f, getattr(device, f, '')) for f in fields]

View File

@ -117,6 +117,12 @@ class PCIDevice(base.APIBase):
bmc_fw_version = wtypes.text
"Represent the BMC firmware version of the fpga device"
retimer_a_version = wtypes.text
"Represent the retimer A version of the fpga device"
retimer_b_version = wtypes.text
"Represent the retimer B version of the fpga device"
root_key = wtypes.text
"Represent the root key of the fpga device"
@ -152,6 +158,7 @@ class PCIDevice(base.APIBase):
'sriov_vf_pdevice_id', 'driver',
'host_uuid', 'enabled',
'bmc_build_version', 'bmc_fw_version',
'retimer_a_version', 'retimer_b_version',
'root_key', 'revoked_key_ids',
'boot_page', 'bitstream_id',
'created_at', 'updated_at',
@ -165,6 +172,8 @@ class PCIDevice(base.APIBase):
if device.pclass_id != dconstants.PCI_DEVICE_CLASS_FPGA:
device.bmc_build_version = wtypes.Unset
device.bmc_fw_version = wtypes.Unset
device.retimer_a_version = wtypes.Unset
device.retimer_b_version = wtypes.Unset
device.root_key = wtypes.Unset
device.revoked_key_ids = wtypes.Unset
device.boot_page = wtypes.Unset

View File

@ -14260,6 +14260,8 @@ class ConductorManager(service.PeriodicService):
attr = {
'bmc_build_version': fpga_dev['bmc_build_version'],
'bmc_fw_version': fpga_dev['bmc_fw_version'],
'retimer_a_version': fpga_dev.get('retimer_a_version', None),
'retimer_b_version': fpga_dev.get('retimer_b_version', None),
'root_key': fpga_dev['root_key'],
'revoked_key_ids': fpga_dev['revoked_key_ids'],
'boot_page': fpga_dev['boot_page'],

View File

@ -0,0 +1,25 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright (c) 2021 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
from sqlalchemy import Column, MetaData, Table, String
ENGINE = 'InnoDB'
CHARSET = 'utf8'
def upgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
fpga_devices = Table('fpga_devices', meta, autoload=True)
fpga_devices.create_column(Column('retimer_a_version', String(32)))
fpga_devices.create_column(Column('retimer_b_version', String(32)))
def downgrade(migrate_engine):
# Downgrade is unsupported in this release.
raise NotImplementedError('SysInv database downgrade is unsupported.')

View File

@ -1503,6 +1503,8 @@ class FpgaDevice(Base):
pciaddr = Column(String(32))
bmc_build_version = Column(String(32))
bmc_fw_version = Column(String(32))
retimer_a_version = Column(String(32))
retimer_b_version = Column(String(32))
root_key = Column(String(128))
revoked_key_ids = Column(String(512))
boot_page = Column(String(16))

View File

@ -95,6 +95,11 @@ CANCELLED_CSKS_PATH = "ifpga_sec_mgr/ifpga_sec*/security/sr_canceled_csks"
IMAGE_LOAD_PATH = "fpga_flash_ctrl/fpga_image_load"
BMC_FW_VER_PATH = "bmcfw_flash_ctrl/bmcfw_version"
BMC_BUILD_VER_PATH = "max10_version"
RETIMER_A_VER_PATH = "pkvl/pkvl_a_version"
RETIMER_B_VER_PATH = "pkvl/pkvl_b_version"
# Length of the retimer version in database
RETIMER_VERSION_LENGTH = 32
def wait_for_n3000_reset():
@ -331,6 +336,26 @@ def get_n3000_bmc_build_version(pci_addr):
return get_n3000_bmc_version(pci_addr, BMC_BUILD_VER_PATH)
def get_n3000_retimer_version(pci_addr, path):
version_pattern = (SYSFS_DEVICE_PATH + pci_addr + FME_PATH +
SPI_PATH + path)
version = read_n3000_sysfs_file(version_pattern)
if len(version) > RETIMER_VERSION_LENGTH:
LOG.warn("Retimer version string (%s) read from file %s is "
"unexpectedly long. It is truncating." %
(version, version_pattern))
version = version[:RETIMER_VERSION_LENGTH]
return version
def get_n3000_retimer_a_version(pci_addr):
return get_n3000_retimer_version(pci_addr, RETIMER_A_VER_PATH)
def get_n3000_retimer_b_version(pci_addr):
return get_n3000_retimer_version(pci_addr, RETIMER_B_VER_PATH)
def get_n3000_devices():
# First get the PCI addresses of each supported FPGA device
cmd = ["lspci", "-Dm", "-d " + constants.N3000_VENDOR + ":" +
@ -539,6 +564,8 @@ class FpgaAgentManager(service.PeriodicService):
fpgainfo = {'pciaddr': addr}
fpgainfo['bmc_build_version'] = get_n3000_bmc_build_version(addr)
fpgainfo['bmc_fw_version'] = get_n3000_bmc_fw_version(addr)
fpgainfo['retimer_a_version'] = get_n3000_retimer_a_version(addr)
fpgainfo['retimer_b_version'] = get_n3000_retimer_b_version(addr)
fpgainfo['boot_page'] = get_n3000_boot_page(addr)
fpgainfo['bitstream_id'] = get_n3000_bitstream_id(addr)
fpgainfo['root_key'] = get_n3000_root_hash(addr)

View File

@ -26,6 +26,8 @@ class FPGADevice(base.SysinvObject):
'pciaddr': utils.str_or_none,
'bmc_build_version': utils.str_or_none,
'bmc_fw_version': utils.str_or_none,
'retimer_a_version': utils.str_or_none,
'retimer_b_version': utils.str_or_none,
'root_key': utils.str_or_none,
'revoked_key_ids': utils.str_or_none,
'boot_page': utils.str_or_none,

View File

@ -40,6 +40,8 @@ class PCIDevice(base.SysinvObject):
'bmc_build_version': utils.str_or_none,
'bmc_fw_version': utils.str_or_none,
'retimer_a_version': utils.str_or_none,
'retimer_b_version': utils.str_or_none,
'root_key': utils.str_or_none,
'revoked_key_ids': utils.str_or_none,
'boot_page': utils.str_or_none,
@ -50,6 +52,8 @@ class PCIDevice(base.SysinvObject):
'host_uuid': 'host:uuid',
'bmc_build_version': 'fpga:bmc_build_version',
'bmc_fw_version': 'fpga:bmc_fw_version',
'retimer_a_version': 'fpga:retimer_a_version',
'retimer_b_version': 'fpga:retimer_b_version',
'root_key': 'fpga:root_key',
'revoked_key_ids': 'fpga:revoked_key_ids',
'boot_page': 'fpga:boot_page',
@ -59,6 +63,8 @@ class PCIDevice(base.SysinvObject):
_optional_fields = {
'bmc_build_version',
'bmc_fw_version',
'retimer_a_version',
'retimer_b_version',
'root_key',
'revoked_key_ids',
'boot_page',

View File

@ -3307,6 +3307,8 @@ class ManagerTestCase(base.DbTestCase):
'pciaddr': PCI_DEV_1['pciaddr'],
'bmc_build_version': 'D.2.0.6',
'bmc_fw_version': 'D.2.0.21',
'retimer_a_version': '101c.1064',
'retimer_b_version': '0000.0000',
'boot_page': 'user',
'bitstream_id': '0x2383A62A010504',
'root_key': '0x2973c55fc739e8181b16b9b51b786a39c0860159df8fb94652b0fbca87223bc7',
@ -3326,6 +3328,8 @@ class ManagerTestCase(base.DbTestCase):
'pciaddr': FPGA_DEV_1['pciaddr'],
'bmc_build_version': 'D.2.0.7',
'bmc_fw_version': 'D.2.0.22',
'retimer_a_version': '101c.105c',
'retimer_b_version': '0000.0000',
'boot_page': 'factory',
'bitstream_id': '0x2383A62A010504',
'root_key': '',

View File

@ -1438,6 +1438,8 @@ def get_test_fpga_device(**kw):
'pciaddr': kw.get('pciaddr', '0000:00:02.0'),
'bmc_build_version': kw.get('bmc_build_version'),
'bmc_fw_version': kw.get('bmc_fw_version'),
'retimer_a_version': kw.get('retimer_a_version'),
'retimer_b_version': kw.get('retimer_b_version'),
'root_key': kw.get('root_key'),
'revoked_key_ids': kw.get('revoked_key_ids'),
'boot_page': kw.get('boot_page'),