by support »
Hello,
One can view a PCIe bus as a tree of switches. Each switch has one upstream port, which is directed towards the root complex (the CPU or its memory chipset in most cases), and several downstream ports, which go to endpoints or other switches. There's always at least one such switch, which is the one next to the root complex.
When the host boots, it performs an enumeration on the PCIe bus (typically done by the BIOS on PCs). Among others, this enumeration includes assigning a segment of physical addresses to each of the downstream ports of each switch, as required (according to BAR entries, or a bit more complicated for PCIe switches / bridges).
So each switch has a memory segment allocated to each of its downstream ports. If a certain downstream port is connected to an endpoint, this memory segment consists of the address range(s) required by this endpoint (possibly with some holes). If there's a switch connected to this port, the address range is allocated so as to satisfy that switch' needs for covering the downstream ports it has.
Now to routing: Whenever a TLP packet that is routed by memory address reaches any of these switches, the switch checks if the address is within one of the ranges allocated to its downstream ports. If so, the packet is routed to that downstream port. If not, it goes to the upstream port.
This simple routing method allows routing packets towards the root complex for addresses that aren't covered by any endpoint, as well as peer-to-peer routing, possibly without going through the root complex' switch.
Regards,
Eli