From: "Wiles, Keith" <keith.wiles@intel.com>
To: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
Cc: "Richardson, Bruce" <bruce.richardson@intel.com>,
"Nélio Laranjeiro" <nelio.laranjeiro@6wind.com>,
"dev@dpdk.org" <dev@dpdk.org>,
"Olivier Matz" <olivier.matz@6wind.com>,
"Lu, Wenzhuo" <wenzhuo.lu@intel.com>,
"Adrien Mazarguil" <adrien.mazarguil@6wind.com>
Subject: Re: [dpdk-dev] [PATCH] net: introduce big and little endian types
Date: Tue, 6 Dec 2016 14:56:53 +0000 [thread overview]
Message-ID: <7E1BBBA1-F384-4235-8A82-4B0D6DC0889C@intel.com> (raw)
In-Reply-To: <2601191342CEEE43887BDE71AB9772583F0E47E1@irsmsx105.ger.corp.intel.com>
> On Dec 6, 2016, at 8:45 AM, Ananyev, Konstantin <konstantin.ananyev@intel.com> wrote:
>
>
>
>>
>> On Tue, Dec 06, 2016 at 12:41:00PM +0000, Ananyev, Konstantin wrote:
>>>
>>>
>>>> -----Original Message-----
>>>> From: Richardson, Bruce
>>>> Sent: Tuesday, December 6, 2016 11:55 AM
>>>> To: Ananyev, Konstantin <konstantin.ananyev@intel.com>
>>>> Cc: Nélio Laranjeiro <nelio.laranjeiro@6wind.com>; dev@dpdk.org; Olivier Matz <olivier.matz@6wind.com>; Lu, Wenzhuo
>>>> <wenzhuo.lu@intel.com>; Adrien Mazarguil <adrien.mazarguil@6wind.com>
>>>> Subject: Re: [dpdk-dev] [PATCH] net: introduce big and little endian types
>>>>
>>>> On Tue, Dec 06, 2016 at 11:23:42AM +0000, Ananyev, Konstantin wrote:
>>>>> Hi Neilo,
>>>>>
>>>>>
>>>>> Hi Neilo,
>>>>>>>>
>>>>>>>> This commit introduces new rte_{le,be}{16,32,64}_t types and updates
>>>>>>>> rte_{le,be,cpu}_to_{le,be,cpu}_*() and network header structures
>>>>>>>> accordingly.
>>>>>>>>
>>>>>>>> Specific big/little endian types avoid uncertainty and conversion mistakes.
>>>>>>>>
>>>>>>>> No ABI change since these are simply typedefs to the original types.
>>>>>>>
>>>>>>> It seems like quite a lot of changes...
>>>>>>> Could you probably explain what will be the benefit in return?
>>>>>>> Konstantin
>>>>>>
>>>>>> Hi Konstantin,
>>>>>>
>>>>>> The benefit is to provide documented byte ordering for data types
>>>>>> software is manipulating to determine when network to CPU (or CPU to
>>>>>> network) conversion must be performed.
>>>>>
>>>>> Ok, but is it really worth it?
>>>>> User can still make a mistake and forget to call ntoh()/hton() at some particular place.
>>>>> From other side most people do know that network protocols headers are usually in BE format.
>>>>> I would understand the effort, if we'll have some sort of tool that would do some sort of static code analysis
>>>>> based on these special types or so.
>>>>> Again, does it mean that we should go and change uint32_t to rte_le_32 inside all Intel PMDs
>>>>> (and might be in some others too) to be consistent?
>>>>> Konstantin
>>>>>
>>>>
>>>> I actually quite like this patch as I think it will help make things
>>>> clear when the user is possibly doing something wrong. I don't think we
>>>> need to globally change all PMDs to use the types, though.
>>>
>>> Ok, so where do you believe we should draw a line?
>>> Why let say inside lib/librte_net people should use these typedefs, but
>>> inside drivers/net/ixgbe they don't?
>>
>> Because those are not public APIs. It would be great if driver writers
>> used the typedefs, but I don't think it should be mandatory.
>
> Ok, so only public API would have to use these typedefs when appropriate, correct?
> I still think that the effort to make these changes and keep this rule outweighs the benefit,
> but ok if everyone else think it is useful - I wouldn't object too much.
I believe the effort and advantages to this change have no real benefit when you can document the type in the function header. Adding a structure around the simple type just adds more typing and still will be difficult to manage even if it gives some compiler checking. The change would not prevent someone putting a BE value into a LE variable, right?
I would not like to see this type of change when documentation would be enough here. Breaking the ABI is a big thing here for a large number of APIs. We keep breaking the ABI and we need to stop doing it on every release of DPDK.
>
>>
>>>
>>>>
>>>> One thing I'm wondering though, is if we might want to take this
>>>> further. For little endian environments, we could define the big endian
>>>> types as structs using typedefs, and similarly the le types on be
>>>> platforms, so that assigning from the non-native type to the native one
>>>> without a transformation function would cause a compiler error.
>>>
>>> Not sure I understand you here.
>>> Could you possibly provide some example?
>>>
>> typedef struct {
>> short val;
>> } rte_be16_t;
>
> Hmm, so:
> uint32_t x = rte_be_to_cpu_32(1);
> would suddenly stop compiling?
> That definitely looks like an ABI breakage to me.
> Konstantin
>
>>
>> That way if you try to assign a value of type rte_be16_t to a uint16_t
>> variable you'll get a compiler error, unless you use an appropriate
>> conversion function. In short, it changes things from not just looking
>> wrong - which is the main purpose of Neilo's patchset - to actually
>> making it incorrect from the compiler's point of view too.
>>
>> /Bruce
Regards,
Keith
next prev parent reply other threads:[~2016-12-06 14:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-09 15:04 Nelio Laranjeiro
2016-12-05 10:09 ` Ananyev, Konstantin
2016-12-05 12:06 ` Nélio Laranjeiro
2016-12-06 11:23 ` Ananyev, Konstantin
2016-12-06 11:55 ` Bruce Richardson
2016-12-06 12:41 ` Ananyev, Konstantin
2016-12-06 13:34 ` Bruce Richardson
2016-12-06 14:45 ` Ananyev, Konstantin
2016-12-06 14:56 ` Wiles, Keith [this message]
2016-12-06 15:34 ` Morten Brørup
2016-12-06 16:28 ` Nélio Laranjeiro
2016-12-06 16:31 ` Wiles, Keith
2016-12-06 16:36 ` Richardson, Bruce
2016-12-06 17:00 ` Ananyev, Konstantin
2016-12-06 17:29 ` Neil Horman
2016-12-06 13:14 ` Nélio Laranjeiro
2016-12-06 13:30 ` Bruce Richardson
2016-12-06 14:06 ` Wiles, Keith
2016-12-08 9:30 ` Nélio Laranjeiro
2016-12-08 13:59 ` Wiles, Keith
2016-12-08 16:06 ` Thomas Monjalon
2016-12-08 15:07 ` Neil Horman
2016-12-08 15:10 ` Ananyev, Konstantin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7E1BBBA1-F384-4235-8A82-4B0D6DC0889C@intel.com \
--to=keith.wiles@intel.com \
--cc=adrien.mazarguil@6wind.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=konstantin.ananyev@intel.com \
--cc=nelio.laranjeiro@6wind.com \
--cc=olivier.matz@6wind.com \
--cc=wenzhuo.lu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).