virtio-net: support device stats
PATCH v15 1/1 virtio-net: support device stats
This patch allows the driver to obtain some statistics from the device.
In the device implementation, we can count a lot of such information, which can be used for debugging and judging the running status of the device. We hope to directly display it to the user through ethtool.
To get stats atomically, try to get stats for all/multiple queue pairs in one command.
---
v15:
* query supported types via cvq @Parav
* fix some problem @David
v14:
* introduce supported_stats to config space
* add header(vq_index, size, type) to each reply stats
* add ref to the tx GSO
device-types/net/description.tex | 430 +++++++++++++++++++++++- device-types/net/device-conformance.tex | 1 + device-types/net/driver-conformance.tex | 1 + 3 files changed, 429 insertions(+), 3 deletions(-)
device-types/net/description.tex +427 -3
@@ -88,6 +88,9 @@ \subsection{Feature bits}\label{sec:Device Types / Network Device / Feature bits \item[VIRTIO_NET_F_CTRL_MAC_ADDR(23)] Set MAC address through control channel. +\item[VIRTIO_NET_F_DEVICE_STATS(50)] Device can provide device-level statistics + to the driver through the control channel. + \item[VIRTIO_NET_F_HASH_TUNNEL(51)] Device supports inner header hash for encapsulated packets. \item[VIRTIO_NET_F_VQ_NOTF_COAL(52)] Device supports virtqueue notification coalescing.
@@ -1156,6 +1159,7 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi u8 command; u8 command-specific-data[]; u8 ack; + u8 command-specific-data-reply[]; }; /* ack values */
@@ -1164,9 +1168,11 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi \end{lstlisting} The \field{class}, \field{command} and command-specific-data are set by the -driver, and the device sets the \field{ack} byte. There is little it can -do except issue a diagnostic if \field{ack} is not -VIRTIO_NET_OK. +driver, and the device sets the \field{ack} byte and optionally +\field{command-specific-data-reply}. There is little the driver can +do except issue a diagnostic if \field{ack} is not VIRTIO_NET_OK. + +The command VIRTIO_NET_CTRL_STATS_GET contains \field{command-specific-data-reply}. \paragraph{Packet Receive Filtering}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Packet Receive Filtering} \label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Setting Promiscuous Mode}%old label for latexdiff
@@ -1805,6 +1811,424 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi Upon reset, a device MUST initialize all coalescing parameters to 0. +\paragraph{Device Statistic}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Device Statistic} + +If the VIRTIO_NET_F_DEVICE_STATS feature is negotiated, the driver can obtain +device stats from the device by using the following command. + +Different types of virtqueues have different stats. The stats of the receiveq +are different from those of the transmitq. + +The stats of a certain type of virtqueue are also divided into multiple types +because different types require different features. This enables the expansion +of new stats. + +At one time, the driver can obtain the stats of one or multiple virtqueues. +Additionally, the driver can obtain multiple type stats of each virtqueue. + +\begin{lstlisting} +#define VIRTIO_NET_CTRL_STATS 7 +#define VIRTIO_NET_CTRL_STATS_QUERY 0 +#define VIRTIO_NET_CTRL_STATS_GET 1 +\end{lstlisting} + +To obtain device stats, use the VIRTIO_NET_CTRL_STATS_GET command with the +\field{command-specific-data} containing the virtio_net_ctrl_queue_stats +structure. The result is returned in the \field{command-specific-data-reply}. + +The following structure is used in \field{command-specific-data}: +\begin{lstlisting} +struct virtio_net_ctrl_queue_stats { + struct { + le16 vq_index; + le16 padding[3]; + le64 types[1]; + } stats[]; +}; +\end{lstlisting} + +The following structures are used in \field{command-specific-data-reply}: +\begin{lstlisting} +struct virtio_net_stats_capabilites { + +#define VIRTIO_NET_STATS_TYPE_CVQ (1 << 0) +#define VIRTIO_NET_STATS_TYPE_RX_BASIC (1 << 1) +#define VIRTIO_NET_STATS_TYPE_RX_CSUM (1 << 2) +#define VIRTIO_NET_STATS_TYPE_RX_GSO (1 << 3) +#define VIRTIO_NET_STATS_TYPE_TX_BASIC (1 << 4) +#define VIRTIO_NET_STATS_TYPE_TX_CSUM (1 << 5) +#define VIRTIO_NET_STATS_TYPE_TX_GSO (1 << 6) + le64 supported_stats_types[1]; +} + +struct virtio_net_stats_reply_hdr { + le16 size; + le16 vq_index; + +#define VIRTIO_NET_STATS_TYPE_REPLY_CVQ 0 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC 1 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM 2 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO 3 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC 4 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM 5 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO 6 + u8 type; + u8 padding[3]; +} + +struct virtio_net_stats_cvq { + struct virtio_net_stats_reply_hdr hdr; + + le64 command_num; + le64 ok_num; +}; + +struct virtio_net_stats_rx_basic { + struct virtio_net_stats_reply_hdr hdr; + + le64 rx_packets; + le64 rx_bytes; + + le64 rx_notification; + le64 rx_interrupt; + + le64 rx_drop; + le64 rx_drop_overruns; + le64 rx_drop_busy; +}; + +struct virtio_net_stats_rx_csum { + struct virtio_net_stats_reply_hdr hdr; + + le64 rx_csum_valid; + le64 rx_needs_csum; + le64 rx_csum_bad; + le64 rx_csum_none; +}; + +struct virtio_net_stats_rx_gso { + struct virtio_net_stats_reply_hdr hdr; + + le64 rx_gso_packets; + le64 rx_gso_bytes; + le64 rx_gso_packets_coalesced; + le64 rx_gso_bytes_coalesced; + le64 rx_gso_segments; + le64 rx_gso_segments_bytes; +}; + +struct virtio_net_stats_tx_basic { + struct virtio_net_stats_reply_hdr hdr; + + le64 tx_packets; + le64 tx_bytes; + + le64 tx_notification; + le64 tx_interrupt; + + le64 tx_drop; + le64 tx_drop_malformed; + + le64 tx_drop_busy; +}; + +struct virtio_net_stats_tx_csum { + struct virtio_net_stats_reply_hdr hdr; + + le64 tx_csum_none; + le64 tx_needs_csum; +}; + +struct virtio_net_stats_tx_gso { + struct virtio_net_stats_reply_hdr hdr; + + le64 tx_gso_packets; + le64 tx_gso_bytes; + le64 tx_gso_packets_split; + le64 tx_gso_bytes_split; + le64 tx_gso_segments; + le64 tx_gso_segments_bytes; +}; + +\end{lstlisting} + +The fields of the \field{struct virtio_net_ctrl_queue_stats}: +\begin{description} + \item [vq_index] + The index of the virtqueue to obtain the stats. + + \item [types] + This is a bitmask of the types of stats to be obtained. Therefore, a + \field{struct stats} inside virtio_net_ctrl_queue_stats may indicate + multiple stats replies for the virtqueue. +\end{description} + +The fields of the \field{struct virtio_net_stats_reply_hdr}: +\begin{description} + \item [vq_index] + The virtqueue index of the reply stats. + + \item [size] + The size of bytes of the reply stats. + + \item [type] + The type of the reply stats. + +\end{description} + +\subparagraph{Controlq Statistic}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Device Statistic / Controlq Statistic} + +The structure corresponding to the controlq stats is virtio_net_stats_cvq. +The corresponding type is VIRTIO_NET_STATS_TYPE_CVQ. This is just for the +controlq. + +\begin{description} + \item [command_num] + The number of commands including the current command. + + \item [ok_num] + The number of commands (including the current command) where the ack was VIRTIO_NET_OK. +\end{description} + + +\subparagraph{Receiveq Basic Statistic}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Device Statistic / Receiveq Basic Statistic} + +The structure corresponding to the receiveq basic stats is virtio_net_stats_rx_basic. +The corresponding type is VIRTIO_NET_STATS_TYPE_RX_BASIC. This is just for the +receiveq. + +Receiveq basic stats does not require any feature. As long as the device supports +VIRTIO_NET_F_DEVICE_STATS, the following are the receiveq basic stats. + +The packets described below were all presented on the specified virtqueue. +\begin{description} + \item [rx_packets] + This is the number of packets received by the device (not the packets + passed to the guest). The count includes the packets dropped by the + device. + + \item [rx_bytes] + This is the bytes of packets received by the device (not the packets + passed to the guest). The count includes the packets dropped by the + device. + + \item [rx_notification] + The number of driver notifications received by device for this receiveq. + + \item [rx_interrupt] + The number of device interrupts for this receiveq. + + \item [rx_drop] + This is the number of packets dropped by the device. The count includes + all types of packets dropped by the device. + + \item [rx_drop_overruns] + This is the number of packets dropped by the device when no more + descriptors were available. + + \item [rx_drop_busy] + This is the number of packets dropped by the device when the device is + busy. + +\end{description} + +\subparagraph{Transmitq Basic Statistic}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Device Statistic / Transmitq Basic Statistic} + +The structure corresponding to the transmitq basic stats is virtio_net_stats_tx_basic. +The corresponding type is VIRTIO_NET_STATS_TYPE_TX_BASIC. This is just for the +transmitq. + +Transmitq basic stats does not require any feature. As long as the device supports +VIRTIO_NET_F_DEVICE_STATS, the following are the transmitq basic stats. + +The packets described below are all from a specific virtqueue. +\begin{description} + \item [tx_packets] + This is the number of packets sent by the device (not the packets + got from the driver). + + \item [tx_bytes] + This is the bytes of packets sent by the device (not the packets + got from the driver). + + \item [tx_notification] + The number of driver notifications for this transmitq. + + \item [tx_interrupt] + The number of device interrupts for this transmitq. + + \item [tx_drop] + The number of packets dropped by the device. The count includes all + types of packets dropped by the device. + + \item [tx_drop_malformed] + The number of packets dropped by the device, when the descriptor is in + an error state. For example, the buffer is too short. + + \item [tx_drop_busy] + The number of packets dropped by the device, when the device is busy. + +\end{description} + +\subparagraph{Receiveq CSUM Statistic}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Device Statistic / Receiveq CSUM Statistic} + +The structure corresponding to the receiveq csum stats is virtio_net_stats_rx_csum. +The corresponding type is VIRTIO_NET_STATS_TYPE_RX_CSUM. This is just for the +receiveq. + +Only after the VIRTIO_NET_F_GUEST_CSUM is negotiated, the receiveq csum stats +can be obtained. + +The packets described below are all steered to a specific virtqueue. +\begin{description} + \item [rx_csum_valid] + The number of packets with VIRTIO_NET_HDR_F_DATA_VALID. + + \item [rx_needs_csum] + The number of packets with VIRTIO_NET_HDR_F_NEEDS_CSUM. + + \item [rx_csum_bad] + The number of packets with abnormal csum. + + \item [rx_csum_none] + The number of packets without hardware csum. The packet here refers to + the non-TCP/UDP packet that the backend cannot recognize. + +\end{description} + +\subparagraph{Transmitq CSUM Statistic}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Device Statistic / Transmitq CSUM Statistic} + +The structure corresponding to the transmitq csum stats is virtio_net_stats_tx_csum. +The corresponding type is VIRTIO_NET_STATS_TYPE_TX_CSUM. This is just for the +transmitq. + +Only after the VIRTIO_NET_F_CSUM is negotiated, the transmitq csum stats can be +obtained. + +The following are the transmitq csum stats: + +The packets described below are all from a specific virtqueue. +\begin{description} + \item [tx_csum_none] + The number of packets that didn't require hardware csum. + + \item [tx_needs_csum] + The number of packets that required hardware csum. + +\end{description} + +\subparagraph{Receiveq GSO Statistic}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Device Statistic / Receiveq GSO Statistic} + +The structure corresponding to the receivq GSO stats is virtio_net_stats_rx_gso. +The corresponding type is VIRTIO_NET_STATS_TYPE_RX_GSO. This is just for the +receiveq. + +If one or more of the VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6, or +VIRTIO_NET_F_GUEST_UFO have been negotiated, the receiveq GSO stats can be +obtained. + +GSO packets refer to packets passed by the device to the driver where +\field{gso_type} is not VIRTIO_NET_HDR_GSO_NONE. + +The packets described below are all steered to a specific virtqueue. +\begin{description} + \item [rx_gso_packets] + The number of the GSO packets received by device. + + \item [rx_gso_bytes] + The bytes of the GSO packets received by device. + + \item [rx_gso_packets_coalesced] + The number of the GSO packets coalesced by device. + + \item [rx_gso_bytes_coalesced] + The bytes of the GSO packets coalesced by device. + + \item [rx_gso_segments] + The number of the segments that make up GSO packets. + + \item [rx_gso_segments_bytes] + The bytes of the segments that make up GSO packets. + +\end{description} + +\subparagraph{Transmitq GSO Statistic}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Device Statistic / Transmitq GSO Statistic} + +The structure corresponding to the transmitq GSO stats is virtio_net_stats_tx_gso. +The corresponding type is VIRTIO_NET_STATS_TYPE_TX_GSO. This is just for the +transmitq. + +If one or more of the VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_TSO6, +VIRTIO_NET_F_HOST_USO or VIRTIO_NET_F_HOST_UFO options have +been negotiated, the transmitq GSO stats can be obtained. + +GSO packets refer to packets passed by the driver to the device where +\field{gso_type} is not VIRTIO_NET_HDR_GSO_NONE. +See more \ref{sec:Device Types / Network Device / Device Operation / Packet +Transmission}. + +The packets described below are all from a specific virtqueue. +\begin{description} + \item [tx_gso_packets] + The number of the GSO packets sent by device that are not cut to small + packets. + + \item [tx_gso_bytes] + The bytes of the GSO packets sent by device that are not cut to small + packets. + + \item [tx_gso_packets_split] + The number of the GSO packets that been cut into small packets. + + \item [tx_gso_bytes_split] + The bytes of the GSO packets that been cut into small packets. + + \item [tx_gso_segments] + The number of segments separated from the GSO packets. + + \item [tx_gso_segments_bytes] + The bytes of segments separated from the GSO packets. +\end{description} + +\devicenormative{\subparagraph}{Device Statistic}{Device Types / Network Device / Device Operation / Control Virtqueue / Device Statistic} +The device MUST replies to the command VIRTIO_NET_CTRL_STATS_QUERY with the +struct virtio_net_stats_capabilites. \field{supported_stats_types} includes all +the stats types supported by the device. + +If virtio_net_ctrl_queue_stats is incorrect (such as the following), the device +MUST set \field{ack} to VIRTIO_NET_ERR. Even if there is only one error, +the device MUST fail the entire command. +\begin{itemize} + \item \field{vq_index} exceeds the queue range. + \item \field{types} contains unknown types. + \item One or more of the bits present in \field{types} is not valid for the + specified virtqueue. + \item The feature corresponding to the specified \field{types} was not negotiated. + \item The size of the buffer allocated by the driver for \field{command-specific-data-reply} + is less than the total size of the stats specialed by + \field{virtio_net_ctrl_queue_stats}. +\end{itemize} + +The device MUST write the requested stats structures in +\field{command-specific-data-reply} in the order specified by the structure +virtio_net_ctrl_queue_stats. If the \field{types} indicates multiple stats, the +replies order by the type value from small to large. + +The device MUST set the actual size of the space occupied by the reply to the +\field{size} of the \field{hdr}. And the device MUST set the \field{type} and +the \field{vq_index} of the stats header. + +\drivernormative{\subparagraph}{Device Statistic}{Device Types / Network Device / Device Operation / Control Virtqueue / Device Statistic} + +The types contained in the \field{types} MUST be queried from the device via +command VIRTIO_NET_CTRL_STATS_QUERY. + +\field{types} in struct virtio_net_ctrl_queue_stats MUST be valid to the vq +specified by \field{vq_index}. + +The \field{command-specific-data-reply} buffer allocated by the driver MUST be +able to hold all the stats specified by virtio_net_ctrl_queue_stats. + \subsubsection{Legacy Interface: Framing Requirements}\label{sec:Device Types / Network Device / Legacy Interface: Framing Requirements}
device-types/net/device-conformance.tex +1 -0
@@ -15,4 +15,5 @@ \item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS processing} \item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing} \item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Inner Header Hash} +\item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Device Statistic} \end{itemize}
device-types/net/driver-conformance.tex +1 -0
@@ -15,4 +15,5 @@ \item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) } \item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing} \item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Inner Header Hash} +\item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Device Statistic} \end{itemize}
--
2.32.0.3.g01195cf9f
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: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
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/
Quoted 40 lines
From: Xuan Zhuo <[email protected]>
Sent: Monday, August 21, 2023 12:13 PMThis patch allows the driver to obtain some statistics from the device.
In the device implementation, we can count a lot of such information, which can be used for debugging and judging the running status of the device. We hope to directly display it to the user through ethtool.
To get stats atomically, try to get stats for all/multiple queue pairs in one command.
Signed-off-by Xuan Zhuo <[email protected]>Suggested-by Michael S. Tsirkin <[email protected]>---
v15:
* query supported types via cvq @Parav
* fix some problem @Davidv14:
* introducesupported_statsto config space
* addheader(vq_index, size, type)to each reply stats
* add ref to the tx GSOdevice-types/net/description.tex | 430 +++++++++++++++++++++++- device-types/net/device-conformance.tex | 1 + device-types/net/driver-conformance.tex | 1 + 3 files changed, 429 insertions(+), 3 deletions(-)device-types/net/description.tex +0
-0@@ -88,6 +88,9 @@ \subsection{Feature bits}\label{sec:Device Types /Network Device / Feature bits \item[VIRTIO_NET_F_CTRL_MAC_ADDR(23)] Set MAC address through control
channel.
Quoted 3 lines
+\item[VIRTIO_NET_F_DEVICE_STATS(50)] Device can provide device-level statistics
+ to the driver through the control channel.
Its over cvq, so lets do,
s/channel/virtqueue
so that user needs to learn one less term.
Quoted 8 lines
+
\item[VIRTIO_NET_F_HASH_TUNNEL(51)] Device supports inner header hash
for encapsulated packets.\item[VIRTIO_NET_F_VQ_NOTF_COAL(52)] Device supports virtqueue
notification coalescing.device-types/net/description.tex +0
-0@@ -1156,6 +1159,7 @@ \subsubsection{Control Virtqueue}\label{sec:DeviceTypes / Network Device / Devi
Quoted 4 lines
u8 command; u8 command-specific-data[]; u8 ack;+ u8 command-specific-data-reply[];
Please rename s/command-specific-data-reply/command_specific_result
This will align to what is done in aq and also shorter name. :)
Quoted 13 lines
};
/* ack values */
device-types/net/description.tex +0
-0@@ -1164,9 +1168,11 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi \end{lstlisting} The \field{class}, \field{command} and command-specific-data are set by the -driver, and the device sets the \field{ack} byte. There is little it can -do except issue a diagnostic if \field{ack} is not -VIRTIO_NET_OK.
+driver, and the device sets the \field{ack} byte and optionally +\field{command-specific-data-reply}.There is little the driver can do
device-types/net/description.tex
Quoted 2 lines
device-types/net/description.tex +2
-0+except issue a diagnostic if \field{ack} is not VIRTIO_NET_OK. +
May be driver can retry the command, put to error state, issue diagnostics, ignore the error. So There is no need to mention what driver can/cannot do, so please just drop the last line.
Quoted 13 lines
+The command
VIRTIO_NET_CTRL_STATS_GETcontains \field{command- specific-data-reply}.\paragraph{Packet Receive Filtering}\label{sec:Device Types / Network Device
/ Device Operation / Control Virtqueue / Packet Receive Filtering} \label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Setting Promiscuous Mode}%old label for latexdiff @@ -1805,6 +1811,424 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / DeviUpon reset, a device MUST initialize all coalescing parameters to 0.
+\paragraph{Device Statistic}\label{sec:Device Types / Network Device /
device-types/net/description.tex
Quoted 5 lines
device-types/net/description.tex +5
-0+Device Operation / Control Virtqueue / Device Statistic} + +If the VIRTIO_NET_F_DEVICE_STATS feature is negotiated, the driver can +obtain device stats from the device by using the following command. +
s/device stats/device statistics at above and throughout many places below. in the spec wording, better to not shorten them.
device-types/net/description.tex
Quoted 8 lines
device-types/net/description.tex +8
-0+Different types of virtqueues have different stats. The stats of the +receiveq are different from those of the transmitq. + +The stats of a certain type of virtqueue are also divided into multiple +types because different types require different features. This enables +the expansion of new stats. + +At one time, the driver can obtain the stats of one or multiple virtqueues.
May be
s/At one time/In one command
This is to be more accurate, otherwise in one time we miss the notion of command.
Quoted 11 lines
device-types/net/description.tex +11
-0+Additionally, the driver can obtain multiple type stats of each virtqueue. + +\begin{lstlisting} +#define VIRTIO_NET_CTRL_STATS 7 +#define VIRTIO_NET_CTRL_STATS_QUERY 0 +#define VIRTIO_NET_CTRL_STATS_GET 1 +\end{lstlisting} + +To obtain device stats, use the VIRTIO_NET_CTRL_STATS_GET command with +the \field{command-specific-data} containing the +virtio_net_ctrl_queue_stats structure. The result is returned in the
Quoted 2 lines
\field{command-specific-data-reply}.
+
We opted for slightly different wording for describing command specific data and results in aq. So lets align it here.
Please reword above as,
The \field{command-specific-data} is in the format of \field{ struct virtio_net_ctrl_queue_stats}.
When the command completes successfully, \field{command_specific_result} is in the format of \field{struct virtio_net_stats_capabilites}.
Quoted 15 lines
device-types/net/description.tex +15
-0+The following structure is used in \field{command-specific-data}: +\begin{lstlisting} +struct virtio_net_ctrl_queue_stats { + struct { + le16 vq_index; + le16 padding[3]; + le64 types[1]; + } stats[]; +}; +\end{lstlisting} + +The following structures are used in \field{command-specific-data-reply}: +\begin{lstlisting} +struct virtio_net_stats_capabilites { +
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 1863
Quoted 10 lines
device-types/net/description.tex +10
-0+#define VIRTIO_NET_STATS_TYPE_CVQ (1 << 0) +#define VIRTIO_NET_STATS_TYPE_RX_BASIC (1 << 1) +#define VIRTIO_NET_STATS_TYPE_RX_CSUM (1 << 2) +#define VIRTIO_NET_STATS_TYPE_RX_GSO (1 << 3) +#define VIRTIO_NET_STATS_TYPE_TX_BASIC (1 << 4) +#define VIRTIO_NET_STATS_TYPE_TX_CSUM (1 << 5) +#define VIRTIO_NET_STATS_TYPE_TX_GSO (1 << 6) + le64 supported_stats_types[1]; +} +
It would be best to split the command and description into two. One for the capabilities bit map. And second for the actual stats header.
This avoids the mix up between the two.
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 1875
Quoted 12 lines
device-types/net/description.tex +12
-0+struct virtio_net_stats_reply_hdr { + le16 size; + le16 vq_index; + +#define VIRTIO_NET_STATS_TYPE_REPLY_CVQ 0 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC 1 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM 2 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO 3 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC 4 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM 5 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO 6 + u8 type;
If the query command input has it, we likely don't need it in the response.
Quoted 69 lines
device-types/net/description.tex +69
-0+ u8 padding[3]; +} + +struct virtio_net_stats_cvq { + struct virtio_net_stats_reply_hdr hdr; + + le64 command_num; + le64 ok_num; +}; + +struct virtio_net_stats_rx_basic { + struct virtio_net_stats_reply_hdr hdr; + + le64 rx_packets; + le64 rx_bytes; + + le64 rx_notification; + le64 rx_interrupt; + + le64 rx_drop; + le64 rx_drop_overruns; + le64 rx_drop_busy; +}; + +struct virtio_net_stats_rx_csum { + struct virtio_net_stats_reply_hdr hdr; + + le64 rx_csum_valid; + le64 rx_needs_csum; + le64 rx_csum_bad; + le64 rx_csum_none; +}; + +struct virtio_net_stats_rx_gso { + struct virtio_net_stats_reply_hdr hdr; + + le64 rx_gso_packets; + le64 rx_gso_bytes; + le64 rx_gso_packets_coalesced; + le64 rx_gso_bytes_coalesced; + le64 rx_gso_segments; + le64 rx_gso_segments_bytes; +}; + +struct virtio_net_stats_tx_basic { + struct virtio_net_stats_reply_hdr hdr; + + le64 tx_packets; + le64 tx_bytes; + + le64 tx_notification; + le64 tx_interrupt; + + le64 tx_drop; + le64 tx_drop_malformed; + + le64 tx_drop_busy; +}; + +struct virtio_net_stats_tx_csum { + struct virtio_net_stats_reply_hdr hdr; + + le64 tx_csum_none; + le64 tx_needs_csum; +}; + +struct virtio_net_stats_tx_gso { + struct virtio_net_stats_reply_hdr hdr; +
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 1954
Quoted 10 lines
device-types/net/description.tex +10
-0+ le64 tx_gso_packets; + le64 tx_gso_bytes; + le64 tx_gso_packets_split; + le64 tx_gso_bytes_split; + le64 tx_gso_segments; + le64 tx_gso_segments_bytes; +}; + +\end{lstlisting} +
Since there are plenty of structures and more to grow, I am finding it hard to navigate between their names and below description. Thinking that below description to be next to the struct listing.
Quoted 9 lines
device-types/net/description.tex +9
-0+The fields of the \field{struct virtio_net_ctrl_queue_stats}: +\begin{description} + \item [vq_index] + The index of the virtqueue to obtain the stats. + + \item [types] + This is a bitmask of the types of stats to be obtained. Therefore, a + \field{struct stats} inside virtio_net_ctrl_queue_stats may indicate + multiple stats replies for the virtqueue.
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 1973
Quoted 10 lines
device-types/net/description.tex +10
-0+\end{description} + +The fields of the \field{struct virtio_net_stats_reply_hdr}: +\begin{description} + \item [vq_index] + The virtqueue index of the reply stats. + + \item [size] + The size of bytes of the reply stats. +
I guess we only need bytes because rest are present in the request, so caller knows what to expect in response.\
Its unlikely to transfer 64K, but it is worth to have the size as le32.
Quoted 7 lines
device-types/net/description.tex +7
-0+ \item [type] + The type of the reply stats. + +\end{description} + +\subparagraph{Controlq Statistic}\label{sec:Device Types / Network +Device / Device Operation / Control Virtqueue / Device Statistic /
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 1988
Quoted 10 lines
device-types/net/description.tex +10
-0+Controlq Statistic} + +The structure corresponding to the controlq stats is virtio_net_stats_cvq. +The corresponding type is VIRTIO_NET_STATS_TYPE_CVQ. This is just for +the controlq. + +\begin{description} + \item [command_num] + The number of commands including the current command. +
The number of commands received by the device including the current command.
Quoted 3 lines
device-types/net/description.tex +2
-0+ \item [ok_num] + The number of commands (including the current command) where theack was
VIRTIO_NET_OK.
The number of commands completed successfully by the device including the current command. No need for braces as we didn't keep in the command_num.
device-types/net/description.tex
Quoted 12 lines
+\end{description}
device-types/net/description.tex +7
-0+ + +\subparagraph{Receiveq Basic Statistic}\label{sec:Device Types / +Network Device / Device Operation / Control Virtqueue / Device +Statistic / Receiveq Basic Statistic} + +The structure corresponding to the receiveq basic stats is
virtio_net_stats_rx_basic.device-types/net/description.tex +3
-0+The corresponding type is VIRTIO_NET_STATS_TYPE_RX_BASIC. This is just +for the receiveq. +
Please drop "just" from above.
Quoted 7 lines
device-types/net/description.tex +2
-0+Receiveq basic stats does not require any feature. As long as the +device supports VIRTIO_NET_F_DEVICE_STATS, the following are the receiveqbasic stats.
device-types/net/description.tex +4
-0+ +The packets described below were all presented on the specified virtqueue. +\begin{description} + \item [rx_packets]
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2015
Quoted 10 lines
device-types/net/description.tex +10
-0+ This is the number of packets received by the device (not the packets + passed to the guest). The count includes the packets dropped by the + device. + + \item [rx_bytes] + This is the bytes of packets received by the device (not the packets + passed to the guest). The count includes the packets dropped by the + device. + + \item [rx_notification]
s/rx_notification/rx_notifications
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2020
Quoted 5 lines
device-types/net/description.tex +5
-0+ The number of driver notifications received by device for this receiveq. + + \item [rx_interrupt] + The number of device interrupts for this receiveq. +
s/rx_interrupt/rx_interrupts
The number of interrupts generated by the device for this receiveq.
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2024
Quoted 4 lines
device-types/net/description.tex +4
-0+ \item [rx_drop] + This is the number of packets dropped by the device. The count includes + all types of packets dropped by the device. +
rx_drops
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2032
Quoted 8 lines
device-types/net/description.tex +8
-0+ \item [rx_drop_overruns] + This is the number of packets dropped by the device when no more + descriptors were available. + + \item [rx_drop_busy] + This is the number of packets dropped by the device when the device is + busy. +
I feel this is bit abstract counter and qualify the device as busy is tricky. Lets move it out of the basic counter. Often pure receive side stats and host side stats are handled by different hw/sw engines.
So better to collocate them.
In other words,
Please move rx_notifications at the start the struct so that rest of the receive side stats adjacent to each other.
device-types/net/description.tex
Quoted 11 lines
+\end{description}
device-types/net/description.tex +6
-0+ +\subparagraph{Transmitq Basic Statistic}\label{sec:Device Types / +Network Device / Device Operation / Control Virtqueue / Device +Statistic / Transmitq Basic Statistic} + +The structure corresponding to the transmitq basic stats is
virtio_net_stats_tx_basic.device-types/net/description.tex +3
-0+The corresponding type is VIRTIO_NET_STATS_TYPE_TX_BASIC. This is just +for the transmitq. +
Please drop "just".
Similar comments as tx.
Quoted 18 lines
device-types/net/description.tex +2
-0+Transmitq basic stats does not require any feature. As long as the +device supports VIRTIO_NET_F_DEVICE_STATS, the following are the transmitqbasic stats.
device-types/net/description.tex +15
-0+ +The packets described below are all from a specific virtqueue. +\begin{description} + \item [tx_packets] + This is the number of packets sent by the device (not the packets + got from the driver). + + \item [tx_bytes] + This is the bytes of packets sent by the device (not the packets + got from the driver). + + \item [tx_notification] + The number of driver notifications for this transmitq. + + \item [tx_interrupt]
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2067
Quoted 10 lines
device-types/net/description.tex +10
-0+ The number of device interrupts for this transmitq. + + \item [tx_drop] + The number of packets dropped by the device. The count includes all + types of packets dropped by the device. + + \item [tx_drop_malformed] + The number of packets dropped by the device, when the descriptor is in + an error state. For example, the buffer is too short. +
There descriptor do not have the state.
So better to like the name, as the descriptors are malformed.
Quoted 18 lines
device-types/net/description.tex +10
-0+ \item [tx_drop_busy] + The number of packets dropped by the device, when the device is busy. + +\end{description} + +\subparagraph{Receiveq CSUM Statistic}\label{sec:Device Types / Network +Device / Device Operation / Control Virtqueue / Device Statistic / +Receiveq CSUM Statistic} + +The structure corresponding to the receiveq csum stats is
virtio_net_stats_rx_csum.device-types/net/description.tex +7
-0+The corresponding type is VIRTIO_NET_STATS_TYPE_RX_CSUM. This is just +for the receiveq. + +Only after the VIRTIO_NET_F_GUEST_CSUM is negotiated, the receiveq csum +stats can be obtained. + +The packets described below are all steered to a specific virtqueue.
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2092
Quoted 10 lines
device-types/net/description.tex +10
-0+\begin{description} + \item [rx_csum_valid] + The number of packets with VIRTIO_NET_HDR_F_DATA_VALID. + + \item [rx_needs_csum] + The number of packets with VIRTIO_NET_HDR_F_NEEDS_CSUM. + + \item [rx_csum_bad] + The number of packets with abnormal csum. +
This error counter to move after _none.
Quoted 12 lines
device-types/net/description.tex +11
-0+ \item [rx_csum_none] + The number of packets without hardware csum. The packet here refers to + the non-TCP/UDP packet that the backend cannot recognize. + +\end{description} + +\subparagraph{Transmitq CSUM Statistic}\label{sec:Device Types / +Network Device / Device Operation / Control Virtqueue / Device +Statistic / Transmitq CSUM Statistic} + +The structure corresponding to the transmitq csum stats is
virtio_net_stats_tx_csum.
device-types/net/description.tex
Quoted 3 lines
device-types/net/description.tex +3
-0+The corresponding type is VIRTIO_NET_STATS_TYPE_TX_CSUM. This is just +for the transmitq. +
Drop "just".
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2114
Quoted 10 lines
device-types/net/description.tex +10
-0+Only after the VIRTIO_NET_F_CSUM is negotiated, the transmitq csum +stats can be obtained. + +The following are the transmitq csum stats: + +The packets described below are all from a specific virtqueue. +\begin{description} + \item [tx_csum_none] + The number of packets that didn't require hardware csum. +
s/that/which
Quoted 26 lines
device-types/net/description.tex +10
-0+ \item [tx_needs_csum] + The number of packets that required hardware csum. + +\end{description} + +\subparagraph{Receiveq GSO Statistic}\label{sec:Device Types / Network +Device / Device Operation / Control Virtqueue / Device Statistic / +Receiveq GSO Statistic} + +The structure corresponding to the receivq GSO stats is
virtio_net_stats_rx_gso.device-types/net/description.tex +4
-0+The corresponding type is VIRTIO_NET_STATS_TYPE_RX_GSO. This is just +for the receiveq. + +If one or more of the VIRTIO_NET_F_GUEST_TSO4,
VIRTIO_NET_F_GUEST_TSO6,device-types/net/description.tex +10
-0+or VIRTIO_NET_F_GUEST_UFO have been negotiated, the receiveq GSO stats +can be obtained. + +GSO packets refer to packets passed by the device to the driver where +\field{gso_type} is not VIRTIO_NET_HDR_GSO_NONE. + +The packets described below are all steered to a specific virtqueue. +\begin{description} + \item [rx_gso_packets] + The number of the GSO packets received by device.
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2146
Quoted 10 lines
device-types/net/description.tex +10
-0+ + \item [rx_gso_bytes] + The bytes of the GSO packets received by device. + + \item [rx_gso_packets_coalesced] + The number of the GSO packets coalesced by device. + + \item [rx_gso_bytes_coalesced] + The bytes of the GSO packets coalesced by device. +
Please mention that the header size of the packet is accounted in GSO.
Quoted 53 lines
device-types/net/description.tex +13
-0+ \item [rx_gso_segments] + The number of the segments that make up GSO packets. + + \item [rx_gso_segments_bytes] + The bytes of the segments that make up GSO packets. + +\end{description} + +\subparagraph{Transmitq GSO Statistic}\label{sec:Device Types / Network +Device / Device Operation / Control Virtqueue / Device Statistic / +Transmitq GSO Statistic} + +The structure corresponding to the transmitq GSO stats is
virtio_net_stats_tx_gso.device-types/net/description.tex +39
-0+The corresponding type is VIRTIO_NET_STATS_TYPE_TX_GSO. This is just +for the transmitq. + +If one or more of the VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_TSO6, +VIRTIO_NET_F_HOST_USO or VIRTIO_NET_F_HOST_UFO options have been +negotiated, the transmitq GSO stats can be obtained. + +GSO packets refer to packets passed by the driver to the device where +\field{gso_type} is not VIRTIO_NET_HDR_GSO_NONE. +See more \ref{sec:Device Types / Network Device / Device Operation / +Packet Transmission}. + +The packets described below are all from a specific virtqueue. +\begin{description} + \item [tx_gso_packets] + The number of the GSO packets sent by device that are not cut to small + packets. + + \item [tx_gso_bytes] + The bytes of the GSO packets sent by device that are not cut to small + packets. + + \item [tx_gso_packets_split] + The number of the GSO packets that been cut into small packets. + + \item [tx_gso_bytes_split] + The bytes of the GSO packets that been cut into small packets. + + \item [tx_gso_segments] + The number of segments separated from the GSO packets. + + \item [tx_gso_segments_bytes] + The bytes of segments separated from the GSO packets. +\end{description} + +\devicenormative{\subparagraph}{Device Statistic}{Device Types / +Network Device / Device Operation / Control Virtqueue / Device +Statistic} The device MUST replies to the command +VIRTIO_NET_CTRL_STATS_QUERY with the struct virtio_net_stats_capabilites.
Quoted 3 lines
\field{supported_stats_types} includes all the stats types supported by the device.
+
I will take the second pass to review below normatives in a day.
We need to add the capabilities and query them from the AQ too.
If the reply header structure and actual stats are split properly, it will be easy to add the query by the owner device.
Quoted 65 lines
device-types/net/description.tex +9
-0+If virtio_net_ctrl_queue_stats is incorrect (such as the following), +the device MUST set \field{ack} to VIRTIO_NET_ERR. Even if there is +only one error, the device MUST fail the entire command. +\begin{itemize} + \item \field{vq_index} exceeds the queue range. + \item \field{types} contains unknown types. + \item One or more of the bits present in \field{types} is not valid for the + specified virtqueue. + \item The feature corresponding to the specified \field{types} was notnegotiated.
+ \item The size of the buffer allocated by the driver for \field{command-
specific-data-reply}device-types/net/description.tex +26
-0+ is less than the total size of the stats specialed by + \field{virtio_net_ctrl_queue_stats}. +\end{itemize} + +The device MUST write the requested stats structures in +\field{command-specific-data-reply} in the order specified by the +structure virtio_net_ctrl_queue_stats. If the \field{types} indicates +multiple stats, the replies order by the type value from small to large. + +The device MUST set the actual size of the space occupied by the reply +to the \field{size} of the \field{hdr}. And the device MUST set the +\field{type} and the \field{vq_index} of the stats header. + +\drivernormative{\subparagraph}{Device Statistic}{Device Types / +Network Device / Device Operation / Control Virtqueue / Device +Statistic} + +The types contained in the \field{types} MUST be queried from the +device via command VIRTIO_NET_CTRL_STATS_QUERY. + +\field{types} in struct virtio_net_ctrl_queue_stats MUST be valid to +the vq specified by \field{vq_index}. + +The \field{command-specific-data-reply} buffer allocated by the driver +MUST be able to hold all the stats specified by virtio_net_ctrl_queue_stats. + \subsubsection{Legacy Interface: Framing Requirements}\label{sec:DeviceTypes / Network Device / Legacy Interface: Framing Requirements}
device- renamed from device-types/net/device-conformance.tex +0
-0types/net/device-conformance.tex
index f88f48b..8ce58fe 100644device-types/net/device-conformance.tex +0
-0@@ -15,4 +15,5 @@ \item \ref{devicenormative:Device Types / Network Device / Device Operation/ Control Virtqueue / Receive-side scaling (RSS) / RSS processing} \item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing} \item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Inner Header Hash}
+\item \ref{devicenormative:Device Types / Network Device / Devicedevice-types/net/device-conformance.tex +1
-0+Operation / Control Virtqueue / Device Statistic} \end{itemize}device-types/net/driver- renamed from device-types/net/driver-conformance.tex +0
-0conformance.tex
index 9d853d9..b6636a2 100644device-types/net/driver-conformance.tex +0
-0@@ -15,4 +15,5 @@ \item \ref{drivernormative:Device Types / Network Device / Device Operation/ Control Virtqueue / Receive-side scaling (RSS) } \item \ref{drivernormative:Device Types / Network Device / Device Operation /
Quoted 8 lines
Control Virtqueue / Notifications Coalescing} \item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Inner Header Hash}
+\item \ref{drivernormative:Device Types / Network Device / Device +Operation / Control Virtqueue / Device Statistic}
\end{itemize}
--
2.32.0.3.g01195cf9f
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: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
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/
Quoted 53 lines · Parav Pandit
Quoted 40 lines
From: Xuan Zhuo <[email protected]>
Sent: Monday, August 21, 2023 12:13 PMThis patch allows the driver to obtain some statistics from the device.
In the device implementation, we can count a lot of such information, which can be used for debugging and judging the running status of the device. We hope to directly display it to the user through ethtool.
To get stats atomically, try to get stats for all/multiple queue pairs in one command.
Signed-off-by Xuan Zhuo <[email protected]>Suggested-by Michael S. Tsirkin <[email protected]>---
v15:
* query supported types via cvq @Parav
* fix some problem @Davidv14:
* introducesupported_statsto config space
* addheader(vq_index, size, type)to each reply stats
* add ref to the tx GSOdevice-types/net/description.tex | 430 +++++++++++++++++++++++- device-types/net/device-conformance.tex | 1 + device-types/net/driver-conformance.tex | 1 + 3 files changed, 429 insertions(+), 3 deletions(-)device-types/net/description.tex +0
-0@@ -88,6 +88,9 @@ \subsection{Feature bits}\label{sec:Device Types /Network Device / Feature bits \item[VIRTIO_NET_F_CTRL_MAC_ADDR(23)] Set MAC address through control
channel.Quoted 3 lines
+\item[VIRTIO_NET_F_DEVICE_STATS(50)] Device can provide device-level statistics
+ to the driver through the control channel.Its over cvq, so lets do,
s/channel/virtqueue
so that user needs to learn one less term.
Quoted 4 lines
+
\item[VIRTIO_NET_F_HASH_TUNNEL(51)] Device supports inner header hash
for encapsulated packets.
Quoted 10 lines
Quoted 8 lines
\item[VIRTIO_NET_F_VQ_NOTF_COAL(52)] Device supports virtqueue
notification coalescing.device-types/net/description.tex +0
-0@@ -1156,6 +1159,7 @@ \subsubsection{Control Virtqueue}\label{sec:DeviceTypes / Network Device / Devi
u8 command; u8 command-specific-data[]; u8 ack;+ u8 command-specific-data-reply[];
Please rename s/command-specific-data-reply/command_specific_result
I agree.
But it will be "command-specific-result" for alignment with 'command-specific-data'.
Quoted 15 lines
This will align to what is done in aq and also shorter name. :)
Quoted 11 lines
};
/* ack values */
device-types/net/description.tex +0
-0@@ -1164,9 +1168,11 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi \end{lstlisting} The \field{class}, \field{command} and command-specific-data are set by the -driver, and the device sets the \field{ack} byte. There is little it can -do except issue a diagnostic if \field{ack} is not -VIRTIO_NET_OK.
+driver, and the device sets the \field{ack} byte and optionally +\field{command-specific-data-reply}.
Quoted 5 lines
device-types/net/description.tex
Quoted 3 lines
There is little the driver can do
device-types/net/description.tex +2
-0+except issue a diagnostic if \field{ack} is not VIRTIO_NET_OK. +May be driver can retry the command, put to error state, issue diagnostics, ignore the error. So There is no need to mention what driver can/cannot do, so please just drop the last line.
This is not new. It turns out that there is this line.
I think, if you want to remove this, you should post a new patch.
Quoted 83 lines
Quoted 14 lines
+The command
VIRTIO_NET_CTRL_STATS_GETcontains \field{command- specific-data-reply}.\paragraph{Packet Receive Filtering}\label{sec:Device Types / Network Device
/ Device Operation / Control Virtqueue / Packet Receive Filtering} \label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Setting Promiscuous Mode}%old label for latexdiff @@ -1805,6 +1811,424 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / DeviUpon reset, a device MUST initialize all coalescing parameters to 0.
+\paragraph{Device Statistic}\label{sec:Device Types / Network Device /
device-types/net/description.tex
Quoted 5 lines
device-types/net/description.tex +5
-0+Device Operation / Control Virtqueue / Device Statistic} + +If the VIRTIO_NET_F_DEVICE_STATS feature is negotiated, the driver can +obtain device stats from the device by using the following command. +s/device stats/device statistics at above and throughout many places below. in the spec wording, better to not shorten them.
device-types/net/description.tex
Quoted 8 lines
device-types/net/description.tex +8
-0+Different types of virtqueues have different stats. The stats of the +receiveq are different from those of the transmitq. + +The stats of a certain type of virtqueue are also divided into multiple +types because different types require different features. This enables +the expansion of new stats. + +At one time, the driver can obtain the stats of one or multiple virtqueues.May be
s/At one time/In one command
This is to be more accurate, otherwise in one time we miss the notion of command.Quoted 11 lines
device-types/net/description.tex +11
-0+Additionally, the driver can obtain multiple type stats of each virtqueue. + +\begin{lstlisting} +#define VIRTIO_NET_CTRL_STATS 7 +#define VIRTIO_NET_CTRL_STATS_QUERY 0 +#define VIRTIO_NET_CTRL_STATS_GET 1 +\end{lstlisting} + +To obtain device stats, use the VIRTIO_NET_CTRL_STATS_GET command with +the \field{command-specific-data} containing the +virtio_net_ctrl_queue_stats structure. The result is returned in theQuoted 2 lines
\field{command-specific-data-reply}.
+We opted for slightly different wording for describing command specific data and results in aq. So lets align it here.
Please reword above as,
The \field{command-specific-data} is in the format of \field{ structvirtio_net_ctrl_queue_stats}.When the command completes successfully, \field{command_specific_result} is in the format of \field{struct
virtio_net_stats_capabilites}.Quoted 15 lines
device-types/net/description.tex +15
-0+The following structure is used in \field{command-specific-data}: +\begin{lstlisting} +struct virtio_net_ctrl_queue_stats { + struct { + le16 vq_index; + le16 padding[3]; + le64 types[1]; + } stats[]; +}; +\end{lstlisting} + +The following structures are used in \field{command-specific-data-reply}: +\begin{lstlisting} +struct virtio_net_stats_capabilites { +device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 1863
Quoted 10 lines
device-types/net/description.tex +10
-0+#define VIRTIO_NET_STATS_TYPE_CVQ (1 << 0) +#define VIRTIO_NET_STATS_TYPE_RX_BASIC (1 << 1) +#define VIRTIO_NET_STATS_TYPE_RX_CSUM (1 << 2) +#define VIRTIO_NET_STATS_TYPE_RX_GSO (1 << 3) +#define VIRTIO_NET_STATS_TYPE_TX_BASIC (1 << 4) +#define VIRTIO_NET_STATS_TYPE_TX_CSUM (1 << 5) +#define VIRTIO_NET_STATS_TYPE_TX_GSO (1 << 6) + le64 supported_stats_types[1]; +} +It would be best to split the command and description into two. One for the capabilities bit map. And second for the actual stats header.
This avoids the mix up between the two.
Quoted 13 lines
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 1875
Quoted 12 lines
device-types/net/description.tex +12
-0+struct virtio_net_stats_reply_hdr { + le16 size; + le16 vq_index; + +#define VIRTIO_NET_STATS_TYPE_REPLY_CVQ 0 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC 1 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM 2 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO 3 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC 4 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM 5 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO 6 + u8 type;If the query command input has it, we likely don't need it in the response.
YES.
But the driver may need to handle multiple reply stats. I think that will be easy for the driver to handle so many stats with the vq_index and type.
Quoted 176 lines
Quoted 69 lines
device-types/net/description.tex +69
-0+ u8 padding[3]; +} + +struct virtio_net_stats_cvq { + struct virtio_net_stats_reply_hdr hdr; + + le64 command_num; + le64 ok_num; +}; + +struct virtio_net_stats_rx_basic { + struct virtio_net_stats_reply_hdr hdr; + + le64 rx_packets; + le64 rx_bytes; + + le64 rx_notification; + le64 rx_interrupt; + + le64 rx_drop; + le64 rx_drop_overruns; + le64 rx_drop_busy; +}; + +struct virtio_net_stats_rx_csum { + struct virtio_net_stats_reply_hdr hdr; + + le64 rx_csum_valid; + le64 rx_needs_csum; + le64 rx_csum_bad; + le64 rx_csum_none; +}; + +struct virtio_net_stats_rx_gso { + struct virtio_net_stats_reply_hdr hdr; + + le64 rx_gso_packets; + le64 rx_gso_bytes; + le64 rx_gso_packets_coalesced; + le64 rx_gso_bytes_coalesced; + le64 rx_gso_segments; + le64 rx_gso_segments_bytes; +}; + +struct virtio_net_stats_tx_basic { + struct virtio_net_stats_reply_hdr hdr; + + le64 tx_packets; + le64 tx_bytes; + + le64 tx_notification; + le64 tx_interrupt; + + le64 tx_drop; + le64 tx_drop_malformed; + + le64 tx_drop_busy; +}; + +struct virtio_net_stats_tx_csum { + struct virtio_net_stats_reply_hdr hdr; + + le64 tx_csum_none; + le64 tx_needs_csum; +}; + +struct virtio_net_stats_tx_gso { + struct virtio_net_stats_reply_hdr hdr; +device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 1954
Quoted 10 lines
device-types/net/description.tex +10
-0+ le64 tx_gso_packets; + le64 tx_gso_bytes; + le64 tx_gso_packets_split; + le64 tx_gso_bytes_split; + le64 tx_gso_segments; + le64 tx_gso_segments_bytes; +}; + +\end{lstlisting} +Since there are plenty of structures and more to grow, I am finding it hard to navigate between their names and below description. Thinking that below description to be next to the struct listing.
Quoted 9 lines
device-types/net/description.tex +9
-0+The fields of the \field{struct virtio_net_ctrl_queue_stats}: +\begin{description} + \item [vq_index] + The index of the virtqueue to obtain the stats. + + \item [types] + This is a bitmask of the types of stats to be obtained. Therefore, a + \field{struct stats} inside virtio_net_ctrl_queue_stats may indicate + multiple stats replies for the virtqueue.device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 1973
Quoted 10 lines
device-types/net/description.tex +10
-0+\end{description} + +The fields of the \field{struct virtio_net_stats_reply_hdr}: +\begin{description} + \item [vq_index] + The virtqueue index of the reply stats. + + \item [size] + The size of bytes of the reply stats. +I guess we only need bytes because rest are present in the request, so caller knows what to expect in response.\
Its unlikely to transfer 64K, but it is worth to have the size as le32.Quoted 7 lines
device-types/net/description.tex +7
-0+ \item [type] + The type of the reply stats. + +\end{description} + +\subparagraph{Controlq Statistic}\label{sec:Device Types / Network +Device / Device Operation / Control Virtqueue / Device Statistic /device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 1988
Quoted 10 lines
device-types/net/description.tex +10
-0+Controlq Statistic} + +The structure corresponding to the controlq stats is virtio_net_stats_cvq. +The corresponding type is VIRTIO_NET_STATS_TYPE_CVQ. This is just for +the controlq. + +\begin{description} + \item [command_num] + The number of commands including the current command. +The number of commands received by the device including the current command.
Quoted 3 lines
device-types/net/description.tex +2
-0+ \item [ok_num] + The number of commands (including the current command) where theack was
VIRTIO_NET_OK.The number of commands completed successfully by the device including the current command. No need for braces as we didn't keep in the
command_num.device-types/net/description.tex
Quoted 12 lines
+\end{description}
device-types/net/description.tex +7
-0+ + +\subparagraph{Receiveq Basic Statistic}\label{sec:Device Types / +Network Device / Device Operation / Control Virtqueue / Device +Statistic / Receiveq Basic Statistic} + +The structure corresponding to the receiveq basic stats is
virtio_net_stats_rx_basic.device-types/net/description.tex +3
-0+The corresponding type is VIRTIO_NET_STATS_TYPE_RX_BASIC. This is just +for the receiveq. +Please drop "just" from above.
Quoted 7 lines
device-types/net/description.tex +2
-0+Receiveq basic stats does not require any feature. As long as the +device supports VIRTIO_NET_F_DEVICE_STATS, the following are the receiveqbasic stats.
device-types/net/description.tex +4
-0+ +The packets described below were all presented on the specified virtqueue. +\begin{description} + \item [rx_packets]device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2015
Quoted 10 lines
device-types/net/description.tex +10
-0+ This is the number of packets received by the device (not the packets + passed to the guest). The count includes the packets dropped by the + device. + + \item [rx_bytes] + This is the bytes of packets received by the device (not the packets + passed to the guest). The count includes the packets dropped by the + device. + + \item [rx_notification]s/rx_notification/rx_notifications
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2020
Quoted 5 lines
device-types/net/description.tex +5
-0+ The number of driver notifications received by device for this receiveq. + + \item [rx_interrupt] + The number of device interrupts for this receiveq. +s/rx_interrupt/rx_interrupts
The number of interrupts generated by the device for this receiveq.device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2024
Quoted 4 lines
device-types/net/description.tex +4
-0+ \item [rx_drop] + This is the number of packets dropped by the device. The count includes + all types of packets dropped by the device. +
rx_drops
Quoted 9 lines
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2032
Quoted 8 lines
device-types/net/description.tex +8
-0+ \item [rx_drop_overruns] + This is the number of packets dropped by the device when no more + descriptors were available. + + \item [rx_drop_busy] + This is the number of packets dropped by the device when the device is + busy. +I feel this is bit abstract counter and qualify the device as busy is tricky. Lets move it out of the basic counter.
I will rethink about this.
Quoted 203 lines
Often pure receive side stats and host side stats are handled by different hw/sw engines.
So better to collocate them.
In other words,
Please moverx_notificationsat the start the struct so that rest of the receive side stats adjacent to each other.device-types/net/description.tex
Quoted 11 lines
+\end{description}
device-types/net/description.tex +6
-0+ +\subparagraph{Transmitq Basic Statistic}\label{sec:Device Types / +Network Device / Device Operation / Control Virtqueue / Device +Statistic / Transmitq Basic Statistic} + +The structure corresponding to the transmitq basic stats is
virtio_net_stats_tx_basic.device-types/net/description.tex +3
-0+The corresponding type is VIRTIO_NET_STATS_TYPE_TX_BASIC. This is just +for the transmitq. +Please drop "just".
Similar comments as tx.Quoted 18 lines
device-types/net/description.tex +2
-0+Transmitq basic stats does not require any feature. As long as the +device supports VIRTIO_NET_F_DEVICE_STATS, the following are the transmitqbasic stats.
device-types/net/description.tex +15
-0+ +The packets described below are all from a specific virtqueue. +\begin{description} + \item [tx_packets] + This is the number of packets sent by the device (not the packets + got from the driver). + + \item [tx_bytes] + This is the bytes of packets sent by the device (not the packets + got from the driver). + + \item [tx_notification] + The number of driver notifications for this transmitq. + + \item [tx_interrupt]device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2067
Quoted 10 lines
device-types/net/description.tex +10
-0+ The number of device interrupts for this transmitq. + + \item [tx_drop] + The number of packets dropped by the device. The count includes all + types of packets dropped by the device. + + \item [tx_drop_malformed] + The number of packets dropped by the device, when the descriptor is in + an error state. For example, the buffer is too short. +There descriptor do not have the state.
So better to like the name, as the descriptors are malformed.Quoted 18 lines
device-types/net/description.tex +10
-0+ \item [tx_drop_busy] + The number of packets dropped by the device, when the device is busy. + +\end{description} + +\subparagraph{Receiveq CSUM Statistic}\label{sec:Device Types / Network +Device / Device Operation / Control Virtqueue / Device Statistic / +Receiveq CSUM Statistic} + +The structure corresponding to the receiveq csum stats is
virtio_net_stats_rx_csum.device-types/net/description.tex +7
-0+The corresponding type is VIRTIO_NET_STATS_TYPE_RX_CSUM. This is just +for the receiveq. + +Only after the VIRTIO_NET_F_GUEST_CSUM is negotiated, the receiveq csum +stats can be obtained. + +The packets described below are all steered to a specific virtqueue.device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2092
Quoted 10 lines
device-types/net/description.tex +10
-0+\begin{description} + \item [rx_csum_valid] + The number of packets with VIRTIO_NET_HDR_F_DATA_VALID. + + \item [rx_needs_csum] + The number of packets with VIRTIO_NET_HDR_F_NEEDS_CSUM. + + \item [rx_csum_bad] + The number of packets with abnormal csum. +This error counter to move after
_none.Quoted 12 lines
device-types/net/description.tex +11
-0+ \item [rx_csum_none] + The number of packets without hardware csum. The packet here refers to + the non-TCP/UDP packet that the backend cannot recognize. + +\end{description} + +\subparagraph{Transmitq CSUM Statistic}\label{sec:Device Types / +Network Device / Device Operation / Control Virtqueue / Device +Statistic / Transmitq CSUM Statistic} + +The structure corresponding to the transmitq csum stats is
virtio_net_stats_tx_csum.device-types/net/description.tex
Quoted 3 lines
device-types/net/description.tex +3
-0+The corresponding type is VIRTIO_NET_STATS_TYPE_TX_CSUM. This is just +for the transmitq. +Drop "just".
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2114
Quoted 10 lines
device-types/net/description.tex +10
-0+Only after the VIRTIO_NET_F_CSUM is negotiated, the transmitq csum +stats can be obtained. + +The following are the transmitq csum stats: + +The packets described below are all from a specific virtqueue. +\begin{description} + \item [tx_csum_none] + The number of packets that didn't require hardware csum. +s/that/which
Quoted 26 lines
device-types/net/description.tex +10
-0+ \item [tx_needs_csum] + The number of packets that required hardware csum. + +\end{description} + +\subparagraph{Receiveq GSO Statistic}\label{sec:Device Types / Network +Device / Device Operation / Control Virtqueue / Device Statistic / +Receiveq GSO Statistic} + +The structure corresponding to the receivq GSO stats is
virtio_net_stats_rx_gso.device-types/net/description.tex +4
-0+The corresponding type is VIRTIO_NET_STATS_TYPE_RX_GSO. This is just +for the receiveq. + +If one or more of the VIRTIO_NET_F_GUEST_TSO4,
VIRTIO_NET_F_GUEST_TSO6,device-types/net/description.tex +10
-0+or VIRTIO_NET_F_GUEST_UFO have been negotiated, the receiveq GSO stats +can be obtained. + +GSO packets refer to packets passed by the device to the driver where +\field{gso_type} is not VIRTIO_NET_HDR_GSO_NONE. + +The packets described below are all steered to a specific virtqueue. +\begin{description} + \item [rx_gso_packets] + The number of the GSO packets received by device.device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2146
Quoted 10 lines
device-types/net/description.tex +10
-0+ + \item [rx_gso_bytes] + The bytes of the GSO packets received by device. + + \item [rx_gso_packets_coalesced] + The number of the GSO packets coalesced by device. + + \item [rx_gso_bytes_coalesced] + The bytes of the GSO packets coalesced by device. +Please mention that the header size of the packet is accounted in GSO.
Quoted 53 lines
device-types/net/description.tex +13
-0+ \item [rx_gso_segments] + The number of the segments that make up GSO packets. + + \item [rx_gso_segments_bytes] + The bytes of the segments that make up GSO packets. + +\end{description} + +\subparagraph{Transmitq GSO Statistic}\label{sec:Device Types / Network +Device / Device Operation / Control Virtqueue / Device Statistic / +Transmitq GSO Statistic} + +The structure corresponding to the transmitq GSO stats is
virtio_net_stats_tx_gso.device-types/net/description.tex +39
-0+The corresponding type is VIRTIO_NET_STATS_TYPE_TX_GSO. This is just +for the transmitq. + +If one or more of the VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_TSO6, +VIRTIO_NET_F_HOST_USO or VIRTIO_NET_F_HOST_UFO options have been +negotiated, the transmitq GSO stats can be obtained. + +GSO packets refer to packets passed by the driver to the device where +\field{gso_type} is not VIRTIO_NET_HDR_GSO_NONE. +See more \ref{sec:Device Types / Network Device / Device Operation / +Packet Transmission}. + +The packets described below are all from a specific virtqueue. +\begin{description} + \item [tx_gso_packets] + The number of the GSO packets sent by device that are not cut to small + packets. + + \item [tx_gso_bytes] + The bytes of the GSO packets sent by device that are not cut to small + packets. + + \item [tx_gso_packets_split] + The number of the GSO packets that been cut into small packets. + + \item [tx_gso_bytes_split] + The bytes of the GSO packets that been cut into small packets. + + \item [tx_gso_segments] + The number of segments separated from the GSO packets. + + \item [tx_gso_segments_bytes] + The bytes of segments separated from the GSO packets. +\end{description} + +\devicenormative{\subparagraph}{Device Statistic}{Device Types / +Network Device / Device Operation / Control Virtqueue / Device +Statistic} The device MUST replies to the command +VIRTIO_NET_CTRL_STATS_QUERY with the struct virtio_net_stats_capabilites.Quoted 3 lines
\field{supported_stats_types} includes all the stats types supported by the device.
+I will take the second pass to review below normatives in a day.
Quoted 2 lines
We need to add the capabilities and query them from the AQ too.
If the reply header structure and actual stats are split properly, it will be easy to add the query by the owner device.
YES. I agree.
But I would to know is there some specific requirements?
I will post the next version today or tomorrow.
Thanks.
Quoted 66 lines
Quoted 66 lines
device-types/net/description.tex +9
-0+If virtio_net_ctrl_queue_stats is incorrect (such as the following), +the device MUST set \field{ack} to VIRTIO_NET_ERR. Even if there is +only one error, the device MUST fail the entire command. +\begin{itemize} + \item \field{vq_index} exceeds the queue range. + \item \field{types} contains unknown types. + \item One or more of the bits present in \field{types} is not valid for the + specified virtqueue. + \item The feature corresponding to the specified \field{types} was notnegotiated.
+ \item The size of the buffer allocated by the driver for \field{command-
specific-data-reply}device-types/net/description.tex +26
-0+ is less than the total size of the stats specialed by + \field{virtio_net_ctrl_queue_stats}. +\end{itemize} + +The device MUST write the requested stats structures in +\field{command-specific-data-reply} in the order specified by the +structure virtio_net_ctrl_queue_stats. If the \field{types} indicates +multiple stats, the replies order by the type value from small to large. + +The device MUST set the actual size of the space occupied by the reply +to the \field{size} of the \field{hdr}. And the device MUST set the +\field{type} and the \field{vq_index} of the stats header. + +\drivernormative{\subparagraph}{Device Statistic}{Device Types / +Network Device / Device Operation / Control Virtqueue / Device +Statistic} + +The types contained in the \field{types} MUST be queried from the +device via command VIRTIO_NET_CTRL_STATS_QUERY. + +\field{types} in struct virtio_net_ctrl_queue_stats MUST be valid to +the vq specified by \field{vq_index}. + +The \field{command-specific-data-reply} buffer allocated by the driver +MUST be able to hold all the stats specified by virtio_net_ctrl_queue_stats. + \subsubsection{Legacy Interface: Framing Requirements}\label{sec:DeviceTypes / Network Device / Legacy Interface: Framing Requirements}
device- renamed from device-types/net/device-conformance.tex +0
-0types/net/device-conformance.tex
index f88f48b..8ce58fe 100644device-types/net/device-conformance.tex +0
-0@@ -15,4 +15,5 @@ \item \ref{devicenormative:Device Types / Network Device / Device Operation/ Control Virtqueue / Receive-side scaling (RSS) / RSS processing} \item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing} \item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Inner Header Hash}
+\item \ref{devicenormative:Device Types / Network Device / Devicedevice-types/net/device-conformance.tex +1
-0+Operation / Control Virtqueue / Device Statistic} \end{itemize}device-types/net/driver- renamed from device-types/net/driver-conformance.tex +0
-0conformance.tex
index 9d853d9..b6636a2 100644device-types/net/driver-conformance.tex +0
-0@@ -15,4 +15,5 @@ \item \ref{drivernormative:Device Types / Network Device / Device Operation/ Control Virtqueue / Receive-side scaling (RSS) } \item \ref{drivernormative:Device Types / Network Device / Device Operation /
Quoted 9 lines
Quoted 8 lines
Control Virtqueue / Notifications Coalescing} \item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Inner Header Hash}
+\item \ref{drivernormative:Device Types / Network Device / Device +Operation / Control Virtqueue / Device Statistic}
\end{itemize}
--
2.32.0.3.g01195cf9f
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: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
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/
Quoted 9 lines
From: Xuan Zhuo <[email protected]>
Sent: Tuesday, August 29, 2023 9:00 AMQuoted 4 lines
Its over cvq, so lets do,
s/channel/virtqueue
Quoted 9 lines
Quoted 2 lines
Please rename s/command-specific-data-reply/command_specific_result
I agree.
But it will be "command-specific-result" for alignment with 'command-specific- data'.
Right.
Quoted 10 lines
Quoted 4 lines
Review
Quoted 3 lines
There is little the driver can do
(quoted diff) +2
-0+except issue a diagnostic if \field{ack} is not VIRTIO_NET_OK. +May be driver can retry the command, put to error state, issue diagnostics,
ignore the error.
Quoted 1 line
So There is no need to mention what driver can/cannot do, so please just
drop the last line.
This is not new. It turns out that there is this line.
:(
I see it now.
Quoted 2 lines
I think, if you want to remove this, you should post a new patch.
It will be separate patch.
Quoted 107 lines
Quoted 25 lines
Quoted 16 lines
+The command
VIRTIO_NET_CTRL_STATS_GETcontains \field{command- specific-data-reply}.\paragraph{Packet Receive Filtering}\label{sec:Device Types /
Network Device / Device Operation / Control Virtqueue / Packet Receive Filtering} \label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Setting Promiscuous Mode}%old label for latexdiff @@ -1805,6
+1811,424 @@ \subsubsection{Control Virtqueue}\label{sec:Device +Types /
Network Device / DeviUpon reset, a device MUST initialize all coalescing parameters to 0.
+\paragraph{Device Statistic}\label{sec:Device Types / Network
Review
Quoted 5 lines
(quoted diff) +5
-0+Device / Device Operation / Control Virtqueue / Device Statistic} + +If the VIRTIO_NET_F_DEVICE_STATS feature is negotiated, the driver +can obtain device stats from the device by using the following command. +s/device stats/device statistics at above and throughout many places below. in the spec wording, better to not shorten them.
Quoted 11 lines
Review
Quoted 8 lines
(quoted diff) +8
-0+Different types of virtqueues have different stats. The stats of +the receiveq are different from those of the transmitq. + +The stats of a certain type of virtqueue are also divided into +multiple types because different types require different features. +This enables the expansion of new stats. + +At one time, the driver can obtain the stats of one or multiple virtqueues.May be
s/At one time/In one command
This is to be more accurate, otherwise in one time we miss the notion ofcommand.
Quoted 16 lines
Quoted 13 lines
device-types/net/description.tex +12
-0+Additionally, the driver can obtain multiple type stats of each virtqueue. + +\begin{lstlisting} +#define VIRTIO_NET_CTRL_STATS 7 +#define VIRTIO_NET_CTRL_STATS_QUERY 0 +#define VIRTIO_NET_CTRL_STATS_GET 1 +\end{lstlisting} + +To obtain device stats, use the VIRTIO_NET_CTRL_STATS_GET command +with the \field{command-specific-data} containing the +virtio_net_ctrl_queue_stats structure. The result is returned in +theQuoted 2 lines
\field{command-specific-data-reply}.
+We opted for slightly different wording for describing command specific data
and results in aq.
Quoted 3 lines
So lets align it here.
Please reword above as,
The \field{command-specific-data} is in the format of \field{ struct
virtio_net_ctrl_queue_stats}.Quoted 2 lines
When the command completes successfully, \field{command_specific_result}
is in the format of \field{struct
virtio_net_stats_capabilites}.Quoted 19 lines
Quoted 19 lines
device-types/net/description.tex +18
-0+The following structure is used in \field{command-specific-data}: +\begin{lstlisting} +struct virtio_net_ctrl_queue_stats { + struct { + le16 vq_index; + le16 padding[3]; + le64 types[1]; + } stats[]; +}; +\end{lstlisting} + +The following structures are used in \field{command-specific-data-reply}: +\begin{lstlisting} +struct virtio_net_stats_capabilites { + +#define VIRTIO_NET_STATS_TYPE_CVQ (1 << 0) +#define VIRTIO_NET_STATS_TYPE_RX_BASIC (1 << 1) +#define VIRTIO_NET_STATS_TYPE_RX_CSUM (1 << 2)Quoted 8 lines
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 1863
Quoted 7 lines
device-types/net/description.tex +7
-0+#define VIRTIO_NET_STATS_TYPE_RX_GSO (1 << 3) +#define VIRTIO_NET_STATS_TYPE_TX_BASIC (1 << 4) +#define VIRTIO_NET_STATS_TYPE_TX_CSUM (1 << 5) +#define VIRTIO_NET_STATS_TYPE_TX_GSO (1 << 6) + le64 supported_stats_types[1]; +} +It would be best to split the command and description into two. One for the
capabilities bit map.
Quoted 16 lines
And second for the actual stats header.
This avoids the mix up between the two.device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 1875
Quoted 12 lines
device-types/net/description.tex +12
-0+struct virtio_net_stats_reply_hdr { + le16 size; + le16 vq_index; + +#define VIRTIO_NET_STATS_TYPE_REPLY_CVQ 0 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC 1 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM 2 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO 3 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC 4 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM 5 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO 6 + u8 type;If the query command input has it, we likely don't need it in the response.
Quoted 5 lines
YES.
But the driver may need to handle multiple reply stats. I think that will be easy for the driver to handle so many stats with the
vq_indexand type.
Do you mean one command result returns multiple stats in one response?
And if so, and the types in the _data is bitmap, better to rename it as types_bmap or types_bitmap.
Quoted 10 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ \item [rx_drop_busy] + This is the number of packets dropped by the device when the deviceis
Quoted 3 lines
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2032
Quoted 2 lines
device-types/net/description.tex +2
-0+ busy. +I feel this is bit abstract counter and qualify the device as busy is tricky. Lets
move it out of the basic counter.
I will rethink about this.
Ok.
Quoted 8 lines
Quoted 2 lines
We need to add the capabilities and query them from the AQ too.
If the reply header structure and actual stats are split properly, it will be easyto add the query by the owner device.
YES. I agree.
But I would to know is there some specific requirements?
Not sure I understand the question.
We have this requirement in the requirements document of 1.4 at [1].
[1] https://lists.oasis-open.org/archives/virtio-comment/202308/msg00260.html
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: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
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/
Quoted 144 lines · Parav Pandit
Quoted 9 lines
From: Xuan Zhuo <[email protected]>
Sent: Tuesday, August 29, 2023 9:00 AMQuoted 4 lines
Its over cvq, so lets do,
s/channel/virtqueue
Quoted 9 lines
Quoted 2 lines
Please rename s/command-specific-data-reply/command_specific_result
I agree.
But it will be "command-specific-result" for alignment with 'command-specific- data'.
Right.
Quoted 10 lines
Quoted 4 lines
Review
Quoted 3 lines
There is little the driver can do
(quoted diff) +2
-0+except issue a diagnostic if \field{ack} is not VIRTIO_NET_OK. +May be driver can retry the command, put to error state, issue diagnostics,
ignore the error.
Quoted 1 line
So There is no need to mention what driver can/cannot do, so please just
drop the last line.
This is not new. It turns out that there is this line.
:(
I see it now.Quoted 2 lines
I think, if you want to remove this, you should post a new patch.
It will be separate patch.
Quoted 107 lines
Quoted 25 lines
Quoted 16 lines
+The command
VIRTIO_NET_CTRL_STATS_GETcontains \field{command- specific-data-reply}.\paragraph{Packet Receive Filtering}\label{sec:Device Types /
Network Device / Device Operation / Control Virtqueue / Packet Receive Filtering} \label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Setting Promiscuous Mode}%old label for latexdiff @@ -1805,6
+1811,424 @@ \subsubsection{Control Virtqueue}\label{sec:Device +Types /
Network Device / DeviUpon reset, a device MUST initialize all coalescing parameters to 0.
+\paragraph{Device Statistic}\label{sec:Device Types / Network
Review
Quoted 5 lines
(quoted diff) +5
-0+Device / Device Operation / Control Virtqueue / Device Statistic} + +If the VIRTIO_NET_F_DEVICE_STATS feature is negotiated, the driver +can obtain device stats from the device by using the following command. +s/device stats/device statistics at above and throughout many places below. in the spec wording, better to not shorten them.
Quoted 11 lines
Review
Quoted 8 lines
(quoted diff) +8
-0+Different types of virtqueues have different stats. The stats of +the receiveq are different from those of the transmitq. + +The stats of a certain type of virtqueue are also divided into +multiple types because different types require different features. +This enables the expansion of new stats. + +At one time, the driver can obtain the stats of one or multiple virtqueues.May be
s/At one time/In one command
This is to be more accurate, otherwise in one time we miss the notion ofcommand.
Quoted 16 lines
Quoted 13 lines
device-types/net/description.tex +12
-0+Additionally, the driver can obtain multiple type stats of each virtqueue. + +\begin{lstlisting} +#define VIRTIO_NET_CTRL_STATS 7 +#define VIRTIO_NET_CTRL_STATS_QUERY 0 +#define VIRTIO_NET_CTRL_STATS_GET 1 +\end{lstlisting} + +To obtain device stats, use the VIRTIO_NET_CTRL_STATS_GET command +with the \field{command-specific-data} containing the +virtio_net_ctrl_queue_stats structure. The result is returned in +theQuoted 2 lines
\field{command-specific-data-reply}.
+We opted for slightly different wording for describing command specific data
and results in aq.
Quoted 3 lines
So lets align it here.
Please reword above as,
The \field{command-specific-data} is in the format of \field{ struct
virtio_net_ctrl_queue_stats}.Quoted 2 lines
When the command completes successfully, \field{command_specific_result}
is in the format of \field{struct
virtio_net_stats_capabilites}.Quoted 19 lines
Quoted 19 lines
device-types/net/description.tex +18
-0+The following structure is used in \field{command-specific-data}: +\begin{lstlisting} +struct virtio_net_ctrl_queue_stats { + struct { + le16 vq_index; + le16 padding[3]; + le64 types[1]; + } stats[]; +}; +\end{lstlisting} + +The following structures are used in \field{command-specific-data-reply}: +\begin{lstlisting} +struct virtio_net_stats_capabilites { + +#define VIRTIO_NET_STATS_TYPE_CVQ (1 << 0) +#define VIRTIO_NET_STATS_TYPE_RX_BASIC (1 << 1) +#define VIRTIO_NET_STATS_TYPE_RX_CSUM (1 << 2)Quoted 8 lines
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 1863
Quoted 7 lines
device-types/net/description.tex +7
-0+#define VIRTIO_NET_STATS_TYPE_RX_GSO (1 << 3) +#define VIRTIO_NET_STATS_TYPE_TX_BASIC (1 << 4) +#define VIRTIO_NET_STATS_TYPE_TX_CSUM (1 << 5) +#define VIRTIO_NET_STATS_TYPE_TX_GSO (1 << 6) + le64 supported_stats_types[1]; +} +It would be best to split the command and description into two. One for the
capabilities bit map.
Quoted 16 lines
And second for the actual stats header.
This avoids the mix up between the two.device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 1875
Quoted 12 lines
device-types/net/description.tex +12
-0+struct virtio_net_stats_reply_hdr { + le16 size; + le16 vq_index; + +#define VIRTIO_NET_STATS_TYPE_REPLY_CVQ 0 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC 1 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM 2 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO 3 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC 4 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM 5 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO 6 + u8 type;If the query command input has it, we likely don't need it in the response.
Quoted 7 lines
Quoted 5 lines
YES.
But the driver may need to handle multiple reply stats. I think that will be easy for the driver to handle so many stats with the
vq_indexand type.Do you mean one command result returns multiple stats in one response?
And if so, and the types in the_datais bitmap, better to rename it astypes_bmaportypes_bitmap.
OK.
Quoted 17 lines
Quoted 11 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ \item [rx_drop_busy] + This is the number of packets dropped by the device when the deviceis
Quoted 3 lines
device-types/net/description.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 2032
Quoted 2 lines
device-types/net/description.tex +2
-0+ busy. +I feel this is bit abstract counter and qualify the device as busy is tricky. Lets
move it out of the basic counter.
I will rethink about this.
Ok.
Quoted 4 lines
Quoted 2 lines
We need to add the capabilities and query them from the AQ too.
If the reply header structure and actual stats are split properly, it will be easyto add the query by the owner device.
Quoted 8 lines
Quoted 4 lines
YES. I agree.
But I would to know is there some specific requirements?
Not sure I understand the question.
We have this requirement in the requirements document of 1.4 at [1].[1] https://lists.oasis-open.org/archives/virtio-comment/202308/msg00260.html
For this line:
"If the reply header structure and actual stats are split properly, it will be easy
to add the query by the owner device."
So for the header structure, is there some specific requirements?
Thanks.
Quoted 10 lines
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.
Quoted 9 lines
Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
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/
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: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
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/
Quoted 9 lines
From: Xuan Zhuo <[email protected]>
Sent: Tuesday, August 29, 2023 12:48 PMFor this line:
"If the reply header structure and actual stats are split properly, it will be easy
to add the query by the owner device."So for the header structure, is there some specific requirements?
TLV type, length, is only two fields needed and to align to 64-bit.
struct virtio_element_type {
u16 type;
u16 rsvd;
u32 length;
};Above generic type if defined, that we can possibly use across many virtio devices.
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: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
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/
Quoted 10 lines · Parav Pandit
Quoted 9 lines
From: Xuan Zhuo <[email protected]>
Sent: Tuesday, August 29, 2023 12:48 PMFor this line:
"If the reply header structure and actual stats are split properly, it will be easy
to add the query by the owner device."So for the header structure, is there some specific requirements?
Quoted 8 lines
TLV type, length, is only two fields needed and to align to 64-bit.
struct virtio_element_type { u16 type; u16 rsvd; u32 length; };Above generic type if defined, that we can possibly use across many virtio devices.
I see.
So I wonder, should we be thinking about this now. When will we try to get statistics via aq. If we try to do this, the request data may also have to use a uniform format.
Thanks.
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: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
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/