diff options
author | Thanos Makatos <thanos.makatos@nutanix.com> | 2020-12-08 10:58:29 -0500 |
---|---|---|
committer | Thanos Makatos <tmakatos@gmail.com> | 2020-12-11 12:54:21 +0000 |
commit | 90211fbd2c7c310df593736b18f1c99f053e2957 (patch) | |
tree | 03462a28541581cbf3ea6eb8f9fde05591c3e893 /include/pci_caps | |
parent | a7ecdc3de9f237d600ceaaa44285115a4e790829 (diff) | |
download | libvfio-user-90211fbd2c7c310df593736b18f1c99f053e2957.zip libvfio-user-90211fbd2c7c310df593736b18f1c99f053e2957.tar.gz libvfio-user-90211fbd2c7c310df593736b18f1c99f053e2957.tar.bz2 |
add support PCI vendor-specific capability
The PCI vendor-specific capability is blindly read/written by the
library. It is possible that the user might want to intercept accesses
to it, in which case we'll have to add callback. The best way to do this
to introduce a new function that configures callbacks for the PCI
capabilities, e.g.
typedef ssize_t (vfu_cap_access_t) (void *pvt, uint8_t id,
char *buf, size_t count, loff_t offset, bool is_write);
vfu_pci_cap_set_cb(vfu_ctx-T *vfu_ctx, uint8_t cap_id,
vfu_cap_access_t *cb);
This way the existing API won't have to change.
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'include/pci_caps')
-rw-r--r-- | include/pci_caps/common.h | 9 | ||||
-rw-r--r-- | include/pci_caps/pm.h | 21 |
2 files changed, 22 insertions, 8 deletions
diff --git a/include/pci_caps/common.h b/include/pci_caps/common.h index 7e158f0..a820f0d 100644 --- a/include/pci_caps/common.h +++ b/include/pci_caps/common.h @@ -45,6 +45,15 @@ _Static_assert(sizeof(struct cap_hdr) == 0x2, "bad PCI capability header size"); _Static_assert(offsetof(struct cap_hdr, id) == PCI_CAP_LIST_ID, "bad offset"); _Static_assert(offsetof(struct cap_hdr, next) == PCI_CAP_LIST_NEXT, "bad offset"); +/* + * Vendor-specific capability + */ +struct vsc { + struct cap_hdr hdr; + uint8_t size; + uint8_t data[]; +} __attribute__ ((packed)); + #ifdef __cplusplus } #endif diff --git a/include/pci_caps/pm.h b/include/pci_caps/pm.h index 3098299..6daa812 100644 --- a/include/pci_caps/pm.h +++ b/include/pci_caps/pm.h @@ -52,14 +52,19 @@ struct pc { _Static_assert(sizeof(struct pc) == 0x2, "bad PC size"); struct pmcs { - unsigned int ps:2; - unsigned int res1:1; - unsigned int nsfrst:1; - unsigned int res2:4; - unsigned int pmee:1; - unsigned int dse:4; - unsigned int dsc:2; - unsigned int pmes:1; + union { + uint16_t raw; + struct { + unsigned int ps:2; + unsigned int res1:1; + unsigned int nsfrst:1; + unsigned int res2:4; + unsigned int pmee:1; + unsigned int dse:4; + unsigned int dsc:2; + unsigned int pmes:1; + }; + }; } __attribute__((packed)); _Static_assert(sizeof(struct pc) == 0x2, "bad PMCS size"); |