On 10/21/20 12:59 PM, Shalini Chellathurai Saroja wrote:
Add support for AP matrix device in libvirt nodedev driver.
Signed-off-by: Shalini Chellathurai Saroja <shalini@xxxxxxxxxxxxx>
Reviewed-by: Bjoern Walk <bwalk@xxxxxxxxxxxxx>
Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>
---
docs/schemas/nodedev.rng | 7 ++++++
src/conf/node_device_conf.c | 10 +++++++-
src/conf/node_device_conf.h | 8 +++++++
src/conf/virnodedeviceobj.c | 1 +
src/node_device/node_device_udev.c | 23 +++++++++++++++++++
tests/nodedevschemadata/ap_matrix.xml | 7 ++++++
...v_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml | 9 ++++++++
tests/nodedevxml2xmltest.c | 2 ++
tools/virsh-nodedev.c | 1 +
9 files changed, 67 insertions(+), 1 deletion(-)
create mode 100644 tests/nodedevschemadata/ap_matrix.xml
create mode 100644 tests/nodedevschemadata/mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml
diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng
index 5f812c8f..7c017ff1 100644
--- a/docs/schemas/nodedev.rng
+++ b/docs/schemas/nodedev.rng
@@ -88,6 +88,7 @@
<ref name="capcssdev"/>
<ref name="capapcard"/>
<ref name="capapqueue"/>
+ <ref name="capapmatrix"/>
</choice>
</element>
</define>
@@ -698,6 +699,12 @@
</element>
</define>
+ <define name='capapmatrix'>
+ <attribute name='type'>
+ <value>ap_matrix</value>
+ </attribute>
+ </define>
+
<define name='address'>
<element name='address'>
<attribute name='domain'><ref name='hexuint'/></attribute>
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index d27b0c71..33c9a020 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -68,6 +68,7 @@ VIR_ENUM_IMPL(virNodeDevCap,
"css",
"ap_card",
"ap_queue",
+ "ap_matrix",
);
VIR_ENUM_IMPL(virNodeDevNetCap,
@@ -626,6 +627,7 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def)
case VIR_NODE_DEV_CAP_MDEV_TYPES:
case VIR_NODE_DEV_CAP_FC_HOST:
case VIR_NODE_DEV_CAP_VPORTS:
+ case VIR_NODE_DEV_CAP_AP_MATRIX:
case VIR_NODE_DEV_CAP_LAST:
break;
}
@@ -1995,6 +1997,9 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt,
ret = virNodeDevCapAPQueueParseXML(ctxt, def, node,
&caps->data.ap_queue);
break;
+ case VIR_NODE_DEV_CAP_AP_MATRIX:
+ ret = 0;
+ break;
case VIR_NODE_DEV_CAP_MDEV_TYPES:
case VIR_NODE_DEV_CAP_FC_HOST:
case VIR_NODE_DEV_CAP_VPORTS:
@@ -2310,6 +2315,9 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
virMediatedDeviceAttrFree(data->mdev.attributes[i]);
VIR_FREE(data->mdev.attributes);
break;
+ case VIR_NODE_DEV_CAP_AP_MATRIX:
+ VIR_FREE(data->ap_matrix.addr);
+ break;
case VIR_NODE_DEV_CAP_MDEV_TYPES:
case VIR_NODE_DEV_CAP_DRM:
case VIR_NODE_DEV_CAP_FC_HOST:
@@ -2374,6 +2382,7 @@ virNodeDeviceUpdateCaps(virNodeDeviceDefPtr def)
case VIR_NODE_DEV_CAP_CSS_DEV:
case VIR_NODE_DEV_CAP_AP_CARD:
case VIR_NODE_DEV_CAP_AP_QUEUE:
+ case VIR_NODE_DEV_CAP_AP_MATRIX:
case VIR_NODE_DEV_CAP_LAST:
break;
}
@@ -2722,7 +2731,6 @@ virNodeDeviceGetPCIDynamicCaps(const char *sysfsPath G_GNUC_UNUSED,
return -1;
}
-
This change is irrelevant. Please remove it.
int virNodeDeviceGetSCSITargetCaps(const char *sysfsPath G_GNUC_UNUSED,
virNodeDevCapSCSITargetPtr scsi_target G_GNUC_UNUSED)
{
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index d732efaa..f1e57ad7 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -67,6 +67,7 @@ typedef enum {
VIR_NODE_DEV_CAP_CSS_DEV, /* s390 channel subsystem device */
VIR_NODE_DEV_CAP_AP_CARD, /* s390 AP Card device */
VIR_NODE_DEV_CAP_AP_QUEUE, /* s390 AP Queue */
+ VIR_NODE_DEV_CAP_AP_MATRIX, /* s390 AP Matrix device */
VIR_NODE_DEV_CAP_LAST
} virNodeDevCapType;
@@ -290,6 +291,12 @@ struct _virNodeDevCapAPQueue {
unsigned int ap_domain;
};
+typedef struct _virNodeDevCapAPMatrix virNodeDevCapAPMatrix;
+typedef virNodeDevCapAPMatrix *virNodeDevCapAPMatrixPtr;
+struct _virNodeDevCapAPMatrix {
+ char *addr;
+};
+
typedef struct _virNodeDevCapData virNodeDevCapData;
typedef virNodeDevCapData *virNodeDevCapDataPtr;
struct _virNodeDevCapData {
@@ -310,6 +317,7 @@ struct _virNodeDevCapData {
virNodeDevCapCCW ccw_dev;
virNodeDevCapAPCard ap_card;
virNodeDevCapAPQueue ap_queue;
+ virNodeDevCapAPMatrix ap_matrix;
};
};
diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index 0ce230db..a19017b8 100644
--- a/src/conf/virnodedeviceobj.c
+++ b/src/conf/virnodedeviceobj.c
@@ -713,6 +713,7 @@ virNodeDeviceObjHasCap(const virNodeDeviceObj *obj,
case VIR_NODE_DEV_CAP_CSS_DEV:
case VIR_NODE_DEV_CAP_AP_CARD:
case VIR_NODE_DEV_CAP_AP_QUEUE:
+ case VIR_NODE_DEV_CAP_AP_MATRIX:
case VIR_NODE_DEV_CAP_LAST:
break;
}
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 16a73db2..ea983726 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1191,6 +1191,25 @@ udevProcessAPQueue(struct udev_device *device,
}
+static int
+udevProcessAPMatrix(struct udev_device *device,
+ virNodeDeviceDefPtr def)
+{
+ size_t i;
+ virNodeDevCapDataPtr data = &def->caps->data;
+
+ data->ap_matrix.addr = g_strdup(udev_device_get_sysname(device));
+ def->name = g_strdup_printf("ap_%s", data->ap_matrix.addr);
+
+ for (i = 0; i < strlen(def->name); i++) {
+ if (!(g_ascii_isalnum(*(def->name + i))))
+ *(def->name + i) = '_';
+ }
+
+ return 0;
+}
+
+
static int
udevGetDeviceNodes(struct udev_device *device,
virNodeDeviceDefPtr def)
@@ -1274,6 +1293,8 @@ udevGetDeviceType(struct udev_device *device,
*type = VIR_NODE_DEV_CAP_CCW_DEV;
else if (STREQ_NULLABLE(subsystem, "css"))
*type = VIR_NODE_DEV_CAP_CSS_DEV;
+ else if (STREQ_NULLABLE(subsystem, "matrix"))
+ *type = VIR_NODE_DEV_CAP_AP_MATRIX;
VIR_FREE(subsystem);
}
@@ -1324,6 +1345,8 @@ udevGetDeviceDetails(struct udev_device *device,
return udevProcessAPCard(device, def);
case VIR_NODE_DEV_CAP_AP_QUEUE:
return udevProcessAPQueue(device, def);
+ case VIR_NODE_DEV_CAP_AP_MATRIX:
+ return udevProcessAPMatrix(device, def);
case VIR_NODE_DEV_CAP_MDEV_TYPES:
case VIR_NODE_DEV_CAP_SYSTEM:
case VIR_NODE_DEV_CAP_FC_HOST:
diff --git a/tests/nodedevschemadata/ap_matrix.xml b/tests/nodedevschemadata/ap_matrix.xml
new file mode 100644
index 00000000..30dab9cf
--- /dev/null
+++ b/tests/nodedevschemadata/ap_matrix.xml
@@ -0,0 +1,7 @@
+<device>
+ <name>ap_matrix</name>
+ <path>/sys/devices/vfio_ap/matrix</path>
+ <parent>computer</parent>
+ <capability type='ap_matrix'>
+ </capability>
+</device>
diff --git a/tests/nodedevschemadata/mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml b/tests/nodedevschemadata/mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml
new file mode 100644
index 00000000..106f7593
--- /dev/null
+++ b/tests/nodedevschemadata/mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad.xml
@@ -0,0 +1,9 @@
+<device>
+ <name>mdev_ee0b88c4-f554-4dc1-809d-b2a01e8e48ad</name>
+ <path>/sys/devices/vfio_ap/matrix/mdev_ee0b88c4-f554-4dc1-809d-b2a01e8e48ad</path>
+ <parent>ap_matrix</parent>
+ <capability type='mdev'>
+ <type id='vfio_ap-passthrough'/>
+ <iommuGroup number='0'/>
+ </capability>
+</device>
diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c
index d6ab25bf..69d72ff0 100644
--- a/tests/nodedevxml2xmltest.c
+++ b/tests/nodedevxml2xmltest.c
@@ -126,6 +126,8 @@ mymain(void)
DO_TEST("css_0_0_ffff");
DO_TEST("ap_card07");
DO_TEST("ap_07_0038");
+ DO_TEST("ap_matrix");
+ DO_TEST("mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad");
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index 3862d8f3..d39d87c7 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -470,6 +470,7 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
case VIR_NODE_DEV_CAP_AP_QUEUE:
flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_AP_QUEUE;
break;
+ case VIR_NODE_DEV_CAP_AP_MATRIX:
case VIR_NODE_DEV_CAP_LAST:
break;
}
--
Mit freundlichen Grüßen/Kind regards
Boris Fiuczynski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294