virtio-comment

 View Only
Expand all | Collapse all

[PATCH v3 0/2] Support enabling virtqueue after DRIVER_OK

  • 1.  [PATCH v3 0/2] Support enabling virtqueue after DRIVER_OK

    Posted 10-02-2023 05:16
    Summary:
    ========
    This patch enables driver to create virtqueues after DRIVER_OK
    status bit is set.

    This patch take the inspiration from the thread [2] with credits to
    Eugenio PÃrez.

    Details:
    ========
    Currently, a virtqueue must be enabled before driver has set the
    DRIVER_OK status bit.

    spec citation to section "Driver Requirements: Device Initialization"

    "Perform device-specific setup, including discovery of virtqueues
    for the device, optional per-bus setup, reading and possibly writing
    the device’s virtio configuration space, and population of virtqueues."

    This implies that a virtqueue must be enabled before reaching the
    DRIVER_OK stage. There was no explicit mention about ability to
    enable the virtqueue after DRIVER_OK stage.

    In following usecases, creating a virtqueue after DRIVER_OK phase is
    desired.

    Use cases:
    =========
    1. Dynamically create aq when administrative commands to be used.
    ate the net device tx/rxq when device is
    opened when deploying for a container.
    In a container, number of virtqueues to be used may be <= max queues.
    3. Dynamically create flow filter queues of netdevice when
    ARFS or ethtool filters are enabled as listed in [1].
    4. Dynamically create rtc functionality related read virtqueue only
    when net device when timestamping to be used.
    5. When XDP program is set, one can create additional XDP specific
    queues without affecting existing queues.

    Hence, This patch introduces an existing queue enable and disable
    (aka reset) facility and a new feature bit to explicitly indicate such
    support by the device.

    With this feature, drivers can skip optional queues creation during
    driver init time. For example, a Linux net device driver
    can create/destroy the transmit and receive queues when net device's
    ndo_open() and ndo_stop() callbacks are invoked respectively.

    [1] https://lists.oasis-open.org/archives/virtio-comment/202308/msg00263.html
    [2] https://lists.oasis-open.org/archives/virtio-comment/202306/msg00097.html

    Patch summary:
    ==============
    patch-1 fixes to add virtqueue reset conformance references
    patch-2 adds VIRTIO_F_RING_DYNAMIC feature bit, requirements

    Please review.

    Fixes: https://github.com/oasis-tcs/virtio-spec/issues/177

    ---
    changelog:
    v2->v3:
    - github issue link updated
    v1->v2:
    - fixed comments from Michael
    - reduced device and driver normatives (simplified)
    - replace 'a virtqueue' to 'the virtqueues'
    - reworded to remove 'interested'
    - avoided repeated 'device initialization text', replaced with
    DRIVER_OK status bit language
    - avoided confusing text around 'MAY' in the requirements
    - replaced 'the queue' to 'specific virtqueues'
    - replaced queue to virtqueue
    - simplified commit log to talk about msix
    v0->v1:
    - fixed comments from Xuan
    - removed blank lines
    - fixed wrong requirement link to device in driver section


    Parav Pandit (2):
    conformance: Add missing virtqueue reset conformance references
    content: Support enabling virtqueue after DRIVER_OK stage

    conformance.tex | 4 ++++
    content.tex | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
    2 files changed, 50 insertions(+), 3 deletions(-)

    --
    2.34.1




  • 2.  [PATCH v3 1/2] conformance: Add missing virtqueue reset conformance references

    Posted 10-02-2023 05:16
    Add the missing references to the virtqueue reset related conformance
    requirements.

    Signed-off-by: Parav Pandit <parav@nvidia.com>
    Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
    ---
    conformance.tex | 2 ++
    1 file changed, 2 insertions(+)

    diff --git a/conformance.tex b/conformance.tex
    index dc00e84..863f9c5 100644
    --- a/conformance.tex
    +++ b/conformance.tex
    @@ -76,6 +76,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
    \item \ref{drivernormative:Basic Facilities of a Virtio Device / Device Reset}
    \item \ref{drivernormative:Basic Facilities of a Virtio Device / Device Configuration Space}
    \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues}
    +\item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Reset / Virtqueue Reset}
    \item \ref{drivernormative:Basic Facilities of a Virtio Device / Message Framing}
    \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table}
    \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
    @@ -162,6 +163,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
    \item \ref{devicenormative:Basic Facilities of a Virtio Device / Feature Bits}
    \item \ref{devicenormative:Basic Facilities of a Virtio Device / Device Reset}
    \item \ref{devicenormative:Basic Facilities of a Virtio Device / Device Configuration Space}
    +\item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Reset / Virtqueue Reset}
    \item \ref{devicenormative:Basic Facilities of a Virtio Device / Message Framing}
    \item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table}
    \item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
    --
    2.34.1




  • 3.  Re: [virtio-comment] [PATCH v3 1/2] conformance: Add missing virtqueue reset conformance references

    Posted 10-05-2023 16:54
    On Mon, Oct 2, 2023 at 7:16?AM Parav Pandit <parav@nvidia.com> wrote:
    >
    > Add the missing references to the virtqueue reset related conformance
    > requirements.
    >

    acked-by was not carried from v1:

    Acked-by: Eugenio Pérez <eperezma@redhat.com>

    > Signed-off-by: Parav Pandit <parav@nvidia.com>
    > Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
    > ---
    > conformance.tex | 2 ++
    > 1 file changed, 2 insertions(+)
    >
    > diff --git a/conformance.tex b/conformance.tex
    > index dc00e84..863f9c5 100644
    > --- a/conformance.tex
    > +++ b/conformance.tex
    > @@ -76,6 +76,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Device Reset}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Device Configuration Space}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues}
    > +\item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Reset / Virtqueue Reset}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Message Framing}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
    > @@ -162,6 +163,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Feature Bits}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Device Reset}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Device Configuration Space}
    > +\item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Reset / Virtqueue Reset}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Message Framing}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
    > --
    > 2.34.1
    >
    >
    > This publicly archived list offers a means to provide input to the
    > OASIS Virtual I/O Device (VIRTIO) TC.
    >
    > In order to verify user consent to the Feedback License terms and
    > to minimize spam in the list archive, subscription is required
    > before posting.
    >
    > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
    > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
    > List help: virtio-comment-help@lists.oasis-open.org
    > List archive: https://lists.oasis-open.org/archives/virtio-comment/
    > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
    > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
    > Committee: https://www.oasis-open.org/committees/virtio/
    > Join OASIS: https://www.oasis-open.org/join/
    >




  • 4.  [PATCH v3 2/2] content: Support enabling virtqueue after DRIVER_OK stage

    Posted 10-02-2023 05:16
    Currently, a virtqueue must be enabled before driver has set the
    DRIVER_OK status bit.

    spec citation to section "Driver Requirements: Device Initialization"

    "Perform device-specific setup, including discovery of virtqueues
    for the device, optional per-bus setup, reading and possibly writing
    the device’s virtio configuration space, and population of virtqueues."

    This implies that a virtqueue must be enabled before reaching the
    DRIVER_OK stage. There was no explicit mention about ability to
    enable the virtqueue after DRIVER_OK stage.

    In following usecases, creating a virtqueue after DRIVER_OK phase is
    desired.

    1. Dynamically create aq when administrative commands to be used.
    2. Dynamically create the net device tx/rxq when device is
    opened when deploying for a container.
    In a container, number of virtqueues to be used may be <= max queues.
    3. Dynamically create flow filter queues of netdevice when
    ARFS or ethtool filters are enabled as listed in [1].
    4. Dynamically create rtc functionality related read virtqueue only
    when net device when timestamping to be used.
    5. When XDP program is set, one can create additional XDP specific
    queues without affecting existing queues.

    Hence, This patch introduces an existing queue enable and disable
    (aka reset) facility and a new feature bit to explicitly indicate such
    support by the device.

    With this feature, drivers can skip optional queues creation during
    driver init time. For example, a Linux net device driver
    can create/destroy the transmit and receive queues when net device's
    ndo_open() and ndo_stop() callbacks are invoked respectively.

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

    Fixes: https://github.com/oasis-tcs/virtio-spec/issues/177
    Signed-off-by: Parav Pandit <parav@nvidia.com>
    ---
    changelog:
    v2->v3:
    - github fixes tag added
    v1->v2:
    - fixed comments from Michael
    - reduced device and driver normatives (simplified)
    - replace 'a virtqueue' to 'the virtqueues'
    - reworded to remove 'interested'
    - avoided repeated 'device initialization text', replaced with
    DRIVER_OK status bit language
    - avoided confusing text around 'MAY' in the requirements
    - replaced 'the queue' to 'specific virtqueues'
    - replaced queue to virtqueue
    - simplified commit log to talk about msix
    v0->v1:
    - fixed comments from Xuan
    - removed blank lines
    - fixed wrong requirement link to device in driver section
    ---
    conformance.tex | 2 ++
    content.tex | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
    2 files changed, 48 insertions(+), 3 deletions(-)

    diff --git a/conformance.tex b/conformance.tex
    index 863f9c5..75de58c 100644
    --- a/conformance.tex
    +++ b/conformance.tex
    @@ -77,6 +77,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
    \item \ref{drivernormative:Basic Facilities of a Virtio Device / Device Configuration Space}
    \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues}
    \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Reset / Virtqueue Reset}
    +\item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues / Enable Virtqueues}
    \item \ref{drivernormative:Basic Facilities of a Virtio Device / Message Framing}
    \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table}
    \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
    @@ -164,6 +165,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
    \item \ref{devicenormative:Basic Facilities of a Virtio Device / Device Reset}
    \item \ref{devicenormative:Basic Facilities of a Virtio Device / Device Configuration Space}
    \item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Reset / Virtqueue Reset}
    +\item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues / Enable Virtqueues}
    \item \ref{devicenormative:Basic Facilities of a Virtio Device / Message Framing}
    \item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table}
    \item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
    diff --git a/content.tex b/content.tex
    index 0a62dce..1a296a9 100644
    --- a/content.tex
    +++ b/content.tex
    @@ -102,7 +102,7 @@ \section{Feature Bits}\label{sec:Basic Facilities of a Virtio Device / Feature B
    \item[24 to 41] Feature bits reserved for extensions to the queue and
    feature negotiation mechanisms

    -\item[42 to 49, and 128 and above] Feature bits reserved for future extensions.
    +\item[43 to 49, and 128 and above] Feature bits reserved for future extensions.
    \end{description}

    \begin{note}
    @@ -440,6 +440,38 @@ \subsubsection{Virtqueue Re-enable}\label{sec:Basic Facilities of a Virtio Devic
    as during initial virtqueue discovery, but optionally with different
    parameters.

    +\subsection{Dynamic Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues}
    +
    +When VIRTIO_F_RING_DYNAMIC is not negotiated, the driver enables the virtqueues
    +during the device initialization sequence, i.e. after the device sets the
    +FEATURES_OK status bit and before the driver setting the DRIVER_OK status bit.
    +
    +When VIRTIO_F_RING_DYNAMIC is negotiated, the driver can avoid enabling the
    +virtqueues before setting the DRIVER_OK status bit; the driver can enable the
    +specific virtqueues after the driver has set the DRIVER_OK status bit.
    +The virtqueue enable mechanism is transport specific.
    +
    +\devicenormative{\paragraph}{Enable Virtqueues}{Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues / Enable Virtqueues}
    +
    +When VIRTIO_F_RING_DYNAMIC is negotiated, the device MUST allow enabling the
    +virtqueue which was not enabled during the device initialization phase
    +i.e. after the device has set the FEATURES_OK status bit and before the
    +driver has set the DRIVER_OK status bit.
    +
    +\drivernormative{\paragraph}{Enable Virtqueues}{Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues / Enable Virtqueues}
    +
    +When VIRTIO_F_RING_DYNAMIC is negotiated,
    +\begin{itemize}
    +\item the driver MAY enable some or all the virtqueues after the driver has set the
    + DRIVER_OK status bit.
    +
    +\item the driver MAY enable some of the virtqueues or all the virtqueues or none of
    + the virtqueues before the driver has set the DRIVER_OK status bit.
    +\end{itemize}
    +
    +When VIRTIO_F_RING_DYNAMIC is not negotiated, the driver MUST enable the
    +required number of virtqueues before setting the DRIVER_OK status bit.
    +
    \input{split-ring.tex}

    \input{packed-ring.tex}
    @@ -537,7 +569,9 @@ \section{Device Initialization}\label{sec:General Initialization And Device Oper

    \item\label{itm:General Initialization And Device Operation / Device Initialization / Device-specific Setup} Perform device-specific setup, including discovery of virtqueues for the
    device, optional per-bus setup, reading and possibly writing the
    - device's virtio configuration space, and population of virtqueues.
    + device's virtio configuration space.
    +
    +\item\label{itm:General Initialization And Device Operation / Device Initialization / Virtqueue Setup} Configure and enable the virtqueues.

    \item\label{itm:General Initialization And Device Operation / Device Initialization / Set DRIVER-OK} Set the DRIVER_OK status bit. At this point the device is
    ``live''.
    @@ -551,6 +585,10 @@ \section{Device Initialization}\label{sec:General Initialization And Device Oper
    The driver MUST NOT send any buffer available notifications to
    the device before setting DRIVER_OK.

    +The driver MAY skip step
    +\ref{itm:General Initialization And Device Operation / Device Initialization / Virtqueue Setup}
    +when driver has negotiated VIRTIO_F_RING_DYNAMIC feature.
    +
    \subsection{Legacy Interface: Device Initialization}\label{sec:General Initialization And Device Operation / Device Initialization / Legacy Interface: Device Initialization}
    Legacy devices did not support the FEATURES_OK status bit, and thus did
    not have a graceful way for the device to indicate unsupported feature
    @@ -569,7 +607,7 @@ \subsection{Legacy Interface: Device Initialization}\label{sec:General Initializ
    Initialization / Re-read FEATURES-OK} were omitted, and steps
    \ref{itm:General Initialization And Device Operation /
    Device Initialization / Read feature bits},
    -\ref{itm:General Initialization And Device Operation / Device Initialization / Device-specific Setup} and \ref{itm:General Initialization And Device Operation / Device Initialization / Set DRIVER-OK}
    +\ref{itm:General Initialization And Device Operation / Device Initialization / Device-specific Setup}, \ref{itm:General Initialization And Device Operation / Device Initialization / Virtqueue Setup} and \ref{itm:General Initialization And Device Operation / Device Initialization / Set DRIVER-OK}
    were conflated.

    Therefore, when using the legacy interface:
    @@ -872,6 +910,11 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
    \ref{devicenormative:Basic Facilities of a Virtio Device / Feature Bits} for
    handling features reserved for future use.

    + \item[VIRTIO_F_RING_DYNAMIC(42)] This feature indicates
    + that the driver can enable the virtqueues individually after the driver has
    + set the status bit of DRIVER_OK.
    + See \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues}.
    +
    \end{description}

    \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
    --
    2.34.1




  • 5.  Re: [virtio-comment] [PATCH v3 2/2] content: Support enabling virtqueue after DRIVER_OK stage

    Posted 10-05-2023 16:53
    On Mon, Oct 2, 2023 at 7:17?AM Parav Pandit <parav@nvidia.com> wrote:
    >
    > Currently, a virtqueue must be enabled before driver has set the
    > DRIVER_OK status bit.
    >
    > spec citation to section "Driver Requirements: Device Initialization"
    >
    > "Perform device-specific setup, including discovery of virtqueues
    > for the device, optional per-bus setup, reading and possibly writing
    > the device’s virtio configuration space, and population of virtqueues."
    >
    > This implies that a virtqueue must be enabled before reaching the
    > DRIVER_OK stage. There was no explicit mention about ability to
    > enable the virtqueue after DRIVER_OK stage.
    >
    > In following usecases, creating a virtqueue after DRIVER_OK phase is
    > desired.
    >
    > 1. Dynamically create aq when administrative commands to be used.
    > 2. Dynamically create the net device tx/rxq when device is
    > opened when deploying for a container.
    > In a container, number of virtqueues to be used may be <= max queues.
    > 3. Dynamically create flow filter queues of netdevice when
    > ARFS or ethtool filters are enabled as listed in [1].
    > 4. Dynamically create rtc functionality related read virtqueue only
    > when net device when timestamping to be used.
    > 5. When XDP program is set, one can create additional XDP specific
    > queues without affecting existing queues.
    >
    > Hence, This patch introduces an existing queue enable and disable
    > (aka reset) facility and a new feature bit to explicitly indicate such
    > support by the device.
    >
    > With this feature, drivers can skip optional queues creation during
    > driver init time. For example, a Linux net device driver
    > can create/destroy the transmit and receive queues when net device's
    > ndo_open() and ndo_stop() callbacks are invoked respectively.
    >
    > [1] https://lists.oasis-open.org/archives/virtio-comment/202308/msg00263.html
    >
    > Fixes: https://github.com/oasis-tcs/virtio-spec/issues/177

    Acked-by: Eugenio Pérez <eperezma@redhat.com>

    > Signed-off-by: Parav Pandit <parav@nvidia.com>
    > ---
    > changelog:
    > v2->v3:
    > - github fixes tag added
    > v1->v2:
    > - fixed comments from Michael
    > - reduced device and driver normatives (simplified)
    > - replace 'a virtqueue' to 'the virtqueues'
    > - reworded to remove 'interested'
    > - avoided repeated 'device initialization text', replaced with
    > DRIVER_OK status bit language
    > - avoided confusing text around 'MAY' in the requirements
    > - replaced 'the queue' to 'specific virtqueues'
    > - replaced queue to virtqueue
    > - simplified commit log to talk about msix
    > v0->v1:
    > - fixed comments from Xuan
    > - removed blank lines
    > - fixed wrong requirement link to device in driver section
    > ---
    > conformance.tex | 2 ++
    > content.tex | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
    > 2 files changed, 48 insertions(+), 3 deletions(-)
    >
    > diff --git a/conformance.tex b/conformance.tex
    > index 863f9c5..75de58c 100644
    > --- a/conformance.tex
    > +++ b/conformance.tex
    > @@ -77,6 +77,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Device Configuration Space}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Reset / Virtqueue Reset}
    > +\item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues / Enable Virtqueues}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Message Framing}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
    > @@ -164,6 +165,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Device Reset}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Device Configuration Space}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Reset / Virtqueue Reset}
    > +\item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues / Enable Virtqueues}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Message Framing}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
    > diff --git a/content.tex b/content.tex
    > index 0a62dce..1a296a9 100644
    > --- a/content.tex
    > +++ b/content.tex
    > @@ -102,7 +102,7 @@ \section{Feature Bits}\label{sec:Basic Facilities of a Virtio Device / Feature B
    > \item[24 to 41] Feature bits reserved for extensions to the queue and
    > feature negotiation mechanisms
    >
    > -\item[42 to 49, and 128 and above] Feature bits reserved for future extensions.
    > +\item[43 to 49, and 128 and above] Feature bits reserved for future extensions.
    > \end{description}
    >
    > \begin{note}
    > @@ -440,6 +440,38 @@ \subsubsection{Virtqueue Re-enable}\label{sec:Basic Facilities of a Virtio Devic
    > as during initial virtqueue discovery, but optionally with different
    > parameters.
    >
    > +\subsection{Dynamic Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues}
    > +
    > +When VIRTIO_F_RING_DYNAMIC is not negotiated, the driver enables the virtqueues
    > +during the device initialization sequence, i.e. after the device sets the
    > +FEATURES_OK status bit and before the driver setting the DRIVER_OK status bit.
    > +
    > +When VIRTIO_F_RING_DYNAMIC is negotiated, the driver can avoid enabling the
    > +virtqueues before setting the DRIVER_OK status bit; the driver can enable the
    > +specific virtqueues after the driver has set the DRIVER_OK status bit.
    > +The virtqueue enable mechanism is transport specific.
    > +
    > +\devicenormative{\paragraph}{Enable Virtqueues}{Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues / Enable Virtqueues}
    > +
    > +When VIRTIO_F_RING_DYNAMIC is negotiated, the device MUST allow enabling the
    > +virtqueue which was not enabled during the device initialization phase
    > +i.e. after the device has set the FEATURES_OK status bit and before the
    > +driver has set the DRIVER_OK status bit.
    > +
    > +\drivernormative{\paragraph}{Enable Virtqueues}{Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues / Enable Virtqueues}
    > +
    > +When VIRTIO_F_RING_DYNAMIC is negotiated,
    > +\begin{itemize}
    > +\item the driver MAY enable some or all the virtqueues after the driver has set the
    > + DRIVER_OK status bit.
    > +
    > +\item the driver MAY enable some of the virtqueues or all the virtqueues or none of
    > + the virtqueues before the driver has set the DRIVER_OK status bit.
    > +\end{itemize}
    > +
    > +When VIRTIO_F_RING_DYNAMIC is not negotiated, the driver MUST enable the
    > +required number of virtqueues before setting the DRIVER_OK status bit.
    > +
    > \input{split-ring.tex}
    >
    > \input{packed-ring.tex}
    > @@ -537,7 +569,9 @@ \section{Device Initialization}\label{sec:General Initialization And Device Oper
    >
    > \item\label{itm:General Initialization And Device Operation / Device Initialization / Device-specific Setup} Perform device-specific setup, including discovery of virtqueues for the
    > device, optional per-bus setup, reading and possibly writing the
    > - device's virtio configuration space, and population of virtqueues.
    > + device's virtio configuration space.
    > +
    > +\item\label{itm:General Initialization And Device Operation / Device Initialization / Virtqueue Setup} Configure and enable the virtqueues.
    >
    > \item\label{itm:General Initialization And Device Operation / Device Initialization / Set DRIVER-OK} Set the DRIVER_OK status bit. At this point the device is
    > ``live''.
    > @@ -551,6 +585,10 @@ \section{Device Initialization}\label{sec:General Initialization And Device Oper
    > The driver MUST NOT send any buffer available notifications to
    > the device before setting DRIVER_OK.
    >
    > +The driver MAY skip step
    > +\ref{itm:General Initialization And Device Operation / Device Initialization / Virtqueue Setup}
    > +when driver has negotiated VIRTIO_F_RING_DYNAMIC feature.
    > +
    > \subsection{Legacy Interface: Device Initialization}\label{sec:General Initialization And Device Operation / Device Initialization / Legacy Interface: Device Initialization}
    > Legacy devices did not support the FEATURES_OK status bit, and thus did
    > not have a graceful way for the device to indicate unsupported feature
    > @@ -569,7 +607,7 @@ \subsection{Legacy Interface: Device Initialization}\label{sec:General Initializ
    > Initialization / Re-read FEATURES-OK} were omitted, and steps
    > \ref{itm:General Initialization And Device Operation /
    > Device Initialization / Read feature bits},
    > -\ref{itm:General Initialization And Device Operation / Device Initialization / Device-specific Setup} and \ref{itm:General Initialization And Device Operation / Device Initialization / Set DRIVER-OK}
    > +\ref{itm:General Initialization And Device Operation / Device Initialization / Device-specific Setup}, \ref{itm:General Initialization And Device Operation / Device Initialization / Virtqueue Setup} and \ref{itm:General Initialization And Device Operation / Device Initialization / Set DRIVER-OK}
    > were conflated.
    >
    > Therefore, when using the legacy interface:
    > @@ -872,6 +910,11 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
    > \ref{devicenormative:Basic Facilities of a Virtio Device / Feature Bits} for
    > handling features reserved for future use.
    >
    > + \item[VIRTIO_F_RING_DYNAMIC(42)] This feature indicates
    > + that the driver can enable the virtqueues individually after the driver has
    > + set the status bit of DRIVER_OK.
    > + See \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues}.
    > +
    > \end{description}
    >
    > \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
    > --
    > 2.34.1
    >
    >
    > This publicly archived list offers a means to provide input to the
    > OASIS Virtual I/O Device (VIRTIO) TC.
    >
    > In order to verify user consent to the Feedback License terms and
    > to minimize spam in the list archive, subscription is required
    > before posting.
    >
    > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
    > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
    > List help: virtio-comment-help@lists.oasis-open.org
    > List archive: https://lists.oasis-open.org/archives/virtio-comment/
    > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
    > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
    > Committee: https://www.oasis-open.org/committees/virtio/
    > Join OASIS: https://www.oasis-open.org/join/
    >




  • 6.  Re: [PATCH v3 2/2] content: Support enabling virtqueue after DRIVER_OK stage

    Posted 10-12-2023 06:39
    On Mon, 2 Oct 2023 08:16:01 +0300, Parav Pandit <parav@nvidia.com> wrote:
    > Currently, a virtqueue must be enabled before driver has set the
    > DRIVER_OK status bit.
    >
    > spec citation to section "Driver Requirements: Device Initialization"
    >
    > "Perform device-specific setup, including discovery of virtqueues
    > for the device, optional per-bus setup, reading and possibly writing
    > the device’s virtio configuration space, and population of virtqueues."
    >
    > This implies that a virtqueue must be enabled before reaching the
    > DRIVER_OK stage. There was no explicit mention about ability to
    > enable the virtqueue after DRIVER_OK stage.
    >
    > In following usecases, creating a virtqueue after DRIVER_OK phase is
    > desired.
    >
    > 1. Dynamically create aq when administrative commands to be used.
    > 2. Dynamically create the net device tx/rxq when device is
    > opened when deploying for a container.
    > In a container, number of virtqueues to be used may be <= max queues.
    > 3. Dynamically create flow filter queues of netdevice when
    > ARFS or ethtool filters are enabled as listed in [1].
    > 4. Dynamically create rtc functionality related read virtqueue only
    > when net device when timestamping to be used.
    > 5. When XDP program is set, one can create additional XDP specific
    > queues without affecting existing queues.
    >
    > Hence, This patch introduces an existing queue enable and disable
    > (aka reset) facility and a new feature bit to explicitly indicate such
    > support by the device.
    >
    > With this feature, drivers can skip optional queues creation during
    > driver init time. For example, a Linux net device driver
    > can create/destroy the transmit and receive queues when net device's
    > ndo_open() and ndo_stop() callbacks are invoked respectively.
    >
    > [1] https://lists.oasis-open.org/archives/virtio-comment/202308/msg00263.html
    >
    > Fixes: https://github.com/oasis-tcs/virtio-spec/issues/177
    > Signed-off-by: Parav Pandit <parav@nvidia.com>

    Acked-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>


    > ---
    > changelog:
    > v2->v3:
    > - github fixes tag added
    > v1->v2:
    > - fixed comments from Michael
    > - reduced device and driver normatives (simplified)
    > - replace 'a virtqueue' to 'the virtqueues'
    > - reworded to remove 'interested'
    > - avoided repeated 'device initialization text', replaced with
    > DRIVER_OK status bit language
    > - avoided confusing text around 'MAY' in the requirements
    > - replaced 'the queue' to 'specific virtqueues'
    > - replaced queue to virtqueue
    > - simplified commit log to talk about msix
    > v0->v1:
    > - fixed comments from Xuan
    > - removed blank lines
    > - fixed wrong requirement link to device in driver section
    > ---
    > conformance.tex | 2 ++
    > content.tex | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
    > 2 files changed, 48 insertions(+), 3 deletions(-)
    >
    > diff --git a/conformance.tex b/conformance.tex
    > index 863f9c5..75de58c 100644
    > --- a/conformance.tex
    > +++ b/conformance.tex
    > @@ -77,6 +77,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Device Configuration Space}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Reset / Virtqueue Reset}
    > +\item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues / Enable Virtqueues}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Message Framing}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table}
    > \item \ref{drivernormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
    > @@ -164,6 +165,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Device Reset}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Device Configuration Space}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Reset / Virtqueue Reset}
    > +\item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues / Enable Virtqueues}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Message Framing}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table}
    > \item \ref{devicenormative:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
    > diff --git a/content.tex b/content.tex
    > index 0a62dce..1a296a9 100644
    > --- a/content.tex
    > +++ b/content.tex
    > @@ -102,7 +102,7 @@ \section{Feature Bits}\label{sec:Basic Facilities of a Virtio Device / Feature B
    > \item[24 to 41] Feature bits reserved for extensions to the queue and
    > feature negotiation mechanisms
    >
    > -\item[42 to 49, and 128 and above] Feature bits reserved for future extensions.
    > +\item[43 to 49, and 128 and above] Feature bits reserved for future extensions.
    > \end{description}
    >
    > \begin{note}
    > @@ -440,6 +440,38 @@ \subsubsection{Virtqueue Re-enable}\label{sec:Basic Facilities of a Virtio Devic
    > as during initial virtqueue discovery, but optionally with different
    > parameters.
    >
    > +\subsection{Dynamic Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues}
    > +
    > +When VIRTIO_F_RING_DYNAMIC is not negotiated, the driver enables the virtqueues
    > +during the device initialization sequence, i.e. after the device sets the
    > +FEATURES_OK status bit and before the driver setting the DRIVER_OK status bit.
    > +
    > +When VIRTIO_F_RING_DYNAMIC is negotiated, the driver can avoid enabling the
    > +virtqueues before setting the DRIVER_OK status bit; the driver can enable the
    > +specific virtqueues after the driver has set the DRIVER_OK status bit.
    > +The virtqueue enable mechanism is transport specific.
    > +
    > +\devicenormative{\paragraph}{Enable Virtqueues}{Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues / Enable Virtqueues}
    > +
    > +When VIRTIO_F_RING_DYNAMIC is negotiated, the device MUST allow enabling the
    > +virtqueue which was not enabled during the device initialization phase
    > +i.e. after the device has set the FEATURES_OK status bit and before the
    > +driver has set the DRIVER_OK status bit.
    > +
    > +\drivernormative{\paragraph}{Enable Virtqueues}{Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues / Enable Virtqueues}
    > +
    > +When VIRTIO_F_RING_DYNAMIC is negotiated,
    > +\begin{itemize}
    > +\item the driver MAY enable some or all the virtqueues after the driver has set the
    > + DRIVER_OK status bit.
    > +
    > +\item the driver MAY enable some of the virtqueues or all the virtqueues or none of
    > + the virtqueues before the driver has set the DRIVER_OK status bit.
    > +\end{itemize}
    > +
    > +When VIRTIO_F_RING_DYNAMIC is not negotiated, the driver MUST enable the
    > +required number of virtqueues before setting the DRIVER_OK status bit.
    > +
    > \input{split-ring.tex}
    >
    > \input{packed-ring.tex}
    > @@ -537,7 +569,9 @@ \section{Device Initialization}\label{sec:General Initialization And Device Oper
    >
    > \item\label{itm:General Initialization And Device Operation / Device Initialization / Device-specific Setup} Perform device-specific setup, including discovery of virtqueues for the
    > device, optional per-bus setup, reading and possibly writing the
    > - device's virtio configuration space, and population of virtqueues.
    > + device's virtio configuration space.
    > +
    > +\item\label{itm:General Initialization And Device Operation / Device Initialization / Virtqueue Setup} Configure and enable the virtqueues.
    >
    > \item\label{itm:General Initialization And Device Operation / Device Initialization / Set DRIVER-OK} Set the DRIVER_OK status bit. At this point the device is
    > ``live''.
    > @@ -551,6 +585,10 @@ \section{Device Initialization}\label{sec:General Initialization And Device Oper
    > The driver MUST NOT send any buffer available notifications to
    > the device before setting DRIVER_OK.
    >
    > +The driver MAY skip step
    > +\ref{itm:General Initialization And Device Operation / Device Initialization / Virtqueue Setup}
    > +when driver has negotiated VIRTIO_F_RING_DYNAMIC feature.
    > +
    > \subsection{Legacy Interface: Device Initialization}\label{sec:General Initialization And Device Operation / Device Initialization / Legacy Interface: Device Initialization}
    > Legacy devices did not support the FEATURES_OK status bit, and thus did
    > not have a graceful way for the device to indicate unsupported feature
    > @@ -569,7 +607,7 @@ \subsection{Legacy Interface: Device Initialization}\label{sec:General Initializ
    > Initialization / Re-read FEATURES-OK} were omitted, and steps
    > \ref{itm:General Initialization And Device Operation /
    > Device Initialization / Read feature bits},
    > -\ref{itm:General Initialization And Device Operation / Device Initialization / Device-specific Setup} and \ref{itm:General Initialization And Device Operation / Device Initialization / Set DRIVER-OK}
    > +\ref{itm:General Initialization And Device Operation / Device Initialization / Device-specific Setup}, \ref{itm:General Initialization And Device Operation / Device Initialization / Virtqueue Setup} and \ref{itm:General Initialization And Device Operation / Device Initialization / Set DRIVER-OK}
    > were conflated.
    >
    > Therefore, when using the legacy interface:
    > @@ -872,6 +910,11 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
    > \ref{devicenormative:Basic Facilities of a Virtio Device / Feature Bits} for
    > handling features reserved for future use.
    >
    > + \item[VIRTIO_F_RING_DYNAMIC(42)] This feature indicates
    > + that the driver can enable the virtqueues individually after the driver has
    > + set the status bit of DRIVER_OK.
    > + See \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues}.
    > +
    > \end{description}
    >
    > \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
    > --
    > 2.34.1
    >



  • 7.  Re: [PATCH v3 2/2] content: Support enabling virtqueue after DRIVER_OK stage

    Posted 10-17-2023 12:25
    On Mon, Oct 02 2023, Parav Pandit <parav@nvidia.com> wrote:

    > Currently, a virtqueue must be enabled before driver has set the
    > DRIVER_OK status bit.
    >
    > spec citation to section "Driver Requirements: Device Initialization"
    >
    > "Perform device-specific setup, including discovery of virtqueues
    > for the device, optional per-bus setup, reading and possibly writing
    > the device’s virtio configuration space, and population of virtqueues."
    >
    > This implies that a virtqueue must be enabled before reaching the
    > DRIVER_OK stage. There was no explicit mention about ability to
    > enable the virtqueue after DRIVER_OK stage.
    >
    > In following usecases, creating a virtqueue after DRIVER_OK phase is
    > desired.
    >
    > 1. Dynamically create aq when administrative commands to be used.
    > 2. Dynamically create the net device tx/rxq when device is
    > opened when deploying for a container.
    > In a container, number of virtqueues to be used may be <= max queues.
    > 3. Dynamically create flow filter queues of netdevice when
    > ARFS or ethtool filters are enabled as listed in [1].
    > 4. Dynamically create rtc functionality related read virtqueue only
    > when net device when timestamping to be used.
    > 5. When XDP program is set, one can create additional XDP specific
    > queues without affecting existing queues.
    >
    > Hence, This patch introduces an existing queue enable and disable
    > (aka reset) facility and a new feature bit to explicitly indicate such
    > support by the device.
    >
    > With this feature, drivers can skip optional queues creation during
    > driver init time. For example, a Linux net device driver
    > can create/destroy the transmit and receive queues when net device's
    > ndo_open() and ndo_stop() callbacks are invoked respectively.
    >
    > [1] https://lists.oasis-open.org/archives/virtio-comment/202308/msg00263.html
    >
    > Fixes: https://github.com/oasis-tcs/virtio-spec/issues/177
    > Signed-off-by: Parav Pandit <parav@nvidia.com>
    > ---
    > changelog:
    > v2->v3:
    > - github fixes tag added
    > v1->v2:
    > - fixed comments from Michael
    > - reduced device and driver normatives (simplified)
    > - replace 'a virtqueue' to 'the virtqueues'
    > - reworded to remove 'interested'
    > - avoided repeated 'device initialization text', replaced with
    > DRIVER_OK status bit language
    > - avoided confusing text around 'MAY' in the requirements
    > - replaced 'the queue' to 'specific virtqueues'
    > - replaced queue to virtqueue
    > - simplified commit log to talk about msix
    > v0->v1:
    > - fixed comments from Xuan
    > - removed blank lines
    > - fixed wrong requirement link to device in driver section
    > ---
    > conformance.tex | 2 ++
    > content.tex | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
    > 2 files changed, 48 insertions(+), 3 deletions(-)
    >

    (...)

    > @@ -440,6 +440,38 @@ \subsubsection{Virtqueue Re-enable}\label{sec:Basic Facilities of a Virtio Devic
    > as during initial virtqueue discovery, but optionally with different
    > parameters.
    >
    > +\subsection{Dynamic Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues}
    > +
    > +When VIRTIO_F_RING_DYNAMIC is not negotiated, the driver enables the virtqueues
    > +during the device initialization sequence, i.e. after the device sets the
    > +FEATURES_OK status bit and before the driver setting the DRIVER_OK status bit.

    _Or_ if a virtqueue has been reset and the driver wants to re-enable it,
    right?

    > +
    > +When VIRTIO_F_RING_DYNAMIC is negotiated, the driver can avoid enabling the
    > +virtqueues before setting the DRIVER_OK status bit; the driver can enable the
    > +specific virtqueues after the driver has set the DRIVER_OK status bit.

    "the driver is not required to enable every virtqueue it wants to use
    before setting the DRIVER_OK status bit; it can choose to enable a
    virtqueue even after it has set the DRIVER_OK status bit."

    > +The virtqueue enable mechanism is transport specific.

    Would that be the same mechanism as for re-enabling a queue after a
    queue reset? I guess I'm missing the relationship here...

    > +
    > +\devicenormative{\paragraph}{Enable Virtqueues}{Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues / Enable Virtqueues}
    > +
    > +When VIRTIO_F_RING_DYNAMIC is negotiated, the device MUST allow enabling the
    > +virtqueue which was not enabled during the device initialization phase

    s/the virtqueue/a virtqueue/

    > +i.e. after the device has set the FEATURES_OK status bit and before the
    > +driver has set the DRIVER_OK status bit.
    > +
    > +\drivernormative{\paragraph}{Enable Virtqueues}{Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues / Enable Virtqueues}
    > +
    > +When VIRTIO_F_RING_DYNAMIC is negotiated,
    > +\begin{itemize}
    > +\item the driver MAY enable some or all the virtqueues after the driver has set the
    > + DRIVER_OK status bit.
    > +
    > +\item the driver MAY enable some of the virtqueues or all the virtqueues or none of
    > + the virtqueues before the driver has set the DRIVER_OK status bit.
    > +\end{itemize}

    Can we write this more concisely as

    "When VIRTIO_F_RING_DYNAMIC is negotiated, the driver MAY enable any
    virtqueue either before or after it has set the DRIVER_OK status bit."

    ?

    > +
    > +When VIRTIO_F_RING_DYNAMIC is not negotiated, the driver MUST enable the
    > +required number of virtqueues before setting the DRIVER_OK status bit.

    What does "required" mean here? It just chooses to enable the queues it
    wants to use, right?

    I'm also still not quite clear how this relates to re-enabling queues
    after queue reset.

    > +
    > \input{split-ring.tex}
    >
    > \input{packed-ring.tex}
    > @@ -537,7 +569,9 @@ \section{Device Initialization}\label{sec:General Initialization And Device Oper
    >
    > \item\label{itm:General Initialization And Device Operation / Device Initialization / Device-specific Setup} Perform device-specific setup, including discovery of virtqueues for the
    > device, optional per-bus setup, reading and possibly writing the
    > - device's virtio configuration space, and population of virtqueues.
    > + device's virtio configuration space.
    > +
    > +\item\label{itm:General Initialization And Device Operation / Device Initialization / Virtqueue Setup} Configure and enable the virtqueues.
    >
    > \item\label{itm:General Initialization And Device Operation / Device Initialization / Set DRIVER-OK} Set the DRIVER_OK status bit. At this point the device is
    > ``live''.
    > @@ -551,6 +585,10 @@ \section{Device Initialization}\label{sec:General Initialization And Device Oper
    > The driver MUST NOT send any buffer available notifications to
    > the device before setting DRIVER_OK.
    >
    > +The driver MAY skip step
    > +\ref{itm:General Initialization And Device Operation / Device Initialization / Virtqueue Setup}
    > +when driver has negotiated VIRTIO_F_RING_DYNAMIC feature.

    That's confusing: It may not only skip it, but also enable only a subset
    of the queues it wants to use later.

    > +
    > \subsection{Legacy Interface: Device Initialization}\label{sec:General Initialization And Device Operation / Device Initialization / Legacy Interface: Device Initialization}
    > Legacy devices did not support the FEATURES_OK status bit, and thus did
    > not have a graceful way for the device to indicate unsupported feature
    > @@ -569,7 +607,7 @@ \subsection{Legacy Interface: Device Initialization}\label{sec:General Initializ
    > Initialization / Re-read FEATURES-OK} were omitted, and steps
    > \ref{itm:General Initialization And Device Operation /
    > Device Initialization / Read feature bits},
    > -\ref{itm:General Initialization And Device Operation / Device Initialization / Device-specific Setup} and \ref{itm:General Initialization And Device Operation / Device Initialization / Set DRIVER-OK}
    > +\ref{itm:General Initialization And Device Operation / Device Initialization / Device-specific Setup}, \ref{itm:General Initialization And Device Operation / Device Initialization / Virtqueue Setup} and \ref{itm:General Initialization And Device Operation / Device Initialization / Set DRIVER-OK}
    > were conflated.
    >
    > Therefore, when using the legacy interface:
    > @@ -872,6 +910,11 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
    > \ref{devicenormative:Basic Facilities of a Virtio Device / Feature Bits} for
    > handling features reserved for future use.
    >
    > + \item[VIRTIO_F_RING_DYNAMIC(42)] This feature indicates
    > + that the driver can enable the virtqueues individually after the driver has

    s/the virtqueues/virtqueues/

    > + set the status bit of DRIVER_OK.
    > + See \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Dynamic Virtqueues}.
    > +
    > \end{description}
    >
    > \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}

    We currently have a device normative statement:

    "The device MUST NOT consume buffers or send any used buffer
    notifications to the driver before DRIVER_OK."

    I guess we need to extend that to not doing that for not-yet-enabled
    queues in the dynamic virtqueue case? There's a (transport-specific)
    point in time when the driver tells the device that the queue is ready,
    right?




  • 8.  RE: [PATCH v3 2/2] content: Support enabling virtqueue after DRIVER_OK stage

    Posted 10-17-2023 12:48

    > From: Cornelia Huck <cohuck@redhat.com>
    > Sent: Tuesday, October 17, 2023 5:55 PM
    >
    > On Mon, Oct 02 2023, Parav Pandit <parav@nvidia.com> wrote:
    >
    > > Currently, a virtqueue must be enabled before driver has set the
    > > DRIVER_OK status bit.
    > >
    > > spec citation to section "Driver Requirements: Device Initialization"
    > >
    > > "Perform device-specific setup, including discovery of virtqueues for
    > > the device, optional per-bus setup, reading and possibly writing the
    > > device’s virtio configuration space, and population of virtqueues."
    > >
    > > This implies that a virtqueue must be enabled before reaching the
    > > DRIVER_OK stage. There was no explicit mention about ability to enable
    > > the virtqueue after DRIVER_OK stage.
    > >
    > > In following usecases, creating a virtqueue after DRIVER_OK phase is
    > > desired.
    > >
    > > 1. Dynamically create aq when administrative commands to be used.
    > > 2. Dynamically create the net device tx/rxq when device is
    > > opened when deploying for a container.
    > > In a container, number of virtqueues to be used may be <= max queues.
    > > 3. Dynamically create flow filter queues of netdevice when
    > > ARFS or ethtool filters are enabled as listed in [1].
    > > 4. Dynamically create rtc functionality related read virtqueue only
    > > when net device when timestamping to be used.
    > > 5. When XDP program is set, one can create additional XDP specific
    > > queues without affecting existing queues.
    > >
    > > Hence, This patch introduces an existing queue enable and disable (aka
    > > reset) facility and a new feature bit to explicitly indicate such
    > > support by the device.
    > >
    > > With this feature, drivers can skip optional queues creation during
    > > driver init time. For example, a Linux net device driver can
    > > create/destroy the transmit and receive queues when net device's
    > > ndo_open() and ndo_stop() callbacks are invoked respectively.
    > >
    > > [1]
    > > https://lists.oasis-open.org/archives/virtio-comment/202308/msg00263.h
    > > tml
    > >
    > > Fixes: https://github.com/oasis-tcs/virtio-spec/issues/177
    > > Signed-off-by: Parav Pandit <parav@nvidia.com>
    > > ---
    > > changelog:
    > > v2->v3:
    > > - github fixes tag added
    > > v1->v2:
    > > - fixed comments from Michael
    > > - reduced device and driver normatives (simplified)
    > > - replace 'a virtqueue' to 'the virtqueues'
    > > - reworded to remove 'interested'
    > > - avoided repeated 'device initialization text', replaced with
    > > DRIVER_OK status bit language
    > > - avoided confusing text around 'MAY' in the requirements
    > > - replaced 'the queue' to 'specific virtqueues'
    > > - replaced queue to virtqueue
    > > - simplified commit log to talk about msix
    > > v0->v1:
    > > - fixed comments from Xuan
    > > - removed blank lines
    > > - fixed wrong requirement link to device in driver section
    > > ---
    > > conformance.tex | 2 ++
    > > content.tex | 49 ++++++++++++++++++++++++++++++++++++++++++++++--
    > -
    > > 2 files changed, 48 insertions(+), 3 deletions(-)
    > >
    >
    > (...)
    >
    > > @@ -440,6 +440,38 @@ \subsubsection{Virtqueue
    > > Re-enable}\label{sec:Basic Facilities of a Virtio Devic as during
    > > initial virtqueue discovery, but optionally with different parameters.
    > >
    > > +\subsection{Dynamic Virtqueues}\label{sec:Basic Facilities of a
    > > +Virtio Device / Virtqueues / Dynamic Virtqueues}
    > > +
    > > +When VIRTIO_F_RING_DYNAMIC is not negotiated, the driver enables the
    > > +virtqueues during the device initialization sequence, i.e. after the
    > > +device sets the FEATURES_OK status bit and before the driver setting the
    > DRIVER_OK status bit.
    >
    > _Or_ if a virtqueue has been reset and the driver wants to re-enable it, right?
    >
    Well no. Because above text is for "enablement", and not re-enablement.
    If the driver want to reset and re-enable, it must be enabled in first place before setting driver_ok.
    VQ not enabled before driver ok, cannot be reset, and hence cannot be re-enabled.

    So I think above text is fine because it says about "enables" and not "re-enables".

    > > +
    > > +When VIRTIO_F_RING_DYNAMIC is negotiated, the driver can avoid
    > > +enabling the virtqueues before setting the DRIVER_OK status bit; the
    > > +driver can enable the specific virtqueues after the driver has set the
    > DRIVER_OK status bit.
    >
    > "the driver is not required to enable every virtqueue it wants to use before
    > setting the DRIVER_OK status bit; it can choose to enable a virtqueue even after
    > it has set the DRIVER_OK status bit."
    >
    Sounds good. Will change it.

    > > +The virtqueue enable mechanism is transport specific.
    >
    > Would that be the same mechanism as for re-enabling a queue after a queue
    > reset? I guess I'm missing the relationship here...
    >
    Yes, it is same.
    There is no change in enabling/re-enabling the virtqueue after/before DRIVER_OK with/without _dynamic bit.
    So no extra text added here.

    > > +
    > > +\devicenormative{\paragraph}{Enable Virtqueues}{Basic Facilities of a
    > > +Virtio Device / Virtqueues / Dynamic Virtqueues / Enable Virtqueues}
    > > +
    > > +When VIRTIO_F_RING_DYNAMIC is negotiated, the device MUST allow
    > > +enabling the virtqueue which was not enabled during the device
    > > +initialization phase
    >
    > s/the virtqueue/a virtqueue/
    >
    Ack.

    > > +i.e. after the device has set the FEATURES_OK status bit and before
    > > +the driver has set the DRIVER_OK status bit.
    > > +
    > > +\drivernormative{\paragraph}{Enable Virtqueues}{Basic Facilities of a
    > > +Virtio Device / Virtqueues / Dynamic Virtqueues / Enable Virtqueues}
    > > +
    > > +When VIRTIO_F_RING_DYNAMIC is negotiated, \begin{itemize} \item the
    > > +driver MAY enable some or all the virtqueues after the driver has set the
    > > + DRIVER_OK status bit.
    > > +
    > > +\item the driver MAY enable some of the virtqueues or all the virtqueues or
    > none of
    > > + the virtqueues before the driver has set the DRIVER_OK status bit.
    > > +\end{itemize}
    >
    > Can we write this more concisely as
    >
    > "When VIRTIO_F_RING_DYNAMIC is negotiated, the driver MAY enable any
    > virtqueue either before or after it has set the DRIVER_OK status bit."
    >
    > ?
    Looks fine to me. Will change.
    >
    > > +
    > > +When VIRTIO_F_RING_DYNAMIC is not negotiated, the driver MUST enable
    > > +the required number of virtqueues before setting the DRIVER_OK status bit.
    >
    > What does "required" mean here? It just chooses to enable the queues it wants
    > to use, right?
    Right.
    Required meaning, whatever number of queues that driver choose to enable, those must be enabled before driver_ok.
    So it is "required by the driver".
    Would that be ok?

    >
    > I'm also still not quite clear how this relates to re-enabling queues after queue
    > reset.
    Queue can be renabled (after queue reset) only if it was enabled before driver_ok.
    This feature bit allows driver to not do such workaround to enable the queue before driver_ok, that it does not want to use in first place.
    Not sure I answered, what you ask.
    Did I?

    >
    > > +
    > > \input{split-ring.tex}
    > >
    > > \input{packed-ring.tex}
    > > @@ -537,7 +569,9 @@ \section{Device Initialization}\label{sec:General
    > > Initialization And Device Oper
    > >
    > > \item\label{itm:General Initialization And Device Operation / Device
    > Initialization / Device-specific Setup} Perform device-specific setup, including
    > discovery of virtqueues for the
    > > device, optional per-bus setup, reading and possibly writing the
    > > - device's virtio configuration space, and population of virtqueues.
    > > + device's virtio configuration space.
    > > +
    > > +\item\label{itm:General Initialization And Device Operation / Device
    > Initialization / Virtqueue Setup} Configure and enable the virtqueues.
    > >
    > > \item\label{itm:General Initialization And Device Operation / Device
    > Initialization / Set DRIVER-OK} Set the DRIVER_OK status bit. At this point the
    > device is
    > > ``live''.
    > > @@ -551,6 +585,10 @@ \section{Device Initialization}\label{sec:General
    > > Initialization And Device Oper The driver MUST NOT send any buffer
    > > available notifications to the device before setting DRIVER_OK.
    > >
    > > +The driver MAY skip step
    > > +\ref{itm:General Initialization And Device Operation / Device
    > > +Initialization / Virtqueue Setup} when driver has negotiated
    > VIRTIO_F_RING_DYNAMIC feature.
    >
    > That's confusing: It may not only skip it, but also enable only a subset of the
    > queues it wants to use later.
    >
    I will add this extra text, that driver may skip or may enable subset of the queues.

    > > +
    > > \subsection{Legacy Interface: Device
    > > Initialization}\label{sec:General Initialization And Device Operation
    > > / Device Initialization / Legacy Interface: Device Initialization}
    > > Legacy devices did not support the FEATURES_OK status bit, and thus
    > > did not have a graceful way for the device to indicate unsupported
    > > feature @@ -569,7 +607,7 @@ \subsection{Legacy Interface: Device
    > > Initialization}\label{sec:General Initializ Initialization / Re-read
    > > FEATURES-OK} were omitted, and steps \ref{itm:General Initialization
    > > And Device Operation / Device Initialization / Read feature bits},
    > > -\ref{itm:General Initialization And Device Operation / Device
    > > Initialization / Device-specific Setup} and \ref{itm:General
    > > Initialization And Device Operation / Device Initialization / Set
    > > DRIVER-OK}
    > > +\ref{itm:General Initialization And Device Operation / Device
    > > +Initialization / Device-specific Setup}, \ref{itm:General
    > > +Initialization And Device Operation / Device Initialization /
    > > +Virtqueue Setup} and \ref{itm:General Initialization And Device
    > > +Operation / Device Initialization / Set DRIVER-OK}
    > > were conflated.
    > >
    > > Therefore, when using the legacy interface:
    > > @@ -872,6 +910,11 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved
    > Feature Bits}
    > > \ref{devicenormative:Basic Facilities of a Virtio Device / Feature Bits}
    > for
    > > handling features reserved for future use.
    > >
    > > + \item[VIRTIO_F_RING_DYNAMIC(42)] This feature indicates that the
    > > + driver can enable the virtqueues individually after the driver has
    >
    > s/the virtqueues/virtqueues/
    Ack

    >
    > > + set the status bit of DRIVER_OK.
    > > + See \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Dynamic
    > Virtqueues}.
    > > +
    > > \end{description}
    > >
    > > \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature
    > > Bits}
    >
    > We currently have a device normative statement:
    >
    > "The device MUST NOT consume buffers or send any used buffer notifications to
    > the driver before DRIVER_OK."
    >
    > I guess we need to extend that to not doing that for not-yet-enabled queues in
    > the dynamic virtqueue case? There's a (transport-specific) point in time when
    > the driver tells the device that the queue is ready, right?

    We don’t need extend this text because device does not know anything about the disabled queue, so it cannot consume any buffer from it anyway.
    Above line only applied to the enabled virtqueue.



  • 9.  Re: [virtio-comment] RE: [PATCH v3 2/2] content: Support enabling virtqueue after DRIVER_OK stage

    Posted 10-18-2023 10:25
    On Tue, Oct 17 2023, Parav Pandit <parav@nvidia.com> wrote:

    >> From: Cornelia Huck <cohuck@redhat.com>
    >> Sent: Tuesday, October 17, 2023 5:55 PM
    >>
    >> On Mon, Oct 02 2023, Parav Pandit <parav@nvidia.com> wrote:
    >> > @@ -440,6 +440,38 @@ \subsubsection{Virtqueue
    >> > Re-enable}\label{sec:Basic Facilities of a Virtio Devic as during
    >> > initial virtqueue discovery, but optionally with different parameters.
    >> >
    >> > +\subsection{Dynamic Virtqueues}\label{sec:Basic Facilities of a
    >> > +Virtio Device / Virtqueues / Dynamic Virtqueues}
    >> > +
    >> > +When VIRTIO_F_RING_DYNAMIC is not negotiated, the driver enables the
    >> > +virtqueues during the device initialization sequence, i.e. after the
    >> > +device sets the FEATURES_OK status bit and before the driver setting the
    >> DRIVER_OK status bit.
    >>
    >> _Or_ if a virtqueue has been reset and the driver wants to re-enable it, right?
    >>
    > Well no. Because above text is for "enablement", and not re-enablement.
    > If the driver want to reset and re-enable, it must be enabled in first place before setting driver_ok.
    > VQ not enabled before driver ok, cannot be reset, and hence cannot be re-enabled.
    >
    > So I think above text is fine because it says about "enables" and not "re-enables".
    >
    >> > +
    >> > +When VIRTIO_F_RING_DYNAMIC is negotiated, the driver can avoid
    >> > +enabling the virtqueues before setting the DRIVER_OK status bit; the
    >> > +driver can enable the specific virtqueues after the driver has set the
    >> DRIVER_OK status bit.
    >>
    >> "the driver is not required to enable every virtqueue it wants to use before
    >> setting the DRIVER_OK status bit; it can choose to enable a virtqueue even after
    >> it has set the DRIVER_OK status bit."
    >>
    > Sounds good. Will change it.
    >
    >> > +The virtqueue enable mechanism is transport specific.
    >>
    >> Would that be the same mechanism as for re-enabling a queue after a queue
    >> reset? I guess I'm missing the relationship here...
    >>
    > Yes, it is same.
    > There is no change in enabling/re-enabling the virtqueue after/before DRIVER_OK with/without _dynamic bit.
    > So no extra text added here.

    This is not really clear to me just from this text, especially if you
    just wrote above that enabling or re-enabling is something
    different... my understanding would be:

    - if neither dynamic vqs nor queue reset are supported or negotiated,
    the only way to enable a vq is before DRIVER_OK, during setup
    - both of these features rely on the transport supporting enabling
    individual queues (either a queue that has not been enabled before, or
    a queue that has been reset)
    - the transport is supposed to use the same mechanism for either

    Did I get it right? If so, I think we should make it a bit more clear.

    (...)

    >> > +When VIRTIO_F_RING_DYNAMIC is not negotiated, the driver MUST enable
    >> > +the required number of virtqueues before setting the DRIVER_OK status bit.
    >>
    >> What does "required" mean here? It just chooses to enable the queues it wants
    >> to use, right?
    > Right.
    > Required meaning, whatever number of queues that driver choose to enable, those must be enabled before driver_ok.
    > So it is "required by the driver".
    > Would that be ok?

    I'd write it as "the driver MUST enable any virtqueue it plans to use"
    or something like that.

    (...)

    >> We currently have a device normative statement:
    >>
    >> "The device MUST NOT consume buffers or send any used buffer notifications to
    >> the driver before DRIVER_OK."
    >>
    >> I guess we need to extend that to not doing that for not-yet-enabled queues in
    >> the dynamic virtqueue case? There's a (transport-specific) point in time when
    >> the driver tells the device that the queue is ready, right?
    >
    > We don’t need extend this text because device does not know anything about the disabled queue, so it cannot consume any buffer from it anyway.
    > Above line only applied to the enabled virtqueue.

    My point is: DRIVER_OK signals that the driver is done with its setup
    and the device may start to interact with the queue. Depending on the
    mechanism the transport uses for enabling the queue, it may "know" about
    the queue before the driver is ready -- it might need to wait until the
    driver has completed enabling of the queue. Not sure if that is worth
    spelling out.




  • 10.  Re: [virtio-comment] RE: [PATCH v3 2/2] content: Support enabling virtqueue after DRIVER_OK stage

    Posted 10-18-2023 10:28
    On Wed, Oct 18, 2023 at 12:25:23PM +0200, Cornelia Huck wrote:
    > On Tue, Oct 17 2023, Parav Pandit <parav@nvidia.com> wrote:
    >
    > >> From: Cornelia Huck <cohuck@redhat.com>
    > >> Sent: Tuesday, October 17, 2023 5:55 PM
    > >>
    > >> On Mon, Oct 02 2023, Parav Pandit <parav@nvidia.com> wrote:
    > >> > @@ -440,6 +440,38 @@ \subsubsection{Virtqueue
    > >> > Re-enable}\label{sec:Basic Facilities of a Virtio Devic as during
    > >> > initial virtqueue discovery, but optionally with different parameters.
    > >> >
    > >> > +\subsection{Dynamic Virtqueues}\label{sec:Basic Facilities of a
    > >> > +Virtio Device / Virtqueues / Dynamic Virtqueues}
    > >> > +
    > >> > +When VIRTIO_F_RING_DYNAMIC is not negotiated, the driver enables the
    > >> > +virtqueues during the device initialization sequence, i.e. after the
    > >> > +device sets the FEATURES_OK status bit and before the driver setting the
    > >> DRIVER_OK status bit.
    > >>
    > >> _Or_ if a virtqueue has been reset and the driver wants to re-enable it, right?
    > >>
    > > Well no. Because above text is for "enablement", and not re-enablement.
    > > If the driver want to reset and re-enable, it must be enabled in first place before setting driver_ok.
    > > VQ not enabled before driver ok, cannot be reset, and hence cannot be re-enabled.
    > >
    > > So I think above text is fine because it says about "enables" and not "re-enables".
    > >
    > >> > +
    > >> > +When VIRTIO_F_RING_DYNAMIC is negotiated, the driver can avoid
    > >> > +enabling the virtqueues before setting the DRIVER_OK status bit; the
    > >> > +driver can enable the specific virtqueues after the driver has set the
    > >> DRIVER_OK status bit.
    > >>
    > >> "the driver is not required to enable every virtqueue it wants to use before
    > >> setting the DRIVER_OK status bit; it can choose to enable a virtqueue even after
    > >> it has set the DRIVER_OK status bit."
    > >>
    > > Sounds good. Will change it.
    > >
    > >> > +The virtqueue enable mechanism is transport specific.
    > >>
    > >> Would that be the same mechanism as for re-enabling a queue after a queue
    > >> reset? I guess I'm missing the relationship here...
    > >>
    > > Yes, it is same.
    > > There is no change in enabling/re-enabling the virtqueue after/before DRIVER_OK with/without _dynamic bit.
    > > So no extra text added here.
    >
    > This is not really clear to me just from this text, especially if you
    > just wrote above that enabling or re-enabling is something
    > different... my understanding would be:
    >
    > - if neither dynamic vqs nor queue reset are supported or negotiated,
    > the only way to enable a vq is before DRIVER_OK, during setup
    > - both of these features rely on the transport supporting enabling
    > individual queues (either a queue that has not been enabled before, or
    > a queue that has been reset)
    > - the transport is supposed to use the same mechanism for either
    >
    > Did I get it right? If so, I think we should make it a bit more clear.
    >
    > (...)
    >
    > >> > +When VIRTIO_F_RING_DYNAMIC is not negotiated, the driver MUST enable
    > >> > +the required number of virtqueues before setting the DRIVER_OK status bit.
    > >>
    > >> What does "required" mean here? It just chooses to enable the queues it wants
    > >> to use, right?
    > > Right.
    > > Required meaning, whatever number of queues that driver choose to enable, those must be enabled before driver_ok.
    > > So it is "required by the driver".
    > > Would that be ok?
    >
    > I'd write it as "the driver MUST enable any virtqueue it plans to use"
    > or something like that.
    >
    > (...)

    It would have to be SHOULD - we can't add new MUST requirements not
    contingent on a feature bit, we can give recommendation based on
    existing installed base.

    > >> We currently have a device normative statement:
    > >>
    > >> "The device MUST NOT consume buffers or send any used buffer notifications to
    > >> the driver before DRIVER_OK."
    > >>
    > >> I guess we need to extend that to not doing that for not-yet-enabled queues in
    > >> the dynamic virtqueue case? There's a (transport-specific) point in time when
    > >> the driver tells the device that the queue is ready, right?
    > >
    > > We don’t need extend this text because device does not know anything about the disabled queue, so it cannot consume any buffer from it anyway.
    > > Above line only applied to the enabled virtqueue.
    >
    > My point is: DRIVER_OK signals that the driver is done with its setup
    > and the device may start to interact with the queue. Depending on the
    > mechanism the transport uses for enabling the queue, it may "know" about
    > the queue before the driver is ready -- it might need to wait until the
    > driver has completed enabling of the queue. Not sure if that is worth
    > spelling out.




  • 11.  Re: [virtio-comment] RE: [PATCH v3 2/2] content: Support enabling virtqueue after DRIVER_OK stage

    Posted 10-18-2023 11:04
    On Wed, Oct 18 2023, "Michael S. Tsirkin" <mst@redhat.com> wrote:

    > On Wed, Oct 18, 2023 at 12:25:23PM +0200, Cornelia Huck wrote:
    >> On Tue, Oct 17 2023, Parav Pandit <parav@nvidia.com> wrote:
    >>
    >> >> From: Cornelia Huck <cohuck@redhat.com>
    >> >> Sent: Tuesday, October 17, 2023 5:55 PM
    >> >>
    >> >> On Mon, Oct 02 2023, Parav Pandit <parav@nvidia.com> wrote:
    >> >> > +When VIRTIO_F_RING_DYNAMIC is not negotiated, the driver MUST enable
    >> >> > +the required number of virtqueues before setting the DRIVER_OK status bit.
    >> >>
    >> >> What does "required" mean here? It just chooses to enable the queues it wants
    >> >> to use, right?
    >> > Right.
    >> > Required meaning, whatever number of queues that driver choose to enable, those must be enabled before driver_ok.
    >> > So it is "required by the driver".
    >> > Would that be ok?
    >>
    >> I'd write it as "the driver MUST enable any virtqueue it plans to use"
    >> or something like that.
    >>
    >> (...)
    >
    > It would have to be SHOULD - we can't add new MUST requirements not
    > contingent on a feature bit, we can give recommendation based on
    > existing installed base.

    Then I wonder whether we need to add any normative statement at all --
    prior to the introduction of this new feature, the driver had to enable
    anything it wanted to use before DRIVER_OK, and if it does not negotiate
    the new feature, nothing changes. Spelling that out in non-normative
    sections should be enough?




  • 12.  Re: [virtio-comment] RE: [PATCH v3 2/2] content: Support enabling virtqueue after DRIVER_OK stage

    Posted 10-18-2023 11:12
    On Wed, Oct 18, 2023 at 01:03:57PM +0200, Cornelia Huck wrote:
    > On Wed, Oct 18 2023, "Michael S. Tsirkin" <mst@redhat.com> wrote:
    >
    > > On Wed, Oct 18, 2023 at 12:25:23PM +0200, Cornelia Huck wrote:
    > >> On Tue, Oct 17 2023, Parav Pandit <parav@nvidia.com> wrote:
    > >>
    > >> >> From: Cornelia Huck <cohuck@redhat.com>
    > >> >> Sent: Tuesday, October 17, 2023 5:55 PM
    > >> >>
    > >> >> On Mon, Oct 02 2023, Parav Pandit <parav@nvidia.com> wrote:
    > >> >> > +When VIRTIO_F_RING_DYNAMIC is not negotiated, the driver MUST enable
    > >> >> > +the required number of virtqueues before setting the DRIVER_OK status bit.
    > >> >>
    > >> >> What does "required" mean here? It just chooses to enable the queues it wants
    > >> >> to use, right?
    > >> > Right.
    > >> > Required meaning, whatever number of queues that driver choose to enable, those must be enabled before driver_ok.
    > >> > So it is "required by the driver".
    > >> > Would that be ok?
    > >>
    > >> I'd write it as "the driver MUST enable any virtqueue it plans to use"
    > >> or something like that.
    > >>
    > >> (...)
    > >
    > > It would have to be SHOULD - we can't add new MUST requirements not
    > > contingent on a feature bit, we can give recommendation based on
    > > existing installed base.
    >
    > Then I wonder whether we need to add any normative statement at all --
    > prior to the introduction of this new feature, the driver had to enable
    > anything it wanted to use before DRIVER_OK, and if it does not negotiate
    > the new feature, nothing changes. Spelling that out in non-normative
    > sections should be enough?

    I think it's not a bad thing to be clearer, but I don't care much.

    --
    MST




  • 13.  RE: [virtio-comment] RE: [PATCH v3 2/2] content: Support enabling virtqueue after DRIVER_OK stage

    Posted 10-18-2023 11:13


    > From: Cornelia Huck <cohuck@redhat.com>
    > Sent: Wednesday, October 18, 2023 4:34 PM

    > On Wed, Oct 18 2023, "Michael S. Tsirkin" <mst@redhat.com> wrote:
    >
    > > On Wed, Oct 18, 2023 at 12:25:23PM +0200, Cornelia Huck wrote:
    > >> On Tue, Oct 17 2023, Parav Pandit <parav@nvidia.com> wrote:
    > >>
    > >> >> From: Cornelia Huck <cohuck@redhat.com>
    > >> >> Sent: Tuesday, October 17, 2023 5:55 PM
    > >> >>
    > >> >> On Mon, Oct 02 2023, Parav Pandit <parav@nvidia.com> wrote:
    > >> >> > +When VIRTIO_F_RING_DYNAMIC is not negotiated, the driver MUST
    > >> >> > +enable the required number of virtqueues before setting the
    > DRIVER_OK status bit.
    > >> >>
    > >> >> What does "required" mean here? It just chooses to enable the
    > >> >> queues it wants to use, right?
    > >> > Right.
    > >> > Required meaning, whatever number of queues that driver choose to
    > enable, those must be enabled before driver_ok.
    > >> > So it is "required by the driver".
    > >> > Would that be ok?
    > >>
    > >> I'd write it as "the driver MUST enable any virtqueue it plans to use"
    > >> or something like that.
    > >>
    > >> (...)
    > >
    > > It would have to be SHOULD - we can't add new MUST requirements not
    > > contingent on a feature bit, we can give recommendation based on
    > > existing installed base.
    >
    It is not just installed base.
    Spec clearly says that:
    "Perform device-specific setup, including discovery of virtqueues for the device, optional per-bus setup,
    reading and possibly writing the device's virtio configuration space, and population of virtqueues."

    There is no feature bit or any text that says "population of virtqueues" can be done later outside of the device initialization phase.
    Only reference is _F_RESET bit which is only for re-enabling. (not enabling).

    > Then I wonder whether we need to add any normative statement at all -- prior
    > to the introduction of this new feature, the driver had to enable anything it
    > wanted to use before DRIVER_OK, and if it does not negotiate the new feature,
    > nothing changes. Spelling that out in non-normative sections should be
    > enough?
    It is already implied in the spec that queues must be enabled before DRIVER_OK.
    So what is written in normative is not changing any behavior.
    It is only making the implied behavior explicit.

    If it says SHOULD, that means, one can enable the queue for the first time after DRIVER_OK stage too.
    And that would violate the "Driver Requirements: Device Initialization".




  • 14.  RE: [PATCH v3 0/2] Support enabling virtqueue after DRIVER_OK

    Posted 10-02-2023 05:20
    Hi Michael, Cornelia,


    > From: Parav Pandit <parav@nvidia.com>
    > Sent: Monday, October 2, 2023 10:46 AM
    >
    > Summary:
    > ========
    > This patch enables driver to create virtqueues after DRIVER_OK status bit is set.
    >
    > This patch take the inspiration from the thread [2] with credits to Eugenio PÃrez.
    >
    > Details:
    > ========
    > Currently, a virtqueue must be enabled before driver has set the DRIVER_OK
    > status bit.
    >
    > spec citation to section "Driver Requirements: Device Initialization"
    >
    > "Perform device-specific setup, including discovery of virtqueues for the device,
    > optional per-bus setup, reading and possibly writing the device’s virtio
    > configuration space, and population of virtqueues."
    >
    > This implies that a virtqueue must be enabled before reaching the DRIVER_OK
    > stage. There was no explicit mention about ability to enable the virtqueue after
    > DRIVER_OK stage.
    >
    > In following usecases, creating a virtqueue after DRIVER_OK phase is desired.
    >
    > Use cases:
    > =========
    > 1. Dynamically create aq when administrative commands to be used.
    > ate the net device tx/rxq when device is
    > opened when deploying for a container.
    > In a container, number of virtqueues to be used may be <= max queues.
    > 3. Dynamically create flow filter queues of netdevice when
    > ARFS or ethtool filters are enabled as listed in [1].
    > 4. Dynamically create rtc functionality related read virtqueue only
    > when net device when timestamping to be used.
    > 5. When XDP program is set, one can create additional XDP specific
    > queues without affecting existing queues.
    >
    > Hence, This patch introduces an existing queue enable and disable (aka reset)
    > facility and a new feature bit to explicitly indicate such support by the device.
    >
    > With this feature, drivers can skip optional queues creation during driver init
    > time. For example, a Linux net device driver can create/destroy the transmit and
    > receive queues when net device's
    > ndo_open() and ndo_stop() callbacks are invoked respectively.
    >
    > [1] https://lists.oasis-open.org/archives/virtio-
    > comment/202308/msg00263.html
    > [2] https://lists.oasis-open.org/archives/virtio-
    > comment/202306/msg00097.html
    >
    > Patch summary:
    > ==============
    > patch-1 fixes to add virtqueue reset conformance references
    > patch-2 adds VIRTIO_F_RING_DYNAMIC feature bit, requirements
    >
    > Please review.
    >
    > Fixes: https://github.com/oasis-tcs/virtio-spec/issues/177
    >
    > ---
    > changelog:
    > v2->v3:
    > - github issue link updated
    > v1->v2:
    > - fixed comments from Michael
    > - reduced device and driver normatives (simplified)
    > - replace 'a virtqueue' to 'the virtqueues'
    > - reworded to remove 'interested'
    > - avoided repeated 'device initialization text', replaced with
    > DRIVER_OK status bit language
    > - avoided confusing text around 'MAY' in the requirements
    > - replaced 'the queue' to 'specific virtqueues'
    > - replaced queue to virtqueue
    > - simplified commit log to talk about msix
    > v0->v1:
    > - fixed comments from Xuan
    > - removed blank lines
    > - fixed wrong requirement link to device in driver section
    >

    I have updated v3 to link to the github issue.
    Now that this small feature was up for few weeks, can you please create the ballot review?