diff mbox series

[v3,4/10] linux-generic: packet: add initializations for new hdr fields

Message ID 1501599610-28388-5-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [v3,1/10] linux-generic: packet: restructure inline routines to use macros | expand

Commit Message

Github ODP bot Aug. 1, 2017, 3 p.m. UTC
From: Bill Fischofer <bill.fischofer@linaro.org>


Add initializations for new packet hdr fields needed to support
packet references.

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

---
/** Email created from pull request 90 (Bill-Fischofer-Linaro:pktrefs)
 ** https://github.com/Linaro/odp/pull/90
 ** Patch: https://github.com/Linaro/odp/pull/90.patch
 ** Base sha: bb0ca193f8c28036fdf8b3d6c8aa5d4f11980e6c
 ** Merge commit sha: dfef320840f96825686124135a6e509db80b7b82
 **/
 platform/linux-generic/include/odp_packet_internal.h | 4 ++++
 platform/linux-generic/odp_packet.c                  | 5 +++++
 2 files changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index 8c83966c..2207ac58 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -222,6 +222,10 @@  static inline void packet_init(odp_packet_hdr_t *pkt_hdr, uint32_t len)
 			     CONFIG_PACKET_TAILROOM;
 
 	pkt_hdr->input = ODP_PKTIO_INVALID;
+
+	/* By default packet has no references */
+	pkt_hdr->unshared_len = len;
+	pkt_hdr->ref_hdr = NULL;
 }
 
 static inline void copy_packet_parser_metadata(odp_packet_hdr_t *src_hdr,
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 988045e4..41262cc2 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -253,6 +253,9 @@  void packet_parse_reset(odp_packet_hdr_t *pkt_hdr)
 	pkt_hdr->p.l2_offset        = 0;
 	pkt_hdr->p.l3_offset        = ODP_PACKET_OFFSET_INVALID;
 	pkt_hdr->p.l4_offset        = ODP_PACKET_OFFSET_INVALID;
+
+	/* Ensure dummy pkt hdrs used in I/O recv classification are valid */
+	pkt_hdr->ref_hdr = NULL;
 }
 
 static inline void init_segments(odp_packet_hdr_t *pkt_hdr[], int num)
@@ -265,6 +268,7 @@  static inline void init_segments(odp_packet_hdr_t *pkt_hdr[], int num)
 
 	hdr->buf_hdr.seg[0].data = hdr->buf_hdr.base_data;
 	hdr->buf_hdr.seg[0].len  = BASE_LEN;
+	packet_ref_count_set(hdr, 1);
 
 	/* Link segments */
 	if (CONFIG_PACKET_MAX_SEGS != 1) {
@@ -274,6 +278,7 @@  static inline void init_segments(odp_packet_hdr_t *pkt_hdr[], int num)
 			for (i = 1; i < num; i++) {
 				odp_buffer_hdr_t *buf_hdr;
 
+				packet_ref_count_set(pkt_hdr[i], 1);
 				buf_hdr = &pkt_hdr[i]->buf_hdr;
 				hdr->buf_hdr.seg[i].hdr  = buf_hdr;
 				hdr->buf_hdr.seg[i].data = buf_hdr->base_data;