From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0080.outbound.protection.outlook.com [104.47.36.80]) by dpdk.org (Postfix) with ESMTP id 8C98428FD for ; Fri, 23 Sep 2016 17:17:39 +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=Z6K3TDIhNZrt2Jk5LudqjIvgLqY8ryRjFJsmY6kk3XI=; b=H2C0WNdCcxk6aQtQSmH34yPJFIL/U25y4UWlcE2ogOXV1ptJGHlrcv2Gbm0safw0x5/qI7Of8fqAlVbtpm4AUAQI02I48Bz6PVv7GGfL3xD6s4Lv0N5hjMxbZRNSyBKJNxSd50aNlyD1vAAFAMQ1tOtO/jZLWL8QBoCggWtDqj8= Received: from BN3PR03MB1494.namprd03.prod.outlook.com (10.163.35.145) by BN3PR03MB1494.namprd03.prod.outlook.com (10.163.35.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5; Fri, 23 Sep 2016 15:17:37 +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.0639.008; Fri, 23 Sep 2016 15:17:37 +0000 From: "Dey, Souvik" To: "Kavanagh, Mark B" , Yuanhan Liu , Stephen Hemminger CC: "dev@dpdk.org" Thread-Topic: [PATCH v6] net/virtio: add set_mtu in virtio Thread-Index: AQHSFF2bGYWatJTFW0SUpX36+50+dKCElTyAgAALYiCAAByIgIAB+TgAgAAUygCAAGPKUA== Date: Fri, 23 Sep 2016 15:17:37 +0000 Message-ID: References: <20160921231147.26820-1-sodey@sonusnet.com> <20160921162213.4b79d1ce@xeon-e3> <20160921184505.584367ef@xeon-e3> <20160923075320.GY23158@yliu-dev.sh.intel.com> In-Reply-To: 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: [208.45.178.4] x-ms-office365-filtering-correlation-id: 6bd0a13c-73e3-4326-f8a4-08d3e3c4c08e x-microsoft-exchange-diagnostics: 1; BN3PR03MB1494; 6:gMzKXpVT/OJTZ5aJsYOqhHczZL/blCgthcwbQ8IXYQMEK58EP8XMqKZHBlu0sJuLW7IN5GrLHydSEkINjhtowq2faYcq9HTDEEVWHj5LJEryFqEVWbE5YG8NagYgxwlnMSD2oiSkq4eP1rWZKffzTdH5OqdEaoYBvSOkZda+t+3eAixVP47oWqQbOc8QdTGuc4O132QN+92mUboT6fpKxH9rFcUv82XR9S0A6kU3rP13kLdFcsULUow5m2lC6MBEnAq3RrXqcOBiB2OAgKk9Bzd/JygztmDMhZTSTBS/2hc=; 5:LPiSIkPLZUhzC9YepKf+RaaFCuti1LMmbSnD+nso1UFGKMQRdtzFczqDK3Ox/O7t5INxYIfV/7yxueOwhMA42sdRaWcoQu6BWNTgOoP+3IZjB8U+m9H4SPhkISfEPSyXgFEy/tzp04UXZ9V0F4lo6w==; 24:BGC5JpCQOuMKuHSx6smSbgUi+8ZRzI3ViNmfvkQdbjZ/Pb/jftkzELdnZSLxlBRExPRShcUzr0oEG78QgYQY+JWQMDQenqBTBRaK7sMDUb8=; 7:/3Jc0/0kmiIEm7GfrfcN5e9p1bzZUCw0u3C2mq7vBCW8wlz7z4Tr7fezz4/4pK3eZSUzpOZKNxZV/goQvQwC76TxaGsJN98q7vlHjyVQ+l4Xts9bGO21a/3j1dZdKvKl6T51JmCwMuVQ9vxbRgBy75r4WQyIq+XKwHXW9HvhQbAonJ+JofvTpXz/CguvfdqoJ8mAX7Q7MIVOpPOXP6dPGzFH3US7MoyT1tUynpfRWZtOA3z1faew32DVNTCgl1u/BScXWiMdnVSjvk0mc9BbCw2Ty3LI5XuzaDLv+KHCL2Nr6qN3pPGp+Nrqi0OHZG4R x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1494; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(21748063052155)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:BN3PR03MB1494; BCL:0; PCL:0; RULEID:; SRVR:BN3PR03MB1494; x-forefront-prvs: 0074BBE012 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(7916002)(24454002)(13464003)(199003)(377454003)(189002)(54356999)(76176999)(101416001)(106116001)(106356001)(586003)(8936002)(102836003)(790700001)(6116002)(3846002)(50986999)(105586002)(19625215002)(2900100001)(2950100001)(92566002)(7736002)(7846002)(93886004)(99286002)(66066001)(122556002)(33656002)(10400500002)(15975445007)(77096005)(74316002)(8676002)(16236675004)(81166006)(81156014)(19580395003)(19580405001)(2906002)(4326007)(5660300001)(9686002)(68736007)(5002640100001)(76576001)(7696004)(189998001)(19300405004)(11100500001)(5001770100001)(86362001)(87936001)(3660700001)(97736004)(3280700002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR03MB1494; H:BN3PR03MB1494.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 MIME-Version: 1.0 X-OriginatorOrg: sonusnet.com X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Sep 2016 15:17:37.1420 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 29a671dc-ed7e-4a54-b1e5-8da1eb495dc3 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB1494 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [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: Fri, 23 Sep 2016 15:17:40 -0000 Hi Liu/Mark/Stephen, I have tried to modify the code with all of your latest comme= nts. Do let me know if this looks fine or you have more comments. Changes done : -- max frame ize is compare to VIRTIO_MAX_RX_PKTLEN instead of dev_info.max= _rx_pktlen -- removed the CRC_LEN from the ether_len calculation and added the merge r= x buf hdr len. ether_hdr_len =3D ETHER_HDR_LEN + VLAN_TAG_SIZE + hw->vtnet_= hdr_size -- Still retained the VLAN Size as the worst case scenario. -- 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"); } +#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 virtio_hw *hw =3D dev->data->dev_private; + uint32_t ether_hdr_len =3D ETHER_HDR_LEN + VLAN_TAG_SIZE + 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_PKTL= EN); + 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, -- Please do let me know if this looks good to you all. Thanks -- Regards, Souvik -----Original Message----- From: Kavanagh, Mark B [mailto:mark.b.kavanagh@intel.com] Sent: Friday, September 23, 2016 5:08 AM To: Yuanhan Liu ; Stephen Hemminger Cc: Dey, Souvik ; dev@dpdk.org Subject: RE: [PATCH v6] net/virtio: add set_mtu in virtio >Subject: Re: [PATCH v6] net/virtio: add set_mtu in virtio > >On Wed, Sep 21, 2016 at 06:45:05PM -0700, Stephen Hemminger wrote: >> On Thu, 22 Sep 2016 00:08:38 +0000 >> "Dey, Souvik" > wrote: >> >> > Answers inline. >> > >> > -- >> > Regards, >> > Souvik >> > >> > -----Original Message----- >> > From: Stephen Hemminger [mailto:stephen@networkplumber.org] >> > Sent: Wednesday, September 21, 2016 7:22 PM >> > To: Dey, Souvik > >> > Cc: mark.b.kavanagh@intel.com; yuanh= an.liu@linux.intel.com; >> > dev@dpdk.org >> > Subject: Re: [PATCH v6] net/virtio: add set_mtu in virtio >> > >> > On Wed, 21 Sep 2016 19:11:47 -0400 >> > Dey > wrote: >> > >> > > >> > > + >> > > +#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 =3D ETHER_HDR_LEN + ETHER_CRC_LEN + V= LAN_TAG_SIZE; >> > > + uint32_t frame_size =3D mtu + ether_hdr_len; >> > > + >> > > + virtio_dev_info_get(dev, &dev_info); >> > > + >> > > + if (mtu < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktl= en) { >> > > + 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; >> > > +} >> > >> > I am fine with the general idea of this patch but: >> > 1. Calling virtio_dev_info_get is needlessly wasteful when all you w= ant >> > is to access the max packet length. Since max_rx_pktlen is always >> > VIRTIO_MAX_RX_PKTLEN, please just use that. >> > [Dey, Souvik] I am using the virtio_dev_info_get as in future >> > can/may support the >max_rx_pktlen as a variable to be set by the application. This will >keep the changes future proof. As we need to support till 65535 instead of= 9728 as the linux does. >> >> Fine, then just dereference hw->rx_max_pktlen. Driver code can/should >> reference its own data directly. > >Dey, maybe you could just use VIRTIO_MAX_RX_PKTLEN here, like what you >did in early versions. > >> > >> > 2. Defining VLAN_TAG_SIZE is irrelevant if doing vlan offload. >> > [Dey, Souvik] vlan offload is not mandatory. Se again still have >> > vlan being sent up to >the application. In that case we need to consider the vlan length in the E= thernet size. >> >> The code needs to handle both vlan offload (or not), correctly. You >> are assuming the worst case here. > >I think we are fine here to assume worst case. > >> > >> > 3. Virtio doesn't insert CRC, therefore CRC_LEN is irrelevant >> > [Dey, Souvik] I am not sure of this. Mark commented earlier to conside= r this length too. >Mark what do you suggest ? >> >> Actually, the thing that matters is the size of the merge rx buf header,= not the CRC. > >Right. My comments were based on my experience with DPDK ethdev PMDs - Stephen and= Yuanhan have much more experience with virtio, so I'd go with their sugges= tion. > > --yliu >> >> The patch is still buggy. >>