[dpdk-dev,v2,4/4] virtio-user: handle ctrl-q in driver

Message ID 1465800223-139122-5-git-send-email-jianfeng.tan@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Yuanhan Liu
Headers

Commit Message

Jianfeng Tan June 13, 2016, 6:43 a.m. UTC
  In virtio-user driver, when notify ctrl-queue, invoke API of
virtio-user device emulation to handle ctrl-q command.

Besides, multi-queue requires ctrl-queue and ctrl-queue will be
enabled automatically when multi-queue is specified.

Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
 drivers/net/virtio/virtio_user_ethdev.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
  

Comments

Yuanhan Liu June 13, 2016, 10:14 a.m. UTC | #1
On Mon, Jun 13, 2016 at 06:43:43AM +0000, Jianfeng Tan wrote:
> In virtio-user driver, when notify ctrl-queue, invoke API of
> virtio-user device emulation to handle ctrl-q command.
> 
> Besides, multi-queue requires ctrl-queue and ctrl-queue will be
> enabled automatically when multi-queue is specified.
> 
> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
> ---
>  drivers/net/virtio/virtio_user_ethdev.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
> index 8f401a3..4c9279e 100644
> --- a/drivers/net/virtio/virtio_user_ethdev.c
> +++ b/drivers/net/virtio/virtio_user_ethdev.c
> @@ -42,6 +42,7 @@
>  #include "virtio_logs.h"
>  #include "virtio_pci.h"
>  #include "virtqueue.h"
> +#include "virtio_rxtx.h"

What's this include for?

	--yliu
  
Jianfeng Tan June 13, 2016, 10:20 a.m. UTC | #2
> -----Original Message-----
> From: Yuanhan Liu [mailto:yuanhan.liu@linux.intel.com]
> Sent: Monday, June 13, 2016 6:14 PM
> To: Tan, Jianfeng
> Cc: dev@dpdk.org; rich.lane@bigswitch.com; mst@redhat.com;
> nakajima.yoshihiro@lab.ntt.co.jp; p.fedin@samsung.com;
> ann.zhuangyanying@huawei.com; mukawa@igel.co.jp;
> nhorman@tuxdriver.com
> Subject: Re: [PATCH v2 4/4] virtio-user: handle ctrl-q in driver
> 
> On Mon, Jun 13, 2016 at 06:43:43AM +0000, Jianfeng Tan wrote:
> > In virtio-user driver, when notify ctrl-queue, invoke API of
> > virtio-user device emulation to handle ctrl-q command.
> >
> > Besides, multi-queue requires ctrl-queue and ctrl-queue will be
> > enabled automatically when multi-queue is specified.
> >
> > Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
> > ---
> >  drivers/net/virtio/virtio_user_ethdev.c | 13 +++++++++++++
> >  1 file changed, 13 insertions(+)
> >
> > diff --git a/drivers/net/virtio/virtio_user_ethdev.c
> b/drivers/net/virtio/virtio_user_ethdev.c
> > index 8f401a3..4c9279e 100644
> > --- a/drivers/net/virtio/virtio_user_ethdev.c
> > +++ b/drivers/net/virtio/virtio_user_ethdev.c
> > @@ -42,6 +42,7 @@
> >  #include "virtio_logs.h"
> >  #include "virtio_pci.h"
> >  #include "virtqueue.h"
> > +#include "virtio_rxtx.h"
> 
> What's this include for?

It's because hw->cvq->cq needs type of hw->cvq (struct virtnet_ctl).

> 
> 	--yliu
  

Patch

diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 8f401a3..4c9279e 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -42,6 +42,7 @@ 
 #include "virtio_logs.h"
 #include "virtio_pci.h"
 #include "virtqueue.h"
+#include "virtio_rxtx.h"
 #include "virtio_user/virtio_user_dev.h"
 
 #define virtio_user_get_dev(hw) \
@@ -200,6 +201,11 @@  virtio_user_notify_queue(struct virtio_hw *hw, struct virtqueue *vq)
 	uint64_t buf = 1;
 	struct virtio_user_dev *dev = virtio_user_get_dev(hw);
 
+	if (hw->cvq && (hw->cvq->vq == vq)) {
+		virtio_user_handle_cq(dev, vq->vq_queue_index);
+		return;
+	}
+
 	if (write(dev->kickfds[vq->vq_queue_index], &buf, sizeof(buf)) < 0)
 		PMD_DRV_LOG(ERR, "failed to kick backend: %s\n",
 			    strerror(errno));
@@ -360,6 +366,13 @@  virtio_user_pmd_devinit(const char *name, const char *params)
 	if (rte_kvargs_count(kvlist, VIRTIO_USER_ARG_CQ_NUM) == 1)
 		rte_kvargs_process(kvlist, VIRTIO_USER_ARG_CQ_NUM,
 				   &get_integer_arg, &cq);
+	else if (queues > 1)
+		cq = 1;
+
+	if (queues > 1 && cq == 0) {
+		PMD_INIT_LOG(ERR, "multi-q requires ctrl-q");
+		goto end;
+	}
 
 	eth_dev = virtio_user_eth_dev_alloc(name);
 	if (!eth_dev) {