From 463165eca8e2c444339ee76079f5d6e71cc77c4b Mon Sep 17 00:00:00 2001 From: Md Irshad Sheikh Date: Mon, 11 Mar 2024 14:41:25 -0400 Subject: [PATCH] Adding QAT devices support in sysinv The commit adds code to auto discover QAT devices with ids 4940 & 4942 and list them as part of system host-device-list command. Also host-device-modify command has been modified to not allow any QAT device configuration due to upstream qat_service code limitations. Now QAT devices are already inited with max VF number and other default configurations during bootstrap, so no further modification is required. TEST CASES: PASSED: The development iso should be successfully deployed. And QAT devices should get listed using host-device-list command. PASSED: system host-device-modify command should raise error when tried to edit any QAT configuration. PASSED: system host-device-show command should show all default QAT device configurations. Story: 2010604 Task: 49701 Change-Id: Id6b00b9e69b233d513e42375d5f8196ddd745e20 Signed-off-by: Md Irshad Sheikh --- sysinv/sysinv/sysinv/sysinv/agent/pci.py | 10 ++++++-- .../sysinv/api/controllers/v1/pci_device.py | 19 +++++++++++++- .../sysinv/sysinv/sysinv/common/constants.py | 6 +++++ .../sysinv/sysinv/tests/api/test_device.py | 25 ++++++++++++++++++- 4 files changed, 56 insertions(+), 4 deletions(-) diff --git a/sysinv/sysinv/sysinv/sysinv/agent/pci.py b/sysinv/sysinv/sysinv/sysinv/agent/pci.py index 8b1baa1846..df11fccc50 100644 --- a/sysinv/sysinv/sysinv/sysinv/agent/pci.py +++ b/sysinv/sysinv/sysinv/sysinv/agent/pci.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2013-2023 Wind River Systems, Inc. +# Copyright (c) 2013-2024 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -39,7 +39,13 @@ KNOWN_PCI_DEVICES = [{"vendor_id": constants.NOVA_PCI_ALIAS_QAT_PF_VENDOR, "device_id": constants.NOVA_PCI_ALIAS_QAT_C62X_PF_DEVICE, "class_id": constants.NOVA_PCI_ALIAS_QAT_CLASS}, {"class_id": constants.NOVA_PCI_ALIAS_GPU_CLASS}, - {"class_id": dconstants.PCI_DEVICE_CLASS_FPGA}] + {"class_id": dconstants.PCI_DEVICE_CLASS_FPGA}, + {"vendor_id": constants.PCI_ALIAS_QAT_VENDOR, + "device_id": constants.PCI_ALIAS_QAT_4XXX_PF_DEVICE, + "class_id": constants.PCI_ALIAS_QAT_CLASS}, + {"vendor_id": constants.PCI_ALIAS_QAT_VENDOR, + "device_id": constants.PCI_ALIAS_QAT_401XX_PF_DEVICE, + "class_id": constants.PCI_ALIAS_QAT_CLASS}] # PCI-SIG 0x06 bridge devices to not inventory. IGNORE_BRIDGE_PCI_CLASSES = ['bridge', 'isa bridge', 'host bridge'] diff --git a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/pci_device.py b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/pci_device.py index a7774dab15..04b22324ad 100755 --- a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/pci_device.py +++ b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/pci_device.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2022 Wind River Systems, Inc. +# Copyright (c) 2015-2024 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -387,6 +387,23 @@ def _check_field(field): def _check_device_sriov(device, host): sriov_update = False + if (device['pdevice_id'] in constants.PCI_ALIAS_SRIOV_ENABLED_QAT_DEVICE_IDS): + LOG.debug("sriov enabled qat dev: %s" % device['pdevice_id']) + current_device = pecan.request.dbapi.pci_device_get(device['pciaddr'], + hostid=host['id']) + # Because of the limitations of the Intel qat_service code, only max number + # of VFs configuration is supported. Currently it is not allowed to modify + # the number of VFs and any other configuration using sysinv. Qat is already + # initialized with the max number of VFs at the time of bootstrap, so + # returning from here without doing any configuration. + msg = (_("QAT device is already initialized, " + "further modification not allowed. Details:- " + "devicename: {}, enabled status: {}, driver: {}, " + "VF driver: vfio, sriov numvfs: {}").format( + current_device['name'], current_device['enabled'], + current_device['driver'], current_device['sriov_numvfs'])) + raise wsme.exc.ClientSideError(msg) + if (device['pdevice_id'] in dconstants.SRIOV_ENABLED_FEC_DEVICE_IDS and host.invprovision not in [constants.UPGRADING, constants.PROVISIONED]): raise wsme.exc.ClientSideError(_("Cannot configure device %s " diff --git a/sysinv/sysinv/sysinv/sysinv/common/constants.py b/sysinv/sysinv/sysinv/sysinv/common/constants.py index c2e1375757..84b6869b37 100644 --- a/sysinv/sysinv/sysinv/sysinv/common/constants.py +++ b/sysinv/sysinv/sysinv/sysinv/common/constants.py @@ -1050,6 +1050,12 @@ NOVA_PCI_ALIAS_QAT_C62X_VF_NAME = "qat-c62x-vf" NOVA_PCI_ALIAS_QAT_VF_VENDOR = "8086" NOVA_PCI_ALIAS_QAT_DH895XCC_VF_DEVICE = "0443" NOVA_PCI_ALIAS_QAT_C62X_VF_DEVICE = "37c9" +PCI_ALIAS_QAT_CLASS = "0x0b4000" +PCI_ALIAS_QAT_VENDOR = "8086" +PCI_ALIAS_QAT_4XXX_PF_DEVICE = "4940" +PCI_ALIAS_QAT_401XX_PF_DEVICE = "4942" +PCI_ALIAS_SRIOV_ENABLED_QAT_DEVICE_IDS = [PCI_ALIAS_QAT_4XXX_PF_DEVICE, + PCI_ALIAS_QAT_401XX_PF_DEVICE] NOVA_PCI_ALIAS_USER_NAME = "user" # Service Parameter diff --git a/sysinv/sysinv/sysinv/sysinv/tests/api/test_device.py b/sysinv/sysinv/sysinv/sysinv/tests/api/test_device.py index b4a09c7ec8..76b0705c45 100644 --- a/sysinv/sysinv/sysinv/sysinv/tests/api/test_device.py +++ b/sysinv/sysinv/sysinv/sysinv/tests/api/test_device.py @@ -2,7 +2,7 @@ # -*- encoding: utf-8 -*- # # -# Copyright (c) 2020-2022 Wind River Systems, Inc. +# Copyright (c) 2020-2024 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -606,3 +606,26 @@ class TestPatchDevice(TestDevice): self.assertIn('The value for number of SR-IOV VFs must be > 0 when the ' 'VF driver is igb_uio', response.json['error_message']) + + def test_device_modify_sriov_qat_reset_all(self): + self.pci_device = dbutils.create_test_pci_device( + host_id=self.worker.id, + pclass_id=self.pclass_id, + pdevice_id=constants.PCI_ALIAS_QAT_401XX_PF_DEVICE, + driver='4xxx', + sriov_vf_driver='vfio', + sriov_totalvfs=16, + sriov_numvfs=16) + response = self.patch_dict_json( + '%s' % self._get_path(self.pci_device['uuid']), + driver='none', + sriov_vf_driver='none', + sriov_numvfs=0, + expect_errors=True) + self.assertEqual(http_client.BAD_REQUEST, response.status_int) + self.assertEqual('application/json', response.content_type) + self.assertTrue(response.json['error_message']) + self.assertIn('QAT device is already initialized, further modification ' + 'not allowed. Details:- devicename: pci_0000_00_02_0 , ' + 'enabled status: True, driver: 4xxx, VF driver: vfio, ' + 'sriov numvfs: 16', response.json['error_message'])