diff mbox

[v3] linux-generic: packet: hide frame_len behind accessor

Message ID 1453464963-26449-1-git-send-email-zoltan.kiss@linaro.org
State Accepted
Commit 57c5e20fa8eb4839548f60c500b15fa6c1b91af1
Headers show

Commit Message

Zoltan Kiss Jan. 22, 2016, 12:16 p.m. UTC
The classification code accesses this variable directly, which prevents
reusing that code e.g. in ODP-DPDK.

Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org>
Reviewed-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
---
v2: rename it packet_len(), to align with packet_set_len()

v3: fix code style

 platform/linux-generic/include/odp_classification_inlines.h | 5 +++--
 platform/linux-generic/include/odp_packet_internal.h        | 5 +++++
 2 files changed, 8 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_classification_inlines.h b/platform/linux-generic/include/odp_classification_inlines.h
index e9739aa..5f0b564 100644
--- a/platform/linux-generic/include/odp_classification_inlines.h
+++ b/platform/linux-generic/include/odp_classification_inlines.h
@@ -24,6 +24,7 @@  extern "C" {
 #include <odp/helper/ipsec.h>
 #include <odp/helper/udp.h>
 #include <odp/helper/tcp.h>
+#include <odp_packet_internal.h>
 
 /* PMR term value verification function
 These functions verify the given PMR term value with the value in the packet
@@ -33,7 +34,7 @@  These following functions return 1 on success and 0 on failure
 static inline int verify_pmr_packet_len(odp_packet_hdr_t *pkt_hdr,
 					pmr_term_value_t *term_value)
 {
-	if (term_value->val == (pkt_hdr->frame_len &
+	if (term_value->val == (packet_len(pkt_hdr) &
 				     term_value->mask))
 		return 1;
 
@@ -240,7 +241,7 @@  static inline int verify_pmr_custom_frame(const uint8_t *pkt_addr,
 
 	ODP_ASSERT(val_sz <= ODP_PMR_TERM_BYTES_MAX);
 
-	if (pkt_hdr->frame_len <= offset + val_sz)
+	if (packet_len(pkt_hdr) <= offset + val_sz)
 		return 0;
 
 	memcpy(&val, pkt_addr + offset, val_sz);
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index 12e9cca..85d4924 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -214,6 +214,11 @@  static inline void pull_tail(odp_packet_hdr_t *pkt_hdr, size_t len)
 	pkt_hdr->frame_len -= len;
 }
 
+static inline uint32_t packet_len(odp_packet_hdr_t *pkt_hdr)
+{
+	return pkt_hdr->frame_len;
+}
+
 static inline void packet_set_len(odp_packet_t pkt, uint32_t len)
 {
 	odp_packet_hdr(pkt)->frame_len = len;