From 2f984adf2d3102beb4f86954128d68132a6d0369 Mon Sep 17 00:00:00 2001 From: Shalini Chellathurai Saroja Date: Thu, 3 Dec 2020 18:59:38 +0100 Subject: [PATCH] nodedev: detect AP matrix device Add support for AP matrix device in libvirt node device driver. https://www.kernel.org/doc/html/latest/s390/vfio-ap.html#the-design Signed-off-by: Shalini Chellathurai Saroja Reviewed-by: Bjoern Walk Reviewed-by: Boris Fiuczynski Reviewed-by: Erik Skultety --- docs/schemas/nodedev.rng | 7 +++++++ src/conf/node_device_conf.c | 9 +++++++++ src/conf/node_device_conf.h | 8 ++++++++ src/conf/virnodedeviceobj.c | 1 + src/node_device/node_device_udev.c | 17 +++++++++++++++++ tools/virsh-nodedev.c | 1 + 6 files changed, 43 insertions(+) diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index 60367653f6..1024ba59f9 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -89,6 +89,7 @@ + @@ -691,6 +692,12 @@ + + + ap_matrix + + + diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 01254a8f16..d32a6afcaf 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -69,6 +69,7 @@ VIR_ENUM_IMPL(virNodeDevCap, "vdpa", "ap_card", "ap_queue", + "ap_matrix", ); VIR_ENUM_IMPL(virNodeDevNetCap, @@ -665,6 +666,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; } @@ -2077,6 +2079,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: @@ -2398,6 +2403,9 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) virMediatedDeviceTypeFree(data->ccw_dev.mdev_types[i]); VIR_FREE(data->ccw_dev.mdev_types); 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: @@ -2467,6 +2475,7 @@ virNodeDeviceUpdateCaps(virNodeDeviceDefPtr def) case VIR_NODE_DEV_CAP_VDPA: 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/conf/node_device_conf.h b/src/conf/node_device_conf.h index b580d6cf3d..b863653b34 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -68,6 +68,7 @@ typedef enum { VIR_NODE_DEV_CAP_VDPA, /* vDPA 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; @@ -304,6 +305,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 { @@ -325,6 +332,7 @@ struct _virNodeDevCapData { virNodeDevCapVDPA vdpa; virNodeDevCapAPCard ap_card; virNodeDevCapAPQueue ap_queue; + virNodeDevCapAPMatrix ap_matrix; }; }; diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index 691632c66d..8fbef5f528 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -719,6 +719,7 @@ virNodeDeviceObjHasCap(const virNodeDeviceObj *obj, case VIR_NODE_DEV_CAP_VDPA: 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 7883f23e85..5782074f40 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1234,6 +1234,19 @@ udevProcessAPQueue(struct udev_device *device, } +static int +udevProcessAPMatrix(virNodeDeviceDefPtr def) +{ + /* Both udev_device_get_sysname and udev_device_get_subsystem return + * "matrix" for an AP matrix device, so in order to prevent confusion in + * naming, let's fallback to hardcoding the name. + */ + def->name = g_strdup("ap_matrix"); + + return 0; +} + + static int udevGetDeviceNodes(struct udev_device *device, virNodeDeviceDefPtr def) @@ -1319,6 +1332,8 @@ udevGetDeviceType(struct udev_device *device, *type = VIR_NODE_DEV_CAP_CSS_DEV; else if (STREQ_NULLABLE(subsystem, "vdpa")) *type = VIR_NODE_DEV_CAP_VDPA; + else if (STREQ_NULLABLE(subsystem, "matrix")) + *type = VIR_NODE_DEV_CAP_AP_MATRIX; VIR_FREE(subsystem); } @@ -1371,6 +1386,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(def); case VIR_NODE_DEV_CAP_MDEV_TYPES: case VIR_NODE_DEV_CAP_SYSTEM: case VIR_NODE_DEV_CAP_FC_HOST: diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index f5ffe52524..f69030d2da 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -473,6 +473,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; }