From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adrien Mazarguil Subject: Re: [PATCH 01/12] ethdev: add API to query what/if packet type is set Date: Thu, 7 Jan 2016 14:32:27 +0100 Message-ID: <20160107133227.GU12095@6wind.com> References: <20160104113814.GT3806@6wind.com> <2601191342CEEE43887BDE71AB97725836AE1002@irsmsx105.ger.corp.intel.com> <20160105161423.GE4712@autoinstall.dev.6wind.com> <2601191342CEEE43887BDE71AB97725836AE18E3@irsmsx105.ger.corp.intel.com> <20160106100053.GJ12095@6wind.com> <2601191342CEEE43887BDE71AB97725836AE1B46@irsmsx105.ger.corp.intel.com> <20160106154438.GP12095@6wind.com> <2601191342CEEE43887BDE71AB97725836AE2DBC@irsmsx105.ger.corp.intel.com> <20160106172248.GT12095@6wind.com> <2601191342CEEE43887BDE71AB97725836AE2F5B@irsmsx105.ger.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" To: "Ananyev, Konstantin" Return-path: Received: from mail-wm0-f50.google.com (mail-wm0-f50.google.com [74.125.82.50]) by dpdk.org (Postfix) with ESMTP id A7C5795C6 for ; Thu, 7 Jan 2016 14:32:47 +0100 (CET) Received: by mail-wm0-f50.google.com with SMTP id b14so123471654wmb.1 for ; Thu, 07 Jan 2016 05:32:47 -0800 (PST) Content-Disposition: inline In-Reply-To: <2601191342CEEE43887BDE71AB97725836AE2F5B@irsmsx105.ger.corp.intel.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, Jan 07, 2016 at 10:24:19AM +0000, Ananyev, Konstantin wrote: >=20 >=20 > > -----Original Message----- > > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] > > Sent: Wednesday, January 06, 2016 5:23 PM > > To: Ananyev, Konstantin > > Cc: N=C3=A9lio Laranjeiro; Tan, Jianfeng; dev@dpdk.org > > Subject: Re: [dpdk-dev] [PATCH 01/12] ethdev: add API to query what/i= f packet type is set > >=20 > > On Wed, Jan 06, 2016 at 04:44:43PM +0000, Ananyev, Konstantin wrote: > > > > > > > > > > -----Original Message----- > > > > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] > > > > Sent: Wednesday, January 06, 2016 3:45 PM > > > > To: Ananyev, Konstantin > > > > Cc: N=C3=A9lio Laranjeiro; Tan, Jianfeng; dev@dpdk.org > > > > Subject: Re: [dpdk-dev] [PATCH 01/12] ethdev: add API to query wh= at/if packet type is set > > > > > > > > On Wed, Jan 06, 2016 at 02:29:07PM +0000, Ananyev, Konstantin wro= te: > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] > > > > > > Sent: Wednesday, January 06, 2016 10:01 AM > > > > > > To: Ananyev, Konstantin > > > > > > Cc: N=C3=A9lio Laranjeiro; Tan, Jianfeng; dev@dpdk.org > > > > > > Subject: Re: [dpdk-dev] [PATCH 01/12] ethdev: add API to quer= y what/if packet type is set > > > > > > > > > > > > On Tue, Jan 05, 2016 at 04:50:31PM +0000, Ananyev, Konstantin= wrote: > > > > > > [...] > > > > > > > > -----Original Message----- > > > > > > > > From: N=C3=A9lio Laranjeiro [mailto:nelio.laranjeiro@6win= d.com] > > > > > > [...] > > > > > > > > I think we miss a comment here in how those 2/6/4 values = are chosen > > > > > > > > because, according to the mask, I expect 16 possibilities= but I get > > > > > > > > less. It will help a lot anyone who needs to add a new t= ype. > > > > > > > > > > > > > > > > Extending the snprintf behavior above, it is best to remo= ve the mask > > > > > > > > argument altogether and have rte_eth_dev_get_ptype_info()= return the > > > > > > > > entire list every time. Applications need to iterate on = the result in > > > > > > > > any case. > > > > > > > > > > > > > > I think we'd better keep mask argument. > > > > > > > In many cases upper layer only interested in some particula= r subset of > > > > > > > all packet types that HW can recognise. > > > > > > > Let say l3fwd only cares about RTE_PTYPE_L3_MASK, it is no= t interested in L4, > > > > > > > tunnelling packet types, etc. > > > > > > > If caller needs to know all recognised ptypes, he can set m= ask=3D=3D-1, > > > > > > > In that case all supported packet types will be returned. > > > > > > > > > > > > There are other drawbacks to the mask argument in my opinion.= The API will > > > > > > have to be updated again as soon as 32 bits aren't enough to = represent all > > > > > > possible masks. We can't predict it will be large enough fore= ver but on the > > > > > > other hand, using uint64_t seems overkill at this point. > > > > > > > > > > Inside rte_mbuf packet_type itself is a 32 bit value. > > > > > These 32 bits are divided into several fields to mark packet ty= pes, > > > > > i.e: bits [0-3] are for all possible L2 types, bits [4-7] for L= 3 types, etc. > > > > > As long as packet_type itself is 32bits, 32bit mask is sufficie= nt. > > > > > If we'll ever run out of 32 bits in packet_type itself, it will= be ABI change anyway. > > > > > > > > Sure, however why not do it now this issue has been raised so thi= s function > > > > doesn't need updating the day it breaks? I know there's a million= other > > > > places with a similar problem but I'm all for making new code fut= ure proof. > > > > > > If rte_mbuf packet_type will have to be increased to 64bit long, th= en > > > this function will have to change anyway (with or without mask para= meter). > > > It will have to become: > > > > > > rte_eth_dev_get_ptype_info(uint8_t portid, uint64_t ptypes[], ...) > > > > > > So I think we don't have to worry about mask parameter itself. > >=20 > > Well, yes, besides I overlooked ptypes[] itself is 32 bit, working ar= ound > > the type width of the mask wouldn't help much. > >=20 > > > > Perhaps in this particular case there is no way to hit the limit = (although > > > > there are only four unused bits left to extend RTE_PTYPE masks) b= ut we've > > > > seen this happen too many times with subsequent ABI breakage. > > > > > > When ptype was introduced we tried to reserve some free space for e= ach layer (L2/L3/L4/...), > > > so it wouldn't be overrun immediately. > > > But of course if there would be a new HW that can recognise dozen n= ew packet types - it is possible. > > > Do you have any particular use-case in mind? > >=20 > > No, that was just to illustrate my point. > >=20 > > > > > > I think this use for masks should be avoided when performance= does not > > > > > > matter much, as in this case, user application cannot know th= e number of > > > > > > entries in advance and must rely on the returned value to ite= rate. > > > > > > > > > > User doesn't know numbers of entries in advance anyway (with an= d without the mask). > > > > > That's why this function was introduced at first place. > > > > > > > > > > With mask it just a bit more handy, in case user cares only abo= ut particular subset of supported > > > > > packet types (only L2 let say). > > > > > > > > OK, so we definitely need something to let applications know the = layer a > > > > given packet type belongs to, I'm sure it can be done in a conven= ient way > > > > that won't be limited to the underlying type of the mask. > > > > > > > > > > A helper function can be added to convert a RTE_PTYPE_* value= to the layer > > > > > > it belongs to (using enum to define possible values). > > > > > > > > > > Not sure what for? > > > > > > > > This is assuming rte_eth_dev_get_ptype_info() doesn't filter anyt= hing (no > > > > "mask" argument). In that case a separate function must be added = to convert > > > > RTE_PTYPE_* values to a layer, so applications can look for inter= esting > > > > packet types while parsing plist[] on their own. > > > > > > Honestly, I don't see why do you need that. > > > You already do know that let say RTE_PTYPE_L3_IPV4 belongs to L3. > > > Why do you need some extra enum here? > > > From my thought - the only purpose of mask parameter was to limit n= umber of elements in the ptypes[] at return. > > > So let say user would need to iterate over 10 elements, instead of = 100 to find > > > the ones he is interested in. > >=20 > > Since this is already a slow manner for retrieving types, 10 or 100 d= oesn't > > make much difference. Such a function shouldn't be used in the data p= ath > > directly. > =20 > Yes, it is not supposed to be called from data-path. >=20 > > My point is, since we're dealing with a slow function, let's keep its= API as > > simple as possible.=20 >=20 > Well, API should be simple, but from other side it has to be flexible a= nd convenient > for the user. > As I user, I would prefer to have an ability to select the layers here = - that's > why I suggested to add the mask parameter.=20 >=20 > >By having a mask to match, a large number of checks are > > added in all PMDs while they could just fill the array without > > bothering.=20 >=20 > That's a valid point. > We could move filter point into rte_ethdev layer. > So PMD would always return an array of all supported ptypes, and > then rte_ethdev layer will filter it based on mask parameter. > Does it sound reasonable to you? Yes, I think it's fine that way, thanks. > >The filtering logic is an application requirement that could be > > useful in its own function as well (converting any random value to it= s > > related layer or mask). > >=20 > > > > This layer information could be defined as an enum, i.e.: > > > > > > > > enum rte_ptype_info { > > > > RTE_PTYPE_UNKNOWN, > > > > RTE_PTYPE_L2, > > > > RTE_PTYPE_L3, > > > > ... > > > > }; > > > > > > > > Or even an int value (2 standing for for "layer 2" etc. Tunnel en= capsulation > > > > wouldn't be described easily that way though). It's just an idea. > > > > > > > > > > If we absolutely want a mean to filter returned values, I sug= gest we use > > > > > > this enum instead of the mask argument. > > > > > > Since it won't be a mask, it won't > > > > > > have to be updated every time a new protocol requires extendi= ng one. > > > > > > > > > > Number of bits PTYPE_L2/L3/L4,... layers are already defined. > > > > > So let say RTE_PTYPE_L2_MASK shouldn't change if you'll add new= L2 ptype - > > > > > there are few reserved values right now. > > > > > if one day we'll run out bits in let say RTE_PTYPE_L2_MASK and= will have to increase its size - > > > > > it would mean change of the packet_type layout and possible ABI= breakage anyway. > > > > > > > > I'm aware of this, only pointing out we tend to rely on masks and= type > > > > boundaries a bit too much when there are other methods that are a= s (if not > > > > more) convenient. > > > > > > Yes, we do rely on masks in ptype. > > > That's how ptype was defined. > > > Let say to check that incoming packet is Ether/IPv4(no extentions)/= UDP, > > > you probably would do: > > > > > > if (mbuf->packet_type & (RTE_PTYPE_L2_MASK | RTE_PTYPE_L3_MASK | RT= E_PTYPE_L4_MASK) =3D=3D > > > (RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP)) {...= } > >=20 > > All right, let's not use a different method to filter packet types. > >=20 > > > > Perhaps some sort of tunneled packet types beyond inner L4 consum= ing the > > > > four remaining bits will be added? That could happen soon. > > > > > > As I said above: do you have particular scenario in mind when 32bit= s for packet_type > > > might be not enough? > > > If yes, then it is probably a good idea to submit an RFC for extend= ing it to 64 bit, > > > or introduce packet_type2, or whatever would be your preferred way = to deal with it. > >=20 > > No, really, I guess we'll extend ptype to 64 bit when necessary. My p= oint on > > filtering separately still stands. > >=20 > > > Konstantin > > > > >=20 > > -- > > Adrien Mazarguil > > 6WIND --=20 Adrien Mazarguil 6WIND