diff mbox series

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

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

Commit Message

Github ODP bot July 20, 2017, 8 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 82 (Bill-Fischofer-Linaro:pktrefs)
 ** https://github.com/Linaro/odp/pull/82
 ** Patch: https://github.com/Linaro/odp/pull/82.patch
 ** Base sha: 3eeb249a4774f12d2d16ca349a591654eae620ae
 ** Merge commit sha: f6e0d4b8b10f1803fb4513254c404df31e3f9f3f
 **/
 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 396d8cb5..e5887c9b 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -216,6 +216,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 38879a7f..8806be8a 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;