DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] vhost: fix build error on old kernel doesn't support MQ
@ 2015-10-29  3:37 Yuanhan Liu
  2015-10-30 14:40 ` David Marchand
  0 siblings, 1 reply; 3+ messages in thread
From: Yuanhan Liu @ 2015-10-29  3:37 UTC (permalink / raw)
  To: dev

Fix build error:

  virtio-net.c:80:89: error: ‘VIRTIO_NET_F_MQ’ undeclared here
  rte_virtio_net.h:109: error: ‘VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX’ undeclared here

Above two virtio-net MQ macros are introduced since kernel v3.8.
For older kernel, we should not reference them directly, hence,
this patch introduced two wrapper macros, with proper values
being set depending on we support MQ or not.

Fixes: 19d4d7ef2a21 ("vhost-user: enable multiple queue")

Reported-by: Gu YongjieX <yongjiex.gu@intel.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
 lib/librte_vhost/rte_virtio_net.h            | 17 ++++++++++++++++-
 lib/librte_vhost/vhost_user/vhost-net-user.c |  2 +-
 lib/librte_vhost/virtio-net.c                |  2 +-
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h
index 426a70d..b6386f9 100644
--- a/lib/librte_vhost/rte_virtio_net.h
+++ b/lib/librte_vhost/rte_virtio_net.h
@@ -93,6 +93,21 @@ struct vhost_virtqueue {
 	struct buf_vector	buf_vec[BUF_VECTOR_MAX];	/**< for scatter RX. */
 } __rte_cache_aligned;
 
+
+/*
+ * Make an extra wrapper for VIRTIO_NET_F_MQ and
+ * VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX as they are
+ * introduced since kernel v3.8. This makes our
+ * code buildable for older kernel.
+ */
+#ifdef VIRTIO_NET_F_MQ
+ #define VHOST_MAX_QUEUE_PAIRS	VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX
+ #define VHOST_SUPPORTS_MQ	(1ULL << VIRTIO_NET_F_MQ)
+#else
+ #define VHOST_MAX_QUEUE_PAIRS	1
+ #define VHOST_SUPPORTS_MQ	0
+#endif
+
 /**
  * Device structure contains all configuration information relating to the device.
  */
@@ -106,7 +121,7 @@ struct virtio_net {
 	char			ifname[IF_NAME_SZ];	/**< Name of the tap device or socket path. */
 	uint32_t		virt_qp_nb;	/**< number of queue pair we have allocated */
 	void			*priv;		/**< private context */
-	struct vhost_virtqueue	*virtqueue[VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX];	/**< Contains all virtqueue information. */
+	struct vhost_virtqueue	*virtqueue[VHOST_MAX_QUEUE_PAIRS * 2];	/**< Contains all virtqueue information. */
 } __rte_cache_aligned;
 
 /**
diff --git a/lib/librte_vhost/vhost_user/vhost-net-user.c b/lib/librte_vhost/vhost_user/vhost-net-user.c
index f681676..2dc0547 100644
--- a/lib/librte_vhost/vhost_user/vhost-net-user.c
+++ b/lib/librte_vhost/vhost_user/vhost-net-user.c
@@ -424,7 +424,7 @@ vserver_message_handler(int connfd, void *dat, int *remove)
 		break;
 
 	case VHOST_USER_GET_QUEUE_NUM:
-		msg.payload.u64 = VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX;
+		msg.payload.u64 = VHOST_MAX_QUEUE_PAIRS;
 		msg.size = sizeof(msg.payload.u64);
 		send_vhost_message(connfd, &msg);
 		break;
diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
index 97213c5..3e82605 100644
--- a/lib/librte_vhost/virtio-net.c
+++ b/lib/librte_vhost/virtio-net.c
@@ -74,7 +74,7 @@ static struct virtio_net_config_ll *ll_root;
 #define VHOST_SUPPORTED_FEATURES ((1ULL << VIRTIO_NET_F_MRG_RXBUF) | \
 				(1ULL << VIRTIO_NET_F_CTRL_VQ) | \
 				(1ULL << VIRTIO_NET_F_CTRL_RX) | \
-				(1ULL << VIRTIO_NET_F_MQ)      | \
+				(VHOST_SUPPORTS_MQ)            | \
 				(1ULL << VHOST_F_LOG_ALL)      | \
 				(1ULL << VHOST_USER_F_PROTOCOL_FEATURES))
 static uint64_t VHOST_FEATURES = VHOST_SUPPORTED_FEATURES;
-- 
1.9.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] vhost: fix build error on old kernel doesn't support MQ
  2015-10-29  3:37 [dpdk-dev] [PATCH] vhost: fix build error on old kernel doesn't support MQ Yuanhan Liu
@ 2015-10-30 14:40 ` David Marchand
  2015-10-30 14:58   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: David Marchand @ 2015-10-30 14:40 UTC (permalink / raw)
  To: Yuanhan Liu; +Cc: dev

On Thu, Oct 29, 2015 at 4:37 AM, Yuanhan Liu <yuanhan.liu@linux.intel.com>
wrote:

> Fix build error:
>
>   virtio-net.c:80:89: error: ‘VIRTIO_NET_F_MQ’ undeclared here
>   rte_virtio_net.h:109: error: ‘VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX’
> undeclared here
>
> Above two virtio-net MQ macros are introduced since kernel v3.8.
> For older kernel, we should not reference them directly, hence,
> this patch introduced two wrapper macros, with proper values
> being set depending on we support MQ or not.
>
> Fixes: 19d4d7ef2a21 ("vhost-user: enable multiple queue")
>

Not sure about this fix line as a build error first appeared for me at
b09b198bfb5c ("vhost-user: announce queue number in message")


> Reported-by: Gu YongjieX <yongjiex.gu@intel.com>
> Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
>

Build restored on kernel 3.2 with this fixed applied.
Tested-by: David Marchand <david.marchand@6wind.com>

-- 
David Marchand

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] vhost: fix build error on old kernel doesn't support MQ
  2015-10-30 14:40 ` David Marchand
@ 2015-10-30 14:58   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2015-10-30 14:58 UTC (permalink / raw)
  To: Yuanhan Liu; +Cc: dev

2015-10-30 15:40, David Marchand:
> On Thu, Oct 29, 2015 at 4:37 AM, Yuanhan Liu <yuanhan.liu@linux.intel.com>
> wrote:
> 
> > Fix build error:
> >
> >   virtio-net.c:80:89: error: ‘VIRTIO_NET_F_MQ’ undeclared here
> >   rte_virtio_net.h:109: error: ‘VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX’
> > undeclared here
> >
> > Above two virtio-net MQ macros are introduced since kernel v3.8.
> > For older kernel, we should not reference them directly, hence,
> > this patch introduced two wrapper macros, with proper values
> > being set depending on we support MQ or not.
> >
> > Fixes: 19d4d7ef2a21 ("vhost-user: enable multiple queue")
> 
> Not sure about this fix line as a build error first appeared for me at
> b09b198bfb5c ("vhost-user: announce queue number in message")

Fixed

> > Reported-by: Gu YongjieX <yongjiex.gu@intel.com>
> > Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> >
> 
> Build restored on kernel 3.2 with this fixed applied.
> Tested-by: David Marchand <david.marchand@6wind.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-30 14:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-29  3:37 [dpdk-dev] [PATCH] vhost: fix build error on old kernel doesn't support MQ Yuanhan Liu
2015-10-30 14:40 ` David Marchand
2015-10-30 14:58   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).