[dpdk-dev] [PATCH v4 1/1] net/virtio-user: add support for server mode
Yang, Zhiyong
zhiyong.yang at intel.com
Wed Apr 4 16:57:28 CEST 2018
> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Yang, Zhiyong
> Sent: Wednesday, April 4, 2018 5:59 PM
> To: Bie, Tiwei <tiwei.bie at intel.com>
> Cc: Tan, Jianfeng <jianfeng.tan at intel.com>; dev at dpdk.org;
> maxime.coquelin at redhat.com; thomas at monjalon.net; Wang, Zhihong
> <zhihong.wang at intel.com>
> Subject: Re: [dpdk-dev] [PATCH v4 1/1] net/virtio-user: add support for
> server mode
>
>
>
> > -----Original Message-----
> > From: Bie, Tiwei
> > Sent: Wednesday, April 4, 2018 1:37 PM
> > To: Yang, Zhiyong <zhiyong.yang at intel.com>
> > Cc: Tan, Jianfeng <jianfeng.tan at intel.com>; dev at dpdk.org;
> > maxime.coquelin at redhat.com; thomas at monjalon.net; Wang, Zhihong
> > <zhihong.wang at intel.com>
> > Subject: Re: [PATCH v4 1/1] net/virtio-user: add support for server
> > mode
> >
> > On Tue, Apr 03, 2018 at 11:16:26PM +0800, Tan, Jianfeng wrote:
> > > On 4/3/2018 8:20 PM, zhiyong.yang at intel.com wrote:
> > [...]
> > > > @@ -267,21 +270,27 @@ virtio_user_dev_setup(struct virtio_user_dev
> > *dev)
> > > > dev->vhostfds = NULL;
> > > > dev->tapfds = NULL;
> > >
> > > Add a check here:
> > > if (dev->is_server && !is_vhost_user_by_type(dev->path))
> > > return error;
> > >
> > > > - if (is_vhost_user_by_type(dev->path)) {
> > > > - dev->ops = &ops_user;
> > > > + if (dev->is_server) {
> > > > + dev->ops = &ops_user;/* server mode only supports vhost
> > user*/
> > > > } else {
> > > > - dev->ops = &ops_kernel;
> > > > -
> > > > - dev->vhostfds = malloc(dev->max_queue_pairs *
> > sizeof(int));
> > > > - dev->tapfds = malloc(dev->max_queue_pairs * sizeof(int));
> > > > - if (!dev->vhostfds || !dev->tapfds) {
> > > > - PMD_INIT_LOG(ERR, "Failed to malloc");
> > > > - return -1;
> > > > - }
> > > > -
> > > > - for (q = 0; q < dev->max_queue_pairs; ++q) {
> > > > - dev->vhostfds[q] = -1;
> > > > - dev->tapfds[q] = -1;
> > > > + if (is_vhost_user_by_type(dev->path)) {
> > > > + dev->ops = &ops_user;
> > > > + } else {
> > > > + dev->ops = &ops_kernel;
> > > > +
> > > > + dev->vhostfds = malloc(dev->max_queue_pairs *
> > > > + sizeof(int));
> > > > + dev->tapfds = malloc(dev->max_queue_pairs *
> > > > + sizeof(int));
> > > > + if (!dev->vhostfds || !dev->tapfds) {
> > > > + PMD_INIT_LOG(ERR, "Failed to malloc");
> > > > + return -1;
> > > > + }
> > > > +
> > > > + for (q = 0; q < dev->max_queue_pairs; ++q) {
> > > > + dev->vhostfds[q] = -1;
> > > > + dev->tapfds[q] = -1;
> > > > + }
> > > > }
> > > > }
> >
> > Hi Zhiyong,
> >
> > I think we can keep using is_vhost_user_by_type() to determine the ops
> > for
> > dev->ops. And you just need to add a check in the vhost-kernel case.
> > Something like
> > this:
> >
> > --- i/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > +++ w/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > @@ -270,6 +270,9 @@ virtio_user_dev_setup(struct virtio_user_dev *dev)
> > if (is_vhost_user_by_type(dev->path)) {
> > dev->ops = &ops_user;
> > } else {
> > + if (dev->is_server)
> > + return -1;
> > +
> > dev->ops = &ops_kernel;
> >
> > dev->vhostfds = malloc(dev->max_queue_pairs *
> sizeof(int));
Tiwei, Jianfeng,
Think again, is_vhost_user_by_type() does not help judge user space or kernel driver for server mode.
As no socket file exists here for both.
Thanks
Zhiyong
More information about the dev
mailing list