Skip to content

Commit 7f276db

Browse files
virtio-msg: restore 16-bit device numbers
Restore the 8-byte common header and 16-bit device-number model for virtio-msg. Revert bus-message device-number payloads and size bounds that were widened for the 64-bit direction. Document that larger deployments can scale with multiple bus instances instead of a wider dev_num field. Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
1 parent fae3435 commit 7f276db

1 file changed

Lines changed: 22 additions & 25 deletions

File tree

transport-msg.tex

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -249,32 +249,32 @@ \subsubsection{Transport Revisions and Maximum Message Size}
249249
\hline
250250
\field{revision} & \field{maximum size} & remarks \\
251251
\hline \hline
252-
1 & 60-65535 & Virtio Message Revision 1 \\
252+
1 & 52-65535 & Virtio Message Revision 1 \\
253253
\hline
254254
\end{tabular}
255255

256256
The table reflects the protocol-defined maximum size; the recommended
257-
advertised maximum remains 272 bytes for interoperability.
257+
advertised maximum remains 264 bytes for interoperability.
258258

259259
Note that a change in the virtio standard does not necessarily
260260
correspond to a change in the virtio-msg transport revision.
261261

262262
The maximum message size is specified from the transport-layer point of view
263-
and includes the 16-byte common header plus payload. Any extra encapsulation
263+
and includes the 8-byte common header plus payload. Any extra encapsulation
264264
imposed by the underlying bus (for example, a framing header) does not count
265265
against this limit. Today the largest practical inline configuration payload is
266266
244 bytes: messages such as GET_CONFIG and SET_CONFIG use 12 bytes of
267267
message-specific fields, leaving up to 244 bytes for device configuration data
268-
in one transfer when the recommended 272-byte maximum message size is used.
268+
in one transfer when the recommended 264-byte maximum message size is used.
269269
Larger configuration regions can be accessed through multiple exchanges without
270270
requiring a larger per-message limit.
271271

272272
\busnormative{\paragraph}{Message Size Bounds}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Revisions / Message Size}
273273
\begin{itemize}
274274
\item A bus implementation MUST advertise a maximum message size of at least
275-
60 bytes.
275+
52 bytes.
276276
\item A bus implementation SHOULD NOT advertise a maximum message size that
277-
exceeds 272 bytes (256-byte payload plus the common header).
277+
exceeds 264 bytes (256-byte payload plus the common header).
278278
\end{itemize}
279279

280280
\paragraph{Versioning and Forward Compatibility}
@@ -340,7 +340,7 @@ \subsubsection{Device Numbers and Enumeration}
340340
Device Numbers}
341341

342342
Each virtio-msg bus instance contains zero or more \emph{devices}, identified
343-
by a 64-bit \textbf{device number}. The device number is a bus-assigned
343+
by a 16-bit \textbf{device number}. The device number is a bus-assigned
344344
identifier and is distinct from the virtio device ID (device type) returned by
345345
\msgref{GET_DEVICE_INFO}. Buses discover these device numbers through
346346
mechanisms such as:
@@ -351,6 +351,10 @@ \subsubsection{Device Numbers and Enumeration}
351351
might inform the bus of available device numbers and their properties.
352352
\end{itemize}
353353

354+
The 16-bit device-number space provides roughly 65k device slots per bus
355+
instance. Deployments that require more devices can instantiate multiple bus
356+
instances and distribute devices across those instances.
357+
354358
Once a bus confirms that a device number is valid, regardless of the discovery
355359
method, it exposes that number to the driver side of the transport. The driver
356360
then issues \msgref{GET_DEVICE_INFO} as the first transport message for that
@@ -605,18 +609,17 @@ \subsubsection{Common Message Format}
605609
\label{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Common Message Format}
606610

607611
All virtio-msg exchanges, whether \emph{bus messages} or \emph{transport
608-
messages}, begin with a 16-byte header followed by an optional payload. The
612+
messages}, begin with an 8-byte header followed by an optional payload. The
609613
fields below describe the wire format for that header.
610614

