Re: [PATCH 11/13] PCI/P2PDMA: Add KUnit tests for ACS routing decisions

Logan Gunthorpe <[email protected]>
Newsgroups org.kernel.vger.linux-kernel,org.kernel.vger.linux-doc,org.kernel.vger.linux-pci
Message-ID <[email protected]>

On 2026-08-02 09:09, Leon Romanovsky wrote:
> From: Leon Romanovsky <[email protected]>
> 
> Add a KUnit suite exercising the ACS peer-to-peer routing logic:
> 
>   - pci_acs_p2pdma_decision(): the full PCIe table 6-11 truth table,
>     including the Egress Control Vector branches (bit set/clear, with and
>     without Request Redirect and Completion Redirect) that require a
>     switch implementing the Egress Control Vector and so cannot be
>     reached on commonly available hardware.
> 
>   - pci_acs_egress_port_valid(): the vector-size boundary, including the
>     "size 0 encodes 256 bits" case.
> 
>   - pci_acs_egress_ctrl_set(): driven through a fake pci_ops returning
>     canned config space, covering target Port Number extraction from
>     LNKCAP, the vector DWORD offset (target_port / 32), the bit position
>     (target_port % 32), the -ERANGE bound, and the unsupported-port
>     guards -- all without real hardware.
> 
> Run with:
> 
> cat > /tmp/pci-acs.kunitconfig <<'EOF'
> CONFIG_KUNIT=y
> CONFIG_PCI=y
> CONFIG_ZONE_DEVICE=y
> CONFIG_MEMORY_HOTPLUG=y
> CONFIG_MEMORY_HOTREMOVE=y
> CONFIG_SPARSEMEM_VMEMMAP=y
> CONFIG_PCI_P2PDMA=y
> CONFIG_PCI_ACS_KUNIT_TEST=y
> EOF
> 
> ./tools/testing/kunit/kunit.py run --arch=x86_64 \
>     --kunitconfig=/tmp/pci-acs.kunitconfig --jobs=$(nproc) pci_acs
> 
> Signed-off-by: Leon Romanovsky <[email protected]>
> Assisted-by: Claude Opus 4.8 <[email protected]>

Great, I like having Kunit tests for this kind of things. Thanks!

Reviewd-by: Logan Gunthorpe <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.