OFS / opae-sdk

Open Programmable Acceleration Engine
https://ofs.github.io
BSD 3-Clause "New" or "Revised" License
259 stars 82 forks source link

Feature: add a method for binding shared virtual addressing #3014

Closed michael-adler closed 1 year ago

michael-adler commented 1 year ago

Description

Add fpgaBindSVA() to allocate and bind PASIDs to FPGA ports. Shared virtual addressing requires hardware support, both in the CPU and on the FPGA.

fpgaBindSVA() depends on /dev/dfl-pci-sva from the dfl-pci driver. IOVA-based pinned DMA remains available with older drivers and hardware that does not support PASID.

OPAE behavior is unchanged when fpgaBindSVA() is not called.

Collateral (docs, reports, design examples, case IDs):

Tests added:

Tests run:

coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 6243520861


Changes Missing Coverage Covered Lines Changed/Added Lines %
libraries/libopae-c/api-shell.c 0 6 0.0%
libraries/plugins/vfio/opae_vfio.c 1 30 3.33%
<!-- Total: 3 38 7.89% -->
Files with Coverage Reduction New Missed Lines %
libraries/plugins/xfpga/open.c 1 74.68%
libraries/plugins/uio/opae_uio.c 4 90.18%
libraries/plugins/vfio/opae_vfio.c 4 82.64%
libraries/plugins/xfpga/mmio.c 6 82.87%
<!-- Total: 15 -->
Totals Coverage Status
Change from base Build 6238677251: -0.2%
Covered Lines: 15744
Relevant Lines: 21925

💛 - Coveralls
michael-adler commented 1 year ago

@rweight and @matthew-gerlach - These are the user space changes that go along with the dfl-pci driver updates.

Note that the changes here will work with old drivers. They won't find /dev/dfl-pci-sva and will be fine with that.

michael-adler commented 1 year ago

@tswhison - Thanks for going through this. I'll come back to it once the low-level device mechanism is set with @rweight. The general framework here will remain, but the details down inside opae_vfio.c are in flux.

michael-adler commented 1 year ago

@tswhison - I'm confused by the failed test at opae-sdk/tests/opae-v/test_opae_vfio_c.cpp:3246. I think I didn't change anything relevant.

I think the test causes vfio_fpgaDestroyEventHandle() to close fd 0. Seems like a bad idea.

michael-adler commented 1 year ago

@tswhison - I still think that opae-sdk/tests/opae-v/test_opae_vfio_c.cpp:3246 is a broken test since it closes fd 0. I exposed that bug by causing another test to do the same thing. My case is fixed in the latest commit by adding flags for pasid so that when the handle is initialized to 0 it doesn't look like there's a file open.

tswhison commented 1 year ago

Thanks for pointing this out. I will submit a fix.