diff mbox series

[V4,vfio,4/9] virtio-pci: Introduce admin commands

Message ID 20231129143746.6153-5-yishaih@nvidia.com (mailing list archive)
State New, archived
Headers show
Series Introduce a vfio driver over virtio devices | expand

Commit Message

Yishai Hadas Nov. 29, 2023, 2:37 p.m. UTC
From: Feng Liu <feliu@nvidia.com>

Introduces admin commands, as follow:

The "list query" command can be used by the driver to query the
set of admin commands supported by the virtio device.
The "list use" command is used to inform the virtio device which
admin commands the driver will use.
The "legacy common cfg rd/wr" commands are used to read from/write
into the legacy common configuration structure.
The "legacy dev cfg rd/wr" commands are used to read from/write
into the legacy device configuration structure.
The "notify info" command is used to query the notification region
information.

Signed-off-by: Feng Liu <feliu@nvidia.com>
Reviewed-by: Parav Pandit <parav@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
---
 include/uapi/linux/virtio_pci.h | 44 +++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

Comments

Michael S. Tsirkin Nov. 30, 2023, 9:52 a.m. UTC | #1
On Wed, Nov 29, 2023 at 04:37:41PM +0200, Yishai Hadas wrote:
> +/* Transitional device admin command. */
> +#define VIRTIO_ADMIN_CMD_LEGACY_COMMON_CFG_WRITE	0x2
> +#define VIRTIO_ADMIN_CMD_LEGACY_COMMON_CFG_READ		0x3
> +#define VIRTIO_ADMIN_CMD_LEGACY_DEV_CFG_WRITE		0x4
> +#define VIRTIO_ADMIN_CMD_LEGACY_DEV_CFG_READ		0x5
> +#define VIRTIO_ADMIN_CMD_LEGACY_NOTIFY_INFO		0x6
> +
> +/* Increment MAX_OPCODE to next value when new opcode is added */
> +#define VIRTIO_ADMIN_MAX_CMD_OPCODE			0x6

Does anything need VIRTIO_ADMIN_MAX_CMD_OPCODE? Not in this
patchset...
Yishai Hadas Nov. 30, 2023, 10:35 a.m. UTC | #2
On 30/11/2023 11:52, Michael S. Tsirkin wrote:
> On Wed, Nov 29, 2023 at 04:37:41PM +0200, Yishai Hadas wrote:
>> +/* Transitional device admin command. */
>> +#define VIRTIO_ADMIN_CMD_LEGACY_COMMON_CFG_WRITE	0x2
>> +#define VIRTIO_ADMIN_CMD_LEGACY_COMMON_CFG_READ		0x3
>> +#define VIRTIO_ADMIN_CMD_LEGACY_DEV_CFG_WRITE		0x4
>> +#define VIRTIO_ADMIN_CMD_LEGACY_DEV_CFG_READ		0x5
>> +#define VIRTIO_ADMIN_CMD_LEGACY_NOTIFY_INFO		0x6
>> +
>> +/* Increment MAX_OPCODE to next value when new opcode is added */
>> +#define VIRTIO_ADMIN_MAX_CMD_OPCODE			0x6
> 
> Does anything need VIRTIO_ADMIN_MAX_CMD_OPCODE? Not in this
> patchset...
> 

Right, once you suggested to move to 'u64 supported_cmds' it's not any 
more in use.

It still can be used in the future, however I can drop it if it's worth 
a V5 sending.

