On 2018/11/15 17:36, Yan Vugenfirer wrote: > > >> On 15 Nov 2018, at 05:56, jiangyiwen <jiangyiwen@xxxxxxxxxx> wrote: >> >> Hi Stefan, Michael, Jason and everyone, >> >> Several days ago, I discussed with jason about "Vsock over Virtio-net". >> This idea has two advantages: >> First, it can use many great features of virtio-net, like batching, >> mergeable rx buffer and multiqueue, etc. >> Second, it can reduce many duplicate codes and make it easy to be >> maintained. > > I would like to add that from Windows guest support perspective it makes more sense. > To support vsock we most probably need NDIS protocol driver and if it will be binded to NDIS miniport driver (the driver that currently handles virtio-net in Windows) it will make our life much easier. Otherwise we need to “plug” into NIDS on one hand, and handle transport outside of NDIS on other hand or in some strange way by creating mini port driver that is not really NIC miniport driver. > > Best regards, > Yan. Sorry, I am not familiar with windows vsock driver, if vsock is integrated in virtio-net, it can make windows vsock more easier, then it should be a more suitable solution. Thanks. >> >> Before the implement, I want to discuss with everyone again, and >> want to know everyone's suggestions. >> >> After the discussion, based on this point I will try to implement >> this idea, but I am not familiar with the virtio-net, that is a >> pity. :( >> >> -------------------------Simple idea------------------------------ >> >> 1. The packet layout will become as follows: >> >> +---------------------------------+ >> | Virtio-net header | >> |(struct virtio_net_hdr_mrg_rxbuf)| >> +---------------------------------+ >> | Vsock header | >> | (struct virtio_vsock_hdr) | >> +---------------------------------+ >> | payload | >> | (until end of packet) | >> +---------------------------------+ >> >> 2. The Guest->Host basic code flow as follow: >> +------------+ >> | Client | >> +------------+ >> | >> | >> +------------------------------------------------------------------+ >> |VSOCK Core Module | >> |ops->sendmsg; (vsock_stream_sendmsg) | >> | -> alloc_skb; /* it will packet a skb buffer, and include vsock | >> | * hdr and payload */ | >> | -> dev_queue_xmit(); /* it will call start_xmit(virtio-net.c) */| >> |vsock hdr and payload, and then call | >> +------------------------------------------------------------------+ >> | >> | >> +------------------------------------------------------------------+ >> |Virtio-net Module | >> |start_xmit | >> | -> add virtio_net_hdr and pack sg in ring desc, notify Host | >> +------------------------------------------------------------------+ >> | >> | >> +------------------------------------------------------------------+ >> |Vhost-net Module | >> |handle_tx | >> | -> get tx buffer, skip virtio_net_hdr and call Vsock function. | >> | /* This point has some differences, vhost-net use ->sendmsg to | >> | * forward information, however vsock only need to notify server | >> | * that data ready. */ | >> +------------------------------------------------------------------+ >> | >> | >> +------------------------------------------------------------------+ >> |VSOCK Core Module | >> |alloc_pkt, copy skb data to pkt. | >> |add pkt to rx_queue and notify server to get data. | >> +------------------------------------------------------------------+ >> >> 3. To Host->Guest >> I have a problem and difficult, mainly I know about virtio-net a little), >> because I have been doing work related with storage and file system. >> >> The problem as follows: >> we should monitor all of socket of vsock in handle_rx, when there are >> data coming, and copy data to vq desc. Vhost-net use ->recvmsg to >> get data, it is different with socket. To vsock, I think host will >> not call ->recvmsg when it need to send message to guest. To net, >> vhost-net only as forwarding layer. >> > > > . >