From 46dadc8cc4e8cd7ac5adc2b8ac421570ee9cade4 Mon Sep 17 00:00:00 2001 From: Matthew Rosato Date: Wed, 29 May 2024 12:28:50 -0400 Subject: [PATCH] libap: add routine to check for dynamic config support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For a given vfio-ap mdev, determine whether or not the device will need dynamic config operations. This boils down to whether or not the device is currently active + whether or not the kernel is detected to support dynamic config operations (via the 'ap_config' sysfs attribute). Reviewed-by: Boris Fiuczynski Reviewed-by: Anthony Krowiak Signed-off-by: Matthew Rosato Signed-off-by: Jan Höppner --- include/lib/ap.h | 1 + libap/ap.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/lib/ap.h b/include/lib/ap.h index 057a78e4..e749f47a 100644 --- a/include/lib/ap.h +++ b/include/lib/ap.h @@ -72,6 +72,7 @@ char *path_get_ap_udev(void); void vfio_ap_parse_matrix(struct vfio_ap_device *dev, char *matrix); void vfio_ap_sort_matrix_results(struct vfio_ap_device *dev); void vfio_ap_parse_control(struct vfio_ap_device *dev, char *control); +bool vfio_ap_need_dynamic_config(struct vfio_ap_device *dev); /* Functions for reading JSON device config */ int vfio_ap_read_device_config(const char *path, struct vfio_ap_device *dev); diff --git a/libap/ap.c b/libap/ap.c index 6a2aa746..d5116d8d 100644 --- a/libap/ap.c +++ b/libap/ap.c @@ -416,6 +416,28 @@ void vfio_ap_parse_control(struct vfio_ap_device *dev, char *control) } } +/** + * Determine if the specified device is currently active. If so, see if + * it is enabled for dynamic configuration support. + * + * @param[in] dev Vfio-ap struct + * + * @retval True Device is active and enabled for dynamic config + * @retval False Device is not active OR no dynamic config support + */ +bool vfio_ap_need_dynamic_config(struct vfio_ap_device *dev) +{ + char *attr = path_get_vfio_ap_attr(dev->uuid, "ap_config"); + + if (!attr) + return false; + + if (!util_path_is_readable(attr)) + return false; + + return true; +} + #ifdef HAVE_JSONC /**