Do PCIe switches know the address windows of their children? Meaning that when one child does an access to one of its peers (another child), the packet is sent directly to the other child rather than all the way up to the root? I'm not too familiar with how PCIe switches get enumerated, but perhaps it gets configured at that time?
Or does it just behave as a regular bus where every device "listens" for accesses to addresses within their BAR regions (implying that every packet gets broadcast to everyone)? However, I suppose that would be more like a hub rather than a switch...I'll do some more reading!
The device could query the root complex (the OS) to find the bus address of the device with a particular host memory address but I don't know if that is a common idiom.
(How this works with Multi-Root IO Virtualisation I'm not sure and it gives me a headache.)