pool can have segments layout in it's capabilities and if needed on thread creating we can check that odp_packet_data() will not be uses cross segments.
Maxim. On 15 February 2018 at 17:42, Savolainen, Petri (Nokia - FI/Espoo) < petri.savolai...@nokia.com> wrote: > > > > -----Original Message----- > > From: Dmitry Eremin-Solenikov [mailto:dmitry.ereminsoleni...@linaro.org] > > Sent: Thursday, February 15, 2018 4:00 PM > > To: Savolainen, Petri (Nokia - FI/Espoo) <petri.savolai...@nokia.com>; > > Bill Fischofer <bill.fischo...@linaro.org> > > Cc: lng-odp-forward <lng-odp@lists.linaro.org> > > Subject: Re: [lng-odp] odp_packet_data() considered harmful > > > > On 15/02/18 16:32, Savolainen, Petri (Nokia - FI/Espoo) wrote: > > > > > odp_packet_offset() is more complex than the proposed > > odp_packet_data_seg_len(). Application mostly finds its data from the > > first segment, so it's important to keep the most common use case fast > (== > > simple). We cannot and should not modify/remove current data() and > > offset() functions. But we can add another which combines data() + > > seg_len(), which is mostly enough for application. When application knows > > already that all (interesting) data is in the first segment, it can use > > data() which is the fastest and simplest function (to inline) to get > > access to the data. > > > > I'm fine with proposed odp_packet_data_seg_len() if that will allow us > > to drop odp_packet_data(). > > There's no need or possibility to remove data(). Documentation for data() > may be improved to be more explicit about possibility of multiple segments. > The function just returns pointer to current head of data, it does not > promise anything more. When application knows already how much data follows > (and usually all data follows), it does not need ask e.g. segment length > over and over again. > > static inline void* odp_packet_data(pkt) { > return (pkt_desc_t)pkt->data_ptr; > } > > static inline void* odp_packet_data_seg_len(pkt, *len) { > *len = (pkt_desc_t)pkt->seg_len; > return (pkt_desc_t)pkt->data_ptr; > } > > The first is faster when application does not need to ask the segment > length. > > -Petri > >