[PATCH v3] config_tool: add MAX_PCI_BUS_NUM in UI


Zhao, Yuanyuan
 

Add MAX_PCI_BUS_NUM in UI for user.
If user defined MAX_PCI_BUS_NUM is greater than the value
calculated by board.xml, use user defined MAX_PCI_BUS_NUM.

v3->v2:
1.Remove minoccurs.
2.Add assertion for user default MAX_PCI_BUS_NUM error.

v2->v1:
1.Hide MAX_PCI_BUS_NUM in UI.
2.Set default as 0.

Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@...>
---
misc/config_tools/schema/config.xsd | 5 +++++
misc/config_tools/static_allocators/board_capability.py | 9 ++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/misc/config_tools/schema/config.xsd b/misc/config_tools/schema/config.xsd
index ddea58c22..4cb164725 100644
--- a/misc/config_tools/schema/config.xsd
+++ b/misc/config_tools/schema/config.xsd
@@ -172,6 +172,11 @@ If your VM is not a security VM, leave this option unchecked. </xs:documentation
</xs:restriction>
</xs:simpleType>
</xs:element>
+ <xs:element name="MAX_PCI_BUS_NUM" type="xs:integer" default="0">
+ <xs:annotation acrn:views="">
+ <xs:documentation>Specify the maximum number of PCI buses. The default value is calculated from the board configuration file. Integer from 1 to 256.</xs:documentation>
+ </xs:annotation>
+ </xs:element>
<xs:element name="MAX_PCI_DEV_NUM" default="96">
<xs:annotation acrn:title="Max PCI devices" acrn:views="advanced">
<xs:documentation>Specify the maximum number of PCI devices. This impacts the amount of memory used to maintain information about these PCI devices. The default value is calculated from the board configuration file. If you have PCI devices that were not detected by the Board Inspector, you may need to change this maximum value.</xs:documentation>
diff --git a/misc/config_tools/static_allocators/board_capability.py b/misc/config_tools/static_allocators/board_capability.py
index 141afca9c..a83cbfc31 100644
--- a/misc/config_tools/static_allocators/board_capability.py
+++ b/misc/config_tools/static_allocators/board_capability.py
@@ -5,6 +5,7 @@
# SPDX-License-Identifier: BSD-3-Clause
#

+from struct import calcsize
import common

def powerof2_roundup(value):
@@ -22,5 +23,11 @@ def create_max_ir_entries(scenario_etree, allocation_etree):

def fn(board_etree, scenario_etree, allocation_etree):
pci_bus_nums = board_etree.xpath("//bus[@type='pci']/@address")
- common.append_node("/acrn-config/platform/MAX_PCI_BUS_NUM", hex(max(map(lambda x: int(x, 16), pci_bus_nums)) + 1), allocation_etree)
+ calc_pci_bus_nums = (max(map(lambda x: int(x, 16), pci_bus_nums)) + 1)
+ user_def_pci_bus_nums = common.get_node(f"//MAX_PCI_BUS_NUM/text()", scenario_etree)
+ if user_def_pci_bus_nums == '0':
+ common.append_node("/acrn-config/platform/MAX_PCI_BUS_NUM", hex(calc_pci_bus_nums), allocation_etree)
+ else:
+ assert calc_pci_bus_nums <= int(user_def_pci_bus_nums), f"MAX_PCI_BUS_NUM should be greater than {calc_pci_bus_nums}"
+ common.append_node("/acrn-config/platform/MAX_PCI_BUS_NUM", hex(int(user_def_pci_bus_nums)), allocation_etree)
create_max_ir_entries(scenario_etree, allocation_etree)
--
2.25.1

Join acrn-dev@lists.projectacrn.org to automatically receive all group messages.