Yishai
Michael S. Tsirkin Nov. 30, 2023, 10:45 a.m. UTC | #3
On Thu, Nov 30, 2023 at 12:35:09PM +0200, Yishai Hadas wrote:
> On 30/11/2023 11:52, Michael S. Tsirkin wrote:
> > On Wed, Nov 29, 2023 at 04:37:41PM +0200, Yishai Hadas wrote:
> > > +/* Transitional device admin command. */
> > > +#define VIRTIO_ADMIN_CMD_LEGACY_COMMON_CFG_WRITE	0x2
> > > +#define VIRTIO_ADMIN_CMD_LEGACY_COMMON_CFG_READ		0x3
> > > +#define VIRTIO_ADMIN_CMD_LEGACY_DEV_CFG_WRITE		0x4
> > > +#define VIRTIO_ADMIN_CMD_LEGACY_DEV_CFG_READ		0x5
> > > +#define VIRTIO_ADMIN_CMD_LEGACY_NOTIFY_INFO		0x6
> > > +
> > > +/* Increment MAX_OPCODE to next value when new opcode is added */
> > > +#define VIRTIO_ADMIN_MAX_CMD_OPCODE			0x6
> > 
> > Does anything need VIRTIO_ADMIN_MAX_CMD_OPCODE? Not in this
> > patchset...
> > 
> 
> Right, once you suggested to move to 'u64 supported_cmds' it's not any more
> in use.
> 
> It still can be used in the future, however I can drop it if it's worth a V5
> sending.
> 
> Yishai

If you don't need it then yea, we need to be careful about what we put in uapi headers.
wait with v5 until others can review v4 though.
diff mbox series

Patch

diff --git a/include/uapi/linux/virtio_pci.h b/include/uapi/linux/virtio_pci.h
index 187fd9e34a30..f920537f5541 100644
--- a/include/uapi/linux/virtio_pci.h
+++ b/include/uapi/linux/virtio_pci.h
@@ -226,6 +226,23 @@  struct virtio_pci_cfg_cap {
 /* Admin command status. */
 #define VIRTIO_ADMIN_STATUS_OK		0
 
+/* Admin command opcode. */
+#define VIRTIO_ADMIN_CMD_LIST_QUERY	0x0
+#define VIRTIO_ADMIN_CMD_LIST_USE	0x1
+
+/* Admin command group type. */
+#define VIRTIO_ADMIN_GROUP_TYPE_SRIOV	0x1
+
+/* Transitional device admin command. */
+#define VIRTIO_ADMIN_CMD_LEGACY_COMMON_CFG_WRITE	0x2
+#define VIRTIO_ADMIN_CMD_LEGACY_COMMON_CFG_READ		0x3
+#define VIRTIO_ADMIN_CMD_LEGACY_DEV_CFG_WRITE		0x4
+#define VIRTIO_ADMIN_CMD_LEGACY_DEV_CFG_READ		0x5
+#define VIRTIO_ADMIN_CMD_LEGACY_NOTIFY_INFO		0x6
+
+/* Increment MAX_OPCODE to next value when new opcode is added */
+#define VIRTIO_ADMIN_MAX_CMD_OPCODE			0x6
+
 struct __packed virtio_admin_cmd_hdr {
 	__le16 opcode;
 	/*
@@ -245,4 +262,31 @@  struct __packed virtio_admin_cmd_status {
 	__u8 reserved2[4];
 };
 
+struct __packed virtio_admin_cmd_legacy_wr_data {
+	__u8 offset; /* Starting offset of the register(s) to write. */
+	__u8 reserved[7];
+	__u8 registers[];
+};
+
+struct __packed virtio_admin_cmd_legacy_rd_data {
+	__u8 offset; /* Starting offset of the register(s) to read. */
+};
+
+#define VIRTIO_ADMIN_CMD_NOTIFY_INFO_FLAGS_END 0
+#define VIRTIO_ADMIN_CMD_NOTIFY_INFO_FLAGS_OWNER_DEV 0x1
+#define VIRTIO_ADMIN_CMD_NOTIFY_INFO_FLAGS_OWNER_MEM 0x2
+
+#define VIRTIO_ADMIN_CMD_MAX_NOTIFY_INFO 4
+
+struct __packed virtio_admin_cmd_notify_info_data {
+	__u8 flags; /* 0 = end of list, 1 = owner device, 2 = member device */
+	__u8 bar; /* BAR of the member or the owner device */
+	__u8 padding[6];
+	__le64 offset; /* Offset within bar. */
+};
+
+struct virtio_admin_cmd_notify_info_result {
+	struct virtio_admin_cmd_notify_info_data entries[VIRTIO_ADMIN_CMD_MAX_NOTIFY_INFO];
+};
+
 #endif