> -----Original Message----- > From: lng-odp-boun...@lists.linaro.org [mailto:lng-odp- > boun...@lists.linaro.org] On Behalf Of ext Bill Fischofer > Sent: Wednesday, December 17, 2014 3:57 AM > To: lng-odp@lists.linaro.org > Subject: [lng-odp] [PATCHv2] linux-generic: packet: streamline packet > add/rem data > > Ensure packet perser metadata is copied from old to new packet as part of > add/rem data operations that omit packet reparsing. > > Signed-off-by: Bill Fischofer <bill.fischo...@linaro.org> > --- > v2 Ensures that parser metadata is copied if we're not reparsing > > platform/linux-generic/include/odp_packet_internal.h | 20 > ++++++++++++++++++++ > platform/linux-generic/odp_packet.c | 12 ++++++++++-- > 2 files changed, 30 insertions(+), 2 deletions(-) > > diff --git a/platform/linux-generic/include/odp_packet_internal.h > b/platform/linux-generic/include/odp_packet_internal.h > index 068f969..54a12b5 100644 > --- a/platform/linux-generic/include/odp_packet_internal.h > +++ b/platform/linux-generic/include/odp_packet_internal.h > @@ -187,6 +187,26 @@ static inline void packet_init(pool_entry_t *pool, > (pool->s.headroom + size); > } > > +static inline void copy_packet_parser_metadata(odp_packet_hdr_t *src_hdr, > + odp_packet_hdr_t *dst_hdr) > +{ > + dst_hdr->input_flags = src_hdr->input_flags; > + dst_hdr->error_flags = src_hdr->error_flags; > + dst_hdr->output_flags = src_hdr->output_flags; > + > + dst_hdr->l2_offset = src_hdr->l2_offset; > + dst_hdr->l3_offset = src_hdr->l3_offset; > + dst_hdr->l4_offset = src_hdr->l4_offset; > + dst_hdr->payload_offset = src_hdr->payload_offset; > + > + dst_hdr->vlan_s_tag = src_hdr->vlan_s_tag; > + dst_hdr->vlan_c_tag = src_hdr->vlan_c_tag; > + dst_hdr->l3_protocol = src_hdr->l3_protocol; > + dst_hdr->l3_len = src_hdr->l3_len; > + dst_hdr->l4_protocol = src_hdr->l4_protocol; > + dst_hdr->l4_len = src_hdr->l4_len; > +} > + > static inline void *packet_map(odp_packet_hdr_t *pkt_hdr, > uint32_t offset, uint32_t *seglen) > { > diff --git a/platform/linux-generic/odp_packet.c b/platform/linux- > generic/odp_packet.c > index 65e6288..43a9419 100644 > --- a/platform/linux-generic/odp_packet.c > +++ b/platform/linux-generic/odp_packet.c > @@ -396,12 +396,16 @@ odp_packet_t odp_packet_add_data(odp_packet_t pkt, > uint32_t offset, > newpkt = ODP_PACKET_INVALID; > } else { > odp_packet_hdr_t *new_hdr = odp_packet_hdr(newpkt); > + new_hdr->input = pkt_hdr->input; > new_hdr->buf_hdr.buf_u64 = pkt_hdr->buf_hdr.buf_u64; > odp_atomic_store_u32( > &new_hdr->buf_hdr.ref_count, > odp_atomic_load_u32( > &pkt_hdr->buf_hdr.ref_count)); > - _odp_packet_parse(newpkt); > + if (offset < pkt_hdr->payload_offset) > + _odp_packet_parse(newpkt);
" Handles and pointers must be updated after the operation. User is responsible to update packet meta-data offsets when needed." The operation must not parse the packet again and thus overwrite existing meta-data. E.g. application may have removed all the headers from the packet at this point. Just copy old meta-data to the new packet. From application point of view this operation just added packet length at the offset and returned a new handle to the same packet. Application will update offsets/flags as needed. -Petri > + else > + copy_packet_parser_metadata(pkt_hdr, new_hdr); > odp_packet_free(pkt); > } > } > @@ -431,12 +435,16 @@ odp_packet_t odp_packet_rem_data(odp_packet_t pkt, > uint32_t offset, > newpkt = ODP_PACKET_INVALID; > } else { > odp_packet_hdr_t *new_hdr = odp_packet_hdr(newpkt); > + new_hdr->input = pkt_hdr->input; > new_hdr->buf_hdr.buf_u64 = pkt_hdr->buf_hdr.buf_u64; > odp_atomic_store_u32( > &new_hdr->buf_hdr.ref_count, > odp_atomic_load_u32( > &pkt_hdr->buf_hdr.ref_count)); > - _odp_packet_parse(newpkt); > + if (offset < pkt_hdr->payload_offset) > + _odp_packet_parse(newpkt); > + else > + copy_packet_parser_metadata(pkt_hdr, new_hdr); > odp_packet_free(pkt); > } > } > -- > 1.8.3.2 > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/lng-odp _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp