Skip to contentSkip to conversation

VIRTIO: Provision maximum MSI-X vectors for a VF

PATCH Superseded Max Gurtovoy 5 participants 110 messages Jan 13, 2022 – Jan 28, 2022

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover VIRTIO: Provision maximum MSI-X vectors for a VF

Hi,

In a PCI SR-IOV configuration, MSI-X vectors of the device is precious device resource. Hence making efficient use of it based on the use case that aligns to the VM configuration is desired for best system performance.

For example, today's static assignment of the amount of MSI-X vectors doesn't allow sophisticated utilization of resources.

A typical cloud provider SR-IOV use case is to create many VFs for use by guest VMs. Each VM might have a different purpose and different amount of resources accordingly (e.g. number of CPUs). A common driver usage of device's MSI-X vectors is proportional to the number of CPUs in the VM. Since the system administrator might know the amount of CPUs in the requested VM, he can also configure the VF's MSI-X vectors amount proportional to the number of CPUs in the VM. In this way, the utilization of the physical hardware will be improved.

Today we have some operating systems that support provisioning MSI-X vectors for PCI VFs.

Update the specification to have a method to change the number of MSI-X vectors supported by a VF using the PF admin virtqueue interface. For that, create a generic infrastructure for managing PCI resources of the managed VF by its parent PF.

Patches (1/5)-(2/5) introduce the admin virtqueue concept and feature bits. Patches (3/5)-(4/5) add the admin virtq to virtio-blk and virtio-net devices.
Patch (5/5) introduce MSI-X mgmt support.

Max Gurtovoy (5):
Add virtio Admin Virtqueue specification
Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER
virtio-blk: add support for VIRTIO_F_ADMIN_VQ
virtio-net: add support for VIRTIO_F_ADMIN_VQ
Add support for dynamic MSI-X vector mgmt for VFs

 admin-virtq.tex | 145 ++++++++++++++++++++++++++++++++++++++++++++++++
 content.tex     |  91 +++++++++++++++++++++++++++---
 packed-ring.tex |  26 ++++-----
 split-ring.tex  |  35 ++++++++----
 4 files changed, 263 insertions(+), 34 deletions(-)
 create mode 100644 admin-virtq.tex
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/5 Add virtio Admin Virtqueue specification

In one of the many use cases a user wants to manipulate features and configuration of the virtio devices regardless of the device type (net/block/console). Some of this configuration is generic enough. i.e Number of MSI-X vectors of a virtio PCI VF device. There is a need to do such features query and manipulation by its parent PCI PF.

Currently virtio specification defines control virtqueue to manipulate features and configuration of the device it operates on. However, control virtqueue commands are device type specific, which makes it very difficult to extend for device agnostic commands. Control virtqueue is also limited to follow in order completion for the device which negotiates VIRTIO_F_IN_ORDER feature. This feature limits the use of control virtqueue for feature manipulation in out of order manner for unrelated commands.

To support these requirements which overcome above two limitations in elegant way, this patch introduces a new admin virtqueue. Admin virtqueue will use the same command format for all types of virtio devices.

Subsequent patches make use of this admin virtqueue.

---
 admin-virtq.tex | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 content.tex     |  9 +++++++--
 2 files changed, 56 insertions(+), 2 deletions(-)
 create mode 100644 admin-virtq.tex
admin-virtq.tex new file +49 -0
new file mode 100644
index 0000000..ad20f89
@@ -0,0 +1,49 @@
+\section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin Virtqueues}
+
+Admin virtqueue is used to send administrative commands to manipulate
+various features of the device which would not easily map into the
+configuration space.
+
+Use of Admin virtqueue is negotiated by the VIRTIO_F_ADMIN_VQ
+feature bit.
+
+Admin virtqueue index may vary among different device types.
+
+The Admin command set defines the commands that may be issued only to the admin
+virtqueue. Each virtio device that advertises the VIRTIO_F_ADMIN_VQ feature, MUST
+support all the mandatory admin commands. A device MAY support also one or more
+optional admin commands. All commands are of the following form:
+
+\begin{lstlisting}
+struct virtio_admin_cmd {
+        /* Device-readable part */
+        u8 command;
+        u8 command-specific-data[];
+
+        /* Device-writable part */
+        u8 status;
+        u8 command-specific-result[];
+};
+
+/* status values */
+#define VIRTIO_ADMIN_STATUS_OK 0
+#define VIRTIO_ADMIN_STATUS_ERR 1
+#define VIRTIO_ADMIN_STATUS_COMMAND_UNSUPPORTED 2
+\end{lstlisting}
+
+The \field{command} and \field{command-specific-data} are
+set by the driver, and the device sets the \field{status} and the
+\field{command-specific-result}, if needed.
+
+The following table describes the Admin command set:
+
+\begin{tabular}{|l|l|l|l|}
+\hline
+Opcode (bits) & Opcode (hex) & Command & M/O \\
+\hline \hline
+ -  & 00h - 7Fh   & Generic admin cmds    & -  \\
+\hline
+ -  & 80h - FFh   & Reserved    & - \\
+\hline
+\end{tabular}
+
content.tex +7 -2
index 32de668..c524fab 100644
@@ -99,10 +99,10 @@ \section{Feature Bits}\label{sec:Basic Facilities of a Virtio Device / Feature B
 \begin{description}
 \item[0 to 23] Feature bits for the specific device type
 
-\item[24 to 40] Feature bits reserved for extensions to the queue and
+\item[24 to 41] Feature bits reserved for extensions to the queue and
   feature negotiation mechanisms
 
-\item[41 and above] Feature bits reserved for future extensions.
+\item[42 and above] Feature bits reserved for future extensions.
 \end{description}
 
 \begin{note}
@@ -449,6 +449,8 @@ \section{Exporting Objects}\label{sec:Basic Facilities of a Virtio Device / Expo
 types. It is RECOMMENDED that devices generate version 4
 UUIDs as specified by \hyperref[intro:rfc4122]{[RFC4122]}.
 
+\input{admin-virtq.tex}
+
 \chapter{General Initialization And Device Operation}\label{sec:General Initialization And Device Operation}
 
 We start with an overview of device initialization, then expand on the
@@ -6847,6 +6849,9 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
   that the driver can reset a queue individually.
   See \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Reset}.
 
+  \item[VIRTIO_F_ADMIN_VQ (41)] This feature indicates that
+  the device supports administration virtqueue negotiation.
+
 \end{description}
 
 \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
Signature · 1 line
2.21.0
#27 lore raw

PATCH 2/5 Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Max Gurtovoy

These new features are parallel to VIRTIO_F_INDIRECT_DESC and VIRTIO_F_IN_ORDER. Some devices might support these features only for admin virtqueues and some might support them for both admin virtqueues and request virtqueues or only for non-admin virtqueues. Some optimization can be made for each type of virtqueue, thus we separate these features for the different virtqueue types.

---
 content.tex     | 47 +++++++++++++++++++++++++++++++++++++++--------
 packed-ring.tex | 26 +++++++++++++-------------
 split-ring.tex  | 35 +++++++++++++++++++++++------------
 3 files changed, 75 insertions(+), 33 deletions(-)
content.tex +39 -8
index c524fab..cc3e648 100644
@@ -99,10 +99,10 @@ \section{Feature Bits}\label{sec:Basic Facilities of a Virtio Device / Feature B
 \begin{description}
 \item[0 to 23] Feature bits for the specific device type
 
-\item[24 to 41] Feature bits reserved for extensions to the queue and
+\item[24 to 43] Feature bits reserved for extensions to the queue and
   feature negotiation mechanisms
 
-\item[42 and above] Feature bits reserved for future extensions.
+\item[44 and above] Feature bits reserved for future extensions.
 \end{description}
 
 \begin{note}
@@ -318,8 +318,9 @@ \section{Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Virtqueues}
 
 Some devices always use descriptors in the same order in which
 they have been made available. These devices can offer the
-VIRTIO_F_IN_ORDER feature. If negotiated, this knowledge
-might allow optimizations or simplify driver and/or device code.
+VIRTIO_F_IN_ORDER and/or VIRTIO_F_ADMIN_VQ_IN_ORDER features.
+If negotiated, this knowledge might allow optimizations or
+simplify driver and/or device code.
 
 Each virtqueue can consist of up to 3 parts:
 \begin{itemize}
@@ -6768,7 +6769,7 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 Device / Virtqueues / The Virtqueue Descriptor Table / Indirect
 Descriptors}~\nameref{sec:Basic Facilities of a Virtio Device /
 Virtqueues / The Virtqueue Descriptor Table / Indirect
-Descriptors} and \ref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}~\nameref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}.
+Descriptors} and \ref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}~\nameref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}. This excluding the descriptors sent via the admin virtqueue.
   \item[VIRTIO_F_EVENT_IDX(29)] This feature enables the \field{used_event}
   and the \field{avail_event} fields as described in
 \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Used Buffer Notification Suppression}, \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Used Ring} and \ref{sec:Packed Virtqueues / Driver and Device Event Suppression}.
@@ -6800,8 +6801,9 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
   support for the packed virtqueue layout as described in
   \ref{sec:Basic Facilities of a Virtio Device / Packed Virtqueues}~\nameref{sec:Basic Facilities of a Virtio Device / Packed Virtqueues}.
   \item[VIRTIO_F_IN_ORDER(35)] This feature indicates
-  that all buffers are used by the device in the same
-  order in which they have been made available.
+  that all buffers are used by the device, excluding buffers used by
+  the admin virtqueue, in the same order in which they have been made
+  available.
   \item[VIRTIO_F_ORDER_PLATFORM(36)] This feature indicates
   that memory accesses by the driver and the device are ordered
   in a way described by the platform.
@@ -6852,6 +6854,18 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
   \item[VIRTIO_F_ADMIN_VQ (41)] This feature indicates that
   the device supports administration virtqueue negotiation.
 
+  \item[VIRTIO_F_ADMIN_VQ_INDIRECT_DESC (42)] Negotiating this feature
+  indicates that the driver can use descriptors with the VIRTQ_DESC_F_INDIRECT
+  flag set, as described in \ref{sec:Basic Facilities of a Virtio
+Device / Virtqueues / The Virtqueue Descriptor Table / Indirect
+Descriptors}~\nameref{sec:Basic Facilities of a Virtio Device /
+Virtqueues / The Virtqueue Descriptor Table / Indirect
+Descriptors} and \ref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}~\nameref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}. This refers to descriptors sent via the admin
+  virtqueue and excluding the descriptors that sent via other virtqueues.
+  \item[VIRTIO_F_ADMIN_VQ_IN_ORDER (43)] This feature indicates
+  that all buffers are used by the admin virtqueue of the device in
+  the same order in which they have been made available.
+
 \end{description}
 
 \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
@@ -6888,6 +6902,12 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 
 A driver SHOULD accept VIRTIO_F_NOTIF_CONFIG_DATA if it is offered.
 
+A driver MAY accept VIRTIO_F_ADMIN_VQ_INDIRECT_DESC only if it accepts
+VIRTIO_F_ADMIN_VQ.
+
+A driver MAY accept VIRTIO_F_ADMIN_VQ_IN_ORDER only if it accepts
+VIRTIO_F_ADMIN_VQ.
+
 \devicenormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
 
 A device MUST offer VIRTIO_F_VERSION_1.  A device MAY fail to operate further
@@ -6902,7 +6922,12 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 accepted.
 
 If VIRTIO_F_IN_ORDER has been negotiated, a device MUST use
-buffers in the same order in which they have been available.
+buffers in the same order in which they have been available. This refers
+to buffers that are used by virtqueue that is not the admin virtqueue.
+
+If VIRTIO_F_ADMIN_VQ_IN_ORDER has been negotiated, a device MUST use
+buffers in the same order in which they have been available. This refers
+only for buffers that are used by the admin virtqueue.
 
 A device MAY fail to operate further if
 VIRTIO_F_ORDER_PLATFORM is offered but not accepted.
@@ -6917,6 +6942,12 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 and presents a PCI SR-IOV capability structure, otherwise
 it MUST NOT offer VIRTIO_F_SR_IOV.
 
+A device MAY offer VIRTIO_F_ADMIN_VQ_INDIRECT_DESC only if it offers
+VIRTIO_F_ADMIN_VQ.
+
+A device MAY offer VIRTIO_F_ADMIN_VQ_IN_ORDER only if it offers
+VIRTIO_F_ADMIN_VQ.
+
 \section{Legacy Interface: Reserved Feature Bits}\label{sec:Reserved Feature Bits / Legacy Interface: Reserved Feature Bits}
 
 Transitional devices MAY offer the following:
packed-ring.tex +13 -13
index a9e6c16..ef1dbc2 100644
@@ -240,13 +240,12 @@ \subsection{Indirect Flag: Scatter-Gather Support}
 \label{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}
 
 Some devices benefit by concurrently dispatching a large number
-of large requests. The VIRTIO_F_INDIRECT_DESC feature allows this. To increase
-ring capacity the driver can store a (read-only by the device) table of indirect
-descriptors anywhere in memory, and insert a descriptor in the main
-virtqueue (with \field{Flags} bit VIRTQ_DESC_F_INDIRECT on) that refers to
-a buffer element
-containing this indirect descriptor table; \field{addr} and \field{len}
-refer to the indirect table address and length in bytes,
+of large requests. The VIRTIO_F_INDIRECT_DESC and VIRTIO_F_ADMIN_VQ_INDIRECT_DESC
+features allows this. To increase ring capacity the driver can store a (read-only
+by the device) table of indirect descriptors anywhere in memory, and insert a
+descriptor in the main virtqueue (with \field{Flags} bit VIRTQ_DESC_F_INDIRECT on)
+that refers to a buffer element containing this indirect descriptor table;
+\field{addr} and \field{len} refer to the indirect table address and length in bytes,
 respectively.
 \begin{lstlisting}
 /* This means the element contains a table of descriptors. */
@@ -279,10 +278,11 @@ \subsection{In-order use of descriptors}
 
 Some devices always use descriptors in the same order in which
 they have been made available. These devices can offer the
-VIRTIO_F_IN_ORDER feature. If negotiated, this knowledge allows
-devices to notify the use of a batch of buffers to the driver by
-only writing out a single used descriptor with the Buffer ID
-corresponding to the last descriptor in the batch.
+VIRTIO_F_IN_ORDER and/or VIRTIO_F_ADMIN_VQ_IN_ORDER features.
+If negotiated, this knowledge allows devices to notify the use of
+a batch of buffers to the driver by only writing out a single used
+descriptor with the Buffer ID corresponding to the last descriptor
+in the batch.
 
 The device then skips forward in the ring according to the size of
 the batch. The driver needs to look up the used Buffer ID and
@@ -500,8 +500,8 @@ \subsection{Event Suppression Structure Format}\label{sec:Basic
 
 \drivernormative{\subsection}{Indirect Descriptors}{Basic Facilities of a Virtio Device / Packed Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
 The driver MUST NOT set the DESC_F_INDIRECT flag unless the
-VIRTIO_F_INDIRECT_DESC feature was negotiated.   The driver MUST NOT
-set any flags except DESC_F_WRITE within an indirect descriptor.
+VIRTIO_F_INDIRECT_DESC or VIRTIO_F_ADMIN_VQ_INDIRECT_DESC features were negotiated.
+The driver MUST NOT set any flags except DESC_F_WRITE within an indirect descriptor.
 
 A driver MUST NOT create a descriptor chain longer than allowed
 by the device.
split-ring.tex +23 -12
index de94038..cd53840 100644
@@ -208,6 +208,10 @@ \subsection{The Virtqueue Descriptor Table}\label{sec:Basic Facilities of a Virt
 descriptors in ring order: starting from offset 0 in the table,
 and wrapping around at the end of the table.
 
+If VIRTIO_F_ADMIN_VQ_IN_ORDER has been negotiated, driver uses
+descriptors in admin virtqueue ring order: starting from offset 0 in the
+table, and wrapping around at the end of the table.
+
 \begin{note}
 The legacy \hyperref[intro:Virtio PCI Draft]{[Virtio PCI Draft]}
 referred to this structure as vring_desc, and the constants as
@@ -223,16 +227,18 @@ \subsection{The Virtqueue Descriptor Table}\label{sec:Basic Facilities of a Virt
 Drivers MUST NOT add a descriptor chain longer than $2^{32}$ bytes in total;
 this implies that loops in the descriptor chain are forbidden!
 
-If VIRTIO_F_IN_ORDER has been negotiated, and when making a
-descriptor with VRING_DESC_F_NEXT set in \field{flags} at offset
-$x$ in the table available to the device, driver MUST set
+If VIRTIO_F_ADMIN_VQ_IN_ORDER and/or VIRTIO_F_IN_ORDER has been negotiated,
+and when making a descriptor with VRING_DESC_F_NEXT set in \field{flags} at
+offset $x$ in the table available to the device, driver MUST set
 \field{next} to $0$ for the last descriptor in the table
 (where $x = queue\_size - 1$) and to $x + 1$ for the rest of the descriptors.
+This refers to admin virtqueue descriptors and rest other virtqueues types descriptors respectively.
 
 \subsubsection{Indirect Descriptors}\label{sec:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
 
 Some devices benefit by concurrently dispatching a large number
-of large requests. The VIRTIO_F_INDIRECT_DESC feature allows this (see \ref{sec:virtio-queue.h}~\nameref{sec:virtio-queue.h}). To increase
+of large requests. The VIRTIO_F_INDIRECT_DESC and VIRTIO_F_ADMIN_VQ_INDIRECT_DESC
+features allows this (see \ref{sec:virtio-queue.h}~\nameref{sec:virtio-queue.h}). To increase
 ring capacity the driver can store a table of indirect
 descriptors anywhere in memory, and insert a descriptor in main
 virtqueue (with \field{flags}\&VIRTQ_DESC_F_INDIRECT on) that refers to memory buffer
@@ -258,15 +264,19 @@ \subsubsection{Indirect Descriptors}\label{sec:Basic Facilities of a Virtio Devi
 A single indirect descriptor
 table can include both device-readable and device-writable descriptors.
 
-If VIRTIO_F_IN_ORDER has been negotiated, indirect descriptors
-use sequential indices, in-order: index 0 followed by index 1
+If VIRTIO_F_IN_ORDER has been negotiated, indirect descriptors,
+for non admin virtqueue, use sequential indices, in-order: index 0 followed
+by index 1 followed by index 2, etc.
+
+If VIRTIO_F_ADMIN_VQ_IN_ORDER has been negotiated, admin virtqueue indirect
+descriptors use sequential indices, in-order: index 0 followed by index 1
 followed by index 2, etc.
 
 \drivernormative{\paragraph}{Indirect Descriptors}{Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
 The driver MUST NOT set the VIRTQ_DESC_F_INDIRECT flag unless the
-VIRTIO_F_INDIRECT_DESC feature was negotiated.   The driver MUST NOT
-set the VIRTQ_DESC_F_INDIRECT flag within an indirect descriptor (ie. only
-one table per descriptor).
+VIRTIO_F_INDIRECT_DESC and/or VIRTIO_F_ADMIN_VQ_INDIRECT_DESC features were negotiated.
+The driver MUST NOT set the VIRTQ_DESC_F_INDIRECT flag within an indirect
+descriptor (ie. only one table per descriptor).
 
 A driver MUST NOT create a descriptor chain longer than the Queue Size of
 the device.
@@ -274,9 +284,10 @@ \subsubsection{Indirect Descriptors}\label{sec:Basic Facilities of a Virtio Devi
 A driver MUST NOT set both VIRTQ_DESC_F_INDIRECT and VIRTQ_DESC_F_NEXT
 in \field{flags}.
 
-If VIRTIO_F_IN_ORDER has been negotiated, indirect descriptors
-MUST appear sequentially, with \field{next} taking the value
-of 1 for the 1st descriptor, 2 for the 2nd one, etc.
+If VIRTIO_F_ADMIN_VQ_IN_ORDER and/or VIRTIO_F_IN_ORDER has been negotiated,
+indirect descriptors MUST appear sequentially, with \field{next} taking the
+value of 1 for the 1st descriptor, 2 for the 2nd one, etc for admin virtqueue
+and rest other virtqueues types respectively.
 
 \devicenormative{\paragraph}{Indirect Descriptors}{Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
 The device MUST ignore the write-only flag (\field{flags}\&VIRTQ_DESC_F_WRITE) in the descriptor that refers to an indirect table.
Signature · 1 line
2.21.0
#87 lore raw

PATCH 3/5 virtio-blk: add support for VIRTIO_F_ADMIN_VQ

In reply to Max Gurtovoy

Set the relevant index in case of VIRTIO_F_ADMIN_VQ negotiation.

---
 content.tex | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
content.tex +10 -1
index cc3e648..0ae4b68 100644
@@ -4518,10 +4518,19 @@ \subsection{Device ID}\label{sec:Device Types / Block Device / Device ID}
   2
 
 \subsection{Virtqueues}\label{sec:Device Types / Block Device / Virtqueues}
+ if VIRTIO_F_ADMIN_VQ is not negotiated, the request queues layout is as follows:
 \begin{description}
 \item[0] requestq1
 \item[\ldots]
 \item[N-1] requestqN
+\end{description}
+
+ If VIRTIO_F_ADMIN_VQ is negotiated, the queues layout is as follows:
+\begin{description}
+\item[0] requestq1
+\item[\ldots]
+\item[N-1] requestqN
+\item[N] adminq
 \end{description}
 
  N=1 if VIRTIO_BLK_F_MQ is not negotiated, otherwise N is set by
@@ -4590,7 +4599,7 @@ \subsection{Device configuration layout}\label{sec:Device Types / Block Device /
 bits as indicated above.
 
 The field \field{num_queues} only exists if VIRTIO_BLK_F_MQ is set. This field specifies
-the number of queues.
+the number of request queues. This field doesn't account admin virtqueue.
 
 The parameters in the configuration space of the device \field{max_discard_sectors}
 \field{discard_sector_alignment} are expressed in 512-byte units if the
Signature · 1 line
2.21.0
#89 lore raw

PATCH 4/5 virtio-net: add support for VIRTIO_F_ADMIN_VQ

In reply to Max Gurtovoy

Set the relevant index in case of VIRTIO_F_ADMIN_VQ negotiation.

---
 content.tex | 3 +++
 1 file changed, 3 insertions(+)
content.tex +3 -0
index 0ae4b68..e9c2383 100644
@@ -3034,6 +3034,7 @@ \subsection{Virtqueues}\label{sec:Device Types / Network Device / Virtqueues}
 \item[2(N-1)] receiveqN
 \item[2(N-1)+1] transmitqN
 \item[2N] controlq
+\item[2N + 1] adminq (or \textbf{2N} in case VIRTIO_NET_F_CTRL_VQ is not set)
 \end{description}
 
  N=1 if neither VIRTIO_NET_F_MQ nor VIRTIO_NET_F_RSS are negotiated, otherwise N is set by
@@ -3041,6 +3042,8 @@ \subsection{Virtqueues}\label{sec:Device Types / Network Device / Virtqueues}
 
  controlq only exists if VIRTIO_NET_F_CTRL_VQ set.
 
+ adminq only exists if VIRTIO_F_ADMIN_VQ set.
+
 \subsection{Feature bits}\label{sec:Device Types / Network Device / Feature bits}
 
 \begin{description}
Signature · 1 line
2.21.0
#104 lore raw

PATCH 5/5 Add support for dynamic MSI-X vector mgmt for VFs

In reply to Max Gurtovoy

A typical cloud provider SR-IOV use case is to create many VFs for use by guest VMs. The VFs may not be assigned to a VM until a user requests a VM of a certain size, e.g., number of CPUs. A VF may need MSI-X vectors proportional to the number of CPUs in the VM, but there is no standard way today in the spec to change the number of MSI-X vectors supported by a VF, although there are some operating systems that support this.

Introduce new feature bits for generic PCI virtualization management mechanism and a specific mechanism to manage the MSI-X vector assignment process of virtual/managed functions by its parent virtio device via its admin virtqueue. For now, virtio supports only PCI virtual function virtualization, thus the virt manager device will be the PF and the managed device will be the VF.

---
 admin-virtq.tex | 98 ++++++++++++++++++++++++++++++++++++++++++++++++-
 content.tex     | 29 ++++++++++++++-
 2 files changed, 124 insertions(+), 3 deletions(-)
admin-virtq.tex +97 -1
index ad20f89..4ee8a32 100644
@@ -41,9 +41,105 @@ \section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin
 \hline
 Opcode (bits) & Opcode (hex) & Command & M/O \\
 \hline \hline
- -  & 00h - 7Fh   & Generic admin cmds    & -  \\
+ 00000000b  & 00h   & VIRTIO_ADMIN_PCI_VIRT_MGMT_ATTR_IDENTIFY    & O  \\
+\hline
+ 00000001b  & 01h   & VIRTIO_ADMIN_PCI_VIRT_PROPERTY_SET    & O  \\
+\hline
+ 00000010b  & 02h   & VIRTIO_ADMIN_PCI_VIRT_PROPERTY_GET    & O  \\
+\hline
+ -  & 03h - 7Fh   & Generic admin cmds    & -  \\
 \hline
  -  & 80h - FFh   & Reserved    & - \\
 \hline
 \end{tabular}
 
+\subsection{VIRTIO ADMIN PCI VIRT MGMT ATTR IDENTIFY command}\label{sec:Basic Facilities of a Virtio Device / Admin Virtqueues / VIRTIO ADMIN PCI VIRT MGMT ATTR IDENTIFY command}
+
+The VIRTIO_ADMIN_PCI_VIRT_MGMT_ATTR_IDENTIFY command has no command specific data set by the driver.
+This command upon success, returns a data buffer that describes information about PCI virtualization
+management attributes. This information is of form:
+\begin{lstlisting}
+struct virtio_admin_pci_virt_mgmt_attr_identify_result {
+        /* For compatibility - indicates which of the below fields are valid (1 means valid):
+         * Bit 0x0 - total_free_vfs_msix_count
+         * Bit 0x1 - per_vf_max_msix_count
+         * Bits 0x2 - 0x3F - reserved for future fields
+         */
+        le64 mask;
+        /* Number of free msix in the global msix pool for VFs */
+        le32 total_free_vfs_msix_count;
+        /* Max number of msix vectors that can be assigned for a single VF */
+        le16 per_vf_max_msix_count;
+};
+\end{lstlisting}
+
+\subsection{VIRTIO ADMIN PCI VIRT PROPERTY SET command}\label{sec:Basic Facilities of a Virtio Device / Admin Virtqueues / VIRTIO ADMIN PCI VIRT PROPERTY SET command}
+
+The VIRTIO_ADMIN_PCI_VIRT_PROPERTY_SET command is used to modify the values of VF properties.
+The command specific data set by the driver is of form:
+\begin{lstlisting}
+virtio_admin_pci_virt_property_set_data {
+        /* The virtual function number */
+        le16 vf_number;
+        /* For compatibility - indicates which of the below properties should be
+         * modified (1 means that field should be modified):
+         * Bit 0x0 - msix_count
+         * Bits 0x1 - 0x3F - reserved for future fields
+         */
+        le64 property_mask;
+        /* The amount of MSI-X vectors */
+        le16 msix_count;
+};
+\end{lstlisting}
+
+\begin{note}
+{vf_number can't be greater than NumVFs value as defined in the PCI specification
+or smaller than 1. An error status will be returned otherwise.}
+\end{note}
+
+This command has no command specific result set by the device. Upon success, the device guarantees
+that all the requested properties were modified to the given values. Otherwise, error will be returned.
+
+\begin{note}
+{Before setting msix_count property the virtual/managed device (VF) shall be un-initialized and may not be used by the driver.}
+\end{note}
+
+\subsection{VIRTIO ADMIN PCI VIRT PROPERTY GET command}\label{sec:Basic Facilities of a Virtio Device / Admin Virtqueues / VIRTIO ADMIN PCI VIRT PROPERTY GET command}
+
+The VIRTIO_ADMIN_PCI_VIRT_PROPERTY_GET command is used to obtain the values of VF properties.
+The command specific data set by the driver is of form:
+\begin{lstlisting}
+virtio_admin_pci_virt_property_get_data {
+        /* The virtual function number */
+        le16 vf_number;
+        /* For compatibility - indicates which of the below properties should be
+         * queried (1 means that field should be queried):
+         * Bit 0x0 - msix_count
+         * Bits 0x1 - 0x3F - reserved for future fields
+         */
+        le64 property_mask;
+        /* The amount of MSI-X vectors */
+        le16 msix_count;
+};
+\end{lstlisting}
+
+\begin{note}
+{vf_number can't be greater than NumVFs value as defined in the PCI specification
+or smaller than 1. An error status will be returned otherwise.}
+\end{note}
+
+This command, upon success, returns a data buffer that describes the properties that were requested
+and their values for the subject virtio VF device according to the given vf_number.
+This information is of form:
+\begin{lstlisting}
+struct virtio_admin_pci_virt_property_get_result {
+        /* For compatibility - indicates which of the below fields were returned
+         * (1 means that field was returned):
+         * Bit 0x0 - msix_count
+         * Bits 0x1 - 0x3F - reserved for future fields
+         */
+        le64 property_mask;
+        /* The amount of MSI-X vectors */
+        le16 msix_count;
+};
+\end{lstlisting}
content.tex +27 -2
index e9c2383..64678f0 100644
@@ -99,10 +99,10 @@ \section{Feature Bits}\label{sec:Basic Facilities of a Virtio Device / Feature B
 \begin{description}
 \item[0 to 23] Feature bits for the specific device type
 
-\item[24 to 43] Feature bits reserved for extensions to the queue and
+\item[24 to 45] Feature bits reserved for extensions to the queue and
   feature negotiation mechanisms
 
-\item[44 and above] Feature bits reserved for future extensions.
+\item[46 and above] Feature bits reserved for future extensions.
 \end{description}
 
 \begin{note}
@@ -6878,6 +6878,17 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
   that all buffers are used by the admin virtqueue of the device in
   the same order in which they have been made available.
 
+  \item[VIRTIO_F_ADMIN_PCI_VIRT_MANAGER (44)] This feature indicates
+  that the device can manage PCI related capabilities for its managed PCI VF
+  devices and supports VIRTIO_ADMIN_PCI_VIRT_MGMT_ATTR_IDENTIFY,
+  VIRTIO_ADMIN_PCI_VIRT_PROPERTY_SET and VIRTIO_ADMIN_PCI_VIRT_PROPERTY_GET
+  admin commands. This feature can be supported only by PCI devices.
+
+  \item[VIRTIO_F_ADMIN_MSIX_MGMT (45)] This feature indicates
+  that the device supports management of the MSI-X vectors for its
+  managed PCI VF devices using VIRTIO_ADMIN_PCI_VIRT_PROPERTY_SET and
+  VIRTIO_ADMIN_PCI_VIRT_PROPERTY_GET admin commands.
+
 \end{description}
 
 \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
@@ -6920,6 +6931,14 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 A driver MAY accept VIRTIO_F_ADMIN_VQ_IN_ORDER only if it accepts
 VIRTIO_F_ADMIN_VQ.
 
+A driver MAY accept VIRTIO_F_ADMIN_PCI_VIRT_MANAGER only if it accepts
+VIRTIO_F_ADMIN_VQ.
+
+A driver MAY accept VIRTIO_F_ADMIN_MSIX_MGMT only if it accepts
+VIRTIO_F_ADMIN_VQ and VIRTIO_F_ADMIN_PCI_VIRT_MANAGER. Currently only
+MSI-X management of PCI virtual functions is supported, so the driver
+MUST NOT negotiate VIRTIO_F_ADMIN_MSIX_MGMT if VIRTIO_F_SR_IOV is not negotiated.
+
 \devicenormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
 
 A device MUST offer VIRTIO_F_VERSION_1.  A device MAY fail to operate further
@@ -6960,6 +6979,12 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 A device MAY offer VIRTIO_F_ADMIN_VQ_IN_ORDER only if it offers
 VIRTIO_F_ADMIN_VQ.
 
+A PCI device MAY offer VIRTIO_F_ADMIN_PCI_VIRT_MANAGER only if it
+offers VIRTIO_F_ADMIN_VQ.
+
+A PCI device MAY offer VIRTIO_F_ADMIN_MSIX_MGMT only if it
+offers VIRTIO_F_ADMIN_VQ, VIRTIO_F_ADMIN_PCI_VIRT_MANAGER and VIRTIO_F_SR_IOV.
+
 \section{Legacy Interface: Reserved Feature Bits}\label{sec:Reserved Feature Bits / Legacy Interface: Reserved Feature Bits}
 
 Transitional devices MAY offer the following:
Signature · 1 line
2.21.0
#28 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Max Gurtovoy
Quoted 9 lines · Max Gurtovoy

These new features are parallel to VIRTIO_F_INDIRECT_DESC and VIRTIO_F_IN_ORDER. Some devices might support these features only for admin virtqueues and some might support them for both admin virtqueues and request virtqueues or only for non-admin virtqueues. Some optimization can be made for each type of virtqueue, thus we separate these features for the different virtqueue types.

That seems vague as motivation.
Why do we need to optimize admin queues? Aren't they fundamentally a control path feature?
Why would we want to special-case these features specifically? Should we allow control of features per VQ generally?

Quoted 245 lines
---
 content.tex     | 47 +++++++++++++++++++++++++++++++++++++++--------
 packed-ring.tex | 26 +++++++++++++-------------
 split-ring.tex  | 35 +++++++++++++++++++++++------------
 3 files changed, 75 insertions(+), 33 deletions(-)
content.tex +39 -8
index c524fab..cc3e648 100644
@@ -99,10 +99,10 @@ \section{Feature Bits}\label{sec:Basic Facilities of a Virtio Device / Feature B
 \begin{description}
 \item[0 to 23] Feature bits for the specific device type
 
-\item[24 to 41] Feature bits reserved for extensions to the queue and
+\item[24 to 43] Feature bits reserved for extensions to the queue and
   feature negotiation mechanisms
 
-\item[42 and above] Feature bits reserved for future extensions.
+\item[44 and above] Feature bits reserved for future extensions.
 \end{description}
 
 \begin{note}
@@ -318,8 +318,9 @@ \section{Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Virtqueues}
 
 Some devices always use descriptors in the same order in which
 they have been made available. These devices can offer the
-VIRTIO_F_IN_ORDER feature. If negotiated, this knowledge
-might allow optimizations or simplify driver and/or device code.
+VIRTIO_F_IN_ORDER and/or VIRTIO_F_ADMIN_VQ_IN_ORDER features.
+If negotiated, this knowledge might allow optimizations or
+simplify driver and/or device code.
 
 Each virtqueue can consist of up to 3 parts:
 \begin{itemize}
@@ -6768,7 +6769,7 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 Device / Virtqueues / The Virtqueue Descriptor Table / Indirect
 Descriptors}~\nameref{sec:Basic Facilities of a Virtio Device /
 Virtqueues / The Virtqueue Descriptor Table / Indirect
-Descriptors} and \ref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}~\nameref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}.
+Descriptors} and \ref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}~\nameref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}. This excluding the descriptors sent via the admin virtqueue.
   \item[VIRTIO_F_EVENT_IDX(29)] This feature enables the \field{used_event}
   and the \field{avail_event} fields as described in
 \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Used Buffer Notification Suppression}, \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Used Ring} and \ref{sec:Packed Virtqueues / Driver and Device Event Suppression}.
@@ -6800,8 +6801,9 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
   support for the packed virtqueue layout as described in
   \ref{sec:Basic Facilities of a Virtio Device / Packed Virtqueues}~\nameref{sec:Basic Facilities of a Virtio Device / Packed Virtqueues}.
   \item[VIRTIO_F_IN_ORDER(35)] This feature indicates
-  that all buffers are used by the device in the same
-  order in which they have been made available.
+  that all buffers are used by the device, excluding buffers used by
+  the admin virtqueue, in the same order in which they have been made
+  available.
   \item[VIRTIO_F_ORDER_PLATFORM(36)] This feature indicates
   that memory accesses by the driver and the device are ordered
   in a way described by the platform.
@@ -6852,6 +6854,18 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
   \item[VIRTIO_F_ADMIN_VQ (41)] This feature indicates that
   the device supports administration virtqueue negotiation.
 
+  \item[VIRTIO_F_ADMIN_VQ_INDIRECT_DESC (42)] Negotiating this feature
+  indicates that the driver can use descriptors with the VIRTQ_DESC_F_INDIRECT
+  flag set, as described in \ref{sec:Basic Facilities of a Virtio
+Device / Virtqueues / The Virtqueue Descriptor Table / Indirect
+Descriptors}~\nameref{sec:Basic Facilities of a Virtio Device /
+Virtqueues / The Virtqueue Descriptor Table / Indirect
+Descriptors} and \ref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}~\nameref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}. This refers to descriptors sent via the admin
+  virtqueue and excluding the descriptors that sent via other virtqueues.
+  \item[VIRTIO_F_ADMIN_VQ_IN_ORDER (43)] This feature indicates
+  that all buffers are used by the admin virtqueue of the device in
+  the same order in which they have been made available.
+
 \end{description}
 
 \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
@@ -6888,6 +6902,12 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 
 A driver SHOULD accept VIRTIO_F_NOTIF_CONFIG_DATA if it is offered.
 
+A driver MAY accept VIRTIO_F_ADMIN_VQ_INDIRECT_DESC only if it accepts
+VIRTIO_F_ADMIN_VQ.
+
+A driver MAY accept VIRTIO_F_ADMIN_VQ_IN_ORDER only if it accepts
+VIRTIO_F_ADMIN_VQ.
+
 \devicenormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
 
 A device MUST offer VIRTIO_F_VERSION_1.  A device MAY fail to operate further
@@ -6902,7 +6922,12 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 accepted.
 
 If VIRTIO_F_IN_ORDER has been negotiated, a device MUST use
-buffers in the same order in which they have been available.
+buffers in the same order in which they have been available. This refers
+to buffers that are used by virtqueue that is not the admin virtqueue.
+
+If VIRTIO_F_ADMIN_VQ_IN_ORDER has been negotiated, a device MUST use
+buffers in the same order in which they have been available. This refers
+only for buffers that are used by the admin virtqueue.
 
 A device MAY fail to operate further if
 VIRTIO_F_ORDER_PLATFORM is offered but not accepted.
@@ -6917,6 +6942,12 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 and presents a PCI SR-IOV capability structure, otherwise
 it MUST NOT offer VIRTIO_F_SR_IOV.
 
+A device MAY offer VIRTIO_F_ADMIN_VQ_INDIRECT_DESC only if it offers
+VIRTIO_F_ADMIN_VQ.
+
+A device MAY offer VIRTIO_F_ADMIN_VQ_IN_ORDER only if it offers
+VIRTIO_F_ADMIN_VQ.
+
 \section{Legacy Interface: Reserved Feature Bits}\label{sec:Reserved Feature Bits / Legacy Interface: Reserved Feature Bits}
 
 Transitional devices MAY offer the following:
packed-ring.tex +13 -13
index a9e6c16..ef1dbc2 100644
@@ -240,13 +240,12 @@ \subsection{Indirect Flag: Scatter-Gather Support}
 \label{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}
 
 Some devices benefit by concurrently dispatching a large number
-of large requests. The VIRTIO_F_INDIRECT_DESC feature allows this. To increase
-ring capacity the driver can store a (read-only by the device) table of indirect
-descriptors anywhere in memory, and insert a descriptor in the main
-virtqueue (with \field{Flags} bit VIRTQ_DESC_F_INDIRECT on) that refers to
-a buffer element
-containing this indirect descriptor table; \field{addr} and \field{len}
-refer to the indirect table address and length in bytes,
+of large requests. The VIRTIO_F_INDIRECT_DESC and VIRTIO_F_ADMIN_VQ_INDIRECT_DESC
+features allows this. To increase ring capacity the driver can store a (read-only
+by the device) table of indirect descriptors anywhere in memory, and insert a
+descriptor in the main virtqueue (with \field{Flags} bit VIRTQ_DESC_F_INDIRECT on)
+that refers to a buffer element containing this indirect descriptor table;
+\field{addr} and \field{len} refer to the indirect table address and length in bytes,
 respectively.
 \begin{lstlisting}
 /* This means the element contains a table of descriptors. */
@@ -279,10 +278,11 @@ \subsection{In-order use of descriptors}
 
 Some devices always use descriptors in the same order in which
 they have been made available. These devices can offer the
-VIRTIO_F_IN_ORDER feature. If negotiated, this knowledge allows
-devices to notify the use of a batch of buffers to the driver by
-only writing out a single used descriptor with the Buffer ID
-corresponding to the last descriptor in the batch.
+VIRTIO_F_IN_ORDER and/or VIRTIO_F_ADMIN_VQ_IN_ORDER features.
+If negotiated, this knowledge allows devices to notify the use of
+a batch of buffers to the driver by only writing out a single used
+descriptor with the Buffer ID corresponding to the last descriptor
+in the batch.
 
 The device then skips forward in the ring according to the size of
 the batch. The driver needs to look up the used Buffer ID and
@@ -500,8 +500,8 @@ \subsection{Event Suppression Structure Format}\label{sec:Basic
 
 \drivernormative{\subsection}{Indirect Descriptors}{Basic Facilities of a Virtio Device / Packed Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
 The driver MUST NOT set the DESC_F_INDIRECT flag unless the
-VIRTIO_F_INDIRECT_DESC feature was negotiated.   The driver MUST NOT
-set any flags except DESC_F_WRITE within an indirect descriptor.
+VIRTIO_F_INDIRECT_DESC or VIRTIO_F_ADMIN_VQ_INDIRECT_DESC features were negotiated.
+The driver MUST NOT set any flags except DESC_F_WRITE within an indirect descriptor.
 
 A driver MUST NOT create a descriptor chain longer than allowed
 by the device.
split-ring.tex +23 -12
index de94038..cd53840 100644
@@ -208,6 +208,10 @@ \subsection{The Virtqueue Descriptor Table}\label{sec:Basic Facilities of a Virt
 descriptors in ring order: starting from offset 0 in the table,
 and wrapping around at the end of the table.
 
+If VIRTIO_F_ADMIN_VQ_IN_ORDER has been negotiated, driver uses
+descriptors in admin virtqueue ring order: starting from offset 0 in the
+table, and wrapping around at the end of the table.
+
 \begin{note}
 The legacy \hyperref[intro:Virtio PCI Draft]{[Virtio PCI Draft]}
 referred to this structure as vring_desc, and the constants as
@@ -223,16 +227,18 @@ \subsection{The Virtqueue Descriptor Table}\label{sec:Basic Facilities of a Virt
 Drivers MUST NOT add a descriptor chain longer than $2^{32}$ bytes in total;
 this implies that loops in the descriptor chain are forbidden!
 
-If VIRTIO_F_IN_ORDER has been negotiated, and when making a
-descriptor with VRING_DESC_F_NEXT set in \field{flags} at offset
-$x$ in the table available to the device, driver MUST set
+If VIRTIO_F_ADMIN_VQ_IN_ORDER and/or VIRTIO_F_IN_ORDER has been negotiated,
+and when making a descriptor with VRING_DESC_F_NEXT set in \field{flags} at
+offset $x$ in the table available to the device, driver MUST set
 \field{next} to $0$ for the last descriptor in the table
 (where $x = queue\_size - 1$) and to $x + 1$ for the rest of the descriptors.
+This refers to admin virtqueue descriptors and rest other virtqueues types descriptors respectively.
 
 \subsubsection{Indirect Descriptors}\label{sec:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
 
 Some devices benefit by concurrently dispatching a large number
-of large requests. The VIRTIO_F_INDIRECT_DESC feature allows this (see \ref{sec:virtio-queue.h}~\nameref{sec:virtio-queue.h}). To increase
+of large requests. The VIRTIO_F_INDIRECT_DESC and VIRTIO_F_ADMIN_VQ_INDIRECT_DESC
+features allows this (see \ref{sec:virtio-queue.h}~\nameref{sec:virtio-queue.h}). To increase
 ring capacity the driver can store a table of indirect
 descriptors anywhere in memory, and insert a descriptor in main
 virtqueue (with \field{flags}\&VIRTQ_DESC_F_INDIRECT on) that refers to memory buffer
@@ -258,15 +264,19 @@ \subsubsection{Indirect Descriptors}\label{sec:Basic Facilities of a Virtio Devi
 A single indirect descriptor
 table can include both device-readable and device-writable descriptors.
 
-If VIRTIO_F_IN_ORDER has been negotiated, indirect descriptors
-use sequential indices, in-order: index 0 followed by index 1
+If VIRTIO_F_IN_ORDER has been negotiated, indirect descriptors,
+for non admin virtqueue, use sequential indices, in-order: index 0 followed
+by index 1 followed by index 2, etc.
+
+If VIRTIO_F_ADMIN_VQ_IN_ORDER has been negotiated, admin virtqueue indirect
+descriptors use sequential indices, in-order: index 0 followed by index 1
 followed by index 2, etc.
 
 \drivernormative{\paragraph}{Indirect Descriptors}{Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
 The driver MUST NOT set the VIRTQ_DESC_F_INDIRECT flag unless the
-VIRTIO_F_INDIRECT_DESC feature was negotiated.   The driver MUST NOT
-set the VIRTQ_DESC_F_INDIRECT flag within an indirect descriptor (ie. only
-one table per descriptor).
+VIRTIO_F_INDIRECT_DESC and/or VIRTIO_F_ADMIN_VQ_INDIRECT_DESC features were negotiated.
+The driver MUST NOT set the VIRTQ_DESC_F_INDIRECT flag within an indirect
+descriptor (ie. only one table per descriptor).
 
 A driver MUST NOT create a descriptor chain longer than the Queue Size of
 the device.
@@ -274,9 +284,10 @@ \subsubsection{Indirect Descriptors}\label{sec:Basic Facilities of a Virtio Devi
 A driver MUST NOT set both VIRTQ_DESC_F_INDIRECT and VIRTQ_DESC_F_NEXT
 in \field{flags}.
 
-If VIRTIO_F_IN_ORDER has been negotiated, indirect descriptors
-MUST appear sequentially, with \field{next} taking the value
-of 1 for the 1st descriptor, 2 for the 2nd one, etc.
+If VIRTIO_F_ADMIN_VQ_IN_ORDER and/or VIRTIO_F_IN_ORDER has been negotiated,
+indirect descriptors MUST appear sequentially, with \field{next} taking the
+value of 1 for the 1st descriptor, 2 for the 2nd one, etc for admin virtqueue
+and rest other virtqueues types respectively.
 
 \devicenormative{\paragraph}{Indirect Descriptors}{Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
 The device MUST ignore the write-only flag (\field{flags}\&VIRTQ_DESC_F_WRITE) in the descriptor that refers to an indirect table.
Signature · 1 line
2.21.0
#29 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines · Max Gurtovoy

These new features are parallel to VIRTIO_F_INDIRECT_DESC and VIRTIO_F_IN_ORDER. Some devices might support these features only for admin virtqueues and some might support them for both admin virtqueues and request virtqueues or only for non-admin virtqueues. Some optimization can be made for each type of virtqueue, thus we separate these features for the different virtqueue types.

Quoted 7 lines
Quoted 2 lines

That seems vague as motivation.
Why do we need to optimize admin queues? Aren't they fundamentally a control path feature?
Why would we want to special-case these features specifically? Should we allow control of features per VQ generally?

We would like to allow executing admins commands out of order and IO requests in order for efficiency.

And also the other way around.

IO cmds and admin cmds have different considerations in many cases.

Quoted 247 lines
Quoted 247 lines

---
  content.tex     | 47 +++++++++++++++++++++++++++++++++++++++--------
  packed-ring.tex | 26 +++++++++++++-------------
  split-ring.tex  | 35 +++++++++++++++++++++++------------
  3 files changed, 75 insertions(+), 33 deletions(-)
content.tex +39 -8
index c524fab..cc3e648 100644
@@ -99,10 +99,10 @@ \section{Feature Bits}\label{sec:Basic Facilities of a Virtio Device / Feature B
  \begin{description}
  \item[0 to 23] Feature bits for the specific device type
 
-\item[24 to 41] Feature bits reserved for extensions to the queue and
+\item[24 to 43] Feature bits reserved for extensions to the queue and
    feature negotiation mechanisms
 
-\item[42 and above] Feature bits reserved for future extensions.
+\item[44 and above] Feature bits reserved for future extensions.
  \end{description}
 
  \begin{note}
@@ -318,8 +318,9 @@ \section{Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Virtqueues}
 
  Some devices always use descriptors in the same order in which
  they have been made available. These devices can offer the
-VIRTIO_F_IN_ORDER feature. If negotiated, this knowledge
-might allow optimizations or simplify driver and/or device code.
+VIRTIO_F_IN_ORDER and/or VIRTIO_F_ADMIN_VQ_IN_ORDER features.
+If negotiated, this knowledge might allow optimizations or
+simplify driver and/or device code.
 
  Each virtqueue can consist of up to 3 parts:
  \begin{itemize}
@@ -6768,7 +6769,7 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
  Device / Virtqueues / The Virtqueue Descriptor Table / Indirect
  Descriptors}~\nameref{sec:Basic Facilities of a Virtio Device /
  Virtqueues / The Virtqueue Descriptor Table / Indirect
-Descriptors} and \ref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}~\nameref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}.
+Descriptors} and \ref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}~\nameref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}. This excluding the descriptors sent via the admin virtqueue.
    \item[VIRTIO_F_EVENT_IDX(29)] This feature enables the \field{used_event}
    and the \field{avail_event} fields as described in
  \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Used Buffer Notification Suppression}, \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Used Ring} and \ref{sec:Packed Virtqueues / Driver and Device Event Suppression}.
@@ -6800,8 +6801,9 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
    support for the packed virtqueue layout as described in
    \ref{sec:Basic Facilities of a Virtio Device / Packed Virtqueues}~\nameref{sec:Basic Facilities of a Virtio Device / Packed Virtqueues}.
    \item[VIRTIO_F_IN_ORDER(35)] This feature indicates
-  that all buffers are used by the device in the same
-  order in which they have been made available.
+  that all buffers are used by the device, excluding buffers used by
+  the admin virtqueue, in the same order in which they have been made
+  available.
    \item[VIRTIO_F_ORDER_PLATFORM(36)] This feature indicates
    that memory accesses by the driver and the device are ordered
    in a way described by the platform.
@@ -6852,6 +6854,18 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
    \item[VIRTIO_F_ADMIN_VQ (41)] This feature indicates that
    the device supports administration virtqueue negotiation.
 
+  \item[VIRTIO_F_ADMIN_VQ_INDIRECT_DESC (42)] Negotiating this feature
+  indicates that the driver can use descriptors with the VIRTQ_DESC_F_INDIRECT
+  flag set, as described in \ref{sec:Basic Facilities of a Virtio
+Device / Virtqueues / The Virtqueue Descriptor Table / Indirect
+Descriptors}~\nameref{sec:Basic Facilities of a Virtio Device /
+Virtqueues / The Virtqueue Descriptor Table / Indirect
+Descriptors} and \ref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}~\nameref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}. This refers to descriptors sent via the admin
+  virtqueue and excluding the descriptors that sent via other virtqueues.
+  \item[VIRTIO_F_ADMIN_VQ_IN_ORDER (43)] This feature indicates
+  that all buffers are used by the admin virtqueue of the device in
+  the same order in which they have been made available.
+
  \end{description}
 
  \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
@@ -6888,6 +6902,12 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 
  A driver SHOULD accept VIRTIO_F_NOTIF_CONFIG_DATA if it is offered.
 
+A driver MAY accept VIRTIO_F_ADMIN_VQ_INDIRECT_DESC only if it accepts
+VIRTIO_F_ADMIN_VQ.
+
+A driver MAY accept VIRTIO_F_ADMIN_VQ_IN_ORDER only if it accepts
+VIRTIO_F_ADMIN_VQ.
+
  \devicenormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
 
  A device MUST offer VIRTIO_F_VERSION_1.  A device MAY fail to operate further
@@ -6902,7 +6922,12 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
  accepted.
 
  If VIRTIO_F_IN_ORDER has been negotiated, a device MUST use
-buffers in the same order in which they have been available.
+buffers in the same order in which they have been available. This refers
+to buffers that are used by virtqueue that is not the admin virtqueue.
+
+If VIRTIO_F_ADMIN_VQ_IN_ORDER has been negotiated, a device MUST use
+buffers in the same order in which they have been available. This refers
+only for buffers that are used by the admin virtqueue.
 
  A device MAY fail to operate further if
  VIRTIO_F_ORDER_PLATFORM is offered but not accepted.
@@ -6917,6 +6942,12 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
  and presents a PCI SR-IOV capability structure, otherwise
  it MUST NOT offer VIRTIO_F_SR_IOV.
 
+A device MAY offer VIRTIO_F_ADMIN_VQ_INDIRECT_DESC only if it offers
+VIRTIO_F_ADMIN_VQ.
+
+A device MAY offer VIRTIO_F_ADMIN_VQ_IN_ORDER only if it offers
+VIRTIO_F_ADMIN_VQ.
+
  \section{Legacy Interface: Reserved Feature Bits}\label{sec:Reserved Feature Bits / Legacy Interface: Reserved Feature Bits}
 
  Transitional devices MAY offer the following:
packed-ring.tex +13 -13
index a9e6c16..ef1dbc2 100644
@@ -240,13 +240,12 @@ \subsection{Indirect Flag: Scatter-Gather Support}
  \label{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}
 
  Some devices benefit by concurrently dispatching a large number
-of large requests. The VIRTIO_F_INDIRECT_DESC feature allows this. To increase
-ring capacity the driver can store a (read-only by the device) table of indirect
-descriptors anywhere in memory, and insert a descriptor in the main
-virtqueue (with \field{Flags} bit VIRTQ_DESC_F_INDIRECT on) that refers to
-a buffer element
-containing this indirect descriptor table; \field{addr} and \field{len}
-refer to the indirect table address and length in bytes,
+of large requests. The VIRTIO_F_INDIRECT_DESC and VIRTIO_F_ADMIN_VQ_INDIRECT_DESC
+features allows this. To increase ring capacity the driver can store a (read-only
+by the device) table of indirect descriptors anywhere in memory, and insert a
+descriptor in the main virtqueue (with \field{Flags} bit VIRTQ_DESC_F_INDIRECT on)
+that refers to a buffer element containing this indirect descriptor table;
+\field{addr} and \field{len} refer to the indirect table address and length in bytes,
  respectively.
  \begin{lstlisting}
  /* This means the element contains a table of descriptors. */
@@ -279,10 +278,11 @@ \subsection{In-order use of descriptors}
 
  Some devices always use descriptors in the same order in which
  they have been made available. These devices can offer the
-VIRTIO_F_IN_ORDER feature. If negotiated, this knowledge allows
-devices to notify the use of a batch of buffers to the driver by
-only writing out a single used descriptor with the Buffer ID
-corresponding to the last descriptor in the batch.
+VIRTIO_F_IN_ORDER and/or VIRTIO_F_ADMIN_VQ_IN_ORDER features.
+If negotiated, this knowledge allows devices to notify the use of
+a batch of buffers to the driver by only writing out a single used
+descriptor with the Buffer ID corresponding to the last descriptor
+in the batch.
 
  The device then skips forward in the ring according to the size of
  the batch. The driver needs to look up the used Buffer ID and
@@ -500,8 +500,8 @@ \subsection{Event Suppression Structure Format}\label{sec:Basic
 
  \drivernormative{\subsection}{Indirect Descriptors}{Basic Facilities of a Virtio Device / Packed Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
  The driver MUST NOT set the DESC_F_INDIRECT flag unless the
-VIRTIO_F_INDIRECT_DESC feature was negotiated.   The driver MUST NOT
-set any flags except DESC_F_WRITE within an indirect descriptor.
+VIRTIO_F_INDIRECT_DESC or VIRTIO_F_ADMIN_VQ_INDIRECT_DESC features were negotiated.
+The driver MUST NOT set any flags except DESC_F_WRITE within an indirect descriptor.
 
  A driver MUST NOT create a descriptor chain longer than allowed
  by the device.
split-ring.tex +23 -12
index de94038..cd53840 100644
@@ -208,6 +208,10 @@ \subsection{The Virtqueue Descriptor Table}\label{sec:Basic Facilities of a Virt
  descriptors in ring order: starting from offset 0 in the table,
  and wrapping around at the end of the table.
 
+If VIRTIO_F_ADMIN_VQ_IN_ORDER has been negotiated, driver uses
+descriptors in admin virtqueue ring order: starting from offset 0 in the
+table, and wrapping around at the end of the table.
+
  \begin{note}
  The legacy \hyperref[intro:Virtio PCI Draft]{[Virtio PCI Draft]}
  referred to this structure as vring_desc, and the constants as
@@ -223,16 +227,18 @@ \subsection{The Virtqueue Descriptor Table}\label{sec:Basic Facilities of a Virt
  Drivers MUST NOT add a descriptor chain longer than $2^{32}$ bytes in total;
  this implies that loops in the descriptor chain are forbidden!
 
-If VIRTIO_F_IN_ORDER has been negotiated, and when making a
-descriptor with VRING_DESC_F_NEXT set in \field{flags} at offset
-$x$ in the table available to the device, driver MUST set
+If VIRTIO_F_ADMIN_VQ_IN_ORDER and/or VIRTIO_F_IN_ORDER has been negotiated,
+and when making a descriptor with VRING_DESC_F_NEXT set in \field{flags} at
+offset $x$ in the table available to the device, driver MUST set
  \field{next} to $0$ for the last descriptor in the table
  (where $x = queue\_size - 1$) and to $x + 1$ for the rest of the descriptors.
+This refers to admin virtqueue descriptors and rest other virtqueues types descriptors respectively.
 
  \subsubsection{Indirect Descriptors}\label{sec:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
 
  Some devices benefit by concurrently dispatching a large number
-of large requests. The VIRTIO_F_INDIRECT_DESC feature allows this (see \ref{sec:virtio-queue.h}~\nameref{sec:virtio-queue.h}). To increase
+of large requests. The VIRTIO_F_INDIRECT_DESC and VIRTIO_F_ADMIN_VQ_INDIRECT_DESC
+features allows this (see \ref{sec:virtio-queue.h}~\nameref{sec:virtio-queue.h}). To increase
  ring capacity the driver can store a table of indirect
  descriptors anywhere in memory, and insert a descriptor in main
  virtqueue (with \field{flags}\&VIRTQ_DESC_F_INDIRECT on) that refers to memory buffer
@@ -258,15 +264,19 @@ \subsubsection{Indirect Descriptors}\label{sec:Basic Facilities of a Virtio Devi
  A single indirect descriptor
  table can include both device-readable and device-writable descriptors.
 
-If VIRTIO_F_IN_ORDER has been negotiated, indirect descriptors
-use sequential indices, in-order: index 0 followed by index 1
+If VIRTIO_F_IN_ORDER has been negotiated, indirect descriptors,
+for non admin virtqueue, use sequential indices, in-order: index 0 followed
+by index 1 followed by index 2, etc.
+
+If VIRTIO_F_ADMIN_VQ_IN_ORDER has been negotiated, admin virtqueue indirect
+descriptors use sequential indices, in-order: index 0 followed by index 1
  followed by index 2, etc.
 
  \drivernormative{\paragraph}{Indirect Descriptors}{Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
  The driver MUST NOT set the VIRTQ_DESC_F_INDIRECT flag unless the
-VIRTIO_F_INDIRECT_DESC feature was negotiated.   The driver MUST NOT
-set the VIRTQ_DESC_F_INDIRECT flag within an indirect descriptor (ie. only
-one table per descriptor).
+VIRTIO_F_INDIRECT_DESC and/or VIRTIO_F_ADMIN_VQ_INDIRECT_DESC features were negotiated.
+The driver MUST NOT set the VIRTQ_DESC_F_INDIRECT flag within an indirect
+descriptor (ie. only one table per descriptor).
 
  A driver MUST NOT create a descriptor chain longer than the Queue Size of
  the device.
@@ -274,9 +284,10 @@ \subsubsection{Indirect Descriptors}\label{sec:Basic Facilities of a Virtio Devi
  A driver MUST NOT set both VIRTQ_DESC_F_INDIRECT and VIRTQ_DESC_F_NEXT
  in \field{flags}.
 
-If VIRTIO_F_IN_ORDER has been negotiated, indirect descriptors
-MUST appear sequentially, with \field{next} taking the value
-of 1 for the 1st descriptor, 2 for the 2nd one, etc.
+If VIRTIO_F_ADMIN_VQ_IN_ORDER and/or VIRTIO_F_IN_ORDER has been negotiated,
+indirect descriptors MUST appear sequentially, with \field{next} taking the
+value of 1 for the 1st descriptor, 2 for the 2nd one, etc for admin virtqueue
+and rest other virtqueues types respectively.
 
  \devicenormative{\paragraph}{Indirect Descriptors}{Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
  The device MUST ignore the write-only flag (\field{flags}\&VIRTQ_DESC_F_WRITE) in the descriptor that refers to an indirect table.
Signature · 1 line
2.21.0
#30 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 12 lines · Max Gurtovoy
Quoted 10 lines · Michael S. Tsirkin
Quoted 9 lines · Max Gurtovoy

These new features are parallel to VIRTIO_F_INDIRECT_DESC and VIRTIO_F_IN_ORDER. Some devices might support these features only for admin virtqueues and some might support them for both admin virtqueues and request virtqueues or only for non-admin virtqueues. Some optimization can be made for each type of virtqueue, thus we separate these features for the different virtqueue types.

Quoted 8 lines
Quoted 5 lines

That seems vague as motivation.
Why do we need to optimize admin queues? Aren't they fundamentally a control path feature?
Why would we want to special-case these features specifically? Should we allow control of features per VQ generally?

We would like to allow executing admins commands out of order and IO requests in order for efficiency.

It's a control queue. Why do we worry?

Quoted 2 lines

And also the other way around.

what exactly does this mean?

Quoted 1 line

IO cmds and admin cmds have different considerations in many cases.

That's still pretty vague. so do other types of VQ, such as RX/TX.

E.g. I can see how a hardware vendor might want to avoid supporting indirect with RX for virtio net with mergeable buffers, but still support it for TX.

I can vaguely see the usefulness of VIRTIO_F_ADMIN_VQ_IN_ORDER. I think you want to reorder admin commands dealing with unrelated VFs but keep io vqs in order for speed. Just guessing, you should spell the real motivation out. However, I think a better way to do that is with finalizing the VIRTIO_F_PARTIAL_ORDER proposal from august.
Pls review and let me know. If there's finally a use for it I'll prioritize finalizing that idea.
Don't see much point in tweaking INDIRECT at all.

Quoted 219 lines
Quoted 219 lines
Quoted 219 lines

---
  content.tex     | 47 +++++++++++++++++++++++++++++++++++++++--------
  packed-ring.tex | 26 +++++++++++++-------------
  split-ring.tex  | 35 +++++++++++++++++++++++------------
  3 files changed, 75 insertions(+), 33 deletions(-)
content.tex +39 -8
index c524fab..cc3e648 100644
@@ -99,10 +99,10 @@ \section{Feature Bits}\label{sec:Basic Facilities of a Virtio Device / Feature B
  \begin{description}
  \item[0 to 23] Feature bits for the specific device type
-\item[24 to 41] Feature bits reserved for extensions to the queue and
+\item[24 to 43] Feature bits reserved for extensions to the queue and
    feature negotiation mechanisms
-\item[42 and above] Feature bits reserved for future extensions.
+\item[44 and above] Feature bits reserved for future extensions.
  \end{description}
  \begin{note}
@@ -318,8 +318,9 @@ \section{Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Virtqueues}
  Some devices always use descriptors in the same order in which
  they have been made available. These devices can offer the
-VIRTIO_F_IN_ORDER feature. If negotiated, this knowledge
-might allow optimizations or simplify driver and/or device code.
+VIRTIO_F_IN_ORDER and/or VIRTIO_F_ADMIN_VQ_IN_ORDER features.
+If negotiated, this knowledge might allow optimizations or
+simplify driver and/or device code.
  Each virtqueue can consist of up to 3 parts:
  \begin{itemize}
@@ -6768,7 +6769,7 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
  Device / Virtqueues / The Virtqueue Descriptor Table / Indirect
  Descriptors}~\nameref{sec:Basic Facilities of a Virtio Device /
  Virtqueues / The Virtqueue Descriptor Table / Indirect
-Descriptors} and \ref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}~\nameref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}.
+Descriptors} and \ref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}~\nameref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}. This excluding the descriptors sent via the admin virtqueue.
    \item[VIRTIO_F_EVENT_IDX(29)] This feature enables the \field{used_event}
    and the \field{avail_event} fields as described in
  \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Used Buffer Notification Suppression}, \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Used Ring} and \ref{sec:Packed Virtqueues / Driver and Device Event Suppression}.
@@ -6800,8 +6801,9 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
    support for the packed virtqueue layout as described in
    \ref{sec:Basic Facilities of a Virtio Device / Packed Virtqueues}~\nameref{sec:Basic Facilities of a Virtio Device / Packed Virtqueues}.
    \item[VIRTIO_F_IN_ORDER(35)] This feature indicates
-  that all buffers are used by the device in the same
-  order in which they have been made available.
+  that all buffers are used by the device, excluding buffers used by
+  the admin virtqueue, in the same order in which they have been made
+  available.
    \item[VIRTIO_F_ORDER_PLATFORM(36)] This feature indicates
    that memory accesses by the driver and the device are ordered
    in a way described by the platform.
@@ -6852,6 +6854,18 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
    \item[VIRTIO_F_ADMIN_VQ (41)] This feature indicates that
    the device supports administration virtqueue negotiation.
+  \item[VIRTIO_F_ADMIN_VQ_INDIRECT_DESC (42)] Negotiating this feature
+  indicates that the driver can use descriptors with the VIRTQ_DESC_F_INDIRECT
+  flag set, as described in \ref{sec:Basic Facilities of a Virtio
+Device / Virtqueues / The Virtqueue Descriptor Table / Indirect
+Descriptors}~\nameref{sec:Basic Facilities of a Virtio Device /
+Virtqueues / The Virtqueue Descriptor Table / Indirect
+Descriptors} and \ref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}~\nameref{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}. This refers to descriptors sent via the admin
+  virtqueue and excluding the descriptors that sent via other virtqueues.
+  \item[VIRTIO_F_ADMIN_VQ_IN_ORDER (43)] This feature indicates
+  that all buffers are used by the admin virtqueue of the device in
+  the same order in which they have been made available.
+
  \end{description}
  \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
@@ -6888,6 +6902,12 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
  A driver SHOULD accept VIRTIO_F_NOTIF_CONFIG_DATA if it is offered.
+A driver MAY accept VIRTIO_F_ADMIN_VQ_INDIRECT_DESC only if it accepts
+VIRTIO_F_ADMIN_VQ.
+
+A driver MAY accept VIRTIO_F_ADMIN_VQ_IN_ORDER only if it accepts
+VIRTIO_F_ADMIN_VQ.
+
  \devicenormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
  A device MUST offer VIRTIO_F_VERSION_1.  A device MAY fail to operate further
@@ -6902,7 +6922,12 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
  accepted.
  If VIRTIO_F_IN_ORDER has been negotiated, a device MUST use
-buffers in the same order in which they have been available.
+buffers in the same order in which they have been available. This refers
+to buffers that are used by virtqueue that is not the admin virtqueue.
+
+If VIRTIO_F_ADMIN_VQ_IN_ORDER has been negotiated, a device MUST use
+buffers in the same order in which they have been available. This refers
+only for buffers that are used by the admin virtqueue.
  A device MAY fail to operate further if
  VIRTIO_F_ORDER_PLATFORM is offered but not accepted.
@@ -6917,6 +6942,12 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
  and presents a PCI SR-IOV capability structure, otherwise
  it MUST NOT offer VIRTIO_F_SR_IOV.
+A device MAY offer VIRTIO_F_ADMIN_VQ_INDIRECT_DESC only if it offers
+VIRTIO_F_ADMIN_VQ.
+
+A device MAY offer VIRTIO_F_ADMIN_VQ_IN_ORDER only if it offers
+VIRTIO_F_ADMIN_VQ.
+
  \section{Legacy Interface: Reserved Feature Bits}\label{sec:Reserved Feature Bits / Legacy Interface: Reserved Feature Bits}
  Transitional devices MAY offer the following:
packed-ring.tex +13 -13
index a9e6c16..ef1dbc2 100644
@@ -240,13 +240,12 @@ \subsection{Indirect Flag: Scatter-Gather Support}
  \label{sec:Packed Virtqueues / Indirect Flag: Scatter-Gather Support}
  Some devices benefit by concurrently dispatching a large number
-of large requests. The VIRTIO_F_INDIRECT_DESC feature allows this. To increase
-ring capacity the driver can store a (read-only by the device) table of indirect
-descriptors anywhere in memory, and insert a descriptor in the main
-virtqueue (with \field{Flags} bit VIRTQ_DESC_F_INDIRECT on) that refers to
-a buffer element
-containing this indirect descriptor table; \field{addr} and \field{len}
-refer to the indirect table address and length in bytes,
+of large requests. The VIRTIO_F_INDIRECT_DESC and VIRTIO_F_ADMIN_VQ_INDIRECT_DESC
+features allows this. To increase ring capacity the driver can store a (read-only
+by the device) table of indirect descriptors anywhere in memory, and insert a
+descriptor in the main virtqueue (with \field{Flags} bit VIRTQ_DESC_F_INDIRECT on)
+that refers to a buffer element containing this indirect descriptor table;
+\field{addr} and \field{len} refer to the indirect table address and length in bytes,
  respectively.
  \begin{lstlisting}
  /* This means the element contains a table of descriptors. */
@@ -279,10 +278,11 @@ \subsection{In-order use of descriptors}
  Some devices always use descriptors in the same order in which
  they have been made available. These devices can offer the
-VIRTIO_F_IN_ORDER feature. If negotiated, this knowledge allows
-devices to notify the use of a batch of buffers to the driver by
-only writing out a single used descriptor with the Buffer ID
-corresponding to the last descriptor in the batch.
+VIRTIO_F_IN_ORDER and/or VIRTIO_F_ADMIN_VQ_IN_ORDER features.
+If negotiated, this knowledge allows devices to notify the use of
+a batch of buffers to the driver by only writing out a single used
+descriptor with the Buffer ID corresponding to the last descriptor
+in the batch.
  The device then skips forward in the ring according to the size of
  the batch. The driver needs to look up the used Buffer ID and
@@ -500,8 +500,8 @@ \subsection{Event Suppression Structure Format}\label{sec:Basic
  \drivernormative{\subsection}{Indirect Descriptors}{Basic Facilities of a Virtio Device / Packed Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
  The driver MUST NOT set the DESC_F_INDIRECT flag unless the
-VIRTIO_F_INDIRECT_DESC feature was negotiated.   The driver MUST NOT
-set any flags except DESC_F_WRITE within an indirect descriptor.
+VIRTIO_F_INDIRECT_DESC or VIRTIO_F_ADMIN_VQ_INDIRECT_DESC features were negotiated.
+The driver MUST NOT set any flags except DESC_F_WRITE within an indirect descriptor.
  A driver MUST NOT create a descriptor chain longer than allowed
  by the device.
split-ring.tex +23 -12
index de94038..cd53840 100644
@@ -208,6 +208,10 @@ \subsection{The Virtqueue Descriptor Table}\label{sec:Basic Facilities of a Virt
  descriptors in ring order: starting from offset 0 in the table,
  and wrapping around at the end of the table.
+If VIRTIO_F_ADMIN_VQ_IN_ORDER has been negotiated, driver uses
+descriptors in admin virtqueue ring order: starting from offset 0 in the
+table, and wrapping around at the end of the table.
+
  \begin{note}
  The legacy \hyperref[intro:Virtio PCI Draft]{[Virtio PCI Draft]}
  referred to this structure as vring_desc, and the constants as
@@ -223,16 +227,18 @@ \subsection{The Virtqueue Descriptor Table}\label{sec:Basic Facilities of a Virt
  Drivers MUST NOT add a descriptor chain longer than $2^{32}$ bytes in total;
  this implies that loops in the descriptor chain are forbidden!
-If VIRTIO_F_IN_ORDER has been negotiated, and when making a
-descriptor with VRING_DESC_F_NEXT set in \field{flags} at offset
-$x$ in the table available to the device, driver MUST set
+If VIRTIO_F_ADMIN_VQ_IN_ORDER and/or VIRTIO_F_IN_ORDER has been negotiated,
+and when making a descriptor with VRING_DESC_F_NEXT set in \field{flags} at
+offset $x$ in the table available to the device, driver MUST set
  \field{next} to $0$ for the last descriptor in the table
  (where $x = queue\_size - 1$) and to $x + 1$ for the rest of the descriptors.
+This refers to admin virtqueue descriptors and rest other virtqueues types descriptors respectively.
  \subsubsection{Indirect Descriptors}\label{sec:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
  Some devices benefit by concurrently dispatching a large number
-of large requests. The VIRTIO_F_INDIRECT_DESC feature allows this (see \ref{sec:virtio-queue.h}~\nameref{sec:virtio-queue.h}). To increase
+of large requests. The VIRTIO_F_INDIRECT_DESC and VIRTIO_F_ADMIN_VQ_INDIRECT_DESC
+features allows this (see \ref{sec:virtio-queue.h}~\nameref{sec:virtio-queue.h}). To increase
  ring capacity the driver can store a table of indirect
  descriptors anywhere in memory, and insert a descriptor in main
  virtqueue (with \field{flags}\&VIRTQ_DESC_F_INDIRECT on) that refers to memory buffer
@@ -258,15 +264,19 @@ \subsubsection{Indirect Descriptors}\label{sec:Basic Facilities of a Virtio Devi
  A single indirect descriptor
  table can include both device-readable and device-writable descriptors.
-If VIRTIO_F_IN_ORDER has been negotiated, indirect descriptors
-use sequential indices, in-order: index 0 followed by index 1
+If VIRTIO_F_IN_ORDER has been negotiated, indirect descriptors,
+for non admin virtqueue, use sequential indices, in-order: index 0 followed
+by index 1 followed by index 2, etc.
+
+If VIRTIO_F_ADMIN_VQ_IN_ORDER has been negotiated, admin virtqueue indirect
+descriptors use sequential indices, in-order: index 0 followed by index 1
  followed by index 2, etc.
  \drivernormative{\paragraph}{Indirect Descriptors}{Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
  The driver MUST NOT set the VIRTQ_DESC_F_INDIRECT flag unless the
-VIRTIO_F_INDIRECT_DESC feature was negotiated.   The driver MUST NOT
-set the VIRTQ_DESC_F_INDIRECT flag within an indirect descriptor (ie. only
-one table per descriptor).
+VIRTIO_F_INDIRECT_DESC and/or VIRTIO_F_ADMIN_VQ_INDIRECT_DESC features were negotiated.
+The driver MUST NOT set the VIRTQ_DESC_F_INDIRECT flag within an indirect
+descriptor (ie. only one table per descriptor).
  A driver MUST NOT create a descriptor chain longer than the Queue Size of
  the device.
@@ -274,9 +284,10 @@ \subsubsection{Indirect Descriptors}\label{sec:Basic Facilities of a Virtio Devi
  A driver MUST NOT set both VIRTQ_DESC_F_INDIRECT and VIRTQ_DESC_F_NEXT
  in \field{flags}.
-If VIRTIO_F_IN_ORDER has been negotiated, indirect descriptors
-MUST appear sequentially, with \field{next} taking the value
-of 1 for the 1st descriptor, 2 for the 2nd one, etc.
+If VIRTIO_F_ADMIN_VQ_IN_ORDER and/or VIRTIO_F_IN_ORDER has been negotiated,
+indirect descriptors MUST appear sequentially, with \field{next} taking the
+value of 1 for the 1st descriptor, 2 for the 2nd one, etc for admin virtqueue
+and rest other virtqueues types respectively.
  \devicenormative{\paragraph}{Indirect Descriptors}{Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
  The device MUST ignore the write-only flag (\field{flags}\&VIRTQ_DESC_F_WRITE) in the descriptor that refers to an indirect table.
Signature · 1 line
2.21.0
#2 lore raw

Re: [PATCH 1/5] Add virtio Admin Virtqueue specification

In reply to Max Gurtovoy
Quoted 36 lines · Max Gurtovoy

In one of the many use cases a user wants to manipulate features and configuration of the virtio devices regardless of the device type (net/block/console). Some of this configuration is generic enough. i.e Number of MSI-X vectors of a virtio PCI VF device. There is a need to do such features query and manipulation by its parent PCI PF.

Currently virtio specification defines control virtqueue to manipulate features and configuration of the device it operates on. However, control virtqueue commands are device type specific, which makes it very difficult to extend for device agnostic commands. Control virtqueue is also limited to follow in order completion for the device which negotiates VIRTIO_F_IN_ORDER feature. This feature limits the use of control virtqueue for feature manipulation in out of order manner for unrelated commands.

To support these requirements which overcome above two limitations in elegant way, this patch introduces a new admin virtqueue. Admin virtqueue will use the same command format for all types of virtio devices.

Subsequent patches make use of this admin virtqueue.

---
 admin-virtq.tex | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 content.tex     |  9 +++++++--
 2 files changed, 56 insertions(+), 2 deletions(-)
 create mode 100644 admin-virtq.tex
admin-virtq.tex new file +0 -0
new file mode 100644
index 0000000..ad20f89

admin-virtq.tex line 5

Quoted 5 lines
admin-virtq.tex new file +5 -0
@@ -0,0 +1,49 @@
+\section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin Virtqueues}
+
+Admin virtqueue is used to send administrative commands to manipulate
+various features of the device which would not easily map into the
+configuration space.

IMHO this is too vague to be useful. E.g. I don't really see why would not commands specified in the next patch map to config space.

We had an off-list meeting where I proposed addressing one device from another or grouping multiple devices as a more specific scope. That would be one way to address this.

Following this idea, all commands would then gain fields for addressing one device from another.

Not everything maps well to a queue. E.g. it would be great to have list of available commands in memory.
Figuring out max vectors also looks like a good
example for memory and not through a command.
VQ # of the admin VQ could also be made more discoverable. How about an SRIOV capability describing this stuff then?

Quoted 33 lines
admin-virtq.tex new file +33 -0
+Use of Admin virtqueue is negotiated by the VIRTIO_F_ADMIN_VQ
+feature bit.
+
+Admin virtqueue index may vary among different device types.
+
+The Admin command set defines the commands that may be issued only to the admin
+virtqueue. Each virtio device that advertises the VIRTIO_F_ADMIN_VQ feature, MUST
+support all the mandatory admin commands. A device MAY support also one or more
+optional admin commands. All commands are of the following form:
+
+\begin{lstlisting}
+struct virtio_admin_cmd {
+        /* Device-readable part */
+        u8 command;
+        u8 command-specific-data[];
+
+        /* Device-writable part */
+        u8 status;
+        u8 command-specific-result[];
+};
+
+/* status values */
+#define VIRTIO_ADMIN_STATUS_OK 0
+#define VIRTIO_ADMIN_STATUS_ERR 1
+#define VIRTIO_ADMIN_STATUS_COMMAND_UNSUPPORTED 2
+\end{lstlisting}
+
+The \field{command} and \field{command-specific-data} are
+set by the driver, and the device sets the \field{status} and the
+\field{command-specific-result}, if needed.
+
+The following table describes the Admin command set:
+

admin-virtq.tex line 49

Quoted 10 lines
admin-virtq.tex new file +10 -0
+\begin{tabular}{|l|l|l|l|}
+\hline
+Opcode (bits) & Opcode (hex) & Command & M/O \\
+\hline \hline
+ -  & 00h - 7Fh   & Generic admin cmds    & -  \\
+\hline
+ -  & 80h - FFh   & Reserved    & - \\
+\hline
+\end{tabular}
+

Add conformance clauses pls. If this section is too generic to have any then this functionality is too generic to be useful ;)

Quoted 38 lines
content.tex +7 -2
index 32de668..c524fab 100644
@@ -99,10 +99,10 @@ \section{Feature Bits}\label{sec:Basic Facilities of a Virtio Device / Feature B
 \begin{description}
 \item[0 to 23] Feature bits for the specific device type
 
-\item[24 to 40] Feature bits reserved for extensions to the queue and
+\item[24 to 41] Feature bits reserved for extensions to the queue and
   feature negotiation mechanisms
 
-\item[41 and above] Feature bits reserved for future extensions.
+\item[42 and above] Feature bits reserved for future extensions.
 \end{description}
 
 \begin{note}
@@ -449,6 +449,8 @@ \section{Exporting Objects}\label{sec:Basic Facilities of a Virtio Device / Expo
 types. It is RECOMMENDED that devices generate version 4
 UUIDs as specified by \hyperref[intro:rfc4122]{[RFC4122]}.
 
+\input{admin-virtq.tex}
+
 \chapter{General Initialization And Device Operation}\label{sec:General Initialization And Device Operation}
 
 We start with an overview of device initialization, then expand on the
@@ -6847,6 +6849,9 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
   that the driver can reset a queue individually.
   See \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Reset}.
 
+  \item[VIRTIO_F_ADMIN_VQ (41)] This feature indicates that
+  the device supports administration virtqueue negotiation.
+
 \end{description}
 
 \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
Signature · 1 line
2.21.0
#90 lore raw

Re: [PATCH 4/5] virtio-net: add support for VIRTIO_F_ADMIN_VQ

In reply to Max Gurtovoy
Quoted 4 lines · Max Gurtovoy

Set the relevant index in case of VIRTIO_F_ADMIN_VQ negotiation.

So admin VQ # is only known when all features are negotiated. Which is quite annoying if hypervisor wants to partition things e.g. handling admin q in process and handling vqs by an external process or by hardware.

I think we can allow devices to set the VQ# for the admin queue instead. Would that work?

Quoted 27 lines
---
 content.tex | 3 +++
 1 file changed, 3 insertions(+)
content.tex +3 -0
index 0ae4b68..e9c2383 100644
@@ -3034,6 +3034,7 @@ \subsection{Virtqueues}\label{sec:Device Types / Network Device / Virtqueues}
 \item[2(N-1)] receiveqN
 \item[2(N-1)+1] transmitqN
 \item[2N] controlq
+\item[2N + 1] adminq (or \textbf{2N} in case VIRTIO_NET_F_CTRL_VQ is not set)
 \end{description}
 
  N=1 if neither VIRTIO_NET_F_MQ nor VIRTIO_NET_F_RSS are negotiated, otherwise N is set by
@@ -3041,6 +3042,8 @@ \subsection{Virtqueues}\label{sec:Device Types / Network Device / Virtqueues}
 
  controlq only exists if VIRTIO_NET_F_CTRL_VQ set.
 
+ adminq only exists if VIRTIO_F_ADMIN_VQ set.
+
 \subsection{Feature bits}\label{sec:Device Types / Network Device / Feature bits}
 
 \begin{description}
Signature · 1 line
2.21.0
#105 lore raw

Re: [PATCH 5/5] Add support for dynamic MSI-X vector mgmt for VFs

In reply to Max Gurtovoy
Quoted 15 lines · Max Gurtovoy

A typical cloud provider SR-IOV use case is to create many VFs for use by guest VMs. The VFs may not be assigned to a VM until a user requests a VM of a certain size, e.g., number of CPUs. A VF may need MSI-X vectors proportional to the number of CPUs in the VM, but there is no standard way today in the spec to change the number of MSI-X vectors supported by a VF, although there are some operating systems that support this.

Introduce new feature bits for generic PCI virtualization management mechanism and a specific mechanism to manage the MSI-X vector assignment process of virtual/managed functions by its parent virtio device via its admin virtqueue. For now, virtio supports only PCI virtual function virtualization, thus the virt manager device will be the PF and the managed device will be the VF.

Quoted 2 lines

So, we have the concept of vectors.

Quoted 11 lines
---
 admin-virtq.tex | 98 ++++++++++++++++++++++++++++++++++++++++++++++++-
 content.tex     | 29 ++++++++++++++-
 2 files changed, 124 insertions(+), 3 deletions(-)
admin-virtq.tex +0 -0
index ad20f89..4ee8a32 100644
@@ -41,9 +41,105 @@ \section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin
 \hline

admin-virtq.tex \section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin · line 50

Quoted 10 lines
admin-virtq.tex +7 -1
 Opcode (bits) & Opcode (hex) & Command & M/O \\
 \hline \hline
- -  & 00h - 7Fh   & Generic admin cmds    & -  \\
+ 00000000b  & 00h   & VIRTIO_ADMIN_PCI_VIRT_MGMT_ATTR_IDENTIFY    & O  \\
+\hline
+ 00000001b  & 01h   & VIRTIO_ADMIN_PCI_VIRT_PROPERTY_SET    & O  \\
+\hline
+ 00000010b  & 02h   & VIRTIO_ADMIN_PCI_VIRT_PROPERTY_GET    & O  \\
+\hline
+ -  & 03h - 7Fh   & Generic admin cmds    & -  \\

What are these?

admin-virtq.tex \section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin · line 55

Quoted 5 lines
admin-virtq.tex +0 -0
 \hline
  -  & 80h - FFh   & Reserved    & - \\
 \hline
 \end{tabular}
 

What are the rules for these commands? Can they be issued when any VFs are in use? What happens then? I don't exactly understand how this interacts with existing virtio devices binding to VFs.
Does device fail assignment of a vector # out of range, falling back to smaller # of vectors?
Generally # of VQs to use and # of interrupts can be related, otherwise performance might suffer - e.g. it's pointless to have many more interrupts than VQs.
Shouldn't we control # of per-device VQs with these commands too then?

Quoted 9 lines
admin-virtq.tex +9 -0
+\subsection{VIRTIO ADMIN PCI VIRT MGMT ATTR IDENTIFY command}\label{sec:Basic Facilities of a Virtio Device / Admin Virtqueues / VIRTIO ADMIN PCI VIRT MGMT ATTR IDENTIFY command}
+
+The VIRTIO_ADMIN_PCI_VIRT_MGMT_ATTR_IDENTIFY command has no command specific data set by the driver.
+This command upon success, returns a data buffer that describes information about PCI virtualization
+management attributes. This information is of form:
+\begin{lstlisting}
+struct virtio_admin_pci_virt_mgmt_attr_identify_result {
+        /* For compatibility - indicates which of the below fields are valid (1 means valid):
+         * Bit 0x0 - total_free_vfs_msix_count

admin-virtq.tex \section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin · line 74

Quoted 10 lines
admin-virtq.tex +10 -0
+         * Bit 0x1 - per_vf_max_msix_count
+         * Bits 0x2 - 0x3F - reserved for future fields
+         */
+        le64 mask;
+        /* Number of free msix in the global msix pool for VFs */
+        le32 total_free_vfs_msix_count;
+        /* Max number of msix vectors that can be assigned for a single VF */
+        le16 per_vf_max_msix_count;
+};
+\end{lstlisting}

Looks like something that should be memory mapped. In fact you reinvented a features/capability mask here which would make memory-mapping this quite easy.

admin-virtq.tex \section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin · line 78

Quoted 4 lines
admin-virtq.tex +4 -0
+
+\subsection{VIRTIO ADMIN PCI VIRT PROPERTY SET command}\label{sec:Basic Facilities of a Virtio Device / Admin Virtqueues / VIRTIO ADMIN PCI VIRT PROPERTY SET command}
+
+The VIRTIO_ADMIN_PCI_VIRT_PROPERTY_SET command is used to modify the values of VF properties.

VF appears completely out of the blue here. You need some description and quote relevant specs to introduce this to the reader. Since this depends on a feature and feature depends on VIRTIO_F_SR_IOV and that in turn is only for PFs, I conclude that this is also only for PFs. But would not hurt to spell this out.
Also can other transport types support partitioning?
Or is that always a PCI thing?

admin-virtq.tex \section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin · line 88

Quoted 10 lines
admin-virtq.tex +10 -0
+The command specific data set by the driver is of form:
+\begin{lstlisting}
+virtio_admin_pci_virt_property_set_data {
+        /* The virtual function number */
+        le16 vf_number;
+        /* For compatibility - indicates which of the below properties should be
+         * modified (1 means that field should be modified):
+         * Bit 0x0 - msix_count
+         * Bits 0x1 - 0x3F - reserved for future fields
+         */

Addressing specific VFs seems like something that should be a generic capability rather a command specific one. No? Why not?

admin-virtq.tex \section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin · line 97

Quoted 9 lines
admin-virtq.tex +9 -0
+        le64 property_mask;
+        /* The amount of MSI-X vectors */
+        le16 msix_count;
+};
+\end{lstlisting}
+
+\begin{note}
+{vf_number can't be greater than NumVFs value as defined in the PCI specification
+or smaller than 1. An error status will be returned otherwise.}

Meaning VIRTIO_ADMIN_STATUS_ERR?

Quoted 7 lines
admin-virtq.tex +7 -0
+\end{note}
+
+This command has no command specific result set by the device. Upon success, the device guarantees
+that all the requested properties were modified to the given values. Otherwise, error will be returned.
+
+\begin{note}
+{Before setting msix_count property the virtual/managed device (VF) shall be un-initialized and may not be used by the driver.}

admin-virtq.tex \section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin · line 114

Quoted 10 lines
admin-virtq.tex +10 -0
+\end{note}
+
+\subsection{VIRTIO ADMIN PCI VIRT PROPERTY GET command}\label{sec:Basic Facilities of a Virtio Device / Admin Virtqueues / VIRTIO ADMIN PCI VIRT PROPERTY GET command}
+
+The VIRTIO_ADMIN_PCI_VIRT_PROPERTY_GET command is used to obtain the values of VF properties.
+The command specific data set by the driver is of form:
+\begin{lstlisting}
+virtio_admin_pci_virt_property_get_data {
+        /* The virtual function number */
+        le16 vf_number;

How will we extend this for things like scalable IOV partitioning? Defining a completely new set of commands for that expected usecase seems weird ...

admin-virtq.tex \section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin · line 123

Quoted 9 lines
admin-virtq.tex +9 -0
+        /* For compatibility - indicates which of the below properties should be
+         * queried (1 means that field should be queried):
+         * Bit 0x0 - msix_count
+         * Bits 0x1 - 0x3F - reserved for future fields
+         */
+        le64 property_mask;
+        /* The amount of MSI-X vectors */
+        le16 msix_count;
+};

Pls change the layout adding padding so fields are length-aligned.

Unclear. So why does query send msix_count?

Quoted 11 lines
admin-virtq.tex +11 -0
+\end{lstlisting}
+
+\begin{note}
+{vf_number can't be greater than NumVFs value as defined in the PCI specification
+or smaller than 1. An error status will be returned otherwise.}
+\end{note}
+
+This command, upon success, returns a data buffer that describes the properties that were requested
+and their values for the subject virtio VF device according to the given vf_number.
+This information is of form:
+\begin{lstlisting}

admin-virtq.tex \section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin · line 144

Quoted 10 lines
admin-virtq.tex +10 -0
+struct virtio_admin_pci_virt_property_get_result {
+        /* For compatibility - indicates which of the below fields were returned
+         * (1 means that field was returned):
+         * Bit 0x0 - msix_count
+         * Bits 0x1 - 0x3F - reserved for future fields
+         */
+        le64 property_mask;
+        /* The amount of MSI-X vectors */
+        le16 msix_count;
+};

Seems the same except for VF #. So how about reusing it so reader does not need to parse this twice?

admin-virtq.tex \section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin · line 145

Quoted 1 line
admin-virtq.tex +1 -0
+\end{lstlisting}

Please describe the various fields in the document body. The structure formatting should be of the format similar to

struct virtio_pci_cap {
u8 cap_vndr; /* Short description */
...
};

We should describe this in indtroduction, I notice that we do not currently do this.

Also pls use bitfields, defines etc as explained in introduction.tex

Pls also add conformance statements about the use here.

Quoted 18 lines
content.tex +2 -2
index e9c2383..64678f0 100644
@@ -99,10 +99,10 @@ \section{Feature Bits}\label{sec:Basic Facilities of a Virtio Device / Feature B
 \begin{description}
 \item[0 to 23] Feature bits for the specific device type
 
-\item[24 to 43] Feature bits reserved for extensions to the queue and
+\item[24 to 45] Feature bits reserved for extensions to the queue and
   feature negotiation mechanisms
 
-\item[44 and above] Feature bits reserved for future extensions.
+\item[46 and above] Feature bits reserved for future extensions.
 \end{description}
 
 \begin{note}

content.tex \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits} · line 6885

Quoted 8 lines
content.tex +5 -0
@@ -6878,6 +6878,17 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
   that all buffers are used by the admin virtqueue of the device in
   the same order in which they have been made available.
 
+  \item[VIRTIO_F_ADMIN_PCI_VIRT_MANAGER (44)] This feature indicates
+  that the device can manage PCI related capabilities for its managed PCI VF
+  devices and supports VIRTIO_ADMIN_PCI_VIRT_MGMT_ATTR_IDENTIFY,
+  VIRTIO_ADMIN_PCI_VIRT_PROPERTY_SET and VIRTIO_ADMIN_PCI_VIRT_PROPERTY_GET
+  admin commands. This feature can be supported only by PCI devices.

Not sure what does _VIRT_ here stand for.

Quoted 39 lines
content.tex +20 -0
+
+  \item[VIRTIO_F_ADMIN_MSIX_MGMT (45)] This feature indicates
+  that the device supports management of the MSI-X vectors for its
+  managed PCI VF devices using VIRTIO_ADMIN_PCI_VIRT_PROPERTY_SET and
+  VIRTIO_ADMIN_PCI_VIRT_PROPERTY_GET admin commands.
+
 \end{description}
 
 \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
@@ -6920,6 +6931,14 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 A driver MAY accept VIRTIO_F_ADMIN_VQ_IN_ORDER only if it accepts
 VIRTIO_F_ADMIN_VQ.
 
+A driver MAY accept VIRTIO_F_ADMIN_PCI_VIRT_MANAGER only if it accepts
+VIRTIO_F_ADMIN_VQ.
+
+A driver MAY accept VIRTIO_F_ADMIN_MSIX_MGMT only if it accepts
+VIRTIO_F_ADMIN_VQ and VIRTIO_F_ADMIN_PCI_VIRT_MANAGER. Currently only
+MSI-X management of PCI virtual functions is supported, so the driver
+MUST NOT negotiate VIRTIO_F_ADMIN_MSIX_MGMT if VIRTIO_F_SR_IOV is not negotiated.
+
 \devicenormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
 
 A device MUST offer VIRTIO_F_VERSION_1.  A device MAY fail to operate further
@@ -6960,6 +6979,12 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 A device MAY offer VIRTIO_F_ADMIN_VQ_IN_ORDER only if it offers
 VIRTIO_F_ADMIN_VQ.
 
+A PCI device MAY offer VIRTIO_F_ADMIN_PCI_VIRT_MANAGER only if it
+offers VIRTIO_F_ADMIN_VQ.
+
+A PCI device MAY offer VIRTIO_F_ADMIN_MSIX_MGMT only if it
+offers VIRTIO_F_ADMIN_VQ, VIRTIO_F_ADMIN_PCI_VIRT_MANAGER and VIRTIO_F_SR_IOV.
+
 \section{Legacy Interface: Reserved Feature Bits}\label{sec:Reserved Feature Bits / Legacy Interface: Reserved Feature Bits}
 
 Transitional devices MAY offer the following:
Signature · 1 line
2.21.0
#88 lore raw

Re: [PATCH 3/5] virtio-blk: add support for VIRTIO_F_ADMIN_VQ

In reply to Max Gurtovoy
Quoted 4 lines · Max Gurtovoy

Set the relevant index in case of VIRTIO_F_ADMIN_VQ negotiation.

Igh. Need to update each and every device just so it can get generic commands seems very annoying.

Quoted 39 lines
---
 content.tex | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
content.tex +10 -1
index cc3e648..0ae4b68 100644
@@ -4518,10 +4518,19 @@ \subsection{Device ID}\label{sec:Device Types / Block Device / Device ID}
   2
 
 \subsection{Virtqueues}\label{sec:Device Types / Block Device / Virtqueues}
+ if VIRTIO_F_ADMIN_VQ is not negotiated, the request queues layout is as follows:
 \begin{description}
 \item[0] requestq1
 \item[\ldots]
 \item[N-1] requestqN
+\end{description}
+
+ If VIRTIO_F_ADMIN_VQ is negotiated, the queues layout is as follows:
+\begin{description}
+\item[0] requestq1
+\item[\ldots]
+\item[N-1] requestqN
+\item[N] adminq
 \end{description}
 
  N=1 if VIRTIO_BLK_F_MQ is not negotiated, otherwise N is set by
@@ -4590,7 +4599,7 @@ \subsection{Device configuration layout}\label{sec:Device Types / Block Device /
 bits as indicated above.
 
 The field \field{num_queues} only exists if VIRTIO_BLK_F_MQ is set. This field specifies
-the number of queues.
+the number of request queues. This field doesn't account admin virtqueue.
 
 The parameters in the configuration space of the device \field{max_discard_sectors}
 \field{discard_sector_alignment} are expressed in 512-byte units if the
Signature · 1 line
2.21.0
#107 lore raw
In reply to Max Gurtovoy
Quoted 19 lines · Max Gurtovoy

Hi,

In a PCI SR-IOV configuration, MSI-X vectors of the device is precious device resource. Hence making efficient use of it based on the use case that aligns to the VM configuration is desired for best system performance.

For example, today's static assignment of the amount of MSI-X vectors doesn't allow sophisticated utilization of resources.

A typical cloud provider SR-IOV use case is to create many VFs for use by guest VMs. Each VM might have a different purpose and different amount of resources accordingly (e.g. number of CPUs). A common driver usage of device's MSI-X vectors is proportional to the number of CPUs in the VM. Since the system administrator might know the amount of CPUs in the requested VM, he can also configure the VF's MSI-X vectors amount proportional to the number of CPUs in the VM. In this way, the utilization of the physical hardware will be improved.

Quoted 7 lines

Today we have some operating systems that support provisioning MSI-X vectors for PCI VFs.

Update the specification to have a method to change the number of MSI-X vectors supported by a VF using the PF admin virtqueue interface. For that, create a generic infrastructure for managing PCI resources of the managed VF by its parent PF.

Can you describe in the cover letter or the commit log of the admin VQ patch the motivation for using a VQ and not memory mapped space for this capability?
In fact I feel at least some commands would be better replaced with a memory mapped structure.

Quoted 21 lines

Patches (1/5)-(2/5) introduce the admin virtqueue concept and feature bits. Patches (3/5)-(4/5) add the admin virtq to virtio-blk and virtio-net devices.
Patch (5/5) introduce MSI-X mgmt support.

Max Gurtovoy (5):
Add virtio Admin Virtqueue specification
Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER
virtio-blk: add support for VIRTIO_F_ADMIN_VQ
virtio-net: add support for VIRTIO_F_ADMIN_VQ
Add support for dynamic MSI-X vector mgmt for VFs

 admin-virtq.tex | 145 ++++++++++++++++++++++++++++++++++++++++++++++++
 content.tex     |  91 +++++++++++++++++++++++++++---
 packed-ring.tex |  26 ++++-----
 split-ring.tex  |  35 ++++++++----
 4 files changed, 263 insertions(+), 34 deletions(-)
 create mode 100644 admin-virtq.tex
Signature · 1 line
2.21.0
#91 lore raw

Re: [PATCH 4/5] virtio-net: add support for VIRTIO_F_ADMIN_VQ

In reply to Michael S. Tsirkin
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Max Gurtovoy

Set the relevant index in case of VIRTIO_F_ADMIN_VQ negotiation.

So admin VQ # is only known when all features are negotiated.

No. The driver should see if VIRTIO_NET_F_CTRL_VQ/VIRTIO_F_ADMIN_VQ are set by the device.

Negotiation is not a must.

Lets say CTRL_VQ is supported by the device and driver A would like to use it and driver B wouldn't like to use it - in both cases the admiq VQ # would be 2N + 1.

Quoted 35 lines

Which is quite annoying if hypervisor wants to partition things e.g. handling admin q in process and handling vqs by an external process or by hardware.

I think we can allow devices to set the VQ# for the admin queue instead. Would that work?

Quoted 27 lines
---
  content.tex | 3 +++
  1 file changed, 3 insertions(+)
content.tex +3 -0
index 0ae4b68..e9c2383 100644
@@ -3034,6 +3034,7 @@ \subsection{Virtqueues}\label{sec:Device Types / Network Device / Virtqueues}
  \item[2(N-1)] receiveqN
  \item[2(N-1)+1] transmitqN
  \item[2N] controlq
+\item[2N + 1] adminq (or \textbf{2N} in case VIRTIO_NET_F_CTRL_VQ is not set)
  \end{description}
 
   N=1 if neither VIRTIO_NET_F_MQ nor VIRTIO_NET_F_RSS are negotiated, otherwise N is set by
@@ -3041,6 +3042,8 @@ \subsection{Virtqueues}\label{sec:Device Types / Network Device / Virtqueues}
 
   controlq only exists if VIRTIO_NET_F_CTRL_VQ set.
 
+ adminq only exists if VIRTIO_F_ADMIN_VQ set.
+
  \subsection{Feature bits}\label{sec:Device Types / Network Device / Feature bits}
 
  \begin{description}
Signature · 1 line
2.21.0
#92 lore raw

Re: [PATCH 4/5] virtio-net: add support for VIRTIO_F_ADMIN_VQ

Quoted 9 lines · Max Gurtovoy
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Max Gurtovoy

Set the relevant index in case of VIRTIO_F_ADMIN_VQ negotiation.

So admin VQ # is only known when all features are negotiated.

Quoted 8 lines

No. The driver should see if VIRTIO_NET_F_CTRL_VQ/VIRTIO_F_ADMIN_VQ are set by the device.

Negotiation is not a must.

Lets say CTRL_VQ is supported by the device and driver A would like to use it and driver B wouldn't like to use it - in both cases the admiq VQ # would be 2N + 1.

What's N here though?

Quoted 3 lines
Quoted 3 lines

Which is quite annoying if hypervisor wants to partition things e.g. handling admin q in process and handling vqs by an external process or by hardware.

This part stands.

Quoted 28 lines
Quoted 28 lines

I think we can allow devices to set the VQ# for the admin queue instead. Would that work?

Quoted 23 lines
---
  content.tex | 3 +++
  1 file changed, 3 insertions(+)
content.tex +3 -0
index 0ae4b68..e9c2383 100644
@@ -3034,6 +3034,7 @@ \subsection{Virtqueues}\label{sec:Device Types / Network Device / Virtqueues}
  \item[2(N-1)] receiveqN
  \item[2(N-1)+1] transmitqN
  \item[2N] controlq
+\item[2N + 1] adminq (or \textbf{2N} in case VIRTIO_NET_F_CTRL_VQ is not set)
  \end{description}
   N=1 if neither VIRTIO_NET_F_MQ nor VIRTIO_NET_F_RSS are negotiated, otherwise N is set by
@@ -3041,6 +3042,8 @@ \subsection{Virtqueues}\label{sec:Device Types / Network Device / Virtqueues}
   controlq only exists if VIRTIO_NET_F_CTRL_VQ set.
+ adminq only exists if VIRTIO_F_ADMIN_VQ set.
+
  \subsection{Feature bits}\label{sec:Device Types / Network Device / Feature bits}
  \begin{description}
Signature · 1 line
2.21.0
#3 lore raw

Re: [PATCH 1/5] Add virtio Admin Virtqueue specification

In reply to Michael S. Tsirkin
Quoted 31 lines · Michael S. Tsirkin
Quoted 30 lines · Max Gurtovoy

In one of the many use cases a user wants to manipulate features and configuration of the virtio devices regardless of the device type (net/block/console). Some of this configuration is generic enough. i.e Number of MSI-X vectors of a virtio PCI VF device. There is a need to do such features query and manipulation by its parent PCI PF.

Currently virtio specification defines control virtqueue to manipulate features and configuration of the device it operates on. However, control virtqueue commands are device type specific, which makes it very difficult to extend for device agnostic commands. Control virtqueue is also limited to follow in order completion for the device which negotiates VIRTIO_F_IN_ORDER feature. This feature limits the use of control virtqueue for feature manipulation in out of order manner for unrelated commands.

To support these requirements which overcome above two limitations in elegant way, this patch introduces a new admin virtqueue. Admin virtqueue will use the same command format for all types of virtio devices.

Subsequent patches make use of this admin virtqueue.

---
  admin-virtq.tex | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
  content.tex     |  9 +++++++--
  2 files changed, 56 insertions(+), 2 deletions(-)

create mode 100644 admin-virtq.tex

Quoted 13 lines

admin-virtq.tex line 5

Quoted 11 lines
admin-virtq.tex new file +5 -0
new file mode 100644
index 0000000..ad20f89
@@ -0,0 +1,49 @@
+\section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin Virtqueues}
+
+Admin virtqueue is used to send administrative commands to manipulate
+various features of the device which would not easily map into the
+configuration space.

IMHO this is too vague to be useful. E.g. I don't really see why would not commands specified in the next patch map to config space.

Well I took this sentence from the current spec :)

Quoted 5 lines

We had an off-list meeting where I proposed addressing one device from another or grouping multiple devices as a more specific scope. That would be one way to address this.

Are you suggestion a creation of a virtio subsystem or a virtio group definition ?

Devices will be part of this subsystem: one primary/manager device and many secondary/managed devices ?

Each subsystem will have a unique UUID and each device will have a unique vdev_id within this subsystem.

If this is the direction, I can prepare something..

Quoted 6 lines

Following this idea, all commands would then gain fields for addressing one device from another.

Not everything maps well to a queue. E.g. it would be great to have list of available commands in memory.

I'm not sure I agree. Why can't it map to a queue ?

Quoted 2 lines

Figuring out max vectors also looks like a good
example for memory and not through a command.

Any explanation why is it looks good ? or better ?

Quoted 90 lines

VQ # of the admin VQ could also be made more discoverable. How about an SRIOV capability describing this stuff then?

Quoted 33 lines
admin-virtq.tex new file +33 -0
+Use of Admin virtqueue is negotiated by the VIRTIO_F_ADMIN_VQ
+feature bit.
+
+Admin virtqueue index may vary among different device types.
+
+The Admin command set defines the commands that may be issued only to the admin
+virtqueue. Each virtio device that advertises the VIRTIO_F_ADMIN_VQ feature, MUST
+support all the mandatory admin commands. A device MAY support also one or more
+optional admin commands. All commands are of the following form:
+
+\begin{lstlisting}
+struct virtio_admin_cmd {
+        /* Device-readable part */
+        u8 command;
+        u8 command-specific-data[];
+
+        /* Device-writable part */
+        u8 status;
+        u8 command-specific-result[];
+};
+
+/* status values */
+#define VIRTIO_ADMIN_STATUS_OK 0
+#define VIRTIO_ADMIN_STATUS_ERR 1
+#define VIRTIO_ADMIN_STATUS_COMMAND_UNSUPPORTED 2
+\end{lstlisting}
+
+The \field{command} and \field{command-specific-data} are
+set by the driver, and the device sets the \field{status} and the
+\field{command-specific-result}, if needed.
+
+The following table describes the Admin command set:
+

admin-virtq.tex line 49

Quoted 10 lines
admin-virtq.tex new file +10 -0
+\begin{tabular}{|l|l|l|l|}
+\hline
+Opcode (bits) & Opcode (hex) & Command & M/O \\
+\hline \hline
+ -  & 00h - 7Fh   & Generic admin cmds    & -  \\
+\hline
+ -  & 80h - FFh   & Reserved    & - \\
+\hline
+\end{tabular}
+

Add conformance clauses pls. If this section is too generic to have any then this functionality is too generic to be useful ;)

Quoted 38 lines
content.tex +7 -2
index 32de668..c524fab 100644
@@ -99,10 +99,10 @@ \section{Feature Bits}\label{sec:Basic Facilities of a Virtio Device / Feature B
  \begin{description}
  \item[0 to 23] Feature bits for the specific device type
 
-\item[24 to 40] Feature bits reserved for extensions to the queue and
+\item[24 to 41] Feature bits reserved for extensions to the queue and
    feature negotiation mechanisms
 
-\item[41 and above] Feature bits reserved for future extensions.
+\item[42 and above] Feature bits reserved for future extensions.
  \end{description}
 
  \begin{note}
@@ -449,6 +449,8 @@ \section{Exporting Objects}\label{sec:Basic Facilities of a Virtio Device / Expo
  types. It is RECOMMENDED that devices generate version 4
  UUIDs as specified by \hyperref[intro:rfc4122]{[RFC4122]}.
 
+\input{admin-virtq.tex}
+
  \chapter{General Initialization And Device Operation}\label{sec:General Initialization And Device Operation}
 
  We start with an overview of device initialization, then expand on the
@@ -6847,6 +6849,9 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
    that the driver can reset a queue individually.
    See \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Reset}.
 
+  \item[VIRTIO_F_ADMIN_VQ (41)] This feature indicates that
+  the device supports administration virtqueue negotiation.
+
  \end{description}
 
  \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
Signature · 1 line
2.21.0
#108 lore raw
In reply to Michael S. Tsirkin

Thursday, January 13, 2022 8:32 PM, Michael S. Tsirkin:

Quoted 31 lines

Subject: Re: [PATCH v1 0/5] VIRTIO: Provision maximum MSI-X vectors for a VF

Quoted 19 lines · Max Gurtovoy

Hi,

In a PCI SR-IOV configuration, MSI-X vectors of the device is precious device resource. Hence making efficient use of it based on the use case that aligns to the VM configuration is desired for best system performance.

For example, today's static assignment of the amount of MSI-X vectors doesn't allow sophisticated utilization of resources.

A typical cloud provider SR-IOV use case is to create many VFs for use by guest VMs. Each VM might have a different purpose and different amount of resources accordingly (e.g. number of CPUs). A common driver usage of device's MSI-X vectors is proportional to the number of CPUs in the VM. Since the system administrator might know the amount of CPUs in the requested VM, he can also configure the VF's MSI-X vectors amount proportional to the number of CPUs in the VM. In this way, the utilization of the physical hardware will be improved.

Quoted 7 lines

Today we have some operating systems that support provisioning MSI-X vectors for PCI VFs.

Update the specification to have a method to change the number of MSI-X vectors supported by a VF using the PF admin virtqueue interface. For that, create a generic infrastructure for managing PCI resources of the managed VF by its parent PF.

Quoted 5 lines

Can you describe in the cover letter or the commit log of the admin VQ patch the motivation for using a VQ and not memory mapped space for this capability?
In fact I feel at least some commands would be better replaced with a memory mapped structure.

I am wondering what is the motivation to go for memory mapped structures for such control operations.

I can fully understand why data plane related fields should be placed on MMIO structures. However for control, memory mapped commands are:
1. More constraining for the device implementor and thus not scalable. MMIO direct access implies on-die resources to be allocated. You can see as example the IMS section on Scalable IOV spec[1] that follows this exact design
2. Hard to maintain - each new command may add new MMIO fields, making the device BAR complex.
3. Implies a non-uniform design - some commands are memory mapped, some commands are VQ based. How do we provide the guiding rules to decide? Isn't it simpler to have a single i/f for all the control?

[1]
https://www.intel.com/content/www/us/en/developer/articles/technical/introducing-intel-scalable-io-virtualization.html

#31 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Michael S. Tsirkin
Quoted 24 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Thursday, January 13, 2022 10:56 PM

Quoted 9 lines · Max Gurtovoy
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Max Gurtovoy

These new features are parallel to VIRTIO_F_INDIRECT_DESC and VIRTIO_F_IN_ORDER. Some devices might support these features only for admin virtqueues and some might support them for both admin virtqueues and request virtqueues or only for non-admin virtqueues. Some optimization can be made for each type of virtqueue, thus we separate these features for the different virtqueue

types.

Quoted 9 lines
Quoted 8 lines
Quoted 3 lines

That seems vague as motivation.
Why do we need to optimize admin queues? Aren't they fundamentally a control path feature?
Why would we want to special-case these features specifically? Should we allow control of features per VQ generally?

Quoted 4 lines
Quoted 2 lines

We would like to allow executing admins commands out of order and IO requests in order for efficiency.

It's a control queue. Why do we worry?

It is used to control/manage the resource of a VF which is deployed usually to a VM.
So higher the latency, higher the time it takes to deploy start the VM.
Hence, it is better to have this basic functionality in place, being useful beyond MSI-X config.
It is not functionally must. But riding AQ command ordering on VIRTIO_F_IN_ORDER for now and later on driving based on new field requires dual handling. Better to start with its AQ's own ordering and one scheme.

Quoted 7 lines
Quoted 4 lines

And also the other way around.

what exactly does this mean?

IO commands out of order (for say block device), but AQ commands in order.
May be AQ command execution can be always treated as out of order, even when VIRTIO_F_IN_ORDER is negotiated. This way it will be even more simpler design for driver and device.

Quoted 9 lines
Quoted 1 line

IO cmds and admin cmds have different considerations in many cases.

That's still pretty vague. so do other types of VQ, such as RX/TX.

E.g. I can see how a hardware vendor might want to avoid supporting indirect with RX for virtio net with mergeable buffers, but still support it for TX.

I can vaguely see the usefulness of VIRTIO_F_ADMIN_VQ_IN_ORDER.

I agree. It only helps driver to ensure that AQ commands are processed in order, so it doesn't need to serialize it. But yes, driver can always serialize it if needed when AQ is always out of order.
I think we should word it that AQ is always out of order.

Quoted 5 lines

I think you want to reorder admin commands dealing with unrelated VFs but keep io vqs in order for speed.
Just guessing, you should spell the real motivation out. However, I think a better way to do that is with finalizing the VIRTIO_F_PARTIAL_ORDER proposal from august.

I read the partial order proposal at [1].
It still appears IN_ORDER from driver POV.
So I am not sure if driver can complete AQ commands out of order. Can it?
I think data path needs more plumbing that just PARTIAL_ORDER flag, for descriptor processing differently on tx and rx side. Not sure merging AQ to it is useful, given that we agree that AQ should always behave as out of order from beginning.

[1] https://lists.oasis-open.org/archives/virtio-dev/202008/msg00001.html

Quoted 3 lines

Pls review and let me know. If there's finally a use for it I'll prioritize finalizing that idea.
Don't see much point in tweaking INDIRECT at all.

Common negotiation of INDIRECT on AQ and other queues forces data path also to handle that.
It is better to not impact the device to handler indirect descriptors on non AQ queues, just because AQ prefers to handle it. Often AQ and data path queues are not handled by same set of processing engines given they both do different tasks.

#93 lore raw

RE: [PATCH 4/5] virtio-net: add support for VIRTIO_F_ADMIN_VQ

In reply to Max Gurtovoy
Quoted 13 lines

From: Max Gurtovoy <[email protected]>
Sent: Sunday, January 16, 2022 3:18 PM

Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Max Gurtovoy

Set the relevant index in case of VIRTIO_F_ADMIN_VQ negotiation.

So admin VQ # is only known when all features are negotiated.

Quoted 15 lines

No. The driver should see if VIRTIO_NET_F_CTRL_VQ/VIRTIO_F_ADMIN_VQ are set by the device.

Negotiation is not a must.

Lets say CTRL_VQ is supported by the device and driver A would like to use it and driver B wouldn't like to use it - in both cases the admiq VQ # would be 2N
+ 1.

Quoted 6 lines

Which is quite annoying if hypervisor wants to partition things e.g. handling admin q in process and handling vqs by an external process or by hardware.

I think we can allow devices to set the VQ# for the admin queue instead. Would that work?

Number of MSI-X configuration and number of VQs config are two different, though it has strong correlation.
Configuring number of queues seems a very device specific configuration (even though num_queues is generic field in struct virtio_pci_common_cfg).

So num VQ configuration is a different command likely combined with other device specific config such as mac or rss or others.

#16 lore raw

RE: [PATCH 1/5] Add virtio Admin Virtqueue specification

In reply to Michael S. Tsirkin
Quoted 5 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Thursday, January 13, 2022 11:24 PM

Quoted 7 lines

We had an off-list meeting where I proposed addressing one device from another or grouping multiple devices as a more specific scope. That would be one way to address this.

Following this idea, all commands would then gain fields for addressing one device from another.

Can you please explain your idea more and a need for grouping? What do you want to group? VFs of parent pci device? How to refer to each VF within a group?

If you have notes of the off-list meeting, it will be useful for us to read through.

#4 lore raw

Re: [PATCH 1/5] Add virtio Admin Virtqueue specification

In reply to Max Gurtovoy
Quoted 47 lines · Max Gurtovoy
Quoted 31 lines · Michael S. Tsirkin
Quoted 30 lines · Max Gurtovoy

In one of the many use cases a user wants to manipulate features and configuration of the virtio devices regardless of the device type (net/block/console). Some of this configuration is generic enough. i.e Number of MSI-X vectors of a virtio PCI VF device. There is a need to do such features query and manipulation by its parent PCI PF.

Currently virtio specification defines control virtqueue to manipulate features and configuration of the device it operates on. However, control virtqueue commands are device type specific, which makes it very difficult to extend for device agnostic commands. Control virtqueue is also limited to follow in order completion for the device which negotiates VIRTIO_F_IN_ORDER feature. This feature limits the use of control virtqueue for feature manipulation in out of order manner for unrelated commands.

To support these requirements which overcome above two limitations in elegant way, this patch introduces a new admin virtqueue. Admin virtqueue will use the same command format for all types of virtio devices.

Subsequent patches make use of this admin virtqueue.

---
  admin-virtq.tex | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
  content.tex     |  9 +++++++--
  2 files changed, 56 insertions(+), 2 deletions(-)

create mode 100644 admin-virtq.tex

Quoted 13 lines

admin-virtq.tex line 5

Quoted 11 lines
admin-virtq.tex new file +5 -0
new file mode 100644
index 0000000..ad20f89
@@ -0,0 +1,49 @@
+\section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin Virtqueues}
+
+Admin virtqueue is used to send administrative commands to manipulate
+various features of the device which would not easily map into the
+configuration space.

IMHO this is too vague to be useful. E.g. I don't really see why would not commands specified in the next patch map to config space.

Quoted 1 line

Well I took this sentence from the current spec :)

Well in current spec it applies to things like MAC address filtering, which does not easily map into config space because number of MACs varies.

Quoted 10 lines
Quoted 6 lines

We had an off-list meeting where I proposed addressing one device from another or grouping multiple devices as a more specific scope. That would be one way to address this.

Are you suggestion a creation of a virtio subsystem or a virtio group definition ?

Quoted 7 lines

Devices will be part of this subsystem: one primary/manager device and many secondary/managed devices ?

Each subsystem will have a unique UUID and each device will have a unique vdev_id within this subsystem.

If this is the direction, I can prepare something..

I was merely saying that what is special about admin queue is that it allows controlling one device from another within some group. Or maybe that it allows grouping multiple devices.
*Not* that these are things that do not map to config space.

Let me give you another example, imagine that you want to handle pagefaults from device. Clearly a generic thing that does not map to config space. It could be a good candidate for the admin queue, however it would require that lots of buffers are pre-added to the queue. So it looks like it will beed another distinct fault queue. Further it is possible that you want to handle faults within guest, by the driver. In that case you do not want it in the admin queue since that is controlled by hypervisor, you want it in a separate queue controlled by driver.

I don't recall discussion about UUID so I can't really say what I think about that. Do we need a UUID? I'm not sure I understand why. It can't hurt to abstract things a bit so it's not all tied to PFs/VFs since we know we'll want subfunctions down the road, too, if that is what you mean.

Quoted 8 lines
Quoted 6 lines

Following this idea, all commands would then gain fields for addressing one device from another.

Not everything maps well to a queue. E.g. it would be great to have list of available commands in memory.

I'm not sure I agree. Why can't it map to a queue ?

You can map it to a queue, yes. But something static and read only such as list of commands maps well to config space. And it's not controlling one device from another, so does not really seem to belong in the admin queue.

Quoted 5 lines
Quoted 3 lines

Figuring out max vectors also looks like a good
example for memory and not through a command.

Any explanation why is it looks good ? or better ?

why is memory easier to operate than a VQ?
It's much simpler and so less error prone. you can have multiple actors read such a field at the same time without races, so e.g. there could be a sysfs attribute that reads from device on each access, and not special error handling is needed.

Quoted 83 lines
Quoted 83 lines

VQ # of the admin VQ could also be made more discoverable. How about an SRIOV capability describing this stuff then?

Quoted 33 lines
admin-virtq.tex new file +33 -0
+Use of Admin virtqueue is negotiated by the VIRTIO_F_ADMIN_VQ
+feature bit.
+
+Admin virtqueue index may vary among different device types.
+
+The Admin command set defines the commands that may be issued only to the admin
+virtqueue. Each virtio device that advertises the VIRTIO_F_ADMIN_VQ feature, MUST
+support all the mandatory admin commands. A device MAY support also one or more
+optional admin commands. All commands are of the following form:
+
+\begin{lstlisting}
+struct virtio_admin_cmd {
+        /* Device-readable part */
+        u8 command;
+        u8 command-specific-data[];
+
+        /* Device-writable part */
+        u8 status;
+        u8 command-specific-result[];
+};
+
+/* status values */
+#define VIRTIO_ADMIN_STATUS_OK 0
+#define VIRTIO_ADMIN_STATUS_ERR 1
+#define VIRTIO_ADMIN_STATUS_COMMAND_UNSUPPORTED 2
+\end{lstlisting}
+
+The \field{command} and \field{command-specific-data} are
+set by the driver, and the device sets the \field{status} and the
+\field{command-specific-result}, if needed.
+
+The following table describes the Admin command set:
+

admin-virtq.tex line 49

Quoted 10 lines
admin-virtq.tex new file +10 -0
+\begin{tabular}{|l|l|l|l|}
+\hline
+Opcode (bits) & Opcode (hex) & Command & M/O \\
+\hline \hline
+ -  & 00h - 7Fh   & Generic admin cmds    & -  \\
+\hline
+ -  & 80h - FFh   & Reserved    & - \\
+\hline
+\end{tabular}
+

Add conformance clauses pls. If this section is too generic to have any then this functionality is too generic to be useful ;)

Quoted 31 lines
content.tex +7 -2
index 32de668..c524fab 100644
@@ -99,10 +99,10 @@ \section{Feature Bits}\label{sec:Basic Facilities of a Virtio Device / Feature B
  \begin{description}
  \item[0 to 23] Feature bits for the specific device type
-\item[24 to 40] Feature bits reserved for extensions to the queue and
+\item[24 to 41] Feature bits reserved for extensions to the queue and
    feature negotiation mechanisms
-\item[41 and above] Feature bits reserved for future extensions.
+\item[42 and above] Feature bits reserved for future extensions.
  \end{description}
  \begin{note}
@@ -449,6 +449,8 @@ \section{Exporting Objects}\label{sec:Basic Facilities of a Virtio Device / Expo
  types. It is RECOMMENDED that devices generate version 4
  UUIDs as specified by \hyperref[intro:rfc4122]{[RFC4122]}.
+\input{admin-virtq.tex}
+
  \chapter{General Initialization And Device Operation}\label{sec:General Initialization And Device Operation}
  We start with an overview of device initialization, then expand on the
@@ -6847,6 +6849,9 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
    that the driver can reset a queue individually.
    See \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Reset}.
+  \item[VIRTIO_F_ADMIN_VQ (41)] This feature indicates that
+  the device supports administration virtqueue negotiation.
+
  \end{description}
  \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
Signature · 1 line
2.21.0
#109 lore raw
In reply to Shahaf Shuler
Quoted 38 lines · Shahaf Shuler

Thursday, January 13, 2022 8:32 PM, Michael S. Tsirkin:

Quoted 31 lines

Subject: Re: [PATCH v1 0/5] VIRTIO: Provision maximum MSI-X vectors for a VF

Quoted 19 lines · Max Gurtovoy

Hi,

In a PCI SR-IOV configuration, MSI-X vectors of the device is precious device resource. Hence making efficient use of it based on the use case that aligns to the VM configuration is desired for best system performance.

For example, today's static assignment of the amount of MSI-X vectors doesn't allow sophisticated utilization of resources.

A typical cloud provider SR-IOV use case is to create many VFs for use by guest VMs. Each VM might have a different purpose and different amount of resources accordingly (e.g. number of CPUs). A common driver usage of device's MSI-X vectors is proportional to the number of CPUs in the VM. Since the system administrator might know the amount of CPUs in the requested VM, he can also configure the VF's MSI-X vectors amount proportional to the number of CPUs in the VM. In this way, the utilization of the physical hardware will be improved.

Quoted 7 lines

Today we have some operating systems that support provisioning MSI-X vectors for PCI VFs.

Update the specification to have a method to change the number of MSI-X vectors supported by a VF using the PF admin virtqueue interface. For that, create a generic infrastructure for managing PCI resources of the managed VF by its parent PF.

Quoted 5 lines

Can you describe in the cover letter or the commit log of the admin VQ patch the motivation for using a VQ and not memory mapped space for this capability?
In fact I feel at least some commands would be better replaced with a memory mapped structure.

Quoted 3 lines

I am wondering what is the motivation to go for memory mapped structures for such control operations.

I can fully understand why data plane related fields should be placed on MMIO structures.

Actually, data plane is usually in a VQ for us, since MMIO accesses trigger VM exits.

Quoted 2 lines

However for control, memory mapped commands are:
1. More constraining for the device implementor and thus not scalable. MMIO direct access implies on-die resources to be allocated. You can see as example the IMS section on Scalable IOV spec[1] that follows this exact design

Oh it's a PCIe thing, right? Read can not depend on another read? So this is one of the reasons we don't put big structures in MMIO. But a couple of bytes is really no big deal IMHO.

Quoted 1 line

2. Hard to maintain - each new command may add new MMIO fields, making the device BAR complex.

Well actually we have very nice APIs to handle dependency between memory and feature bits. It's much harder to abstract away VQ commands, we don't have anything uniform for that.

Quoted 3 lines

3. Implies a non-uniform design - some commands are memory mapped, some commands are VQ based. How do we provide the guiding rules to decide? Isn't it simpler to have a single i/f for all the control?

newdevice.tex has some guiding principles, see "What Device Configuration Space Layout?".

But yes, if the answer is "commands A,B,C do not fit in config space, we placed commands D,E in a VQ for consitency" then that is an ok answer, but it's something to be mentioned in the commit log.

Quoted 3 lines

[1]
https://www.intel.com/content/www/us/en/developer/articles/technical/introducing-intel-scalable-io-virtualization.html

config space is generally more robust, requires less code on both host and guest side.

#17 lore raw

Re: [PATCH 1/5] Add virtio Admin Virtqueue specification

In reply to Parav Pandit
Quoted 9 lines · Parav Pandit
Quoted 9 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Thursday, January 13, 2022 11:24 PM

We had an off-list meeting where I proposed addressing one device from another or grouping multiple devices as a more specific scope. That would be one way to address this.

Quoted 6 lines
Quoted 3 lines

Following this idea, all commands would then gain fields for addressing one device from another.

Can you please explain your idea more and a need for grouping? What do you want to group? VFs of parent pci device? How to refer to each VF within a group?

So for example, VFs of a PF are a group right? And they are all controlled by a PF.

I can think of setups like nesting where we might want to create a group of VFs and pass them to L1, one of the VFs to act as an admin for the reset of them for purposes of L2. subfunctions with PASID etc are another example. I am not asking you to add such mechanisms straight away but the current proposal kind of obscures this to the point where I don't see how would we extend it with these things down the road.

Quoted 1 line

If you have notes of the off-list meeting, it will be useful for us to read through.

Sorry didn't take notes.

Signature · 1 line
MST
#32 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Parav Pandit
Quoted 24 lines · Parav Pandit
Quoted 24 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Thursday, January 13, 2022 10:56 PM

Quoted 9 lines · Max Gurtovoy
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Max Gurtovoy

These new features are parallel to VIRTIO_F_INDIRECT_DESC and VIRTIO_F_IN_ORDER. Some devices might support these features only for admin virtqueues and some might support them for both admin virtqueues and request virtqueues or only for non-admin virtqueues. Some optimization can be made for each type of virtqueue, thus we separate these features for the different virtqueue

types.

Quoted 9 lines
Quoted 8 lines
Quoted 3 lines

That seems vague as motivation.
Why do we need to optimize admin queues? Aren't they fundamentally a control path feature?
Why would we want to special-case these features specifically? Should we allow control of features per VQ generally?

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

We would like to allow executing admins commands out of order and IO requests in order for efficiency.

It's a control queue. Why do we worry?

It is used to control/manage the resource of a VF which is deployed usually to a VM. So higher the latency, higher the time it takes to deploy start the VM.

What are the savings here, in real terms? Boot times for smallest VMs are in 10s of milliseconds. Is reordering of a queue somehow going to save more than microseconds?

Quoted 3 lines

Hence, it is better to have this basic functionality in place, being useful beyond MSI-X config.
It is not functionally must. But riding AQ command ordering on VIRTIO_F_IN_ORDER for now and later on driving based on new field requires dual handling. Better to start with its AQ's own ordering and one scheme.

Sorry I'm still scratching my head.

Quoted 24 lines
Quoted 7 lines
Quoted 4 lines

And also the other way around.

what exactly does this mean?

IO commands out of order (for say block device), but AQ commands in order.
May be AQ command execution can be always treated as out of order, even when VIRTIO_F_IN_ORDER is negotiated. This way it will be even more simpler design for driver and device.

Quoted 9 lines
Quoted 1 line

IO cmds and admin cmds have different considerations in many cases.

That's still pretty vague. so do other types of VQ, such as RX/TX.

E.g. I can see how a hardware vendor might want to avoid supporting indirect with RX for virtio net with mergeable buffers, but still support it for TX.

I can vaguely see the usefulness of VIRTIO_F_ADMIN_VQ_IN_ORDER.

I agree. It only helps driver to ensure that AQ commands are processed in order, so it doesn't need to serialize it. But yes, driver can always serialize it if needed when AQ is always out of order.
I think we should word it that AQ is always out of order.

Quoted 8 lines
Quoted 5 lines

I think you want to reorder admin commands dealing with unrelated VFs but keep io vqs in order for speed.
Just guessing, you should spell the real motivation out. However, I think a better way to do that is with finalizing the VIRTIO_F_PARTIAL_ORDER proposal from august.

I read the partial order proposal at [1].
It still appears IN_ORDER from driver POV.
So I am not sure if driver can complete AQ commands out of order. Can it?

complete commands == use buffers?
drivers do not use buffers.

Quoted 4 lines

I think data path needs more plumbing that just PARTIAL_ORDER flag, for descriptor processing differently on tx and rx side. Not sure merging AQ to it is useful, given that we agree that AQ should always behave as out of order from beginning.

[1] https://lists.oasis-open.org/archives/virtio-dev/202008/msg00001.html

You mean *device*. Driver does not control the order.
The point of PARTIAL_ORDER is basically that some
descriptors are in order some out of order and its up to device. So it is even finer resolution.

Quoted 4 lines
Quoted 3 lines

Pls review and let me know. If there's finally a use for it I'll prioritize finalizing that idea.
Don't see much point in tweaking INDIRECT at all.

Common negotiation of INDIRECT on AQ and other queues forces data path also to handle that.

I don't see why admin queue needs indirect descriptors.

Quoted 2 lines

It is better to not impact the device to handler indirect descriptors on non AQ queues, just because AQ prefers to handle it. Often AQ and data path queues are not handled by same set of processing engines given they both do different tasks.

so for example, many guests want to use indirect for tx but not for rx. if you are worrying about things like that, maybe a per-vq control over indirect support makes sense.
adding complexity like that should really be much better motivated, and maybe have some PoC code or back of the napkin math showing the expected gains.

Signature · 1 line
MST
#94 lore raw

Re: [PATCH 4/5] virtio-net: add support for VIRTIO_F_ADMIN_VQ

In reply to Parav Pandit
Quoted 22 lines · Parav Pandit
Quoted 22 lines

From: Max Gurtovoy <[email protected]>
Sent: Sunday, January 16, 2022 3:18 PM

Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Max Gurtovoy

Set the relevant index in case of VIRTIO_F_ADMIN_VQ negotiation.

So admin VQ # is only known when all features are negotiated.

No. The driver should see if VIRTIO_NET_F_CTRL_VQ/VIRTIO_F_ADMIN_VQ are set by the device.

Negotiation is not a must.

Lets say CTRL_VQ is supported by the device and driver A would like to use it and driver B wouldn't like to use it - in both cases the admiq VQ # would be 2N
+ 1.

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

Which is quite annoying if hypervisor wants to partition things e.g. handling admin q in process and handling vqs by an external process or by hardware.

I think we can allow devices to set the VQ# for the admin queue instead. Would that work?

Number of MSI-X configuration and number of VQs config are two different,

I was talking about the number of the VQ used for admin commands. Not about the number of VQs.

Quoted 4 lines

though it has strong correlation.
Configuring number of queues seems a very device specific configuration (even though num_queues is generic field in struct virtio_pci_common_cfg).

So num VQ configuration is a different command likely combined with other device specific config such as mac or rss or others.

I was not talking about that at all, but since you mention that, to me it looks like something that many device types can support. It's not necessarily rss related, MQ config would benefit too, so I am not sure why not have a command for controlling number of queues. Looks like it could quite be generic.

Since current guests only support two modes: a vector per VQ and a shared vector for all VQs, it follows that it is important when configuring vectors per VF to also configure VQs per VF. This makes me wonder whether ability to configure vectors per VF in isolation without ability to configure or at least query VQs per VF even has value.

Signature · 1 line
MST
#95 lore raw

Re: [PATCH 4/5] virtio-net: add support for VIRTIO_F_ADMIN_VQ

Quoted 42 lines · Michael S. Tsirkin
Quoted 20 lines · Parav Pandit
Quoted 20 lines

From: Max Gurtovoy <[email protected]>
Sent: Sunday, January 16, 2022 3:18 PM

Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Max Gurtovoy

Set the relevant index in case of VIRTIO_F_ADMIN_VQ negotiation.

So admin VQ # is only known when all features are negotiated.

No. The driver should see if VIRTIO_NET_F_CTRL_VQ/VIRTIO_F_ADMIN_VQ are set by the device.

Negotiation is not a must.

Lets say CTRL_VQ is supported by the device and driver A would like to use it and driver B wouldn't like to use it - in both cases the admiq VQ # would be 2N
+ 1.

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

Which is quite annoying if hypervisor wants to partition things e.g. handling admin q in process and handling vqs by an external process or by hardware.

I think we can allow devices to set the VQ# for the admin queue instead. Would that work?

Number of MSI-X configuration and number of VQs config are two different,

I was talking about the number of the VQ used for admin commands. Not about the number of VQs.

Quoted 4 lines

though it has strong correlation.
Configuring number of queues seems a very device specific configuration (even though num_queues is generic field in struct virtio_pci_common_cfg).

So num VQ configuration is a different command likely combined with other device specific config such as mac or rss or others.

I was not talking about that at all, but since you mention that, to me it looks like something that many device types can support. It's not necessarily rss related, MQ config would benefit too, so I am not sure why not have a command for controlling number of queues. Looks like it could quite be generic.

Quoted 6 lines

Since current guests only support two modes: a vector per VQ and a shared vector for all VQs, it follows that it is important when configuring vectors per VF to also configure VQs per VF. This makes me wonder whether ability to configure vectors per VF in isolation without ability to configure or at least query VQs per VF even has value.

So I had some thought in the past, it looks to me we need a generic provision interface that contains all the necessary attributes:

1) #queues
2) device_features
3) #msi_vectors
4) device specific configurations

It could be either an admin virtqueue interface[1] or a dedicated capability[2], (the latter seems easier).

Thanks

[1] https://lists.oasis-open.org/archives/virtio-comment/202108/msg00025.html
[2] https://lists.oasis-open.org/archives/virtio-comment/202108/msg00136.html

Quoted 2 lines
#5 lore raw

RE: [PATCH 1/5] Add virtio Admin Virtqueue specification

In reply to Michael S. Tsirkin
Quoted 12 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 3:01 AM

Quoted 6 lines · Max Gurtovoy
Quoted 5 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+Admin virtqueue is used to send administrative commands to
+manipulate various features of the device which would not easily
+map into the configuration space.

IMHO this is too vague to be useful. E.g. I don't really see why would not commands specified in the next patch map to config space.

Quoted 4 lines
Quoted 1 line

Well I took this sentence from the current spec :)

Well in current spec it applies to things like MAC address filtering, which does not easily map into config space because number of MACs varies.

It doesn't well map to the config space for very primary reason that that it is read+write access that driver should be able to in async manner. Yes, we will improve this part of the commit log to described that doing via AQ enables driver to not get blocked by previous outstanding command.

Quoted 25 lines
Quoted 12 lines
Quoted 8 lines

We had an off-list meeting where I proposed addressing one device from another or grouping multiple devices as a more specific scope. That would be one way to address this.

Are you suggestion a creation of a virtio subsystem or a virtio group definition ?

Quoted 7 lines

Devices will be part of this subsystem: one primary/manager device and many secondary/managed devices ?

Each subsystem will have a unique UUID and each device will have a unique vdev_id within this subsystem.

If this is the direction, I can prepare something..

I was merely saying that what is special about admin queue is that it allows controlling one device from another within some group.
Or maybe that it allows grouping multiple devices.
*Not* that these are things that do not map to config space.

Quoted 5 lines

Let me give you another example, imagine that you want to handle pagefaults from device. Clearly a generic thing that does not map to config space. It could be a good candidate for the admin queue, however it would require that lots of buffers are pre-added to the queue. So it looks like it will beed another distinct fault queue.

Right page fault queue is async queue located in hv and/or guest more like net device rq. AQ is serving request-response queue.
Page fault queue likely needed multiple to have any reasonable bw, per cpu is one option.

Quoted 5 lines

Further it is possible that you want to handle faults
within guest, by the driver. In that case you do not want it in the admin queue since that is controlled by hypervisor, you want it in a separate queue controlled by driver.

Yes. so it is better to not merge page fault queue with admin queue.

Quoted 6 lines

I don't recall discussion about UUID so I can't really say what I think about that. Do we need a UUID? I'm not sure I understand why.
It can't hurt to abstract things a bit so it's not all tied to PFs/VFs since we know we'll want subfunctions down the road, too, if that is what you mean.

I still didn't find any reason in the discussion to find out why grouping device is needed.
Current AQ proposal implicitly indicates that VFs of a PF are managed by its parent PF.
And for some reason this work by one of the VF, this role assignment can be certainly a new command on AQ as group command or some other command.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Following this idea, all commands would then gain fields for addressing one device from another.

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

Not everything maps well to a queue. E.g. it would be great to have list of available commands in memory.

I'm not sure I agree. Why can't it map to a queue ?

You can map it to a queue, yes. But something static and read only such as list of commands maps well to config space. And it's not controlling one device from another, so does not really seem to belong in the admin queue.

Aq serves the writing device config too in patch-5 in this patchset.

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

Figuring out max vectors also looks like a good example for memory and not through a command.

Quoted 8 lines
Quoted 1 line

Any explanation why is it looks good ? or better ?

why is memory easier to operate than a VQ?
It's much simpler and so less error prone. you can have multiple actors read such a field at the same time without races, so e.g. there could be a sysfs attribute that reads from device on each access, and not special error handling is needed.

Writing fields is inherent part of the aq without getting blocked on previous writes. I see you acked that AQ is fine in cover letter patch as below, so we are sync on the motivation now. Yes, will update the commit log as you suggested.

" if the answer is "commands A,B,C do not fit in config space, we placed commands D,E in a VQ for consistency"
then that is an ok answer, but it's something to be mentioned in the commit log"

#18 lore raw

RE: [PATCH 1/5] Add virtio Admin Virtqueue specification

In reply to Michael S. Tsirkin
Quoted 22 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 3:33 AM

Quoted 9 lines · Parav Pandit
Quoted 9 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Thursday, January 13, 2022 11:24 PM

We had an off-list meeting where I proposed addressing one device from another or grouping multiple devices as a more specific scope. That would be one way to address this.

Quoted 6 lines
Quoted 3 lines

Following this idea, all commands would then gain fields for addressing one device from another.

Can you please explain your idea more and a need for grouping? What do you want to group? VFs of parent pci device? How to refer to each VF within a group?

Quoted 6 lines

So for example, VFs of a PF are a group right? And they are all controlled by a PF.

I can think of setups like nesting where we might want to create a group of VFs and pass them to L1, one of the VFs to act as an admin for the reset of them for purposes of L2. subfunctions with PASID etc are another example.

Subfunctions with PASID can be similarly managed by extending device identification and its MSIX/IMS vector details. May be vf_number should be put in the union as,

union device_id {
struct pci_vf vf_id; /* current */
struct pci_sf sf_id; /* future */
};

So that they both can use command opcode.

Quoted 5 lines

I am not
asking you to add such mechanisms straight away but the current proposal kind of obscures this to the point where I don't see how would we extend it with these things down the road.

Which part in specific make it obscure? New device type can be identifiable by above union.

May be a better structure would be in patch-5 is:
Something like below,

struct virtio_admin_pci_virt_property_set {
	enum virtio_device_identifier_type type; /* pci pf, pci vf, subfunction */
	union virtio_device_identifier {
		struct virtio_pci_dev_id pf_vf; /* current */
		struct virtio_subfunction sf; /* future */
	};
	enum virtio_interrupt_type interrupt_type; /* msix, ims=device specific, intx, something else */
	union virtio_interrupt_config {
		struct virtio_pci_msix_config msix_config;
	};
};
struct virtio_pci_interrupt_config {
	le16 msix_count;
};
#33 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Michael S. Tsirkin
Quoted 5 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 3:44 AM

Quoted 9 lines
Quoted 2 lines
Quoted 1 line

It's a control queue. Why do we worry?

It is used to control/manage the resource of a VF which is deployed usually

to a VM.

Quoted 1 line

So higher the latency, higher the time it takes to deploy start the VM.

What are the savings here, in real terms? Boot times for smallest VMs are in 10s of milliseconds. Is reordering of a queue somehow going to save more than microseconds?

It is probably better not to pick on a specific vendor implementation.
But for real numbers, I see that an implementation takes 54usec to 500 usec range for simple configuration.

It is better to not small VM 4 vector configuration to take longer because there was previous AQ command for 64 vectors.

Quoted 8 lines
Quoted 1 line

Hence, it is better to have this basic functionality in place, being useful

beyond MSI-X config.

Quoted 1 line

It is not functionally must. But riding AQ command ordering on

VIRTIO_F_IN_ORDER for now and later on driving based on new field requires dual handling.

Quoted 1 line

Better to start with its AQ's own ordering and one scheme.

Sorry I'm still scratching my head.

if (DEV.IN_ORDER_NEGOTIATED /*current */ ||

    AQ.IN_ORDERED_NEGOTIATED /* new */) {
	/* handle AQ descriptors in-order way */
} else { 
	/* handle AQ desc out-of order way */
}

By always doing AQ commands out of order, we simplify the driver and device to avoid in-order execution.

Quoted 31 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

And also the other way around.

what exactly does this mean?

IO commands out of order (for say block device), but AQ commands in order. May be AQ command execution can be always treated as out of order, even

when VIRTIO_F_IN_ORDER is negotiated.

Quoted 8 lines

This way it will be even more simpler design for driver and device.

Quoted 6 lines
Quoted 1 line

IO cmds and admin cmds have different considerations in many cases.

That's still pretty vague. so do other types of VQ, such as RX/TX.

E.g. I can see how a hardware vendor might want to avoid supporting indirect with RX for virtio net with mergeable buffers, but still support it for

TX.

Quoted 4 lines
Quoted 3 lines

I can vaguely see the usefulness of VIRTIO_F_ADMIN_VQ_IN_ORDER.

I agree. It only helps driver to ensure that AQ commands are processed in

order, so it doesn't need to serialize it.

Quoted 1 line

But yes, driver can always serialize it if needed when AQ is always out of

order.

Quoted 7 lines

I think we should word it that AQ is always out of order.

Quoted 5 lines

I think you want to reorder admin commands dealing with unrelated VFs but keep io vqs in order for speed.
Just guessing, you should spell the real motivation out. However, I think a better way to do that is with finalizing the VIRTIO_F_PARTIAL_ORDER proposal from august.

Quoted 5 lines
Quoted 3 lines

I read the partial order proposal at [1].
It still appears IN_ORDER from driver POV.
So I am not sure if driver can complete AQ commands out of order. Can it?

complete commands == use buffers?

Complete descriptors out of order.
I used term command as AQ descriptor used commands. Will rephase.

Quoted 4 lines

drivers do not use buffers.

Quoted 1 line

I think data path needs more plumbing that just PARTIAL_ORDER flag, for

Quoted 8 lines

descriptor processing differently on tx and rx side.

Quoted 1 line

Not sure merging AQ to it is useful, given that we agree that AQ should

always behave as out of order from beginning.

Quoted 3 lines

[1]
https://lists.oasis-open.org/archives/virtio-dev/202008/msg00001.html

You mean *device*. Driver does not control the order.

Data path I meant device and driver both.
Driver doesn't control the order, but should be ready to handle used descriptors out of order when PARTIAL is negotiated.

Quoted 4 lines

The point of PARTIAL_ORDER is basically that some descriptors are in order some out of order and its up to device. So it is even finer resolution.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

Pls review and let me know. If there's finally a use for it I'll prioritize finalizing that idea.
Don't see much point in tweaking INDIRECT at all.

Common negotiation of INDIRECT on AQ and other queues forces data path

also to handle that.

I don't see why admin queue needs indirect descriptors.

Probably yes. the simple idea is, not to impose indirect descriptors on AQ because txq/rxq prefers to use it. Not that AQ needs it.
At the same time, you don't want AQ object in spec to be limited to always operate without indirect descriptor.

Quoted 11 lines
Quoted 1 line

It is better to not impact the device to handler indirect descriptors on non

AQ queues, just because AQ prefers to handle it.

Quoted 1 line

Often AQ and data path queues are not handled by same set of processing

engines given they both do different tasks.

so for example, many guests want to use indirect for tx but not for rx. if you are worrying about things like that, maybe a per-vq control over indirect support makes sense.
adding complexity like that should really be much better motivated, and maybe have some PoC code or back of the napkin math showing the expected gains.

I do not have gains handy for tx vs rx q. It was in your example of partial order page fault thread. So may be you can share those results and/or poc code?

The motivation for AQ is simple as I explained about, i.e. txq/rxq indirect descriptor capability should not be imposed on AQ.

#96 lore raw

Re: [PATCH 4/5] virtio-net: add support for VIRTIO_F_ADMIN_VQ

In reply to Jason Wang
Quoted 63 lines · Jason Wang
Quoted 42 lines · Michael S. Tsirkin
Quoted 20 lines · Parav Pandit
Quoted 20 lines

From: Max Gurtovoy <[email protected]>
Sent: Sunday, January 16, 2022 3:18 PM

Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Max Gurtovoy

Set the relevant index in case of VIRTIO_F_ADMIN_VQ negotiation.

So admin VQ # is only known when all features are negotiated.

No. The driver should see if VIRTIO_NET_F_CTRL_VQ/VIRTIO_F_ADMIN_VQ are set by the device.

Negotiation is not a must.

Lets say CTRL_VQ is supported by the device and driver A would like to use it and driver B wouldn't like to use it - in both cases the admiq VQ # would be 2N
+ 1.

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

Which is quite annoying if hypervisor wants to partition things e.g. handling admin q in process and handling vqs by an external process or by hardware.

I think we can allow devices to set the VQ# for the admin queue instead. Would that work?

Number of MSI-X configuration and number of VQs config are two different,

I was talking about the number of the VQ used for admin commands. Not about the number of VQs.

Quoted 4 lines

though it has strong correlation.
Configuring number of queues seems a very device specific configuration (even though num_queues is generic field in struct virtio_pci_common_cfg).

So num VQ configuration is a different command likely combined with other device specific config such as mac or rss or others.

I was not talking about that at all, but since you mention that, to me it looks like something that many device types can support. It's not necessarily rss related, MQ config would benefit too, so I am not sure why not have a command for controlling number of queues. Looks like it could quite be generic.

Quoted 6 lines

Since current guests only support two modes: a vector per VQ and a shared vector for all VQs, it follows that it is important when configuring vectors per VF to also configure VQs per VF. This makes me wonder whether ability to configure vectors per VF in isolation without ability to configure or at least query VQs per VF even has value.

So I had some thought in the past, it looks to me we need a generic provision interface that contains all the necessary attributes:

1) #queues
2) device_features
3) #msi_vectors
4) device specific configurations

It could be either an admin virtqueue interface[1] or a dedicated capability[2], (the latter seems easier).

Quoted 7 lines

Thanks

[1]
https://lists.oasis-open.org/archives/virtio-comment/202108/msg00025.html
[2]
https://lists.oasis-open.org/archives/virtio-comment/202108/msg00136.html

We also need
- something like injecting cvq commands to control rx mode from the admin device
- page fault / dirty page handling

these two seem to call for a vq.

Quoted 2 lines
Quoted 2 lines
#6 lore raw

Re: [PATCH 1/5] Add virtio Admin Virtqueue specification

In reply to Parav Pandit
Quoted 6 lines · Parav Pandit
Quoted 5 lines

I don't recall discussion about UUID so I can't really say what I think about that. Do we need a UUID? I'm not sure I understand why.
It can't hurt to abstract things a bit so it's not all tied to PFs/VFs since we know we'll want subfunctions down the road, too, if that is what you mean.

I still didn't find any reason in the discussion to find out why grouping device is needed.

VFs are already grouped with their PF. However we should spell this out as the motivation for the admin queue.

Quoted 14 lines

Current AQ proposal implicitly indicates that VFs of a PF are managed by its parent PF. And for some reason this work by one of the VF, this role assignment
can be certainly a new command on AQ as group command or some other command.

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

Following this idea, all commands would then gain fields for addressing one device from another.

Not everything maps well to a queue. E.g. it would be great to have list of available commands in memory.

Quoted 7 lines
Quoted 6 lines
Quoted 1 line

I'm not sure I agree. Why can't it map to a queue ?

You can map it to a queue, yes. But something static and read only such as list of commands maps well to config space. And it's not controlling one device from another, so does not really seem to belong in the admin queue.

Aq serves the writing device config too in patch-5 in this patchset.

List of available admin commands does not need to be written.

Quoted 18 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

Figuring out max vectors also looks like a good example for memory and not through a command.

Quoted 8 lines
Quoted 1 line

Any explanation why is it looks good ? or better ?

why is memory easier to operate than a VQ?
It's much simpler and so less error prone. you can have multiple actors read such a field at the same time without races, so e.g. there could be a sysfs attribute that reads from device on each access, and not special error handling is needed.

Writing fields is inherent part of the aq without getting blocked on previous writes. I see you acked that AQ is fine in cover letter patch as below, so we are sync on the motivation now. Yes, will update the commit log as you suggested.

" if the answer is "commands A,B,C do not fit in config space, we placed commands D,E in a VQ for consistency"
then that is an ok answer, but it's something to be mentioned in the commit log"

#34 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Parav Pandit
Quoted 10 lines · Parav Pandit
Quoted 10 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 3:44 AM

Quoted 2 lines
Quoted 1 line

It's a control queue. Why do we worry?

It is used to control/manage the resource of a VF which is deployed usually

to a VM.

Quoted 1 line

So higher the latency, higher the time it takes to deploy start the VM.

Quoted 8 lines
Quoted 4 lines

What are the savings here, in real terms? Boot times for smallest VMs are in 10s of milliseconds. Is reordering of a queue somehow going to save more than microseconds?

It is probably better not to pick on a specific vendor implementation.
But for real numbers, I see that an implementation takes 54usec to 500 usec range for simple configuration.

It is better to not small VM 4 vector configuration to take longer because there was previous AQ command for 64 vectors.

So virtio discovery on boot includes multiple of vmexits, each costs ~1000 cycles. And people do not seem to worry about it.
You want a compelling argument for working on performance of config. I frankly think it's not really useful but I especially think you should cut this out of the current proposal, it's too big as it is.

Quoted 9 lines
Quoted 8 lines
Quoted 1 line

Hence, it is better to have this basic functionality in place, being useful

beyond MSI-X config.

Quoted 1 line

It is not functionally must. But riding AQ command ordering on

VIRTIO_F_IN_ORDER for now and later on driving based on new field requires dual handling.

Quoted 1 line

Better to start with its AQ's own ordering and one scheme.

Sorry I'm still scratching my head.

Quoted 8 lines

if (DEV.IN_ORDER_NEGOTIATED /*current */ ||

    AQ.IN_ORDERED_NEGOTIATED /* new */) {
	/* handle AQ descriptors in-order way */
} else { 
	/* handle AQ desc out-of order way */
}

By always doing AQ commands out of order, we simplify the driver and device to avoid in-order execution.

No idea what this means. Needs much more motivational discussion, and more thought about using generic infrastructure.
How about making this a separate proposal?

Quoted 31 lines
Quoted 31 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

And also the other way around.

what exactly does this mean?

IO commands out of order (for say block device), but AQ commands in order. May be AQ command execution can be always treated as out of order, even

when VIRTIO_F_IN_ORDER is negotiated.

Quoted 8 lines

This way it will be even more simpler design for driver and device.

Quoted 6 lines
Quoted 1 line

IO cmds and admin cmds have different considerations in many cases.

That's still pretty vague. so do other types of VQ, such as RX/TX.

E.g. I can see how a hardware vendor might want to avoid supporting indirect with RX for virtio net with mergeable buffers, but still support it for

TX.

Quoted 4 lines
Quoted 3 lines

I can vaguely see the usefulness of VIRTIO_F_ADMIN_VQ_IN_ORDER.

I agree. It only helps driver to ensure that AQ commands are processed in

order, so it doesn't need to serialize it.

Quoted 1 line

But yes, driver can always serialize it if needed when AQ is always out of

order.

Quoted 7 lines

I think we should word it that AQ is always out of order.

Quoted 5 lines

I think you want to reorder admin commands dealing with unrelated VFs but keep io vqs in order for speed.
Just guessing, you should spell the real motivation out. However, I think a better way to do that is with finalizing the VIRTIO_F_PARTIAL_ORDER proposal from august.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I read the partial order proposal at [1].
It still appears IN_ORDER from driver POV.
So I am not sure if driver can complete AQ commands out of order. Can it?

complete commands == use buffers?

Complete descriptors out of order.
I used term command as AQ descriptor used commands. Will rephase.

So in that case just work on VIRTIO_F_PARTIAL_ORDER please. I think there's a way to make it work for your usecase.

Quoted 42 lines
Quoted 4 lines

drivers do not use buffers.

Quoted 1 line

I think data path needs more plumbing that just PARTIAL_ORDER flag, for

Quoted 8 lines

descriptor processing differently on tx and rx side.

Quoted 1 line

Not sure merging AQ to it is useful, given that we agree that AQ should

always behave as out of order from beginning.

Quoted 3 lines

[1]
https://lists.oasis-open.org/archives/virtio-dev/202008/msg00001.html

You mean *device*. Driver does not control the order.

Data path I meant device and driver both.
Driver doesn't control the order, but should be ready to handle used descriptors out of order when PARTIAL is negotiated.

Quoted 4 lines

The point of PARTIAL_ORDER is basically that some descriptors are in order some out of order and its up to device. So it is even finer resolution.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

Pls review and let me know. If there's finally a use for it I'll prioritize finalizing that idea.
Don't see much point in tweaking INDIRECT at all.

Common negotiation of INDIRECT on AQ and other queues forces data path

also to handle that.

I don't see why admin queue needs indirect descriptors.

Probably yes. the simple idea is, not to impose indirect descriptors on AQ because txq/rxq prefers to use it. Not that AQ needs it.
At the same time, you don't want AQ object in spec to be limited to always operate without indirect descriptor.

Quoted 11 lines
Quoted 1 line

It is better to not impact the device to handler indirect descriptors on non

AQ queues, just because AQ prefers to handle it.

Quoted 1 line

Often AQ and data path queues are not handled by same set of processing

engines given they both do different tasks.

so for example, many guests want to use indirect for tx but not for rx. if you are worrying about things like that, maybe a per-vq control over indirect support makes sense.
adding complexity like that should really be much better motivated, and maybe have some PoC code or back of the napkin math showing the expected gains.

Quoted 4 lines

I do not have gains handy for tx vs rx q. It was in your example of partial order page fault thread. So may be you can share those results and/or poc code?

The motivation for AQ is simple as I explained about, i.e. txq/rxq indirect descriptor capability should not be imposed on AQ.

If I were you I would defer this, the AQ patch is already too big.

Signature · 1 line
MST
#35 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 23 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 11:54 AM

Quoted 9 lines · Parav Pandit
Quoted 9 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 3:44 AM

Quoted 3 lines
Quoted 1 line

It's a control queue. Why do we worry?

It is used to control/manage the resource of a VF which is deployed usually

to a VM.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

So higher the latency, higher the time it takes to deploy start the VM.

What are the savings here, in real terms? Boot times for smallest VMs are in 10s of milliseconds. Is reordering of a queue somehow going to save more than microseconds?

It is probably better not to pick on a specific vendor implementation. But for real numbers, I see that an implementation takes 54usec to 500 usec

Quoted 7 lines

range for simple configuration.

Quoted 2 lines

It is better to not small VM 4 vector configuration to take longer because

there was previous AQ command for 64 vectors.

So virtio discovery on boot includes multiple of vmexits, each costs ~1000 cycles. And people do not seem to worry about it.

It is not the vector configuration by guest VM.
It is the AQ command that provisions number of msix vectors for the VF that takes tens to hundreds of usecs. These are the command in patch-5 in this proposal.

Quoted 4 lines

You want a compelling argument for working on performance of config.
I frankly think it's not really useful but I especially think you should cut this out of the current proposal, it's too big as it is.

Ok. We can do follow on proposal after AQ.
We already see need of out of order AQ in internal performance tests we are running. But fine, we can differ.

Quoted 15 lines
Quoted 15 lines
Quoted 9 lines
Quoted 2 lines

Hence, it is better to have this basic functionality in place, being useful

beyond MSI-X config.

Quoted 1 line

It is not functionally must. But riding AQ command ordering on

VIRTIO_F_IN_ORDER for now and later on driving based on new field requires dual handling.

Quoted 1 line

Better to start with its AQ's own ordering and one scheme.

Sorry I'm still scratching my head.

if (DEV.IN_ORDER_NEGOTIATED /*current */ ||

    AQ.IN_ORDERED_NEGOTIATED /* new */) {
	/* handle AQ descriptors in-order way */ } else {
	/* handle AQ desc out-of order way */ }
Quoted 7 lines
Quoted 1 line

By always doing AQ commands out of order, we simplify the driver and

device to avoid in-order execution.

No idea what this means. Needs much more motivational discussion, and more thought about using generic infrastructure.
How about making this a separate proposal?

Got it. Will drive it in follow on separate proposal.

Quoted 102 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

And also the other way around.

what exactly does this mean?

IO commands out of order (for say block device), but AQ commands in

order.

Quoted 24 lines
Quoted 24 lines
Quoted 2 lines

May be AQ command execution can be always treated as out of order, even

when VIRTIO_F_IN_ORDER is negotiated.

Quoted 9 lines

This way it will be even more simpler design for driver and device.

Quoted 7 lines
Quoted 1 line

IO cmds and admin cmds have different considerations in many cases.

That's still pretty vague. so do other types of VQ, such as RX/TX.

E.g. I can see how a hardware vendor might want to avoid supporting indirect with RX for virtio net with mergeable buffers, but still support it for

TX.

Quoted 5 lines
Quoted 3 lines

I can vaguely see the usefulness of VIRTIO_F_ADMIN_VQ_IN_ORDER.

I agree. It only helps driver to ensure that AQ commands are processed in

order, so it doesn't need to serialize it.

Quoted 2 lines

But yes, driver can always serialize it if needed when AQ is always out of

order.

Quoted 2 lines

I think we should word it that AQ is always out of order.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

I think you want to reorder admin commands dealing with unrelated VFs but keep io vqs in order for speed. Just guessing, you should spell the real motivation out. However, I think a better way to do that is with finalizing the VIRTIO_F_PARTIAL_ORDER proposal from august.

I read the partial order proposal at [1].
It still appears IN_ORDER from driver POV.
So I am not sure if driver can complete AQ commands out of order. Can

it?

Quoted 5 lines
Quoted 2 lines

complete commands == use buffers?

Complete descriptors out of order.
I used term command as AQ descriptor used commands. Will rephase.

So in that case just work on VIRTIO_F_PARTIAL_ORDER please. I think there's a way to make it work for your usecase.

Quoted 10 lines
Quoted 10 lines

drivers do not use buffers.

Quoted 2 lines

I think data path needs more plumbing that just PARTIAL_ORDER flag, for

descriptor processing differently on tx and rx side.

Quoted 2 lines

Not sure merging AQ to it is useful, given that we agree that AQ should

always behave as out of order from beginning.

Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

[1]
https://lists.oasis-open.org/archives/virtio-dev/202008/msg00001.h
tml

You mean *device*. Driver does not control the order.

Data path I meant device and driver both.
Driver doesn't control the order, but should be ready to handle used

descriptors out of order when PARTIAL is negotiated.

Quoted 8 lines
Quoted 8 lines

The point of PARTIAL_ORDER is basically that some descriptors are in order some out of order and its up to device. So it is even finer resolution.

Quoted 3 lines
Quoted 3 lines

Pls review and let me know. If there's finally a use for it I'll prioritize finalizing that idea.
Don't see much point in tweaking INDIRECT at all.

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

Common negotiation of INDIRECT on AQ and other queues forces data path

also to handle that.

I don't see why admin queue needs indirect descriptors.

Probably yes. the simple idea is, not to impose indirect descriptors on AQ

because txq/rxq prefers to use it.

Quoted 2 lines

Not that AQ needs it.
At the same time, you don't want AQ object in spec to be limited to always

operate without indirect descriptor.

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

It is better to not impact the device to handler indirect descriptors on non

AQ queues, just because AQ prefers to handle it.

Quoted 2 lines

Often AQ and data path queues are not handled by same set of processing

engines given they both do different tasks.

Quoted 7 lines
Quoted 6 lines

so for example, many guests want to use indirect for tx but not for rx. if you are worrying about things like that, maybe a per-vq control over indirect support makes sense.
adding complexity like that should really be much better motivated, and maybe have some PoC code or back of the napkin math showing the expected gains.

I do not have gains handy for tx vs rx q. It was in your example of partial

Quoted 8 lines

order page fault thread.

Quoted 3 lines

So may be you can share those results and/or poc code?

The motivation for AQ is simple as I explained about, i.e. txq/rxq indirect

descriptor capability should not be imposed on AQ.

If I were you I would defer this, the AQ patch is already too big.

o.k. we can differ.
But if you see on the other side, AQ always following INDIRECT_DESC feature bit, forces device implementation to support indirect descriptors. Isn't that make device implementation big from beginning, even though it may not be needed?

#36 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 25 lines · Parav Pandit
Quoted 25 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 11:54 AM

Quoted 9 lines · Parav Pandit
Quoted 9 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 3:44 AM

Quoted 3 lines
Quoted 1 line

It's a control queue. Why do we worry?

It is used to control/manage the resource of a VF which is deployed usually

to a VM.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

So higher the latency, higher the time it takes to deploy start the VM.

What are the savings here, in real terms? Boot times for smallest VMs are in 10s of milliseconds. Is reordering of a queue somehow going to save more than microseconds?

It is probably better not to pick on a specific vendor implementation. But for real numbers, I see that an implementation takes 54usec to 500 usec

range for simple configuration.

Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

It is better to not small VM 4 vector configuration to take longer because

there was previous AQ command for 64 vectors.

So virtio discovery on boot includes multiple of vmexits, each costs ~1000 cycles. And people do not seem to worry about it.

It is not the vector configuration by guest VM.
It is the AQ command that provisions number of msix vectors for the VF that takes tens to hundreds of usecs. These are the command in patch-5 in this proposal.

Hundreds of usecs is negligeable compared to VM boot time. Sorry I don't really see why we worry about indirect in that case.

Quoted 6 lines
Quoted 4 lines

You want a compelling argument for working on performance of config.
I frankly think it's not really useful but I especially think you should cut this out of the current proposal, it's too big as it is.

Ok. We can do follow on proposal after AQ.
We already see need of out of order AQ in internal performance tests we are running.

OK so first of all you can avoid declaring IN_ORDER. If you see that IN_ORDER improves performance for you so you need it, then look at PARTIAL_ORDER pls. And if that does not address your needs then let's discuss, I'd rather have a generic solution since the requirement does not seem to be specific to AQ.

Quoted 131 lines

But fine, we can differ.

Quoted 15 lines
Quoted 15 lines
Quoted 9 lines
Quoted 2 lines

Hence, it is better to have this basic functionality in place, being useful

beyond MSI-X config.

Quoted 1 line

It is not functionally must. But riding AQ command ordering on

VIRTIO_F_IN_ORDER for now and later on driving based on new field requires dual handling.

Quoted 1 line

Better to start with its AQ's own ordering and one scheme.

Sorry I'm still scratching my head.

if (DEV.IN_ORDER_NEGOTIATED /*current */ ||

    AQ.IN_ORDERED_NEGOTIATED /* new */) {
	/* handle AQ descriptors in-order way */ } else {
	/* handle AQ desc out-of order way */ }
Quoted 7 lines
Quoted 1 line

By always doing AQ commands out of order, we simplify the driver and

device to avoid in-order execution.

No idea what this means. Needs much more motivational discussion, and more thought about using generic infrastructure.
How about making this a separate proposal?

Got it. Will drive it in follow on separate proposal.

Quoted 105 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

And also the other way around.

what exactly does this mean?

IO commands out of order (for say block device), but AQ commands in

order.

Quoted 24 lines
Quoted 24 lines
Quoted 2 lines

May be AQ command execution can be always treated as out of order, even

when VIRTIO_F_IN_ORDER is negotiated.

Quoted 9 lines

This way it will be even more simpler design for driver and device.

Quoted 7 lines
Quoted 1 line

IO cmds and admin cmds have different considerations in many cases.

That's still pretty vague. so do other types of VQ, such as RX/TX.

E.g. I can see how a hardware vendor might want to avoid supporting indirect with RX for virtio net with mergeable buffers, but still support it for

TX.

Quoted 5 lines
Quoted 3 lines

I can vaguely see the usefulness of VIRTIO_F_ADMIN_VQ_IN_ORDER.

I agree. It only helps driver to ensure that AQ commands are processed in

order, so it doesn't need to serialize it.

Quoted 2 lines

But yes, driver can always serialize it if needed when AQ is always out of

order.

Quoted 2 lines

I think we should word it that AQ is always out of order.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

I think you want to reorder admin commands dealing with unrelated VFs but keep io vqs in order for speed. Just guessing, you should spell the real motivation out. However, I think a better way to do that is with finalizing the VIRTIO_F_PARTIAL_ORDER proposal from august.

I read the partial order proposal at [1].
It still appears IN_ORDER from driver POV.
So I am not sure if driver can complete AQ commands out of order. Can

it?

Quoted 5 lines
Quoted 2 lines

complete commands == use buffers?

Complete descriptors out of order.
I used term command as AQ descriptor used commands. Will rephase.

So in that case just work on VIRTIO_F_PARTIAL_ORDER please. I think there's a way to make it work for your usecase.

Quoted 10 lines
Quoted 10 lines

drivers do not use buffers.

Quoted 2 lines

I think data path needs more plumbing that just PARTIAL_ORDER flag, for

descriptor processing differently on tx and rx side.

Quoted 2 lines

Not sure merging AQ to it is useful, given that we agree that AQ should

always behave as out of order from beginning.

Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

[1]
https://lists.oasis-open.org/archives/virtio-dev/202008/msg00001.h
tml

You mean *device*. Driver does not control the order.

Data path I meant device and driver both.
Driver doesn't control the order, but should be ready to handle used

descriptors out of order when PARTIAL is negotiated.

Quoted 8 lines
Quoted 8 lines

The point of PARTIAL_ORDER is basically that some descriptors are in order some out of order and its up to device. So it is even finer resolution.

Quoted 3 lines
Quoted 3 lines

Pls review and let me know. If there's finally a use for it I'll prioritize finalizing that idea.
Don't see much point in tweaking INDIRECT at all.

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

Common negotiation of INDIRECT on AQ and other queues forces data path

also to handle that.

I don't see why admin queue needs indirect descriptors.

Probably yes. the simple idea is, not to impose indirect descriptors on AQ

because txq/rxq prefers to use it.

Quoted 2 lines

Not that AQ needs it.
At the same time, you don't want AQ object in spec to be limited to always

operate without indirect descriptor.

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

It is better to not impact the device to handler indirect descriptors on non

AQ queues, just because AQ prefers to handle it.

Quoted 2 lines

Often AQ and data path queues are not handled by same set of processing

engines given they both do different tasks.

Quoted 7 lines
Quoted 6 lines

so for example, many guests want to use indirect for tx but not for rx. if you are worrying about things like that, maybe a per-vq control over indirect support makes sense.
adding complexity like that should really be much better motivated, and maybe have some PoC code or back of the napkin math showing the expected gains.

I do not have gains handy for tx vs rx q. It was in your example of partial

order page fault thread.

Quoted 2 lines

So may be you can share those results and/or poc code?

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

The motivation for AQ is simple as I explained about, i.e. txq/rxq indirect

descriptor capability should not be imposed on AQ.

If I were you I would defer this, the AQ patch is already too big.

o.k. we can differ.
But if you see on the other side, AQ always following INDIRECT_DESC feature bit, forces device implementation to support indirect descriptors. Isn't that make device implementation big from beginning, even though it may not be needed?

The problem is not unique to AQ though. RX queues for virtio net have the same issue.
If it's there but not used you can punt it to a slow path in firmware was always our approach. If not, worth thinking of a generic solution.

Signature · 1 line
MST
#37 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 37 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 12:25 PM

Quoted 32 lines · Parav Pandit
Quoted 32 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 11:54 AM

Quoted 11 lines · Parav Pandit
Quoted 11 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 3:44 AM

Quoted 3 lines
Quoted 1 line

It's a control queue. Why do we worry?

It is used to control/manage the resource of a VF which is deployed usually

to a VM.

Quoted 1 line

So higher the latency, higher the time it takes to deploy start the VM.

Quoted 7 lines
Quoted 4 lines

What are the savings here, in real terms? Boot times for smallest VMs are in 10s of milliseconds. Is reordering of a queue somehow going to save more than microseconds?

It is probably better not to pick on a specific vendor implementation. But for real numbers, I see that an implementation takes 54usec to 500 usec

range for simple configuration.

Quoted 3 lines

It is better to not small VM 4 vector configuration to take longer because

there was previous AQ command for 64 vectors.

So virtio discovery on boot includes multiple of vmexits, each costs ~1000 cycles. And people do not seem to worry about it.

Quoted 9 lines
Quoted 2 lines

It is not the vector configuration by guest VM.
It is the AQ command that provisions number of msix vectors for the VF that

takes tens to hundreds of usecs.

Quoted 1 line

These are the command in patch-5 in this proposal.

Hundreds of usecs is negligeable compared to VM boot time. Sorry I don't really see why we worry about indirect in that case.

Ok. we will do incremental proposal after this for wider use case.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

You want a compelling argument for working on performance of config. I frankly think it's not really useful but I especially think you should cut this out of the current proposal, it's too big as it is.

Ok. We can do follow on proposal after AQ.
We already see need of out of order AQ in internal performance tests we are

running.

OK so first of all you can avoid declaring IN_ORDER.

This will force non IN_ORDER on other txq and rxq too that causes higher latency. But fine, initial implementation can start without it.

Quoted 3 lines

If you see that IN_ORDER
improves performance for you so you need it, then look at PARTIAL_ORDER pls.

Ok. will consider PARTIAL_ORDER more in future proposal.

Quoted 4 lines

And if that does not address your needs then let's discuss, I'd rather have a generic solution since the requirement does not seem to be specific to AQ.

Quoted 1 line

But fine, we can differ.

So far I gather below summary that needs to be addressed in v2.

1. Use AQ for msix query and config
2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues
3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds)
4. Improve documentation around msix config to link to sriov section of virtio spec
5. Describe error that if VF is bound to the device, admin commands targeting VF can fail, describe this error code

Did I miss anything?

Yet to receive your feedback on group, if/why is it needed and, why/if it must be in this proposal, what pieces prevents it do as follow-on.

Cornelia, Jason,
Can you please review current proposal as well before we revise v2?

#19 lore raw

Re: [PATCH 1/5] Add virtio Admin Virtqueue specification

In reply to Parav Pandit
Quoted 32 lines · Parav Pandit
Quoted 22 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 3:33 AM

Quoted 9 lines · Parav Pandit
Quoted 9 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Thursday, January 13, 2022 11:24 PM

We had an off-list meeting where I proposed addressing one device from another or grouping multiple devices as a more specific scope. That would be one way to address this.

Quoted 6 lines
Quoted 3 lines

Following this idea, all commands would then gain fields for addressing one device from another.

Can you please explain your idea more and a need for grouping? What do you want to group? VFs of parent pci device? How to refer to each VF within a group?

Quoted 6 lines

So for example, VFs of a PF are a group right? And they are all controlled by a PF.

I can think of setups like nesting where we might want to create a group of VFs and pass them to L1, one of the VFs to act as an admin for the reset of them for purposes of L2. subfunctions with PASID etc are another example.

Subfunctions with PASID can be similarly managed by extending device identification and its MSIX/IMS vector details. May be vf_number should be put in the union as,

Quoted 6 lines

union device_id {
struct pci_vf vf_id; /* current */
struct pci_sf sf_id; /* future */
};

So that they both can use command opcode.

device id is not a good name, but yes. However this is why I think we should have a slightly more generic terminology, and more space for these IDs, and then we'd have a specific binding for VFs.

Quoted 6 lines
Quoted 5 lines

I am not
asking you to add such mechanisms straight away but the current proposal kind of obscures this to the point where I don't see how would we extend it with these things down the road.

Which part in specific make it obscure?

just that the text is not generic. would be nicer if adding new types would involve only changing one or two places

Quoted 17 lines

New device type can be identifiable by above union.

May be a better structure would be in patch-5 is:
Something like below,

struct virtio_admin_pci_virt_property_set {
	enum virtio_device_identifier_type type; /* pci pf, pci vf, subfunction */
	union virtio_device_identifier {
		struct virtio_pci_dev_id pf_vf; /* current */
		struct virtio_subfunction sf; /* future */
	};
	enum virtio_interrupt_type interrupt_type; /* msix, ims=device specific, intx, something else */
	union virtio_interrupt_config {
		struct virtio_pci_msix_config msix_config;
	};
};
Quoted 3 lines
struct virtio_pci_interrupt_config {
	le16 msix_count;
};

you do not need a union straight away, Simply use something like this "device identifier" everywhere and then add some text explaining that currently it is a VF number and that admin device is a PF.

However we need better names, device ID is already used in the spec for enumeration/discovery. come up with something else please.

#38 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Parav Pandit
Quoted 7 lines · Parav Pandit

1. Use AQ for msix query and config
2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues
3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds)
4. Improve documentation around msix config to link to sriov section of virtio spec
5. Describe error that if VF is bound to the device, admin commands targeting VF can fail, describe this error code

Did I miss anything?

Better document in spec text just what is the scope for AQ.

Quoted 1 line

Yet to receive your feedback on group, if/why is it needed and, why/if it must be in this proposal, what pieces prevents it do as follow-on.

I think this is related to the subfunction usecase or other future usecase. In case of PF/VF grouping is implicit through the SRIOV capability. It would be nice to have things somewhat generic in most of the text though since we already know this will be needed. E.g. jason sent a proposal for commands to add/delete subfunctions, take a look at it, somehow AQ needs to be extendable to support that functionality too.

Quoted 2 lines

Cornelia, Jason,
Can you please review current proposal as well before we revise v2?

#54 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Parav Pandit
Quoted 1 line · Parav Pandit

Can you please review current proposal as well before we revise v2?

I think what you listed amounts to a significant rework and will make things easier to review. Not 100% sure you need more feedback at this point.

Signature · 1 line
MST
#20 lore raw

RE: [PATCH 1/5] Add virtio Admin Virtqueue specification

In reply to Michael S. Tsirkin
Quoted 14 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 12:38 PM

Quoted 1 line

Subfunctions with PASID can be similarly managed by extending device

identification and its MSIX/IMS vector details.

Quoted 7 lines

May be vf_number should be put in the union as,

union device_id {
struct pci_vf vf_id; /* current */
struct pci_sf sf_id; /* future */
};

Quoted 6 lines
Quoted 1 line

So that they both can use command opcode.

device id is not a good name, but yes. However this is why I think we should have a slightly more generic terminology, and more space for these IDs, and then we'd have a specific binding for VFs.

I couldn't think of better name for identifying a PCI VF. But yes have to think better name for sure.

Quoted 29 lines
Quoted 6 lines
Quoted 5 lines

I am not
asking you to add such mechanisms straight away but the current proposal kind of obscures this to the point where I don't see how would we extend it with these things down the road.

Which part in specific make it obscure?

just that the text is not generic. would be nicer if adding new types would involve only changing one or two places

Quoted 7 lines

New device type can be identifiable by above union.

May be a better structure would be in patch-5 is:
Something like below,

struct virtio_admin_pci_virt_property_set {
enum virtio_device_identifier_type type; /* pci pf, pci vf, subfunction

*/

Quoted 5 lines

union virtio_device_identifier {
struct virtio_pci_dev_id pf_vf; /* current */ struct virtio_subfunction sf; /* future */
};
enum virtio_interrupt_type interrupt_type; /* msix, ims=device

specific, intx, something else */

Quoted 5 lines
	union virtio_interrupt_config {
		struct virtio_pci_msix_config msix_config;
	};
};
Quoted 7 lines
Quoted 3 lines
struct virtio_pci_interrupt_config {
	le16 msix_count;
};

you do not need a union straight away, Simply use something like this "device identifier" everywhere and then add some text explaining that currently it is a VF number and that admin device is a PF.

Unless we reserve some bytes, I fail to see how can it be future compatible for unknown device id type for subfunction. pci_vf_number is very crisp for the pci device for a PCI VF specific command.
So I am ruling out arbitrary number of bytes reservation.
And split the command to two pieces.
1. command opcode
2. command content (pci vf specific). This will be different structure for subfunction or for non pci device

Would that be more elegant?

Quoted 3 lines

However we need better names, device ID is already used in the spec for enumeration/discovery. come up with something else please.

Yes.

#21 lore raw

Re: [PATCH 1/5] Add virtio Admin Virtqueue specification

Quoted 51 lines · Parav Pandit
Quoted 14 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 12:38 PM

Quoted 1 line

Subfunctions with PASID can be similarly managed by extending device

identification and its MSIX/IMS vector details.

Quoted 7 lines

May be vf_number should be put in the union as,

union device_id {
struct pci_vf vf_id; /* current */
struct pci_sf sf_id; /* future */
};

Quoted 6 lines
Quoted 1 line

So that they both can use command opcode.

device id is not a good name, but yes. However this is why I think we should have a slightly more generic terminology, and more space for these IDs, and then we'd have a specific binding for VFs.

I couldn't think of better name for identifying a PCI VF. But yes have to think better name for sure.

Quoted 29 lines
Quoted 6 lines
Quoted 5 lines

I am not
asking you to add such mechanisms straight away but the current proposal kind of obscures this to the point where I don't see how would we extend it with these things down the road.

Which part in specific make it obscure?

just that the text is not generic. would be nicer if adding new types would involve only changing one or two places

Quoted 7 lines

New device type can be identifiable by above union.

May be a better structure would be in patch-5 is:
Something like below,

struct virtio_admin_pci_virt_property_set {
enum virtio_device_identifier_type type; /* pci pf, pci vf, subfunction

*/

Quoted 5 lines

union virtio_device_identifier {
struct virtio_pci_dev_id pf_vf; /* current */ struct virtio_subfunction sf; /* future */
};
enum virtio_interrupt_type interrupt_type; /* msix, ims=device

specific, intx, something else */

Quoted 5 lines
	union virtio_interrupt_config {
		struct virtio_pci_msix_config msix_config;
	};
};
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
struct virtio_pci_interrupt_config {
	le16 msix_count;
};

you do not need a union straight away, Simply use something like this "device identifier" everywhere and then add some text explaining that currently it is a VF number and that admin device is a PF.

Unless we reserve some bytes, I fail to see how can it be future compatible for unknown device id type for subfunction.

So reserve some bytes then. 4 should be plenty.

Quoted 2 lines

pci_vf_number is very crisp for the pci device for a PCI VF specific command. So I am ruling out arbitrary number of bytes reservation.

we already know we'll need subfunctions. so I would say make it 4 bytes.

Quoted 5 lines

And split the command to two pieces.
1. command opcode
2. command content (pci vf specific). This will be different structure for subfunction or for non pci device

Would that be more elegant?

no idea about non pci. we do know about subfunctions so let us not pretend then are this unknown entity that are very hard to reason about, it's something that's just around the corner.

Quoted 4 lines
Quoted 3 lines

However we need better names, device ID is already used in the spec for enumeration/discovery. come up with something else please.

Yes.

#55 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Michael S. Tsirkin
Quoted 10 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 12:44 PM

Quoted 1 line · Parav Pandit

Can you please review current proposal as well before we revise v2?

I think what you listed amounts to a significant rework and will make things easier to review. Not 100% sure you need more feedback at this point.

With
(a) the motivation that Jason mentioned for config vqs, vectors etc,
(b) the msix config/query of this proposal
(c) your description to handle them in uniform way,
(d) understanding the scale inefficiency, on-die resources, multiple outstanding cmds discussion in the thread,

I would like to receive feedback that we all agree to configure these values via AQ.

Rest of the plumbing on AQ etc to address comments to complete in v2, once this looks ok.

#39 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Michael S. Tsirkin
Quoted 14 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 12:42 PM

Quoted 8 lines · Parav Pandit

1. Use AQ for msix query and config
2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues 3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds) 4. Improve documentation around msix config to link to sriov section of virtio spec 5. Describe error that if VF is bound to the device, admin commands targeting VF can fail, describe this error code

Quoted 4 lines
Quoted 1 line

Did I miss anything?

Better document in spec text just what is the scope for AQ.

Yes, will improve this spec.

Quoted 11 lines
Quoted 2 lines

Yet to receive your feedback on group, if/why is it needed and, why/if it must

be in this proposal, what pieces prevents it do as follow-on.

I think this is related to the subfunction usecase or other future usecase. In case of PF/VF grouping is implicit through the SRIOV capability. It would be nice to have things somewhat generic in most of the text though since we already know this will be needed.
E.g. jason sent a proposal for commands to add/delete subfunctions, take a look at it, somehow AQ needs to be extendable to support that functionality too.

I looked briefly to it. AQ can be used for such purpose. Current proposal adds only msix config piece. But more commands can be added in future.

What I wanted to check with you and other is, do we want command opcode to be 7-bit enough?
#127 is lot of admin commands. 😊
But given virtio spec diversity of transport and device types, I was thinking to keep it 15-bit for future proofing. What do you think?

An unrelated command to AQ in Jason's proposal [1] is about " The management driver MUST create a managed device by allocating". We see that creator of the subfunction is often not the only entity managing it.
They being same in new era finding less and less users.
So this piece needs more discussion whenever we address that.

[1] https://lists.oasis-open.org/archives/virtio-comment/202108/msg00136.html

#56 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Parav Pandit
Quoted 11 lines · Parav Pandit
Quoted 10 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 12:44 PM

Quoted 1 line · Parav Pandit

Can you please review current proposal as well before we revise v2?

I think what you listed amounts to a significant rework and will make things easier to review. Not 100% sure you need more feedback at this point.

Quoted 8 lines

With
(a) the motivation that Jason mentioned for config vqs, vectors etc,
(b) the msix config/query of this proposal
(c) your description to handle them in uniform way,
(d) understanding the scale inefficiency, on-die resources, multiple outstanding cmds discussion in the thread,

I would like to receive feedback that we all agree to configure these values via AQ. Rest of the plumbing on AQ etc to address comments to complete in v2, once this looks ok.

Go ahead and wait if you like, that was just my advice because personally if I see a mega-thread like this one on the list I just wait for the next version. Review time has to be viewed as more precious than developer time, otherwise things do not scale.

Or to put it more succinctly, iterating quickly is recipe for success.

Signature · 1 line
MST
#40 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Parav Pandit
Quoted 31 lines · Parav Pandit
Quoted 14 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 12:42 PM

Quoted 8 lines · Parav Pandit

1. Use AQ for msix query and config
2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues 3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds) 4. Improve documentation around msix config to link to sriov section of virtio spec 5. Describe error that if VF is bound to the device, admin commands targeting VF can fail, describe this error code

Quoted 4 lines
Quoted 1 line

Did I miss anything?

Better document in spec text just what is the scope for AQ.

Yes, will improve this spec.

Quoted 11 lines
Quoted 2 lines

Yet to receive your feedback on group, if/why is it needed and, why/if it must

be in this proposal, what pieces prevents it do as follow-on.

I think this is related to the subfunction usecase or other future usecase. In case of PF/VF grouping is implicit through the SRIOV capability. It would be nice to have things somewhat generic in most of the text though since we already know this will be needed.
E.g. jason sent a proposal for commands to add/delete subfunctions, take a look at it, somehow AQ needs to be extendable to support that functionality too.

Quoted 7 lines

I looked briefly to it. AQ can be used for such purpose. Current proposal adds only msix config piece. But more commands can be added in future.

What I wanted to check with you and other is, do we want command opcode to be 7-bit enough?
#127 is lot of admin commands. 😊
But given virtio spec diversity of transport and device types, I was thinking to keep it 15-bit for future proofing. What do you think?

I agree, we are not short on bits.

Quoted 2 lines

An unrelated command to AQ in Jason's proposal [1] is about " The management driver MUST create a managed device by allocating". We see that creator of the subfunction is often not the only entity managing it.

I think whoever does it can go through the main function driver.

Quoted 4 lines

They being same in new era finding less and less users. So this piece needs more discussion whenever we address that.

[1] https://lists.oasis-open.org/archives/virtio-comment/202108/msg00136.html

#7 lore raw

RE: [PATCH 1/5] Add virtio Admin Virtqueue specification

In reply to Michael S. Tsirkin
Quoted 11 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 11:47 AM

Quoted 1 line · Parav Pandit
Quoted 1 line

I don't recall discussion about UUID so I can't really say what I think about

that.

Quoted 3 lines
Quoted 3 lines

Do we need a UUID? I'm not sure I understand why.
It can't hurt to abstract things a bit so it's not all tied to PFs/VFs since we know we'll want subfunctions down the road, too, if that

Quoted 8 lines

is what you mean.

Quoted 2 lines
Quoted 1 line

I still didn't find any reason in the discussion to find out why grouping device

is needed.

VFs are already grouped with their PF. However we should spell this out as the motivation for the admin queue.

Ok. so for now, we are not introducing any explicitly grouping concept. In v2, will revise to have description as,

PCI VFs of a parent PCI PF device are grouped together. These devices can be optionally managed by its parent PCI PF.

Quoted 17 lines
Quoted 1 line

Current AQ proposal implicitly indicates that VFs of a PF are managed by its

parent PF.

Quoted 15 lines

And for some reason this work by one of the VF, this role assignment can be certainly a new command on AQ as group command or some other command.

Quoted 11 lines
Quoted 10 lines
Quoted 8 lines

Following this idea, all commands would then gain fields for addressing one device from another.

Not everything maps well to a queue. E.g. it would be great to have list of available commands in memory.

I'm not sure I agree. Why can't it map to a queue ?

Quoted 9 lines
Quoted 3 lines
Quoted 3 lines

You can map it to a queue, yes. But something static and read only such as list of commands maps well to config space. And it's not controlling one device from another, so does not really seem to belong in

the admin queue.

Quoted 2 lines
Quoted 1 line

Aq serves the writing device config too in patch-5 in this patchset.

List of available admin commands does not need to be written.

It is not written into the aq commands.
It is part of the feature bit VIRTIO_F_ADMIN_PCI_VIRT_MANAGER indicating a given functionality supported or not in patch-5.
And structure like, virtio_admin_pci_virt_mgmt_attr_identify_result can potentially grow and storing those fields on on-chip resource is less efficient. Hence, they are shared via AQ.

Quoted 22 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

Figuring out max vectors also looks like a good example for memory and not through a command.

Any explanation why is it looks good ? or better ?

Quoted 7 lines
Quoted 6 lines

why is memory easier to operate than a VQ?
It's much simpler and so less error prone. you can have multiple actors read such a field at the same time without races, so e.g. there could be a sysfs attribute that reads from device on each access, and not special error handling is needed.

Writing fields is inherent part of the aq without getting blocked on previous

writes.

Quoted 1 line

I see you acked that AQ is fine in cover letter patch as below, so we are sync

on the motivation now.

Quoted 3 lines

Yes, will update the commit log as you suggested.

" if the answer is "commands A,B,C do not fit in config space, we placed

commands D,E in a VQ for consistency"

Quoted 1 line

then that is an ok answer, but it's something to be mentioned in the commit

log"

#8 lore raw

Re: [PATCH 1/5] Add virtio Admin Virtqueue specification

Quoted 44 lines · Parav Pandit
Quoted 11 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 11:47 AM

Quoted 1 line · Parav Pandit
Quoted 1 line

I don't recall discussion about UUID so I can't really say what I think about

that.

Quoted 3 lines
Quoted 3 lines

Do we need a UUID? I'm not sure I understand why.
It can't hurt to abstract things a bit so it's not all tied to PFs/VFs since we know we'll want subfunctions down the road, too, if that

Quoted 8 lines

is what you mean.

Quoted 2 lines
Quoted 1 line

I still didn't find any reason in the discussion to find out why grouping device

is needed.

VFs are already grouped with their PF. However we should spell this out as the motivation for the admin queue.

Ok. so for now, we are not introducing any explicitly grouping concept. In v2, will revise to have description as,

PCI VFs of a parent PCI PF device are grouped together. These devices can be optionally managed by its parent PCI PF.

Quoted 20 lines
Quoted 1 line

Current AQ proposal implicitly indicates that VFs of a PF are managed by its

parent PF.

Quoted 18 lines

And for some reason this work by one of the VF, this role assignment can be certainly a new command on AQ as group command or some other command.

Quoted 14 lines
Quoted 10 lines
Quoted 8 lines

Following this idea, all commands would then gain fields for addressing one device from another.

Not everything maps well to a queue. E.g. it would be great to have list of available commands in memory.

I'm not sure I agree. Why can't it map to a queue ?

You can map it to a queue, yes. But something static and read only such as list of commands maps well to config space. And it's not controlling one device from another, so does not really seem to belong in

Quoted 8 lines
Quoted 6 lines

the admin queue.

Quoted 2 lines
Quoted 1 line

Aq serves the writing device config too in patch-5 in this patchset.

List of available admin commands does not need to be written.

It is not written into the aq commands.
It is part of the feature bit VIRTIO_F_ADMIN_PCI_VIRT_MANAGER indicating a given functionality supported or not in patch-5.

Btw I don't see what does "VIRT_MANAGER" mean here. "manager" is just a generic thing that means nothing, and VIRT just repeats VIRTIO.

Quoted 2 lines

And structure like, virtio_admin_pci_virt_mgmt_attr_identify_result can potentially grow and storing those fields on on-chip resource is less efficient. Hence, they are shared via AQ.

The issue is this: VIRTIO_F_ADMIN_PCI_VIRT_MANAGER seems to mean there are pci related admin commands. OK I guess. However you then say this same feature bit implies generic functionality like list of supported commands. Confusing.

Quoted 23 lines
Quoted 23 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

Figuring out max vectors also looks like a good example for memory and not through a command.

Any explanation why is it looks good ? or better ?

Quoted 7 lines
Quoted 6 lines

why is memory easier to operate than a VQ?
It's much simpler and so less error prone. you can have multiple actors read such a field at the same time without races, so e.g. there could be a sysfs attribute that reads from device on each access, and not special error handling is needed.

Writing fields is inherent part of the aq without getting blocked on previous

writes.

Quoted 1 line

I see you acked that AQ is fine in cover letter patch as below, so we are sync

on the motivation now.

Quoted 3 lines

Yes, will update the commit log as you suggested.

" if the answer is "commands A,B,C do not fit in config space, we placed

commands D,E in a VQ for consistency"

Quoted 1 line

then that is an ok answer, but it's something to be mentioned in the commit

log"

#9 lore raw

RE: [PATCH 1/5] Add virtio Admin Virtqueue specification

Quoted 3 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 1:36 PM

[..]

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines

You can map it to a queue, yes. But something static and read only such as list of commands maps well to config space. And it's not controlling one device from another, so does not really seem to belong in

the admin queue.

Quoted 2 lines
Quoted 1 line

Aq serves the writing device config too in patch-5 in this patchset.

List of available admin commands does not need to be written.

Quoted 8 lines
Quoted 2 lines

It is not written into the aq commands.
It is part of the feature bit VIRTIO_F_ADMIN_PCI_VIRT_MANAGER indicating

a given functionality supported or not in patch-5.

Btw I don't see what does "VIRT_MANAGER" mean here. "manager" is just a generic thing that means nothing, and VIRT just repeats VIRTIO.

VIRT doesn't repeat VIRTIO. VIRT indicates PCI virtual functions. Manager is generic thing to manage.
Below is the snippet from patch-5.

+ \item[VIRTIO_F_ADMIN_PCI_VIRT_MANAGER (44)] This feature indicates
+ that the device can manage PCI related capabilities for its managed
+ PCI VF devices and supports VIRTIO_ADMIN_PCI_VIRT_MGMT_ATTR_IDENTIFY,
+ VIRTIO_ADMIN_PCI_VIRT_PROPERTY_SET and
+ VIRTIO_ADMIN_PCI_VIRT_PROPERTY_GET
+ admin commands. This feature can be supported only by PCI devices. +

Quoted 7 lines
Quoted 2 lines

And structure like, virtio_admin_pci_virt_mgmt_attr_identify_result can

potentially grow and storing those fields on on-chip resource is less efficient.

Quoted 1 line

Hence, they are shared via AQ.

The issue is this: VIRTIO_F_ADMIN_PCI_VIRT_MANAGER seems to mean there are pci related admin commands. OK I guess.

Right.

Quoted 4 lines

However you then say this same
feature bit implies generic functionality like list of supported commands. Confusing.

Not sure where I mentioned generic functionality.
This feature bit implies pci virtualization related functionality by means of above listed commands.

#10 lore raw

Re: [PATCH 1/5] Add virtio Admin Virtqueue specification

Quoted 17 lines · Parav Pandit
Quoted 3 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 1:36 PM

[..]

Quoted 12 lines
Quoted 12 lines
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines

You can map it to a queue, yes. But something static and read only such as list of commands maps well to config space. And it's not controlling one device from another, so does not really seem to belong in

the admin queue.

Quoted 2 lines
Quoted 1 line

Aq serves the writing device config too in patch-5 in this patchset.

List of available admin commands does not need to be written.

It is not written into the aq commands.
It is part of the feature bit VIRTIO_F_ADMIN_PCI_VIRT_MANAGER indicating

Quoted 7 lines
Quoted 6 lines

a given functionality supported or not in patch-5.

Btw I don't see what does "VIRT_MANAGER" mean here. "manager" is just a generic thing that means nothing, and VIRT just repeats VIRTIO.

VIRT doesn't repeat VIRTIO.

It's literally a substring ;)

Quoted 1 line

VIRT indicates PCI virtual functions.

I'd use something like "SRIOV" then.

Quoted 1 line

Manager is generic thing to manage.

generic to the point of being meaningless.

Quoted 5 lines

Below is the snippet from patch-5.

+ \item[VIRTIO_F_ADMIN_PCI_VIRT_MANAGER (44)] This feature indicates
+ that the device can manage PCI related capabilities for its managed
+ PCI VF devices and supports VIRTIO_ADMIN_PCI_VIRT_MGMT_ATTR_IDENTIFY,

manage twice here. VFs are always managed. And manage here again does not mean much. I'd say something like:
"allow control over VFs through admin vq of the PF"

Quoted 12 lines
(quoted diff) +4 -0
+  VIRTIO_ADMIN_PCI_VIRT_PROPERTY_SET and 
+ VIRTIO_ADMIN_PCI_VIRT_PROPERTY_GET
+  admin commands. This feature can be supported only by PCI devices.
+
Quoted 8 lines
Quoted 3 lines

And structure like, virtio_admin_pci_virt_mgmt_attr_identify_result can

potentially grow and storing those fields on on-chip resource is less efficient.

Quoted 1 line

Hence, they are shared via AQ.

The issue is this: VIRTIO_F_ADMIN_PCI_VIRT_MANAGER seems to mean there are pci related admin commands. OK I guess.

Quoted 7 lines

Right.

Quoted 4 lines

However you then say this same
feature bit implies generic functionality like list of supported commands. Confusing.

Not sure where I mentioned generic functionality.
This feature bit implies pci virtualization related functionality by means of above listed commands.

pci virtualization being SRIOV here with PF controlling VFs.

Signature · 1 line
MST
#11 lore raw

RE: [PATCH 1/5] Add virtio Admin Virtqueue specification

Quoted 30 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 3:57 PM

Quoted 24 lines · Parav Pandit
Quoted 3 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 1:36 PM

[..]

Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

You can map it to a queue, yes. But something static and read only such as list of commands maps well to config space. And it's not controlling one device from another, so does not really seem to belong in

the admin queue.

Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Aq serves the writing device config too in patch-5 in this patchset.

List of available admin commands does not need to be written.

It is not written into the aq commands.
It is part of the feature bit VIRTIO_F_ADMIN_PCI_VIRT_MANAGER indicating

a given functionality supported or not in patch-5.

Btw I don't see what does "VIRT_MANAGER" mean here. "manager" is just a generic thing that means nothing, and VIRT just repeats VIRTIO.

Quoted 7 lines
Quoted 1 line

VIRT doesn't repeat VIRTIO.

It's literally a substring ;)

Quoted 1 line

VIRT indicates PCI virtual functions.

I'd use something like "SRIOV" then.

Yeah. This is good short string.
How about VIRTIO_F_ADMIN_PCI_SRIOV?

#106 lore raw

Re: [PATCH 5/5] Add support for dynamic MSI-X vector mgmt for VFs

In reply to Max Gurtovoy
Quoted 5 lines · Max Gurtovoy

A typical cloud provider SR-IOV use case is to create many VFs for use by guest VMs. The VFs may not be assigned to a VM until a user requests a VM of a certain size, e.g., number of CPUs. A VF may need
MSI-X vectors proportional to the number of CPUs in the VM,

Problem is, it does not work like that. VF needs vectors proportional to # of VQs and yes, # of VQs proportional to # of CPUs.

So I am not sure what does control over # of vectors get us without control over # of VQs. Something to better explain in the cover letter.

Quoted 195 lines

but there is
no standard way today in the spec to change the number of MSI-X vectors supported by a VF, although there are some operating systems that support this.

Introduce new feature bits for generic PCI virtualization management mechanism and a specific mechanism to manage the MSI-X vector assignment process of virtual/managed functions by its parent virtio device via its admin virtqueue. For now, virtio supports only PCI virtual function virtualization, thus the virt manager device will be the PF and the managed device will be the VF.

---
 admin-virtq.tex | 98 ++++++++++++++++++++++++++++++++++++++++++++++++-
 content.tex     | 29 ++++++++++++++-
 2 files changed, 124 insertions(+), 3 deletions(-)
admin-virtq.tex +97 -1
index ad20f89..4ee8a32 100644
@@ -41,9 +41,105 @@ \section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin
 \hline
 Opcode (bits) & Opcode (hex) & Command & M/O \\
 \hline \hline
- -  & 00h - 7Fh   & Generic admin cmds    & -  \\
+ 00000000b  & 00h   & VIRTIO_ADMIN_PCI_VIRT_MGMT_ATTR_IDENTIFY    & O  \\
+\hline
+ 00000001b  & 01h   & VIRTIO_ADMIN_PCI_VIRT_PROPERTY_SET    & O  \\
+\hline
+ 00000010b  & 02h   & VIRTIO_ADMIN_PCI_VIRT_PROPERTY_GET    & O  \\
+\hline
+ -  & 03h - 7Fh   & Generic admin cmds    & -  \\
 \hline
  -  & 80h - FFh   & Reserved    & - \\
 \hline
 \end{tabular}
 
+\subsection{VIRTIO ADMIN PCI VIRT MGMT ATTR IDENTIFY command}\label{sec:Basic Facilities of a Virtio Device / Admin Virtqueues / VIRTIO ADMIN PCI VIRT MGMT ATTR IDENTIFY command}
+
+The VIRTIO_ADMIN_PCI_VIRT_MGMT_ATTR_IDENTIFY command has no command specific data set by the driver.
+This command upon success, returns a data buffer that describes information about PCI virtualization
+management attributes. This information is of form:
+\begin{lstlisting}
+struct virtio_admin_pci_virt_mgmt_attr_identify_result {
+        /* For compatibility - indicates which of the below fields are valid (1 means valid):
+         * Bit 0x0 - total_free_vfs_msix_count
+         * Bit 0x1 - per_vf_max_msix_count
+         * Bits 0x2 - 0x3F - reserved for future fields
+         */
+        le64 mask;
+        /* Number of free msix in the global msix pool for VFs */
+        le32 total_free_vfs_msix_count;
+        /* Max number of msix vectors that can be assigned for a single VF */
+        le16 per_vf_max_msix_count;
+};
+\end{lstlisting}
+
+\subsection{VIRTIO ADMIN PCI VIRT PROPERTY SET command}\label{sec:Basic Facilities of a Virtio Device / Admin Virtqueues / VIRTIO ADMIN PCI VIRT PROPERTY SET command}
+
+The VIRTIO_ADMIN_PCI_VIRT_PROPERTY_SET command is used to modify the values of VF properties.
+The command specific data set by the driver is of form:
+\begin{lstlisting}
+virtio_admin_pci_virt_property_set_data {
+        /* The virtual function number */
+        le16 vf_number;
+        /* For compatibility - indicates which of the below properties should be
+         * modified (1 means that field should be modified):
+         * Bit 0x0 - msix_count
+         * Bits 0x1 - 0x3F - reserved for future fields
+         */
+        le64 property_mask;
+        /* The amount of MSI-X vectors */
+        le16 msix_count;
+};
+\end{lstlisting}
+
+\begin{note}
+{vf_number can't be greater than NumVFs value as defined in the PCI specification
+or smaller than 1. An error status will be returned otherwise.}
+\end{note}
+
+This command has no command specific result set by the device. Upon success, the device guarantees
+that all the requested properties were modified to the given values. Otherwise, error will be returned.
+
+\begin{note}
+{Before setting msix_count property the virtual/managed device (VF) shall be un-initialized and may not be used by the driver.}
+\end{note}
+
+\subsection{VIRTIO ADMIN PCI VIRT PROPERTY GET command}\label{sec:Basic Facilities of a Virtio Device / Admin Virtqueues / VIRTIO ADMIN PCI VIRT PROPERTY GET command}
+
+The VIRTIO_ADMIN_PCI_VIRT_PROPERTY_GET command is used to obtain the values of VF properties.
+The command specific data set by the driver is of form:
+\begin{lstlisting}
+virtio_admin_pci_virt_property_get_data {
+        /* The virtual function number */
+        le16 vf_number;
+        /* For compatibility - indicates which of the below properties should be
+         * queried (1 means that field should be queried):
+         * Bit 0x0 - msix_count
+         * Bits 0x1 - 0x3F - reserved for future fields
+         */
+        le64 property_mask;
+        /* The amount of MSI-X vectors */
+        le16 msix_count;
+};
+\end{lstlisting}
+
+\begin{note}
+{vf_number can't be greater than NumVFs value as defined in the PCI specification
+or smaller than 1. An error status will be returned otherwise.}
+\end{note}
+
+This command, upon success, returns a data buffer that describes the properties that were requested
+and their values for the subject virtio VF device according to the given vf_number.
+This information is of form:
+\begin{lstlisting}
+struct virtio_admin_pci_virt_property_get_result {
+        /* For compatibility - indicates which of the below fields were returned
+         * (1 means that field was returned):
+         * Bit 0x0 - msix_count
+         * Bits 0x1 - 0x3F - reserved for future fields
+         */
+        le64 property_mask;
+        /* The amount of MSI-X vectors */
+        le16 msix_count;
+};
+\end{lstlisting}
content.tex +27 -2
index e9c2383..64678f0 100644
@@ -99,10 +99,10 @@ \section{Feature Bits}\label{sec:Basic Facilities of a Virtio Device / Feature B
 \begin{description}
 \item[0 to 23] Feature bits for the specific device type
 
-\item[24 to 43] Feature bits reserved for extensions to the queue and
+\item[24 to 45] Feature bits reserved for extensions to the queue and
   feature negotiation mechanisms
 
-\item[44 and above] Feature bits reserved for future extensions.
+\item[46 and above] Feature bits reserved for future extensions.
 \end{description}
 
 \begin{note}
@@ -6878,6 +6878,17 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
   that all buffers are used by the admin virtqueue of the device in
   the same order in which they have been made available.
 
+  \item[VIRTIO_F_ADMIN_PCI_VIRT_MANAGER (44)] This feature indicates
+  that the device can manage PCI related capabilities for its managed PCI VF
+  devices and supports VIRTIO_ADMIN_PCI_VIRT_MGMT_ATTR_IDENTIFY,
+  VIRTIO_ADMIN_PCI_VIRT_PROPERTY_SET and VIRTIO_ADMIN_PCI_VIRT_PROPERTY_GET
+  admin commands. This feature can be supported only by PCI devices.
+
+  \item[VIRTIO_F_ADMIN_MSIX_MGMT (45)] This feature indicates
+  that the device supports management of the MSI-X vectors for its
+  managed PCI VF devices using VIRTIO_ADMIN_PCI_VIRT_PROPERTY_SET and
+  VIRTIO_ADMIN_PCI_VIRT_PROPERTY_GET admin commands.
+
 \end{description}
 
 \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
@@ -6920,6 +6931,14 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 A driver MAY accept VIRTIO_F_ADMIN_VQ_IN_ORDER only if it accepts
 VIRTIO_F_ADMIN_VQ.
 
+A driver MAY accept VIRTIO_F_ADMIN_PCI_VIRT_MANAGER only if it accepts
+VIRTIO_F_ADMIN_VQ.
+
+A driver MAY accept VIRTIO_F_ADMIN_MSIX_MGMT only if it accepts
+VIRTIO_F_ADMIN_VQ and VIRTIO_F_ADMIN_PCI_VIRT_MANAGER. Currently only
+MSI-X management of PCI virtual functions is supported, so the driver
+MUST NOT negotiate VIRTIO_F_ADMIN_MSIX_MGMT if VIRTIO_F_SR_IOV is not negotiated.
+
 \devicenormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
 
 A device MUST offer VIRTIO_F_VERSION_1.  A device MAY fail to operate further
@@ -6960,6 +6979,12 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 A device MAY offer VIRTIO_F_ADMIN_VQ_IN_ORDER only if it offers
 VIRTIO_F_ADMIN_VQ.
 
+A PCI device MAY offer VIRTIO_F_ADMIN_PCI_VIRT_MANAGER only if it
+offers VIRTIO_F_ADMIN_VQ.
+
+A PCI device MAY offer VIRTIO_F_ADMIN_MSIX_MGMT only if it
+offers VIRTIO_F_ADMIN_VQ, VIRTIO_F_ADMIN_PCI_VIRT_MANAGER and VIRTIO_F_SR_IOV.
+
 \section{Legacy Interface: Reserved Feature Bits}\label{sec:Reserved Feature Bits / Legacy Interface: Reserved Feature Bits}
 
 Transitional devices MAY offer the following:
Signature · 1 line
2.21.0
#44 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Parav Pandit
Quoted 6 lines · Parav Pandit

An unrelated command to AQ in Jason's proposal [1] is about " The management driver MUST create a managed device by allocating". We see that creator of the subfunction is often not the only entity managing it.
They being same in new era finding less and less users.
So this piece needs more discussion whenever we address that.

[1] https://lists.oasis-open.org/archives/virtio-comment/202108/msg00136.html

This reminds me. How do AQ commands interact with VF lifecycle? E.g. can one change number of vectors for an active VF? Need to specify this.

Also, I started worrying about compatibility here. Let's say the msix capability in a VF specifies 16 vectors. Can PF specify 32? If yes how will driver program them? Can PF specify 8? If yes how do we make sure driver does not attempt to use 16? And what happens if it does? Again, something to address.

Signature · 1 line
MST
#12 lore raw

Re: [PATCH 1/5] Add virtio Admin Virtqueue specification

In reply to Parav Pandit
Quoted 32 lines · Parav Pandit
Quoted 32 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 3:57 PM

Quoted 25 lines · Parav Pandit
Quoted 3 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 1:36 PM

[..]

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines

You can map it to a queue, yes. But something static and read only such as list of commands maps well to config space. And it's not controlling one device from another, so does not really seem to belong in

the admin queue.

Quoted 2 lines
Quoted 1 line

Aq serves the writing device config too in patch-5 in this patchset.

List of available admin commands does not need to be written.

Quoted 9 lines
Quoted 3 lines

It is not written into the aq commands.
It is part of the feature bit VIRTIO_F_ADMIN_PCI_VIRT_MANAGER indicating

a given functionality supported or not in patch-5.

Btw I don't see what does "VIRT_MANAGER" mean here. "manager" is just a generic thing that means nothing, and VIRT just repeats VIRTIO.

VIRT doesn't repeat VIRTIO.

Quoted 7 lines
Quoted 5 lines

It's literally a substring ;)

Quoted 1 line

VIRT indicates PCI virtual functions.

I'd use something like "SRIOV" then.

Yeah. This is good short string.
How about VIRTIO_F_ADMIN_PCI_SRIOV?

OK

Signature · 1 line
MST
#45 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Michael S. Tsirkin
Quoted 10 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 4:09 PM

Quoted 1 line · Parav Pandit

An unrelated command to AQ in Jason's proposal [1] is about " The

management driver MUST create a managed device by allocating".

Quoted 1 line

We see that creator of the subfunction is often not the only entity managing

it.

Quoted 8 lines
Quoted 6 lines

They being same in new era finding less and less users. So this piece needs more discussion whenever we address that.

[1]
https://lists.oasis-open.org/archives/virtio-comment/202108/msg00136.h
tml

This reminds me. How do AQ commands interact with VF lifecycle?

VF device usage is controlled by the same system which is configuring the VF via its parent PF device. So VF device shouldn't be in use. Any configuration change while VF device is in use will result in failing the AQ command.

Quoted 6 lines

E.g. can one change number of vectors for an active VF? Need to specify this.

Also, I started worrying about compatibility here. Let's say the msix capability in a VF specifies 16 vectors. Can PF specify 32? If yes how will driver program them?

Yes, PF can change to 32. When VF driver queries the PCI capability, it will reflect 32 instead of 16.

Quoted 2 lines

Can PF specify 8? If yes how do we make sure driver does not attempt to use 16? And what happens if it does?

PF is programming the VF msix capability in the device. So virtio pci driver operating the PCI VF device cannot access vectors beyond the max value programmed by the PF driver.

Quoted 1 line

Again, something to address.

Yes, this has to be described in the spec text. Will add more clearly in v2.

Quoted 4 lines

--
MST

#46 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 24 lines · Parav Pandit
Quoted 10 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 4:09 PM

Quoted 1 line · Parav Pandit

An unrelated command to AQ in Jason's proposal [1] is about " The

management driver MUST create a managed device by allocating".

Quoted 1 line

We see that creator of the subfunction is often not the only entity managing

it.

Quoted 8 lines
Quoted 6 lines

They being same in new era finding less and less users. So this piece needs more discussion whenever we address that.

[1]
https://lists.oasis-open.org/archives/virtio-comment/202108/msg00136.h
tml

This reminds me. How do AQ commands interact with VF lifecycle?

VF device usage is controlled by the same system which is configuring the VF via its parent PF device. So VF device shouldn't be in use. Any configuration change while VF device is in use will result in failing the AQ command.

Quoted 3 lines

E.g. can one change number of vectors for an active VF? Need to specify this.

Quoted 7 lines
Quoted 3 lines

Also, I started worrying about compatibility here. Let's say the msix capability in a VF specifies 16 vectors. Can PF specify 32? If yes how will driver program them?

Yes, PF can change to 32. When VF driver queries the PCI capability, it will reflect 32 instead of 16.

Quoted 2 lines

Can PF specify 8? If yes how do we make sure driver does not attempt to use 16? And what happens if it does?

PF is programming the VF msix capability in the device. So virtio pci driver operating the PCI VF device cannot access vectors beyond the max value programmed by the PF driver.

Um. Interesting. This means that the msix capability of the VF changes? Is that in fact spec compliant? Could some OSes cache the value of the capability even if the device is not in active use? E.g. I can see how this might happen in order to map the MSIX tables even before loading the driver.

The spec says:
Depending upon system software policy, system software, device driver software, or each at different times or environments may configure a function’s MSI-X capability and table structures with suitable vectors.

So MSIX canfiguation might not be up to the driver.

We actually ask driver to read back any vector assigned to a VQ so it's possible to fail vector assignment. Maybe that's better.

Quoted 7 lines
Quoted 1 line

Again, something to address.

Yes, this has to be described in the spec text. Will add more clearly in v2.

Quoted 4 lines

--
MST

#47 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 38 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 8:39 PM

Quoted 14 lines · Parav Pandit
Quoted 14 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 4:09 PM

Quoted 1 line · Parav Pandit

An unrelated command to AQ in Jason's proposal [1] is about " The

management driver MUST create a managed device by allocating".

Quoted 2 lines

We see that creator of the subfunction is often not the only entity managing

it.

Quoted 3 lines

They being same in new era finding less and less users. So this piece needs more discussion whenever we address that.

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

[1]
https://lists.oasis-open.org/archives/virtio-comment/202108/msg001
36.h
tml

This reminds me. How do AQ commands interact with VF lifecycle?

VF device usage is controlled by the same system which is configuring the VF

via its parent PF device.

Quoted 1 line

So VF device shouldn't be in use. Any configuration change while VF device is

in use will result in failing the AQ command.

Quoted 8 lines
Quoted 7 lines

E.g. can one change number of vectors for an active VF? Need to specify this.

Also, I started worrying about compatibility here. Let's say the msix capability in a VF specifies 16 vectors. Can PF specify 32? If yes how will driver program them?

Yes, PF can change to 32. When VF driver queries the PCI capability, it will

Quoted 8 lines

reflect 32 instead of 16.

Quoted 3 lines
Quoted 2 lines

Can PF specify 8? If yes how do we make sure driver does not attempt to use 16? And what happens if it does?

PF is programming the VF msix capability in the device. So virtio pci driver

operating the PCI VF device cannot access vectors beyond the max value programmed by the PF driver.

Um. Interesting. This means that the msix capability of the VF changes?

Yes.

Quoted 4 lines

Is that in fact spec compliant? Could some OSes cache the value of the capability even if the device is not in active use? E.g. I can see how this might happen in order to map the MSIX tables even before loading the driver.

PCI subsystem can catch the value before the device driver can load.
Generally a device support intx/msix or intx/msi. So PCI subsystem is not aware what will be used by its upper layer device drivers. So it usually differs such initialization to a later stage until it is actually used.

Whichever OS driver which implements msix configuration, will have to either not cache it or flush+ rebuild the cache.

Quoted 7 lines

The spec says:
Depending upon system software policy, system software, device driver
software, or each at
different times or environments may configure a function’s MSI-X
capability and table
structures with suitable vectors.

Quoted 5 lines

So MSIX canfiguation might not be up to the driver.

We actually ask driver to read back any vector assigned to a VQ so it's possible to fail vector assignment. Maybe that's better.

Virtio driver should not incur any additional complexity in re-reading vector etc.
All the msix config should happen much before drivers gets loaded for the VF.
It is PCI layer of the HV to provide a stable device to virtio device driver which is not undergoing msix table changes, when virtio device driver is operating on it.

#13 lore raw

Re: [PATCH 1/5] Add virtio Admin Virtqueue specification

In reply to Michael S. Tsirkin
Quoted 71 lines · Michael S. Tsirkin
Quoted 45 lines · Max Gurtovoy
Quoted 31 lines · Michael S. Tsirkin
Quoted 30 lines · Max Gurtovoy

In one of the many use cases a user wants to manipulate features and configuration of the virtio devices regardless of the device type (net/block/console). Some of this configuration is generic enough. i.e Number of MSI-X vectors of a virtio PCI VF device. There is a need to do such features query and manipulation by its parent PCI PF.

Currently virtio specification defines control virtqueue to manipulate features and configuration of the device it operates on. However, control virtqueue commands are device type specific, which makes it very difficult to extend for device agnostic commands. Control virtqueue is also limited to follow in order completion for the device which negotiates VIRTIO_F_IN_ORDER feature. This feature limits the use of control virtqueue for feature manipulation in out of order manner for unrelated commands.

To support these requirements which overcome above two limitations in elegant way, this patch introduces a new admin virtqueue. Admin virtqueue will use the same command format for all types of virtio devices.

Subsequent patches make use of this admin virtqueue.

---
   admin-virtq.tex | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
   content.tex     |  9 +++++++--
   2 files changed, 56 insertions(+), 2 deletions(-)

create mode 100644 admin-virtq.tex

Quoted 13 lines

admin-virtq.tex line 5

Quoted 11 lines
admin-virtq.tex new file +5 -0
new file mode 100644
index 0000000..ad20f89
@@ -0,0 +1,49 @@
+\section{Admin Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Admin Virtqueues}
+
+Admin virtqueue is used to send administrative commands to manipulate
+various features of the device which would not easily map into the
+configuration space.

IMHO this is too vague to be useful. E.g. I don't really see why would not commands specified in the next patch map to config space.

Quoted 1 line

Well I took this sentence from the current spec :)

Well in current spec it applies to things like MAC address filtering, which does not easily map into config space because number of MACs varies.

Quoted 7 lines
Quoted 4 lines

We had an off-list meeting where I proposed addressing one device from another or grouping multiple devices as a more specific scope. That would be one way to address this.

Are you suggestion a creation of a virtio subsystem or a virtio group definition ?

Quoted 7 lines

Devices will be part of this subsystem: one primary/manager device and many secondary/managed devices ?

Each subsystem will have a unique UUID and each device will have a unique vdev_id within this subsystem.

If this is the direction, I can prepare something..

I was merely saying that what is special about admin queue is that it allows controlling one device from another within some group. Or maybe that it allows grouping multiple devices.
*Not* that these are things that do not map to config space.

Quoted 5 lines

Let me give you another example, imagine that you want to handle pagefaults from device. Clearly a generic thing that does not map to config space. It could be a good candidate for the admin queue, however it would require that lots of buffers are pre-added to the queue. So it looks like it will beed another distinct fault queue.

That seems a duplication of the PRS queue which is implemented in the AMD/Intel IOMMUs which I'm not sure it's worth.

Quoted 4 lines

Further it is
possible that you want to handle faults within guest, by the driver. In that case you do not want it in the admin queue since that is controlled by hypervisor, you want it in a separate queue controlled by driver.

Exactly, another call for the using the PRS queue instead. But generally speaking, admin virtqueue limit or complicate the functions that can be exported to guest. That's why I suggest to decouple all the possible features out of admin virtqueue, and make it available by both the admin virtqueue and the transport specific method (e.g capability).

Thanks

Quoted 113 lines

I don't recall discussion about UUID so I can't really say what I think about that. Do we need a UUID? I'm not sure I understand why. It can't hurt to abstract things a bit so it's not all tied to PFs/VFs since we know we'll want subfunctions down the road, too, if that is what you mean.

Quoted 6 lines
Quoted 5 lines

Following this idea, all commands would then gain fields for addressing one device from another.

Not everything maps well to a queue. E.g. it would be great to have list of available commands in memory.

I'm not sure I agree. Why can't it map to a queue ?

You can map it to a queue, yes. But something static and read only such as list of commands maps well to config space. And it's not controlling one device from another, so does not really seem to belong in the admin queue.

Quoted 3 lines
Quoted 2 lines

Figuring out max vectors also looks like a good
example for memory and not through a command.

Any explanation why is it looks good ? or better ?

why is memory easier to operate than a VQ?
It's much simpler and so less error prone. you can have multiple actors read such a field at the same time without races, so e.g. there could be a sysfs attribute that reads from device on each access, and not special error handling is needed.

Quoted 83 lines
Quoted 83 lines

VQ # of the admin VQ could also be made more discoverable. How about an SRIOV capability describing this stuff then?

Quoted 33 lines
admin-virtq.tex new file +33 -0
+Use of Admin virtqueue is negotiated by the VIRTIO_F_ADMIN_VQ
+feature bit.
+
+Admin virtqueue index may vary among different device types.
+
+The Admin command set defines the commands that may be issued only to the admin
+virtqueue. Each virtio device that advertises the VIRTIO_F_ADMIN_VQ feature, MUST
+support all the mandatory admin commands. A device MAY support also one or more
+optional admin commands. All commands are of the following form:
+
+\begin{lstlisting}
+struct virtio_admin_cmd {
+        /* Device-readable part */
+        u8 command;
+        u8 command-specific-data[];
+
+        /* Device-writable part */
+        u8 status;
+        u8 command-specific-result[];
+};
+
+/* status values */
+#define VIRTIO_ADMIN_STATUS_OK 0
+#define VIRTIO_ADMIN_STATUS_ERR 1
+#define VIRTIO_ADMIN_STATUS_COMMAND_UNSUPPORTED 2
+\end{lstlisting}
+
+The \field{command} and \field{command-specific-data} are
+set by the driver, and the device sets the \field{status} and the
+\field{command-specific-result}, if needed.
+
+The following table describes the Admin command set:
+

admin-virtq.tex line 49

Quoted 10 lines
admin-virtq.tex new file +10 -0
+\begin{tabular}{|l|l|l|l|}
+\hline
+Opcode (bits) & Opcode (hex) & Command & M/O \\
+\hline \hline
+ -  & 00h - 7Fh   & Generic admin cmds    & -  \\
+\hline
+ -  & 80h - FFh   & Reserved    & - \\
+\hline
+\end{tabular}
+

Add conformance clauses pls. If this section is too generic to have any then this functionality is too generic to be useful ;)

Quoted 31 lines
content.tex +7 -2
index 32de668..c524fab 100644
@@ -99,10 +99,10 @@ \section{Feature Bits}\label{sec:Basic Facilities of a Virtio Device / Feature B
   \begin{description}
   \item[0 to 23] Feature bits for the specific device type
-\item[24 to 40] Feature bits reserved for extensions to the queue and
+\item[24 to 41] Feature bits reserved for extensions to the queue and
     feature negotiation mechanisms
-\item[41 and above] Feature bits reserved for future extensions.
+\item[42 and above] Feature bits reserved for future extensions.
   \end{description}
   \begin{note}
@@ -449,6 +449,8 @@ \section{Exporting Objects}\label{sec:Basic Facilities of a Virtio Device / Expo
   types. It is RECOMMENDED that devices generate version 4
   UUIDs as specified by \hyperref[intro:rfc4122]{[RFC4122]}.
+\input{admin-virtq.tex}
+
   \chapter{General Initialization And Device Operation}\label{sec:General Initialization And Device Operation}
   We start with an overview of device initialization, then expand on the
@@ -6847,6 +6849,9 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
     that the driver can reset a queue individually.
     See \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Reset}.
+  \item[VIRTIO_F_ADMIN_VQ (41)] This feature indicates that
+  the device supports administration virtqueue negotiation.
+
   \end{description}
   \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
Signature · 1 line
2.21.0
#57 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Parav Pandit
Quoted 58 lines · Parav Pandit
Quoted 29 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 12:25 PM

Quoted 25 lines · Parav Pandit
Quoted 25 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 11:54 AM

Quoted 7 lines · Parav Pandit
Quoted 7 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 3:44 AM

Quoted 3 lines
Quoted 1 line

It's a control queue. Why do we worry?

It is used to control/manage the resource of a VF which is deployed usually

to a VM.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

So higher the latency, higher the time it takes to deploy start the VM.

What are the savings here, in real terms? Boot times for smallest VMs are in 10s of milliseconds. Is reordering of a queue somehow going to save more than microseconds?

It is probably better not to pick on a specific vendor implementation. But for real numbers, I see that an implementation takes 54usec to 500 usec

range for simple configuration.

Quoted 2 lines

It is better to not small VM 4 vector configuration to take longer because

there was previous AQ command for 64 vectors.

Quoted 10 lines
Quoted 4 lines
Quoted 2 lines

So virtio discovery on boot includes multiple of vmexits, each costs ~1000 cycles. And people do not seem to worry about it.

It is not the vector configuration by guest VM.
It is the AQ command that provisions number of msix vectors for the VF that

takes tens to hundreds of usecs.

Quoted 1 line

These are the command in patch-5 in this proposal.

Hundreds of usecs is negligeable compared to VM boot time. Sorry I don't really see why we worry about indirect in that case.

Ok. we will do incremental proposal after this for wider use case.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

You want a compelling argument for working on performance of config. I frankly think it's not really useful but I especially think you should cut this out of the current proposal, it's too big as it is.

Ok. We can do follow on proposal after AQ.
We already see need of out of order AQ in internal performance tests we are

running.

OK so first of all you can avoid declaring IN_ORDER.

This will force non IN_ORDER on other txq and rxq too that causes higher latency. But fine, initial implementation can start without it.

Quoted 3 lines

If you see that IN_ORDER
improves performance for you so you need it, then look at PARTIAL_ORDER pls.

Ok. will consider PARTIAL_ORDER more in future proposal.

Quoted 7 lines
Quoted 4 lines

And if that does not address your needs then let's discuss, I'd rather have a generic solution since the requirement does not seem to be specific to AQ.

Quoted 1 line

But fine, we can differ.

So far I gather below summary that needs to be addressed in v2.

1. Use AQ for msix query and config

It it means IMS, there's already a proposal[1] that introduce MSI commands via the admin virtqueue. And we had similar requirement for virtio-MMIO[2] and managed device or SF [3], so I would rather to introduce IMS (need a better name though) as a basic facility instead of tie it to any specific transport.

Quoted 2 lines

2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues
3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds)

I fail to understand the scale/registeres issues. With the one of my previous proposal (device selector), technically we don't even need any config space or BAR for VF or SF by multiplexing the registers for PF.

I do see one advantage is that the admin virtqueue is transport independent (or it could be used as a transport).

Quoted 9 lines

4. Improve documentation around msix config to link to sriov section of virtio spec
5. Describe error that if VF is bound to the device, admin commands targeting VF can fail, describe this error code

Did I miss anything?

Yet to receive your feedback on group, if/why is it needed and, why/if it must be in this proposal, what pieces prevents it do as follow-on.

Cornelia, Jason,
Can you please review current proposal as well before we revise v2?

If I understand correctly, most of the features (except for the admin virtqueue in_order stuffs) are not specific to the admin virtqueue. As discussed in the previous versions, I still think it's better:

1) adding sections in the basic device facility or data structure for provisioning and MSI
2) introduce admin virtqueue on top as an device interface for those features

The leaves the chance for future extensions to allow those features to be used by transport specific interface which will benefit for

1) vendor that doesn't want to transport specific method (MMIO or PCIe capability) [4]
2) features that can be used by guest or nesting environment (L1)

Thanks

[1] https://lists.oasis-open.org/archives/virtio-comment/202108/msg00025.html

[2] https://lkml.org/lkml/2020/1/21/31

[3] https://lists.oasis-open.org/archives/virtio-comment/202108/msg00134.html

[4] https://lists.oasis-open.org/archives/virtio-comment/202108/msg00136.html

Quoted 1 line
#97 lore raw

Re: [PATCH 4/5] virtio-net: add support for VIRTIO_F_ADMIN_VQ

In reply to Michael S. Tsirkin
Quoted 73 lines · Michael S. Tsirkin
Quoted 63 lines · Jason Wang
Quoted 42 lines · Michael S. Tsirkin
Quoted 20 lines · Parav Pandit
Quoted 20 lines

From: Max Gurtovoy <[email protected]>
Sent: Sunday, January 16, 2022 3:18 PM

Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Max Gurtovoy

Set the relevant index in case of VIRTIO_F_ADMIN_VQ negotiation.

So admin VQ # is only known when all features are negotiated.

No. The driver should see if VIRTIO_NET_F_CTRL_VQ/VIRTIO_F_ADMIN_VQ are set by the device.

Negotiation is not a must.

Lets say CTRL_VQ is supported by the device and driver A would like to use it and driver B wouldn't like to use it - in both cases the admiq VQ # would be 2N
+ 1.

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

Which is quite annoying if hypervisor wants to partition things e.g. handling admin q in process and handling vqs by an external process or by hardware.

I think we can allow devices to set the VQ# for the admin queue instead. Would that work?

Number of MSI-X configuration and number of VQs config are two different,

I was talking about the number of the VQ used for admin commands. Not about the number of VQs.

Quoted 4 lines

though it has strong correlation.
Configuring number of queues seems a very device specific configuration (even though num_queues is generic field in struct virtio_pci_common_cfg).

So num VQ configuration is a different command likely combined with other device specific config such as mac or rss or others.

I was not talking about that at all, but since you mention that, to me it looks like something that many device types can support. It's not necessarily rss related, MQ config would benefit too, so I am not sure why not have a command for controlling number of queues. Looks like it could quite be generic.

Quoted 6 lines

Since current guests only support two modes: a vector per VQ and a shared vector for all VQs, it follows that it is important when configuring vectors per VF to also configure VQs per VF. This makes me wonder whether ability to configure vectors per VF in isolation without ability to configure or at least query VQs per VF even has value.

So I had some thought in the past, it looks to me we need a generic provision interface that contains all the necessary attributes:

1) #queues
2) device_features
3) #msi_vectors
4) device specific configurations

It could be either an admin virtqueue interface[1] or a dedicated capability[2], (the latter seems easier).

Quoted 7 lines

Thanks

[1]
https://lists.oasis-open.org/archives/virtio-comment/202108/msg00025.html
[2]
https://lists.oasis-open.org/archives/virtio-comment/202108/msg00136.html

Quoted 5 lines

We also need
- something like injecting cvq commands to control rx mode from the admin device
- page fault / dirty page handling

these two seem to call for a vq.

Right, but vq is not necessarily for PF if we had PASID. And with PASID we don't even need a dedicated new cvq.

Thanks

Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
#41 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Michael S. Tsirkin
Quoted 36 lines · Michael S. Tsirkin
Quoted 28 lines · Parav Pandit
Quoted 13 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 12:42 PM

Quoted 8 lines · Parav Pandit

1. Use AQ for msix query and config
2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues 3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds) 4. Improve documentation around msix config to link to sriov section of virtio spec 5. Describe error that if VF is bound to the device, admin commands targeting VF can fail, describe this error code

Quoted 3 lines
Quoted 1 line

Did I miss anything?

Better document in spec text just what is the scope for AQ.

Yes, will improve this spec.

Quoted 10 lines
Quoted 1 line

Yet to receive your feedback on group, if/why is it needed and, why/if it must

be in this proposal, what pieces prevents it do as follow-on.

I think this is related to the subfunction usecase or other future usecase. In case of PF/VF grouping is implicit through the SRIOV capability. It would be nice to have things somewhat generic in most of the text though since we already know this will be needed.
E.g. jason sent a proposal for commands to add/delete subfunctions, take a look at it, somehow AQ needs to be extendable to support that functionality too.

Quoted 7 lines

I looked briefly to it. AQ can be used for such purpose. Current proposal adds only msix config piece. But more commands can be added in future.

What I wanted to check with you and other is, do we want command opcode to be 7-bit enough?
#127 is lot of admin commands. 😊
But given virtio spec diversity of transport and device types, I was thinking to keep it 15-bit for future proofing. What do you think?

Quoted 10 lines

I agree, we are not short on bits.

Quoted 2 lines

An unrelated command to AQ in Jason's proposal [1] is about " The management driver MUST create a managed device by allocating". We see that creator of the subfunction is often not the only entity managing it.

I think whoever does it can go through the main function driver.

Quoted 4 lines

They being same in new era finding less and less users. So this piece needs more discussion whenever we address that.

[1] https://lists.oasis-open.org/archives/virtio-comment/202108/msg00136.html

Yes, I do that for dynamic provisioning which seems a requirement (or better to have) for SIOV spec. We can extend or tweak it for static provisioning.

Thanks

#58 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Jason Wang
Quoted 11 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 19, 2022 9:33 AM

It it means IMS, there's already a proposal[1] that introduce MSI commands via the admin virtqueue. And we had similar requirement for virtio-MMIO[2] and managed device or SF [3], so I would rather to introduce IMS (need a better name though) as a basic facility instead of tie it to any specific transport.

IMS of [1] is a interrupt configuration by the virtio driver for the device is it driving, which needs a queue. So regardless of the device type as PCI PF/VF/SF/ADI, there is desire to have a generic admin queue not attached to device type. And AQ in this proposal exactly serves this purpose.

Device configuring its own IMS vector vs PCI PF configuring VF's MSI-X max vector count are two different functionality. Both of these commands can ride on a generic queue.
However the queue is not same, because
PF owns its own admin queue (for vf msix config),
VF or SF operates its own admin queue (for IMS config).

So a good example is,
1. PCI PF configures 8 MSI-X or 16 IMS vectors for the VF using PF_AQ in HV.
2. PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ in GVM. Both the functions will have AQ feature bit set.

Fair enough, so we have more users of admin queue than just MSI-X config.

Quoted 10 lines
Quoted 4 lines

2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues 3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds)

I fail to understand the scale/registeres issues. With the one of my previous proposal (device selector), technically we don't even need any config space or BAR for VF or SF by multiplexing the registers for PF.

Scale issue is: when you want to create, query, manipulate hundreds of objects, having shared MMIO register or configuration register, will be too slow. And additionally such register set doesn't scale to allow sharing large number of bytes as DMA cannot be done.

From physical device perspective, it doesn’t scale because device needs to have those resources ready to answer on MMIO reads and for hundreds to thousand of devices it just cannot do it. This is one of the reason for birth of IMS.

Quoted 3 lines

I do see one advantage is that the admin virtqueue is transport independent (or it could be used as a transport).

I am yet to read the transport part from [1].

Quoted 15 lines
Quoted 2 lines

4. Improve documentation around msix config to link to sriov section of virtio

spec

Quoted 1 line

5. Describe error that if VF is bound to the device, admin commands

targeting VF can fail, describe this error code

Quoted 4 lines

Did I miss anything?

Yet to receive your feedback on group, if/why is it needed and, why/if it must

be in this proposal, what pieces prevents it do as follow-on.

Quoted 3 lines

Cornelia, Jason,
Can you please review current proposal as well before we revise v2?

Quoted 9 lines

If I understand correctly, most of the features (except for the admin virtqueue in_order stuffs) are not specific to the admin virtqueue. As discussed in the previous versions, I still think it's better:

1) adding sections in the basic device facility or data structure for provisioning and MSI
2) introduce admin virtqueue on top as an device interface for those features

I didn't follow your suggestion. Can you please explain? Specifically "data structure for provisioning and MSI"..

Quoted 3 lines

The leaves the chance for future extensions to allow those features to be used by transport specific interface which will benefit for

AQ allows communication (command, response) between driver and device in transport independent way. Sometimes it query/set transport specific fields like MSI-X vectors of VF. Sometimes device configure its on IMS interrupt.
Something else in future.
So it is really a generic request-response queue.

Quoted 2 lines

[1]
https://lists.oasis-open.org/archives/virtio-comment/202108/msg00025.html

#48 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Parav Pandit
Quoted 51 lines · Parav Pandit
Quoted 38 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 8:39 PM

Quoted 14 lines · Parav Pandit
Quoted 14 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 4:09 PM

Quoted 1 line · Parav Pandit

An unrelated command to AQ in Jason's proposal [1] is about " The

management driver MUST create a managed device by allocating".

Quoted 2 lines

We see that creator of the subfunction is often not the only entity managing

it.

Quoted 3 lines

They being same in new era finding less and less users. So this piece needs more discussion whenever we address that.

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

[1]
https://lists.oasis-open.org/archives/virtio-comment/202108/msg001
36.h
tml

This reminds me. How do AQ commands interact with VF lifecycle?

VF device usage is controlled by the same system which is configuring the VF

via its parent PF device.

Quoted 1 line

So VF device shouldn't be in use. Any configuration change while VF device is

in use will result in failing the AQ command.

Quoted 8 lines
Quoted 7 lines

E.g. can one change number of vectors for an active VF? Need to specify this.

Also, I started worrying about compatibility here. Let's say the msix capability in a VF specifies 16 vectors. Can PF specify 32? If yes how will driver program them?

Yes, PF can change to 32. When VF driver queries the PCI capability, it will

Quoted 8 lines

reflect 32 instead of 16.

Quoted 3 lines
Quoted 2 lines

Can PF specify 8? If yes how do we make sure driver does not attempt to use 16? And what happens if it does?

PF is programming the VF msix capability in the device. So virtio pci driver

operating the PCI VF device cannot access vectors beyond the max value programmed by the PF driver.

Um. Interesting. This means that the msix capability of the VF changes?

Yes.

Quoted 4 lines

Is that in fact spec compliant? Could some OSes cache the value of the capability even if the device is not in active use? E.g. I can see how this might happen in order to map the MSIX tables even before loading the driver.

Quoted 5 lines

PCI subsystem can catch the value before the device driver can load.
Generally a device support intx/msix or intx/msi. So PCI subsystem is not aware what will be used by its upper layer device drivers. So it usually differs such initialization to a later stage until it is actually used.

Whichever OS driver which implements msix configuration, will have to either not cache it or flush+ rebuild the cache.

Seems to contradict what the spec says (below).

Quoted 7 lines
Quoted 7 lines

The spec says:
Depending upon system software policy, system software, device driver
software, or each at
different times or environments may configure a function’s MSI-X
capability and table
structures with suitable vectors.

Quoted 6 lines
Quoted 5 lines

So MSIX canfiguation might not be up to the driver.

We actually ask driver to read back any vector assigned to a VQ so it's possible to fail vector assignment. Maybe that's better.

Virtio driver should not incur any additional complexity in re-reading vector etc.

I think it does this already.

Quoted 2 lines

All the msix config should happen much before drivers gets loaded for the VF.
It is PCI layer of the HV to provide a stable device to virtio device driver which is not undergoing msix table changes, when virtio device driver is operating on it.

Problem is in the guest though. I'm not sure we can rely on this part being part of the driver and not part of the OS.

Signature · 1 line
MST
#14 lore raw

Re: [PATCH 1/5] Add virtio Admin Virtqueue specification

In reply to Jason Wang
Quoted 5 lines · Jason Wang

Exactly, another call for the using the PRS queue instead. But generally speaking, admin virtqueue limit or complicate the functions that can be exported to guest. That's why I suggest to decouple all the possible features out of admin virtqueue, and make it available by both the admin virtqueue and the transport specific method (e.g capability).

I'm not exactly sure what's wrong with starting with a queue, if there's need to also allow passing that over another transport we can add that. In particular, I think it's useful to have a capability to inject requests as if they have been passed through a VQ.
Such a capability would address this need, won't it?

Signature · 1 line
MST
#49 lore raw

RE: [virtio-dev] Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Michael S. Tsirkin
Quoted 14 lines

From: [email protected] <[email protected]> On Behalf Of Michael S. Tsirkin
Sent: Wednesday, January 19, 2022 12:51 PM

Quoted 5 lines
Quoted 1 line

Um. Interesting. This means that the msix capability of the VF changes?

Yes.

Quoted 3 lines

Is that in fact spec compliant? Could some OSes cache the value of the capability even if the device is not in active use? E.g. I can see how this might happen in order to map the MSIX tables even before

loading the driver.

Quoted 3 lines
Quoted 1 line

PCI subsystem can catch the value before the device driver can load. Generally a device support intx/msix or intx/msi. So PCI subsystem is not

Quoted 7 lines

aware what will be used by its upper layer device drivers.

Quoted 3 lines

So it usually differs such initialization to a later stage until it is actually used.

Whichever OS driver which implements msix configuration, will have to

either not cache it or flush+ rebuild the cache.

Seems to contradict what the spec says (below).

No it doesn't. spec covers that dependency is on system software policy, system sw, driver sw. So this system that contains policy, sw, driver sw will implement virtio extension.

In above sentence of "whichever OS driver", it covers all sw components involved in this functionality.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

The spec says:
Depending upon system software policy, system software, device
driver software, or each at
different times or environments may configure a function’s MSI-X
capability and table
structures with suitable vectors.

So MSIX canfiguation might not be up to the driver.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

We actually ask driver to read back any vector assigned to a VQ so it's possible to fail vector assignment. Maybe that's better.

Virtio driver should not incur any additional complexity in re-reading vector

etc.

I think it does this already.

When does it re-read?
I do not follow your point of "ask driver to read back any vector". When do you want to do this?

Quoted 9 lines
Quoted 3 lines

All the msix config should happen much before drivers gets loaded for the VF. It is PCI layer of the HV to provide a stable device to virtio device driver which

is not undergoing msix table changes, when virtio device driver is operating on it.

Problem is in the guest though. I'm not sure we can rely on this part being part of the driver and not part of the OS.

It is part of the system software that consist of virtio driver, pci subsystem and user interface.
I do not follow your comment about "problem is in guest though".
Can you please explain?
VF is simply not available to the guest, when HV has not given it. And when its given, HV doesn’t modify the msix in some random manner.

#50 lore raw

Re: [virtio-dev] Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 6 lines · Parav Pandit
Quoted 4 lines
Quoted 1 line

Virtio driver should not incur any additional complexity in re-reading vector

etc.

I think it does this already.

When does it re-read?
I do not follow your point of "ask driver to read back any vector". When do you want to do this?

After mapping an event to vector, the
driver MUST verify success by reading the Vector field value: on success, the previously written value is returned, and on failure, NO_VECTOR is returned. If a mapping failure is detected, the driver MAY retry mapping with fewer vectors, disable MSI-X or report device failure.

Quoted 11 lines
Quoted 9 lines
Quoted 3 lines

All the msix config should happen much before drivers gets loaded for the VF. It is PCI layer of the HV to provide a stable device to virtio device driver which

is not undergoing msix table changes, when virtio device driver is operating on it.

Problem is in the guest though. I'm not sure we can rely on this part being part of the driver and not part of the OS.

It is part of the system software that consist of virtio driver, pci subsystem and user interface. I do not follow your comment about "problem is in guest though".

sorry I meant host of course.

Quoted 3 lines

Can you please explain?
VF is simply not available to the guest, when HV has not given it. And when its given, HV doesn’t modify the msix in some random manner.

I am concerned that we can not be sure that changing MSIX capability while device is present is safe since spec does not promise
the capability is not read by host at boot. However, given device can instead fail to map events to vectors, even if it is not safe we have other ways to fail gracefully. It's probably a good idea to mention all this in the spec text.

Signature · 1 line
MST
#98 lore raw

Re: [PATCH 4/5] virtio-net: add support for VIRTIO_F_ADMIN_VQ

In reply to Jason Wang
Quoted 8 lines · Jason Wang
Quoted 5 lines

We also need
- something like injecting cvq commands to control rx mode from the admin device
- page fault / dirty page handling

these two seem to call for a vq.

Right, but vq is not necessarily for PF if we had PASID. And with PASID we don't even need a dedicated new cvq.

I don't think it's a good idea to mix transactions from multiple PASIDs on the same vq.

Attaching a PASID to a queue seems more reasonable. cvq is under guest control, so yes I think a separate vq is preferable.

What is true is that with subfunctions you would have PASID per subfunction and then one subfunction for control.

I think a sketch of how things will work with scalable iov can't hurt as part of this proposal. And, I'm not sure we should have so much
flexibility: if there's an interface that works for SRIOV and SIOV then that seems preferable than having distinct transports for SRIOV and SIOV.

Signature · 1 line
MST
#42 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Jason Wang
Quoted 46 lines · Jason Wang
Quoted 44 lines · Michael S. Tsirkin
Quoted 27 lines · Parav Pandit
Quoted 13 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 12:42 PM

Quoted 8 lines · Parav Pandit

1. Use AQ for msix query and config
2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues 3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds) 4. Improve documentation around msix config to link to sriov section of virtio spec 5. Describe error that if VF is bound to the device, admin commands targeting VF can fail, describe this error code

Quoted 3 lines
Quoted 1 line

Did I miss anything?

Better document in spec text just what is the scope for AQ.

Yes, will improve this spec.

Quoted 10 lines
Quoted 1 line

Yet to receive your feedback on group, if/why is it needed and, why/if it must

be in this proposal, what pieces prevents it do as follow-on.

I think this is related to the subfunction usecase or other future usecase. In case of PF/VF grouping is implicit through the SRIOV capability. It would be nice to have things somewhat generic in most of the text though since we already know this will be needed.
E.g. jason sent a proposal for commands to add/delete subfunctions, take a look at it, somehow AQ needs to be extendable to support that functionality too.

Quoted 7 lines

I looked briefly to it. AQ can be used for such purpose. Current proposal adds only msix config piece. But more commands can be added in future.

What I wanted to check with you and other is, do we want command opcode to be 7-bit enough?
#127 is lot of admin commands. 😊
But given virtio spec diversity of transport and device types, I was thinking to keep it 15-bit for future proofing. What do you think?

I agree, we are not short on bits.

Quoted 2 lines

An unrelated command to AQ in Jason's proposal [1] is about " The management driver MUST create a managed device by allocating". We see that creator of the subfunction is often not the only entity managing it.

I think whoever does it can go through the main function driver.

Quoted 3 lines

They being same in new era finding less and less users. So this piece needs more discussion whenever we address that.

Quoted 8 lines
Quoted 1 line
Quoted 1 line

[1] https://lists.oasis-open.org/archives/virtio-comment/202108/msg00136.html

Yes, I do that for dynamic provisioning which seems a requirement (or better to have) for SIOV spec. We can extend or tweak it for static provisioning.

Thanks

So you are basically saying that since with scalable iov we need commands to create subfunctions, let's straight away teach people to use them to manage VFs.
So before a VF can be used, you are asking that people "allocate" it through a PF. Is that right?

I have to say that addresses one concern I just had, which is that it's unclear what is the status of a VF before any commands are issued.

Signature · 1 line
MST
#51 lore raw

RE: [virtio-dev] Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Michael S. Tsirkin
Quoted 12 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Wednesday, January 19, 2022 1:51 PM

Quoted 7 lines · Parav Pandit
Quoted 5 lines
Quoted 2 lines

Virtio driver should not incur any additional complexity in re-reading vector

etc.

I think it does this already.

When does it re-read?
I do not follow your point of "ask driver to read back any vector". When do

Quoted 8 lines

you want to do this?

After mapping an event to vector, the
driver MUST verify success by reading the Vector field value: on success, the previously written value is returned, and on failure, NO_VECTOR is returned. If a mapping failure is detected, the driver MAY retry mapping with fewer vectors, disable MSI-X or report device failure.

Ok I got it now.
But insane HV can attempt to change the value this vector even after this read was successful.
And it will obviously break the VM.
This isn't the usage model.
PF (admin device) user giving VF to VM ( = system software) has to ensure that they don’t give VF to VM while in middle of configuration. We must add it to the spec in v2.

Quoted 22 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

All the msix config should happen much before drivers gets loaded for the

VF.

Quoted 9 lines
Quoted 8 lines
Quoted 2 lines

It is PCI layer of the HV to provide a stable device to virtio device driver which

is not undergoing msix table changes, when virtio device driver is operating on it.

Problem is in the guest though. I'm not sure we can rely on this part being part of the driver and not part of the OS.

It is part of the system software that consist of virtio driver, pci subsystem

and user interface.

Quoted 1 line

I do not follow your comment about "problem is in guest though".

sorry I meant host of course.

Quoted 3 lines

Can you please explain?
VF is simply not available to the guest, when HV has not given it. And when its given, HV doesn’t modify the msix in some random manner.

Quoted 5 lines

I am concerned that we can not be sure that changing MSIX capability while device is present is safe since spec does not promise the capability is not read by host at boot. However, given device can instead fail to map events to vectors, even if it is not safe we have other ways to fail gracefully. It's probably a good idea to mention all this in the spec text.

It is the system who implements virtio spec has to ensure that it doesn't change msix capability while device is use.
Virtio spec should define a minimum expectations from the system such as flushing the cache or no cache or not use the device while undergoing config.

For sure, this will be added to v2.

#22 lore raw

Re: [PATCH 1/5] Add virtio Admin Virtqueue specification

In reply to Michael S. Tsirkin
Quoted 48 lines · Michael S. Tsirkin
Quoted 47 lines · Parav Pandit
Quoted 12 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 12:38 PM

Quoted 1 line

Subfunctions with PASID can be similarly managed by extending device

identification and its MSIX/IMS vector details.

Quoted 7 lines

May be vf_number should be put in the union as,

union device_id {
struct pci_vf vf_id; /* current */
struct pci_sf sf_id; /* future */
};

Quoted 5 lines
Quoted 1 line

So that they both can use command opcode.

device id is not a good name, but yes. However this is why I think we should have a slightly more generic terminology, and more space for these IDs, and then we'd have a specific binding for VFs.

I couldn't think of better name for identifying a PCI VF. But yes have to think better name for sure.

Quoted 28 lines
Quoted 6 lines
Quoted 5 lines

I am not
asking you to add such mechanisms straight away but the current proposal kind of obscures this to the point where I don't see how would we extend it with these things down the road.

Which part in specific make it obscure?

just that the text is not generic. would be nicer if adding new types would involve only changing one or two places

Quoted 7 lines

New device type can be identifiable by above union.

May be a better structure would be in patch-5 is:
Something like below,

struct virtio_admin_pci_virt_property_set {
enum virtio_device_identifier_type type; /* pci pf, pci vf, subfunction

*/

Quoted 5 lines

union virtio_device_identifier {
struct virtio_pci_dev_id pf_vf; /* current */ struct virtio_subfunction sf; /* future */
};
enum virtio_interrupt_type interrupt_type; /* msix, ims=device

specific, intx, something else */

Quoted 5 lines
	union virtio_interrupt_config {
		struct virtio_pci_msix_config msix_config;
	};
};
Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
struct virtio_pci_interrupt_config {
	le16 msix_count;
};

you do not need a union straight away, Simply use something like this "device identifier" everywhere and then add some text explaining that currently it is a VF number and that admin device is a PF.

Unless we reserve some bytes, I fail to see how can it be future compatible for unknown device id type for subfunction.

So reserve some bytes then. 4 should be plenty.

Ok so in V2 we'll use 4 bytes as device identifier to be generic.

We can call it lid (local id) of vlid (virtio local id) ?

Are we ok with one of the above names ?

#23 lore raw

RE: [PATCH 1/5] Add virtio Admin Virtqueue specification

Quoted 3 lines

From: Max Gurtovoy <[email protected]>
Sent: Wednesday, January 19, 2022 5:04 PM

[..]

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 3 lines

struct virtio_admin_pci_virt_property_set {
enum virtio_device_identifier_type type; /* pci pf, pci vf,
subfunction

*/

Quoted 5 lines

union virtio_device_identifier {
struct virtio_pci_dev_id pf_vf; /* current */ struct virtio_subfunction sf; /* future */
};
enum virtio_interrupt_type interrupt_type; /* msix, ims=device

specific, intx, something else */

Quoted 5 lines
	union virtio_interrupt_config {
		struct virtio_pci_msix_config msix_config;
	};
};
Quoted 10 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
struct virtio_pci_interrupt_config {
	le16 msix_count;
};

you do not need a union straight away, Simply use something like this "device identifier" everywhere and then add some text explaining that currently it is a VF number and that admin device is a PF.

Unless we reserve some bytes, I fail to see how can it be future compatible

for unknown device id type for subfunction.

Quoted 1 line

So reserve some bytes then. 4 should be plenty.

I am not comfortable reserving 4 bytes for sf, though it is good option and already in use in one OS for more a year now.

Quoted 6 lines

Ok so in V2 we'll use 4 bytes as device identifier to be generic.

We can call it lid (local id) of vlid (virtio local id) ?

Are we ok with one of the above names ?

I go back to rethink the structure, and don’t see a need to abstract something which is so well defined.

I see need of below structures, how should it be made more abstract without breaking backward compat and without defining as TLV.

struct virtio_admin_pci_vf_interrupt_config {
	/* v1 current */
	le64 property_mask; /* bit 0 valid */
	le16 vf_number;
	le16 msix_count;
};
struct virtio_admin_pci_vf_interrupt_config {
	/* v2 near future, backward compatible */
	le64 property_mask; /* bit 0, 1 valid */
	le16 vf_number;
	le16 msix_count;
	le16 ims_count;
};
struct virtio_admin_pci_sf_interrupt_config {
	/* v3 future, new struct, no need of backward compat */
	le64 property_mask; /* bit 0,1,2, valid */
	le32 sf_number;
	/* is 4 bytes enough to describe sf,
	 * what if community decides uuid to identify sf?
	 * How about we take out device identifier outside of this struct?
	 */
	le16 msix_count;
	le16 ims_count;
	le16 pci_caps; /* pci atomics enable */
};
virtio_unknown_transport_interrupt_config {
	/* vX future */
	le64 property_mask;
	<unknown len> device identifier;
	le16 msix_count;
	le16 ims_count;
};
#24 lore raw

Re: [PATCH 1/5] Add virtio Admin Virtqueue specification

Quoted 31 lines · Parav Pandit
Quoted 2 lines

From: Max Gurtovoy <[email protected]>
Sent: Wednesday, January 19, 2022 5:04 PM

[..]

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 3 lines

struct virtio_admin_pci_virt_property_set {
enum virtio_device_identifier_type type; /* pci pf, pci vf,
subfunction

*/

Quoted 5 lines

union virtio_device_identifier {
struct virtio_pci_dev_id pf_vf; /* current */ struct virtio_subfunction sf; /* future */
};
enum virtio_interrupt_type interrupt_type; /* msix, ims=device

specific, intx, something else */

Quoted 5 lines
	union virtio_interrupt_config {
		struct virtio_pci_msix_config msix_config;
	};
};
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
struct virtio_pci_interrupt_config {
	le16 msix_count;
};

you do not need a union straight away, Simply use something like this "device identifier" everywhere and then add some text explaining that currently it is a VF number and that admin device is a PF.

Unless we reserve some bytes, I fail to see how can it be future compatible

for unknown device id type for subfunction.

Quoted 1 line

So reserve some bytes then. 4 should be plenty.

I am not comfortable reserving 4 bytes for sf, though it is good option and already in use in one OS for more a year now.

Quoted 2 lines

Ok so in V2 we'll use 4 bytes as device identifier to be generic.

Quoted 7 lines
Quoted 4 lines

We can call it lid (local id) of vlid (virtio local id) ?

Are we ok with one of the above names ?

I go back to rethink the structure, and don’t see a need to abstract something which is so well defined.

I see need of below structures, how should it be made more abstract without breaking backward compat and without defining as TLV.

I agree, I don't see why it's not possible to use a different command opcode for vf interrupt configuration and sf interrupt configuration.

We're not short in opcodes and it's very elegant and extendable IMO.

I think the order should be:

1. add adminq to virtio spec with one simple example (say MSIX config for VFs)

2. in parallel submission for admin commands: S-IOV support, num VQs config, feature bits config and more...

The below example emphasizes that the adminq protocol is flexible and easily extendable.

Quoted 36 lines
struct virtio_admin_pci_vf_interrupt_config {
	/* v1 current */
	le64 property_mask; /* bit 0 valid */
	le16 vf_number;
	le16 msix_count;
};
struct virtio_admin_pci_vf_interrupt_config {
	/* v2 near future, backward compatible */
	le64 property_mask; /* bit 0, 1 valid */
	le16 vf_number;
	le16 msix_count;
	le16 ims_count;
};
struct virtio_admin_pci_sf_interrupt_config {
	/* v3 future, new struct, no need of backward compat */
	le64 property_mask; /* bit 0,1,2, valid */
	le32 sf_number;
	/* is 4 bytes enough to describe sf,
	 * what if community decides uuid to identify sf?
	 * How about we take out device identifier outside of this struct?
	 */
	le16 msix_count;
	le16 ims_count;
	le16 pci_caps; /* pci atomics enable */
};
virtio_unknown_transport_interrupt_config {
	/* vX future */
	le64 property_mask;
	<unknown len> device identifier;
	le16 msix_count;
	le16 ims_count;
};
#25 lore raw

Re: [PATCH 1/5] Add virtio Admin Virtqueue specification

Quoted 5 lines · Max Gurtovoy

I agree, I don't see why it's not possible to use a different command opcode for vf interrupt configuration and sf interrupt configuration.

We're not short in opcodes and it's very elegant and extendable IMO.

Quoted 7 lines

I think the order should be:

1. add adminq to virtio spec with one simple example (say MSIX config for VFs)

2. in parallel submission for admin commands: S-IOV support, num VQs config, feature bits config and more...

Up to you for sure but didn't you guys try this already? I think there are concerns such as how this will be extended to support subfunctions. I can't say what do you want to do about that in v2, ignoring them completely is probably not a good way to get more support in the TC. Just my two cents, hope this helps.

Signature · 1 line
MST
#26 lore raw

Re: [PATCH 1/5] Add virtio Admin Virtqueue specification

Quoted 11 lines · Michael S. Tsirkin
Quoted 10 lines · Max Gurtovoy

I agree, I don't see why it's not possible to use a different command opcode for vf interrupt configuration and sf interrupt configuration.

We're not short in opcodes and it's very elegant and extendable IMO.

I think the order should be:

1. add adminq to virtio spec with one simple example (say MSIX config for VFs)

Quoted 7 lines
Quoted 2 lines

2. in parallel submission for admin commands: S-IOV support, num VQs config, feature bits config and more...

Up to you for sure but didn't you guys try this already? I think there are concerns such as how this will be extended to support subfunctions. I can't say what do you want to do about that in v2, ignoring them completely is probably not a good way to get more support in the TC. Just my two cents, hope this helps.

I think that Parav demonstrated the flexibility and extendability of this interface.

And also I think you mentioned that you don't expect us to instrument this solution to this series.

During this discussion we agreed that using admin commands one can manage SRIOV and SIOV, didn't we ?

#52 lore raw

Re: [virtio-dev] Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Parav Pandit
Quoted 2 lines · Parav Pandit

Virtio spec should define a minimum expectations from the system such as flushing the cache or no cache

well one of the things virtio is trying to do is being compatible with a wide range of hypervisors/OSes. it might be tricky to change how they work internally. if we are relying on tricks like this it might be necessary to poke at some popular systems to see what they do. lots of work ...

Signature · 1 line
MST
#53 lore raw

RE: [virtio-dev] Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 11 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Wednesday, January 19, 2022 10:10 PM

Quoted 2 lines · Parav Pandit

Virtio spec should define a minimum expectations from the system such as flushing the cache or no cache

well one of the things virtio is trying to do is being compatible with a wide range of hypervisors/OSes.

We are not breaking any compatibility with this optional enhancement.

Quoted 3 lines

it might be tricky to change how they work
internally. if we are relying on tricks like this it might be necessary to poke at some popular systems to see what they do.

Sure it should work on wide range of hypervisors/OSes. It's a new feature so those will implement when scale is critical for them.

If we consider Linux as popular system than Linux pci subsystem and mlx5 driver already implements it in upstream kernel 5.13. (It doesn't cache it).

Similar implementation for non virtio also exists in _other_ popular OS, which I should avoid annotating here.

#59 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Parav Pandit

Hi Jason,

Quoted 27 lines

From: Parav Pandit
Sent: Wednesday, January 19, 2022 10:18 AM

Quoted 10 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 19, 2022 9:33 AM

It it means IMS, there's already a proposal[1] that introduce MSI commands via the admin virtqueue. And we had similar requirement for virtio-MMIO[2] and managed device or SF [3], so I would rather to introduce IMS (need a better name though) as a basic facility instead of tie it to any specific transport.

IMS of [1] is a interrupt configuration by the virtio driver for the device is it driving, which needs a queue.
So regardless of the device type as PCI PF/VF/SF/ADI, there is desire to have a generic admin queue not attached to device type.
And AQ in this proposal exactly serves this purpose.

Device configuring its own IMS vector vs PCI PF configuring VF's MSI-X max vector count are two different functionality.
Both of these commands can ride on a generic queue.
However the queue is not same, because
PF owns its own admin queue (for vf msix config), VF or SF operates its own admin queue (for IMS config).

Quoted 8 lines

So a good example is,
1. PCI PF configures 8 MSI-X or 16 IMS vectors for the VF using PF_AQ in HV.
2. PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ in GVM.
Both the functions will have AQ feature bit set.

Fair enough, so we have more users of admin queue than just MSI-X config.

If we treat the AQ as any other VQ, than IMS configuration by the virtio driver of #2 for VF or SF cannot be done through AQ. Because AQ needs to be live before setting DRIVER_OK.
And spec mandates "The driver MUST configure the other virtqueue fields before enabling the virtqueue with queue_enable." This includes the vector configuration.
So AQ will operate in polling mode which is not so good.
And it cannot be disabled to update MSI-X/IMS vectore because spec says "The driver MUST NOT write a 0 to queue_enable.".

Make special exception to AQ is equally not good in physical device implementation given all the queue config is located in single config space.

So a better approach for IMS configuration would be to have, limited config registers to bootstrap IMS configuration. Something like,

struct virtio_pci_dev_interrupt_cfg {
le16 max_device_interrupts; /* read-only tells maximum ims interrupts */
le16 refer_index; /* write-only interrupt index to program */
u8 status; /* read only response by device, 0x0 = success, 0x1=busy, other error codes */
u8 enable; /* enable/disable interrupt referred by index */
le16 reserved_pad;
u64 addr; /* write only interrupt addr handle on MSIX TLPs */
u32 data; /* write only interrupt data handle.. */
};
This way, VF, SF can configure large number of vectors before starting the queue and without on-chip resource. Only on-chip resource required per VF is 20 bytes of above cfg registers.

#62 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Parav Pandit
Quoted 14 lines · Parav Pandit
Quoted 10 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 19, 2022 9:33 AM

It it means IMS, there's already a proposal[1] that introduce MSI commands via the admin virtqueue. And we had similar requirement for virtio-MMIO[2] and managed device or SF [3], so I would rather to introduce IMS (need a better name though) as a basic facility instead of tie it to any specific transport.

IMS of [1] is a interrupt configuration by the virtio driver for the device is it driving, which needs a queue. So regardless of the device type as PCI PF/VF/SF/ADI, there is desire to have a generic admin queue not attached to device type. And AQ in this proposal exactly serves this purpose.

Quoted 5 lines

Device configuring its own IMS vector vs PCI PF configuring VF's MSI-X max vector count are two different functionality. Both of these commands can ride on a generic queue.
However the queue is not same, because
PF owns its own admin queue (for vf msix config),
VF or SF operates its own admin queue (for IMS config).

So I think in the next version we need to clarify:

1) is there a single admin virtqueue shared by all the VFs and PF

or

2) per VF/PF admin virtqueue, and how does the driver know how to find the corresponding admin virtqueue

Quoted 5 lines

So a good example is,
1. PCI PF configures 8 MSI-X or 16 IMS vectors for the VF using PF_AQ in HV.
2. PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ in GVM. Both the functions will have AQ feature bit set.

Where did the VF_AQ sit? I guess it belongs to the VF. But if this is true, don't we need some kind of address isolation like PASID?

Quoted 2 lines

Fair enough, so we have more users of admin queue than just MSI-X config.

Well, what I really meant is that we actually have more users of IMS. That's is exactly what virito-mmio wants. In this case introducing admin queue looks too heavyweight for that.

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues 3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds)

I fail to understand the scale/registeres issues. With the one of my previous proposal (device selector), technically we don't even need any config space or BAR for VF or SF by multiplexing the registers for PF.

Scale issue is: when you want to create, query, manipulate hundreds of objects, having shared MMIO register or configuration register, will be too slow.

Ok, this need to be clarified in the commit log. And we need make sure it's not an issue that is only happen for some specific vendor. I was told by some DPU vendors that MMIO register is just DRAM for them.

Quoted 1 line

And additionally such register set doesn't scale to allow sharing large number of bytes as DMA cannot be done.

That's true.

Quoted 3 lines

From physical device perspective, it doesn’t scale because device needs to have those resources ready to answer on MMIO reads and for hundreds to thousand of devices it just cannot do it.
This is one of the reason for birth of IMS.

IMS allows the table to be stored in the memory and cached by the device to have the best scalability. But I had other questions:

1) if we have a single admin virtqueue, there will still be contention in the driver side

2) if we have per vf admin virtqueue, it still doesn't scale since it occupies more hardware resources

Quoted 5 lines
Quoted 4 lines

I do see one advantage is that the admin virtqueue is transport independent (or it could be used as a transport).

I am yet to read the transport part from [1].

Yes, the main goal is to be compatible with SIOV.

Thanks

Quoted 16 lines
Quoted 16 lines
Quoted 2 lines

4. Improve documentation around msix config to link to sriov section of virtio

spec

Quoted 1 line

5. Describe error that if VF is bound to the device, admin commands

targeting VF can fail, describe this error code

Quoted 3 lines

Did I miss anything?

Yet to receive your feedback on group, if/why is it needed and, why/if it must

be in this proposal, what pieces prevents it do as follow-on.

Quoted 2 lines

Cornelia, Jason,
Can you please review current proposal as well before we revise v2?

If I understand correctly, most of the features (except for the admin virtqueue in_order stuffs) are not specific to the admin virtqueue. As discussed in the previous versions, I still think it's better:

Quoted 7 lines
Quoted 5 lines

1) adding sections in the basic device facility or data structure for provisioning and MSI
2) introduce admin virtqueue on top as an device interface for those features

I didn't follow your suggestion. Can you please explain? Specifically "data structure for provisioning and MSI"..

I meant:

There's a chapter "Basic Facilities of a Virtio Device", we can introduce the concepts there like:

1) Managed device and Management device (terminology proposed by Michael), and can use PF and VF as a example

2) Managed device provisioning (the data structure to specify the attributes of a managed device (VF))

3) MSI

And then we can introduced admin virtqueue in either

1) transport part

or

2) PCI transport

In the admin virtqueue, there will be commands to provision and configure MSI.

Quoted 9 lines
Quoted 4 lines

The leaves the chance for future extensions to allow those features to be used by transport specific interface which will benefit for

AQ allows communication (command, response) between driver and device in transport independent way. Sometimes it query/set transport specific fields like MSI-X vectors of VF. Sometimes device configure its on IMS interrupt.
Something else in future.
So it is really a generic request-response queue.

I agree, but I think we can't mandate new features to a specific transport.

Thanks

Quoted 3 lines
Quoted 3 lines

[1]
https://lists.oasis-open.org/archives/virtio-comment/202108/msg00025.html

#15 lore raw

Re: [PATCH 1/5] Add virtio Admin Virtqueue specification

In reply to Michael S. Tsirkin
Quoted 10 lines · Michael S. Tsirkin
Quoted 5 lines · Jason Wang

Exactly, another call for the using the PRS queue instead. But generally speaking, admin virtqueue limit or complicate the functions that can be exported to guest. That's why I suggest to decouple all the possible features out of admin virtqueue, and make it available by both the admin virtqueue and the transport specific method (e.g capability).

I'm not exactly sure what's wrong with starting with a queue, if there's need to also allow passing that over another transport we can add that.

Nothing wrong, but I think we can't mandate the features to be implemented solely via admin virtqueue. Each transport has its own use cases. Making admin virtqueue to be visible in the nested environment will be a challenge.

Quoted 3 lines

In particular, I think it's useful to have a capability to inject requests as if they have been passed through a VQ.
Such a capability would address this need, won't it?

It really depends on the requirement, for simple requests like MSI support in virtio-mmio, introducing such a large change seems sub-optimal than an ad-hoc MSI interface.

Thanks

Quoted 4 lines

--
MST

#43 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Michael S. Tsirkin
Quoted 54 lines · Michael S. Tsirkin
Quoted 52 lines · Jason Wang
Quoted 35 lines · Michael S. Tsirkin
Quoted 27 lines · Parav Pandit
Quoted 13 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 18, 2022 12:42 PM

Quoted 8 lines · Parav Pandit

1. Use AQ for msix query and config
2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues 3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds) 4. Improve documentation around msix config to link to sriov section of virtio spec 5. Describe error that if VF is bound to the device, admin commands targeting VF can fail, describe this error code

Quoted 3 lines
Quoted 1 line

Did I miss anything?

Better document in spec text just what is the scope for AQ.

Yes, will improve this spec.

Quoted 10 lines
Quoted 1 line

Yet to receive your feedback on group, if/why is it needed and, why/if it must

be in this proposal, what pieces prevents it do as follow-on.

I think this is related to the subfunction usecase or other future usecase. In case of PF/VF grouping is implicit through the SRIOV capability. It would be nice to have things somewhat generic in most of the text though since we already know this will be needed.
E.g. jason sent a proposal for commands to add/delete subfunctions, take a look at it, somehow AQ needs to be extendable to support that functionality too.

Quoted 7 lines

I looked briefly to it. AQ can be used for such purpose. Current proposal adds only msix config piece. But more commands can be added in future.

What I wanted to check with you and other is, do we want command opcode to be 7-bit enough?
#127 is lot of admin commands. 😊
But given virtio spec diversity of transport and device types, I was thinking to keep it 15-bit for future proofing. What do you think?

Quoted 10 lines

I agree, we are not short on bits.

Quoted 2 lines

An unrelated command to AQ in Jason's proposal [1] is about " The management driver MUST create a managed device by allocating". We see that creator of the subfunction is often not the only entity managing it.

I think whoever does it can go through the main function driver.

Quoted 4 lines

They being same in new era finding less and less users. So this piece needs more discussion whenever we address that.

[1] https://lists.oasis-open.org/archives/virtio-comment/202108/msg00136.html

Yes, I do that for dynamic provisioning which seems a requirement (or better to have) for SIOV spec. We can extend or tweak it for static provisioning.

Quoted 8 lines
Quoted 2 lines

Thanks

So you are basically saying that since with scalable iov we need commands to create subfunctions, let's straight away teach people to use them to manage VFs.
So before a VF can be used, you are asking that people "allocate" it through a PF. Is that right?

Right.

Quoted 4 lines

I have to say that addresses one concern I just had, which is that it's unclear what is the status of a VF before any commands are issued.

I'm not even sure it's possible, my understanding is that most vendors choose to go with static provisioning via sriov_numvfs. So such dynamic on demand provisioning might be tricky.

For SR-IOV it has another subtle limitation that mandates all VF to have the same device type.

Thanks

Quoted 5 lines

--
MST

#60 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Parav Pandit
Quoted 44 lines · Parav Pandit

Hi Jason,

Quoted 27 lines

From: Parav Pandit
Sent: Wednesday, January 19, 2022 10:18 AM

Quoted 10 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 19, 2022 9:33 AM

It it means IMS, there's already a proposal[1] that introduce MSI commands via the admin virtqueue. And we had similar requirement for virtio-MMIO[2] and managed device or SF [3], so I would rather to introduce IMS (need a better name though) as a basic facility instead of tie it to any specific transport.

IMS of [1] is a interrupt configuration by the virtio driver for the device is it driving, which needs a queue.
So regardless of the device type as PCI PF/VF/SF/ADI, there is desire to have a generic admin queue not attached to device type.
And AQ in this proposal exactly serves this purpose.

Device configuring its own IMS vector vs PCI PF configuring VF's MSI-X max vector count are two different functionality.
Both of these commands can ride on a generic queue.
However the queue is not same, because
PF owns its own admin queue (for vf msix config), VF or SF operates its own admin queue (for IMS config).

Quoted 8 lines

So a good example is,
1. PCI PF configures 8 MSI-X or 16 IMS vectors for the VF using PF_AQ in HV.
2. PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ in GVM.
Both the functions will have AQ feature bit set.

Fair enough, so we have more users of admin queue than just MSI-X config.

If we treat the AQ as any other VQ, than IMS configuration by the virtio driver of #2 for VF or SF cannot be done through AQ. Because AQ needs to be live before setting DRIVER_OK.
And spec mandates "The driver MUST configure the other virtqueue fields before enabling the virtqueue with queue_enable." This includes the vector configuration.
So AQ will operate in polling mode which is not so good.
And it cannot be disabled to update MSI-X/IMS vectore because spec says "The driver MUST NOT write a 0 to queue_enable.".

Quoted 7 lines

Make special exception to AQ is equally not good in physical device implementation given all the queue config is located in single config space.

So a better approach for IMS configuration would be to have, limited config registers to bootstrap IMS configuration. Something like,

struct virtio_pci_dev_interrupt_cfg {
le16 max_device_interrupts; /* read-only tells maximum ims interrupts */

Is it better to use the same terminology with MSI capability like "max_device_vectors"

Quoted 3 lines

le16 refer_index; /* write-only interrupt index to program */
u8 status; /* read only response by device, 0x0 = success, 0x1=busy, other error codes */
u8 enable; /* enable/disable interrupt referred by index */

Any reason we need this assuming we've already had PCI_NO_VECTOR in common cfg? I think what's better to have is the ability to mask and unmask a vector.

Quoted 4 lines

le16 reserved_pad;
u64 addr; /* write only interrupt addr handle on MSIX TLPs */ u32 data; /* write only interrupt data handle.. */
};

Is this better to split the above into different commands?

Thanks

Quoted 2 lines

This way, VF, SF can configure large number of vectors before starting the queue and without on-chip resource. Only on-chip resource required per VF is 20 bytes of above cfg registers.

#63 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Jason Wang

Hi Jason,

Quoted 28 lines

From: Jason Wang <[email protected]>
Sent: Tuesday, January 25, 2022 8:59 AM

Quoted 11 lines · Parav Pandit
Quoted 10 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 19, 2022 9:33 AM

It it means IMS, there's already a proposal[1] that introduce MSI commands via the admin virtqueue. And we had similar requirement for virtio-MMIO[2] and managed device or SF [3], so I would rather to introduce IMS (need a better name though) as a basic facility instead of tie it to any specific transport.

IMS of [1] is a interrupt configuration by the virtio driver for the device is it

driving, which needs a queue.

Quoted 1 line

So regardless of the device type as PCI PF/VF/SF/ADI, there is desire to have a

generic admin queue not attached to device type.

Quoted 3 lines

And AQ in this proposal exactly serves this purpose.

Device configuring its own IMS vector vs PCI PF configuring VF's MSI-X max

vector count are two different functionality.

Quoted 4 lines

Both of these commands can ride on a generic queue. However the queue is not same, because PF owns its own admin queue (for vf msix config), VF or SF operates its own admin queue (for IMS config).

Quoted 9 lines

So I think in the next version we need to clarify:

1) is there a single admin virtqueue shared by all the VFs and PF

or

2) per VF/PF admin virtqueue, and how does the driver know how to find the corresponding admin virtqueue

Admin queue is not per VF.
Lets take concrete examples.
1. So for example, PCI PF can have one AQ.
This AQ carries command to query/config MSI-X vector of VFs.

2. In second example, PCI PF is creating/destroying SFs. This is again done by using the AQ of the PCI PF.

3. A PCI VF has its own AQ to configure some of its own generic attribute, don't know which is that today. May be something that is extremely hard to do over features bit.
Currently proposed v2 doesn't restrict admin queue to be within PCI PF or VF or that matter not limited to other transports.

Quoted 5 lines
Quoted 5 lines

So a good example is,
1. PCI PF configures 8 MSI-X or 16 IMS vectors for the VF using PF_AQ in HV.
2. PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ

Quoted 7 lines

in GVM.

Quoted 1 line

Both the functions will have AQ feature bit set.

Where did the VF_AQ sit? I guess it belongs to the VF. But if this is true, don't we need some kind of address isolation like PASID?

Above one for IMS is not a good example. I replied the reasoning last week for it.

Quoted 9 lines
Quoted 3 lines

Fair enough, so we have more users of admin queue than just MSI-X config.

Well, what I really meant is that we actually have more users of IMS. That's is exactly what virito-mmio wants. In this case introducing admin queue looks too heavyweight for that.

IMS config cannot be done over AQ as described in previous email in this thread.

Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues 3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds)

I fail to understand the scale/registeres issues. With the one of my previous proposal (device selector), technically we don't even need any config space

or

Quoted 2 lines
Quoted 2 lines

BAR for VF or SF by multiplexing the registers for PF.

Quoted 7 lines
Quoted 1 line

Scale issue is: when you want to create, query, manipulate hundreds of

objects, having shared MMIO register or configuration register, will be too slow.

Ok, this need to be clarified in the commit log. And we need make sure it's not an issue that is only happen for some specific vendor.

It is present in the v2 commit log cover letter.
Please let me know if you think it should be in the actual patch commit log.

Quoted 11 lines
Quoted 1 line

And additionally such register set doesn't scale to allow sharing large

number of bytes as DMA cannot be done.

That's true.

Quoted 2 lines

From physical device perspective, it doesn’t scale because device needs to

have those resources ready to answer on MMIO reads and for hundreds to thousand of devices it just cannot do it.

Quoted 9 lines
Quoted 1 line

This is one of the reason for birth of IMS.

IMS allows the table to be stored in the memory and cached by the device to have the best scalability. But I had other questions:

1) if we have a single admin virtqueue, there will still be contention in the driver side

AQ inherently allows out of order commands execution.
It shouldn't face contention. For example 1K depth AQ should be serving hundreds of descriptors commands in parallel for SF creation, VF MSI-X config and more.

Which area/commands etc you think can lead to the contention?

Quoted 3 lines

2) if we have per vf admin virtqueue, it still doesn't scale since it occupies more hardware resources

That is too heavy, and doesn’t scale. Proposal is to not have per vf admin queue. Proposal is to have one admin queue in a virtio device.

Quoted 11 lines
Quoted 3 lines
Quoted 3 lines

I do see one advantage is that the admin virtqueue is transport

independent

Quoted 3 lines
Quoted 2 lines

(or it could be used as a transport).

I am yet to read the transport part from [1].

Yes, the main goal is to be compatible with SIOV.

Admin queue is a command interface transport where higher layer services can be buit. This includes SR-IOV config, SIOV config.
And v2 enables SIOV commands implementation whenever they are ready.

Quoted 32 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

4. Improve documentation around msix config to link to sriov section of

virtio

Quoted 6 lines
Quoted 6 lines

spec

Quoted 1 line

5. Describe error that if VF is bound to the device, admin commands

targeting VF can fail, describe this error code

Quoted 3 lines

Did I miss anything?

Yet to receive your feedback on group, if/why is it needed and, why/if it

must

Quoted 8 lines
Quoted 8 lines

be in this proposal, what pieces prevents it do as follow-on.

Quoted 2 lines

Cornelia, Jason,
Can you please review current proposal as well before we revise v2?

If I understand correctly, most of the features (except for the admin virtqueue in_order stuffs) are not specific to the admin virtqueue. As discussed in the previous versions, I still think it's better:

Quoted 7 lines
Quoted 5 lines

1) adding sections in the basic device facility or data structure for provisioning and MSI
2) introduce admin virtqueue on top as an device interface for those features

I didn't follow your suggestion. Can you please explain? Specifically "data structure for provisioning and MSI"..

I meant:

There's a chapter "Basic Facilities of a Virtio Device", we can introduce the concepts there like:

Quoted 8 lines

1) Managed device and Management device (terminology proposed by Michael), and can use PF and VF as a example

2) Managed device provisioning (the data structure to specify the attributes of a managed device (VF))

3) MSI

Above is good idea. Will revisit v2, if it is not arranged this way.

Quoted 8 lines

And then we can introduced admin virtqueue in either

1) transport part

or

2) PCI transport

It is not specific to PCI transport, and currently it is not a transport either. So admin queue will keep as general entity for admin work.

Quoted 3 lines

In the admin virtqueue, there will be commands to provision and configure MSI.

Please review v2 if it is not arranged this way.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

The leaves the chance for future extensions to allow those features to be used by transport specific interface which will benefit for

AQ allows communication (command, response) between driver and device

Quoted 9 lines

in transport independent way.

Quoted 4 lines

Sometimes it query/set transport specific fields like MSI-X vectors of VF. Sometimes device configure its on IMS interrupt.
Something else in future.
So it is really a generic request-response queue.

I agree, but I think we can't mandate new features to a specific transport.

Certainly. Admin queue is transport independent.
PCI MSI-X configuration is PCI transport specific command, so structures are defined it accordingly. It is similar to struct virtio_pci_cap, struct virtio_pci_common_cfg etc.

Any other transport will have transport specific interrupt configuration. So it will be defined accordingly whenever that occurs. For example, IMS for VF or IMS for SF.

#99 lore raw

Re: [PATCH 4/5] virtio-net: add support for VIRTIO_F_ADMIN_VQ

In reply to Michael S. Tsirkin
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Jason Wang
Quoted 4 lines

We also need
- something like injecting cvq commands to control rx mode from the admin device
- page fault / dirty page handling

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

these two seem to call for a vq.

Right, but vq is not necessarily for PF if we had PASID. And with PASID we don't even need a dedicated new cvq.

I don't think it's a good idea to mix transactions from multiple PASIDs on the same vq.

To be clear, I don't mean to let a single vq use multiple PASIDs.

Quoted 4 lines

Attaching a PASID to a queue seems more reasonable. cvq is under guest control, so yes I think a separate vq is preferable.

Sorry, I don't get here. E.g in the case of virtio-net, it's more than sufficient to assign a dedicated PASID to cvq, any reason for yet another one?

Quoted 3 lines

What is true is that with subfunctions you would have PASID per subfunction and then one subfunction for control.

Well, it's possible, but it's also possible to have everything self contained in a single subfucntion. Then cvq can be assigned to a PASID that is used only for the hypervisor.

Quoted 6 lines

I think a sketch of how things will work with scalable iov can't hurt as part of this proposal. And, I'm not sure we should have so much
flexibility: if there's an interface that works for SRIOV and SIOV then that seems preferable than having distinct transports for SRIOV and SIOV.

Some of my understanding of SR-IOV vs SIOV:

1) SR-IOV doesn't requires a transport, VF use PCI config space; But SIOV requires one
2) SR-IOV doesn't support dynamic on demand provisioning where SIOV can

So I'm not sure how hard it is if we want to unify the management plane of the above two.

Thanks

Quoted 5 lines

--
MST

#61 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Jason Wang
Quoted 59 lines

From: Jason Wang <[email protected]>
Sent: Tuesday, January 25, 2022 9:16 AM

Quoted 35 lines · Parav Pandit

Hi Jason,

Quoted 33 lines

From: Parav Pandit
Sent: Wednesday, January 19, 2022 10:18 AM

Quoted 10 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 19, 2022 9:33 AM

It it means IMS, there's already a proposal[1] that introduce MSI commands via the admin virtqueue. And we had similar requirement for virtio-MMIO[2] and managed device or SF [3], so I would rather to introduce IMS (need a better name though) as a basic facility instead of tie it to any specific transport.

IMS of [1] is a interrupt configuration by the virtio driver for the device is it driving, which needs a queue.
So regardless of the device type as PCI PF/VF/SF/ADI, there is desire to have a generic admin queue not attached to device type. And AQ in this proposal exactly serves this purpose.

Device configuring its own IMS vector vs PCI PF configuring VF's MSI-X max vector count are two different functionality. Both of these commands can ride on a generic queue. However the queue is not same, because PF owns its own admin queue (for vf msix config), VF or SF operates its own admin queue (for IMS config).

So a good example is,
1. PCI PF configures 8 MSI-X or 16 IMS vectors for the VF using PF_AQ in HV.
2. PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ in GVM.
Both the functions will have AQ feature bit set.

Quoted 3 lines
Quoted 2 lines

Fair enough, so we have more users of admin queue than just MSI-X config.

If we treat the AQ as any other VQ, than IMS configuration by the virtio

driver of #2 for VF or SF cannot be done through AQ.

Quoted 2 lines

Because AQ needs to be live before setting DRIVER_OK.
And spec mandates "The driver MUST configure the other virtqueue fields

before enabling the virtqueue with queue_enable."

Quoted 3 lines

This includes the vector configuration.
So AQ will operate in polling mode which is not so good.
And it cannot be disabled to update MSI-X/IMS vectore because spec says

"The driver MUST NOT write a 0 to queue_enable.".

Quoted 2 lines

Make special exception to AQ is equally not good in physical device

implementation given all the queue config is located in single config space.

Quoted 2 lines

So a better approach for IMS configuration would be to have, limited config

registers to bootstrap IMS configuration.

Quoted 2 lines

Something like,

Quoted 9 lines
Quoted 2 lines

struct virtio_pci_dev_interrupt_cfg {
le16 max_device_interrupts; /* read-only tells maximum ims

interrupts

Quoted 1 line

*/

Is it better to use the same terminology with MSI capability like "max_device_vectors"

Yep.

Quoted 11 lines
Quoted 3 lines
	le16 refer_index; /* write-only interrupt index to program */
	u8 status;	/* read only response by device, 0x0 = success,

0x1=busy, other error codes */

Quoted 1 line

u8 enable; /* enable/disable interrupt referred by index */

Any reason we need this assuming we've already had PCI_NO_VECTOR in common cfg? I think what's better to have is the ability to mask and unmask a vector.

Yes. mask/unmask is more appropriate. I just put a high level sketch of what we need to do outside of AQ. NO_VECTOR is something stored inside the queue config.
Above MMIO structure is to enable/disable (mask/unmask) a specific vector.

Quoted 9 lines
Quoted 5 lines

le16 reserved_pad;
u64 addr; /* write only interrupt addr handle on MSIX TLPs */ u32 data; /* write only interrupt data handle.. */
};

Is this better to split the above into different commands?

Probably yes, I think we also need the ability to see if addr + data is needed. I hear in an offline discussion that addr + data is not always necessary and burdensome. So virtio adapting to this flexibility will be probably better.

#100 lore raw

Re: [PATCH 4/5] virtio-net: add support for VIRTIO_F_ADMIN_VQ

In reply to Jason Wang
Quoted 18 lines · Jason Wang
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Jason Wang
Quoted 4 lines

We also need
- something like injecting cvq commands to control rx mode from the admin device
- page fault / dirty page handling

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

these two seem to call for a vq.

Right, but vq is not necessarily for PF if we had PASID. And with PASID we don't even need a dedicated new cvq.

I don't think it's a good idea to mix transactions from multiple PASIDs on the same vq.

To be clear, I don't mean to let a single vq use multiple PASIDs.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

Attaching a PASID to a queue seems more reasonable. cvq is under guest control, so yes I think a separate vq is preferable.

Sorry, I don't get here. E.g in the case of virtio-net, it's more than sufficient to assign a dedicated PASID to cvq, any reason for yet another one?

Well I'm not sure how cheap it is to have an extra PASID. In theory you can share page tables making it not that expensive. In practice is it hard for the MMU to do so? If page tables are not shared extra PASIDs become expensive.

Quoted 17 lines
Quoted 3 lines

What is true is that with subfunctions you would have PASID per subfunction and then one subfunction for control.

Well, it's possible, but it's also possible to have everything self contained in a single subfucntion. Then cvq can be assigned to a PASID that is used only for the hypervisor.

Quoted 6 lines

I think a sketch of how things will work with scalable iov can't hurt as part of this proposal. And, I'm not sure we should have so much
flexibility: if there's an interface that works for SRIOV and SIOV then that seems preferable than having distinct transports for SRIOV and SIOV.

Some of my understanding of SR-IOV vs SIOV:

Quoted 8 lines

1) SR-IOV doesn't requires a transport, VF use PCI config space; But SIOV requires one
2) SR-IOV doesn't support dynamic on demand provisioning where SIOV can

So I'm not sure how hard it is if we want to unify the management plane of the above two.

Thanks

Interesting. So are you fine with a proposal which ignores the PASID things completely then? If yes can we take that discussion to a different thread then? This one is already too long ...

Quoted 6 lines
Quoted 6 lines

--
MST

#64 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Parav Pandit
Quoted 108 lines · Parav Pandit

Hi Jason,

Quoted 27 lines

From: Jason Wang <[email protected]>
Sent: Tuesday, January 25, 2022 8:59 AM

Quoted 11 lines · Parav Pandit
Quoted 10 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 19, 2022 9:33 AM

It it means IMS, there's already a proposal[1] that introduce MSI commands via the admin virtqueue. And we had similar requirement for virtio-MMIO[2] and managed device or SF [3], so I would rather to introduce IMS (need a better name though) as a basic facility instead of tie it to any specific transport.

IMS of [1] is a interrupt configuration by the virtio driver for the device is it

driving, which needs a queue.

Quoted 1 line

So regardless of the device type as PCI PF/VF/SF/ADI, there is desire to have a

generic admin queue not attached to device type.

Quoted 3 lines

And AQ in this proposal exactly serves this purpose.

Device configuring its own IMS vector vs PCI PF configuring VF's MSI-X max

vector count are two different functionality.

Quoted 4 lines

Both of these commands can ride on a generic queue. However the queue is not same, because PF owns its own admin queue (for vf msix config), VF or SF operates its own admin queue (for IMS config).

Quoted 9 lines

So I think in the next version we need to clarify:

1) is there a single admin virtqueue shared by all the VFs and PF

or

2) per VF/PF admin virtqueue, and how does the driver know how to find the corresponding admin virtqueue

Admin queue is not per VF.
Lets take concrete examples.
1. So for example, PCI PF can have one AQ.
This AQ carries command to query/config MSI-X vector of VFs.

2. In second example, PCI PF is creating/destroying SFs. This is again done by using the AQ of the PCI PF.

3. A PCI VF has its own AQ to configure some of its own generic attribute, don't know which is that today. May be something that is extremely hard to do over features bit.
Currently proposed v2 doesn't restrict admin queue to be within PCI PF or VF or that matter not limited to other transports.

Quoted 9 lines
Quoted 3 lines

So a good example is,
1. PCI PF configures 8 MSI-X or 16 IMS vectors for the VF using PF_AQ in HV.
2. PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ

in GVM.

Quoted 1 line

Both the functions will have AQ feature bit set.

Where did the VF_AQ sit? I guess it belongs to the VF. But if this is true, don't we need some kind of address isolation like PASID?

Above one for IMS is not a good example. I replied the reasoning last week for it.

Quoted 6 lines
Quoted 1 line

Fair enough, so we have more users of admin queue than just MSI-X config.

Well, what I really meant is that we actually have more users of IMS. That's is exactly what virito-mmio wants. In this case introducing admin queue looks too heavyweight for that.

IMS config cannot be done over AQ as described in previous email in this thread.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues 3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds)

I fail to understand the scale/registeres issues. With the one of my previous proposal (device selector), technically we don't even need any config space

or

Quoted 2 lines
Quoted 2 lines

BAR for VF or SF by multiplexing the registers for PF.

Quoted 7 lines
Quoted 1 line

Scale issue is: when you want to create, query, manipulate hundreds of

objects, having shared MMIO register or configuration register, will be too slow.

Ok, this need to be clarified in the commit log. And we need make sure it's not an issue that is only happen for some specific vendor.

It is present in the v2 commit log cover letter.
Please let me know if you think it should be in the actual patch commit log.

Quoted 10 lines
Quoted 1 line

And additionally such register set doesn't scale to allow sharing large

number of bytes as DMA cannot be done.

That's true.

Quoted 1 line

From physical device perspective, it doesn’t scale because device needs to

have those resources ready to answer on MMIO reads and for hundreds to thousand of devices it just cannot do it.

Quoted 8 lines
Quoted 1 line

This is one of the reason for birth of IMS.

IMS allows the table to be stored in the memory and cached by the device to have the best scalability. But I had other questions:

1) if we have a single admin virtqueue, there will still be contention in the driver side

AQ inherently allows out of order commands execution.
It shouldn't face contention. For example 1K depth AQ should be serving hundreds of descriptors commands in parallel for SF creation, VF MSI-X config and more.

Quoted 7 lines

Which area/commands etc you think can lead to the contention?

Quoted 3 lines

2) if we have per vf admin virtqueue, it still doesn't scale since it occupies more hardware resources

That is too heavy, and doesn’t scale. Proposal is to not have per vf admin queue. Proposal is to have one admin queue in a virtio device.

Right ? where did we mention something that can imply otherwise ?

Quoted 45 lines
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines

I do see one advantage is that the admin virtqueue is transport

independent

Quoted 3 lines
Quoted 2 lines

(or it could be used as a transport).

I am yet to read the transport part from [1].

Yes, the main goal is to be compatible with SIOV.

Admin queue is a command interface transport where higher layer services can be buit. This includes SR-IOV config, SIOV config.
And v2 enables SIOV commands implementation whenever they are ready.

Quoted 32 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

4. Improve documentation around msix config to link to sriov section of

virtio

Quoted 6 lines
Quoted 6 lines

spec

Quoted 1 line

5. Describe error that if VF is bound to the device, admin commands

targeting VF can fail, describe this error code

Quoted 3 lines

Did I miss anything?

Yet to receive your feedback on group, if/why is it needed and, why/if it

must

Quoted 7 lines
Quoted 7 lines

be in this proposal, what pieces prevents it do as follow-on.

Quoted 2 lines

Cornelia, Jason,
Can you please review current proposal as well before we revise v2?

If I understand correctly, most of the features (except for the admin virtqueue in_order stuffs) are not specific to the admin virtqueue. As discussed in the previous versions, I still think it's better:

Quoted 7 lines
Quoted 5 lines

1) adding sections in the basic device facility or data structure for provisioning and MSI
2) introduce admin virtqueue on top as an device interface for those features

I didn't follow your suggestion. Can you please explain? Specifically "data structure for provisioning and MSI"..

I meant:

There's a chapter "Basic Facilities of a Virtio Device", we can introduce the concepts there like:

1) Managed device and Management device (terminology proposed by Michael), and can use PF and VF as a example

Quoted 6 lines
Quoted 5 lines

2) Managed device provisioning (the data structure to specify the attributes of a managed device (VF))

3) MSI

Above is good idea. Will revisit v2, if it is not arranged this way.

Let me make sure I understand, you would like to see a new chapter under "Basic Facilities of a Virtio Device" that is

called "Device management" and this chapter will explain in few words the concept and it will point to another chapter under "Basic Facilities of a Virtio Device"

that was introduced here "Admin Virtqueues" ?

So you do agree that managing a managed (create/destroy/setup/etc...) will be done using the AQ of the managing device ?

Quoted 35 lines
Quoted 9 lines

And then we can introduced admin virtqueue in either

1) transport part

or

2) PCI transport

It is not specific to PCI transport, and currently it is not a transport either. So admin queue will keep as general entity for admin work.

Quoted 3 lines

In the admin virtqueue, there will be commands to provision and configure MSI.

Please review v2 if it is not arranged this way.

Quoted 12 lines
Quoted 4 lines
Quoted 3 lines

The leaves the chance for future extensions to allow those features to be used by transport specific interface which will benefit for

AQ allows communication (command, response) between driver and device

in transport independent way.

Quoted 4 lines

Sometimes it query/set transport specific fields like MSI-X vectors of VF. Sometimes device configure its on IMS interrupt.
Something else in future.
So it is really a generic request-response queue.

I agree, but I think we can't mandate new features to a specific transport.

Certainly. Admin queue is transport independent.
PCI MSI-X configuration is PCI transport specific command, so structures are defined it accordingly. It is similar to struct virtio_pci_cap, struct virtio_pci_common_cfg etc.

Any other transport will have transport specific interrupt configuration. So it will be defined accordingly whenever that occurs. For example, IMS for VF or IMS for SF.

#65 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 172 lines · Max Gurtovoy
Quoted 106 lines · Parav Pandit

Hi Jason,

Quoted 27 lines

From: Jason Wang <[email protected]>
Sent: Tuesday, January 25, 2022 8:59 AM

Quoted 11 lines · Parav Pandit
Quoted 10 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 19, 2022 9:33 AM

It it means IMS, there's already a proposal[1] that introduce MSI commands via the admin virtqueue. And we had similar requirement for virtio-MMIO[2] and managed device or SF [3], so I would rather to introduce IMS (need a better name though) as a basic facility instead of tie it to any specific transport.

IMS of [1] is a interrupt configuration by the virtio driver for the device is it

driving, which needs a queue.

Quoted 1 line

So regardless of the device type as PCI PF/VF/SF/ADI, there is desire to have a

generic admin queue not attached to device type.

Quoted 3 lines

And AQ in this proposal exactly serves this purpose.

Device configuring its own IMS vector vs PCI PF configuring VF's MSI-X max

vector count are two different functionality.

Quoted 4 lines

Both of these commands can ride on a generic queue. However the queue is not same, because PF owns its own admin queue (for vf msix config), VF or SF operates its own admin queue (for IMS config).

Quoted 9 lines

So I think in the next version we need to clarify:

1) is there a single admin virtqueue shared by all the VFs and PF

or

2) per VF/PF admin virtqueue, and how does the driver know how to find the corresponding admin virtqueue

Admin queue is not per VF.
Lets take concrete examples.
1. So for example, PCI PF can have one AQ.
This AQ carries command to query/config MSI-X vector of VFs.

2. In second example, PCI PF is creating/destroying SFs. This is again done by using the AQ of the PCI PF.

3. A PCI VF has its own AQ to configure some of its own generic attribute, don't know which is that today. May be something that is extremely hard to do over features bit.
Currently proposed v2 doesn't restrict admin queue to be within PCI PF or VF or that matter not limited to other transports.

Quoted 9 lines
Quoted 3 lines

So a good example is,
1. PCI PF configures 8 MSI-X or 16 IMS vectors for the VF using PF_AQ in HV.
2. PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ

in GVM.

Quoted 1 line

Both the functions will have AQ feature bit set.

Where did the VF_AQ sit? I guess it belongs to the VF. But if this is true, don't we need some kind of address isolation like PASID?

Above one for IMS is not a good example. I replied the reasoning last week for it.

Quoted 6 lines
Quoted 1 line

Fair enough, so we have more users of admin queue than just MSI-X config.

Well, what I really meant is that we actually have more users of IMS. That's is exactly what virito-mmio wants. In this case introducing admin queue looks too heavyweight for that.

IMS config cannot be done over AQ as described in previous email in this thread.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues 3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds)

I fail to understand the scale/registeres issues. With the one of my previous proposal (device selector), technically we don't even need any config space

or

Quoted 2 lines
Quoted 2 lines

BAR for VF or SF by multiplexing the registers for PF.

Quoted 7 lines
Quoted 1 line

Scale issue is: when you want to create, query, manipulate hundreds of

objects, having shared MMIO register or configuration register, will be too slow.

Ok, this need to be clarified in the commit log. And we need make sure it's not an issue that is only happen for some specific vendor.

It is present in the v2 commit log cover letter.
Please let me know if you think it should be in the actual patch commit log.

Quoted 10 lines
Quoted 1 line

And additionally such register set doesn't scale to allow sharing large

number of bytes as DMA cannot be done.

That's true.

Quoted 1 line

From physical device perspective, it doesn’t scale because device needs to

have those resources ready to answer on MMIO reads and for hundreds to thousand of devices it just cannot do it.

Quoted 8 lines
Quoted 1 line

This is one of the reason for birth of IMS.

IMS allows the table to be stored in the memory and cached by the device to have the best scalability. But I had other questions:

1) if we have a single admin virtqueue, there will still be contention in the driver side

AQ inherently allows out of order commands execution.
It shouldn't face contention. For example 1K depth AQ should be serving hundreds of descriptors commands in parallel for SF creation, VF MSI-X config and more.

Quoted 6 lines

Which area/commands etc you think can lead to the contention?

Quoted 3 lines

2) if we have per vf admin virtqueue, it still doesn't scale since it occupies more hardware resources

That is too heavy, and doesn’t scale. Proposal is to not have per vf admin queue. Proposal is to have one admin queue in a virtio device.

Right ? where did we mention something that can imply otherwise ?

Quoted 44 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line

I do see one advantage is that the admin virtqueue is transport

independent

Quoted 3 lines
Quoted 2 lines

(or it could be used as a transport).

I am yet to read the transport part from [1].

Yes, the main goal is to be compatible with SIOV.

Admin queue is a command interface transport where higher layer services can be buit. This includes SR-IOV config, SIOV config.
And v2 enables SIOV commands implementation whenever they are ready.

Quoted 32 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

4. Improve documentation around msix config to link to sriov section of

virtio

Quoted 6 lines
Quoted 6 lines

spec

Quoted 1 line

5. Describe error that if VF is bound to the device, admin commands

targeting VF can fail, describe this error code

Quoted 3 lines

Did I miss anything?

Yet to receive your feedback on group, if/why is it needed and, why/if it

must

Quoted 7 lines
Quoted 7 lines

be in this proposal, what pieces prevents it do as follow-on.

Quoted 2 lines

Cornelia, Jason,
Can you please review current proposal as well before we revise v2?

If I understand correctly, most of the features (except for the admin virtqueue in_order stuffs) are not specific to the admin virtqueue. As discussed in the previous versions, I still think it's better:

Quoted 7 lines
Quoted 5 lines

1) adding sections in the basic device facility or data structure for provisioning and MSI
2) introduce admin virtqueue on top as an device interface for those features

I didn't follow your suggestion. Can you please explain? Specifically "data structure for provisioning and MSI"..

I meant:

There's a chapter "Basic Facilities of a Virtio Device", we can introduce the concepts there like:

1) Managed device and Management device (terminology proposed by Michael), and can use PF and VF as a example

Quoted 6 lines
Quoted 5 lines

2) Managed device provisioning (the data structure to specify the attributes of a managed device (VF))

3) MSI

Above is good idea. Will revisit v2, if it is not arranged this way.

Let me make sure I understand, you would like to see a new chapter under "Basic Facilities of a Virtio Device" that is

Quoted 8 lines

called "Device management" and this chapter will explain in few words the concept and it will point to another chapter under "Basic Facilities of a Virtio Device"

that was introduced here "Admin Virtqueues" ?

So you do agree that managing a managed (create/destroy/setup/etc...) will be done using the AQ of the managing device ?

I think Jason asked that the management commands are split from the queue itself, such that they can be implemented in more ways down the road.

Quoted 33 lines
Quoted 33 lines
Quoted 8 lines

And then we can introduced admin virtqueue in either

1) transport part

or

2) PCI transport

It is not specific to PCI transport, and currently it is not a transport either. So admin queue will keep as general entity for admin work.

Quoted 3 lines

In the admin virtqueue, there will be commands to provision and configure MSI.

Please review v2 if it is not arranged this way.

Quoted 12 lines
Quoted 4 lines
Quoted 3 lines

The leaves the chance for future extensions to allow those features to be used by transport specific interface which will benefit for

AQ allows communication (command, response) between driver and device

in transport independent way.

Quoted 4 lines

Sometimes it query/set transport specific fields like MSI-X vectors of VF. Sometimes device configure its on IMS interrupt.
Something else in future.
So it is really a generic request-response queue.

I agree, but I think we can't mandate new features to a specific transport.

Certainly. Admin queue is transport independent.
PCI MSI-X configuration is PCI transport specific command, so structures are defined it accordingly. It is similar to struct virtio_pci_cap, struct virtio_pci_common_cfg etc.

Any other transport will have transport specific interrupt configuration. So it will be defined accordingly whenever that occurs. For example, IMS for VF or IMS for SF.

#77 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Parav Pandit
Quoted 38 lines · Parav Pandit

Hi Jason,

Quoted 27 lines

From: Jason Wang <[email protected]>
Sent: Tuesday, January 25, 2022 8:59 AM

Quoted 11 lines · Parav Pandit
Quoted 10 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 19, 2022 9:33 AM

It it means IMS, there's already a proposal[1] that introduce MSI commands via the admin virtqueue. And we had similar requirement for virtio-MMIO[2] and managed device or SF [3], so I would rather to introduce IMS (need a better name though) as a basic facility instead of tie it to any specific transport.

IMS of [1] is a interrupt configuration by the virtio driver for the device is it

driving, which needs a queue.

Quoted 1 line

So regardless of the device type as PCI PF/VF/SF/ADI, there is desire to have a

generic admin queue not attached to device type.

Quoted 3 lines

And AQ in this proposal exactly serves this purpose.

Device configuring its own IMS vector vs PCI PF configuring VF's MSI-X max

vector count are two different functionality.

Quoted 4 lines

Both of these commands can ride on a generic queue. However the queue is not same, because PF owns its own admin queue (for vf msix config), VF or SF operates its own admin queue (for IMS config).

Quoted 9 lines

So I think in the next version we need to clarify:

1) is there a single admin virtqueue shared by all the VFs and PF

or

2) per VF/PF admin virtqueue, and how does the driver know how to find the corresponding admin virtqueue

Quoted 8 lines

Admin queue is not per VF.
Lets take concrete examples.
1. So for example, PCI PF can have one AQ.
This AQ carries command to query/config MSI-X vector of VFs.

2. In second example, PCI PF is creating/destroying SFs. This is again done by using the AQ of the PCI PF.

3. A PCI VF has its own AQ to configure some of its own generic attribute, don't know which is that today.

So this could be useful if we can create SF on top of VF. But as discussed we'd better to generalize the concept (management device vs managed device).

Quoted 56 lines

May be something that is extremely hard to do over features bit.
Currently proposed v2 doesn't restrict admin queue to be within PCI PF or VF or that matter not limited to other transports.

Quoted 9 lines
Quoted 3 lines

So a good example is,
1. PCI PF configures 8 MSI-X or 16 IMS vectors for the VF using PF_AQ in HV.
2. PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ

in GVM.

Quoted 1 line

Both the functions will have AQ feature bit set.

Where did the VF_AQ sit? I guess it belongs to the VF. But if this is true, don't we need some kind of address isolation like PASID?

Above one for IMS is not a good example. I replied the reasoning last week for it.

Quoted 6 lines
Quoted 1 line

Fair enough, so we have more users of admin queue than just MSI-X config.

Well, what I really meant is that we actually have more users of IMS. That's is exactly what virito-mmio wants. In this case introducing admin queue looks too heavyweight for that.

IMS config cannot be done over AQ as described in previous email in this thread.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues 3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds)

I fail to understand the scale/registeres issues. With the one of my previous proposal (device selector), technically we don't even need any config space

or

Quoted 2 lines
Quoted 2 lines

BAR for VF or SF by multiplexing the registers for PF.

Quoted 7 lines
Quoted 1 line

Scale issue is: when you want to create, query, manipulate hundreds of

objects, having shared MMIO register or configuration register, will be too slow.

Ok, this need to be clarified in the commit log. And we need make sure it's not an issue that is only happen for some specific vendor.

It is present in the v2 commit log cover letter.
Please let me know if you think it should be in the actual patch commit log.

Quoted 15 lines
Quoted 1 line

And additionally such register set doesn't scale to allow sharing large

number of bytes as DMA cannot be done.

That's true.

Quoted 1 line

From physical device perspective, it doesn’t scale because device needs to

have those resources ready to answer on MMIO reads and for hundreds to thousand of devices it just cannot do it.

Quoted 1 line

This is one of the reason for birth of IMS.

IMS allows the table to be stored in the memory and cached by the device to have the best scalability. But I had other questions:

Quoted 7 lines
Quoted 3 lines

1) if we have a single admin virtqueue, there will still be contention in the driver side

AQ inherently allows out of order commands execution.
It shouldn't face contention. For example 1K depth AQ should be serving hundreds of descriptors commands in parallel for SF creation, VF MSI-X config and more.

Which area/commands etc you think can lead to the contention?

Unless the we have self-conainted descriptor which contains per descriptor writeback address. Even if we have OOO, the enqueue and dequeue still needs to be serialized?

Quoted 6 lines
Quoted 4 lines

2) if we have per vf admin virtqueue, it still doesn't scale since it occupies more hardware resources

That is too heavy, and doesn’t scale. Proposal is to not have per vf admin queue. Proposal is to have one admin queue in a virtio device.

Ok.

Quoted 54 lines
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines

I do see one advantage is that the admin virtqueue is transport

independent

Quoted 3 lines
Quoted 2 lines

(or it could be used as a transport).

I am yet to read the transport part from [1].

Yes, the main goal is to be compatible with SIOV.

Admin queue is a command interface transport where higher layer services can be buit. This includes SR-IOV config, SIOV config.
And v2 enables SIOV commands implementation whenever they are ready.

Quoted 29 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

4. Improve documentation around msix config to link to sriov section of

virtio

Quoted 6 lines
Quoted 6 lines

spec

Quoted 1 line

5. Describe error that if VF is bound to the device, admin commands

targeting VF can fail, describe this error code

Quoted 3 lines

Did I miss anything?

Yet to receive your feedback on group, if/why is it needed and, why/if it

must

Quoted 7 lines
Quoted 7 lines

be in this proposal, what pieces prevents it do as follow-on.

Quoted 2 lines

Cornelia, Jason,
Can you please review current proposal as well before we revise v2?

If I understand correctly, most of the features (except for the admin virtqueue in_order stuffs) are not specific to the admin virtqueue. As discussed in the previous versions, I still think it's better:

Quoted 7 lines
Quoted 5 lines

1) adding sections in the basic device facility or data structure for provisioning and MSI
2) introduce admin virtqueue on top as an device interface for those features

I didn't follow your suggestion. Can you please explain? Specifically "data structure for provisioning and MSI"..

I meant:

There's a chapter "Basic Facilities of a Virtio Device", we can introduce the concepts there like:

Quoted 8 lines

1) Managed device and Management device (terminology proposed by Michael), and can use PF and VF as a example

2) Managed device provisioning (the data structure to specify the attributes of a managed device (VF))

3) MSI

Above is good idea. Will revisit v2, if it is not arranged this way.

Quoted 2 lines

And then we can introduced admin virtqueue in either

Quoted 7 lines
Quoted 6 lines

1) transport part

or

2) PCI transport

It is not specific to PCI transport, and currently it is not a transport either.

Kind of, it allows to configure some basic attributes somehow. I think we'd better try not to couple any features to admin virtqueue.

Quoted 6 lines

So admin queue will keep as general entity for admin work.

Quoted 3 lines

In the admin virtqueue, there will be commands to provision and configure MSI.

Please review v2 if it is not arranged this way.

Ok.

Quoted 11 lines
Quoted 11 lines
Quoted 5 lines
Quoted 4 lines

The leaves the chance for future extensions to allow those features to be used by transport specific interface which will benefit for

AQ allows communication (command, response) between driver and device

in transport independent way.

Quoted 4 lines

Sometimes it query/set transport specific fields like MSI-X vectors of VF. Sometimes device configure its on IMS interrupt.
Something else in future.
So it is really a generic request-response queue.

Quoted 8 lines
Quoted 2 lines

I agree, but I think we can't mandate new features to a specific transport.

Certainly. Admin queue is transport independent.
PCI MSI-X configuration is PCI transport specific command, so structures are defined it accordingly. It is similar to struct virtio_pci_cap, struct virtio_pci_common_cfg etc.

Any other transport will have transport specific interrupt configuration. So it will be defined accordingly whenever that occurs. For example, IMS for VF or IMS for SF.

I don't think IMS is PCI specific stuffs, we had similar requests for MMIO.

Thanks

#78 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 53 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 26, 2022 10:35 AM

Quoted 41 lines · Parav Pandit

Hi Jason,

Quoted 30 lines

From: Jason Wang <[email protected]>
Sent: Tuesday, January 25, 2022 8:59 AM

Quoted 4 lines · Parav Pandit
Quoted 4 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 19, 2022 9:33 AM

Quoted 8 lines
Quoted 6 lines

It it means IMS, there's already a proposal[1] that introduce MSI commands via the admin virtqueue. And we had similar requirement for virtio-MMIO[2] and managed device or SF [3], so I would rather to introduce IMS (need a better name though) as a basic facility instead of tie it to any specific transport.

IMS of [1] is a interrupt configuration by the virtio driver for the device is it

driving, which needs a queue.

Quoted 2 lines

So regardless of the device type as PCI PF/VF/SF/ADI, there is desire to have a

generic admin queue not attached to device type.

Quoted 4 lines

And AQ in this proposal exactly serves this purpose.

Device configuring its own IMS vector vs PCI PF configuring VF's MSI-X max

vector count are two different functionality.

Quoted 4 lines

Both of these commands can ride on a generic queue. However the queue is not same, because PF owns its own admin queue (for vf msix config), VF or SF operates its own admin queue (for IMS config).

Quoted 9 lines

So I think in the next version we need to clarify:

1) is there a single admin virtqueue shared by all the VFs and PF

or

2) per VF/PF admin virtqueue, and how does the driver know how to find the corresponding admin virtqueue

Quoted 6 lines

Admin queue is not per VF.
Lets take concrete examples.
1. So for example, PCI PF can have one AQ.
This AQ carries command to query/config MSI-X vector of VFs.

2. In second example, PCI PF is creating/destroying SFs. This is again done by

Quoted 9 lines

using the AQ of the PCI PF.

Quoted 2 lines

3. A PCI VF has its own AQ to configure some of its own generic attribute,

don't know which is that today.

So this could be useful if we can create SF on top of VF. But as discussed we'd better to generalize the concept (management device vs managed device).

It does not matter if the SF is created over PCI PF or VF. Its on top of PCI virtio device. When/if someone creates SF over PCI VF, PCI VF is management device, and PCI SF is managed device.

When/if SF is created over PCI PF, PCI PF is managed device, and PCI SF is managed device.

In either case the AQ on the PCI device is transporting SF create/destroy commands.

Quoted 5 lines
Quoted 2 lines

AQ inherently allows out of order commands execution.
It shouldn't face contention. For example 1K depth AQ should be serving

hundreds of descriptors commands in parallel for SF creation, VF MSI-X config and more.

Quoted 1 line
Quoted 7 lines
Quoted 1 line

Which area/commands etc you think can lead to the contention?

Unless the we have self-conainted descriptor which contains per descriptor writeback address. Even if we have OOO, the enqueue and dequeue still needs to be serialized?

No. we don't need to define any behavior.
When VIRTIO_F_IN_ORDER is not negotiated, the way a VQ behaves, AQ always behaves this way.
And any synchronization to be done is done in the driver like today. Usually when posting descriptors it needs to hold lock for short internal. And this cannot lead to contention, due to the fact that descriptor posting time is very short.

Quoted 75 lines
Quoted 6 lines
Quoted 5 lines

2) if we have per vf admin virtqueue, it still doesn't scale since it occupies more hardware resources

That is too heavy, and doesn’t scale. Proposal is to not have per vf admin

queue.

Quoted 1 line

Proposal is to have one admin queue in a virtio device.

Ok.

Quoted 10 lines
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines

I do see one advantage is that the admin virtqueue is transport

independent

Quoted 3 lines
Quoted 2 lines

(or it could be used as a transport).

I am yet to read the transport part from [1].

Yes, the main goal is to be compatible with SIOV.

Admin queue is a command interface transport where higher layer services

can be buit.

Quoted 51 lines

This includes SR-IOV config, SIOV config.
And v2 enables SIOV commands implementation whenever they are ready.

Quoted 32 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

4. Improve documentation around msix config to link to sriov section of

virtio

Quoted 8 lines
Quoted 8 lines

spec

Quoted 2 lines

5. Describe error that if VF is bound to the device, admin commands

targeting VF can fail, describe this error code

Quoted 4 lines

Did I miss anything?

Yet to receive your feedback on group, if/why is it needed and, why/if it

must

Quoted 7 lines
Quoted 7 lines

be in this proposal, what pieces prevents it do as follow-on.

Quoted 2 lines

Cornelia, Jason,
Can you please review current proposal as well before we revise v2?

If I understand correctly, most of the features (except for the admin virtqueue in_order stuffs) are not specific to the admin virtqueue. As discussed in the previous versions, I still think it's better:

Quoted 7 lines
Quoted 5 lines

1) adding sections in the basic device facility or data structure for provisioning and MSI
2) introduce admin virtqueue on top as an device interface for those features

I didn't follow your suggestion. Can you please explain? Specifically "data structure for provisioning and MSI"..

I meant:

There's a chapter "Basic Facilities of a Virtio Device", we can introduce the concepts there like:

Quoted 8 lines

1) Managed device and Management device (terminology proposed by Michael), and can use PF and VF as a example

2) Managed device provisioning (the data structure to specify the attributes of a managed device (VF))

3) MSI

Above is good idea. Will revisit v2, if it is not arranged this way.

Quoted 6 lines

And then we can introduced admin virtqueue in either

1) transport part

or

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

2) PCI transport

It is not specific to PCI transport, and currently it is not a transport either.

Kind of, it allows to configure some basic attributes somehow. I think we'd better try not to couple any features to admin virtqueue.

I am fine by defining virtio_mgmt_cmd that somehow can be issued without the admin queue.
For example, struct virtio_fs_req is detached from the request queue, but only way it can be issued today is with request queue. So we can draft the specification this way.

But I repeatedly miss to see an explanation why is that needed.
Where in the recent spec a new queue is added that has request structure detached from queue. I would like to see reference to the spec that indicates that
a. struct virtio_fs_req can be issued by other means other than request queue.
b. Currently the negotiation is done by so and so feature bit to do so via a request queue. c. "hence down the road something else can be used to carry struct virtio_fs_req instead of request queue".

And that will give good explanation why admin queue should follow some recently added queue which has structure detached from the queue. (not just in form of structure name, but also in form on feature negotiation plumbing etc).

Otherwise detach mgmt. cmd from admin queue is vague requirement to me, that doesn’t require detachment.

Quoted 11 lines
Quoted 2 lines

Certainly. Admin queue is transport independent.
PCI MSI-X configuration is PCI transport specific command, so structures are

defined it accordingly.

Quoted 3 lines

It is similar to struct virtio_pci_cap, struct virtio_pci_common_cfg etc.

Any other transport will have transport specific interrupt configuration. So it

will be defined accordingly whenever that occurs.

Quoted 1 line

For example, IMS for VF or IMS for SF.

I don't think IMS is PCI specific stuffs, we had similar requests for MMIO.

Sure, but even for that there will be SF specific command for IMS configuration. This command will have main difference from VF will be the SF identifier vs VF identifier.

#79 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 63 lines · Parav Pandit
Quoted 54 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 26, 2022 10:35 AM

Quoted 41 lines · Parav Pandit

Hi Jason,

Quoted 30 lines

From: Jason Wang <[email protected]>
Sent: Tuesday, January 25, 2022 8:59 AM

Quoted 4 lines · Parav Pandit
Quoted 4 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 19, 2022 9:33 AM

Quoted 8 lines
Quoted 6 lines

It it means IMS, there's already a proposal[1] that introduce MSI commands via the admin virtqueue. And we had similar requirement for virtio-MMIO[2] and managed device or SF [3], so I would rather to introduce IMS (need a better name though) as a basic facility instead of tie it to any specific transport.

IMS of [1] is a interrupt configuration by the virtio driver for the device is it

driving, which needs a queue.

Quoted 2 lines

So regardless of the device type as PCI PF/VF/SF/ADI, there is desire to have a

generic admin queue not attached to device type.

Quoted 4 lines

And AQ in this proposal exactly serves this purpose.

Device configuring its own IMS vector vs PCI PF configuring VF's MSI-X max

vector count are two different functionality.

Quoted 4 lines

Both of these commands can ride on a generic queue. However the queue is not same, because PF owns its own admin queue (for vf msix config), VF or SF operates its own admin queue (for IMS config).

Quoted 9 lines

So I think in the next version we need to clarify:

1) is there a single admin virtqueue shared by all the VFs and PF

or

2) per VF/PF admin virtqueue, and how does the driver know how to find the corresponding admin virtqueue

Quoted 6 lines

Admin queue is not per VF.
Lets take concrete examples.
1. So for example, PCI PF can have one AQ.
This AQ carries command to query/config MSI-X vector of VFs.

2. In second example, PCI PF is creating/destroying SFs. This is again done by

Quoted 9 lines

using the AQ of the PCI PF.

Quoted 2 lines

3. A PCI VF has its own AQ to configure some of its own generic attribute,

don't know which is that today.

So this could be useful if we can create SF on top of VF. But as discussed we'd better to generalize the concept (management device vs managed device).

Quoted 6 lines

It does not matter if the SF is created over PCI PF or VF. Its on top of PCI virtio device. When/if someone creates SF over PCI VF, PCI VF is management device, and PCI SF is managed device.

When/if SF is created over PCI PF, PCI PF is managed device, and PCI SF is managed device.

In either case the AQ on the PCI device is transporting SF create/destroy commands.

That's exactly what I meant.

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines

AQ inherently allows out of order commands execution.
It shouldn't face contention. For example 1K depth AQ should be serving

hundreds of descriptors commands in parallel for SF creation, VF MSI-X config and more.

Quoted 2 lines

Which area/commands etc you think can lead to the contention?

Quoted 8 lines
Quoted 4 lines

Unless the we have self-conainted descriptor which contains per descriptor writeback address. Even if we have OOO, the enqueue and dequeue still needs to be serialized?

No. we don't need to define any behavior.
When VIRTIO_F_IN_ORDER is not negotiated, the way a VQ behaves, AQ always behaves this way.
And any synchronization to be done is done in the driver like today. Usually when posting descriptors it needs to hold lock for short internal. And this cannot lead to contention, due to the fact that descriptor posting time is very short.

Probably but it really depends on the magnitude of the objects that you want to manage via the admin virtqueue. 1K queue size may work for 1K objects but not for 10K or 100K.

The lock is not the only thing that needs to care, the (busy) waiting for the completion of the command may still take time.

Quoted 95 lines
Quoted 76 lines
Quoted 7 lines
Quoted 6 lines

2) if we have per vf admin virtqueue, it still doesn't scale since it occupies more hardware resources

That is too heavy, and doesn’t scale. Proposal is to not have per vf admin

queue.

Quoted 1 line

Proposal is to have one admin queue in a virtio device.

Ok.

Quoted 10 lines
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines

I do see one advantage is that the admin virtqueue is transport

independent

Quoted 3 lines
Quoted 2 lines

(or it could be used as a transport).

I am yet to read the transport part from [1].

Yes, the main goal is to be compatible with SIOV.

Admin queue is a command interface transport where higher layer services

can be buit.

Quoted 51 lines

This includes SR-IOV config, SIOV config.
And v2 enables SIOV commands implementation whenever they are ready.

Quoted 32 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

4. Improve documentation around msix config to link to sriov section of

virtio

Quoted 8 lines
Quoted 8 lines

spec

Quoted 2 lines

5. Describe error that if VF is bound to the device, admin commands

targeting VF can fail, describe this error code

Quoted 4 lines

Did I miss anything?

Yet to receive your feedback on group, if/why is it needed and, why/if it

must

Quoted 7 lines
Quoted 7 lines

be in this proposal, what pieces prevents it do as follow-on.

Quoted 2 lines

Cornelia, Jason,
Can you please review current proposal as well before we revise v2?

If I understand correctly, most of the features (except for the admin virtqueue in_order stuffs) are not specific to the admin virtqueue. As discussed in the previous versions, I still think it's better:

Quoted 7 lines
Quoted 5 lines

1) adding sections in the basic device facility or data structure for provisioning and MSI
2) introduce admin virtqueue on top as an device interface for those features

I didn't follow your suggestion. Can you please explain? Specifically "data structure for provisioning and MSI"..

I meant:

There's a chapter "Basic Facilities of a Virtio Device", we can introduce the concepts there like:

Quoted 8 lines

1) Managed device and Management device (terminology proposed by Michael), and can use PF and VF as a example

2) Managed device provisioning (the data structure to specify the attributes of a managed device (VF))

3) MSI

Above is good idea. Will revisit v2, if it is not arranged this way.

Quoted 6 lines

And then we can introduced admin virtqueue in either

1) transport part

or

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

2) PCI transport

It is not specific to PCI transport, and currently it is not a transport either.

Kind of, it allows to configure some basic attributes somehow. I think we'd better try not to couple any features to admin virtqueue.

I am fine by defining virtio_mgmt_cmd that somehow can be issued without the admin queue.
For example, struct virtio_fs_req is detached from the request queue, but only way it can be issued today is with request queue. So we can draft the specification this way.

But I repeatedly miss to see an explanation why is that needed.
Where in the recent spec a new queue is added that has request structure detached from queue. I would like to see reference to the spec that indicates that
a. struct virtio_fs_req can be issued by other means other than request queue.
b. Currently the negotiation is done by so and so feature bit to do so via a request queue. c. "hence down the road something else can be used to carry struct virtio_fs_req instead of request queue".

Quoted 4 lines

And that will give good explanation why admin queue should follow some recently added queue which has structure detached from the queue. (not just in form of structure name, but also in form on feature negotiation plumbing etc).

Otherwise detach mgmt. cmd from admin queue is vague requirement to me, that doesn’t require detachment.

So what I meant is not specific to any type of device. Device specific operations should be done via virtqueue.

What I see is, we should not limit the interface for the device independent basic device facility to be admin virtqueue only:

E.g for IMS, we should allow it to be configured with various ways

1) transport independent way: e.g admin virtqueue (which will be eventually became another transport)

or

2) transport specific way, E.g a simple PCI(e) capability or MMIO registeres.

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

Certainly. Admin queue is transport independent.
PCI MSI-X configuration is PCI transport specific command, so structures are

defined it accordingly.

Quoted 2 lines

It is similar to struct virtio_pci_cap, struct virtio_pci_common_cfg etc.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Any other transport will have transport specific interrupt configuration. So it

will be defined accordingly whenever that occurs.

Quoted 1 line

For example, IMS for VF or IMS for SF.

I don't think IMS is PCI specific stuffs, we had similar requests for MMIO.

Sure, but even for that there will be SF specific command for IMS configuration. This command will have main difference from VF will be the SF identifier vs VF identifier.

I think it's not hard to have a single identifier and just say it's transport specific? Or simply reserving IDs for VF.

Thanks

#101 lore raw

Re: [PATCH 4/5] virtio-net: add support for VIRTIO_F_ADMIN_VQ

In reply to Michael S. Tsirkin
Quoted 24 lines · Michael S. Tsirkin
Quoted 22 lines · Jason Wang
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Jason Wang
Quoted 4 lines

We also need
- something like injecting cvq commands to control rx mode from the admin device
- page fault / dirty page handling

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

these two seem to call for a vq.

Right, but vq is not necessarily for PF if we had PASID. And with PASID we don't even need a dedicated new cvq.

I don't think it's a good idea to mix transactions from multiple PASIDs on the same vq.

To be clear, I don't mean to let a single vq use multiple PASIDs.

Quoted 4 lines

Attaching a PASID to a queue seems more reasonable. cvq is under guest control, so yes I think a separate vq is preferable.

Quoted 7 lines
Quoted 3 lines

Sorry, I don't get here. E.g in the case of virtio-net, it's more than sufficient to assign a dedicated PASID to cvq, any reason for yet another one?

Well I'm not sure how cheap it is to have an extra PASID. In theory you can share page tables making it not that expensive.

I think it should not be expensive since PASID is per RID according to the PCIe spec.

Quoted 2 lines

In practice is it hard for the MMU to do so?
If page tables are not shared extra PASIDs become expensive.

Why? For CVQ, we don't need sharing page tables, just maintaining one dedicated buffer for command forwarding is sufficient.

Quoted 23 lines
Quoted 23 lines
Quoted 5 lines

What is true is that with subfunctions you would have PASID per subfunction and then one subfunction for control.

Well, it's possible, but it's also possible to have everything self contained in a single subfucntion. Then cvq can be assigned to a PASID that is used only for the hypervisor.

Quoted 6 lines

I think a sketch of how things will work with scalable iov can't hurt as part of this proposal. And, I'm not sure we should have so much
flexibility: if there's an interface that works for SRIOV and SIOV then that seems preferable than having distinct transports for SRIOV and SIOV.

Some of my understanding of SR-IOV vs SIOV:

1) SR-IOV doesn't requires a transport, VF use PCI config space; But SIOV requires one
2) SR-IOV doesn't support dynamic on demand provisioning where SIOV can

Quoted 7 lines
Quoted 4 lines

So I'm not sure how hard it is if we want to unify the management plane of the above two.

Thanks

Interesting. So are you fine with a proposal which ignores the PASID things completely then?

I'm fine, just a note that:

The main advantages of using admin virtqueue in another device (PF) is that the DMA is isolated, but with the help of PASID, there's no need to do that and we will have a better interface for nesting.

Thanks

Quoted 11 lines

If yes can we take that discussion to
a different thread then? This one is already too long ...

Quoted 6 lines
Quoted 6 lines

--
MST

#80 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Jason Wang
Quoted 9 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 26, 2022 11:15 AM

Quoted 1 line

It does not matter if the SF is created over PCI PF or VF. Its on top of PCI virtio

device.

Quoted 1 line

When/if someone creates SF over PCI VF, PCI VF is management device, and

PCI SF is managed device.

Quoted 1 line
Quoted 7 lines
Quoted 1 line

When/if SF is created over PCI PF, PCI PF is managed device, and PCI SF is

managed device.

Quoted 2 lines

In either case the AQ on the PCI device is transporting SF create/destroy

commands.

That's exactly what I meant.

Ok. cool. So we are in sync here. :)

Quoted 5 lines

Probably but it really depends on the magnitude of the objects that you want to manage via the admin virtqueue. 1K queue size may work for 1K objects but not for 10K or 100K.

We can have higher queue depth.
Not sure if all 10K will be active at same time, even though total 10K or 100K devices are there. We don’t see the same in current Linux subfunctions users.

Quoted 2 lines

The lock is not the only thing that needs to care, the (busy) waiting for the completion of the command may still take time.

There is no need for busy waiting for completion.
Its admin command issued from the process context, it should be like blk request. When completion arrives, notifier will awake the caller.

Quoted 21 lines
Quoted 1 line

I am fine by defining virtio_mgmt_cmd that somehow can be issued without

the admin queue.

Quoted 1 line

For example, struct virtio_fs_req is detached from the request queue, but

only way it can be issued today is with request queue.

Quoted 4 lines

So we can draft the specification this way.

But I repeatedly miss to see an explanation why is that needed. Where in the recent spec a new queue is added that has request structure

detached from queue.

Quoted 3 lines

I would like to see reference to the spec that indicates that a. struct virtio_fs_req can be issued by other means other than request queue. b. Currently the negotiation is done by so and so feature bit to do so via a

request queue.

Quoted 1 line

c. "hence down the road something else can be used to carry struct

virtio_fs_req instead of request queue".

Quoted 2 lines

And that will give good explanation why admin queue should follow some

recently added queue which has structure detached from the queue.

Quoted 1 line

(not just in form of structure name, but also in form on feature negotiation

plumbing etc).

Quoted 1 line
Quoted 8 lines
Quoted 1 line

Otherwise detach mgmt. cmd from admin queue is vague requirement to

me, that doesn’t require detachment.

So what I meant is not specific to any type of device. Device specific operations should be done via virtqueue.

What I see is, we should not limit the interface for the device independent basic device facility to be admin virtqueue only:

Can you explain, why?

Quoted 3 lines

E.g for IMS, we should allow it to be configured with various ways

IMS configuration is very abstract.
Lets talk specific.
I want to make sure when you say IMS configuration,

Do you me HV is configuring IMS number of vectors for the VF/SF? If it's this, than, it is similar to how HV provision MSIX for a VF.

Or you mean, a guest driver of VF or SF is configuring its IMS to later consume for the VQ?
If its this, than I explained that admin queue is not the vehicle to do so, and we discussed the other structure yday.

Quoted 3 lines

1) transport independent way: e.g admin virtqueue (which will be eventually became another transport)

IMS by guest driver cannot be configured by AQ.

Quoted 4 lines

or

2) transport specific way, E.g a simple PCI(e) capability or MMIO registeres.

This is practical.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 4 lines

Certainly. Admin queue is transport independent. PCI MSI-X configuration is PCI transport specific command, so structures are

defined it accordingly.

Quoted 4 lines

It is similar to struct virtio_pci_cap, struct virtio_pci_common_cfg etc.

Any other transport will have transport specific interrupt configuration. So it

will be defined accordingly whenever that occurs.

Quoted 1 line

For example, IMS for VF or IMS for SF.

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

I don't think IMS is PCI specific stuffs, we had similar requests for MMIO.

Sure, but even for that there will be SF specific command for IMS

configuration.

Quoted 1 line

This command will have main difference from VF will be the SF identifier vs

VF identifier.

I think it's not hard to have a single identifier and just say it's transport specific?

It is hard when SFs are not defined.

Quoted 1 line

Or simply reserving IDs for VF.

When SF are not defined, it doesn’t make sense to reserve any bytes for it. Linux has 4 bytes SF identifier.
Community might go UUID way or some other way.
We cannot define arbitrary bytes that may/may not be enough.

When SF will be defined, it will anyway have sf identifier and it will be super easy to define new vector configuration structure for SF. Let's not overload VF MSI-X configuration proposal to be intermix with SF.

#81 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 20 lines · Parav Pandit
Quoted 10 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 26, 2022 11:15 AM

Quoted 1 line

It does not matter if the SF is created over PCI PF or VF. Its on top of PCI virtio

device.

Quoted 1 line

When/if someone creates SF over PCI VF, PCI VF is management device, and

PCI SF is managed device.

Quoted 1 line
Quoted 7 lines
Quoted 1 line

When/if SF is created over PCI PF, PCI PF is managed device, and PCI SF is

managed device.

Quoted 2 lines

In either case the AQ on the PCI device is transporting SF create/destroy

commands.

That's exactly what I meant.

Ok. cool. So we are in sync here. :)

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

Probably but it really depends on the magnitude of the objects that you want to manage via the admin virtqueue. 1K queue size may work for 1K objects but not for 10K or 100K.

We can have higher queue depth.
Not sure if all 10K will be active at same time, even though total 10K or 100K devices are there. We don’t see the same in current Linux subfunctions users.

Not specific to this proposal but we see at least 10K+ requirement.

Quoted 4 lines
Quoted 3 lines

The lock is not the only thing that needs to care, the (busy) waiting for the completion of the command may still take time.

There is no need for busy waiting for completion.

Yes, that's why I put busy in the brace.

Quoted 25 lines

Its admin command issued from the process context, it should be like blk request. When completion arrives, notifier will awake the caller.

Quoted 22 lines
Quoted 1 line

I am fine by defining virtio_mgmt_cmd that somehow can be issued without

the admin queue.

Quoted 1 line

For example, struct virtio_fs_req is detached from the request queue, but

only way it can be issued today is with request queue.

Quoted 4 lines

So we can draft the specification this way.

But I repeatedly miss to see an explanation why is that needed. Where in the recent spec a new queue is added that has request structure

detached from queue.

Quoted 3 lines

I would like to see reference to the spec that indicates that a. struct virtio_fs_req can be issued by other means other than request queue. b. Currently the negotiation is done by so and so feature bit to do so via a

request queue.

Quoted 1 line

c. "hence down the road something else can be used to carry struct

virtio_fs_req instead of request queue".

Quoted 2 lines

And that will give good explanation why admin queue should follow some

recently added queue which has structure detached from the queue.

Quoted 1 line

(not just in form of structure name, but also in form on feature negotiation

plumbing etc).

Quoted 2 lines

Otherwise detach mgmt. cmd from admin queue is vague requirement to

Quoted 8 lines
Quoted 7 lines

me, that doesn’t require detachment.

So what I meant is not specific to any type of device. Device specific operations should be done via virtqueue.

What I see is, we should not limit the interface for the device independent basic device facility to be admin virtqueue only:

Can you explain, why?

For

1) the vendor and transport that doesn't want to use admin virtqueue
2) a more simple interface for L1

Quoted 10 lines
Quoted 4 lines

E.g for IMS, we should allow it to be configured with various ways

IMS configuration is very abstract.
Lets talk specific.
I want to make sure when you say IMS configuration,

Do you me HV is configuring IMS number of vectors for the VF/SF? If it's this, than, it is similar to how HV provision MSIX for a VF.

It can be done by introducing a capability in the PF?

struct msix_provision {
u32 device_select;
u16 msix_vectors;
u16 padding;
};

Quoted 3 lines

Or you mean, a guest driver of VF or SF is configuring its IMS to later consume for the VQ?
If its this, than I explained that admin queue is not the vehicle to do so, and we discussed the other structure yday.

Yes, I guess that's the nesting case I mentioned above.

Quoted 5 lines
Quoted 4 lines

1) transport independent way: e.g admin virtqueue (which will be eventually became another transport)

IMS by guest driver cannot be configured by AQ.

Yes, that's one point.

Quoted 6 lines
Quoted 5 lines

or

2) transport specific way, E.g a simple PCI(e) capability or MMIO registeres.

This is practical.

Right.

Quoted 23 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 5 lines

Certainly. Admin queue is transport independent. PCI MSI-X configuration is PCI transport specific command, so structures are

defined it accordingly.

Quoted 4 lines

It is similar to struct virtio_pci_cap, struct virtio_pci_common_cfg etc.

Any other transport will have transport specific interrupt configuration. So it

will be defined accordingly whenever that occurs.

Quoted 1 line

For example, IMS for VF or IMS for SF.

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

I don't think IMS is PCI specific stuffs, we had similar requests for MMIO.

Sure, but even for that there will be SF specific command for IMS

configuration.

Quoted 1 line

This command will have main difference from VF will be the SF identifier vs

VF identifier.

I think it's not hard to have a single identifier and just say it's transport specific?

It is hard when SFs are not defined.

Quoted 8 lines
Quoted 1 line

Or simply reserving IDs for VF.

When SF are not defined, it doesn’t make sense to reserve any bytes for it. Linux has 4 bytes SF identifier.
Community might go UUID way or some other way.
We cannot define arbitrary bytes that may/may not be enough.

When SF will be defined, it will anyway have sf identifier and it will be super easy to define new vector configuration structure for SF. Let's not overload VF MSI-X configuration proposal to be intermix with SF.

That's fine.

Thanks

#82 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 86 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 26, 2022 11:36 AM

Quoted 24 lines · Parav Pandit
Quoted 14 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 26, 2022 11:15 AM

Quoted 2 lines

It does not matter if the SF is created over PCI PF or VF. Its on top of PCI virtio

device.

Quoted 2 lines

When/if someone creates SF over PCI VF, PCI VF is management device, and

PCI SF is managed device.

Quoted 3 lines

When/if SF is created over PCI PF, PCI PF is managed device, and PCI SF is

Quoted 7 lines

managed device.

Quoted 3 lines

In either case the AQ on the PCI device is transporting SF create/destroy

commands.

That's exactly what I meant.

Ok. cool. So we are in sync here. :)

Quoted 1 line
Quoted 6 lines
Quoted 4 lines

Probably but it really depends on the magnitude of the objects that you want to manage via the admin virtqueue. 1K queue size may work for 1K objects but not for 10K or 100K.

We can have higher queue depth.
Not sure if all 10K will be active at same time, even though total 10K or 100K

devices are there.

Quoted 1 line

We don’t see the same in current Linux subfunctions users.

Not specific to this proposal but we see at least 10K+ requirement.

Quoted 4 lines
Quoted 3 lines

The lock is not the only thing that needs to care, the (busy) waiting for the completion of the command may still take time.

There is no need for busy waiting for completion.

Yes, that's why I put busy in the brace.

Quoted 1 line

Its admin command issued from the process context, it should be like blk

request.

Quoted 16 lines

When completion arrives, notifier will awake the caller.

Quoted 14 lines
Quoted 2 lines

I am fine by defining virtio_mgmt_cmd that somehow can be issued without

the admin queue.

Quoted 2 lines

For example, struct virtio_fs_req is detached from the request queue, but

only way it can be issued today is with request queue.

Quoted 5 lines

So we can draft the specification this way.

But I repeatedly miss to see an explanation why is that needed. Where in the recent spec a new queue is added that has request structure

detached from queue.

Quoted 2 lines

I would like to see reference to the spec that indicates that a. struct virtio_fs_req can be issued by other means other than request

queue.

Quoted 20 lines
Quoted 20 lines
Quoted 2 lines

b. Currently the negotiation is done by so and so feature bit to do so via a

request queue.

Quoted 1 line

c. "hence down the road something else can be used to carry struct

virtio_fs_req instead of request queue".

Quoted 3 lines

And that will give good explanation why admin queue should follow some

recently added queue which has structure detached from the queue.

Quoted 2 lines

(not just in form of structure name, but also in form on feature negotiation

plumbing etc).

Quoted 3 lines

Otherwise detach mgmt. cmd from admin queue is vague requirement to

me, that doesn’t require detachment.

So what I meant is not specific to any type of device. Device specific operations should be done via virtqueue.

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

What I see is, we should not limit the interface for the device independent basic device facility to be admin virtqueue only:

Can you explain, why?

For

1) the vendor and transport that doesn't want to use admin virtqueue

It is not the choice of vendor to use admin virtqueue or not. It is the spec definition.

Why a transport doesn’t want to use admin queue?
I don’t follow why virtio fs device wants to use something other than request queue to transport virtio_fs_req.

Quoted 1 line

2) a more simple interface for L1

I don’t see virtqueue as complicated object which exists for 10+ years now and in use by 18 devices in L1 and also in L2. And it is something to be used for multiple commands.

Quoted 12 lines
Quoted 11 lines
Quoted 5 lines

E.g for IMS, we should allow it to be configured with various ways

IMS configuration is very abstract.
Lets talk specific.
I want to make sure when you say IMS configuration,

Do you me HV is configuring IMS number of vectors for the VF/SF? If it's this, than, it is similar to how HV provision MSIX for a VF.

Quoted 8 lines

It can be done by introducing a capability in the PF?

struct msix_provision {
u32 device_select;
u16 msix_vectors;
u16 padding;
};

Shahaf and I already explained in this thread that this capability doesn’t scale to your question about "I do not understand scale ..". So a device that wants to do above can simply do this with AQ with single VQ depth and still achieve the simplicity.

Michael also responded that device configuration will not end at msix configuration. So adding more and more tiny capabilities for each configuration doesn't scale either.

Quoted 9 lines
Quoted 2 lines

Or you mean, a guest driver of VF or SF is configuring its IMS to later

consume for the VQ?

Quoted 1 line

If its this, than I explained that admin queue is not the vehicle to do so, and

we discussed the other structure yday.

Yes, I guess that's the nesting case I mentioned above.

Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

1) transport independent way: e.g admin virtqueue (which will be eventually became another transport)

IMS by guest driver cannot be configured by AQ.

Yes, that's one point.

Ok. cool. We sync here too. :)

Quoted 41 lines
Quoted 6 lines
Quoted 5 lines

or

2) transport specific way, E.g a simple PCI(e) capability or MMIO registeres.

This is practical.

Right.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

Certainly. Admin queue is transport independent. PCI MSI-X configuration is PCI transport specific command, so structures are

defined it accordingly.

Quoted 2 lines

It is similar to struct virtio_pci_cap, struct virtio_pci_common_cfg etc.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

Any other transport will have transport specific interrupt configuration. So it

will be defined accordingly whenever that occurs.

Quoted 1 line

For example, IMS for VF or IMS for SF.

I don't think IMS is PCI specific stuffs, we had similar requests for

MMIO.

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

Sure, but even for that there will be SF specific command for IMS

configuration.

Quoted 2 lines

This command will have main difference from VF will be the SF identifier vs

VF identifier.

I think it's not hard to have a single identifier and just say it's transport

specific?

Quoted 8 lines

It is hard when SFs are not defined.

Quoted 1 line

Or simply reserving IDs for VF.

When SF are not defined, it doesn’t make sense to reserve any bytes for it. Linux has 4 bytes SF identifier.
Community might go UUID way or some other way.
We cannot define arbitrary bytes that may/may not be enough.

Quoted 5 lines
Quoted 1 line

When SF will be defined, it will anyway have sf identifier and it will be super

easy to define new vector configuration structure for SF.

Quoted 1 line

Let's not overload VF MSI-X configuration proposal to be intermix with SF.

That's fine.

Ok. thanks.

#83 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 87 lines · Parav Pandit
Quoted 87 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 26, 2022 11:36 AM

Quoted 24 lines · Parav Pandit
Quoted 14 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 26, 2022 11:15 AM

Quoted 2 lines

It does not matter if the SF is created over PCI PF or VF. Its on top of PCI virtio

device.

Quoted 2 lines

When/if someone creates SF over PCI VF, PCI VF is management device, and

PCI SF is managed device.

Quoted 3 lines

When/if SF is created over PCI PF, PCI PF is managed device, and PCI SF is

Quoted 7 lines

managed device.

Quoted 3 lines

In either case the AQ on the PCI device is transporting SF create/destroy

commands.

That's exactly what I meant.

Ok. cool. So we are in sync here. :)

Quoted 1 line
Quoted 6 lines
Quoted 4 lines

Probably but it really depends on the magnitude of the objects that you want to manage via the admin virtqueue. 1K queue size may work for 1K objects but not for 10K or 100K.

We can have higher queue depth.
Not sure if all 10K will be active at same time, even though total 10K or 100K

devices are there.

Quoted 1 line

We don’t see the same in current Linux subfunctions users.

Not specific to this proposal but we see at least 10K+ requirement.

Quoted 4 lines
Quoted 3 lines

The lock is not the only thing that needs to care, the (busy) waiting for the completion of the command may still take time.

There is no need for busy waiting for completion.

Yes, that's why I put busy in the brace.

Quoted 1 line

Its admin command issued from the process context, it should be like blk

request.

Quoted 16 lines

When completion arrives, notifier will awake the caller.

Quoted 14 lines
Quoted 2 lines

I am fine by defining virtio_mgmt_cmd that somehow can be issued without

the admin queue.

Quoted 2 lines

For example, struct virtio_fs_req is detached from the request queue, but

only way it can be issued today is with request queue.

Quoted 5 lines

So we can draft the specification this way.

But I repeatedly miss to see an explanation why is that needed. Where in the recent spec a new queue is added that has request structure

detached from queue.

Quoted 2 lines

I would like to see reference to the spec that indicates that a. struct virtio_fs_req can be issued by other means other than request

queue.

Quoted 20 lines
Quoted 20 lines
Quoted 2 lines

b. Currently the negotiation is done by so and so feature bit to do so via a

request queue.

Quoted 1 line

c. "hence down the road something else can be used to carry struct

virtio_fs_req instead of request queue".

Quoted 3 lines

And that will give good explanation why admin queue should follow some

recently added queue which has structure detached from the queue.

Quoted 2 lines

(not just in form of structure name, but also in form on feature negotiation

plumbing etc).

Quoted 3 lines

Otherwise detach mgmt. cmd from admin queue is vague requirement to

me, that doesn’t require detachment.

So what I meant is not specific to any type of device. Device specific operations should be done via virtqueue.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

What I see is, we should not limit the interface for the device independent basic device facility to be admin virtqueue only:

Can you explain, why?

For

1) the vendor and transport that doesn't want to use admin virtqueue

It is not the choice of vendor to use admin virtqueue or not. It is the spec definition.

We are discussing the proposal which hasn't been a part of the spec right now. It doesn't mean we can't do better.

Quoted 2 lines

Why a transport doesn’t want to use admin queue?

The answer is simple and straightforward, each transport had already had its transport specific way to configure the device.

Quoted 1 line

I don’t follow why virtio fs device wants to use something other than request queue to transport virtio_fs_req.

See my previous reply, I didn't mean we need to change any device specific operation like virtio_fs_req.

What I meant is, let's take MSI as an example

1) PCI has MSI table
2) MMIO doesn't support MSI

It looks to me you want to mandate admin virtqueue to MMIO in order to configure MSI?

Quoted 4 lines
Quoted 2 lines

2) a more simple interface for L1

I don’t see virtqueue as complicated object which exists for 10+ years now and in use by 18 devices in L1 and also in L2. And it is something to be used for multiple commands.

So again, there's misunderstanding. It's all about the "control plane" but not "dataplane". A simple example is to configure the vq address.

1) For PCI it was done via common_cfg structure
2) For MMIO it was done via dedicated registers
3) For CCW, it was done via dedicated commands

And we know we need dedicated commands for the admin virtqueue. Since we had a transport specific interface, guest drivers can still configure the virtqueue address in L1 via the transport specific interface. So the hypervisor can hide the admin virtqueue. Let's say we introduce a new feature X for the admin virtqueue only. How can a guest driver to use that feature? Do we want to hide or assign the admin virtqueue to L1?

I understand that for things like provisioning which might not be needed for L1, but how about others?

Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
Quoted 8 lines
Quoted 2 lines

E.g for IMS, we should allow it to be configured with various ways

IMS configuration is very abstract.
Lets talk specific.
I want to make sure when you say IMS configuration,

Do you me HV is configuring IMS number of vectors for the VF/SF? If it's this, than, it is similar to how HV provision MSIX for a VF.

It can be done by introducing a capability in the PF?

Quoted 8 lines
Quoted 6 lines

struct msix_provision {
u32 device_select;
u16 msix_vectors;
u16 padding;
};

Shahaf and I already explained in this thread that this capability doesn’t scale to your question about "I do not understand scale ..". So a device that wants to do above can simply do this with AQ with single VQ depth and still achieve the simplicity.

I thought it was for SF but not SR-IOV.

I think we all know SR-IOV doesn't scale in many ways and if I understand this series correctly, the main goal is not to address the scalability issues.

It's good to consider the scalability but there could be cases that don't need to be scaled.

Quoted 13 lines

Michael also responded that device configuration will not end at msix configuration. So adding more and more tiny capabilities for each configuration doesn't scale either.

Quoted 9 lines
Quoted 2 lines

Or you mean, a guest driver of VF or SF is configuring its IMS to later

consume for the VQ?

Quoted 1 line

If its this, than I explained that admin queue is not the vehicle to do so, and

we discussed the other structure yday.

Yes, I guess that's the nesting case I mentioned above.

Quoted 1 line
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

1) transport independent way: e.g admin virtqueue (which will be eventually became another transport)

IMS by guest driver cannot be configured by AQ.

Yes, that's one point.

Ok. cool. We sync here too. :)

So I guess you know what I meant for the L1 interface?

Thanks

Quoted 49 lines
Quoted 42 lines
Quoted 7 lines
Quoted 6 lines

or

2) transport specific way, E.g a simple PCI(e) capability or MMIO registeres.

This is practical.

Right.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

Certainly. Admin queue is transport independent. PCI MSI-X configuration is PCI transport specific command, so structures are

defined it accordingly.

Quoted 2 lines

It is similar to struct virtio_pci_cap, struct virtio_pci_common_cfg etc.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

Any other transport will have transport specific interrupt configuration. So it

will be defined accordingly whenever that occurs.

Quoted 1 line

For example, IMS for VF or IMS for SF.

I don't think IMS is PCI specific stuffs, we had similar requests for

MMIO.

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

Sure, but even for that there will be SF specific command for IMS

configuration.

Quoted 2 lines

This command will have main difference from VF will be the SF identifier vs

VF identifier.

I think it's not hard to have a single identifier and just say it's transport

specific?

Quoted 8 lines

It is hard when SFs are not defined.

Quoted 1 line

Or simply reserving IDs for VF.

When SF are not defined, it doesn’t make sense to reserve any bytes for it. Linux has 4 bytes SF identifier.
Community might go UUID way or some other way.
We cannot define arbitrary bytes that may/may not be enough.

Quoted 5 lines
Quoted 1 line

When SF will be defined, it will anyway have sf identifier and it will be super

easy to define new vector configuration structure for SF.

Quoted 1 line

Let's not overload VF MSI-X configuration proposal to be intermix with SF.

That's fine.

Ok. thanks.

#102 lore raw

Re: [PATCH 4/5] virtio-net: add support for VIRTIO_F_ADMIN_VQ

In reply to Jason Wang
Quoted 33 lines · Jason Wang
Quoted 24 lines · Michael S. Tsirkin
Quoted 22 lines · Jason Wang
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Jason Wang
Quoted 4 lines

We also need
- something like injecting cvq commands to control rx mode from the admin device
- page fault / dirty page handling

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

these two seem to call for a vq.

Right, but vq is not necessarily for PF if we had PASID. And with PASID we don't even need a dedicated new cvq.

I don't think it's a good idea to mix transactions from multiple PASIDs on the same vq.

To be clear, I don't mean to let a single vq use multiple PASIDs.

Quoted 4 lines

Attaching a PASID to a queue seems more reasonable. cvq is under guest control, so yes I think a separate vq is preferable.

Quoted 7 lines
Quoted 3 lines

Sorry, I don't get here. E.g in the case of virtio-net, it's more than sufficient to assign a dedicated PASID to cvq, any reason for yet another one?

Well I'm not sure how cheap it is to have an extra PASID. In theory you can share page tables making it not that expensive.

Quoted 8 lines

I think it should not be expensive since PASID is per RID according to the PCIe spec.

Quoted 2 lines

In practice is it hard for the MMU to do so?
If page tables are not shared extra PASIDs become expensive.

Why? For CVQ, we don't need sharing page tables, just maintaining one dedicated buffer for command forwarding is sufficient.

I am talking about the IOMMU page tables, these are not part of PCIe spec. You need to map all of guest memory to the device, this needs a set of PTEs. If two PASIDs map same memory you might be able to share PTEs but I am guessing that this will need some kind of reference counting to track their usage. I am not sure how complex/expensive that will turn out to be. In absence of that, we are doubling the amount of PTEs by using two PASIDs for the same device.

Quoted 28 lines
Quoted 28 lines
Quoted 27 lines
Quoted 5 lines

What is true is that with subfunctions you would have PASID per subfunction and then one subfunction for control.

Well, it's possible, but it's also possible to have everything self contained in a single subfucntion. Then cvq can be assigned to a PASID that is used only for the hypervisor.

Quoted 6 lines

I think a sketch of how things will work with scalable iov can't hurt as part of this proposal. And, I'm not sure we should have so much
flexibility: if there's an interface that works for SRIOV and SIOV then that seems preferable than having distinct transports for SRIOV and SIOV.

Some of my understanding of SR-IOV vs SIOV:

1) SR-IOV doesn't requires a transport, VF use PCI config space; But SIOV requires one
2) SR-IOV doesn't support dynamic on demand provisioning where SIOV can

So I'm not sure how hard it is if we want to unify the management plane of the above two.

Thanks

Quoted 7 lines
Quoted 2 lines

Interesting. So are you fine with a proposal which ignores the PASID things completely then?

I'm fine, just a note that:

The main advantages of using admin virtqueue in another device (PF) is that the DMA is isolated,

Right

Quoted 2 lines

but with the help of PASID, there's no need
to do that

In that you can make the AQ part of the VF itself?

Quoted 3 lines

and we will have a better interface for nesting.

Thanks

In fact, nesting is an interesting use case. I have not thought about this too much, it is worth thinking about how this interface will virtualize.

Quoted 11 lines
Quoted 11 lines

If yes can we take that discussion to
a different thread then? This one is already too long ...

Quoted 6 lines
Quoted 6 lines

--
MST

#72 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Max Gurtovoy
Quoted 113 lines · Max Gurtovoy
Quoted 110 lines · Parav Pandit

Hi Jason,

Quoted 27 lines

From: Jason Wang <[email protected]>
Sent: Tuesday, January 25, 2022 8:59 AM

Quoted 11 lines · Parav Pandit
Quoted 10 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 19, 2022 9:33 AM

It it means IMS, there's already a proposal[1] that introduce MSI commands via the admin virtqueue. And we had similar requirement for virtio-MMIO[2] and managed device or SF [3], so I would rather to introduce IMS (need a better name though) as a basic facility instead of tie it to any specific transport.

IMS of [1] is a interrupt configuration by the virtio driver for the device is it

driving, which needs a queue.

Quoted 1 line

So regardless of the device type as PCI PF/VF/SF/ADI, there is desire to have a

generic admin queue not attached to device type.

Quoted 3 lines

And AQ in this proposal exactly serves this purpose.

Device configuring its own IMS vector vs PCI PF configuring VF's MSI-X max

vector count are two different functionality.

Quoted 4 lines

Both of these commands can ride on a generic queue. However the queue is not same, because PF owns its own admin queue (for vf msix config), VF or SF operates its own admin queue (for IMS config).

Quoted 9 lines

So I think in the next version we need to clarify:

1) is there a single admin virtqueue shared by all the VFs and PF

or

2) per VF/PF admin virtqueue, and how does the driver know how to find the corresponding admin virtqueue

Admin queue is not per VF.
Lets take concrete examples.
1. So for example, PCI PF can have one AQ.
This AQ carries command to query/config MSI-X vector of VFs.

2. In second example, PCI PF is creating/destroying SFs. This is again done by using the AQ of the PCI PF.

3. A PCI VF has its own AQ to configure some of its own generic attribute, don't know which is that today. May be something that is extremely hard to do over features bit.
Currently proposed v2 doesn't restrict admin queue to be within PCI PF or VF or that matter not limited to other transports.

Quoted 9 lines
Quoted 3 lines

So a good example is,
1. PCI PF configures 8 MSI-X or 16 IMS vectors for the VF using PF_AQ in HV.
2. PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ

in GVM.

Quoted 1 line

Both the functions will have AQ feature bit set.

Where did the VF_AQ sit? I guess it belongs to the VF. But if this is true, don't we need some kind of address isolation like PASID?

Above one for IMS is not a good example. I replied the reasoning last week for it.

Quoted 6 lines
Quoted 1 line

Fair enough, so we have more users of admin queue than just MSI-X config.

Well, what I really meant is that we actually have more users of IMS. That's is exactly what virito-mmio wants. In this case introducing admin queue looks too heavyweight for that.

IMS config cannot be done over AQ as described in previous email in this thread.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues 3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds)

I fail to understand the scale/registeres issues. With the one of my previous proposal (device selector), technically we don't even need any config space

or

Quoted 2 lines
Quoted 2 lines

BAR for VF or SF by multiplexing the registers for PF.

Quoted 7 lines
Quoted 1 line

Scale issue is: when you want to create, query, manipulate hundreds of

objects, having shared MMIO register or configuration register, will be too slow.

Ok, this need to be clarified in the commit log. And we need make sure it's not an issue that is only happen for some specific vendor.

It is present in the v2 commit log cover letter.
Please let me know if you think it should be in the actual patch commit log.

Quoted 10 lines
Quoted 1 line

And additionally such register set doesn't scale to allow sharing large

number of bytes as DMA cannot be done.

That's true.

Quoted 1 line

From physical device perspective, it doesn’t scale because device needs to

have those resources ready to answer on MMIO reads and for hundreds to thousand of devices it just cannot do it.

Quoted 8 lines
Quoted 1 line

This is one of the reason for birth of IMS.

IMS allows the table to be stored in the memory and cached by the device to have the best scalability. But I had other questions:

1) if we have a single admin virtqueue, there will still be contention in the driver side

AQ inherently allows out of order commands execution.
It shouldn't face contention. For example 1K depth AQ should be serving hundreds of descriptors commands in parallel for SF creation, VF MSI-X config and more.

Which area/commands etc you think can lead to the contention?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

2) if we have per vf admin virtqueue, it still doesn't scale since it occupies more hardware resources

That is too heavy, and doesn’t scale. Proposal is to not have per vf admin queue. Proposal is to have one admin queue in a virtio device.

Right ? where did we mention something that can imply otherwise ?

Well, I don't know but probably this part,

" PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ ..."

Quoted 52 lines
Quoted 52 lines
Quoted 11 lines
Quoted 4 lines
Quoted 4 lines

I do see one advantage is that the admin virtqueue is transport

independent

Quoted 3 lines
Quoted 2 lines

(or it could be used as a transport).

I am yet to read the transport part from [1].

Yes, the main goal is to be compatible with SIOV.

Admin queue is a command interface transport where higher layer services can be buit. This includes SR-IOV config, SIOV config.
And v2 enables SIOV commands implementation whenever they are ready.

Quoted 37 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

4. Improve documentation around msix config to link to sriov section of

virtio

Quoted 6 lines
Quoted 6 lines

spec

Quoted 1 line

5. Describe error that if VF is bound to the device, admin commands

targeting VF can fail, describe this error code

Quoted 3 lines

Did I miss anything?

Yet to receive your feedback on group, if/why is it needed and, why/if it

must

Quoted 7 lines
Quoted 7 lines

be in this proposal, what pieces prevents it do as follow-on.

Quoted 2 lines

Cornelia, Jason,
Can you please review current proposal as well before we revise v2?

If I understand correctly, most of the features (except for the admin virtqueue in_order stuffs) are not specific to the admin virtqueue. As discussed in the previous versions, I still think it's better:

Quoted 7 lines
Quoted 5 lines

1) adding sections in the basic device facility or data structure for provisioning and MSI
2) introduce admin virtqueue on top as an device interface for those features

I didn't follow your suggestion. Can you please explain? Specifically "data structure for provisioning and MSI"..

I meant:

There's a chapter "Basic Facilities of a Virtio Device", we can introduce the concepts there like:

1) Managed device and Management device (terminology proposed by Michael), and can use PF and VF as a example

2) Managed device provisioning (the data structure to specify the attributes of a managed device (VF))

3) MSI

Quoted 7 lines
Quoted 1 line

Above is good idea. Will revisit v2, if it is not arranged this way.

Let me make sure I understand, you would like to see a new chapter under "Basic Facilities of a Virtio Device" that is

called "Device management" and this chapter will explain in few words the concept

Yes.

Quoted 4 lines

and it will point to another chapter under "Basic Facilities of a Virtio Device"

that was introduced here "Admin Virtqueues" ?

So far as I see from the proposal, it needs belong to PCI transport part or a new transport.

Quoted 3 lines

So you do agree that managing a managed (create/destroy/setup/etc...) will be done using the AQ of the managing device ?

I agree.

Thanks

Quoted 37 lines
Quoted 36 lines
Quoted 10 lines

And then we can introduced admin virtqueue in either

1) transport part

or

2) PCI transport

It is not specific to PCI transport, and currently it is not a transport either. So admin queue will keep as general entity for admin work.

Quoted 3 lines

In the admin virtqueue, there will be commands to provision and configure MSI.

Please review v2 if it is not arranged this way.

Quoted 12 lines
Quoted 4 lines
Quoted 3 lines

The leaves the chance for future extensions to allow those features to be used by transport specific interface which will benefit for

AQ allows communication (command, response) between driver and device

in transport independent way.

Quoted 4 lines

Sometimes it query/set transport specific fields like MSI-X vectors of VF. Sometimes device configure its on IMS interrupt.
Something else in future.
So it is really a generic request-response queue.

I agree, but I think we can't mandate new features to a specific transport.

Certainly. Admin queue is transport independent.
PCI MSI-X configuration is PCI transport specific command, so structures are defined it accordingly. It is similar to struct virtio_pci_cap, struct virtio_pci_common_cfg etc.

Any other transport will have transport specific interrupt configuration. So it will be defined accordingly whenever that occurs. For example, IMS for VF or IMS for SF.

#103 lore raw

Re: [PATCH 4/5] virtio-net: add support for VIRTIO_F_ADMIN_VQ

In reply to Michael S. Tsirkin
Quoted 44 lines · Michael S. Tsirkin
Quoted 33 lines · Jason Wang
Quoted 24 lines · Michael S. Tsirkin
Quoted 22 lines · Jason Wang
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Jason Wang
Quoted 4 lines

We also need
- something like injecting cvq commands to control rx mode from the admin device
- page fault / dirty page handling

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

these two seem to call for a vq.

Right, but vq is not necessarily for PF if we had PASID. And with PASID we don't even need a dedicated new cvq.

I don't think it's a good idea to mix transactions from multiple PASIDs on the same vq.

To be clear, I don't mean to let a single vq use multiple PASIDs.

Quoted 4 lines

Attaching a PASID to a queue seems more reasonable. cvq is under guest control, so yes I think a separate vq is preferable.

Quoted 7 lines
Quoted 3 lines

Sorry, I don't get here. E.g in the case of virtio-net, it's more than sufficient to assign a dedicated PASID to cvq, any reason for yet another one?

Well I'm not sure how cheap it is to have an extra PASID. In theory you can share page tables making it not that expensive.

Quoted 8 lines

I think it should not be expensive since PASID is per RID according to the PCIe spec.

Quoted 2 lines

In practice is it hard for the MMU to do so?
If page tables are not shared extra PASIDs become expensive.

Why? For CVQ, we don't need sharing page tables, just maintaining one dedicated buffer for command forwarding is sufficient.

Quoted 7 lines

I am talking about the IOMMU page tables, these are not part of PCIe spec. You need to map all of guest memory to the device, this needs a set of PTEs. If two PASIDs map same memory you might be able to share PTEs but I am guessing that this will need some kind of reference counting to track their usage. I am not sure how complex/expensive that will turn out to be. In absence of that, we are doubling the amount of PTEs by using two PASIDs for the same device.

So it depends on the migration model

1) save and restore

or

2) trap and emulate

Then:

- If the device provides the facility to sync the state we don't need a dedicated PASID for CVQ, and CVQ can be assigned to guests.
- If the device doesn't provide the facility to sync the state, we need trap CVQ and get the state (what Qemu currently did), then CVQ needs to be trapped (an emulated CVQ will be presented to guests). And we need a dedicated PASID for hardware CVQ, but in this case we don't need to map guest memory to hardware CVQ otherwise there will be security implications. It's sufficient to map a small buffer.

Quoted 38 lines
Quoted 30 lines
Quoted 30 lines
Quoted 29 lines
Quoted 7 lines

What is true is that with subfunctions you would have PASID per subfunction and then one subfunction for control.

Well, it's possible, but it's also possible to have everything self contained in a single subfucntion. Then cvq can be assigned to a PASID that is used only for the hypervisor.

Quoted 6 lines

I think a sketch of how things will work with scalable iov can't hurt as part of this proposal. And, I'm not sure we should have so much
flexibility: if there's an interface that works for SRIOV and SIOV then that seems preferable than having distinct transports for SRIOV and SIOV.

Some of my understanding of SR-IOV vs SIOV:

1) SR-IOV doesn't requires a transport, VF use PCI config space; But SIOV requires one
2) SR-IOV doesn't support dynamic on demand provisioning where SIOV can

So I'm not sure how hard it is if we want to unify the management plane of the above two.

Thanks

Quoted 7 lines
Quoted 2 lines

Interesting. So are you fine with a proposal which ignores the PASID things completely then?

I'm fine, just a note that:

The main advantages of using admin virtqueue in another device (PF) is that the DMA is isolated,

Quoted 6 lines

Right

Quoted 2 lines

but with the help of PASID, there's no need
to do that

In that you can make the AQ part of the VF itself?

Not sure, but I guess for nesting, A bar/register interface is much more simpler/better for the case that doesn't need DMA.

Quoted 8 lines
Quoted 4 lines

and we will have a better interface for nesting.

Thanks

In fact, nesting is an interesting use case. I have not thought about this too much, it is worth thinking about how this interface will virtualize.

I totally agree.

Thanks

Quoted 13 lines
Quoted 12 lines
Quoted 12 lines

If yes can we take that discussion to
a different thread then? This one is already too long ...

Quoted 6 lines
Quoted 6 lines

--
MST

#84 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Jason Wang
Quoted 11 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 26, 2022 12:24 PM

Quoted 3 lines
Quoted 2 lines

1) the vendor and transport that doesn't want to use admin virtqueue

It is not the choice of vendor to use admin virtqueue or not. It is the spec

definition.

We are discussing the proposal which hasn't been a part of the spec right now. It doesn't mean we can't do better.

Sure. It’s the proposal we are discussing, but I fail to understand why a vendor doesn’t want to use a admin queue due to which it needs to be detached.

Quoted 5 lines
Quoted 2 lines

Why a transport doesn’t want to use admin queue?

The answer is simple and straightforward, each transport had already had its transport specific way to configure the device.

Each transport uses transport agnostic way to communicate the requests and response to the device by means of virtqueue descriptors.

And that is done through virtqueue.

A descriptor in a virtqueue represents wide range of things.
1. Sometime sending packet,
2. sometimes configuring vlan,
3. sometime configuring adding mac to table.
4. sometime adding crypto session
5. and now sometime managing a managed VF or SF device

Item #5 is no different than #1 to #4.
Managed device configuration != "generic configure the device".

Quoted 7 lines
Quoted 2 lines

I don’t follow why virtio fs device wants to use something other than request

queue to transport virtio_fs_req.

See my previous reply, I didn't mean we need to change any device specific operation like virtio_fs_req.

You imply that virtio_fs_req must be carried on the request queue, but some other request like to use other than virtqueue even though its explained several times that why virtqueue is used. Doesn't make sense at all.

Quoted 8 lines

What I meant is, let's take MSI as an example

1) PCI has MSI table
2) MMIO doesn't support MSI

It looks to me you want to mandate admin virtqueue to MMIO in order to configure MSI?

If you want to attribute it as "mandate" than yes, it is no different than, virtio_fs_req is mandated on request vq. virtio_crypto_op_ctrl_req ia mandated on control vq.

What prevents both above examples to used AQ in generic manner?

Quoted 4 lines
Quoted 3 lines
Quoted 2 lines

2) a more simple interface for L1

I don’t see virtqueue as complicated object which exists for 10+ years now

and in use by 18 devices in L1 and also in L2.

Quoted 8 lines
Quoted 1 line

And it is something to be used for multiple commands.

So again, there's misunderstanding. It's all about the "control plane" but not "dataplane". A simple example is to configure the vq address.

1) For PCI it was done via common_cfg structure
2) For MMIO it was done via dedicated registers
3) For CCW, it was done via dedicated commands

We discussed already and you ignored the scale, on-die and other comments. And low level self-device configuration is compared with managing device configuration. This comparison simply isn't right.

data plane => vq
control plane => cq + transport specific cfg
mgmt plane => aq (this proposal)

mgmt plane != device on vq configuration.
Device on vq configuration doesn't block with other device VQ configuration.

Quoted 2 lines

And we know we need dedicated commands for the admin virtqueue.

Not sure I follow you. AQ carries admin queue commands like any other queues.

Quoted 5 lines

Since we
had a transport specific interface, guest drivers can still configure the virtqueue address in L1 via the transport specific interface. So the hypervisor can hide the admin virtqueue. Let's say we introduce a new feature X for the admin virtqueue only. How can a guest driver to use that feature?

As the patch-1, and patch-4 clearly shows the purpose of the AQ, AQ is of the virtio device located in the HV is not for the consumption in the guest driver.

Quoted 2 lines

Do we want to hide
or assign the admin virtqueue to L1?

A virtio device in guest may have its own admin queue. But again, until now there is no concrete example discussed that demands an admin queue in the guest driver. IMS vector enable/disable was the closest one we discussed and we agreed that AQ cannot be used for that.

Quoted 3 lines

I understand that for things like provisioning which might not be needed for L1, but how about others?

Others?

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

Shahaf and I already explained in this thread that this capability doesn’t scale

to your question about "I do not understand scale ..".

Quoted 1 line

So a device that wants to do above can simply do this with AQ with single VQ

depth and still achieve the simplicity.

I thought it was for SF but not SR-IOV.

Ah, that was the misunderstanding you had. It applies to SF and SR-IOV both.

Quoted 3 lines

I think we all know SR-IOV doesn't scale in many ways and if I understand this series correctly, the main goal is not to address the scalability issues.

You are mixing many things here. Do not mix SR-IOV VF scaling with PF resource scaling. Please keep it focused.

The goal as constantly repeated, is to have a interface between driver and device to carry multiple commands in scalable way without consuming on-chip resources.

Quoted 3 lines

It's good to consider the scalability but there could be cases that don't need to be scaled.

Sure, in that case AQ of single entry is just fine.

Quoted 7 lines
Quoted 3 lines

Michael also responded that device configuration will not end at msix

configuration.

Quoted 1 line

So adding more and more tiny capabilities for each configuration doesn't

scale either.

Quoted 1 line

You need to ack above point otherwise we will keep discussing this even 2 weeks from now. :)

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 3 lines

Or you mean, a guest driver of VF or SF is configuring its IMS to later

consume for the VQ?

Quoted 2 lines

If its this, than I explained that admin queue is not the vehicle to do so, and

we discussed the other structure yday.

Yes, I guess that's the nesting case I mentioned above.

Quoted 4 lines
Quoted 4 lines

1) transport independent way: e.g admin virtqueue (which will be eventually became another transport)

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

IMS by guest driver cannot be configured by AQ.

Yes, that's one point.

Ok. cool. We sync here too. :)

So I guess you know what I meant for the L1 interface?

With your last question, let me double check my understanding. :)

My understanding of L1 interface is virtio device in hypervisor. Is that right?

#85 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 6 lines · Parav Pandit
Quoted 6 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 26, 2022 12:24 PM

Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Quoted 1 line

1) the vendor and transport that doesn't want to use admin virtqueue

It is not the choice of vendor to use admin virtqueue or not. It is the spec

definition.

We are discussing the proposal which hasn't been a part of the spec right now. It doesn't mean we can't do better.

Sure. It’s the proposal we are discussing, but I fail to understand why a vendor doesn’t want to use a admin queue due to which it needs to be detached.

What do you mean by "detached"?

Quoted 17 lines
Quoted 6 lines
Quoted 3 lines

Why a transport doesn’t want to use admin queue?

The answer is simple and straightforward, each transport had already had its transport specific way to configure the device.

Each transport uses transport agnostic way to communicate the requests and response to the device by means of virtqueue descriptors.

And that is done through virtqueue.

A descriptor in a virtqueue represents wide range of things.
1. Sometime sending packet,
2. sometimes configuring vlan,
3. sometime configuring adding mac to table.
4. sometime adding crypto session
5. and now sometime managing a managed VF or SF device

Quoted 2 lines

Item #5 is no different than #1 to #4.
Managed device configuration != "generic configure the device".

Well, I think then you need to explain this well in the patch.

Quoted 10 lines
Quoted 8 lines
Quoted 3 lines

I don’t follow why virtio fs device wants to use something other than request

queue to transport virtio_fs_req.

See my previous reply, I didn't mean we need to change any device specific operation like virtio_fs_req.

You imply that virtio_fs_req must be carried on the request queue, but some other request like to use other than virtqueue even though its explained several times that why virtqueue is used. Doesn't make sense at all.

So a virtqueue is needed only when DMA is required. That is the case for virtio_fs_req.

For other cases that DMA is not a must, it could or not be a queue interface.

Quoted 6 lines
Quoted 6 lines

What I meant is, let's take MSI as an example

1) PCI has MSI table
2) MMIO doesn't support MSI

Quoted 8 lines
Quoted 3 lines

It looks to me you want to mandate admin virtqueue to MMIO in order to configure MSI?

If you want to attribute it as "mandate" than yes, it is no different than, virtio_fs_req is mandated on request vq. virtio_crypto_op_ctrl_req ia mandated on control vq.

What prevents both above examples to used AQ in generic manner?

Nothing, but for simple features like MSI I don't think we can exclude the possibility of using dedicated registers. For a simple setup like a guest that is using an MMIO device, using new virtqueue just for MSI seems an odd burden.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

2) a more simple interface for L1

I don’t see virtqueue as complicated object which exists for 10+ years now

and in use by 18 devices in L1 and also in L2.

Quoted 1 line

And it is something to be used for multiple commands.

Quoted 8 lines
Quoted 6 lines

So again, there's misunderstanding. It's all about the "control plane" but not "dataplane". A simple example is to configure the vq address.

1) For PCI it was done via common_cfg structure
2) For MMIO it was done via dedicated registers
3) For CCW, it was done via dedicated commands

We discussed already and you ignored the scale, on-die and other comments.

Looks not, it's the IMS discussion that confuses the thread probably.

Quoted 8 lines

And low level self-device configuration is compared with managing device configuration. This comparison simply isn't right.

data plane => vq
control plane => cq + transport specific cfg
mgmt plane => aq (this proposal)

mgmt plane != device on vq configuration.

To clarify, we need to define what exactly did management mean? E.g is IMS considered to be mgmt or control?

Quoted 11 lines

Device on vq configuration doesn't block with other device VQ configuration.

Quoted 2 lines

And we know we need dedicated commands for the admin virtqueue.

Not sure I follow you. AQ carries admin queue commands like any other queues.

Quoted 5 lines

Since we
had a transport specific interface, guest drivers can still configure the virtqueue address in L1 via the transport specific interface. So the hypervisor can hide the admin virtqueue. Let's say we introduce a new feature X for the admin virtqueue only. How can a guest driver to use that feature?

Quoted 6 lines

As the patch-1, and patch-4 clearly shows the purpose of the AQ, AQ is of the virtio device located in the HV is not for the consumption in the guest driver.

Quoted 2 lines

Do we want to hide
or assign the admin virtqueue to L1?

A virtio device in guest may have its own admin queue. But again, until now there is no concrete example discussed that demands an admin queue in the guest driver. IMS vector enable/disable was the closest one we discussed and we agreed that AQ cannot be used for that.

Ok.

Quoted 5 lines
Quoted 4 lines

I understand that for things like provisioning which might not be needed for L1, but how about others?

Others?

Well, I'd say if you limit the admin virtuqueue for provisioning, it should be fine.

Quoted 25 lines
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

Shahaf and I already explained in this thread that this capability doesn’t scale

to your question about "I do not understand scale ..".

Quoted 1 line

So a device that wants to do above can simply do this with AQ with single VQ

depth and still achieve the simplicity.

I thought it was for SF but not SR-IOV.

Ah, that was the misunderstanding you had. It applies to SF and SR-IOV both.

Quoted 3 lines

I think we all know SR-IOV doesn't scale in many ways and if I understand this series correctly, the main goal is not to address the scalability issues.

You are mixing many things here. Do not mix SR-IOV VF scaling with PF resource scaling. Please keep it focused.

The goal as constantly repeated, is to have a interface between driver and device to carry multiple commands in scalable way without consuming on-chip resources.

Quoted 3 lines

It's good to consider the scalability but there could be cases that don't need to be scaled.

Sure, in that case AQ of single entry is just fine.

Quoted 2 lines
Quoted 2 lines
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

Michael also responded that device configuration will not end at msix

configuration.

Quoted 1 line

So adding more and more tiny capabilities for each configuration doesn't

scale either.

Quoted 1 line

You need to ack above point otherwise we will keep discussing this even 2 weeks from now. :)

I think I've acknowledged in another thread about the idea of using admin virtqueue.

Thanks

Quoted 26 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 4 lines

Or you mean, a guest driver of VF or SF is configuring its IMS to later

consume for the VQ?

Quoted 2 lines

If its this, than I explained that admin queue is not the vehicle to do so, and

we discussed the other structure yday.

Yes, I guess that's the nesting case I mentioned above.

Quoted 4 lines
Quoted 4 lines

1) transport independent way: e.g admin virtqueue (which will be eventually became another transport)

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

IMS by guest driver cannot be configured by AQ.

Yes, that's one point.

Ok. cool. We sync here too. :)

So I guess you know what I meant for the L1 interface?

With your last question, let me double check my understanding. :)

My understanding of L1 interface is virtio device in hypervisor. Is that right?

#73 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Jason Wang
Quoted 173 lines · Jason Wang
Quoted 106 lines · Max Gurtovoy
Quoted 104 lines · Parav Pandit

Hi Jason,

Quoted 26 lines

From: Jason Wang <[email protected]>
Sent: Tuesday, January 25, 2022 8:59 AM

Quoted 11 lines · Parav Pandit
Quoted 10 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 19, 2022 9:33 AM

It it means IMS, there's already a proposal[1] that introduce MSI commands via the admin virtqueue. And we had similar requirement for virtio-MMIO[2] and managed device or SF [3], so I would rather to introduce IMS (need a better name though) as a basic facility instead of tie it to any specific transport.

IMS of [1] is a interrupt configuration by the virtio driver for the device is it

driving, which needs a queue.

Quoted 1 line

So regardless of the device type as PCI PF/VF/SF/ADI, there is desire to have a

generic admin queue not attached to device type.

Quoted 3 lines

And AQ in this proposal exactly serves this purpose.

Device configuring its own IMS vector vs PCI PF configuring VF's MSI-X max

vector count are two different functionality.

Quoted 4 lines

Both of these commands can ride on a generic queue. However the queue is not same, because PF owns its own admin queue (for vf msix config), VF or SF operates its own admin queue (for IMS config).

Quoted 9 lines

So I think in the next version we need to clarify:

1) is there a single admin virtqueue shared by all the VFs and PF

or

2) per VF/PF admin virtqueue, and how does the driver know how to find the corresponding admin virtqueue

Admin queue is not per VF.
Lets take concrete examples.
1. So for example, PCI PF can have one AQ.
This AQ carries command to query/config MSI-X vector of VFs.

2. In second example, PCI PF is creating/destroying SFs. This is again done by using the AQ of the PCI PF.

3. A PCI VF has its own AQ to configure some of its own generic attribute, don't know which is that today. May be something that is extremely hard to do over features bit.
Currently proposed v2 doesn't restrict admin queue to be within PCI PF or VF or that matter not limited to other transports.

Quoted 8 lines
Quoted 3 lines

So a good example is,
1. PCI PF configures 8 MSI-X or 16 IMS vectors for the VF using PF_AQ in HV.
2. PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ

in GVM.

Quoted 1 line

Both the functions will have AQ feature bit set.

Where did the VF_AQ sit? I guess it belongs to the VF. But if this is true, don't we need some kind of address isolation like PASID?

Above one for IMS is not a good example. I replied the reasoning last week for it.

Quoted 5 lines
Quoted 1 line

Fair enough, so we have more users of admin queue than just MSI-X config.

Well, what I really meant is that we actually have more users of IMS. That's is exactly what virito-mmio wants. In this case introducing admin queue looks too heavyweight for that.

IMS config cannot be done over AQ as described in previous email in this thread.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues 3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds)

I fail to understand the scale/registeres issues. With the one of my previous proposal (device selector), technically we don't even need any config space

or

Quoted 2 lines
Quoted 2 lines

BAR for VF or SF by multiplexing the registers for PF.

Quoted 7 lines
Quoted 1 line

Scale issue is: when you want to create, query, manipulate hundreds of

objects, having shared MMIO register or configuration register, will be too slow.

Ok, this need to be clarified in the commit log. And we need make sure it's not an issue that is only happen for some specific vendor.

It is present in the v2 commit log cover letter.
Please let me know if you think it should be in the actual patch commit log.

Quoted 8 lines
Quoted 1 line

And additionally such register set doesn't scale to allow sharing large

number of bytes as DMA cannot be done.

That's true.

Quoted 1 line

From physical device perspective, it doesn’t scale because device needs to

Quoted 9 lines

have those resources ready to answer on MMIO reads and for hundreds to thousand of devices it just cannot do it.

Quoted 1 line

This is one of the reason for birth of IMS.

IMS allows the table to be stored in the memory and cached by the device to have the best scalability. But I had other questions:

1) if we have a single admin virtqueue, there will still be contention in the driver side

AQ inherently allows out of order commands execution.
It shouldn't face contention. For example 1K depth AQ should be serving hundreds of descriptors commands in parallel for SF creation, VF MSI-X config and more.

Quoted 8 lines
Quoted 7 lines

Which area/commands etc you think can lead to the contention?

Quoted 3 lines

2) if we have per vf admin virtqueue, it still doesn't scale since it occupies more hardware resources

That is too heavy, and doesn’t scale. Proposal is to not have per vf admin queue. Proposal is to have one admin queue in a virtio device.

Right ? where did we mention something that can imply otherwise ?

Well, I don't know but probably this part,

" PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ ..."

Quoted 46 lines
Quoted 46 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

I do see one advantage is that the admin virtqueue is transport

independent

Quoted 3 lines
Quoted 2 lines

(or it could be used as a transport).

I am yet to read the transport part from [1].

Yes, the main goal is to be compatible with SIOV.

Admin queue is a command interface transport where higher layer services can be buit. This includes SR-IOV config, SIOV config.
And v2 enables SIOV commands implementation whenever they are ready.

Quoted 34 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

4. Improve documentation around msix config to link to sriov section of

virtio

Quoted 6 lines
Quoted 6 lines

spec

Quoted 1 line

5. Describe error that if VF is bound to the device, admin commands

targeting VF can fail, describe this error code

Quoted 3 lines

Did I miss anything?

Yet to receive your feedback on group, if/why is it needed and, why/if it

must

Quoted 7 lines
Quoted 7 lines

be in this proposal, what pieces prevents it do as follow-on.

Quoted 2 lines

Cornelia, Jason,
Can you please review current proposal as well before we revise v2?

If I understand correctly, most of the features (except for the admin virtqueue in_order stuffs) are not specific to the admin virtqueue. As discussed in the previous versions, I still think it's better:

Quoted 7 lines
Quoted 5 lines

1) adding sections in the basic device facility or data structure for provisioning and MSI
2) introduce admin virtqueue on top as an device interface for those features

I didn't follow your suggestion. Can you please explain? Specifically "data structure for provisioning and MSI"..

I meant:

There's a chapter "Basic Facilities of a Virtio Device", we can introduce the concepts there like:

1) Managed device and Management device (terminology proposed by Michael), and can use PF and VF as a example

2) Managed device provisioning (the data structure to specify the attributes of a managed device (VF))

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

3) MSI

Above is good idea. Will revisit v2, if it is not arranged this way.

Let me make sure I understand, you would like to see a new chapter under "Basic Facilities of a Virtio Device" that is

called "Device management" and this chapter will explain in few words the concept

Quoted 8 lines

Yes.

Quoted 4 lines

and it will point to another chapter under "Basic Facilities of a Virtio Device"

that was introduced here "Admin Virtqueues" ?

So far as I see from the proposal, it needs belong to PCI transport part or a new transport.

No it's not.

It should stay in the basic/generic area like we discussed in the past and already agreed on.

Lets move forward please.

Quoted 5 lines
Quoted 2 lines

So you do agree that managing a managed (create/destroy/setup/etc...) will be done using the AQ of the managing device ?

I agree.

Thanks

Ok so I guess we agree on the concept of this patch set and the AQ.

Thanks.

Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 9 lines

And then we can introduced admin virtqueue in either

1) transport part

or

2) PCI transport

It is not specific to PCI transport, and currently it is not a transport either. So admin queue will keep as general entity for admin work.

Quoted 3 lines

In the admin virtqueue, there will be commands to provision and configure MSI.

Please review v2 if it is not arranged this way.

Quoted 11 lines
Quoted 4 lines
Quoted 3 lines

The leaves the chance for future extensions to allow those features to be used by transport specific interface which will benefit for

AQ allows communication (command, response) between driver and device

in transport independent way.

Quoted 4 lines

Sometimes it query/set transport specific fields like MSI-X vectors of VF. Sometimes device configure its on IMS interrupt.
Something else in future.
So it is really a generic request-response queue.

I agree, but I think we can't mandate new features to a specific transport.

Certainly. Admin queue is transport independent.
PCI MSI-X configuration is PCI transport specific command, so structures are defined it accordingly. It is similar to struct virtio_pci_cap, struct virtio_pci_common_cfg etc.

Any other transport will have transport specific interrupt configuration. So it will be defined accordingly whenever that occurs. For example, IMS for VF or IMS for SF.

#74 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 185 lines · Max Gurtovoy
Quoted 173 lines · Jason Wang
Quoted 106 lines · Max Gurtovoy
Quoted 104 lines · Parav Pandit

Hi Jason,

Quoted 26 lines

From: Jason Wang <[email protected]>
Sent: Tuesday, January 25, 2022 8:59 AM

Quoted 11 lines · Parav Pandit
Quoted 10 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 19, 2022 9:33 AM

It it means IMS, there's already a proposal[1] that introduce MSI commands via the admin virtqueue. And we had similar requirement for virtio-MMIO[2] and managed device or SF [3], so I would rather to introduce IMS (need a better name though) as a basic facility instead of tie it to any specific transport.

IMS of [1] is a interrupt configuration by the virtio driver for the device is it

driving, which needs a queue.

Quoted 1 line

So regardless of the device type as PCI PF/VF/SF/ADI, there is desire to have a

generic admin queue not attached to device type.

Quoted 3 lines

And AQ in this proposal exactly serves this purpose.

Device configuring its own IMS vector vs PCI PF configuring VF's MSI-X max

vector count are two different functionality.

Quoted 4 lines

Both of these commands can ride on a generic queue. However the queue is not same, because PF owns its own admin queue (for vf msix config), VF or SF operates its own admin queue (for IMS config).

Quoted 9 lines

So I think in the next version we need to clarify:

1) is there a single admin virtqueue shared by all the VFs and PF

or

2) per VF/PF admin virtqueue, and how does the driver know how to find the corresponding admin virtqueue

Admin queue is not per VF.
Lets take concrete examples.
1. So for example, PCI PF can have one AQ.
This AQ carries command to query/config MSI-X vector of VFs.

2. In second example, PCI PF is creating/destroying SFs. This is again done by using the AQ of the PCI PF.

3. A PCI VF has its own AQ to configure some of its own generic attribute, don't know which is that today. May be something that is extremely hard to do over features bit.
Currently proposed v2 doesn't restrict admin queue to be within PCI PF or VF or that matter not limited to other transports.

Quoted 8 lines
Quoted 3 lines

So a good example is,
1. PCI PF configures 8 MSI-X or 16 IMS vectors for the VF using PF_AQ in HV.
2. PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ

in GVM.

Quoted 1 line

Both the functions will have AQ feature bit set.

Where did the VF_AQ sit? I guess it belongs to the VF. But if this is true, don't we need some kind of address isolation like PASID?

Above one for IMS is not a good example. I replied the reasoning last week for it.

Quoted 5 lines
Quoted 1 line

Fair enough, so we have more users of admin queue than just MSI-X config.

Well, what I really meant is that we actually have more users of IMS. That's is exactly what virito-mmio wants. In this case introducing admin queue looks too heavyweight for that.

IMS config cannot be done over AQ as described in previous email in this thread.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues 3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds)

I fail to understand the scale/registeres issues. With the one of my previous proposal (device selector), technically we don't even need any config space

or

Quoted 2 lines
Quoted 2 lines

BAR for VF or SF by multiplexing the registers for PF.

Quoted 7 lines
Quoted 1 line

Scale issue is: when you want to create, query, manipulate hundreds of

objects, having shared MMIO register or configuration register, will be too slow.

Ok, this need to be clarified in the commit log. And we need make sure it's not an issue that is only happen for some specific vendor.

It is present in the v2 commit log cover letter.
Please let me know if you think it should be in the actual patch commit log.

Quoted 8 lines
Quoted 1 line

And additionally such register set doesn't scale to allow sharing large

number of bytes as DMA cannot be done.

That's true.

Quoted 1 line

From physical device perspective, it doesn’t scale because device needs to

Quoted 9 lines

have those resources ready to answer on MMIO reads and for hundreds to thousand of devices it just cannot do it.

Quoted 1 line

This is one of the reason for birth of IMS.

IMS allows the table to be stored in the memory and cached by the device to have the best scalability. But I had other questions:

1) if we have a single admin virtqueue, there will still be contention in the driver side

AQ inherently allows out of order commands execution.
It shouldn't face contention. For example 1K depth AQ should be serving hundreds of descriptors commands in parallel for SF creation, VF MSI-X config and more.

Quoted 8 lines
Quoted 7 lines

Which area/commands etc you think can lead to the contention?

Quoted 3 lines

2) if we have per vf admin virtqueue, it still doesn't scale since it occupies more hardware resources

That is too heavy, and doesn’t scale. Proposal is to not have per vf admin queue. Proposal is to have one admin queue in a virtio device.

Right ? where did we mention something that can imply otherwise ?

Well, I don't know but probably this part,

" PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ ..."

Quoted 46 lines
Quoted 46 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

I do see one advantage is that the admin virtqueue is transport

independent

Quoted 3 lines
Quoted 2 lines

(or it could be used as a transport).

I am yet to read the transport part from [1].

Yes, the main goal is to be compatible with SIOV.

Admin queue is a command interface transport where higher layer services can be buit. This includes SR-IOV config, SIOV config.
And v2 enables SIOV commands implementation whenever they are ready.

Quoted 34 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

4. Improve documentation around msix config to link to sriov section of

virtio

Quoted 6 lines
Quoted 6 lines

spec

Quoted 1 line

5. Describe error that if VF is bound to the device, admin commands

targeting VF can fail, describe this error code

Quoted 3 lines

Did I miss anything?

Yet to receive your feedback on group, if/why is it needed and, why/if it

must

Quoted 7 lines
Quoted 7 lines

be in this proposal, what pieces prevents it do as follow-on.

Quoted 2 lines

Cornelia, Jason,
Can you please review current proposal as well before we revise v2?

If I understand correctly, most of the features (except for the admin virtqueue in_order stuffs) are not specific to the admin virtqueue. As discussed in the previous versions, I still think it's better:

Quoted 7 lines
Quoted 5 lines

1) adding sections in the basic device facility or data structure for provisioning and MSI
2) introduce admin virtqueue on top as an device interface for those features

I didn't follow your suggestion. Can you please explain? Specifically "data structure for provisioning and MSI"..

I meant:

There's a chapter "Basic Facilities of a Virtio Device", we can introduce the concepts there like:

1) Managed device and Management device (terminology proposed by Michael), and can use PF and VF as a example

2) Managed device provisioning (the data structure to specify the attributes of a managed device (VF))

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

3) MSI

Above is good idea. Will revisit v2, if it is not arranged this way.

Let me make sure I understand, you would like to see a new chapter under "Basic Facilities of a Virtio Device" that is

called "Device management" and this chapter will explain in few words the concept

Quoted 8 lines

Yes.

Quoted 4 lines

and it will point to another chapter under "Basic Facilities of a Virtio Device"

that was introduced here "Admin Virtqueues" ?

So far as I see from the proposal, it needs belong to PCI transport part or a new transport.

Quoted 6 lines

No it's not.

It should stay in the basic/generic area like we discussed in the past and already agreed on.

Lets move forward please.

Yes, for the general admin virtqueue part, it should be fine, but for SR-IOV ATTRS part, is it better to move it to PCI transport?

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

So you do agree that managing a managed (create/destroy/setup/etc...) will be done using the AQ of the managing device ?

I agree.

Thanks

Ok so I guess we agree on the concept of this patch set and the AQ.

Yes.

Thanks

Quoted 38 lines

Thanks.

Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 9 lines

And then we can introduced admin virtqueue in either

1) transport part

or

2) PCI transport

It is not specific to PCI transport, and currently it is not a transport either. So admin queue will keep as general entity for admin work.

Quoted 3 lines

In the admin virtqueue, there will be commands to provision and configure MSI.

Please review v2 if it is not arranged this way.

Quoted 11 lines
Quoted 4 lines
Quoted 3 lines

The leaves the chance for future extensions to allow those features to be used by transport specific interface which will benefit for

AQ allows communication (command, response) between driver and device

in transport independent way.

Quoted 4 lines

Sometimes it query/set transport specific fields like MSI-X vectors of VF. Sometimes device configure its on IMS interrupt.
Something else in future.
So it is really a generic request-response queue.

I agree, but I think we can't mandate new features to a specific transport.

Certainly. Admin queue is transport independent.
PCI MSI-X configuration is PCI transport specific command, so structures are defined it accordingly. It is similar to struct virtio_pci_cap, struct virtio_pci_common_cfg etc.

Any other transport will have transport specific interrupt configuration. So it will be defined accordingly whenever that occurs. For example, IMS for VF or IMS for SF.

#75 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 182 lines · Jason Wang
Quoted 181 lines · Max Gurtovoy
Quoted 179 lines · Jason Wang
Quoted 105 lines · Max Gurtovoy
Quoted 104 lines · Parav Pandit

Hi Jason,

Quoted 26 lines

From: Jason Wang <[email protected]>
Sent: Tuesday, January 25, 2022 8:59 AM

Quoted 11 lines · Parav Pandit
Quoted 10 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 19, 2022 9:33 AM

It it means IMS, there's already a proposal[1] that introduce MSI commands via the admin virtqueue. And we had similar requirement for virtio-MMIO[2] and managed device or SF [3], so I would rather to introduce IMS (need a better name though) as a basic facility instead of tie it to any specific transport.

IMS of [1] is a interrupt configuration by the virtio driver for the device is it

driving, which needs a queue.

Quoted 1 line

So regardless of the device type as PCI PF/VF/SF/ADI, there is desire to have a

generic admin queue not attached to device type.

Quoted 3 lines

And AQ in this proposal exactly serves this purpose.

Device configuring its own IMS vector vs PCI PF configuring VF's MSI-X max

vector count are two different functionality.

Quoted 4 lines

Both of these commands can ride on a generic queue. However the queue is not same, because PF owns its own admin queue (for vf msix config), VF or SF operates its own admin queue (for IMS config).

Quoted 9 lines

So I think in the next version we need to clarify:

1) is there a single admin virtqueue shared by all the VFs and PF

or

2) per VF/PF admin virtqueue, and how does the driver know how to find the corresponding admin virtqueue

Admin queue is not per VF.
Lets take concrete examples.
1. So for example, PCI PF can have one AQ.
This AQ carries command to query/config MSI-X vector of VFs.

2. In second example, PCI PF is creating/destroying SFs. This is again done by using the AQ of the PCI PF.

3. A PCI VF has its own AQ to configure some of its own generic attribute, don't know which is that today. May be something that is extremely hard to do over features bit.
Currently proposed v2 doesn't restrict admin queue to be within PCI PF or VF or that matter not limited to other transports.

Quoted 8 lines
Quoted 3 lines

So a good example is,
1. PCI PF configures 8 MSI-X or 16 IMS vectors for the VF using PF_AQ in HV.
2. PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ

in GVM.

Quoted 1 line

Both the functions will have AQ feature bit set.

Where did the VF_AQ sit? I guess it belongs to the VF. But if this is true, don't we need some kind of address isolation like PASID?

Above one for IMS is not a good example. I replied the reasoning last week for it.

Quoted 5 lines
Quoted 1 line

Fair enough, so we have more users of admin queue than just MSI-X config.

Well, what I really meant is that we actually have more users of IMS. That's is exactly what virito-mmio wants. In this case introducing admin queue looks too heavyweight for that.

IMS config cannot be done over AQ as described in previous email in this thread.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues 3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds)

I fail to understand the scale/registeres issues. With the one of my previous proposal (device selector), technically we don't even need any config space

or

Quoted 2 lines
Quoted 2 lines

BAR for VF or SF by multiplexing the registers for PF.

Quoted 7 lines
Quoted 1 line

Scale issue is: when you want to create, query, manipulate hundreds of

objects, having shared MMIO register or configuration register, will be too slow.

Ok, this need to be clarified in the commit log. And we need make sure it's not an issue that is only happen for some specific vendor.

It is present in the v2 commit log cover letter.
Please let me know if you think it should be in the actual patch commit log.

Quoted 8 lines
Quoted 1 line

And additionally such register set doesn't scale to allow sharing large

number of bytes as DMA cannot be done.

That's true.

Quoted 1 line

From physical device perspective, it doesn’t scale because device needs to

Quoted 9 lines

have those resources ready to answer on MMIO reads and for hundreds to thousand of devices it just cannot do it.

Quoted 1 line

This is one of the reason for birth of IMS.

IMS allows the table to be stored in the memory and cached by the device to have the best scalability. But I had other questions:

1) if we have a single admin virtqueue, there will still be contention in the driver side

AQ inherently allows out of order commands execution.
It shouldn't face contention. For example 1K depth AQ should be serving hundreds of descriptors commands in parallel for SF creation, VF MSI-X config and more.

Quoted 8 lines
Quoted 7 lines

Which area/commands etc you think can lead to the contention?

Quoted 3 lines

2) if we have per vf admin virtqueue, it still doesn't scale since it occupies more hardware resources

That is too heavy, and doesn’t scale. Proposal is to not have per vf admin queue. Proposal is to have one admin queue in a virtio device.

Right ? where did we mention something that can imply otherwise ?

Well, I don't know but probably this part,

" PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ ..."

Quoted 45 lines
Quoted 45 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line

I do see one advantage is that the admin virtqueue is transport

independent

Quoted 3 lines
Quoted 2 lines

(or it could be used as a transport).

I am yet to read the transport part from [1].

Yes, the main goal is to be compatible with SIOV.

Admin queue is a command interface transport where higher layer services can be buit. This includes SR-IOV config, SIOV config.
And v2 enables SIOV commands implementation whenever they are ready.

Quoted 34 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

4. Improve documentation around msix config to link to sriov section of

virtio

Quoted 6 lines
Quoted 6 lines

spec

Quoted 1 line

5. Describe error that if VF is bound to the device, admin commands

targeting VF can fail, describe this error code

Quoted 3 lines

Did I miss anything?

Yet to receive your feedback on group, if/why is it needed and, why/if it

must

Quoted 7 lines
Quoted 7 lines

be in this proposal, what pieces prevents it do as follow-on.

Quoted 2 lines

Cornelia, Jason,
Can you please review current proposal as well before we revise v2?

If I understand correctly, most of the features (except for the admin virtqueue in_order stuffs) are not specific to the admin virtqueue. As discussed in the previous versions, I still think it's better:

Quoted 7 lines
Quoted 5 lines

1) adding sections in the basic device facility or data structure for provisioning and MSI
2) introduce admin virtqueue on top as an device interface for those features

I didn't follow your suggestion. Can you please explain? Specifically "data structure for provisioning and MSI"..

I meant:

There's a chapter "Basic Facilities of a Virtio Device", we can introduce the concepts there like:

1) Managed device and Management device (terminology proposed by Michael), and can use PF and VF as a example

2) Managed device provisioning (the data structure to specify the attributes of a managed device (VF))

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

3) MSI

Above is good idea. Will revisit v2, if it is not arranged this way.

Let me make sure I understand, you would like to see a new chapter under "Basic Facilities of a Virtio Device" that is

called "Device management" and this chapter will explain in few words the concept

Yes.

Quoted 4 lines

and it will point to another chapter under "Basic Facilities of a Virtio Device"

that was introduced here "Admin Virtqueues" ?

So far as I see from the proposal, it needs belong to PCI transport part or a new transport.

Quoted 8 lines
Quoted 6 lines

No it's not.

It should stay in the basic/generic area like we discussed in the past and already agreed on.

Lets move forward please.

Yes, for the general admin virtqueue part, it should be fine, but for SR-IOV ATTRS part, is it better to move it to PCI transport?

Did you see V2 ?

I've added a chapter in the PCI for PCI-specific admin capabilities.

And we have the "Admin Virtqueues" section to have a common place for all admin opcodes and cmd structure (optional and mandatory).

Quoted 46 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

So you do agree that managing a managed (create/destroy/setup/etc...) will be done using the AQ of the managing device ?

I agree.

Thanks

Ok so I guess we agree on the concept of this patch set and the AQ.

Yes.

Thanks

Quoted 35 lines

Thanks.

Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 8 lines

And then we can introduced admin virtqueue in either

1) transport part

or

2) PCI transport

It is not specific to PCI transport, and currently it is not a transport either. So admin queue will keep as general entity for admin work.

Quoted 3 lines

In the admin virtqueue, there will be commands to provision and configure MSI.

Please review v2 if it is not arranged this way.

Quoted 11 lines
Quoted 4 lines
Quoted 3 lines

The leaves the chance for future extensions to allow those features to be used by transport specific interface which will benefit for

AQ allows communication (command, response) between driver and device

in transport independent way.

Quoted 4 lines

Sometimes it query/set transport specific fields like MSI-X vectors of VF. Sometimes device configure its on IMS interrupt.
Something else in future.
So it is really a generic request-response queue.

I agree, but I think we can't mandate new features to a specific transport.

Certainly. Admin queue is transport independent.
PCI MSI-X configuration is PCI transport specific command, so structures are defined it accordingly. It is similar to struct virtio_pci_cap, struct virtio_pci_common_cfg etc.

Any other transport will have transport specific interrupt configuration. So it will be defined accordingly whenever that occurs. For example, IMS for VF or IMS for SF.

#86 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Jason Wang
Quoted 18 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 26, 2022 2:37 PM

Quoted 12 lines · Parav Pandit
Quoted 12 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 26, 2022 12:24 PM

Quoted 5 lines
Quoted 3 lines

1) the vendor and transport that doesn't want to use admin virtqueue

It is not the choice of vendor to use admin virtqueue or not. It is the spec

definition.

Quoted 7 lines
Quoted 1 line
Quoted 1 line

We are discussing the proposal which hasn't been a part of the spec right

now.

Quoted 2 lines
Quoted 1 line

It doesn't mean we can't do better.

Sure. It’s the proposal we are discussing, but I fail to understand why a vendor

doesn’t want to use a admin queue due to which it needs to be detached.

What do you mean by "detached"?

Detaching the mgmt cmd from the admin queue.

Quoted 8 lines
Quoted 8 lines

A descriptor in a virtqueue represents wide range of things.
1. Sometime sending packet,
2. sometimes configuring vlan,
3. sometime configuring adding mac to table.
4. sometime adding crypto session
5. and now sometime managing a managed VF or SF device

Quoted 5 lines
Quoted 2 lines

Item #5 is no different than #1 to #4.
Managed device configuration != "generic configure the device".

Well, I think then you need to explain this well in the patch.

Did you get a chance to review v2 commit log?
It describes the motivation for AQ.

Quoted 4 lines

So a virtqueue is needed only when DMA is required. That is the case for virtio_fs_req.

For other cases that DMA is not a must, it could or not be a queue interface.

It is not only the DMA, it is the ability to enqueue multiple requests to the device.

Quoted 9 lines
Quoted 5 lines

If you want to attribute it as "mandate" than yes, it is no different than, virtio_fs_req is mandated on request vq. virtio_crypto_op_ctrl_req ia mandated on control vq.

What prevents both above examples to used AQ in generic manner?

Nothing, but for simple features like MSI I don't think we can exclude the possibility of using dedicated registers. For a simple setup like a guest that is using an MMIO device, using new virtqueue just for MSI seems an odd burden.

You mixing MSI configuration done by guest driver with AQ.
Guest driver can never use AQ for configuring its own vector configuration which must happen before AQ is created. So AQ is not useful for that purpose anyway.
And how many vectors a MMIO device gets, can be always configured by HV over AQ.
Even for the simple setup.

Quoted 2 lines

To clarify, we need to define what exactly did management mean? E.g is IMS considered to be mgmt or control?

What is IMS. Please be specific?
(a) IMS vector configuration before queue configuration by guest driver? Or
(b) IMS vector provisioning for a VF or SF by its parent(management) device by PF?

Above #a falls in the configuration area and needs transport specific registers. Above #b falls in the mgmt bucket.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

Michael also responded that device configuration will not end at msix

configuration.

Quoted 2 lines

So adding more and more tiny capabilities for each configuration doesn't

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

scale either.

Quoted 1 line

You need to ack above point otherwise we will keep discussing this even 2 weeks from now. :)

I think I've acknowledged in another thread about the idea of using admin virtqueue.

Ok. I am clear now that we have ack from you to use AQ for MSI-X provisioning by the HV PF.

#66 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Michael S. Tsirkin
Quoted 10 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 25, 2022 5:39 PM

Quoted 3 lines

So you do agree that managing a managed (create/destroy/setup/etc...) will be done using the AQ of the managing device ?

I think Jason asked that the management commands are split from the queue itself, such that they can be implemented in more ways down the road.

Admin commands involved DMA. And also multiple commands can be enqueued to the device.
I don't see any other construct in the spec other than vq that enables driver and device to achieve both. Hence split the queue from command is very weird for spec to do.

A recent addition like virtio_fs_req didn’t adopt this suggestion.

If we just want to split so that admin commands can be transported via non admin queue, we should remove below line from spec:

"The Admin command set defines the commands that may be issued only to the admin virtqueue"

And reword it as below,

The Admin command set defines the commands to manipulate various features/attributes of another device within the same group... When VIRTIO_F_ADMIN_VQ feature is negotiated, admin commands must be transported through the admin queue.

Looks ok?

#67 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 8 lines · Parav Pandit
Quoted 8 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 25, 2022 5:39 PM

Quoted 3 lines

So you do agree that managing a managed (create/destroy/setup/etc...) will be done using the AQ of the managing device ?

Quoted 6 lines
Quoted 2 lines

I think Jason asked that the management commands are split from the queue itself, such that they can be implemented in more ways down the road.

Admin commands involved DMA. And also multiple commands can be enqueued to the device.
I don't see any other construct in the spec other than vq that enables driver and device to achieve both. Hence split the queue from command is very weird for spec to do.

VIRTIO_PCI_CAP_SHARED_MEMORY_CFG can do this.

Quoted 5 lines

A recent addition like virtio_fs_req didn’t adopt this suggestion.

If we just want to split so that admin commands can be transported via non admin queue, we should remove below line from spec:

"The Admin command set defines the commands that may be issued only to the admin virtqueue"

sure

Quoted 6 lines

And reword it as below,

The Admin command set defines the commands to manipulate various features/attributes of another device within the same group... When VIRTIO_F_ADMIN_VQ feature is negotiated, admin commands must be transported through the admin queue.

Looks ok?

I see no problem with that.

Signature · 1 line
MST
#76 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Max Gurtovoy
Quoted 187 lines · Max Gurtovoy
Quoted 184 lines · Jason Wang
Quoted 183 lines · Max Gurtovoy
Quoted 171 lines · Jason Wang
Quoted 105 lines · Max Gurtovoy
Quoted 104 lines · Parav Pandit

Hi Jason,

Quoted 26 lines

From: Jason Wang <[email protected]>
Sent: Tuesday, January 25, 2022 8:59 AM

Quoted 11 lines · Parav Pandit
Quoted 10 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, January 19, 2022 9:33 AM

It it means IMS, there's already a proposal[1] that introduce MSI commands via the admin virtqueue. And we had similar requirement for virtio-MMIO[2] and managed device or SF [3], so I would rather to introduce IMS (need a better name though) as a basic facility instead of tie it to any specific transport.

IMS of [1] is a interrupt configuration by the virtio driver for the device is it

driving, which needs a queue.

Quoted 1 line

So regardless of the device type as PCI PF/VF/SF/ADI, there is desire to have a

generic admin queue not attached to device type.

Quoted 3 lines

And AQ in this proposal exactly serves this purpose.

Device configuring its own IMS vector vs PCI PF configuring VF's MSI-X max

vector count are two different functionality.

Quoted 4 lines

Both of these commands can ride on a generic queue. However the queue is not same, because PF owns its own admin queue (for vf msix config), VF or SF operates its own admin queue (for IMS config).

Quoted 9 lines

So I think in the next version we need to clarify:

1) is there a single admin virtqueue shared by all the VFs and PF

or

2) per VF/PF admin virtqueue, and how does the driver know how to find the corresponding admin virtqueue

Admin queue is not per VF.
Lets take concrete examples.
1. So for example, PCI PF can have one AQ.
This AQ carries command to query/config MSI-X vector of VFs.

2. In second example, PCI PF is creating/destroying SFs. This is again done by using the AQ of the PCI PF.

3. A PCI VF has its own AQ to configure some of its own generic attribute, don't know which is that today. May be something that is extremely hard to do over features bit.
Currently proposed v2 doesn't restrict admin queue to be within PCI PF or VF or that matter not limited to other transports.

Quoted 8 lines
Quoted 3 lines

So a good example is,
1. PCI PF configures 8 MSI-X or 16 IMS vectors for the VF using PF_AQ in HV.
2. PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ

in GVM.

Quoted 1 line

Both the functions will have AQ feature bit set.

Where did the VF_AQ sit? I guess it belongs to the VF. But if this is true, don't we need some kind of address isolation like PASID?

Above one for IMS is not a good example. I replied the reasoning last week for it.

Quoted 5 lines
Quoted 1 line

Fair enough, so we have more users of admin queue than just MSI-X config.

Well, what I really meant is that we actually have more users of IMS. That's is exactly what virito-mmio wants. In this case introducing admin queue looks too heavyweight for that.

IMS config cannot be done over AQ as described in previous email in this thread.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

2. AQ to follows IN_ORDER and INDIRECT_DESC negotiation like rest of the queues 3. Update commit log to describe why config space is not chosen (scale, on-die registers, uniform way to handle all aq cmds)

I fail to understand the scale/registeres issues. With the one of my previous proposal (device selector), technically we don't even need any config space

or

Quoted 2 lines
Quoted 2 lines

BAR for VF or SF by multiplexing the registers for PF.

Quoted 7 lines
Quoted 1 line

Scale issue is: when you want to create, query, manipulate hundreds of

objects, having shared MMIO register or configuration register, will be too slow.

Ok, this need to be clarified in the commit log. And we need make sure it's not an issue that is only happen for some specific vendor.

It is present in the v2 commit log cover letter.
Please let me know if you think it should be in the actual patch commit log.

Quoted 8 lines
Quoted 1 line

And additionally such register set doesn't scale to allow sharing large

number of bytes as DMA cannot be done.

That's true.

Quoted 1 line

From physical device perspective, it doesn’t scale because device needs to

Quoted 9 lines

have those resources ready to answer on MMIO reads and for hundreds to thousand of devices it just cannot do it.

Quoted 1 line

This is one of the reason for birth of IMS.

IMS allows the table to be stored in the memory and cached by the device to have the best scalability. But I had other questions:

1) if we have a single admin virtqueue, there will still be contention in the driver side

AQ inherently allows out of order commands execution.
It shouldn't face contention. For example 1K depth AQ should be serving hundreds of descriptors commands in parallel for SF creation, VF MSI-X config and more.

Quoted 8 lines
Quoted 7 lines

Which area/commands etc you think can lead to the contention?

Quoted 3 lines

2) if we have per vf admin virtqueue, it still doesn't scale since it occupies more hardware resources

That is too heavy, and doesn’t scale. Proposal is to not have per vf admin queue. Proposal is to have one admin queue in a virtio device.

Right ? where did we mention something that can imply otherwise ?

Well, I don't know but probably this part,

" PCI VF when using IMS configures, IMS data, vector, mask etc using VF_AQ ..."

Quoted 45 lines
Quoted 45 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line

I do see one advantage is that the admin virtqueue is transport

independent

Quoted 3 lines
Quoted 2 lines

(or it could be used as a transport).

I am yet to read the transport part from [1].

Yes, the main goal is to be compatible with SIOV.

Admin queue is a command interface transport where higher layer services can be buit. This includes SR-IOV config, SIOV config.
And v2 enables SIOV commands implementation whenever they are ready.

Quoted 34 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

4. Improve documentation around msix config to link to sriov section of

virtio

Quoted 6 lines
Quoted 6 lines

spec

Quoted 1 line

5. Describe error that if VF is bound to the device, admin commands

targeting VF can fail, describe this error code

Quoted 3 lines

Did I miss anything?

Yet to receive your feedback on group, if/why is it needed and, why/if it

must

Quoted 7 lines
Quoted 7 lines

be in this proposal, what pieces prevents it do as follow-on.

Quoted 2 lines

Cornelia, Jason,
Can you please review current proposal as well before we revise v2?

If I understand correctly, most of the features (except for the admin virtqueue in_order stuffs) are not specific to the admin virtqueue. As discussed in the previous versions, I still think it's better:

Quoted 7 lines
Quoted 5 lines

1) adding sections in the basic device facility or data structure for provisioning and MSI
2) introduce admin virtqueue on top as an device interface for those features

I didn't follow your suggestion. Can you please explain? Specifically "data structure for provisioning and MSI"..

I meant:

There's a chapter "Basic Facilities of a Virtio Device", we can introduce the concepts there like:

1) Managed device and Management device (terminology proposed by Michael), and can use PF and VF as a example

2) Managed device provisioning (the data structure to specify the attributes of a managed device (VF))

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

3) MSI

Above is good idea. Will revisit v2, if it is not arranged this way.

Let me make sure I understand, you would like to see a new chapter under "Basic Facilities of a Virtio Device" that is

called "Device management" and this chapter will explain in few words the concept

Quoted 8 lines

Yes.

Quoted 4 lines

and it will point to another chapter under "Basic Facilities of a Virtio Device"

that was introduced here "Admin Virtqueues" ?

So far as I see from the proposal, it needs belong to PCI transport part or a new transport.

No it's not.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

It should stay in the basic/generic area like we discussed in the past and already agreed on.

Lets move forward please.

Yes, for the general admin virtqueue part, it should be fine, but for SR-IOV ATTRS part, is it better to move it to PCI transport?

Did you see V2 ?

Not yet for the time of last reply.

Quoted 2 lines

I've added a chapter in the PCI for PCI-specific admin capabilities.

But I still see stuffs like PF/VF in the general chapter.

Do we need to

1) using more general terminology

or

2) move those to PCI part?

Thanks

Quoted 51 lines

And we have the "Admin Virtqueues" section to have a common place for all admin opcodes and cmd structure (optional and mandatory).

Quoted 46 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

So you do agree that managing a managed (create/destroy/setup/etc...) will be done using the AQ of the managing device ?

I agree.

Thanks

Ok so I guess we agree on the concept of this patch set and the AQ.

Yes.

Thanks

Quoted 35 lines

Thanks.

Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 8 lines

And then we can introduced admin virtqueue in either

1) transport part

or

2) PCI transport

It is not specific to PCI transport, and currently it is not a transport either. So admin queue will keep as general entity for admin work.

Quoted 3 lines

In the admin virtqueue, there will be commands to provision and configure MSI.

Please review v2 if it is not arranged this way.

Quoted 11 lines
Quoted 4 lines
Quoted 3 lines

The leaves the chance for future extensions to allow those features to be used by transport specific interface which will benefit for

AQ allows communication (command, response) between driver and device

in transport independent way.

Quoted 4 lines

Sometimes it query/set transport specific fields like MSI-X vectors of VF. Sometimes device configure its on IMS interrupt.
Something else in future.
So it is really a generic request-response queue.

I agree, but I think we can't mandate new features to a specific transport.

Certainly. Admin queue is transport independent.
PCI MSI-X configuration is PCI transport specific command, so structures are defined it accordingly. It is similar to struct virtio_pci_cap, struct virtio_pci_common_cfg etc.

Any other transport will have transport specific interrupt configuration. So it will be defined accordingly whenever that occurs. For example, IMS for VF or IMS for SF.

#68 lore raw

RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Michael S. Tsirkin
Quoted 18 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Wednesday, January 26, 2022 7:42 PM

Quoted 7 lines · Parav Pandit
Quoted 7 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 25, 2022 5:39 PM

Quoted 3 lines

So you do agree that managing a managed (create/destroy/setup/etc...) will be done using the AQ of the managing

device ?

Quoted 3 lines
Quoted 3 lines

I think Jason asked that the management commands are split from the queue itself, such that they can be implemented in more ways down the

road.

Quoted 1 line
Quoted 8 lines
Quoted 1 line

Admin commands involved DMA. And also multiple commands can be

enqueued to the device.

Quoted 1 line

I don't see any other construct in the spec other than vq that enables driver

and device to achieve both.

Quoted 1 line

Hence split the queue from command is very weird for spec to do.

VIRTIO_PCI_CAP_SHARED_MEMORY_CFG can do this.

Device needs to always have shared memory region always in available range for driver to read. Driver still needs to copy data from shared region to own memory.
How DMA Can be done in the host driver PA using shared memory region?

In future when SIOV occurs, each new SIOV SF/ADI will require new window in the shared regions exposed statically during PCI discovery time. So it doesn't scale.

Quoted 13 lines
Quoted 4 lines

A recent addition like virtio_fs_req didn’t adopt this suggestion.

If we just want to split so that admin commands can be transported via non

admin queue, we should remove below line from spec:

Quoted 2 lines

"The Admin command set defines the commands that may be issued only to

the admin virtqueue"

sure

Quoted 2 lines

And reword it as below,

Quoted 8 lines
Quoted 1 line

The Admin command set defines the commands to manipulate various

features/attributes of another device within the same group...

Quoted 1 line

When VIRTIO_F_ADMIN_VQ feature is negotiated, admin commands must

be transported through the admin queue.

Quoted 2 lines

Looks ok?

I see no problem with that.

Since we agree for this, I considered AQ vs no_AQ as closed topic?

#69 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 21 lines · Parav Pandit
Quoted 21 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Wednesday, January 26, 2022 7:42 PM

Quoted 7 lines · Parav Pandit
Quoted 7 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 25, 2022 5:39 PM

Quoted 3 lines

So you do agree that managing a managed (create/destroy/setup/etc...) will be done using the AQ of the managing

device ?

Quoted 3 lines
Quoted 3 lines

I think Jason asked that the management commands are split from the queue itself, such that they can be implemented in more ways down the

road.

Quoted 2 lines

Admin commands involved DMA. And also multiple commands can be

enqueued to the device.

Quoted 1 line

I don't see any other construct in the spec other than vq that enables driver

Quoted 8 lines
Quoted 5 lines

and device to achieve both.

Quoted 1 line

Hence split the queue from command is very weird for spec to do.

VIRTIO_PCI_CAP_SHARED_MEMORY_CFG can do this.

Device needs to always have shared memory region always in available range for driver to read. Driver still needs to copy data from shared region to own memory.
How DMA Can be done in the host driver PA using shared memory region?

It can't but you don't need DMA if device is writing its own memory.

Quoted 3 lines

In future when SIOV occurs, each new SIOV SF/ADI will require new window in the shared regions exposed statically during PCI discovery time.

Donnu if it's statically. But we are talking about AQ thing, that is just per group not per SF, so might not be too bad.

Quoted 1 line

So it doesn't scale.

Maybe. You said that's the only way to queue commands to device in the spec, I just responded with a way. No need to code that up right now, but just something to keep in mind, things are not absolute here.

Quoted 15 lines
Quoted 15 lines
Quoted 4 lines

A recent addition like virtio_fs_req didn’t adopt this suggestion.

If we just want to split so that admin commands can be transported via non

admin queue, we should remove below line from spec:

Quoted 2 lines

"The Admin command set defines the commands that may be issued only to

the admin virtqueue"

sure

Quoted 3 lines

And reword it as below,

The Admin command set defines the commands to manipulate various

features/attributes of another device within the same group...

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

When VIRTIO_F_ADMIN_VQ feature is negotiated, admin commands must

be transported through the admin queue.

Quoted 2 lines

Looks ok?

I see no problem with that.

Since we agree for this, I considered AQ vs no_AQ as closed topic?

It's always hard to answer questions like this when all I have to go on is a vague idea of what you mean. Based on the discussion I am guessing that your v3 will use the VQ in a way that is not controversial if that is what you are asking about.

Signature · 1 line
MST
#70 lore raw

[virtio-dev] RE: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

Quoted 32 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Thursday, January 27, 2022 6:36 PM

Quoted 27 lines · Parav Pandit
Quoted 27 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Wednesday, January 26, 2022 7:42 PM

Quoted 8 lines · Parav Pandit
Quoted 8 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 25, 2022 5:39 PM

Quoted 4 lines

So you do agree that managing a managed (create/destroy/setup/etc...) will be done using the AQ of the managing

device ?

Quoted 4 lines
Quoted 4 lines

I think Jason asked that the management commands are split from the queue itself, such that they can be implemented in more ways down the

road.

Quoted 2 lines

Admin commands involved DMA. And also multiple commands can be

enqueued to the device.

Quoted 2 lines

I don't see any other construct in the spec other than vq that enables driver

and device to achieve both.

Quoted 1 line

Hence split the queue from command is very weird for spec to do.

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

VIRTIO_PCI_CAP_SHARED_MEMORY_CFG can do this.

Device needs to always have shared memory region always in available

range for driver to read.

Quoted 2 lines

Driver still needs to copy data from shared region to own memory. How DMA Can be done in the host driver PA using shared memory region?

It can't but you don't need DMA if device is writing its own memory.

And sometimes host also needs to write. So DMA is required.

Quoted 7 lines
Quoted 4 lines

In future when SIOV occurs, each new SIOV SF/ADI will require new window in the shared regions exposed statically during PCI discovery time.

Donnu if it's statically. But we are talking about AQ thing, that is just per group not per SF, so might not be too bad.

I must repeat again that it requires memory to be always available at scale.
For example if a virtio device state requires 1Kbytes of metadata, you are asking device to implement 1Mbytes of memory to be accessible in PCI read latency time window. This is super waste of device resources for querying objects used only during mgmt. time.

If you were thinking to use this shared memory regions as small region and using it for command queuing interface, than probably yes, but than it starts looking like spec's well defined VQ object. And at that point reinventing VQ of shared memory just doesn’t make much sense.

Quoted 4 lines
Quoted 1 line

Since we agree for this, I considered AQ vs no_AQ as closed topic?

It's always hard to answer questions like this when all I have to go on is a vague idea of what you mean.

Which area is still vague? Can you please be specific, so that it can be covered in v3? We answered all or almost the queries.
We addressed the comments you requested in V2.
Did you get a chance to review v2?

Jason's comment of splitting admin commands from admin queue is major item to fix in v3. Documenting section differently, some in transport specific area was another fix to happen in v3.

In v3, if we are again going to discuss AQ vs config mmio region vs shared region, than we should discuss now before posting v3. So please let me know if this area is vague or something else.

#71 lore raw

Re: [PATCH 2/5] Introduce VIRTIO_F_ADMIN_VQ_INDIRECT_DESC/VIRTIO_F_ADMIN_VQ_IN_ORDER

In reply to Parav Pandit
Quoted 9 lines · Parav Pandit
Quoted 6 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, January 25, 2022 5:39 PM

Quoted 2 lines

So you do agree that managing a managed (create/destroy/setup/etc...) will be done using the AQ of the managing device ?

I think Jason asked that the management commands are split from the queue itself, such that they can be implemented in more ways down the road.

Admin commands involved DMA. And also multiple commands can be enqueued to the device.
I don't see any other construct in the spec other than vq that enables driver and device to achieve both. Hence split the queue from command is very weird for spec to do.

I'd say it really depends on the transport. Not all transport uses registers. There could be transport that:

1) use DMA (e.g CCW)

2) use transport specific queue

3) doesn't need DMA at all (e.g using shared memory like virtio-rproc)

Having another VQ seems redundant.

Thanks

Quoted 13 lines

A recent addition like virtio_fs_req didn’t adopt this suggestion.

If we just want to split so that admin commands can be transported via non admin queue, we should remove below line from spec:

"The Admin command set defines the commands that may be issued only to the admin virtqueue"

And reword it as below,

The Admin command set defines the commands to manipulate various features/attributes of another device within the same group... When VIRTIO_F_ADMIN_VQ feature is negotiated, admin commands must be transported through the admin queue.

Looks ok?