From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0085.outbound.protection.outlook.com [104.47.42.85]) by dpdk.org (Postfix) with ESMTP id E36538DA0 for ; Fri, 16 Sep 2016 19:14:13 +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=HY+vDCxbzb9P9gOPxnThbAhCAMffRhAKTPU6lket7ZQ=; b=HSzzGyK+cYvIfHL8fpLjJz1D9cP8EJQTxOb1E5UG1Yb5Uo9UXWzbJ5Cp614prrnsmCskOF26yD7FRJ2RzHVGjBHScR39nYW3HWmyTMHXqOM5As50h4twQa2V78w9CGzZxvwCptyPXN7tj/Vu0K6jQ38FnT7cg/RTyNwjyr5yVHI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=sodey@sonusnet.com; Received: from SODEY-LMA.sonusnet.com (208.45.178.4) by BLUPR03MB1491.namprd03.prod.outlook.com (10.163.81.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.619.10; Fri, 16 Sep 2016 17:14:10 +0000 From: souvikdey33 To: , , , CC: souvikdey33 Date: Fri, 16 Sep 2016 13:13:57 -0400 Message-ID: <20160916171357.69640-1-sodey@sonusnet.com> X-Mailer: git-send-email 2.9.3.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [208.45.178.4] X-ClientProxiedBy: BN6PR14CA0016.namprd14.prod.outlook.com (10.173.157.154) To BLUPR03MB1491.namprd03.prod.outlook.com (10.163.81.21) X-MS-Office365-Filtering-Correlation-Id: 518199ef-2a75-4f56-dea0-08d3de54e016 X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB1491; 2:P8FM0zAVzm3e2DwRo8jtmQR8YFK+H3E3thTZeC/ndkqn9ByYj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UT5R8StMA/G6pNjMTNcWTi6WFmAfXvYaPxBJLQlh7R3mZTEbjWxASN8QSdiTfDeqml8PFQQuxj3+douaFuy8EC/U4y/l+RYmmKysw63KLruMOg6l/UkmvwCyV9Q0ZUIMOrcvER8D1uXxToycSGP43V2fazQ43J6rIyTSeXPGZqULKx6PbxxjwaFoc7lvyX21UuT1p0l3xt//XoGapyLDLXkP6w627uLH6de+tbooRQ/tEtR45EsTC3Kr3Dad2c2p29UflmkgG7XzLFgD0697Djh9xpPfld0gGDSFXxGtX2xvFpw94M+ckBVu3l7TR0DPuHI46LbQBY0LVIrrAJVYorbF2DDlLRmQPvtgDgv4e+5b5Wjc3/r7939kftzgkE6MQ6pmWMa1KgmurBLHuchluo6n6Y+JTQh8PMOrTSrCKMSQH2WDCtRLOzweSGf+5Biytg9chW911JUhGIp3 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:BLUPR03MB1491; BCL:0; PCL:0; RULEID:; SRVR:BLUPR03MB1491; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB1491; 4:XuLl5MhIplXxx9TsGUkYN80UW2juSp9xnF4zKMVW1T9BjnUwtFmWrJQknZw049U1dM2TctlOFqHUvF/pMioAUm2gLwbqthmsDXwoyHvSsZgR3dezgV2ONOXCbyNNcvVaML8QoDdfmM6UOSU0syVw42TRXtG/m4iuOR7siczpQfiHI4JCOfvAXbqlIHgqrG+GRcfI7BMH4PgdvKCykeGgL1qzUz6tve6hti6S354xRaOQW0QUGGNXZWwX9/AtTIeHgz41TcS0wRgQ/M+q0rmVdEHRFvX3wso3DXbeL3SPL/NlTfDuyE918OpgGQXVPhIs4e7w+2Nmh6Ggb1wlBt9eb/uqXz1kHzyWTOwiItC0HlcXQrsXewNjbaM2CdR4gacXBbZq8oLlS3pkQQct+KJSPLy9OmU3FOmLyTXHfpOLHgCurKdThOGeckaHolxkJOju X-Forefront-PRVS: 0067A8BA2A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(199003)(189002)(43544003)(36756003)(19580405001)(101416001)(50226002)(19580395003)(48376002)(33646002)(50986999)(189998001)(69596002)(229853001)(50466002)(106356001)(105586002)(68736007)(42186005)(53416004)(81156014)(7736002)(5003940100001)(7846002)(107886002)(66066001)(6116002)(3846002)(586003)(4326007)(1076002)(5660300001)(4001430100002)(305945005)(77096005)(5001770100001)(86152002)(92566002)(2906002)(47776003)(97736004)(81166006)(2201001)(8676002)(86362001)(43062003); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB1491; 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; BLUPR03MB1491; 23:IVxAqkAbDK5BEVP7K0GUMcaeELjG3U7O8VC5+cZR9?= =?us-ascii?Q?hWFW9IN8QhpKf0xd/474H8Pej+q4MW4Z9QnHe8A+xXC2HO0uA/w7Pt5W6vVi?= =?us-ascii?Q?iqDltKQfcwjz+jRU1KxxQYYsaelGDkpJlFW3vUyPnnx7y3Pv+J38Qfh6T60p?= =?us-ascii?Q?9JzHcCEWyxJBY93AQmHPsQ3WidWb0rL77ilCfS1Qw+JWIUFQFf4toj/FugHI?= =?us-ascii?Q?mIpqwTcMibMKwXQ/+6vHIdETx4n7B5IZDihO/C43310Iiq+dPLacEbGSC/Pk?= =?us-ascii?Q?V+kiRFVhQ3YlDCHX4HCONFQIevQoI0kW4cnfL0xR+N92SIej2GSw7LGDkToG?= =?us-ascii?Q?3gGNUW3WioKfBJmkIERoHPJT7AJJetpfConFbQcEsw0qFPKwEnngh/xuyb3r?= =?us-ascii?Q?v45wXuwAVSb1m6WIfqFBJe7pcv9QWM/a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IwnOZ+ISJXZ0l3X09ZWAcFRTRblS8rCWWQ9ZXRqCe6H0my8S07imXYXmSZpzp20psskIf2SAZ2sLIzlIyuM1O3zRny+FNpa8y4lBTg6MfbDwYDPax7xTML3JqPzGncF6i8RcAAi4mVmJzzpYsUONHYbLupg1lnSHX0RnLugILtaGRTMVDuuu+Ebz9o5dXJKI0LyQKoFusI5OYuePK/V/0Oj/lrYiQeQLxTM=; 5:YTDXv/O9XNG7B2PyqhWnJBoVfAF/NU4cObuJ3Xwv9v1iJBIkfYk6WppOUfEzH1jUbKriub0VasRARViNrhYltCUOQEYulab2BAw+m3Y2uEsKRJsXIZRKTOZmpJHDSEPqf/OMWnwuOk5Q7DM5JQ99zg==; 24:yCrIUdW5VAedYZs/JdJ0shHHNAlmDyDQ3x1rnR49ETyl9E2BadsbvgFrY+rHPVACP9LgDAgERXmss3hnFmcC92fN/dyBxvFc3qZS4jijc1A=; 7:TIz8IOG6QTdPxRTihPRYDTxuNdxERrSEc0fbGjy6yIFPhlWkshmHA/hejc1Y26rmUQVacSPKQ+aFj2kNz4fbyCE5+lQFs/3p/p1+azLExxRHxZuuR4IqKynCrypogwZymnEDvjZZJw+KmApEePHcluYcbFtdt9GFECCjlapATmv6H520ACz9Lnj6ofWbiHafOGDzFlgfcs88F2AExvkY7bnn6hlQ2M1WolwfQErJgcucUdq6663OGPx9sMCW7i8l SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sonusnet.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2016 17:14:10.5864 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB1491 Subject: [dpdk-dev] [PATCH v5]net/virtio: add mtu set 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: Fri, 16 Sep 2016 17:14:14 -0000 Virtio interfaces should also support setting of mtu, as in case of cloud it is expected to have the consistent mtu across the infrastructure that the dhcp server sends and not hardcoded to 1500(default). In case when GRE/VXLAN tunneling is used, it adds overheads to the total size of 1518, and in that cases the DHCP server corrects the L3 MTU to 1454 to take care of the overhead. BUt since virtio interfaces was not having the mtu set that mtu sent by dhcp was ignored and teh instance will still send packets with 1500 mtu which afetr encapsulation will become more than 1518 and eventually gets dropped in the infrastructure. This issue can be solved by honoring the mtu 1454 sent by dhcp server, which this below patch will take care. Changes in v5: Incorporated review comments. Changes in v4: Incorporated review comments. Changes in v3: Corrected few style errors as reported by sys-stv. Changes in v2: Incorporated review comments. Signed-off-by: Souvik Dey --- 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 07d6449..da16ad4 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 (frame_size < 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 - ether_hdr_len), + (dev_info.max_rx_pktlen - ether_hdr_len)); + return -EINVAL; + } + return 0; +} @@ -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