def add_downstream_port(self, addr): """ Add downstream port of the certain address """ if addr not in self.__downstream_ports: bus_id = "%s.%s" % (self.busid, int(addr, 16)) bus = QPCIBus(bus_id, 'PCIE', bus_id) self.__downstream_ports[addr] = bus downstream = qdevices.QDevice(self.__downstream_type, {'id': bus_id, 'bus': self.busid, 'addr': addr}, aobject=self.aobject, parent_bus={'busid': '_PCI_CHASSIS'}, child_bus=bus) return downstream
def _add_root_port(self, addr, root_port_type, multifunction="off"): """ Generate pcie-root-port QDevice object with certain addr and id :param addr: addr to add the root port :param root_port_type: root port type :param multifunction: if multifunction on or off :return: pcie-root-port QDevice object """ _addr = int(addr, 16) bus_id = "%s-root-port-%s" % (self.busid, _addr) length = 1 if multifunction == "off" else 8 bus = QPCIBus(bus_id, 'PCIE', bus_id, length=length) params = {'id': bus_id} return qdevices.QDevice(root_port_type, params, aobject=bus_id, parent_bus=[{ 'aobject': self.aobject }], child_bus=bus)