Discussion of the implementations of VIRTIO specification
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: virtio-comment@lists.oasis-open.org,
	virtio-dev@lists.oasis-open.org, cohuck@redhat.com,
	sgarzare@redhat.com, stefanha@redhat.com, nrupal.jani@intel.com,
	Piotr.Uminski@intel.com, hang.yuan@intel.com,
	virtio@lists.oasis-open.org,
	Zhu Lingshan <lingshan.zhu@intel.com>,
	pasic@linux.ibm.com, Shahaf Shuler <shahafs@nvidia.com>,
	Parav Pandit <parav@nvidia.com>,
	Max Gurtovoy <mgurtovoy@nvidia.com>
Subject: Re: [PATCH v9 08/10] admin: command list discovery
Date: Thu, 24 Nov 2022 03:30:41 -0500	[thread overview]
Message-ID: <20221124032505-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CACGkMEsientWq6sKcuB-0hL0uaPJB4dcp4=8c2BXpNRZrd5RWA@mail.gmail.com>

On Thu, Nov 24, 2022 at 02:40:15PM +0800, Jason Wang wrote:
> On Thu, Nov 24, 2022 at 5:08 AM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
> > Add commands to find out which commands does each group support,
> > as well as enable their use by driver.
> > This will be especially useful once we have multiple group types.
> >
> > An alternative is per-type VQs. This is possible but will
> > require more per-transport work. Discovery through the vq
> > helps keep things contained.
> 
> This seems to complicate the migration (compatibility) of the adminq
> itself. We need check both features and command list.

Yes. There's no way around this though - commands need to
be per group and a pci device can host at least both
SIOV and SRIOV children.


