DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: aconole@redhat.com, sodey@sonusnet.com,
	yuanhan.liu@linux.intel.com, jianfeng.tan@intel.com,
	dev@dpdk.org
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [dpdk-dev] [PATCH v2 2/7] vhost: vhost-user: Add MTU protocol feature support
Date: Mon,  6 Mar 2017 09:27:35 +0100	[thread overview]
Message-ID: <20170306082740.5675-3-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <20170306082740.5675-1-maxime.coquelin@redhat.com>

This patch implements the vhost-user MTU protocol feature support.
When VIRTIO_NET_F_MTU is negotiated, QEMU notifies the vhost-user
backend with the configured MTU if dedicated protocol feature is
supported.

The value can be used by the application to ensure consistency with
value set by the user.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 lib/librte_vhost/vhost.h      |  1 +
 lib/librte_vhost/vhost_user.c | 24 ++++++++++++++++++++++++
 lib/librte_vhost/vhost_user.h |  5 ++++-
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index 6a57bb3..549296f 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -170,6 +170,7 @@ struct virtio_net {
 	uint64_t		log_base;
 	uint64_t		log_addr;
 	struct ether_addr	mac;
+	uint16_t		mtu;
 
 	uint32_t		nr_guest_pages;
 	uint32_t		max_guest_pages;
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index cb2156a..69877a4 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -51,6 +51,9 @@
 #include "vhost.h"
 #include "vhost_user.h"
 
+#define VIRTIO_MIN_MTU 68
+#define VIRTIO_MAX_MTU 65535
+
 static const char *vhost_message_str[VHOST_USER_MAX] = {
 	[VHOST_USER_NONE] = "VHOST_USER_NONE",
 	[VHOST_USER_GET_FEATURES] = "VHOST_USER_GET_FEATURES",
@@ -72,6 +75,7 @@ static const char *vhost_message_str[VHOST_USER_MAX] = {
 	[VHOST_USER_GET_QUEUE_NUM]  = "VHOST_USER_GET_QUEUE_NUM",
 	[VHOST_USER_SET_VRING_ENABLE]  = "VHOST_USER_SET_VRING_ENABLE",
 	[VHOST_USER_SEND_RARP]  = "VHOST_USER_SEND_RARP",
+	[VHOST_USER_NET_SET_MTU]  = "VHOST_USER_NET_SET_MTU",
 };
 
 static uint64_t
@@ -865,6 +869,22 @@ vhost_user_send_rarp(struct virtio_net *dev, struct VhostUserMsg *msg)
 	return 0;
 }
 
+static int
+vhost_user_net_set_mtu(struct virtio_net *dev, struct VhostUserMsg *msg)
+{
+	if (msg->payload.u64 < VIRTIO_MIN_MTU ||
+			msg->payload.u64 > VIRTIO_MAX_MTU) {
+		RTE_LOG(ERR, VHOST_CONFIG, "Invalid MTU size (%lu)\n",
+				msg->payload.u64);
+
+		return -1;
+	}
+
+	dev->mtu = (uint16_t)msg->payload.u64;
+
+	return 0;
+}
+
 /* return bytes# of read on success or negative val on failure. */
 static int
 read_vhost_message(int sockfd, struct VhostUserMsg *msg)
@@ -1027,6 +1047,10 @@ vhost_user_msg_handler(int vid, int fd)
 		vhost_user_send_rarp(dev, &msg);
 		break;
 
+	case VHOST_USER_NET_SET_MTU:
+		ret = vhost_user_net_set_mtu(dev, &msg);
+		break;
+
 	default:
 		ret = -1;
 		break;
diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h
index 179e441..838dec8 100644
--- a/lib/librte_vhost/vhost_user.h
+++ b/lib/librte_vhost/vhost_user.h
@@ -47,11 +47,13 @@
 #define VHOST_USER_PROTOCOL_F_LOG_SHMFD	1
 #define VHOST_USER_PROTOCOL_F_RARP	2
 #define VHOST_USER_PROTOCOL_F_REPLY_ACK	3
+#define VHOST_USER_PROTOCOL_F_NET_MTU 4
 
 #define VHOST_USER_PROTOCOL_FEATURES	((1ULL << VHOST_USER_PROTOCOL_F_MQ) | \
 					 (1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD) |\
 					 (1ULL << VHOST_USER_PROTOCOL_F_RARP) | \
-					 (1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK))
+					 (1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK) | \
+					 (1ULL << VHOST_USER_PROTOCOL_F_NET_MTU))
 
 typedef enum VhostUserRequest {
 	VHOST_USER_NONE = 0,
@@ -74,6 +76,7 @@ typedef enum VhostUserRequest {
 	VHOST_USER_GET_QUEUE_NUM = 17,
 	VHOST_USER_SET_VRING_ENABLE = 18,
 	VHOST_USER_SEND_RARP = 19,
+	VHOST_USER_NET_SET_MTU = 20,
 	VHOST_USER_MAX
 } VhostUserRequest;
 
-- 
2.9.3

  parent reply	other threads:[~2017-03-06  8:27 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-13 14:28 [dpdk-dev] [PATCH 0/7] virtio/vhost: Add MTU " Maxime Coquelin
2017-02-13 14:28 ` [dpdk-dev] [PATCH 1/7] vhost: Enable VIRTIO_NET_F_MTU feature Maxime Coquelin
2017-02-13 14:28 ` [dpdk-dev] [PATCH 2/7] vhost: vhost-user: Add MTU protocol feature support Maxime Coquelin
2017-02-13 14:28 ` [dpdk-dev] [PATCH 3/7] vhost: Add new ready status flag Maxime Coquelin
2017-02-13 14:28 ` [dpdk-dev] [PATCH 4/7] vhost: Add API to get/set MTU value Maxime Coquelin
2017-02-13 14:28 ` [dpdk-dev] [PATCH 5/7] net/vhost: Implement mtu_set callback Maxime Coquelin
2017-02-13 14:28 ` [dpdk-dev] [PATCH 6/7] net/virtio: Add MTU feature support Maxime Coquelin
2017-02-16 19:31   ` Aaron Conole
2017-02-16 21:17     ` Maxime Coquelin
2017-02-13 14:28 ` [dpdk-dev] [PATCH 7/7] app/testpmd: print MTU value in show port info Maxime Coquelin
2017-02-23  7:10 ` [dpdk-dev] [PATCH 0/7] virtio/vhost: Add MTU feature support Yuanhan Liu
2017-03-01  7:44   ` Maxime Coquelin
2017-03-06  8:27 ` [dpdk-dev] [PATCH v2 " Maxime Coquelin
2017-03-06  8:27   ` [dpdk-dev] [PATCH v2 1/7] vhost: Enable VIRTIO_NET_F_MTU feature Maxime Coquelin
2017-03-06  8:27   ` Maxime Coquelin [this message]
2017-03-08  2:31     ` [dpdk-dev] [PATCH v2 2/7] vhost: vhost-user: Add MTU protocol feature support Yuanhan Liu
2017-03-12 10:24       ` Maxime Coquelin
2017-03-06  8:27   ` [dpdk-dev] [PATCH v2 3/7] vhost: Add new ready status flag Maxime Coquelin
2017-03-06  8:27   ` [dpdk-dev] [PATCH v2 4/7] vhost: Add API to get MTU value Maxime Coquelin
2017-03-08  2:45     ` Yuanhan Liu
2017-03-12 10:23       ` Maxime Coquelin
2017-03-06  8:27   ` [dpdk-dev] [PATCH v2 5/7] net/vhost: Fill rte_eth_dev's MTU property Maxime Coquelin
2017-03-06  8:27   ` [dpdk-dev] [PATCH v2 6/7] net/virtio: Add MTU feature support Maxime Coquelin
2017-03-06  8:27   ` [dpdk-dev] [PATCH v2 7/7] app/testpmd: print MTU value in show port info Maxime Coquelin
2017-03-07 21:57   ` [dpdk-dev] [PATCH v2 0/7] virtio/vhost: Add MTU feature support Thomas Monjalon
2017-03-12 10:00     ` Maxime Coquelin
2017-03-12 16:33 ` [dpdk-dev] [PATCH v3 0/9] " Maxime Coquelin
2017-03-12 16:33   ` [dpdk-dev] [PATCH v3 1/9] vhost: Enable VIRTIO_NET_F_MTU feature Maxime Coquelin
2017-03-12 16:33   ` [dpdk-dev] [PATCH v3 2/9] vhost: vhost-user: Add MTU protocol feature support Maxime Coquelin
2017-03-12 16:34   ` [dpdk-dev] [PATCH v3 3/9] vhost: Add new ready status flag Maxime Coquelin
2017-03-12 16:34   ` [dpdk-dev] [PATCH v3 4/9] vhost: Add API to get MTU value Maxime Coquelin
2017-03-16  8:00     ` Yuanhan Liu
2017-03-16 11:37       ` Maxime Coquelin
2017-03-17  5:32         ` Yuanhan Liu
2017-03-17  9:59           ` Maxime Coquelin
2017-03-20  8:42             ` Yuanhan Liu
2017-03-12 16:34   ` [dpdk-dev] [PATCH v3 5/9] vhost: export " Maxime Coquelin
2017-03-12 16:34   ` [dpdk-dev] [PATCH v3 6/9] net/vhost: Fill rte_eth_dev's MTU property Maxime Coquelin
2017-03-12 16:34   ` [dpdk-dev] [PATCH v3 7/9] net/virtio: Add MTU feature support Maxime Coquelin
2017-04-05  4:52     ` Tan, Jianfeng
2017-04-05  7:11       ` Maxime Coquelin
2017-04-05  9:42         ` Tan, Jianfeng
2017-04-05 13:54           ` Maxime Coquelin
2017-04-05 14:50             ` Tan, Jianfeng
2017-04-07 16:40               ` Maxime Coquelin
2017-04-10  6:48                 ` Tan, Jianfeng
2017-03-12 16:34   ` [dpdk-dev] [PATCH v3 8/9] doc: announce Virtio and Vhost MTU support Maxime Coquelin
2017-03-12 16:34   ` [dpdk-dev] [PATCH v3 9/9] app/testpmd: print MTU value in show port info Maxime Coquelin
2017-03-22  8:58   ` [dpdk-dev] [PATCH v3 0/9] virtio/vhost: Add MTU feature support Yuanhan Liu
2017-03-22  9:03     ` Maxime Coquelin
2017-03-28  5:39   ` Yao, Lei A
2017-03-30 11:34     ` Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170306082740.5675-3-maxime.coquelin@redhat.com \
    --to=maxime.coquelin@redhat.com \
    --cc=aconole@redhat.com \
    --cc=dev@dpdk.org \
    --cc=jianfeng.tan@intel.com \
    --cc=sodey@sonusnet.com \
    --cc=yuanhan.liu@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).