[virtio-dev] Re: [PATCH] virtio-vsock: add VIRTIO_VSOCK_F_DGRAM feature bit

2023-09-06 Thread Bobby Eshleman
On Wed, Sep 06, 2023 at 04:28:12PM +0200, Stefano Garzarella wrote:
> On Sat, Sep 02, 2023 at 04:35:25AM -0400, Michael S. Tsirkin wrote:
> > On Sat, Sep 02, 2023 at 04:56:42AM +, Bobby Eshleman wrote:
> > > On Fri, Sep 01, 2023 at 02:45:14PM +0200, Stefano Garzarella wrote:
> > > > On Tue, Aug 29, 2023 at 09:29:45PM +, Bobby Eshleman wrote:
> > > > > This adds support for datagrams to the virtio-vsock device.
> > > > >
> > > > > virtio-vsock already supports stream and seqpacket types. The existing
> > > > > message types and header fields are extended to support datagrams.
> > > > > Semantic differences between the flow types are stated, as well as any
> > > > > additional requirements for devices and drivers implementing this
> > > > > feature.
> > > > >
> > > > > Signed-off-by: Bobby Eshleman 
> > > > > ---
> > > > > device-types/vsock/description.tex | 95 +++---
> > > > > 1 file changed, 88 insertions(+), 7 deletions(-)
> > > > >
> > > > > diff --git a/device-types/vsock/description.tex 
> > > > > b/device-types/vsock/description.tex
> > > > > index 7d91d159872f..638dca8e5da1 100644
> > > > > --- a/device-types/vsock/description.tex
> > > > > +++ b/device-types/vsock/description.tex
> > > > > @@ -20,6 +20,7 @@ \subsection{Feature bits}\label{sec:Device Types / 
> > > > > Socket Device / Feature bits}
> > > > > \item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported.
> > > > > \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is 
> > > > > supported.
> > > > > \item[VIRTIO_VSOCK_F_NO_IMPLIED_STREAM (2)] stream socket type is not 
> > > > > implied.
> > > > > +\item[VIRTIO_VSOCK_F_DGRAM (3)] datagram socket type is supported.
> > > > > \end{description}
> > > > >
> > > > > \drivernormative{\subsubsection}{Feature bits}{Device Types / Socket 
> > > > > Device / Feature bits}
> > > > > @@ -167,17 +168,22 @@ \subsubsection{Addressing}\label{sec:Device 
> > > > > Types / Socket Device / Device Opera
> > > > > consists of a (cid, port number) tuple. The header fields used for 
> > > > > this are
> > > > > \field{src_cid}, \field{src_port}, \field{dst_cid}, and 
> > > > > \field{dst_port}.
> > > > >
> > > > > -Currently stream and seqpacket sockets are supported. \field{type} 
> > > > > is 1 (VIRTIO_VSOCK_TYPE_STREAM)
> > > > > -for stream socket types, and 2 (VIRTIO_VSOCK_TYPE_SEQPACKET) for 
> > > > > seqpacket socket types.
> > > > > +
> > > > > +Currently stream, seqpacket, and datagram sockets are supported. 
> > > > > \field{type} is
> > > > > +1 (VIRTIO_VSOCK_TYPE_STREAM) for stream socket types, 2 
> > > > > (VIRTIO_VSOCK_TYPE_SEQPACKET) for
> > > > > +seqpacket socket types, and 3 (VIRTIO_VSOCK_TYPE_DGRAM) for datagram 
> > > > > socket types.
> > > > >
> > > > > \begin{lstlisting}
> > > > > #define VIRTIO_VSOCK_TYPE_STREAM1
> > > > > #define VIRTIO_VSOCK_TYPE_SEQPACKET 2
> > > > > +#define VIRTIO_VSOCK_TYPE_DGRAM 3
> > > > > \end{lstlisting}
> > > > >
> > > > > Stream sockets provide in-order, guaranteed, connection-oriented 
> > > > > delivery
> > > > > without message boundaries. Seqpacket sockets provide in-order, 
> > > > > guaranteed,
> > > > > -connection-oriented delivery with message and record boundaries.
> > > > > +connection-oriented delivery with message and record boundaries. 
> > > > > Datagram
> > > > > +sockets provide connection-less, best-effort delivery of messages, 
> > > > > with no
> > > > > +order or reliability guarantees.
> > > > >
> > > > > \subsubsection{Buffer Space Management}\label{sec:Device Types / 
> > > > > Socket Device / Device Operation / Buffer Space Management}
> > > > > \field{buf_alloc} and \field{fwd_cnt} are used for buffer space 
> > > > > management of
> > > > > @@ -203,16 +209,19 @@ \subsubsection{Buffer Space 
> > > > > Management}\label{sec:Device Types / Socket Device /
> > > > > previously receiving a VIRTIO_VSOCK_OP_CREDIT_REQUEST packet. This 
> > > > > allows
> > > > > communicating updates any time a change in buffer space occurs.
> > > > >
> > > > > +\field{buf_alloc} and \field{fwd_cnt} are reserved for future use by 
> > > > > datagram
> > > > > +sockets. These fields are not used for datagram buffer space 
> > > > > management.
> > > > > +
> > > > > \drivernormative{\paragraph}{Device Operation: Buffer Space 
> > > > > Management}{Device Types / Socket Device / Device Operation / Buffer 
> > > > > Space Management}
> > > > > -VIRTIO_VSOCK_OP_RW data packets MUST only be transmitted when the 
> > > > > peer has
> > > > > -sufficient free buffer space for the payload.
> > > > > +For stream and seqpacket flows, VIRTIO_VSOCK_OP_RW data packets MUST 
> > > > > only be
> > > > > +transmitted when the peer has sufficient free buffer space for the 
> > > > > payload.
> > > > >
> > > > > All packets associated with a stream flow MUST contain valid 
> > > > > information in
> > > > > \field{buf_alloc} and \field{fwd_cnt} fields.
> > > > >
> > > > > \devicenormative{\paragraph}{Device Operation: 

Re: [virtio-dev] Re: [PATCH] virtio-vsock: add VIRTIO_VSOCK_F_DGRAM feature bit

2023-09-06 Thread Bobby Eshleman
On Wed, Sep 06, 2023 at 04:17:59AM -0400, Michael S. Tsirkin wrote:
> On Sat, Sep 02, 2023 at 09:24:26AM +, Bobby Eshleman wrote:
> > On Sat, Sep 02, 2023 at 04:41:28AM -0400, Michael S. Tsirkin wrote:
> > > On Sat, Sep 02, 2023 at 04:37:19AM +, Bobby Eshleman wrote:
> > > > On Fri, Sep 01, 2023 at 09:31:03AM -0400, Michael S. Tsirkin wrote:
> > > > > On Wed, Aug 30, 2023 at 12:43:03AM +, Bobby Eshleman wrote:
> > > > > > On Tue, Aug 29, 2023 at 06:21:35PM -0400, Michael S. Tsirkin wrote:
> > > > > > > On Tue, Aug 29, 2023 at 09:29:45PM +, Bobby Eshleman wrote:
> > > > > > > > This adds support for datagrams to the virtio-vsock device.
> > > > > > > > 
> > > > > > > > virtio-vsock already supports stream and seqpacket types. The 
> > > > > > > > existing
> > > > > > > > message types and header fields are extended to support 
> > > > > > > > datagrams.
> > > > > > > > Semantic differences between the flow types are stated, as well 
> > > > > > > > as any
> > > > > > > > additional requirements for devices and drivers implementing 
> > > > > > > > this
> > > > > > > > feature.
> > > > > > > > 
> > > > > > > > Signed-off-by: Bobby Eshleman 
> > > > > > > > ---
> > > > > > > >  device-types/vsock/description.tex | 95 
> > > > > > > > +++---
> > > > > > > >  1 file changed, 88 insertions(+), 7 deletions(-)
> > > > > > > > 
> > > > > > > > diff --git a/device-types/vsock/description.tex 
> > > > > > > > b/device-types/vsock/description.tex
> > > > > > > > index 7d91d159872f..638dca8e5da1 100644
> > > > > > > > --- a/device-types/vsock/description.tex
> > > > > > > > +++ b/device-types/vsock/description.tex
> > > > > > > > @@ -20,6 +20,7 @@ \subsection{Feature bits}\label{sec:Device 
> > > > > > > > Types / Socket Device / Feature bits}
> > > > > > > >  \item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is 
> > > > > > > > supported.
> > > > > > > >  \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is 
> > > > > > > > supported.
> > > > > > > >  \item[VIRTIO_VSOCK_F_NO_IMPLIED_STREAM (2)] stream socket type 
> > > > > > > > is not implied.
> > > > > > > > +\item[VIRTIO_VSOCK_F_DGRAM (3)] datagram socket type is 
> > > > > > > > supported.
> > > > > > > >  \end{description}
> > > > > > > >  
> > > > > > > >  \drivernormative{\subsubsection}{Feature bits}{Device Types / 
> > > > > > > > Socket Device / Feature bits}
> > > > > > > > @@ -167,17 +168,22 @@ 
> > > > > > > > \subsubsection{Addressing}\label{sec:Device Types / Socket 
> > > > > > > > Device / Device Opera
> > > > > > > >  consists of a (cid, port number) tuple. The header fields used 
> > > > > > > > for this are
> > > > > > > >  \field{src_cid}, \field{src_port}, \field{dst_cid}, and 
> > > > > > > > \field{dst_port}.
> > > > > > > >  
> > > > > > > > -Currently stream and seqpacket sockets are supported. 
> > > > > > > > \field{type} is 1 (VIRTIO_VSOCK_TYPE_STREAM)
> > > > > > > > -for stream socket types, and 2 (VIRTIO_VSOCK_TYPE_SEQPACKET) 
> > > > > > > > for seqpacket socket types.
> > > > > > > > +
> > > > > > > > +Currently stream, seqpacket, and datagram sockets are 
> > > > > > > > supported. \field{type} is
> > > > > > > > +1 (VIRTIO_VSOCK_TYPE_STREAM) for stream socket types, 2 
> > > > > > > > (VIRTIO_VSOCK_TYPE_SEQPACKET) for
> > > > > > > > +seqpacket socket types, and 3 (VIRTIO_VSOCK_TYPE_DGRAM) for 
> > > > > > > > datagram socket types.
> > > > > > > >  
> > > > > > > >  \begin{lstlisting}
> > > > > > > >  #define VIRTIO_VSOCK_TYPE_STREAM1
> > > > > > > >  #define VIRTIO_VSOCK_TYPE_SEQPACKET 2
> > > > > > > > +#define VIRTIO_VSOCK_TYPE_DGRAM 3
> > > > > > > >  \end{lstlisting}
> > > > > > > >  
> > > > > > > >  Stream sockets provide in-order, guaranteed, 
> > > > > > > > connection-oriented delivery
> > > > > > > >  without message boundaries. Seqpacket sockets provide 
> > > > > > > > in-order, guaranteed,
> > > > > > > > -connection-oriented delivery with message and record 
> > > > > > > > boundaries.
> > > > > > > > +connection-oriented delivery with message and record 
> > > > > > > > boundaries. Datagram
> > > > > > > > +sockets provide connection-less, best-effort delivery of 
> > > > > > > > messages, with no
> > > > > > > > +order or reliability guarantees.
> > > > > > > >  
> > > > > > > >  \subsubsection{Buffer Space Management}\label{sec:Device Types 
> > > > > > > > / Socket Device / Device Operation / Buffer Space Management}
> > > > > > > >  \field{buf_alloc} and \field{fwd_cnt} are used for buffer 
> > > > > > > > space management of
> > > > > > > > @@ -203,16 +209,19 @@ \subsubsection{Buffer Space 
> > > > > > > > Management}\label{sec:Device Types / Socket Device /
> > > > > > > >  previously receiving a VIRTIO_VSOCK_OP_CREDIT_REQUEST packet. 
> > > > > > > > This allows
> > > > > > > >  communicating updates any time a change in buffer space occurs.
> > > > > > > >  
> > > > > > > > +\field{buf_alloc} and \field{fwd_cnt} are reserved for future 
> > > > > > 

[virtio-dev] Re: [PATCH] virtio-vsock: add VIRTIO_VSOCK_F_DGRAM feature bit

2023-09-06 Thread Stefano Garzarella

On Sat, Sep 02, 2023 at 04:35:25AM -0400, Michael S. Tsirkin wrote:

On Sat, Sep 02, 2023 at 04:56:42AM +, Bobby Eshleman wrote:

On Fri, Sep 01, 2023 at 02:45:14PM +0200, Stefano Garzarella wrote:
> On Tue, Aug 29, 2023 at 09:29:45PM +, Bobby Eshleman wrote:
> > This adds support for datagrams to the virtio-vsock device.
> >
> > virtio-vsock already supports stream and seqpacket types. The existing
> > message types and header fields are extended to support datagrams.
> > Semantic differences between the flow types are stated, as well as any
> > additional requirements for devices and drivers implementing this
> > feature.
> >
> > Signed-off-by: Bobby Eshleman 
> > ---
> > device-types/vsock/description.tex | 95 +++---
> > 1 file changed, 88 insertions(+), 7 deletions(-)
> >
> > diff --git a/device-types/vsock/description.tex 
b/device-types/vsock/description.tex
> > index 7d91d159872f..638dca8e5da1 100644
> > --- a/device-types/vsock/description.tex
> > +++ b/device-types/vsock/description.tex
> > @@ -20,6 +20,7 @@ \subsection{Feature bits}\label{sec:Device Types / Socket 
Device / Feature bits}
> > \item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported.
> > \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is supported.
> > \item[VIRTIO_VSOCK_F_NO_IMPLIED_STREAM (2)] stream socket type is not 
implied.
> > +\item[VIRTIO_VSOCK_F_DGRAM (3)] datagram socket type is supported.
> > \end{description}
> >
> > \drivernormative{\subsubsection}{Feature bits}{Device Types / Socket Device 
/ Feature bits}
> > @@ -167,17 +168,22 @@ \subsubsection{Addressing}\label{sec:Device Types / 
Socket Device / Device Opera
> > consists of a (cid, port number) tuple. The header fields used for this are
> > \field{src_cid}, \field{src_port}, \field{dst_cid}, and \field{dst_port}.
> >
> > -Currently stream and seqpacket sockets are supported. \field{type} is 1 
(VIRTIO_VSOCK_TYPE_STREAM)
> > -for stream socket types, and 2 (VIRTIO_VSOCK_TYPE_SEQPACKET) for seqpacket 
socket types.
> > +
> > +Currently stream, seqpacket, and datagram sockets are supported. 
\field{type} is
> > +1 (VIRTIO_VSOCK_TYPE_STREAM) for stream socket types, 2 
(VIRTIO_VSOCK_TYPE_SEQPACKET) for
> > +seqpacket socket types, and 3 (VIRTIO_VSOCK_TYPE_DGRAM) for datagram 
socket types.
> >
> > \begin{lstlisting}
> > #define VIRTIO_VSOCK_TYPE_STREAM1
> > #define VIRTIO_VSOCK_TYPE_SEQPACKET 2
> > +#define VIRTIO_VSOCK_TYPE_DGRAM 3
> > \end{lstlisting}
> >
> > Stream sockets provide in-order, guaranteed, connection-oriented delivery
> > without message boundaries. Seqpacket sockets provide in-order, guaranteed,
> > -connection-oriented delivery with message and record boundaries.
> > +connection-oriented delivery with message and record boundaries. Datagram
> > +sockets provide connection-less, best-effort delivery of messages, with no
> > +order or reliability guarantees.
> >
> > \subsubsection{Buffer Space Management}\label{sec:Device Types / Socket 
Device / Device Operation / Buffer Space Management}
> > \field{buf_alloc} and \field{fwd_cnt} are used for buffer space management 
of
> > @@ -203,16 +209,19 @@ \subsubsection{Buffer Space 
Management}\label{sec:Device Types / Socket Device /
> > previously receiving a VIRTIO_VSOCK_OP_CREDIT_REQUEST packet. This allows
> > communicating updates any time a change in buffer space occurs.
> >
> > +\field{buf_alloc} and \field{fwd_cnt} are reserved for future use by 
datagram
> > +sockets. These fields are not used for datagram buffer space management.
> > +
> > \drivernormative{\paragraph}{Device Operation: Buffer Space 
Management}{Device Types / Socket Device / Device Operation / Buffer Space Management}
> > -VIRTIO_VSOCK_OP_RW data packets MUST only be transmitted when the peer has
> > -sufficient free buffer space for the payload.
> > +For stream and seqpacket flows, VIRTIO_VSOCK_OP_RW data packets MUST only 
be
> > +transmitted when the peer has sufficient free buffer space for the payload.
> >
> > All packets associated with a stream flow MUST contain valid information in
> > \field{buf_alloc} and \field{fwd_cnt} fields.
> >
> > \devicenormative{\paragraph}{Device Operation: Buffer Space
> > Management}{Device Types / Socket Device / Device Operation / Buffer
> > Space Management}
> > -VIRTIO_VSOCK_OP_RW data packets MUST only be transmitted when the peer has
> > -sufficient free buffer space for the payload.
> > +For stream and seqpacket flows, VIRTIO_VSOCK_OP_RW data packets MUST only 
be
> > +transmitted when the peer has sufficient free buffer space for the payload.
> >
> > All packets associated with a stream flow MUST contain valid information in
> > \field{buf_alloc} and \field{fwd_cnt} fields.
> > @@ -299,6 +308,78 @@ \subsubsection{Seqpacket Sockets}\label{sec:Device 
Types / Socket Device / Devic
> > #define VIRTIO_VSOCK_SEQ_EOR (1 << 1)
> > \end{lstlisting}
> >
> > +\subsubsection{Datagram Sockets}\label{sec:Device Types / Socket Device / 

[virtio-dev] Re: [PATCH] virtio-vsock: add VIRTIO_VSOCK_F_DGRAM feature bit

2023-09-06 Thread Michael S. Tsirkin
On Sat, Sep 02, 2023 at 09:24:26AM +, Bobby Eshleman wrote:
> On Sat, Sep 02, 2023 at 04:41:28AM -0400, Michael S. Tsirkin wrote:
> > On Sat, Sep 02, 2023 at 04:37:19AM +, Bobby Eshleman wrote:
> > > On Fri, Sep 01, 2023 at 09:31:03AM -0400, Michael S. Tsirkin wrote:
> > > > On Wed, Aug 30, 2023 at 12:43:03AM +, Bobby Eshleman wrote:
> > > > > On Tue, Aug 29, 2023 at 06:21:35PM -0400, Michael S. Tsirkin wrote:
> > > > > > On Tue, Aug 29, 2023 at 09:29:45PM +, Bobby Eshleman wrote:
> > > > > > > This adds support for datagrams to the virtio-vsock device.
> > > > > > > 
> > > > > > > virtio-vsock already supports stream and seqpacket types. The 
> > > > > > > existing
> > > > > > > message types and header fields are extended to support datagrams.
> > > > > > > Semantic differences between the flow types are stated, as well 
> > > > > > > as any
> > > > > > > additional requirements for devices and drivers implementing this
> > > > > > > feature.
> > > > > > > 
> > > > > > > Signed-off-by: Bobby Eshleman 
> > > > > > > ---
> > > > > > >  device-types/vsock/description.tex | 95 
> > > > > > > +++---
> > > > > > >  1 file changed, 88 insertions(+), 7 deletions(-)
> > > > > > > 
> > > > > > > diff --git a/device-types/vsock/description.tex 
> > > > > > > b/device-types/vsock/description.tex
> > > > > > > index 7d91d159872f..638dca8e5da1 100644
> > > > > > > --- a/device-types/vsock/description.tex
> > > > > > > +++ b/device-types/vsock/description.tex
> > > > > > > @@ -20,6 +20,7 @@ \subsection{Feature bits}\label{sec:Device 
> > > > > > > Types / Socket Device / Feature bits}
> > > > > > >  \item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported.
> > > > > > >  \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is 
> > > > > > > supported.
> > > > > > >  \item[VIRTIO_VSOCK_F_NO_IMPLIED_STREAM (2)] stream socket type 
> > > > > > > is not implied.
> > > > > > > +\item[VIRTIO_VSOCK_F_DGRAM (3)] datagram socket type is 
> > > > > > > supported.
> > > > > > >  \end{description}
> > > > > > >  
> > > > > > >  \drivernormative{\subsubsection}{Feature bits}{Device Types / 
> > > > > > > Socket Device / Feature bits}
> > > > > > > @@ -167,17 +168,22 @@ \subsubsection{Addressing}\label{sec:Device 
> > > > > > > Types / Socket Device / Device Opera
> > > > > > >  consists of a (cid, port number) tuple. The header fields used 
> > > > > > > for this are
> > > > > > >  \field{src_cid}, \field{src_port}, \field{dst_cid}, and 
> > > > > > > \field{dst_port}.
> > > > > > >  
> > > > > > > -Currently stream and seqpacket sockets are supported. 
> > > > > > > \field{type} is 1 (VIRTIO_VSOCK_TYPE_STREAM)
> > > > > > > -for stream socket types, and 2 (VIRTIO_VSOCK_TYPE_SEQPACKET) for 
> > > > > > > seqpacket socket types.
> > > > > > > +
> > > > > > > +Currently stream, seqpacket, and datagram sockets are supported. 
> > > > > > > \field{type} is
> > > > > > > +1 (VIRTIO_VSOCK_TYPE_STREAM) for stream socket types, 2 
> > > > > > > (VIRTIO_VSOCK_TYPE_SEQPACKET) for
> > > > > > > +seqpacket socket types, and 3 (VIRTIO_VSOCK_TYPE_DGRAM) for 
> > > > > > > datagram socket types.
> > > > > > >  
> > > > > > >  \begin{lstlisting}
> > > > > > >  #define VIRTIO_VSOCK_TYPE_STREAM1
> > > > > > >  #define VIRTIO_VSOCK_TYPE_SEQPACKET 2
> > > > > > > +#define VIRTIO_VSOCK_TYPE_DGRAM 3
> > > > > > >  \end{lstlisting}
> > > > > > >  
> > > > > > >  Stream sockets provide in-order, guaranteed, connection-oriented 
> > > > > > > delivery
> > > > > > >  without message boundaries. Seqpacket sockets provide in-order, 
> > > > > > > guaranteed,
> > > > > > > -connection-oriented delivery with message and record boundaries.
> > > > > > > +connection-oriented delivery with message and record boundaries. 
> > > > > > > Datagram
> > > > > > > +sockets provide connection-less, best-effort delivery of 
> > > > > > > messages, with no
> > > > > > > +order or reliability guarantees.
> > > > > > >  
> > > > > > >  \subsubsection{Buffer Space Management}\label{sec:Device Types / 
> > > > > > > Socket Device / Device Operation / Buffer Space Management}
> > > > > > >  \field{buf_alloc} and \field{fwd_cnt} are used for buffer space 
> > > > > > > management of
> > > > > > > @@ -203,16 +209,19 @@ \subsubsection{Buffer Space 
> > > > > > > Management}\label{sec:Device Types / Socket Device /
> > > > > > >  previously receiving a VIRTIO_VSOCK_OP_CREDIT_REQUEST packet. 
> > > > > > > This allows
> > > > > > >  communicating updates any time a change in buffer space occurs.
> > > > > > >  
> > > > > > > +\field{buf_alloc} and \field{fwd_cnt} are reserved for future 
> > > > > > > use by datagram
> > > > > > > +sockets. These fields are not used for datagram buffer space 
> > > > > > > management.
> > > > > > 
> > > > > > no limits on datagram size?
> > > > > > 
> > > > > 
> > > > > In the Linux proof-of-concept, it is 64KB. I can add that here too.
> > > > 
> > > > or device driven maybe ...
> > > > 

[virtio-dev] Re: [PATCH] virtio-vsock: add VIRTIO_VSOCK_F_DGRAM feature bit

2023-09-05 Thread Bobby Eshleman
On Sat, Sep 02, 2023 at 04:35:25AM -0400, Michael S. Tsirkin wrote:
> On Sat, Sep 02, 2023 at 04:56:42AM +, Bobby Eshleman wrote:
> > On Fri, Sep 01, 2023 at 02:45:14PM +0200, Stefano Garzarella wrote:
> > > On Tue, Aug 29, 2023 at 09:29:45PM +, Bobby Eshleman wrote:
> > > > This adds support for datagrams to the virtio-vsock device.
> > > > 
> > > > virtio-vsock already supports stream and seqpacket types. The existing
> > > > message types and header fields are extended to support datagrams.
> > > > Semantic differences between the flow types are stated, as well as any
> > > > additional requirements for devices and drivers implementing this
> > > > feature.
> > > > 
> > > > Signed-off-by: Bobby Eshleman 
> > > > ---
> > > > device-types/vsock/description.tex | 95 +++---
> > > > 1 file changed, 88 insertions(+), 7 deletions(-)
> > > > 
> > > > diff --git a/device-types/vsock/description.tex 
> > > > b/device-types/vsock/description.tex
> > > > index 7d91d159872f..638dca8e5da1 100644
> > > > --- a/device-types/vsock/description.tex
> > > > +++ b/device-types/vsock/description.tex
> > > > @@ -20,6 +20,7 @@ \subsection{Feature bits}\label{sec:Device Types / 
> > > > Socket Device / Feature bits}
> > > > \item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported.
> > > > \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is supported.
> > > > \item[VIRTIO_VSOCK_F_NO_IMPLIED_STREAM (2)] stream socket type is not 
> > > > implied.
> > > > +\item[VIRTIO_VSOCK_F_DGRAM (3)] datagram socket type is supported.
> > > > \end{description}
> > > > 
> > > > \drivernormative{\subsubsection}{Feature bits}{Device Types / Socket 
> > > > Device / Feature bits}
> > > > @@ -167,17 +168,22 @@ \subsubsection{Addressing}\label{sec:Device Types 
> > > > / Socket Device / Device Opera
> > > > consists of a (cid, port number) tuple. The header fields used for this 
> > > > are
> > > > \field{src_cid}, \field{src_port}, \field{dst_cid}, and 
> > > > \field{dst_port}.
> > > > 
> > > > -Currently stream and seqpacket sockets are supported. \field{type} is 
> > > > 1 (VIRTIO_VSOCK_TYPE_STREAM)
> > > > -for stream socket types, and 2 (VIRTIO_VSOCK_TYPE_SEQPACKET) for 
> > > > seqpacket socket types.
> > > > +
> > > > +Currently stream, seqpacket, and datagram sockets are supported. 
> > > > \field{type} is
> > > > +1 (VIRTIO_VSOCK_TYPE_STREAM) for stream socket types, 2 
> > > > (VIRTIO_VSOCK_TYPE_SEQPACKET) for
> > > > +seqpacket socket types, and 3 (VIRTIO_VSOCK_TYPE_DGRAM) for datagram 
> > > > socket types.
> > > > 
> > > > \begin{lstlisting}
> > > > #define VIRTIO_VSOCK_TYPE_STREAM1
> > > > #define VIRTIO_VSOCK_TYPE_SEQPACKET 2
> > > > +#define VIRTIO_VSOCK_TYPE_DGRAM 3
> > > > \end{lstlisting}
> > > > 
> > > > Stream sockets provide in-order, guaranteed, connection-oriented 
> > > > delivery
> > > > without message boundaries. Seqpacket sockets provide in-order, 
> > > > guaranteed,
> > > > -connection-oriented delivery with message and record boundaries.
> > > > +connection-oriented delivery with message and record boundaries. 
> > > > Datagram
> > > > +sockets provide connection-less, best-effort delivery of messages, 
> > > > with no
> > > > +order or reliability guarantees.
> > > > 
> > > > \subsubsection{Buffer Space Management}\label{sec:Device Types / Socket 
> > > > Device / Device Operation / Buffer Space Management}
> > > > \field{buf_alloc} and \field{fwd_cnt} are used for buffer space 
> > > > management of
> > > > @@ -203,16 +209,19 @@ \subsubsection{Buffer Space 
> > > > Management}\label{sec:Device Types / Socket Device /
> > > > previously receiving a VIRTIO_VSOCK_OP_CREDIT_REQUEST packet. This 
> > > > allows
> > > > communicating updates any time a change in buffer space occurs.
> > > > 
> > > > +\field{buf_alloc} and \field{fwd_cnt} are reserved for future use by 
> > > > datagram
> > > > +sockets. These fields are not used for datagram buffer space 
> > > > management.
> > > > +
> > > > \drivernormative{\paragraph}{Device Operation: Buffer Space 
> > > > Management}{Device Types / Socket Device / Device Operation / Buffer 
> > > > Space Management}
> > > > -VIRTIO_VSOCK_OP_RW data packets MUST only be transmitted when the peer 
> > > > has
> > > > -sufficient free buffer space for the payload.
> > > > +For stream and seqpacket flows, VIRTIO_VSOCK_OP_RW data packets MUST 
> > > > only be
> > > > +transmitted when the peer has sufficient free buffer space for the 
> > > > payload.
> > > > 
> > > > All packets associated with a stream flow MUST contain valid 
> > > > information in
> > > > \field{buf_alloc} and \field{fwd_cnt} fields.
> > > > 
> > > > \devicenormative{\paragraph}{Device Operation: Buffer Space
> > > > Management}{Device Types / Socket Device / Device Operation / Buffer
> > > > Space Management}
> > > > -VIRTIO_VSOCK_OP_RW data packets MUST only be transmitted when the peer 
> > > > has
> > > > -sufficient free buffer space for the payload.
> > 

[virtio-dev] Re: [PATCH] virtio-vsock: add VIRTIO_VSOCK_F_DGRAM feature bit

2023-09-05 Thread Bobby Eshleman
On Sat, Sep 02, 2023 at 04:41:28AM -0400, Michael S. Tsirkin wrote:
> On Sat, Sep 02, 2023 at 04:37:19AM +, Bobby Eshleman wrote:
> > On Fri, Sep 01, 2023 at 09:31:03AM -0400, Michael S. Tsirkin wrote:
> > > On Wed, Aug 30, 2023 at 12:43:03AM +, Bobby Eshleman wrote:
> > > > On Tue, Aug 29, 2023 at 06:21:35PM -0400, Michael S. Tsirkin wrote:
> > > > > On Tue, Aug 29, 2023 at 09:29:45PM +, Bobby Eshleman wrote:
> > > > > > This adds support for datagrams to the virtio-vsock device.
> > > > > > 
> > > > > > virtio-vsock already supports stream and seqpacket types. The 
> > > > > > existing
> > > > > > message types and header fields are extended to support datagrams.
> > > > > > Semantic differences between the flow types are stated, as well as 
> > > > > > any
> > > > > > additional requirements for devices and drivers implementing this
> > > > > > feature.
> > > > > > 
> > > > > > Signed-off-by: Bobby Eshleman 
> > > > > > ---
> > > > > >  device-types/vsock/description.tex | 95 
> > > > > > +++---
> > > > > >  1 file changed, 88 insertions(+), 7 deletions(-)
> > > > > > 
> > > > > > diff --git a/device-types/vsock/description.tex 
> > > > > > b/device-types/vsock/description.tex
> > > > > > index 7d91d159872f..638dca8e5da1 100644
> > > > > > --- a/device-types/vsock/description.tex
> > > > > > +++ b/device-types/vsock/description.tex
> > > > > > @@ -20,6 +20,7 @@ \subsection{Feature bits}\label{sec:Device Types 
> > > > > > / Socket Device / Feature bits}
> > > > > >  \item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported.
> > > > > >  \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is 
> > > > > > supported.
> > > > > >  \item[VIRTIO_VSOCK_F_NO_IMPLIED_STREAM (2)] stream socket type is 
> > > > > > not implied.
> > > > > > +\item[VIRTIO_VSOCK_F_DGRAM (3)] datagram socket type is supported.
> > > > > >  \end{description}
> > > > > >  
> > > > > >  \drivernormative{\subsubsection}{Feature bits}{Device Types / 
> > > > > > Socket Device / Feature bits}
> > > > > > @@ -167,17 +168,22 @@ \subsubsection{Addressing}\label{sec:Device 
> > > > > > Types / Socket Device / Device Opera
> > > > > >  consists of a (cid, port number) tuple. The header fields used for 
> > > > > > this are
> > > > > >  \field{src_cid}, \field{src_port}, \field{dst_cid}, and 
> > > > > > \field{dst_port}.
> > > > > >  
> > > > > > -Currently stream and seqpacket sockets are supported. \field{type} 
> > > > > > is 1 (VIRTIO_VSOCK_TYPE_STREAM)
> > > > > > -for stream socket types, and 2 (VIRTIO_VSOCK_TYPE_SEQPACKET) for 
> > > > > > seqpacket socket types.
> > > > > > +
> > > > > > +Currently stream, seqpacket, and datagram sockets are supported. 
> > > > > > \field{type} is
> > > > > > +1 (VIRTIO_VSOCK_TYPE_STREAM) for stream socket types, 2 
> > > > > > (VIRTIO_VSOCK_TYPE_SEQPACKET) for
> > > > > > +seqpacket socket types, and 3 (VIRTIO_VSOCK_TYPE_DGRAM) for 
> > > > > > datagram socket types.
> > > > > >  
> > > > > >  \begin{lstlisting}
> > > > > >  #define VIRTIO_VSOCK_TYPE_STREAM1
> > > > > >  #define VIRTIO_VSOCK_TYPE_SEQPACKET 2
> > > > > > +#define VIRTIO_VSOCK_TYPE_DGRAM 3
> > > > > >  \end{lstlisting}
> > > > > >  
> > > > > >  Stream sockets provide in-order, guaranteed, connection-oriented 
> > > > > > delivery
> > > > > >  without message boundaries. Seqpacket sockets provide in-order, 
> > > > > > guaranteed,
> > > > > > -connection-oriented delivery with message and record boundaries.
> > > > > > +connection-oriented delivery with message and record boundaries. 
> > > > > > Datagram
> > > > > > +sockets provide connection-less, best-effort delivery of messages, 
> > > > > > with no
> > > > > > +order or reliability guarantees.
> > > > > >  
> > > > > >  \subsubsection{Buffer Space Management}\label{sec:Device Types / 
> > > > > > Socket Device / Device Operation / Buffer Space Management}
> > > > > >  \field{buf_alloc} and \field{fwd_cnt} are used for buffer space 
> > > > > > management of
> > > > > > @@ -203,16 +209,19 @@ \subsubsection{Buffer Space 
> > > > > > Management}\label{sec:Device Types / Socket Device /
> > > > > >  previously receiving a VIRTIO_VSOCK_OP_CREDIT_REQUEST packet. This 
> > > > > > allows
> > > > > >  communicating updates any time a change in buffer space occurs.
> > > > > >  
> > > > > > +\field{buf_alloc} and \field{fwd_cnt} are reserved for future use 
> > > > > > by datagram
> > > > > > +sockets. These fields are not used for datagram buffer space 
> > > > > > management.
> > > > > 
> > > > > no limits on datagram size?
> > > > > 
> > > > 
> > > > In the Linux proof-of-concept, it is 64KB. I can add that here too.
> > > 
> > > or device driven maybe ...
> > > 
> > 
> > Ah yes, I think Stefano was suggesting something like Laura's proposal:
> > https://lists.oasis-open.org/archives/virtio-comment/202206/msg00093.html
> > 
> > > > > also with no flow control at all there's a performance problem:
> > > > > imagine queue gets full. 

[virtio-dev] Re: [PATCH] virtio-vsock: add VIRTIO_VSOCK_F_DGRAM feature bit

2023-09-02 Thread Michael S. Tsirkin
On Sat, Sep 02, 2023 at 04:37:19AM +, Bobby Eshleman wrote:
> On Fri, Sep 01, 2023 at 09:31:03AM -0400, Michael S. Tsirkin wrote:
> > On Wed, Aug 30, 2023 at 12:43:03AM +, Bobby Eshleman wrote:
> > > On Tue, Aug 29, 2023 at 06:21:35PM -0400, Michael S. Tsirkin wrote:
> > > > On Tue, Aug 29, 2023 at 09:29:45PM +, Bobby Eshleman wrote:
> > > > > This adds support for datagrams to the virtio-vsock device.
> > > > > 
> > > > > virtio-vsock already supports stream and seqpacket types. The existing
> > > > > message types and header fields are extended to support datagrams.
> > > > > Semantic differences between the flow types are stated, as well as any
> > > > > additional requirements for devices and drivers implementing this
> > > > > feature.
> > > > > 
> > > > > Signed-off-by: Bobby Eshleman 
> > > > > ---
> > > > >  device-types/vsock/description.tex | 95 
> > > > > +++---
> > > > >  1 file changed, 88 insertions(+), 7 deletions(-)
> > > > > 
> > > > > diff --git a/device-types/vsock/description.tex 
> > > > > b/device-types/vsock/description.tex
> > > > > index 7d91d159872f..638dca8e5da1 100644
> > > > > --- a/device-types/vsock/description.tex
> > > > > +++ b/device-types/vsock/description.tex
> > > > > @@ -20,6 +20,7 @@ \subsection{Feature bits}\label{sec:Device Types / 
> > > > > Socket Device / Feature bits}
> > > > >  \item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported.
> > > > >  \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is 
> > > > > supported.
> > > > >  \item[VIRTIO_VSOCK_F_NO_IMPLIED_STREAM (2)] stream socket type is 
> > > > > not implied.
> > > > > +\item[VIRTIO_VSOCK_F_DGRAM (3)] datagram socket type is supported.
> > > > >  \end{description}
> > > > >  
> > > > >  \drivernormative{\subsubsection}{Feature bits}{Device Types / Socket 
> > > > > Device / Feature bits}
> > > > > @@ -167,17 +168,22 @@ \subsubsection{Addressing}\label{sec:Device 
> > > > > Types / Socket Device / Device Opera
> > > > >  consists of a (cid, port number) tuple. The header fields used for 
> > > > > this are
> > > > >  \field{src_cid}, \field{src_port}, \field{dst_cid}, and 
> > > > > \field{dst_port}.
> > > > >  
> > > > > -Currently stream and seqpacket sockets are supported. \field{type} 
> > > > > is 1 (VIRTIO_VSOCK_TYPE_STREAM)
> > > > > -for stream socket types, and 2 (VIRTIO_VSOCK_TYPE_SEQPACKET) for 
> > > > > seqpacket socket types.
> > > > > +
> > > > > +Currently stream, seqpacket, and datagram sockets are supported. 
> > > > > \field{type} is
> > > > > +1 (VIRTIO_VSOCK_TYPE_STREAM) for stream socket types, 2 
> > > > > (VIRTIO_VSOCK_TYPE_SEQPACKET) for
> > > > > +seqpacket socket types, and 3 (VIRTIO_VSOCK_TYPE_DGRAM) for datagram 
> > > > > socket types.
> > > > >  
> > > > >  \begin{lstlisting}
> > > > >  #define VIRTIO_VSOCK_TYPE_STREAM1
> > > > >  #define VIRTIO_VSOCK_TYPE_SEQPACKET 2
> > > > > +#define VIRTIO_VSOCK_TYPE_DGRAM 3
> > > > >  \end{lstlisting}
> > > > >  
> > > > >  Stream sockets provide in-order, guaranteed, connection-oriented 
> > > > > delivery
> > > > >  without message boundaries. Seqpacket sockets provide in-order, 
> > > > > guaranteed,
> > > > > -connection-oriented delivery with message and record boundaries.
> > > > > +connection-oriented delivery with message and record boundaries. 
> > > > > Datagram
> > > > > +sockets provide connection-less, best-effort delivery of messages, 
> > > > > with no
> > > > > +order or reliability guarantees.
> > > > >  
> > > > >  \subsubsection{Buffer Space Management}\label{sec:Device Types / 
> > > > > Socket Device / Device Operation / Buffer Space Management}
> > > > >  \field{buf_alloc} and \field{fwd_cnt} are used for buffer space 
> > > > > management of
> > > > > @@ -203,16 +209,19 @@ \subsubsection{Buffer Space 
> > > > > Management}\label{sec:Device Types / Socket Device /
> > > > >  previously receiving a VIRTIO_VSOCK_OP_CREDIT_REQUEST packet. This 
> > > > > allows
> > > > >  communicating updates any time a change in buffer space occurs.
> > > > >  
> > > > > +\field{buf_alloc} and \field{fwd_cnt} are reserved for future use by 
> > > > > datagram
> > > > > +sockets. These fields are not used for datagram buffer space 
> > > > > management.
> > > > 
> > > > no limits on datagram size?
> > > > 
> > > 
> > > In the Linux proof-of-concept, it is 64KB. I can add that here too.
> > 
> > or device driven maybe ...
> > 
> 
> Ah yes, I think Stefano was suggesting something like Laura's proposal:
> https://lists.oasis-open.org/archives/virtio-comment/202206/msg00093.html
> 
> > > > also with no flow control at all there's a performance problem:
> > > > imagine queue gets full. now buffers begin to be dropped.
> > > > problem is, dropping is faster than delivering to application.
> > > > so now application sees its packets consumed super quickly
> > > > and starts sending even faster.
> > > > not good for performance.
> > > > 
> > > > yes datagram expects some way to 

[virtio-dev] Re: [PATCH] virtio-vsock: add VIRTIO_VSOCK_F_DGRAM feature bit

2023-09-02 Thread Michael S. Tsirkin
On Sat, Sep 02, 2023 at 04:56:42AM +, Bobby Eshleman wrote:
> On Fri, Sep 01, 2023 at 02:45:14PM +0200, Stefano Garzarella wrote:
> > On Tue, Aug 29, 2023 at 09:29:45PM +, Bobby Eshleman wrote:
> > > This adds support for datagrams to the virtio-vsock device.
> > > 
> > > virtio-vsock already supports stream and seqpacket types. The existing
> > > message types and header fields are extended to support datagrams.
> > > Semantic differences between the flow types are stated, as well as any
> > > additional requirements for devices and drivers implementing this
> > > feature.
> > > 
> > > Signed-off-by: Bobby Eshleman 
> > > ---
> > > device-types/vsock/description.tex | 95 +++---
> > > 1 file changed, 88 insertions(+), 7 deletions(-)
> > > 
> > > diff --git a/device-types/vsock/description.tex 
> > > b/device-types/vsock/description.tex
> > > index 7d91d159872f..638dca8e5da1 100644
> > > --- a/device-types/vsock/description.tex
> > > +++ b/device-types/vsock/description.tex
> > > @@ -20,6 +20,7 @@ \subsection{Feature bits}\label{sec:Device Types / 
> > > Socket Device / Feature bits}
> > > \item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported.
> > > \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is supported.
> > > \item[VIRTIO_VSOCK_F_NO_IMPLIED_STREAM (2)] stream socket type is not 
> > > implied.
> > > +\item[VIRTIO_VSOCK_F_DGRAM (3)] datagram socket type is supported.
> > > \end{description}
> > > 
> > > \drivernormative{\subsubsection}{Feature bits}{Device Types / Socket 
> > > Device / Feature bits}
> > > @@ -167,17 +168,22 @@ \subsubsection{Addressing}\label{sec:Device Types / 
> > > Socket Device / Device Opera
> > > consists of a (cid, port number) tuple. The header fields used for this 
> > > are
> > > \field{src_cid}, \field{src_port}, \field{dst_cid}, and \field{dst_port}.
> > > 
> > > -Currently stream and seqpacket sockets are supported. \field{type} is 1 
> > > (VIRTIO_VSOCK_TYPE_STREAM)
> > > -for stream socket types, and 2 (VIRTIO_VSOCK_TYPE_SEQPACKET) for 
> > > seqpacket socket types.
> > > +
> > > +Currently stream, seqpacket, and datagram sockets are supported. 
> > > \field{type} is
> > > +1 (VIRTIO_VSOCK_TYPE_STREAM) for stream socket types, 2 
> > > (VIRTIO_VSOCK_TYPE_SEQPACKET) for
> > > +seqpacket socket types, and 3 (VIRTIO_VSOCK_TYPE_DGRAM) for datagram 
> > > socket types.
> > > 
> > > \begin{lstlisting}
> > > #define VIRTIO_VSOCK_TYPE_STREAM1
> > > #define VIRTIO_VSOCK_TYPE_SEQPACKET 2
> > > +#define VIRTIO_VSOCK_TYPE_DGRAM 3
> > > \end{lstlisting}
> > > 
> > > Stream sockets provide in-order, guaranteed, connection-oriented delivery
> > > without message boundaries. Seqpacket sockets provide in-order, 
> > > guaranteed,
> > > -connection-oriented delivery with message and record boundaries.
> > > +connection-oriented delivery with message and record boundaries. Datagram
> > > +sockets provide connection-less, best-effort delivery of messages, with 
> > > no
> > > +order or reliability guarantees.
> > > 
> > > \subsubsection{Buffer Space Management}\label{sec:Device Types / Socket 
> > > Device / Device Operation / Buffer Space Management}
> > > \field{buf_alloc} and \field{fwd_cnt} are used for buffer space 
> > > management of
> > > @@ -203,16 +209,19 @@ \subsubsection{Buffer Space 
> > > Management}\label{sec:Device Types / Socket Device /
> > > previously receiving a VIRTIO_VSOCK_OP_CREDIT_REQUEST packet. This allows
> > > communicating updates any time a change in buffer space occurs.
> > > 
> > > +\field{buf_alloc} and \field{fwd_cnt} are reserved for future use by 
> > > datagram
> > > +sockets. These fields are not used for datagram buffer space management.
> > > +
> > > \drivernormative{\paragraph}{Device Operation: Buffer Space 
> > > Management}{Device Types / Socket Device / Device Operation / Buffer 
> > > Space Management}
> > > -VIRTIO_VSOCK_OP_RW data packets MUST only be transmitted when the peer 
> > > has
> > > -sufficient free buffer space for the payload.
> > > +For stream and seqpacket flows, VIRTIO_VSOCK_OP_RW data packets MUST 
> > > only be
> > > +transmitted when the peer has sufficient free buffer space for the 
> > > payload.
> > > 
> > > All packets associated with a stream flow MUST contain valid information 
> > > in
> > > \field{buf_alloc} and \field{fwd_cnt} fields.
> > > 
> > > \devicenormative{\paragraph}{Device Operation: Buffer Space
> > > Management}{Device Types / Socket Device / Device Operation / Buffer
> > > Space Management}
> > > -VIRTIO_VSOCK_OP_RW data packets MUST only be transmitted when the peer 
> > > has
> > > -sufficient free buffer space for the payload.
> > > +For stream and seqpacket flows, VIRTIO_VSOCK_OP_RW data packets MUST 
> > > only be
> > > +transmitted when the peer has sufficient free buffer space for the 
> > > payload.
> > > 
> > > All packets associated with a stream flow MUST contain valid information 
> > > in
> > > \field{buf_alloc} and 

[virtio-dev] Re: [PATCH] virtio-vsock: add VIRTIO_VSOCK_F_DGRAM feature bit

2023-09-01 Thread Bobby Eshleman
On Fri, Sep 01, 2023 at 02:45:14PM +0200, Stefano Garzarella wrote:
> On Tue, Aug 29, 2023 at 09:29:45PM +, Bobby Eshleman wrote:
> > This adds support for datagrams to the virtio-vsock device.
> > 
> > virtio-vsock already supports stream and seqpacket types. The existing
> > message types and header fields are extended to support datagrams.
> > Semantic differences between the flow types are stated, as well as any
> > additional requirements for devices and drivers implementing this
> > feature.
> > 
> > Signed-off-by: Bobby Eshleman 
> > ---
> > device-types/vsock/description.tex | 95 +++---
> > 1 file changed, 88 insertions(+), 7 deletions(-)
> > 
> > diff --git a/device-types/vsock/description.tex 
> > b/device-types/vsock/description.tex
> > index 7d91d159872f..638dca8e5da1 100644
> > --- a/device-types/vsock/description.tex
> > +++ b/device-types/vsock/description.tex
> > @@ -20,6 +20,7 @@ \subsection{Feature bits}\label{sec:Device Types / Socket 
> > Device / Feature bits}
> > \item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported.
> > \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is supported.
> > \item[VIRTIO_VSOCK_F_NO_IMPLIED_STREAM (2)] stream socket type is not 
> > implied.
> > +\item[VIRTIO_VSOCK_F_DGRAM (3)] datagram socket type is supported.
> > \end{description}
> > 
> > \drivernormative{\subsubsection}{Feature bits}{Device Types / Socket Device 
> > / Feature bits}
> > @@ -167,17 +168,22 @@ \subsubsection{Addressing}\label{sec:Device Types / 
> > Socket Device / Device Opera
> > consists of a (cid, port number) tuple. The header fields used for this are
> > \field{src_cid}, \field{src_port}, \field{dst_cid}, and \field{dst_port}.
> > 
> > -Currently stream and seqpacket sockets are supported. \field{type} is 1 
> > (VIRTIO_VSOCK_TYPE_STREAM)
> > -for stream socket types, and 2 (VIRTIO_VSOCK_TYPE_SEQPACKET) for seqpacket 
> > socket types.
> > +
> > +Currently stream, seqpacket, and datagram sockets are supported. 
> > \field{type} is
> > +1 (VIRTIO_VSOCK_TYPE_STREAM) for stream socket types, 2 
> > (VIRTIO_VSOCK_TYPE_SEQPACKET) for
> > +seqpacket socket types, and 3 (VIRTIO_VSOCK_TYPE_DGRAM) for datagram 
> > socket types.
> > 
> > \begin{lstlisting}
> > #define VIRTIO_VSOCK_TYPE_STREAM1
> > #define VIRTIO_VSOCK_TYPE_SEQPACKET 2
> > +#define VIRTIO_VSOCK_TYPE_DGRAM 3
> > \end{lstlisting}
> > 
> > Stream sockets provide in-order, guaranteed, connection-oriented delivery
> > without message boundaries. Seqpacket sockets provide in-order, guaranteed,
> > -connection-oriented delivery with message and record boundaries.
> > +connection-oriented delivery with message and record boundaries. Datagram
> > +sockets provide connection-less, best-effort delivery of messages, with no
> > +order or reliability guarantees.
> > 
> > \subsubsection{Buffer Space Management}\label{sec:Device Types / Socket 
> > Device / Device Operation / Buffer Space Management}
> > \field{buf_alloc} and \field{fwd_cnt} are used for buffer space management 
> > of
> > @@ -203,16 +209,19 @@ \subsubsection{Buffer Space 
> > Management}\label{sec:Device Types / Socket Device /
> > previously receiving a VIRTIO_VSOCK_OP_CREDIT_REQUEST packet. This allows
> > communicating updates any time a change in buffer space occurs.
> > 
> > +\field{buf_alloc} and \field{fwd_cnt} are reserved for future use by 
> > datagram
> > +sockets. These fields are not used for datagram buffer space management.
> > +
> > \drivernormative{\paragraph}{Device Operation: Buffer Space 
> > Management}{Device Types / Socket Device / Device Operation / Buffer Space 
> > Management}
> > -VIRTIO_VSOCK_OP_RW data packets MUST only be transmitted when the peer has
> > -sufficient free buffer space for the payload.
> > +For stream and seqpacket flows, VIRTIO_VSOCK_OP_RW data packets MUST only 
> > be
> > +transmitted when the peer has sufficient free buffer space for the payload.
> > 
> > All packets associated with a stream flow MUST contain valid information in
> > \field{buf_alloc} and \field{fwd_cnt} fields.
> > 
> > \devicenormative{\paragraph}{Device Operation: Buffer Space
> > Management}{Device Types / Socket Device / Device Operation / Buffer
> > Space Management}
> > -VIRTIO_VSOCK_OP_RW data packets MUST only be transmitted when the peer has
> > -sufficient free buffer space for the payload.
> > +For stream and seqpacket flows, VIRTIO_VSOCK_OP_RW data packets MUST only 
> > be
> > +transmitted when the peer has sufficient free buffer space for the payload.
> > 
> > All packets associated with a stream flow MUST contain valid information in
> > \field{buf_alloc} and \field{fwd_cnt} fields.
> > @@ -299,6 +308,78 @@ \subsubsection{Seqpacket Sockets}\label{sec:Device 
> > Types / Socket Device / Devic
> > #define VIRTIO_VSOCK_SEQ_EOR (1 << 1)
> > \end{lstlisting}
> > 
> > +\subsubsection{Datagram Sockets}\label{sec:Device Types / Socket Device / 
> > Device Operation / Datagram Sockets}
> > +
> 

[virtio-dev] Re: [PATCH] virtio-vsock: add VIRTIO_VSOCK_F_DGRAM feature bit

2023-09-01 Thread Bobby Eshleman
On Fri, Sep 01, 2023 at 09:31:03AM -0400, Michael S. Tsirkin wrote:
> On Wed, Aug 30, 2023 at 12:43:03AM +, Bobby Eshleman wrote:
> > On Tue, Aug 29, 2023 at 06:21:35PM -0400, Michael S. Tsirkin wrote:
> > > On Tue, Aug 29, 2023 at 09:29:45PM +, Bobby Eshleman wrote:
> > > > This adds support for datagrams to the virtio-vsock device.
> > > > 
> > > > virtio-vsock already supports stream and seqpacket types. The existing
> > > > message types and header fields are extended to support datagrams.
> > > > Semantic differences between the flow types are stated, as well as any
> > > > additional requirements for devices and drivers implementing this
> > > > feature.
> > > > 
> > > > Signed-off-by: Bobby Eshleman 
> > > > ---
> > > >  device-types/vsock/description.tex | 95 +++---
> > > >  1 file changed, 88 insertions(+), 7 deletions(-)
> > > > 
> > > > diff --git a/device-types/vsock/description.tex 
> > > > b/device-types/vsock/description.tex
> > > > index 7d91d159872f..638dca8e5da1 100644
> > > > --- a/device-types/vsock/description.tex
> > > > +++ b/device-types/vsock/description.tex
> > > > @@ -20,6 +20,7 @@ \subsection{Feature bits}\label{sec:Device Types / 
> > > > Socket Device / Feature bits}
> > > >  \item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported.
> > > >  \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is supported.
> > > >  \item[VIRTIO_VSOCK_F_NO_IMPLIED_STREAM (2)] stream socket type is not 
> > > > implied.
> > > > +\item[VIRTIO_VSOCK_F_DGRAM (3)] datagram socket type is supported.
> > > >  \end{description}
> > > >  
> > > >  \drivernormative{\subsubsection}{Feature bits}{Device Types / Socket 
> > > > Device / Feature bits}
> > > > @@ -167,17 +168,22 @@ \subsubsection{Addressing}\label{sec:Device Types 
> > > > / Socket Device / Device Opera
> > > >  consists of a (cid, port number) tuple. The header fields used for 
> > > > this are
> > > >  \field{src_cid}, \field{src_port}, \field{dst_cid}, and 
> > > > \field{dst_port}.
> > > >  
> > > > -Currently stream and seqpacket sockets are supported. \field{type} is 
> > > > 1 (VIRTIO_VSOCK_TYPE_STREAM)
> > > > -for stream socket types, and 2 (VIRTIO_VSOCK_TYPE_SEQPACKET) for 
> > > > seqpacket socket types.
> > > > +
> > > > +Currently stream, seqpacket, and datagram sockets are supported. 
> > > > \field{type} is
> > > > +1 (VIRTIO_VSOCK_TYPE_STREAM) for stream socket types, 2 
> > > > (VIRTIO_VSOCK_TYPE_SEQPACKET) for
> > > > +seqpacket socket types, and 3 (VIRTIO_VSOCK_TYPE_DGRAM) for datagram 
> > > > socket types.
> > > >  
> > > >  \begin{lstlisting}
> > > >  #define VIRTIO_VSOCK_TYPE_STREAM1
> > > >  #define VIRTIO_VSOCK_TYPE_SEQPACKET 2
> > > > +#define VIRTIO_VSOCK_TYPE_DGRAM 3
> > > >  \end{lstlisting}
> > > >  
> > > >  Stream sockets provide in-order, guaranteed, connection-oriented 
> > > > delivery
> > > >  without message boundaries. Seqpacket sockets provide in-order, 
> > > > guaranteed,
> > > > -connection-oriented delivery with message and record boundaries.
> > > > +connection-oriented delivery with message and record boundaries. 
> > > > Datagram
> > > > +sockets provide connection-less, best-effort delivery of messages, 
> > > > with no
> > > > +order or reliability guarantees.
> > > >  
> > > >  \subsubsection{Buffer Space Management}\label{sec:Device Types / 
> > > > Socket Device / Device Operation / Buffer Space Management}
> > > >  \field{buf_alloc} and \field{fwd_cnt} are used for buffer space 
> > > > management of
> > > > @@ -203,16 +209,19 @@ \subsubsection{Buffer Space 
> > > > Management}\label{sec:Device Types / Socket Device /
> > > >  previously receiving a VIRTIO_VSOCK_OP_CREDIT_REQUEST packet. This 
> > > > allows
> > > >  communicating updates any time a change in buffer space occurs.
> > > >  
> > > > +\field{buf_alloc} and \field{fwd_cnt} are reserved for future use by 
> > > > datagram
> > > > +sockets. These fields are not used for datagram buffer space 
> > > > management.
> > > 
> > > no limits on datagram size?
> > > 
> > 
> > In the Linux proof-of-concept, it is 64KB. I can add that here too.
> 
> or device driven maybe ...
> 

Ah yes, I think Stefano was suggesting something like Laura's proposal:
https://lists.oasis-open.org/archives/virtio-comment/202206/msg00093.html

> > > also with no flow control at all there's a performance problem:
> > > imagine queue gets full. now buffers begin to be dropped.
> > > problem is, dropping is faster than delivering to application.
> > > so now application sees its packets consumed super quickly
> > > and starts sending even faster.
> > > not good for performance.
> > > 
> > > yes datagram expects some way to drop packets but just disabling flow
> > > control completely is not the right thing to do I think.
> > > 
> > 
> > On the LKML I discussed using congestion notification as a way to handle
> > this situation, but deferred it to a future feature bit. I can build
> > it in from the beginning 

[virtio-dev] Re: [PATCH] virtio-vsock: add VIRTIO_VSOCK_F_DGRAM feature bit

2023-09-01 Thread Michael S. Tsirkin
On Wed, Aug 30, 2023 at 12:43:03AM +, Bobby Eshleman wrote:
> On Tue, Aug 29, 2023 at 06:21:35PM -0400, Michael S. Tsirkin wrote:
> > On Tue, Aug 29, 2023 at 09:29:45PM +, Bobby Eshleman wrote:
> > > This adds support for datagrams to the virtio-vsock device.
> > > 
> > > virtio-vsock already supports stream and seqpacket types. The existing
> > > message types and header fields are extended to support datagrams.
> > > Semantic differences between the flow types are stated, as well as any
> > > additional requirements for devices and drivers implementing this
> > > feature.
> > > 
> > > Signed-off-by: Bobby Eshleman 
> > > ---
> > >  device-types/vsock/description.tex | 95 +++---
> > >  1 file changed, 88 insertions(+), 7 deletions(-)
> > > 
> > > diff --git a/device-types/vsock/description.tex 
> > > b/device-types/vsock/description.tex
> > > index 7d91d159872f..638dca8e5da1 100644
> > > --- a/device-types/vsock/description.tex
> > > +++ b/device-types/vsock/description.tex
> > > @@ -20,6 +20,7 @@ \subsection{Feature bits}\label{sec:Device Types / 
> > > Socket Device / Feature bits}
> > >  \item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported.
> > >  \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is supported.
> > >  \item[VIRTIO_VSOCK_F_NO_IMPLIED_STREAM (2)] stream socket type is not 
> > > implied.
> > > +\item[VIRTIO_VSOCK_F_DGRAM (3)] datagram socket type is supported.
> > >  \end{description}
> > >  
> > >  \drivernormative{\subsubsection}{Feature bits}{Device Types / Socket 
> > > Device / Feature bits}
> > > @@ -167,17 +168,22 @@ \subsubsection{Addressing}\label{sec:Device Types / 
> > > Socket Device / Device Opera
> > >  consists of a (cid, port number) tuple. The header fields used for this 
> > > are
> > >  \field{src_cid}, \field{src_port}, \field{dst_cid}, and \field{dst_port}.
> > >  
> > > -Currently stream and seqpacket sockets are supported. \field{type} is 1 
> > > (VIRTIO_VSOCK_TYPE_STREAM)
> > > -for stream socket types, and 2 (VIRTIO_VSOCK_TYPE_SEQPACKET) for 
> > > seqpacket socket types.
> > > +
> > > +Currently stream, seqpacket, and datagram sockets are supported. 
> > > \field{type} is
> > > +1 (VIRTIO_VSOCK_TYPE_STREAM) for stream socket types, 2 
> > > (VIRTIO_VSOCK_TYPE_SEQPACKET) for
> > > +seqpacket socket types, and 3 (VIRTIO_VSOCK_TYPE_DGRAM) for datagram 
> > > socket types.
> > >  
> > >  \begin{lstlisting}
> > >  #define VIRTIO_VSOCK_TYPE_STREAM1
> > >  #define VIRTIO_VSOCK_TYPE_SEQPACKET 2
> > > +#define VIRTIO_VSOCK_TYPE_DGRAM 3
> > >  \end{lstlisting}
> > >  
> > >  Stream sockets provide in-order, guaranteed, connection-oriented delivery
> > >  without message boundaries. Seqpacket sockets provide in-order, 
> > > guaranteed,
> > > -connection-oriented delivery with message and record boundaries.
> > > +connection-oriented delivery with message and record boundaries. Datagram
> > > +sockets provide connection-less, best-effort delivery of messages, with 
> > > no
> > > +order or reliability guarantees.
> > >  
> > >  \subsubsection{Buffer Space Management}\label{sec:Device Types / Socket 
> > > Device / Device Operation / Buffer Space Management}
> > >  \field{buf_alloc} and \field{fwd_cnt} are used for buffer space 
> > > management of
> > > @@ -203,16 +209,19 @@ \subsubsection{Buffer Space 
> > > Management}\label{sec:Device Types / Socket Device /
> > >  previously receiving a VIRTIO_VSOCK_OP_CREDIT_REQUEST packet. This allows
> > >  communicating updates any time a change in buffer space occurs.
> > >  
> > > +\field{buf_alloc} and \field{fwd_cnt} are reserved for future use by 
> > > datagram
> > > +sockets. These fields are not used for datagram buffer space management.
> > 
> > no limits on datagram size?
> > 
> 
> In the Linux proof-of-concept, it is 64KB. I can add that here too.

or device driven maybe ...

> > also with no flow control at all there's a performance problem:
> > imagine queue gets full. now buffers begin to be dropped.
> > problem is, dropping is faster than delivering to application.
> > so now application sees its packets consumed super quickly
> > and starts sending even faster.
> > not good for performance.
> > 
> > yes datagram expects some way to drop packets but just disabling flow
> > control completely is not the right thing to do I think.
> > 
> 
> On the LKML I discussed using congestion notification as a way to handle
> this situation, but deferred it to a future feature bit. I can build
> it in from the beginning though.

as in messages to stop/start transmission? might work.

> > 
> > > +
> > >  \drivernormative{\paragraph}{Device Operation: Buffer Space 
> > > Management}{Device Types / Socket Device / Device Operation / Buffer 
> > > Space Management}
> > > -VIRTIO_VSOCK_OP_RW data packets MUST only be transmitted when the peer 
> > > has
> > > -sufficient free buffer space for the payload.
> > > +For stream and seqpacket flows, VIRTIO_VSOCK_OP_RW data packets 

[virtio-dev] Re: [PATCH] virtio-vsock: add VIRTIO_VSOCK_F_DGRAM feature bit

2023-09-01 Thread Stefano Garzarella

On Tue, Aug 29, 2023 at 09:29:45PM +, Bobby Eshleman wrote:

This adds support for datagrams to the virtio-vsock device.

virtio-vsock already supports stream and seqpacket types. The existing
message types and header fields are extended to support datagrams.
Semantic differences between the flow types are stated, as well as any
additional requirements for devices and drivers implementing this
feature.

Signed-off-by: Bobby Eshleman 
---
device-types/vsock/description.tex | 95 +++---
1 file changed, 88 insertions(+), 7 deletions(-)

diff --git a/device-types/vsock/description.tex 
b/device-types/vsock/description.tex
index 7d91d159872f..638dca8e5da1 100644
--- a/device-types/vsock/description.tex
+++ b/device-types/vsock/description.tex
@@ -20,6 +20,7 @@ \subsection{Feature bits}\label{sec:Device Types / Socket 
Device / Feature bits}
\item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported.
\item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is supported.
\item[VIRTIO_VSOCK_F_NO_IMPLIED_STREAM (2)] stream socket type is not implied.
+\item[VIRTIO_VSOCK_F_DGRAM (3)] datagram socket type is supported.
\end{description}

\drivernormative{\subsubsection}{Feature bits}{Device Types / Socket Device / 
Feature bits}
@@ -167,17 +168,22 @@ \subsubsection{Addressing}\label{sec:Device Types / 
Socket Device / Device Opera
consists of a (cid, port number) tuple. The header fields used for this are
\field{src_cid}, \field{src_port}, \field{dst_cid}, and \field{dst_port}.

-Currently stream and seqpacket sockets are supported. \field{type} is 1 
(VIRTIO_VSOCK_TYPE_STREAM)
-for stream socket types, and 2 (VIRTIO_VSOCK_TYPE_SEQPACKET) for seqpacket 
socket types.
+
+Currently stream, seqpacket, and datagram sockets are supported. \field{type} 
is
+1 (VIRTIO_VSOCK_TYPE_STREAM) for stream socket types, 2 
(VIRTIO_VSOCK_TYPE_SEQPACKET) for
+seqpacket socket types, and 3 (VIRTIO_VSOCK_TYPE_DGRAM) for datagram socket 
types.

\begin{lstlisting}
#define VIRTIO_VSOCK_TYPE_STREAM1
#define VIRTIO_VSOCK_TYPE_SEQPACKET 2
+#define VIRTIO_VSOCK_TYPE_DGRAM 3
\end{lstlisting}

Stream sockets provide in-order, guaranteed, connection-oriented delivery
without message boundaries. Seqpacket sockets provide in-order, guaranteed,
-connection-oriented delivery with message and record boundaries.
+connection-oriented delivery with message and record boundaries. Datagram
+sockets provide connection-less, best-effort delivery of messages, with no
+order or reliability guarantees.

\subsubsection{Buffer Space Management}\label{sec:Device Types / Socket Device 
/ Device Operation / Buffer Space Management}
\field{buf_alloc} and \field{fwd_cnt} are used for buffer space management of
@@ -203,16 +209,19 @@ \subsubsection{Buffer Space Management}\label{sec:Device 
Types / Socket Device /
previously receiving a VIRTIO_VSOCK_OP_CREDIT_REQUEST packet. This allows
communicating updates any time a change in buffer space occurs.

+\field{buf_alloc} and \field{fwd_cnt} are reserved for future use by datagram
+sockets. These fields are not used for datagram buffer space management.
+
\drivernormative{\paragraph}{Device Operation: Buffer Space Management}{Device 
Types / Socket Device / Device Operation / Buffer Space Management}
-VIRTIO_VSOCK_OP_RW data packets MUST only be transmitted when the peer has
-sufficient free buffer space for the payload.
+For stream and seqpacket flows, VIRTIO_VSOCK_OP_RW data packets MUST only be
+transmitted when the peer has sufficient free buffer space for the payload.

All packets associated with a stream flow MUST contain valid information in
\field{buf_alloc} and \field{fwd_cnt} fields.

\devicenormative{\paragraph}{Device Operation: Buffer Space 
Management}{Device Types / Socket Device / Device Operation / Buffer 
Space Management}

-VIRTIO_VSOCK_OP_RW data packets MUST only be transmitted when the peer has
-sufficient free buffer space for the payload.
+For stream and seqpacket flows, VIRTIO_VSOCK_OP_RW data packets MUST only be
+transmitted when the peer has sufficient free buffer space for the payload.

All packets associated with a stream flow MUST contain valid information in
\field{buf_alloc} and \field{fwd_cnt} fields.
@@ -299,6 +308,78 @@ \subsubsection{Seqpacket Sockets}\label{sec:Device Types / 
Socket Device / Devic
#define VIRTIO_VSOCK_SEQ_EOR (1 << 1)
\end{lstlisting}

+\subsubsection{Datagram Sockets}\label{sec:Device Types / Socket Device / 
Device Operation / Datagram Sockets}
+
+\drivernormative{\paragraph}{Device Operation: Packet Fragmentation}{Device 
Types / Socket Device / Datagram Sockets / Fragmentation}
+
+Drivers MAY disassemble packets into smaller fragments. If drivers fragment a
+packet, they MUST follow the fragmentation rules described in section
+\ref{sec:Device Types / Socket Device / Device Operation / Datagram Sockets / 
Fragmentation}.
+
+Drivers MUST support assembly of received packet fragments according to the
+fragmentation rules 

[virtio-dev] Re: [PATCH] virtio-vsock: add VIRTIO_VSOCK_F_DGRAM feature bit

2023-08-29 Thread Bobby Eshleman
On Tue, Aug 29, 2023 at 06:21:35PM -0400, Michael S. Tsirkin wrote:
> On Tue, Aug 29, 2023 at 09:29:45PM +, Bobby Eshleman wrote:
> > This adds support for datagrams to the virtio-vsock device.
> > 
> > virtio-vsock already supports stream and seqpacket types. The existing
> > message types and header fields are extended to support datagrams.
> > Semantic differences between the flow types are stated, as well as any
> > additional requirements for devices and drivers implementing this
> > feature.
> > 
> > Signed-off-by: Bobby Eshleman 
> > ---
> >  device-types/vsock/description.tex | 95 +++---
> >  1 file changed, 88 insertions(+), 7 deletions(-)
> > 
> > diff --git a/device-types/vsock/description.tex 
> > b/device-types/vsock/description.tex
> > index 7d91d159872f..638dca8e5da1 100644
> > --- a/device-types/vsock/description.tex
> > +++ b/device-types/vsock/description.tex
> > @@ -20,6 +20,7 @@ \subsection{Feature bits}\label{sec:Device Types / Socket 
> > Device / Feature bits}
> >  \item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported.
> >  \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is supported.
> >  \item[VIRTIO_VSOCK_F_NO_IMPLIED_STREAM (2)] stream socket type is not 
> > implied.
> > +\item[VIRTIO_VSOCK_F_DGRAM (3)] datagram socket type is supported.
> >  \end{description}
> >  
> >  \drivernormative{\subsubsection}{Feature bits}{Device Types / Socket 
> > Device / Feature bits}
> > @@ -167,17 +168,22 @@ \subsubsection{Addressing}\label{sec:Device Types / 
> > Socket Device / Device Opera
> >  consists of a (cid, port number) tuple. The header fields used for this are
> >  \field{src_cid}, \field{src_port}, \field{dst_cid}, and \field{dst_port}.
> >  
> > -Currently stream and seqpacket sockets are supported. \field{type} is 1 
> > (VIRTIO_VSOCK_TYPE_STREAM)
> > -for stream socket types, and 2 (VIRTIO_VSOCK_TYPE_SEQPACKET) for seqpacket 
> > socket types.
> > +
> > +Currently stream, seqpacket, and datagram sockets are supported. 
> > \field{type} is
> > +1 (VIRTIO_VSOCK_TYPE_STREAM) for stream socket types, 2 
> > (VIRTIO_VSOCK_TYPE_SEQPACKET) for
> > +seqpacket socket types, and 3 (VIRTIO_VSOCK_TYPE_DGRAM) for datagram 
> > socket types.
> >  
> >  \begin{lstlisting}
> >  #define VIRTIO_VSOCK_TYPE_STREAM1
> >  #define VIRTIO_VSOCK_TYPE_SEQPACKET 2
> > +#define VIRTIO_VSOCK_TYPE_DGRAM 3
> >  \end{lstlisting}
> >  
> >  Stream sockets provide in-order, guaranteed, connection-oriented delivery
> >  without message boundaries. Seqpacket sockets provide in-order, guaranteed,
> > -connection-oriented delivery with message and record boundaries.
> > +connection-oriented delivery with message and record boundaries. Datagram
> > +sockets provide connection-less, best-effort delivery of messages, with no
> > +order or reliability guarantees.
> >  
> >  \subsubsection{Buffer Space Management}\label{sec:Device Types / Socket 
> > Device / Device Operation / Buffer Space Management}
> >  \field{buf_alloc} and \field{fwd_cnt} are used for buffer space management 
> > of
> > @@ -203,16 +209,19 @@ \subsubsection{Buffer Space 
> > Management}\label{sec:Device Types / Socket Device /
> >  previously receiving a VIRTIO_VSOCK_OP_CREDIT_REQUEST packet. This allows
> >  communicating updates any time a change in buffer space occurs.
> >  
> > +\field{buf_alloc} and \field{fwd_cnt} are reserved for future use by 
> > datagram
> > +sockets. These fields are not used for datagram buffer space management.
> 
> no limits on datagram size?
> 

In the Linux proof-of-concept, it is 64KB. I can add that here too.

> also with no flow control at all there's a performance problem:
> imagine queue gets full. now buffers begin to be dropped.
> problem is, dropping is faster than delivering to application.
> so now application sees its packets consumed super quickly
> and starts sending even faster.
> not good for performance.
> 
> yes datagram expects some way to drop packets but just disabling flow
> control completely is not the right thing to do I think.
> 

On the LKML I discussed using congestion notification as a way to handle
this situation, but deferred it to a future feature bit. I can build
it in from the beginning though.

> 
> > +
> >  \drivernormative{\paragraph}{Device Operation: Buffer Space 
> > Management}{Device Types / Socket Device / Device Operation / Buffer Space 
> > Management}
> > -VIRTIO_VSOCK_OP_RW data packets MUST only be transmitted when the peer has
> > -sufficient free buffer space for the payload.
> > +For stream and seqpacket flows, VIRTIO_VSOCK_OP_RW data packets MUST only 
> > be
> > +transmitted when the peer has sufficient free buffer space for the payload.
> >  
> >  All packets associated with a stream flow MUST contain valid information in
> >  \field{buf_alloc} and \field{fwd_cnt} fields.
> >  
> >  \devicenormative{\paragraph}{Device Operation: Buffer Space 
> > Management}{Device Types / Socket Device / Device Operation / 

[virtio-dev] Re: [PATCH] virtio-vsock: add VIRTIO_VSOCK_F_DGRAM feature bit

2023-08-29 Thread Michael S. Tsirkin
On Tue, Aug 29, 2023 at 09:29:45PM +, Bobby Eshleman wrote:
> This adds support for datagrams to the virtio-vsock device.
> 
> virtio-vsock already supports stream and seqpacket types. The existing
> message types and header fields are extended to support datagrams.
> Semantic differences between the flow types are stated, as well as any
> additional requirements for devices and drivers implementing this
> feature.
> 
> Signed-off-by: Bobby Eshleman 
> ---
>  device-types/vsock/description.tex | 95 +++---
>  1 file changed, 88 insertions(+), 7 deletions(-)
> 
> diff --git a/device-types/vsock/description.tex 
> b/device-types/vsock/description.tex
> index 7d91d159872f..638dca8e5da1 100644
> --- a/device-types/vsock/description.tex
> +++ b/device-types/vsock/description.tex
> @@ -20,6 +20,7 @@ \subsection{Feature bits}\label{sec:Device Types / Socket 
> Device / Feature bits}
>  \item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported.
>  \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is supported.
>  \item[VIRTIO_VSOCK_F_NO_IMPLIED_STREAM (2)] stream socket type is not 
> implied.
> +\item[VIRTIO_VSOCK_F_DGRAM (3)] datagram socket type is supported.
>  \end{description}
>  
>  \drivernormative{\subsubsection}{Feature bits}{Device Types / Socket Device 
> / Feature bits}
> @@ -167,17 +168,22 @@ \subsubsection{Addressing}\label{sec:Device Types / 
> Socket Device / Device Opera
>  consists of a (cid, port number) tuple. The header fields used for this are
>  \field{src_cid}, \field{src_port}, \field{dst_cid}, and \field{dst_port}.
>  
> -Currently stream and seqpacket sockets are supported. \field{type} is 1 
> (VIRTIO_VSOCK_TYPE_STREAM)
> -for stream socket types, and 2 (VIRTIO_VSOCK_TYPE_SEQPACKET) for seqpacket 
> socket types.
> +
> +Currently stream, seqpacket, and datagram sockets are supported. 
> \field{type} is
> +1 (VIRTIO_VSOCK_TYPE_STREAM) for stream socket types, 2 
> (VIRTIO_VSOCK_TYPE_SEQPACKET) for
> +seqpacket socket types, and 3 (VIRTIO_VSOCK_TYPE_DGRAM) for datagram socket 
> types.
>  
>  \begin{lstlisting}
>  #define VIRTIO_VSOCK_TYPE_STREAM1
>  #define VIRTIO_VSOCK_TYPE_SEQPACKET 2
> +#define VIRTIO_VSOCK_TYPE_DGRAM 3
>  \end{lstlisting}
>  
>  Stream sockets provide in-order, guaranteed, connection-oriented delivery
>  without message boundaries. Seqpacket sockets provide in-order, guaranteed,
> -connection-oriented delivery with message and record boundaries.
> +connection-oriented delivery with message and record boundaries. Datagram
> +sockets provide connection-less, best-effort delivery of messages, with no
> +order or reliability guarantees.
>  
>  \subsubsection{Buffer Space Management}\label{sec:Device Types / Socket 
> Device / Device Operation / Buffer Space Management}
>  \field{buf_alloc} and \field{fwd_cnt} are used for buffer space management of
> @@ -203,16 +209,19 @@ \subsubsection{Buffer Space 
> Management}\label{sec:Device Types / Socket Device /
>  previously receiving a VIRTIO_VSOCK_OP_CREDIT_REQUEST packet. This allows
>  communicating updates any time a change in buffer space occurs.
>  
> +\field{buf_alloc} and \field{fwd_cnt} are reserved for future use by datagram
> +sockets. These fields are not used for datagram buffer space management.

no limits on datagram size?

also with no flow control at all there's a performance problem:
imagine queue gets full. now buffers begin to be dropped.
problem is, dropping is faster than delivering to application.
so now application sees its packets consumed super quickly
and starts sending even faster.
not good for performance.

yes datagram expects some way to drop packets but just disabling flow
control completely is not the right thing to do I think.


> +
>  \drivernormative{\paragraph}{Device Operation: Buffer Space 
> Management}{Device Types / Socket Device / Device Operation / Buffer Space 
> Management}
> -VIRTIO_VSOCK_OP_RW data packets MUST only be transmitted when the peer has
> -sufficient free buffer space for the payload.
> +For stream and seqpacket flows, VIRTIO_VSOCK_OP_RW data packets MUST only be
> +transmitted when the peer has sufficient free buffer space for the payload.
>  
>  All packets associated with a stream flow MUST contain valid information in
>  \field{buf_alloc} and \field{fwd_cnt} fields.
>  
>  \devicenormative{\paragraph}{Device Operation: Buffer Space 
> Management}{Device Types / Socket Device / Device Operation / Buffer Space 
> Management}
> -VIRTIO_VSOCK_OP_RW data packets MUST only be transmitted when the peer has
> -sufficient free buffer space for the payload.
> +For stream and seqpacket flows, VIRTIO_VSOCK_OP_RW data packets MUST only be
> +transmitted when the peer has sufficient free buffer space for the payload.
>  
>  All packets associated with a stream flow MUST contain valid information in
>  \field{buf_alloc} and \field{fwd_cnt} fields.
> @@ -299,6 +308,78 @@ \subsubsection{Seqpacket Sockets}\label{sec:Device Types