Skip to content

Commit d1b3d60

Browse files
virtio-msg: convert common message format to normative
Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
1 parent f537d94 commit d1b3d60

1 file changed

Lines changed: 54 additions & 19 deletions

File tree

transport-msg.tex

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@ \subsubsection{Endianness}
363363
\subsubsection{Common Message Format}
364364
\label{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Common Message Format}
365365

366-
All virtio-msg exchanges, whether \emph{bus messages} or
367-
\emph{transport messages}, begin with an 8 byte header followed by an optional
368-
payload.
366+
All virtio-msg exchanges, whether \emph{bus messages} or \emph{transport
367+
messages}, begin with an 8-byte header followed by an optional payload. The
368+
fields below describe the wire format for that header.
369369

370370
The header layout is:
371371
\begin{lstlisting}
@@ -384,30 +384,65 @@ \subsubsection{Common Message Format}
384384
\item \field{type}:
385385
\begin{itemize}
386386
\item Bit[0]: 0=request, 1=response.
387-
\item Bit[1]: 0=Transport Message, 1=Bus Message.
388-
\item Bits[2..7]: MUST be zero; receivers MUST ignore.
387+
\item Bit[1]: 0=transport message, 1=bus message.
388+
\item Bits[2..7]: reserved for future use.
389389
\end{itemize}
390390
\item \field{msg_id}: Message ID identifying the message definition. Ranges
391391
are defined in
392392
\ref{sec:Virtio Transport Options / Virtio Over Messages / Transport Messages}
393393
and
394394
\ref{sec:Virtio Transport Options / Virtio Over Messages / Bus Messages}.
395-
\item \field{dev_num}: For Transport Messages, the target device number; for
396-
Bus Messages MUST be zero.
397-
\item \field{token}: Non-zero for requests (which expect a response); zero
398-
MUST be used only for event (one-way) messages. Responses
399-
MUST echo the request's \field{token}.
400-
\item \field{msg_size}: Total size in bytes of the complete message (header +
401-
payload). MUST be \(\ge 8\) and MUST NOT exceed the
402-
bus's maximum message size.
403-
\item \field{payload}: Operation-specific data. Unused trailing bytes (if any
404-
introduced by a bus framing) MUST be zero and MUST be
405-
ignored by receivers.
395+
\item \field{dev_num}: For transport messages, the device number that should
396+
receive the message. Bus messages operate on device number 0.
397+
\item \field{token}: Requests use non-zero tokens so responses can be matched;
398+
event (one-way) messages use token 0 and do not expect a response.
399+
\item \field{msg_size}: Total size in bytes of the complete message (header
400+
plus payload).
401+
\item \field{payload}: Operation-specific data. If a bus introduces extra
402+
padding bytes, those bytes are not part of the payload semantics.
406403
\end{itemize}
407404

408-
All reserved header bits and any unspecified header values MUST be
409-
sent as zero and MUST be ignored on receive to preserve forward
410-
compatibility.
405+
\drivernormative{\paragraph}{Common Header (Driver)}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Common Message Format / Driver}
406+
\begin{itemize}
407+
\item A driver MUST set bits 2..7 of \field{type} to zero and MUST treat them as reserved when
408+
parsing received headers.
409+
\item A driver MUST ensure \field{msg_size} reflects the total message length (header plus payload)
410+
and MUST NOT exceed the maximum message size advertised by the bus instance.
411+
\item A driver MUST set \field{token}=0 for event (one-way) messages and MUST assign a non-zero
412+
\field{token} for every request that expects a response.
413+
\item When sending a transport message, a driver MUST set \field{dev_num} to the intended device
414+
number.
415+
\item If a driver introduces padding bytes that become part of the transport payload, it MUST set
416+
those bytes to zero.
417+
\end{itemize}
418+
419+
\devicenormative{\paragraph}{Common Header (Device)}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Common Message Format / Device}
420+
\begin{itemize}
421+
\item A device MUST set bits 2..7 of \field{type} to zero in transmitted messages and MUST ignore
422+
those bits on receive.
423+
\item A device MUST ensure \field{msg_size} reflects the total message length (header plus payload)
424+
and does not exceed the bus's advertised maximum.
425+
\item A device MUST set \field{token}=0 for event (one-way) messages it originates and MUST echo
426+
the \field{token} received in requests when producing responses.
427+
\item When sending a transport message, a device MUST set \field{dev_num} to its own device number.
428+
\item A device MUST ignore padding bytes that are documented as bus-specific and MUST zero any such
429+
bytes it introduces into the transport payload.
430+
\end{itemize}
431+
432+
\busnormative{\paragraph}{Common Header (Bus)}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Common Message Format / Bus}
433+
\begin{itemize}
434+
\item A bus implementation MUST deliver bus messages with \field{dev_num}=0 and MUST NOT alter
435+
\field{dev_num} for transport messages beyond the routing needed to reach the addressed
436+
device.
437+
\item A bus implementation MUST set bits 2..7 of \field{type} to zero when generating bus messages
438+
and MUST ignore those bits when forwarding transport messages.
439+
\item If the bus adds framing or padding bytes around the common header or payload, it MUST set
440+
those bytes to zero before delivering the message to the opposite side and MUST present the
441+
same zero padding when the opposite side reads a message.
442+
\end{itemize}
443+
444+
Reserved header bits and unspecified header values MUST be transmitted as zero and ignored on
445+
receive to preserve forward compatibility.
411446

412447
\subsubsection{Message Correlation}
413448
\label{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Correlation}

0 commit comments

Comments
 (0)