diff mbox

[PATCHv3] linux-generic: packet: streamline packet add/rem data

Message ID 1418901329-32369-1-git-send-email-bill.fischofer@linaro.org
State Accepted
Commit d0b70558a1ed73f57e407c71f706c25990069c19
Headers show

Commit Message

Bill Fischofer Dec. 18, 2014, 11:15 a.m. UTC
Ensure packet parser metadata is copied from old to new packet as part of
add/rem data operations.

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
v3 removes reparsing in all cases

 platform/linux-generic/include/odp_packet_internal.h | 20 ++++++++++++++++++++
 platform/linux-generic/odp_packet.c                  |  6 ++++--
 2 files changed, 24 insertions(+), 2 deletions(-)

Comments

Mike Holmes Dec. 19, 2014, 10 p.m. UTC | #1
Petri

This is the last one we need your review on since you commented on it, with
this I think 0.6.0 is ready

Mike

On 18 December 2014 at 06:15, Bill Fischofer <bill.fischofer@linaro.org>
wrote:

> Ensure packet parser metadata is copied from old to new packet as part of
> add/rem data operations.
>
> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
> ---
> v3 removes reparsing in all cases
>
>  platform/linux-generic/include/odp_packet_internal.h | 20
> ++++++++++++++++++++
>  platform/linux-generic/odp_packet.c                  |  6 ++++--
>  2 files changed, 24 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..a78b3d1 100644
> --- a/platform/linux-generic/odp_packet.c
> +++ b/platform/linux-generic/odp_packet.c
> @@ -396,12 +396,13 @@ 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);
> +                       copy_packet_parser_metadata(pkt_hdr, new_hdr);
>                         odp_packet_free(pkt);
>                 }
>         }
> @@ -431,12 +432,13 @@ 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);
> +                       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
>
diff mbox

Patch

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..a78b3d1 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -396,12 +396,13 @@  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);
+			copy_packet_parser_metadata(pkt_hdr, new_hdr);
 			odp_packet_free(pkt);
 		}
 	}
@@ -431,12 +432,13 @@  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);
+			copy_packet_parser_metadata(pkt_hdr, new_hdr);
 			odp_packet_free(pkt);
 		}
 	}