From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0044.outbound.protection.outlook.com [104.47.33.44]) by dpdk.org (Postfix) with ESMTP id C575A2BD1 for ; Tue, 30 Aug 2016 01:11:44 +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=qtvWrxiy5bV2WtUCeeefigtilkjWsuoZkX1il3GI/IE=; b=JebUgSbbMN8kWTLT/deO9URNrN6ogZrox+tOM6kED/CW7BnPrE1QvxWre3tD+kRBNUcg53ppdWkVlGhVb9fgcylPKtJq4nNpDhTWw72t8EN68hcuCanfLVt2KLcOvtZKh6zx7hrxrlo8L8twolyYT5gbWbcW2yljLlitsEm9MeI= Received: from BN6PR03MB2740.namprd03.prod.outlook.com (10.173.144.135) by BN6PR03MB2738.namprd03.prod.outlook.com (10.173.144.21) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.587.13; Mon, 29 Aug 2016 22:49:47 +0000 Received: from BN6PR03MB2740.namprd03.prod.outlook.com ([10.173.144.135]) by BN6PR03MB2740.namprd03.prod.outlook.com ([10.173.144.135]) with mapi id 15.01.0587.013; Mon, 29 Aug 2016 22:49:47 +0000 From: "Dey, Souvik" To: Stephen Hemminger CC: "huawei.xie@intel.com" , "yuanhan.liu@linux.intel.com" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v1] add mtu set in virtio Thread-Index: AQHR//2h9IuLF04epUu392CynAnVbqBdgqOAgAF3eyCAAV47AIAAMsKw Date: Mon, 29 Aug 2016 22:49:47 +0000 Message-ID: References: <20160827005428.16556-1-sodey@sonusnet.com> <20160827171541.5f6b17c2@xeon-e3> <20160829123306.4e2bf00d@xeon-e3> In-Reply-To: <20160829123306.4e2bf00d@xeon-e3> 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: [73.114.35.204] x-ms-office365-filtering-correlation-id: 4da6b4cf-fc6a-4aed-4b4c-08d3d05ec747 x-microsoft-exchange-diagnostics: 1; BN6PR03MB2738; 6:+/PZUI+vYv7QW6h7ibO4ome3L8ReYwvqUBOjjfS5S7qqiq20qp1vFmBaobU2WUWG76XbR/Z/GHoOC6D0Q1R93/Vd+9RPvrGMLdoX6y/X9zDk6kHzJUGRn5FK7dsJ3n6biPv6oXjC+l94ulqr/TBjJwqgp2vGQcvce3r0Ppx5rxExfUmpJw139lqBb/FC0UNQSZuVXzsiK87UYYt34Z0caYaOWkGvGMcSEEzGnWcDtxIk/CHxb/aJo8wzqBeadogKl997BJ67KITJzfurlELS0kuiSWjejcCXGPMvTMSCDwI=; 5:hS71Lmv2sn+a7YpnFJvNgJo5dK87x3l9y0SaHOKABDIZMARHIUFF0FPOtDwjUsvaVUceR6/HzzVfut7Pd6ikqnX2QeicEYJiW+kFXmSlvdBwKwqNI9UNPEfiY8fWi5hGnxNNcTQfL2rFUhQJQiwVhQ==; 24:u0978lse+YQiA6vb1k0sLJwsKodo5qIKG3ZCeN8GWaBPyU+B/jmVPRSc600dNvUhVnnlXp2q+z/0r8/hruM9wj/OYMywEirGjt6HTBisi0s=; 7:GT8QO8Mhu7rXnleAIUebMRqwLzgtMnQm2HtGwBdAKJretZmhL2UEZdsNbx77z/01c86KEREljCbdPuBbOByjYzSW20+BjVX3/HbGnqPlZawE2h2fkrYVTp8I0E/RK9afCBdx2MCzSCyhtXFbq2gHzoiVr0QeBiVwwq8lrhRD+m5Df+GLNDttbQEy9XONH2JaF8Jve30ojrur3wscaeTmd9OkWYat15gNen1ToSnYmpJ9WwF3teV7QEmCxVE2m7dI x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN6PR03MB2738; 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)(10201501046)(3002001); SRVR:BN6PR03MB2738; BCL:0; PCL:0; RULEID:; SRVR:BN6PR03MB2738; x-forefront-prvs: 0049B3F387 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(377454003)(199003)(189002)(13464003)(24454002)(105586002)(11100500001)(8936002)(5660300001)(7696003)(106356001)(81156014)(8676002)(305945005)(92566002)(87936001)(77096005)(7846002)(2900100001)(7736002)(81166006)(2950100001)(2906002)(9686002)(10400500002)(19580405001)(3846002)(3280700002)(110136002)(5002640100001)(4326007)(54356999)(33656002)(86362001)(99286002)(93886004)(76576001)(50986999)(19580395003)(74316002)(189998001)(76176999)(97736004)(586003)(6116002)(106116001)(122556002)(66066001)(68736007)(101416001)(102836003)(3660700001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB2738; H:BN6PR03MB2740.namprd03.prod.outlook.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) 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: 29 Aug 2016 22:49:47.3889 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 29a671dc-ed7e-4a54-b1e5-8da1eb495dc3 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2738 Subject: Re: [dpdk-dev] [PATCH v1] 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: Mon, 29 Aug 2016 23:11:45 -0000 Thanks , I will remove the unlikely from the conditionally statement. Below is the complete patch : >>From 2e4b391fe90ba5e617611e341a7d260dd3dd9144 Mon Sep 17 00:00:00 2001 From: souvikdey33 Date: Fri, 26 Aug 2016 20:46:21 -0400 Subject: [PATCH v2 2/3] Signed-off-by: Souvik Dey Fixes: 1fb8e8896ca8 ("Signed-off-by: Souvik Dey ") Reviewed-by: Stephen Hemminger 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). --- drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++ 1 file changed, 12 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 @@ -92,6 +92,7 @@ static void virtio_mac_addr_add(struct rte_eth_dev *dev, static void virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index= ); static void virtio_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr); +static int virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); =20 static int virtio_dev_queue_stats_mapping_set( __rte_unused struct rte_eth_dev *eth_dev, @@ -652,6 +653,16 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *de= v) PMD_INIT_LOG(ERR, "Failed to disable allmulticast"); } =20 +static int=20 +virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)=20 +{ + struct virtio_hw *hw =3D dev->data->dev_private; + if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLEN) { + PMD_INIT_LOG(ERR,"Mtu should be between 64 and 9728." + return -EINVAL; + } + return 0; +} + /* * dev_ops for virtio, bare necessities for basic operation */ @@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops =3D = { .promiscuous_disable =3D virtio_dev_promiscuous_disable, .allmulticast_enable =3D virtio_dev_allmulticast_enable, .allmulticast_disable =3D virtio_dev_allmulticast_disable, + .mtu_set =3D virtio_mtu_set, =20 .dev_infos_get =3D virtio_dev_info_get, .stats_get =3D virtio_dev_stats_get, --=20 2.9.3.windows.1 As I am submitting to DPDK for the first time can you please guide with the= next steps. -- Regards, Souvik -----Original Message----- From: Stephen Hemminger [mailto:stephen@networkplumber.org]=20 Sent: Monday, August 29, 2016 3:33 PM To: Dey, Souvik Cc: huawei.xie@intel.com; yuanhan.liu@linux.intel.com; dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v1] add mtu set in virtio On Sun, 28 Aug 2016 22:43:54 +0000 "Dey, Souvik" wrote: > Hi , > Currently as you have mentioned, I have changed the code to: > static int > virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) { > struct virtio_hw *hw =3D dev->data->dev_private; > - if (unlikely(mtu < (uint32_t)hw->vtnet_hdr_size + ETHER_HDR_LEN)) { > - return -1; > + if (unlikely(mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_PKTLE= N)) { > + PMD_INIT_LOG(ERR,"Mtu should be between 64 and 9728." > + return -EINVAL; > } > return 0; > } >=20 > Yes, we should support till 64K as the kernel does , but I need to go thr= ough the changes and test it properly before submitting it for review. More= over I was thinking with the changes in the mtu, we should also support mul= ti-segment buffers in kni. What do you suggest ? This looks good, but you really don't need likely/unlikely in this code. It is not at all performance critical.