> More below.
> 
> >
> > Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >  admin.tex | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 81 insertions(+), 1 deletion(-)
> >
> > diff --git a/admin.tex b/admin.tex
> > index eeccd2e..eec12a9 100644
> > --- a/admin.tex
> > +++ b/admin.tex
> > @@ -91,7 +91,9 @@ \subsection{Group administration commands}\label{sec:Basic Facilities of a Virti
> >  \hline
> >  opcode & Name & Command Description \\
> >  \hline \hline
> > -0x0000 - 0x7FFF & - &  Group administration commands    \\
> > +0x0000 & VIRTIO_ADMIN_CMD_LIST_QUERY & Provides to driver list of commands supported for this group type    \\
> > +0x0001 & VIRTIO_ADMIN_CMD_LIST_USE & Provides to device list of commands used for this group type \\
> > +0x0002 - 0x7FFF & - &  Group administration commands    \\
> >  \hline
> >  0x8000 - 0xFFFF & - & Reserved    \\
> >  \hline
> > @@ -142,6 +144,84 @@ \subsection{Group administration commands}\label{sec:Basic Facilities of a Virti
> >  \hline
> >  \end{tabular}
> >
> > +Before sending any administration commands to the device, the driver
> > +needs to communicate to the device which commands it is going to
> > +use. Initially (after reset), only two commands are assumed to be used:
> > +VIRTIO_ADMIN_CMD_LIST_QUERY and VIRTIO_ADMIN_CMD_LIST_USE.
> > +
> > +Before sending any other commands for any member of a specific group to
> > +the device, the driver queries the supported commands via
> > +VIRTIO_ADMIN_CMD_LIST_QUERY and sends the commands it will use via
> > +VIRTIO_ADMIN_CMD_LIST_USE.
> > +
> > +Commands VIRTIO_ADMIN_CMD_LIST_QUERY and
> > +VIRTIO_ADMIN_CMD_LIST_USE
> > +both use the following structure describing the
> > +command opcodes:
> > +
> > +\begin{lstlisting}
> > +struct virtio_admin_cmd_list {
> > +       /* Indicates which of the below fields were returned
> > +       le32 device_admin_cmds[];
> > +};
> > +\end{lstlisting}
> > +
> > +This structure is an array of 32 bit values in little-endian byte
> > +order, in which a bit is set if the specific command opcode
> > +is supported.
> 
> Is this simpler if we map group type instead of a single opcode? E.g
> virtqueue transport will introduce 10+ commands, using a bit for a
> specific opcode will complicate things.

I think more flexibility is better, and bits are cheap.


> > +Thus, \field{device_admin_cmds[0]} refers to the first 32-bit value
> > +in this array corresponding to opcodes 0 to 31,
> > +\field{device_admin_cmds[1]} is the second 32-bit value
> > +corresponding to opcodes 32 to 63, etc.
> > +For example, the array of size 2 including
> > +the values 0x3 in \field{device_admin_cmds[0]}
> > +and 0x1 in \field{device_admin_cmds[1]} indicates that only opcodes 0, 1 and 32
> > +are supported.
> > +
> > +Accordingly, bits 0 and 1 corresponding to opcode 0
> > +(VIRTIO_ADMIN_CMD_LIST_QUERY) and 1
> > +(VIRTIO_ADMIN_CMD_LIST_USE) are
> > +always set in \field{device_admin_cmds[0]} returned by VIRTIO_ADMIN_CMD_LIST_QUERY.
> > +
> > +For the command VIRTIO_ADMIN_CMD_LIST_QUERY, \field{opcode} is set to 0x0.
> > +The \field{group_member_id} is unused. It is set to zero by driver.
> > +This command has no command specific data.
> > +The device, upon success, returns a result in
> > +\field{command_specific_result} in the format
> > +\field{struct virtio_admin_cmd_list} describing the
> > +list of administration commands supported for the given group.
> > +
> > +
> > +For the command VIRTIO_ADMIN_CMD_LIST_USE, \field{opcode}
> > +is set to 0x1.
> > +The \field{group_member_id} is unused. It is set to zero by driver.
> > +The \field{command_specific_data} is in the format
> > +\field{struct virtio_admin_cmd_list} describing the
> > +list of administration commands used by the driver.
> > +This command has no command specific result.
> > +
> > +The driver issues the command VIRTIO_ADMIN_CMD_LIST_QUERY to
> > +query the list of commands valid for this group and before sending
> > +any commands for any member of a group.
> > +
> > +The driver then enables use of some of the opcodes by sending to
> > +the device the command VIRTIO_ADMIN_CMD_LIST_USE with a subset
> > +of the list returned by VIRTIO_ADMIN_CMD_LIST_QUERY that is
> > +both understood and used by the driver.
> 
> Any reason we need to invent a negotiation process here? (This seems
> only useful when some commands/opcodes are mutually exclusive)
> 
> Thanks

yes, features don't help because they are per owner.
this is per group.

imagine vq transport. SET_FEATURES commands sets the features
for the child. we need something to negotiate with owner
but still within the vq.



> > +
> > +If the device supports the command list used by the driver, the
> > +device completes the command with status VIRTIO_ADMIN_STATUS_OK.
> > +If the device does not support the command list, the device
> > +completes the command with status
> > +VIRTIO_ADMIN_STATUS_INVALID_FIELD.
> > +
> > +Note: drivers are assumed not to set bits in device_admin_cmds
> > +if they are not familiar with how the command opcode
> > +is used, since devices could have dependencies between
> > +command opcodes.
> > +
> > +It is assumed that all members in a group support and are used
> > +with the same list of commands.
> > +
> >  \section{Administration Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Administration Virtqueues}
> >
> >  An administration virtqueue of an owner device is used to submit
> > --
> > MST
> >


  reply	other threads:[~2022-11-24  8:30 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23 21:07 [PATCH v9 00/10] Introduce device group and device management Michael S. Tsirkin
2022-11-23 21:08 ` [PATCH v9 01/10] virtio: document forward compatibility guarantees Michael S. Tsirkin
2022-11-24  4:33   ` Jason Wang
2022-11-24  6:59     ` Michael S. Tsirkin
2022-11-24  7:34       ` Jason Wang
2022-11-24  8:15         ` Michael S. Tsirkin
2022-11-24 12:05           ` [virtio-dev] " Cornelia Huck
2022-11-25  3:17             ` Jason Wang
2022-11-25 10:37               ` [virtio-dev] " Cornelia Huck
2022-11-28  6:14                 ` Jason Wang
2022-11-23 21:08 ` [PATCH v9 02/10] admin: introduce device group and related concepts Michael S. Tsirkin
2022-11-24  5:41   ` Jason Wang
2022-11-24  7:08     ` Michael S. Tsirkin
2022-11-24  7:37       ` [virtio-dev] " Jason Wang
2022-11-24  8:18         ` Michael S. Tsirkin
2022-11-24 12:12           ` Cornelia Huck
2022-11-25  3:23             ` Jason Wang
2022-11-25 10:58               ` [virtio] " Cornelia Huck
2022-11-25 12:08               ` Michael S. Tsirkin
2022-11-23 21:08 ` [PATCH v9 03/10] admin: introduce group administration commands Michael S. Tsirkin
2022-11-24  5:52   ` [virtio-dev] " Jason Wang
2022-11-24  7:12     ` Michael S. Tsirkin
2022-11-24  7:42       ` Jason Wang
2022-11-24  8:03         ` Michael S. Tsirkin
2022-11-25  3:24           ` [virtio-comment] " Jason Wang
2022-11-24 12:21     ` [virtio-dev] " Cornelia Huck
2022-11-25  3:54       ` Jason Wang
2022-11-28 13:14   ` [virtio-comment] " Zhu Lingshan
2022-11-23 21:08 ` [PATCH v9 04/10] admin: introduce virtio admin virtqueues Michael S. Tsirkin
2022-11-28 13:12   ` [virtio-comment] " Zhu Lingshan
2022-11-23 21:08 ` [PATCH v9 05/10] pci: add admin vq registers to virtio over pci Michael S. Tsirkin
2022-11-24  6:00   ` Jason Wang
2022-11-24  7:14     ` Michael S. Tsirkin
2022-11-24  7:46       ` Jason Wang
2022-11-24  8:09         ` Michael S. Tsirkin
2022-11-25  3:27           ` Jason Wang
2022-11-23 21:08 ` [PATCH v9 06/10] mmio: document ADMIN_VQ as reserved Michael S. Tsirkin
2022-11-24  6:03   ` Jason Wang
2022-11-24  7:45     ` Michael S. Tsirkin
2022-11-23 21:08 ` [PATCH v9 07/10] ccw: " Michael S. Tsirkin
2022-11-23 21:08 ` [PATCH v9 08/10] admin: command list discovery Michael S. Tsirkin
2022-11-24  6:40   ` Jason Wang
2022-11-24  8:30     ` Michael S. Tsirkin [this message]
2022-11-25  3:38       ` [virtio-comment] " Jason Wang
2022-11-25 11:43         ` Michael S. Tsirkin
2022-11-28  4:34           ` Jason Wang
2022-11-28  7:42             ` Michael S. Tsirkin
2022-11-23 21:08 ` [PATCH v9 09/10] admin: conformance clauses Michael S. Tsirkin
2022-11-24  6:51   ` Jason Wang
2022-11-24  8:36     ` Michael S. Tsirkin
2022-11-25  3:50       ` Jason Wang
2022-11-25 11:42         ` [virtio] " Cornelia Huck
2022-11-25 11:56           ` Michael S. Tsirkin
2022-11-25 12:10             ` [virtio] " Cornelia Huck
2022-11-25 11:47         ` Michael S. Tsirkin
2022-11-28  4:32           ` Jason Wang
2022-11-28  7:39             ` Michael S. Tsirkin
2022-11-24 12:28     ` [virtio] " Cornelia Huck
2022-11-25  3:38       ` Jason Wang
2022-11-23 21:08 ` [PATCH RFC v9 10/10] ccw: document more reserved features Michael S. Tsirkin
2022-11-24  6:53   ` Jason Wang
2022-11-24  8:31     ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221124032505-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=Piotr.Uminski@intel.com \
    --cc=cohuck@redhat.com \
    --cc=hang.yuan@intel.com \
    --cc=jasowang@redhat.com \
    --cc=lingshan.zhu@intel.com \
    --cc=mgurtovoy@nvidia.com \
    --cc=nrupal.jani@intel.com \
    --cc=parav@nvidia.com \
    --cc=pasic@linux.ibm.com \
    --cc=sgarzare@redhat.com \
    --cc=shahafs@nvidia.com \
    --cc=stefanha@redhat.com \
    --cc=virtio-comment@lists.oasis-open.org \
    --cc=virtio-dev@lists.oasis-open.org \
    --cc=virtio@lists.oasis-open.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox