From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0057.outbound.protection.outlook.com [104.47.42.57]) by dpdk.org (Postfix) with ESMTP id 5CCC556A8 for ; Thu, 22 Sep 2016 15:57:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=SonusNetworks.onmicrosoft.com; s=selector1-sonusnet-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ySGAscm2FyWMaYTedQcZmHjP1d9LRu4eskYEHNnmy3U=; b=vi2GKyGkv8zuPCISyz5DvfOCOGvvlpGRjy5VqqvnBNPP0BIu8OKwkF0WFU1hvCRENXaEAMlNK5HYBJmWMFyy5yJ/Ez0WkbfpCjv2ZrDdcmhsFLGxBYPDtGofikVjUncxUGqzBWvl2jjq+CMX+6eRi0b35pHpOx6mc5ZtdycUFzA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=sodey@sonusnet.com; Received: from SODEY-LMA.sonusnet.com (208.45.178.4) by BLUPR03MB1490.namprd03.prod.outlook.com (10.163.81.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5; Thu, 22 Sep 2016 13:57:03 +0000 From: Dey To: , , , CC: Dey Date: Thu, 22 Sep 2016 09:56:43 -0400 Message-ID: <20160922135643.37636-1-sodey@sonusnet.com> X-Mailer: git-send-email 2.9.3.windows.1 In-Reply-To: <20160916171357.69640-1-sodey@sonusnet.com> References: <20160916171357.69640-1-sodey@sonusnet.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [208.45.178.4] X-ClientProxiedBy: BN6PR14CA0002.namprd14.prod.outlook.com (10.173.157.140) To BLUPR03MB1490.namprd03.prod.outlook.com (10.163.81.20) X-MS-Office365-Filtering-Correlation-Id: 31732295-8573-416b-6823-08d3e2f054ff X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB1490;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Dxz1awOLAksghHKDEsLVrSBOdpH4ZDTWZee+j2motMj5ZOyeE7MSHgudUR7gwozXqOUyEb8bJn/JGimnevetbaJ2DP5DupPizgeIc2KJ3QpyoVWxAflA8zhjy5UN/s34oGb5aMCzu+T1UTQAX1whbFzwqNejU4drqL+K9p+53foUrb7Fu4GfdHMWvQ02194S3LVox0WMGZzeqtaFYYoPHPBE5bLXIzSVJx X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(158342451672863); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001); SRVR:BLUPR03MB1490; BCL:0; PCL:0; RULEID:; SRVR:BLUPR03MB1490; X-Forefront-PRVS: 0073BFEF03 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(199003)(189002)(43544003)(5001770100001)(105586002)(77096005)(189998001)(42186005)(50226002)(107886002)(106356001)(50466002)(586003)(2950100001)(3846002)(6116002)(1076002)(97736004)(92566002)(305945005)(66066001)(8676002)(101416001)(81156014)(81166006)(5003940100001)(69596002)(4001430100002)(86362001)(229853001)(7846002)(68736007)(7736002)(19580405001)(4326007)(33646002)(19580395003)(5660300001)(47776003)(2906002)(2201001)(50986999)(48376002)(53416004)(36756003)(76176999); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB1490; H:SODEY-LMA.sonusnet.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: sonusnet.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR03MB1490; 23:VojZuBIiBFU0PvOPlDQwV/cckRZPTc+NxBF5Y7UfA?= =?us-ascii?Q?wZwqN+59Rq7u8+iE+AIyQt2F3ShCCHe1ddsQjqmegk2U/Yy6wBi/rPj/O7tj?= =?us-ascii?Q?rTxq/nLXaoNkQTvyIoGEL1w49Qr8RF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oHjRAoQpM8jnXVaADci9yZCMp1MJ4i92ehLnRinGjEu1hhp0GeTk2lTBcv7W3KLj+pwa7hpqhe2bcGYbpREEEnVBPJYLLPGk7rCM8iPbpW6d469jlXRBmX+ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sonusnet.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2016 13:57:03.3703 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB1490 Subject: [dpdk-dev] [PATCH v6] net/virtio: add set_mtu in virtio X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Sep 2016 13:57:07 -0000 Virtio interfaces do not currently allow the user to specify a particular Maximum Transmission Unit (MTU).Consequently, the MTU of Virtio interfaces is typically set to the Ethernet default value of 1500. This is problematic in the case of cloud deployments, in which a specific (and potentially non-standard) MTU needs to be set by a DHCP server, which needs to be honored by all interfaces across the traffic path.To acheive this Virtio interfaces should support setting of MTU. In case when GRE/VXLAN tunneling is used for internal communication, there will be an overhead added by the infrastructure in the packet over and above the ETHER MTU of 1518. So to take care of this overhead in these cases the DHCP server corrects the L3 MTU to 1454. But since virtio interfaces was not having the MTU set functionality that MTU sent by the DHCP server was ignored and the instance will still send packets with 1500 MTU which after encapsulation will become more than 1518 and eventually gets dropped in the infrastructure. By adding an additional 'set_mtu' function to the Virtio driver, we can honor the MTU sent by the DHCP server. The dhcp server/controller can then leverage this 'set_mtu' functionality to resolve the above mentioned issue of packets getting dropped due to incorrect size. Signed-off-by: Souvik Dey --- Changes in v6: - Description of change corrected - Corrected the identations - Corrected the subject line too - The From line was also not correct - Re-submitting as the below patch was not proper Changes in v5: - Fix log message for out-of-bounds MTU parameter in virtio_mtu_set - Calculate frame size, based on 'mtu' parameter - Corrected the upper bound and lower bound checks in virtio_mtu_set Changes in v4: Incorporated review comments. Changes in v3: Corrected few style errors as reported by sys-stv. Changes in v2: Incorporated review comments. drivers/net/virtio/virtio_ethdev.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 423c597..1dbfea6 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -653,12 +653,20 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev) PMD_INIT_LOG(ERR, "Failed to disable allmulticast"); } +#define VLAN_TAG_SIZE 4 /* 802.3ac tag (not DMA'd) */ + +static int virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) +{ + struct rte_eth_dev_info dev_info; + uint32_t ether_hdr_len = ETHER_HDR_LEN + ETHER_CRC_LEN + VLAN_TAG_SIZE; + uint32_t frame_size = mtu + ether_hdr_len; + + virtio_dev_info_get(dev, &dev_info); + + if (mtu < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) { + PMD_INIT_LOG(ERR, "MTU should be between %d and %d\n", + ETHER_MIN_MTU, + (dev_info.max_rx_pktlen - ether_hdr_len)); + return -EINVAL; + } + return 0; +} /* * dev_ops for virtio, bare necessities for basic operation */ @@ -677,7 +685,6 @@ static const struct eth_dev_ops virtio_eth_dev_ops = { .allmulticast_enable = virtio_dev_allmulticast_enable, .allmulticast_disable = virtio_dev_allmulticast_disable, + .mtu_set = virtio_mtu_set, .dev_infos_get = virtio_dev_info_get, .stats_get = virtio_dev_stats_get, .xstats_get = virtio_dev_xstats_get, -- 2.9.3.windows.1