This gives properties "x-fault-inject-tag" and "x-fault-inject-mode" a generated type_info with a valid masked_name, so it appears in query-qmp-schema introspection and the qapi-type field of qom-list-properties output.
The conversion is trivial for ufs_prop_get_fault_inject_tag. For ufs_prop_get_fault_inject_tag, we need to conver UfsFaultInjectMode to a QAPI enum. Signed-off-by: Markus Armbruster <[email protected]> --- Fixup needed for commit c821f2f69f1 (hw/ufs: Add experimental fault injection properties for holding requests) qapi/common.json | 30 ++++++++++++++++++++++++++++++ hw/ufs/ufs.h | 34 ---------------------------------- hw/ufs/ufs.c | 15 +++------------ 3 files changed, 33 insertions(+), 46 deletions(-) diff --git a/qapi/common.json b/qapi/common.json index 68b649ecf2..84f12c133a 100644 --- a/qapi/common.json +++ b/qapi/common.json @@ -245,3 +245,33 @@ 'tm_hour': 'int32', 'tm_min': 'int32', 'tm_sec': 'int32' } } + +## +# @UfsFaultInjectMode: +# Fault injection modes for x-fault-inject-mode property. +# Controls how the held transfer request and subsequent Task +# Management Request (TMR) are resolved by the controller: +# +# @abort-success: TMR ABORT_TASK aborts the held request, clears its +# state, and returns SUCCESS (COMPL). +# +# @abort-failed: TMR ABORT_TASK returns TASK_MANAGEMENT_FUNC_FAILED, +# forcing host driver to escalate to Host Reset. +# +# @in-transition: TMR QUERY_TASK releases the held request to execute +# normally through the SCSI layer and returns the real task status +# (SUCCEEDED while the command is still in flight); ABORT_TASK +# cancels the held request and returns FUNCTION_COMPLETE. +# +# @timeout: TMR ABORT_TASK does not complete or clear doorbell, +# triggering hardware-level TMR timeout. +# +# @ssu-timeout: Intercepts SCSI START_STOP (0x1B) commands targeting +# the UFS Device WLUN when x-fault-inject-tag is armed. +# +# Since: 11.2 +## +{ 'enum': 'UfsFaultInjectMode', + 'prefix': 'UFS_FAULT_INJECT', + 'data': [ 'abort-success', 'abort-failed', 'in-transition', 'timeout', + 'ssu-timeout' ] } diff --git a/hw/ufs/ufs.h b/hw/ufs/ufs.h index 7ddc540546..0014978322 100644 --- a/hw/ufs/ufs.h +++ b/hw/ufs/ufs.h @@ -90,39 +90,6 @@ typedef struct UfsLu { UfsScsiOp scsi_op; } UfsLu; -/* - * Fault injection modes for x-fault-inject-mode property. - * Controls how the held transfer request and subsequent Task Management - * Request (TMR) are resolved by the controller: - * - * UFS_FAULT_INJECT_ABORT_SUCCESS: TMR ABORT_TASK aborts the held request, - * clears its state, and returns SUCCESS - * (COMPL). - * UFS_FAULT_INJECT_ABORT_FAILED: TMR ABORT_TASK returns - * TASK_MANAGEMENT_FUNC_FAILED, forcing host - * driver to escalate to Host Reset. - * UFS_FAULT_INJECT_IN_TRANSITION: TMR QUERY_TASK releases the held request to - * execute normally through the SCSI layer and - * returns the real task status (SUCCEEDED while - * the command is still in flight); - * ABORT_TASK cancels the held request and - * returns FUNCTION_COMPLETE. - * UFS_FAULT_INJECT_TIMEOUT: TMR ABORT_TASK does not complete or clear - * doorbell, triggering hardware-level TMR - * timeout. - * UFS_FAULT_INJECT_SSU_TIMEOUT: Intercepts SCSI START_STOP (0x1B) commands - * targeting the UFS Device WLUN when - * x-fault-inject-tag is armed. - */ -typedef enum UfsFaultInjectMode { - UFS_FAULT_INJECT_ABORT_SUCCESS = 0, - UFS_FAULT_INJECT_ABORT_FAILED, - UFS_FAULT_INJECT_IN_TRANSITION, - UFS_FAULT_INJECT_TIMEOUT, - UFS_FAULT_INJECT_SSU_TIMEOUT, - UFS_FAULT_INJECT_MODE_MAX, -} UfsFaultInjectMode; - /* * Sentinel values for x-fault-inject-tag property. * Task Tags in UFS are 8-bit (0..255). Values >= 256 are reserved as @@ -375,6 +342,5 @@ void ufs_unrealize(UfsHc *u); extern const PropertyInfo ufs_prop_fault_inject_tag; extern const PropertyInfo ufs_prop_fault_inject_mode; -extern const QEnumLookup UfsFaultInjectMode_lookup; #endif /* HW_UFS_UFS_H */ diff --git a/hw/ufs/ufs.c b/hw/ufs/ufs.c index f8da7c9554..3de67831ea 100644 --- a/hw/ufs/ufs.c +++ b/hw/ufs/ufs.c @@ -15,6 +15,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-type-infos-common.h" #include "qapi/visitor.h" #include "scsi/constants.h" #include "hw/core/irq.h" @@ -3234,17 +3235,6 @@ static void ufs_init_hc(UfsHc *u) ufs_fault_inject_init(u); } -const QEnumLookup UfsFaultInjectMode_lookup = { - .array = (const char *const[]) { - [UFS_FAULT_INJECT_ABORT_SUCCESS] = "abort-success", - [UFS_FAULT_INJECT_ABORT_FAILED] = "abort-failed", - [UFS_FAULT_INJECT_IN_TRANSITION] = "in-transition", - [UFS_FAULT_INJECT_TIMEOUT] = "timeout", - [UFS_FAULT_INJECT_SSU_TIMEOUT] = "ssu-timeout", - }, - .size = UFS_FAULT_INJECT_MODE_MAX, -}; - static void ufs_prop_get_fault_inject_tag(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) @@ -3300,6 +3290,7 @@ static void ufs_prop_set_default_fault_inject_tag(ObjectProperty *op, const PropertyInfo ufs_prop_fault_inject_tag = { .type = "uint32", + .qapi_type = &uint32_type_info, .description = "Task tag to hold for fault injection", .get = ufs_prop_get_fault_inject_tag, .set = ufs_prop_set_fault_inject_tag, @@ -3309,9 +3300,9 @@ const PropertyInfo ufs_prop_fault_inject_tag = { const PropertyInfo ufs_prop_fault_inject_mode = { .type = "UfsFaultInjectMode", + .qapi_type = &UfsFaultInjectMode_type_info, .description = "Fault injection mode: abort-success, abort-failed, " "in-transition, timeout, ssu-timeout", - .enum_table = &UfsFaultInjectMode_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, .set_default_value = qdev_propinfo_set_default_value_enum, -- 2.55.0
