mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
libap: add routines to generate masks for vfio_ap_device
Add routines to generate mask values for the adapters, domains and control domains for a specified vfio_ap_device struct. Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Anthony Krowiak <akrowiak@linux.ibm.com> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
46dadc8cc4
commit
962af1a90e
@@ -88,6 +88,9 @@ bool ap_read_udev_masks(char *path, char *ap, char *aq, bool *read_ap,
|
||||
bool *read_aq);
|
||||
void ap_mask_to_list(char *mask, struct util_list *list);
|
||||
void ap_list_remove_all(struct util_list *list);
|
||||
char *vfio_ap_device_get_adapter_mask(struct vfio_ap_device *dev, int *size);
|
||||
char *vfio_ap_device_get_domain_mask(struct vfio_ap_device *dev, int *size);
|
||||
char *vfio_ap_device_get_control_mask(struct vfio_ap_device *dev, int *size);
|
||||
|
||||
/* Lock Functions */
|
||||
int ap_get_lock(void);
|
||||
|
||||
87
libap/ap.c
87
libap/ap.c
@@ -33,6 +33,9 @@
|
||||
#include "lib/util_path.h"
|
||||
#include "lib/util_udev.h"
|
||||
|
||||
static const char default_mask[AP_MASK_SIZE] =
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000000";
|
||||
|
||||
/*
|
||||
* Return sysfs path to a bus attribute
|
||||
* Note: caller is responsible for freeing the returned string
|
||||
@@ -737,6 +740,90 @@ static unsigned int random_delay(void)
|
||||
return AP_LOCK_DELAY_US + (rand() % AP_LOCK_VARIANCE_US);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a mask of assigned adapters for the specified vfio_ap device.
|
||||
* Note: caller is responsible for freeing the returned string
|
||||
*
|
||||
* @param[in] dev Vfio-ap struct to get adapter mask from
|
||||
* @param[in, out] size Size of mask buffer returned
|
||||
*
|
||||
* @retval != 0 Adapter mask (hex string)
|
||||
* @retval 0 Failed to generate a mask
|
||||
*/
|
||||
char *vfio_ap_device_get_adapter_mask(struct vfio_ap_device *dev, int *size)
|
||||
{
|
||||
struct vfio_ap_node *node;
|
||||
char *mask;
|
||||
|
||||
if (!dev || !size)
|
||||
return NULL;
|
||||
|
||||
mask = util_strdup(default_mask);
|
||||
*size = AP_MASK_SIZE;
|
||||
|
||||
util_list_iterate(dev->adapters, node) {
|
||||
ap_set_bit(node->id, mask, true);
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a mask of assigned domains for the specified vfio_ap device.
|
||||
* Note: caller is responsible for freeing the returned string
|
||||
*
|
||||
* @param[in] dev Vfio-ap struct to get domain mask from
|
||||
* @param[in, out] size Size of mask buffer returned
|
||||
*
|
||||
* @retval != 0 Domain mask (hex string)
|
||||
* @retval 0 Failed to generate a mask
|
||||
*/
|
||||
char *vfio_ap_device_get_domain_mask(struct vfio_ap_device *dev, int *size)
|
||||
{
|
||||
struct vfio_ap_node *node;
|
||||
char *mask;
|
||||
|
||||
if (!dev || !size)
|
||||
return NULL;
|
||||
|
||||
mask = util_strdup(default_mask);
|
||||
*size = AP_MASK_SIZE;
|
||||
|
||||
util_list_iterate(dev->domains, node) {
|
||||
ap_set_bit(node->id, mask, true);
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a mask of assigned control domains for the specified vfio_ap device.
|
||||
* Note: caller is responsible for freeing the returned string
|
||||
*
|
||||
* @param[in] dev Vfio-ap struct to get control domain mask from
|
||||
* @param[in, out] size Size of mask buffer returned
|
||||
*
|
||||
* @retval != 0 Control domain mask (hex string)
|
||||
* @retval 0 Failed to generate a mask
|
||||
*/
|
||||
char *vfio_ap_device_get_control_mask(struct vfio_ap_device *dev, int *size)
|
||||
{
|
||||
struct vfio_ap_node *node;
|
||||
char *mask;
|
||||
|
||||
if (!dev || !size)
|
||||
return NULL;
|
||||
|
||||
mask = util_strdup(default_mask);
|
||||
*size = AP_MASK_SIZE;
|
||||
|
||||
util_list_iterate(dev->controls, node) {
|
||||
ap_set_bit(node->id, mask, true);
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Acquire the ap config lock using this Process ID
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user