Thread (19 messages) flat view 19 messages, 4 authors, 2022-03-16

Re: [PATCH v7 2/4] vdpa: Allow for printing negotiated features of a device

From: David Ahern <dsahern@kernel.org>
Date: 2022-03-16 15:46:12

On 3/15/22 5:35 AM, Eli Cohen wrote:
quoted
quoted
+};
+
+#define VIRTIO_F_IN_ORDER 35
+#define VIRTIO_F_NOTIFICATION_DATA 38
+#define VDPA_EXT_FEATURES_SZ (VIRTIO_TRANSPORT_F_END - \
+			      VIRTIO_TRANSPORT_F_START + 1)
+
+static const char * const ext_feature_strs[VDPA_EXT_FEATURES_SZ] = {
+	[VIRTIO_RING_F_INDIRECT_DESC - VIRTIO_TRANSPORT_F_START] = "RING_INDIRECT_DESC",
+	[VIRTIO_RING_F_EVENT_IDX - VIRTIO_TRANSPORT_F_START] = "RING_EVENT_IDX",
+	[VIRTIO_F_VERSION_1 - VIRTIO_TRANSPORT_F_START] = "VERSION_1",
+	[VIRTIO_F_ACCESS_PLATFORM - VIRTIO_TRANSPORT_F_START] = "ACCESS_PLATFORM",
+	[VIRTIO_F_RING_PACKED - VIRTIO_TRANSPORT_F_START] = "RING_PACKED",
+	[VIRTIO_F_IN_ORDER - VIRTIO_TRANSPORT_F_START] = "IN_ORDER",
+	[VIRTIO_F_ORDER_PLATFORM - VIRTIO_TRANSPORT_F_START] = "ORDER_PLATFORM",
+	[VIRTIO_F_SR_IOV - VIRTIO_TRANSPORT_F_START] = "SR_IOV",
+	[VIRTIO_F_NOTIFICATION_DATA - VIRTIO_TRANSPORT_F_START] = "NOTIFICATION_DATA",
and the entries here should be a macro to handle the
VIRTIO_TRANSPORT_F_START  offset with column aligned strings.
I guess I could define a macro here if all the flags would start with "VIRTIO_F_ =" but unfortunately,
the first two flags don't follow this pattern.
I could send kernel patches to replace VIRTIO_RING_F_INDIRECT_DESC and
VIRTIO_RING_F_EVENT_IDX to VIRTIO_F_RING_INDIRECT_DESC and VIRTIO_F_RING_EVENT_IDX
and then fix the format here.

If you meant something else, please be more specific.
It can still work with the existing naming - it's the redundant use of
VIRTIO_TRANSPORT_F_START as an offset that is hidden by the macro
allowing the feature to string conversion to be easier to read.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help