From a164322f1c20ebe388c2e322473e0bfa0a8feb5c Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Mon, 27 Nov 2023 16:27:25 -0800 Subject: [PATCH] Remove dest_id from Tlp object; use completer_id instead Signed-off-by: Alex Forencich --- cocotbext/pcie/core/bridge.py | 6 +++--- cocotbext/pcie/core/device.py | 2 +- cocotbext/pcie/core/function.py | 18 +++++++++--------- cocotbext/pcie/core/rc.py | 4 ++-- cocotbext/pcie/core/tlp.py | 16 ++-------------- cocotbext/pcie/intel/ptile/ptile_model.py | 4 ++-- cocotbext/pcie/intel/s10/s10_model.py | 4 ++-- cocotbext/pcie/xilinx/us/tlp.py | 2 -- cocotbext/pcie/xilinx/us/us_model.py | 4 ++-- cocotbext/pcie/xilinx/us/usp_model.py | 4 ++-- 10 files changed, 25 insertions(+), 39 deletions(-) diff --git a/cocotbext/pcie/core/bridge.py b/cocotbext/pcie/core/bridge.py index eb86cb3..a0d2388 100644 --- a/cocotbext/pcie/core/bridge.py +++ b/cocotbext/pcie/core/bridge.py @@ -282,13 +282,13 @@ def match_tlp_secondary(self, tlp): return False elif tlp.fmt_type in {TlpType.CFG_READ_1, TlpType.CFG_WRITE_1}: # Config type 1 - return self.sec_bus_num <= tlp.dest_id.bus <= self.sub_bus_num and tlp.dest_id != PcieId(0, 0, 0) + return self.sec_bus_num <= tlp.completer_id.bus <= self.sub_bus_num and tlp.completer_id != PcieId(0, 0, 0) elif tlp.fmt_type in {TlpType.CPL, TlpType.CPL_DATA, TlpType.CPL_LOCKED, TlpType.CPL_LOCKED_DATA}: # Completion return self.sec_bus_num <= tlp.requester_id.bus <= self.sub_bus_num and tlp.requester_id != PcieId(0, 0, 0) elif tlp.fmt_type in {TlpType.MSG_ID, TlpType.MSG_DATA_ID}: # ID routed message - return self.sec_bus_num <= tlp.dest_id.bus <= self.sub_bus_num and tlp.dest_id != PcieId(0, 0, 0) + return self.sec_bus_num <= tlp.completer_id.bus <= self.sub_bus_num and tlp.completer_id != PcieId(0, 0, 0) elif tlp.fmt_type in {TlpType.IO_READ, TlpType.IO_WRITE}: # IO read/write return self.io_base <= tlp.address <= self.io_limit @@ -342,7 +342,7 @@ async def upstream_recv(self, tlp): # Route TLPs from primary side to secondary side if self.match_tlp_secondary(tlp): - if tlp.fmt_type in {TlpType.CFG_READ_1, TlpType.CFG_WRITE_1} and tlp.dest_id.bus == self.sec_bus_num: + if tlp.fmt_type in {TlpType.CFG_READ_1, TlpType.CFG_WRITE_1} and tlp.completer_id.bus == self.sec_bus_num: # config type 1 targeted to directly connected device; change to type 0 if tlp.fmt_type == TlpType.CFG_READ_1: tlp.fmt_type = TlpType.CFG_READ_0 diff --git a/cocotbext/pcie/core/device.py b/cocotbext/pcie/core/device.py index cd0ab2a..c0c8833 100644 --- a/cocotbext/pcie/core/device.py +++ b/cocotbext/pcie/core/device.py @@ -116,7 +116,7 @@ async def upstream_recv(self, tlp): # config type 0 # capture address information - self.bus_num = tlp.dest_id.bus + self.bus_num = tlp.completer_id.bus # pass TLP to function for f in self.functions: diff --git a/cocotbext/pcie/core/function.py b/cocotbext/pcie/core/function.py index 9e92d4d..1baa934 100644 --- a/cocotbext/pcie/core/function.py +++ b/cocotbext/pcie/core/function.py @@ -397,7 +397,7 @@ def match_io_bar(self, addr): def match_tlp(self, tlp): if tlp.fmt_type in {TlpType.CFG_READ_0, TlpType.CFG_WRITE_0}: # Config type 0 - return self.device_num == tlp.dest_id.device and self.function_num == tlp.dest_id.function + return self.device_num == tlp.completer_id.device and self.function_num == tlp.completer_id.function elif tlp.fmt_type in {TlpType.CFG_READ_1, TlpType.CFG_WRITE_1}: # Config type 1 return False @@ -545,13 +545,13 @@ async def perform_nonposted_operation(self, req, timeout=0, timeout_unit='ns'): return completions async def handle_config_0_read_tlp(self, tlp): - if tlp.dest_id.device == self.device_num and tlp.dest_id.function == self.function_num: + if tlp.completer_id.device == self.device_num and tlp.completer_id.function == self.function_num: self.log.info("Config type 0 read, reg 0x%03x", tlp.address >> 2) # capture address information - if self.bus_num != tlp.dest_id.bus: - self.log.info("Capture bus number %d", tlp.dest_id.bus) - self.pcie_id = self.pcie_id._replace(bus=tlp.dest_id.bus) + if self.bus_num != tlp.completer_id.bus: + self.log.info("Capture bus number %d", tlp.completer_id.bus) + self.pcie_id = self.pcie_id._replace(bus=tlp.completer_id.bus) # perform operation data = await self.read_config_register(tlp.address >> 2) @@ -572,14 +572,14 @@ async def handle_config_0_read_tlp(self, tlp): await self.upstream_send(cpl) async def handle_config_0_write_tlp(self, tlp): - if tlp.dest_id.device == self.device_num and tlp.dest_id.function == self.function_num: + if tlp.completer_id.device == self.device_num and tlp.completer_id.function == self.function_num: self.log.info("Config type 0 write, reg 0x%03x data 0x%08x", tlp.address >> 2, struct.unpack('L', dw)) else: if self.fmt in {TlpFmt.FOUR_DW, TlpFmt.FOUR_DW_DATA}: @@ -577,7 +567,7 @@ def unpack_header(cls, pkt): if tlp.fmt_type in {TlpType.CFG_READ_0, TlpType.CFG_WRITE_0, TlpType.CFG_READ_1, TlpType.CFG_WRITE_1}: dw, = struct.unpack_from('>L', pkt, 8) tlp.address = dw & 0xffc - tlp.dest_id = PcieId.from_int(dw >> 16) + tlp.completer_id = PcieId.from_int(dw >> 16) elif tlp.fmt in {TlpFmt.FOUR_DW, TlpFmt.FOUR_DW_DATA}: val, = struct.unpack_from('>Q', pkt, 8) tlp.address = val & 0xfffffffffffffffc @@ -631,7 +621,6 @@ def __eq__(self, other): self.bcm == other.bcm and self.byte_count == other.byte_count and self.requester_id == other.requester_id and - self.dest_id == other.dest_id and self.tag == other.tag and self.first_be == other.first_be and self.last_be == other.last_be and @@ -659,7 +648,6 @@ def __repr__(self): f"bcm={self.bcm}, " f"byte_count={self.byte_count}, " f"requester_id={self.requester_id!r}, " - f"dest_id={self.dest_id!r}, " f"tag={self.tag}, " f"first_be={self.first_be:#x}, " f"last_be={self.last_be:#x}, " diff --git a/cocotbext/pcie/intel/ptile/ptile_model.py b/cocotbext/pcie/intel/ptile/ptile_model.py index 4127594..7f0abd9 100644 --- a/cocotbext/pcie/intel/ptile/ptile_model.py +++ b/cocotbext/pcie/intel/ptile/ptile_model.py @@ -761,11 +761,11 @@ async def upstream_recv(self, tlp): # config type 0 # capture address information - self.bus_num = tlp.dest_id.bus + self.bus_num = tlp.completer_id.bus # pass TLP to function for f in self.functions: - if f.pcie_id == tlp.dest_id: + if f.pcie_id == tlp.completer_id: await f.upstream_recv(tlp) return diff --git a/cocotbext/pcie/intel/s10/s10_model.py b/cocotbext/pcie/intel/s10/s10_model.py index 0554ed8..f45dfe5 100644 --- a/cocotbext/pcie/intel/s10/s10_model.py +++ b/cocotbext/pcie/intel/s10/s10_model.py @@ -615,11 +615,11 @@ async def upstream_recv(self, tlp): # config type 0 # capture address information - self.bus_num = tlp.dest_id.bus + self.bus_num = tlp.completer_id.bus # pass TLP to function for f in self.functions: - if f.pcie_id == tlp.dest_id: + if f.pcie_id == tlp.completer_id: await f.upstream_recv(tlp) return diff --git a/cocotbext/pcie/xilinx/us/tlp.py b/cocotbext/pcie/xilinx/us/tlp.py index 6d0660b..7a9bcf6 100644 --- a/cocotbext/pcie/xilinx/us/tlp.py +++ b/cocotbext/pcie/xilinx/us/tlp.py @@ -532,7 +532,6 @@ def __eq__(self, other): self.bcm == other.bcm and self.byte_count == other.byte_count and self.requester_id == other.requester_id and - self.dest_id == other.dest_id and self.tag == other.tag and self.first_be == other.first_be and self.last_be == other.last_be and @@ -559,7 +558,6 @@ def __repr__(self): f"bcm={self.bcm}, " f"byte_count={self.byte_count}, " f"requester_id={self.requester_id!r}, " - f"dest_id={self.dest_id!r}, " f"tag={self.tag}, " f"first_be={self.first_be:#x}, " f"last_be={self.last_be:#x}, " diff --git a/cocotbext/pcie/xilinx/us/us_model.py b/cocotbext/pcie/xilinx/us/us_model.py index b97a07b..fa9a675 100644 --- a/cocotbext/pcie/xilinx/us/us_model.py +++ b/cocotbext/pcie/xilinx/us/us_model.py @@ -782,11 +782,11 @@ async def upstream_recv(self, tlp): return else: # capture address information - self.bus_num = tlp.dest_id.bus + self.bus_num = tlp.completer_id.bus # pass TLP to function for f in self.functions: - if f.pcie_id == tlp.dest_id: + if f.pcie_id == tlp.completer_id: await f.upstream_recv(tlp) return diff --git a/cocotbext/pcie/xilinx/us/usp_model.py b/cocotbext/pcie/xilinx/us/usp_model.py index 2eafe8f..63eb4ab 100644 --- a/cocotbext/pcie/xilinx/us/usp_model.py +++ b/cocotbext/pcie/xilinx/us/usp_model.py @@ -926,11 +926,11 @@ async def upstream_recv(self, tlp): return else: # capture address information - self.bus_num = tlp.dest_id.bus + self.bus_num = tlp.completer_id.bus # pass TLP to function for f in self.functions: - if f.pcie_id == tlp.dest_id: + if f.pcie_id == tlp.completer_id: await f.upstream_recv(tlp) return