Skip to content

Commit e12aa0b

Browse files
Jason J. HerneAlexander Gordeev
authored andcommitted
s390/vfio-ap: Add sysfs attr, ap_config, to export mdev state
Add ap_config sysfs attribute. This will provide the means for setting or displaying the adapters, domains and control domains assigned to the vfio-ap mediated device in a single operation. This sysfs attribute is comprised of three masks: One for adapters, one for domains, and one for control domains. This attribute is intended to be used by mdevctl to query a vfio-ap mediated device's state. Signed-off-by: "Jason J. Herne" <jjherne@linux.ibm.com> Reviewed-by: Tony Krowiak <akrowiak@linux.ibm.com> Tested-by: Matthew Rosato <mjrosato@linux.ibm.com> Link: https://lore.kernel.org/r/20240415152555.13152-3-jjherne@linux.ibm.com Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
1 parent 6e69739 commit e12aa0b

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

drivers/s390/crypto/vfio_ap_ops.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,13 +1570,40 @@ static ssize_t guest_matrix_show(struct device *dev,
15701570
}
15711571
static DEVICE_ATTR_RO(guest_matrix);
15721572

1573+
static ssize_t write_ap_bitmap(unsigned long *bitmap, char *buf, int offset, char sep)
1574+
{
1575+
return sysfs_emit_at(buf, offset, "0x%016lx%016lx%016lx%016lx%c",
1576+
bitmap[0], bitmap[1], bitmap[2], bitmap[3], sep);
1577+
}
1578+
1579+
static ssize_t ap_config_show(struct device *dev, struct device_attribute *attr,
1580+
char *buf)
1581+
{
1582+
struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev);
1583+
int idx = 0;
1584+
1585+
idx += write_ap_bitmap(matrix_mdev->matrix.apm, buf, idx, ',');
1586+
idx += write_ap_bitmap(matrix_mdev->matrix.aqm, buf, idx, ',');
1587+
idx += write_ap_bitmap(matrix_mdev->matrix.adm, buf, idx, '\n');
1588+
1589+
return idx;
1590+
}
1591+
1592+
static ssize_t ap_config_store(struct device *dev, struct device_attribute *attr,
1593+
const char *buf, size_t count)
1594+
{
1595+
return count;
1596+
}
1597+
static DEVICE_ATTR_RW(ap_config);
1598+
15731599
static struct attribute *vfio_ap_mdev_attrs[] = {
15741600
&dev_attr_assign_adapter.attr,
15751601
&dev_attr_unassign_adapter.attr,
15761602
&dev_attr_assign_domain.attr,
15771603
&dev_attr_unassign_domain.attr,
15781604
&dev_attr_assign_control_domain.attr,
15791605
&dev_attr_unassign_control_domain.attr,
1606+
&dev_attr_ap_config.attr,
15801607
&dev_attr_control_domains.attr,
15811608
&dev_attr_matrix.attr,
15821609
&dev_attr_guest_matrix.attr,

0 commit comments

Comments
 (0)