Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/21427/?format=api
https://patches.dpdk.org/api/patches/21427/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/20170306082740.5675-7-maxime.coquelin@redhat.com/", "project": { "id": 1, "url": "https://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20170306082740.5675-7-maxime.coquelin@redhat.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20170306082740.5675-7-maxime.coquelin@redhat.com", "date": "2017-03-06T08:27:39", "name": "[dpdk-dev,v2,6/7] net/virtio: Add MTU feature support", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "c6b4ab1e2c39f83e183de4c91e27f6c4914f4059", "submitter": { "id": 512, "url": "https://patches.dpdk.org/api/people/512/?format=api", "name": "Maxime Coquelin", "email": "maxime.coquelin@redhat.com" }, "delegate": { "id": 355, "url": "https://patches.dpdk.org/api/users/355/?format=api", "username": "yliu", "first_name": "Yuanhan", "last_name": "Liu", "email": "yuanhan.liu@linux.intel.com" }, "mbox": "https://patches.dpdk.org/project/dpdk/patch/20170306082740.5675-7-maxime.coquelin@redhat.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/21427/comments/", "check": "success", "checks": "https://patches.dpdk.org/api/patches/21427/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id EB01EF618;\n\tMon, 6 Mar 2017 09:28:43 +0100 (CET)", "from mx1.redhat.com (mx1.redhat.com [209.132.183.28])\n\tby dpdk.org (Postfix) with ESMTP id 7B570567F\n\tfor <dev@dpdk.org>; Mon, 6 Mar 2017 09:28:11 +0100 (CET)", "from int-mx13.intmail.prod.int.phx2.redhat.com\n\t(int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id E251DC00AFDF;\n\tMon, 6 Mar 2017 08:28:11 +0000 (UTC)", "from max-t460s.redhat.com (ovpn-116-235.ams2.redhat.com\n\t[10.36.116.235])\n\tby int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with\n\tESMTP id v268RmvG006934; Mon, 6 Mar 2017 03:28:09 -0500" ], "From": "Maxime Coquelin <maxime.coquelin@redhat.com>", "To": "aconole@redhat.com, sodey@sonusnet.com, yuanhan.liu@linux.intel.com,\n\tjianfeng.tan@intel.com, dev@dpdk.org", "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>", "Date": "Mon, 6 Mar 2017 09:27:39 +0100", "Message-Id": "<20170306082740.5675-7-maxime.coquelin@redhat.com>", "In-Reply-To": "<20170306082740.5675-1-maxime.coquelin@redhat.com>", "References": "<20170213142820.8964-1-maxime.coquelin@redhat.com>\n\t<20170306082740.5675-1-maxime.coquelin@redhat.com>", "X-Scanned-By": "MIMEDefang 2.68 on 10.5.11.26", "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.31]); Mon, 06 Mar 2017 08:28:11 +0000 (UTC)", "Subject": "[dpdk-dev] [PATCH v2 6/7] net/virtio: Add MTU feature support", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "This patch implements support for the Virtio MTU feature.\nWhen negotiated, the host shares its maximum supported MTU,\nwhich is used as initial MTU and as maximum MTU the application\ncan set.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n doc/guides/nics/features/virtio.ini | 1 +\n drivers/net/virtio/virtio_ethdev.c | 45 +++++++++++++++++++++++++++++++++++--\n drivers/net/virtio/virtio_ethdev.h | 3 ++-\n drivers/net/virtio/virtio_pci.h | 3 +++\n 4 files changed, 49 insertions(+), 3 deletions(-)", "diff": "diff --git a/doc/guides/nics/features/virtio.ini b/doc/guides/nics/features/virtio.ini\nindex 84d2012..8e3aca1 100644\n--- a/doc/guides/nics/features/virtio.ini\n+++ b/doc/guides/nics/features/virtio.ini\n@@ -25,3 +25,4 @@ ARMv8 = Y\n x86-32 = Y\n x86-64 = Y\n Usage doc = Y\n+MTU update = Y\ndiff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c\nindex 4dc03b9..fd1213c 100644\n--- a/drivers/net/virtio/virtio_ethdev.c\n+++ b/drivers/net/virtio/virtio_ethdev.c\n@@ -721,10 +721,13 @@ virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)\n \tuint32_t ether_hdr_len = ETHER_HDR_LEN + VLAN_TAG_LEN +\n \t\t\t\t hw->vtnet_hdr_size;\n \tuint32_t frame_size = mtu + ether_hdr_len;\n+\tuint32_t max_frame_size = hw->max_mtu + ether_hdr_len;\n \n-\tif (mtu < ETHER_MIN_MTU || frame_size > VIRTIO_MAX_RX_PKTLEN) {\n+\tmax_frame_size = RTE_MIN(max_frame_size, VIRTIO_MAX_RX_PKTLEN);\n+\n+\tif (mtu < ETHER_MIN_MTU || frame_size > max_frame_size) {\n \t\tPMD_INIT_LOG(ERR, \"MTU should be between %d and %d\",\n-\t\t\tETHER_MIN_MTU, VIRTIO_MAX_RX_PKTLEN - ether_hdr_len);\n+\t\t\tETHER_MIN_MTU, max_frame_size - ether_hdr_len);\n \t\treturn -EINVAL;\n \t}\n \treturn 0;\n@@ -1158,6 +1161,18 @@ virtio_negotiate_features(struct virtio_hw *hw, uint64_t req_features)\n \tPMD_INIT_LOG(DEBUG, \"host_features before negotiate = %\" PRIx64,\n \t\thost_features);\n \n+\t/* If supported, ensure MTU value is valid before acknowledging it. */\n+\tif (host_features & req_features & (1ULL << VIRTIO_NET_F_MTU)) {\n+\t\tstruct virtio_net_config config;\n+\n+\t\tvtpci_read_dev_config(hw,\n+\t\t\toffsetof(struct virtio_net_config, mtu),\n+\t\t\t&config.mtu, sizeof(config.mtu));\n+\n+\t\tif (config.mtu < ETHER_MIN_MTU)\n+\t\t\treq_features &= ~(1ULL << VIRTIO_NET_F_MTU);\n+\t}\n+\n \t/*\n \t * Negotiate features: Subset of device feature bits are written back\n \t * guest feature bits.\n@@ -1392,6 +1407,32 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)\n \n \t\thw->max_queue_pairs = config->max_virtqueue_pairs;\n \n+\t\tif (vtpci_with_feature(hw, VIRTIO_NET_F_MTU)) {\n+\t\t\tvtpci_read_dev_config(hw,\n+\t\t\t\toffsetof(struct virtio_net_config, mtu),\n+\t\t\t\t&config->mtu,\n+\t\t\t\tsizeof(config->mtu));\n+\n+\t\t\t/*\n+\t\t\t * MTU value has already been checked at negotiation\n+\t\t\t * time, but check again in case it has changed since\n+\t\t\t * then, which should not happen.\n+\t\t\t */\n+\t\t\tif (config->mtu < ETHER_MIN_MTU) {\n+\t\t\t\tPMD_INIT_LOG(ERR, \"invalid max MTU value (%u)\",\n+\t\t\t\t\t\tconfig->mtu);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\n+\t\t\thw->max_mtu = config->mtu;\n+\t\t\t/* Set initial MTU to maximum one supported by vhost */\n+\t\t\teth_dev->data->mtu = config->mtu;\n+\n+\t\t} else {\n+\t\t\thw->max_mtu = VIRTIO_MAX_RX_PKTLEN - ETHER_HDR_LEN -\n+\t\t\t\tVLAN_TAG_LEN - hw->vtnet_hdr_size;\n+\t\t}\n+\n \t\tPMD_INIT_LOG(DEBUG, \"config->max_virtqueue_pairs=%d\",\n \t\t\t\tconfig->max_virtqueue_pairs);\n \t\tPMD_INIT_LOG(DEBUG, \"config->status=%d\", config->status);\ndiff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h\nindex 777a14b..aa78adc 100644\n--- a/drivers/net/virtio/virtio_ethdev.h\n+++ b/drivers/net/virtio/virtio_ethdev.h\n@@ -51,7 +51,7 @@\n #define VIRTIO_MAX_TX_QUEUES 128U\n #define VIRTIO_MAX_MAC_ADDRS 64\n #define VIRTIO_MIN_RX_BUFSIZE 64\n-#define VIRTIO_MAX_RX_PKTLEN 9728\n+#define VIRTIO_MAX_RX_PKTLEN 9728U\n \n /* Features desired/implemented by this driver. */\n #define VIRTIO_PMD_DEFAULT_GUEST_FEATURES\t\\\n@@ -66,6 +66,7 @@\n \t 1u << VIRTIO_NET_F_HOST_TSO4\t |\t\\\n \t 1u << VIRTIO_NET_F_HOST_TSO6\t |\t\\\n \t 1u << VIRTIO_NET_F_MRG_RXBUF\t |\t\\\n+\t 1u << VIRTIO_NET_F_MTU\t| \\\n \t 1u << VIRTIO_RING_F_INDIRECT_DESC | \\\n \t 1ULL << VIRTIO_F_VERSION_1 |\t\\\n \t 1ULL << VIRTIO_F_IOMMU_PLATFORM)\ndiff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h\nindex 59e45c4..771f5b1 100644\n--- a/drivers/net/virtio/virtio_pci.h\n+++ b/drivers/net/virtio/virtio_pci.h\n@@ -106,6 +106,7 @@ struct virtnet_ctl;\n /* The feature bitmap for virtio net */\n #define VIRTIO_NET_F_CSUM\t0\t/* Host handles pkts w/ partial csum */\n #define VIRTIO_NET_F_GUEST_CSUM\t1\t/* Guest handles pkts w/ partial csum */\n+#define VIRTIO_NET_F_MTU\t3\t/* Initial MTU advice. */\n #define VIRTIO_NET_F_MAC\t5\t/* Host has given MAC address. */\n #define VIRTIO_NET_F_GUEST_TSO4\t7\t/* Guest can handle TSOv4 in. */\n #define VIRTIO_NET_F_GUEST_TSO6\t8\t/* Guest can handle TSOv6 in. */\n@@ -251,6 +252,7 @@ struct virtio_hw {\n \tuint64_t req_guest_features;\n \tuint64_t guest_features;\n \tuint32_t max_queue_pairs;\n+\tuint16_t\tmax_mtu;\n \tuint16_t vtnet_hdr_size;\n \tuint8_t\t vlan_strip;\n \tuint8_t\t use_msix;\n@@ -296,6 +298,7 @@ struct virtio_net_config {\n \t/* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */\n \tuint16_t status;\n \tuint16_t max_virtqueue_pairs;\n+\tuint16_t mtu;\n } __attribute__((packed));\n \n /*\n", "prefixes": [ "dpdk-dev", "v2", "6/7" ] }{ "id": 21427, "url": "