611615
The header layout is:
612616
\begin{lstlisting}
613617
struct virtio_msg_header {
614618
u8 type; /* request/response + bus/transport */
615619
u8 msg_id; /* message id */
620+
le16 dev_num; /* target device number; bus messages MUST use 0 */
616621
le16 token; /* bus-managed correlation identifier */
617-
le16 msg_size; /* total size: header (16) + payload */
618-
le16 reserved; /* reserved, MUST be zero */
619-
le64 dev_num; /* target device number; bus messages MUST use 0 */
622+
le16 msg_size; /* total size: header (8) + payload */
620623
u8 payload[];
621624
};
622625
\end{lstlisting}
@@ -642,6 +645,10 @@ \subsubsection{Common Message Format}
642645
\item Bit[6]: 0=request/response message, 1=event.
643646
\item Bit[7]: 0=standardized message ID, 1=implementation-defined message ID.
644647
\end{itemize}
648+
\item \field{dev_num}: For transport messages, the device number that should
649+
receive the message. Device number 0 is not reserved for transport
650+
messages. Bus messages are identified by \field{type} and MUST carry
651+
\field{dev_num}=0.
645652
\item \field{token}: Correlation identifier owned and managed by the bus.
646653
Drivers and devices treat this field as opaque. A bus implementation MAY
647654
transparently insert or overwrite \field{token} values on the request leg,
@@ -650,12 +657,6 @@ \subsubsection{Common Message Format}
650657
\field{token} into the matching response before any bus-side rewrite.
651658
\item \field{msg_size}: Total size in bytes of the complete message (header
652659
plus payload).
653-
\item \field{reserved}: Reserved for future use. Transmitters set this field
654-
to zero, and receivers ignore it.
655-
\item \field{dev_num}: For transport messages, the device number that should
656-
receive the message. Device number 0 is not reserved for transport
657-
messages. Bus messages are identified by \field{type} and MUST carry
658-
\field{dev_num}=0.
659660
\item \field{payload}: Operation-specific data. If a bus introduces extra
660661
padding bytes, those bytes are not part of the payload semantics.
661662
\end{itemize}
@@ -667,8 +668,6 @@ \subsubsection{Common Message Format}
667668
\item A driver MUST ensure \field{msg_size} reflects the total message length
668669
(header plus payload) and MUST NOT exceed the maximum message size
669670
advertised by the bus instance.
670-
\item A driver MUST set \field{reserved} to zero when transmitting and MUST
671-
ignore the received \field{reserved} value.
672671
\item When sending a transport message, a driver MUST set \field{dev_num} to
673672
the intended device number.
674673
\item If a driver introduces padding bytes that become part of the transport
@@ -683,8 +682,6 @@ \subsubsection{Common Message Format}
683682
messages and MUST ignore those bits on receive.
684683
\item A device MUST ensure \field{msg_size} reflects the total message length
685684
(header plus payload) and does not exceed the bus's advertised maximum.
686-
\item A device MUST set \field{reserved} to zero when transmitting and MUST
687-
ignore the received \field{reserved} value.
688685
\item When sending a transport message, a device MUST set \field{dev_num} to
689686
its own device number.
690687
\item A device MUST ignore padding bytes that are documented as bus-specific
@@ -1931,13 +1928,13 @@ \subsubsection{Overview}
19311928

19321929
\begin{lstlisting}
19331930
struct virtio_bus_msg_get_devices_req {
1934-
le64 offset; /* starting device number */
1931+
le16 offset; /* starting device number */
19351932
le16 count; /* number of device-number slots requested */
19361933
};
19371934

19381935
struct virtio_bus_msg_get_devices_resp {
1939-
le64 offset; /* echoed starting device number */
1940-
le64 next_offset; /* 0 or suggested start for next query */
1936+
le16 offset; /* echoed starting device number */
1937+
le16 next_offset; /* 0 or suggested start for next query */
19411938
le16 count; /* number of slots returned */
19421939
u8 bitmap[]; /* ((count + 7) / 8) bytes, LSB-first packing */
19431940
};
@@ -2035,7 +2032,7 @@ \subsubsection{Overview}
20352032

20362033
\begin{lstlisting}
20372034
struct virtio_bus_msg_event_device {
2038-
le64 device_number;
2035+
le16 device_number;
20392036
le16 device_bus_state; /* see table below */
20402037
};
20412038
\end{lstlisting}

0 commit comments

Comments
 (0)