From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 4FEE95599 for ; Mon, 12 Sep 2016 16:48:00 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP; 12 Sep 2016 07:47:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,323,1470726000"; d="scan'208";a="1049134037" Received: from irsmsx105.ger.corp.intel.com ([163.33.3.28]) by orsmga002.jf.intel.com with ESMTP; 12 Sep 2016 07:47:58 -0700 Received: from irsmsx156.ger.corp.intel.com (10.108.20.68) by irsmsx105.ger.corp.intel.com (163.33.3.28) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 12 Sep 2016 15:47:57 +0100 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.102]) by IRSMSX156.ger.corp.intel.com ([169.254.3.234]) with mapi id 14.03.0248.002; Mon, 12 Sep 2016 15:47:56 +0100 From: "Kavanagh, Mark B" To: "Dey, Souvik" , Yuanhan Liu CC: "dev@dpdk.org" , "stephen@networkplumber.org" Thread-Topic: [PATCH v4]net/virtio: add mtu set in virtio Thread-Index: AQHSCqVo9QrBVjxw+E+LTSeFyfJhrKBxQBXA///45wCAABEqUIAAHECAgARzApA= Date: Mon, 12 Sep 2016 14:47:55 +0000 Message-ID: References: <20160907041832.35384-1-sodey@sonusnet.com> <20160909070009.GS23158@yliu-dev.sh.intel.com> In-Reply-To: Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNjExMmYyMTEtZDJjNS00M2U1LWIwN2UtOTE1YTMyYjY5OGQ0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6InhvcVd0QnJRN3lkNGVzYWlPdnBWZXNid0R4VDU4cjU4TklzMTd0OUNrWGc9In0= x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v4]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: Mon, 12 Sep 2016 14:48:01 -0000 > >Hi Mark/Liu, >=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Thanks to both of you for being so= patient with a series of silly errors. I >have tried to make it better this time. Also there were some un-used varia= ble in the function >which I have removed. Please check the new patch with all your comments in= corporated. Also >along with the L2_HDR_LEN and L2_CRC_LEN, I have taken in consideration th= e VLAN_LEN too. > >One doubt though, >"9728 is the largest L2 frame size allowed by the NIC" -- this 9728 size i= s some constrain >due to DPDK as the virtio driver in the kernel can support till mtu size o= f 68 to 65535, >where as in DPDK pmd we are trying with 64 to 9728. Yes, I meant the NIC as controlled by a DPDK PMD (I thought this was implic= it, given the context of this discussion). I'll be more explicit in future = mails though. > >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/virti= o_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) >=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 PMD_INIT_LOG(ERR, "Failed to= disable allmulticast"); >} > >+#define VLAN_TAG_LEN=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 4=A0=A0=A0 /* 802.3ac = tag (not DMA'd) */ >+ >+static int=A0 virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) One thing on this function: it doesn't actually set any fields, but rather = just sanitizes 'mtu'. Maybe this is acceptable, since the calling function (i.e. rte_eth_dev_set_= mtu) sets rte_eth_dev->data->mtu? >+{ >+=A0=A0=A0=A0=A0=A0 struct rte_eth_dev_info dev_info; >+=A0=A0=A0=A0=A0=A0 uint32_t ether_hdr_len =3D ETHER_HDR_LEN + ETHER_CRC_L= EN + VLAN_TAG_LEN; >+=A0=A0=A0=A0=A0=A0 uint32_t frame_size =3D mtu + ether_hdr_len; >+ >+=A0=A0=A0=A0=A0=A0 virtio_dev_info_get(dev, &dev_info); >+ >+=A0=A0=A0=A0=A0=A0 if (mtu < dev_info.min_rx_bufsize || frame_size > dev_= info.max_rx_pktlen) { It's not clear to me whether 'mtu' in this case should be compared with ETH= ER_MIN_MTU, as per other DPDK drivers, or alternatively whether 'frame_size= ' should be compared with dev_info.min_rx_bufsize. Any thoughts? >+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 PMD_INIT_LOG(ERR, "MTU should = be between %d and %d\n", >+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0dev_info.min_rx_bufsize, As above. >+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0 (dev_info.max_rx_pktlen - ether_hdr_len)); >+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return -EINVAL; >+=A0=A0=A0=A0=A0=A0 } >+ =A0=A0=A0=A0=A0=A0return 0; >+} >@@ -677,7 +685,6 @@ static const struct eth_dev_ops virtio_eth_dev_ops =3D= { >=A0=A0=A0=A0=A0 =A0=A0.allmulticast_enable=A0=A0=A0=A0 =3D virtio_dev_allm= ulticast_enable, >=A0=A0=A0=A0=A0=A0=A0 .allmulticast_disable=A0=A0=A0 =3D virtio_dev_allmul= ticast_disable, >+=A0=A0=A0=A0=A0=A0 .mtu_set=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 =3D virtio_mtu_set, >=A0=A0=A0=A0=A0=A0=A0 .dev_infos_get=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =3D vir= tio_dev_info_get, >=A0=A0=A0=A0=A0=A0=A0 .stats_get=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =3D virtio_dev_stats_get, >=A0=A0=A0=A0=A0=A0=A0 .xstats_get=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 = =3D virtio_dev_xstats_get, > > >-- >Regards, >Souvik > >-----Original Message----- >From: Kavanagh, Mark B [mailto:mark.b.kavanagh@intel.com] >Sent: Friday, September 9, 2016 11:44 AM >To: Dey, Souvik ; Yuanhan Liu >Cc: dev@dpdk.org; stephen@networkplumber.org >Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio > >> >>Hi Mark, >> >>Yes I thought I did that change. Sorry once again.. making too many mista= kes. Changed it . >>Thanks. >>The MTU here is L3 MTU.=A0 Setting this will help in reducing the >>fragmented/multi-segmented packets and also in case we want to reduce >>the MTU below 1500, to support VXLAN or GRE tunnel for the packets in ope= nstack and cloud >environments. >> >>--- >> 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 >> >>static int virtio_dev_queue_stats_mapping_set( >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 __rte_unused struct rte_eth_dev *eth_dev,= @@ -652,6 +653,16 @@ >>virtio_dev_allmulticast_disable(struct rte_eth_dev *dev) >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 PMD_INIT_LOG(ERR, "Failed to disable allmulticast");=A0 } >> >>+static int >>+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) { >>+=A0=A0=A0=A0=A0=A0=A0=A0=A0 struct virtio_hw *hw =3D dev->data->dev_priv= ate; >>+=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIR= TIO_MAX_RX_PKTLEN) { > >If MTU is the L3 MTU as you've indicated, then you need to take account of= L2 overhead before >performing the comparison above. >Say the user supplies 'mtu' as 9728 - the corresponding minimum frame size= is L2_HDR_LEN + >9728 + L2_CRC_LEN =3D 9746 bytes, which is larger than the NIC can accommo= date (note that 9728 >is the largest L2 frame size allowed by the NIC, not the largest IP packet= size). > >>+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 PM= D_INIT_LOG(ERR, "Mtu should be between VIRTIO_MIN_RX_BUFSIZE and >>VIRTIO_MAX_RX_PKTLEN \n"); > >Two things on this statement: >1) in the context of a log message, VIRTIO_XXX_RX_BUFSIZE most likely mean= s very little, and >as such is not helpful. I suggest going with the format that I included in= my earlier mail, >which prints the numeric value of the min and max rx defines >2) MTU is an initialization, and should be printed as such in a= log (i.e. all >caps) > >Hope this helps, >Mark > >>+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 re= turn -EINVAL; >>+=A0=A0=A0=A0=A0=A0=A0=A0=A0 } >>+=A0=A0=A0=A0=A0=A0=A0=A0=A0 return 0; >>+} >>+ >> /* >>=A0 * dev_ops for virtio, bare necessities for basic operation >>=A0 */ >>@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = =3D { >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 .promiscuous_disable=A0=A0=A0=A0 =3D virt= io_dev_promiscuous_disable, >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 .allmulticast_enable=A0=A0=A0=A0 =3D virt= io_dev_allmulticast_enable, >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 .allmulticast_disable=A0=A0=A0 =3D virtio= _dev_allmulticast_disable, >>+=A0=A0=A0=A0=A0=A0=A0=A0=A0 .mtu_set=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 =3D virtio_mtu_set, >> >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 .dev_infos_get=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 =3D virtio_dev_info_get, >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 .stats_get=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 =3D virtio_dev_stats_get, >>-- >> >>-- >>Regards, >>Souvik >>-----Original Message----- >>From: Kavanagh, Mark B [mailto:mark.b.kavanagh@intel.com] >>Sent: Friday, September 9, 2016 11:05 AM >>To: Dey, Souvik ; Yuanhan Liu >> >>Cc: dev@dpdk.org; stephen@networkplumber.org >>Subject: RE: [PATCH v4]net/virtio: add mtu set in virtio >> >>> >>>Hi Liu, >>> >>>Yes agreed your comment. I will definitely remove the declaration as >>>it is not really required. >>> So the latest patch will look like this . Yes I did rush a bit to >>>submit the patch last will correct my suite. So sending the patch in a >>>reply if we have more comments we can take a look and they re-submit >>>the final reviewed >>patch. Thanks for the help though. >>> >>>--- >>> 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 >>> >>>+static int >>>+virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) { >>>+=A0=A0=A0=A0=A0=A0=A0 struct virtio_hw *hw =3D dev->data->dev_private; >>>+=A0=A0=A0=A0=A0=A0=A0 if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_M= AX_RX_PKTLEN) { >>>+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 PMD_INI= T_LOG(ERR, "Mtu should be between 64 and 9728\n"); >> >>Hi Souvik, >> >>Why hardcode the values in the PMD_INIT_LOG? >> >>Why not=A0 do the following: PMD_INIT_LOG(ERR, "MTU should be between %d = and %d", >> >=A0=A0=A0=A0=A0=A0 VIRTIO_MIN_RX_BUFSIZE, >>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 VIRTIO_MAX >_RX_PKTLEN); >> >>That way, if the values that the macros evaluate to change, the log >>will update correspondingly. >> >>Also, does 'MTU' in this context relate to the L2 or L3 MTU? >> >>>+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return = -EINVAL; >>>+=A0=A0=A0=A0=A0=A0=A0 } >>>+=A0=A0=A0=A0=A0=A0=A0 return 0; >>>+} >>>+ >>> /* >>>=A0 * dev_ops for virtio, bare necessities for basic operation >>>=A0 */ >>>@@ -664,6 +675,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = =3D { >>> =A0=A0=A0=A0=A0=A0=A0=A0 .promiscuous_disable=A0=A0=A0=A0 =3D virtio_de= v_promiscuous_disable, >>> =A0=A0=A0=A0=A0=A0=A0=A0 .allmulticast_enable=A0=A0=A0=A0 =3D virtio_de= v_allmulticast_enable, >>> =A0=A0=A0=A0=A0=A0=A0=A0 .allmulticast_disable=A0=A0=A0 =3D virtio_dev_= allmulticast_disable, >>>+=A0=A0=A0=A0=A0=A0=A0 .mtu_set=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0 =3D virtio_mtu_set, >>> >>> =A0=A0=A0=A0=A0=A0=A0=A0 .dev_infos_get=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 = =3D virtio_dev_info_get, >>> =A0=A0=A0=A0=A0=A0=A0=A0 .stats_get=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0 =3D virtio_dev_stats_get, >>>-- >>> >>>-- >>>Regards, >>>Souvik >>> >>>-----Original Message----- >>>From: Yuanhan Liu [mailto:yuanhan.liu@linux.intel.com] >>>Sent: Friday, September 9, 2016 3:00 AM >>>To: Dey, Souvik >>>Cc: dev@dpdk.org; stephen@networkplumber.org >>>Subject: Re: [PATCH v4]net/virtio: add mtu set in virtio >>> >>>On Wed, Sep 07, 2016 at 04:21:30AM +0000, Dey, Souvik wrote: >>>> Hi Liu, >>>> =A0=A0=A0=A0=A0=A0 Submitted the version 4 of the patch as you suggest= ed , >>> >>>Your patch is looking much better. But not really, you ignored few of my= comments. >>> >>>> and have removed the Reviewed by line. >>>> I have still kept the function definition as to follow the same suit >>>> as we have done for >>>other eth_dev_ops. >>> >>>That's because most of the method implementions are after the >>>reference, thus the declaration is needed. >>> >>>For your case, I see no good reason to do that. BTW, if you disagree >>>with my comment, you shoud made a reply, instead of rushing to sending a= new version. >>> >>>> -- >>>> Regards, >>>> Souvik >>>> >>>> -----Original Message----- >>>> From: Dey, Souvik >>>> Sent: Wednesday, September 7, 2016 12:19 AM >>>> To: dev@dpdk.org; stephen@networkplumber.org; >>>> yuanhan.liu@linux.intel.com >>>> Cc: Dey, Souvik >>>> Subject: [PATCH v4]net/virtio: add mtu set in virtio >>>> >>>> >>>> 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). >>>> >>>> Changes in v4: Incorporated review comments. >>>> Changes in v3: Corrected few style errors as reported by sys-stv. >>>> Changes in v2: Incorporated review comments. >>> >>>DPDK prefers to put the change log to ... >>>> >>>> Signed-off-by: Souvik Dey >>>> >>>> --- >>> >>>... here. >>> >>>So that they will be showed in mailing list (for review), but they will = be gone after >apply. >>>In another word, we don't like to see those change log in git history, >>>but we'd like to see them while review. >>> >>>>=A0 drivers/net/virtio/virtio_ethdev.c | 12 ++++++++++++ >>>>=A0 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,=A0 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, >>>>=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 struct ether_addr *mac_addr); >>>> +static int=A0 virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); >>>> >>>>=A0 static int virtio_dev_queue_stats_mapping_set( >>>>=A0 =A0=A0=A0=A0=A0 __rte_unused struct rte_eth_dev *eth_dev, @@ -652,6= +653,16 @@ >>>virtio_dev_allmulticast_disable(struct rte_eth_dev *dev) >>>>=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 PMD_INIT_= LOG(ERR, "Failed to disable allmulticast");=A0 } >>>> >>>> +static int >>>> +virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) { >>>> +=A0=A0=A0=A0 struct virtio_hw *hw =3D dev->data->dev_private; >>>> +=A0=A0=A0=A0 if (mtu < VIRTIO_MIN_RX_BUFSIZE || mtu > VIRTIO_MAX_RX_P= KTLEN) { >>>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 PMD_INIT_LOG(E= RR, "Mtu should be between 64 and 9728\n"); >>> >>>I still saw those numbers. >>> >>>=A0=A0=A0=A0=A0=A0=A0=A0=A0 --yliu