From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0078.outbound.protection.outlook.com [104.47.34.78]) by dpdk.org (Postfix) with ESMTP id D05F168FC for ; Sat, 1 Oct 2016 16:09:02 +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=PjjAKfVO63/KvuSMdjlpSxYInEyxPyT3TJ22onS2Nkk=; b=MItUCCQS6H48HET9coYThTZV8REaUtdleYFRYKKByqoDatKNosw9Xi85LbWz328Hj/ynCCHZ7xR7+Urz4piliUOzCKLjdlznwv/eHgu9HcBFUlodgHOBXopyOwFfV+Rw6MvaWdxXyn4cKmNl+7gb2I9UClNJl9Y8Hahiiwa4Vr4= Received: from BN3PR03MB1494.namprd03.prod.outlook.com (10.163.35.145) by BN3PR03MB1495.namprd03.prod.outlook.com (10.163.35.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.649.16; Sat, 1 Oct 2016 14:08:59 +0000 Received: from BN3PR03MB1494.namprd03.prod.outlook.com ([10.163.35.145]) by BN3PR03MB1494.namprd03.prod.outlook.com ([10.163.35.145]) with mapi id 15.01.0649.021; Sat, 1 Oct 2016 14:08:59 +0000 From: "Dey, Souvik" To: "mark.b.kavanagh@intel.com" , "yuanhan.liu@linux.intel.com" , "stephen@networkplumber.org" , "dev@dpdk.org" Thread-Topic: [PATCH v7] net/virtio: add set_mtu in virtio Thread-Index: AQHSGpCEO2JH49nnlEKHRbCquIGY6aCTpQrA Date: Sat, 1 Oct 2016 14:08:59 +0000 Message-ID: References: <20160922135643.37636-1-sodey@sonusnet.com> <20160929203130.58712-1-sodey@sonusnet.com> In-Reply-To: <20160929203130.58712-1-sodey@sonusnet.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=sodey@sonusnet.com; x-originating-ip: [66.30.138.194] x-ms-office365-filtering-correlation-id: 70a4f718-8f0e-4324-858c-08d3ea047d6b x-microsoft-exchange-diagnostics: 1; BN3PR03MB1495; 6:iaRt7qIi3GTg2CCK9i94w7ogA72qqb2M/wU9rqcXbW4aGnMPrqs9sMdlipWOpmV+Eaz8t7BHDavbomGihZXWCnOHMwhyFDHEJfaAuRwUNLls/489tLeGrmeTv0C+YNcCILjhfrxkKtVfBqKEjXWZPfBTtqhTHegzW/mHklQCmt/PYFvth6Xeflso7po41U3V5qKwb+88fap4OcX6t/URNzEkH0QsOszFcnfmdfeGq7lz0CsnJN44Im2Khsj7fAp3G+WyrLcO+Cxdwmxthfv+F8Mc+BSsi9MHvhF2Uh/6NKkClvEEC4uRR3hlbyCuXzxS; 5:TgalTSbXW2zvMDKT9H1vyl/obeEzETkmBSSx61qaYHe3b5wQdNgXvVanItUejiDqho3XdYDdhkYD0SJzSiHETNBvkmt2LYNM1nbhGF3mynAhC0ykTxhfzkFKSxWtUiDd06nTzHHkSBxeoAChq//epcY+RUO3gOGs76oA7V2RJhXOmhRKqHvdeUsmK3Kfi3qJ; 24:zk6l9GZtdEzQ/Jo9/eJQWtncISz7q8cZGeabtGUgOujkbEB2yfrP8FvtQppN2F8pjjY7GqWjosc5WcmFR1SYec7IhJNXUOszKx8L65i/StU=; 7:MVtRSGB8lGndVkMQ64R41Zfcz8y5Ax7JAS6hDrAm6iK22yMiiAFkWZe9b5UU/1dOHiDGQljQmfBEDKoi1CLsaHDdEomrsQest5fPRcuXmNtRtGBj7EevbUZX1Oeq/je1T0q2BC1CjCf94PWl+Isu6B/3rhs3iEn0FNnKjrGxkF/HcBhCsuc12hwPjfcG18+7+ug00d3Y0WieK+Wc1CBFVRJB++4+MOYVLJsaNqccCzfZeDzpIdDsIUdYw39syESXjSuqv0MWifkvSX1DgQLf0O+k7qhIsCvPEIF6II08EBW/rfLqvuFcEpb1Xx6cxS1A7w90mK6yThUMEdFnKB01Bg== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1495; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(158342451672863)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:BN3PR03MB1495; BCL:0; PCL:0; RULEID:(304825118); SRVR:BN3PR03MB1495; x-forefront-prvs: 00826B6158 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(13464003)(43544003)(189002)(199003)(377454003)(8676002)(97736004)(5001770100001)(8936002)(81156014)(81166006)(11100500001)(86362001)(105586002)(106116001)(189998001)(2501003)(9686002)(101416001)(2201001)(50986999)(76176999)(19580405001)(19580395003)(3280700002)(54356999)(5002640100001)(107886002)(99286002)(66066001)(2906002)(106356001)(3660700001)(122556002)(68736007)(3900700001)(10400500002)(6116002)(2900100001)(102836003)(3846002)(305945005)(7736002)(7696004)(586003)(87936001)(33656002)(76576001)(7846002)(2950100002)(74316002)(5660300001)(77096005)(92566002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR03MB1495; H:BN3PR03MB1494.namprd03.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: sonusnet.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: sonusnet.com X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Oct 2016 14:08:59.2027 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 29a671dc-ed7e-4a54-b1e5-8da1eb495dc3 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB1495 Subject: Re: [dpdk-dev] [PATCH v7] 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: Sat, 01 Oct 2016 14:09:03 -0000 Hi Liu/Stephen/Mark, I have submitted Version 7 of this patch. Do let me know if this looks pro= per. -- Regards, Souvik =20 -----Original Message----- From: Dey, Souvik=20 Sent: Thursday, September 29, 2016 4:32 PM To: mark.b.kavanagh@intel.com; yuanhan.liu@linux.intel.com; stephen@network= plumber.org; dev@dpdk.org Cc: Dey, Souvik Subject: [PATCH v7] net/virtio: add set_mtu in virtio Virtio interfaces do not currently allow the user to specify a particular=20 Maximum Transmission Unit (MTU).Consequently, the MTU of Virtio interfaces= =20 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= =20 needs to be honored by all interfaces across the traffic path.To acheive=20 this Virtio interfaces should support setting of MTU. In case when GRE/VXLAN tunneling is used for internal communication, there= =20 will be an overhead added by the infrastructure in the packet over and=20 above the ETHER MTU of 1518. So to take care of this overhead in these=20 cases the DHCP server corrects the L3 MTU to 1454. But since virtio=20 interfaces was not having the MTU set functionality that MTU sent by the=20 DHCP server was ignored and the instance will still send packets with 1500= =20 MTU which after encapsulation will become more than 1518 and eventually=20 gets dropped in the infrastructure.=20 By adding an additional 'set_mtu' function to the Virtio driver, we can=20 honor the MTU sent by the DHCP server. The dhcp server/controller can=20 then leverage this 'set_mtu' functionality to resolve the above=20 mentioned issue of packets getting dropped due to incorrect size. Signed-off-by: Souvik Dey --- Changes in v7: - Replaced the CRC_LEN with the merge rx buf header length. - Changed the frame_len max validation to VIRTIO_MAX_RX_PKTLEN. 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:=20 - 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 | 16 ++++++++++++++++ 1 file changed, 16 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 *d= ev) PMD_INIT_LOG(ERR, "Failed to disable allmulticast"); }=20 +#define VLAN_TAG_LEN 4 /* 802.3ac tag (not DMA'd) */ +static int virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) +{ + struct virtio_hw *hw =3D dev->data->dev_private; + uint32_t ether_hdr_len =3D ETHER_HDR_LEN + VLAN_TAG_LEN + + hw->vtnet_hdr_size; + uint32_t frame_size =3D mtu + ether_hdr_len; + + if (mtu < ETHER_MIN_MTU || frame_size > VIRTIO_MAX_RX_PKTLEN) { + PMD_INIT_LOG(ERR, "MTU should be between %d and %d\n", + ETHER_MIN_MTU, VIRTIO_MAX_RX_PKTLEN); + 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 =3D = { .allmulticast_enable =3D virtio_dev_allmulticast_enable, .allmulticast_disable =3D virtio_dev_allmulticast_disable, + .mtu_set =3D virtio_mtu_set, .dev_infos_get =3D virtio_dev_info_get, .stats_get =3D virtio_dev_stats_get, .xstats_get =3D virtio_dev_xstats_get, --=20 2.9.3.windows.1