diff mbox

[v2,1/2] linux-generic: packet_flags: use accessors to modify eth and l2 flag

Message ID 1458321603-23979-2-git-send-email-zoltan.kiss@linaro.org
State Accepted
Commit 7630edb0c33731cd59492bfdd8596e3f4cf01753
Headers show

Commit Message

Zoltan Kiss March 18, 2016, 5:20 p.m. UTC
This makes it possible for other implementations like ODP-DPDK to reuse
classification code while using a different packet API.

Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org>
---
 platform/linux-generic/include/odp_classification_inlines.h |  2 +-
 platform/linux-generic/include/odp_packet_internal.h        | 10 ++++++++++
 platform/linux-generic/odp_classification.c                 |  4 ++--
 3 files changed, 13 insertions(+), 3 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 8bd010d..bac5b48 100644
--- a/platform/linux-generic/include/odp_classification_inlines.h
+++ b/platform/linux-generic/include/odp_classification_inlines.h
@@ -162,7 +162,7 @@  static inline int verify_pmr_dmac(const uint8_t *pkt_addr,
 	uint64_t dmac_be = 0;
 	const odph_ethhdr_t *eth;
 
-	if (!pkt_hdr->input_flags.eth)
+	if (!packet_hdr_has_eth(pkt_hdr))
 		return 0;
 
 	eth = (const odph_ethhdr_t *)(pkt_addr + pkt_hdr->l2_offset);
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index b632ece..7974a20 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -267,6 +267,16 @@  odp_buffer_t _odp_packet_to_buffer(odp_packet_t pkt);
 /* Convert a buffer handle to a packet handle */
 odp_packet_t _odp_packet_from_buffer(odp_buffer_t buf);
 
+static inline int packet_hdr_has_l2(odp_packet_hdr_t *pkt_hdr)
+{
+	return pkt_hdr->input_flags.l2;
+}
+
+static inline int packet_hdr_has_eth(odp_packet_hdr_t *pkt_hdr)
+{
+	return pkt_hdr->input_flags.eth;
+}
+
 int _odp_parse_common(odp_packet_hdr_t *pkt_hdr, const uint8_t *parseptr);
 
 int _odp_cls_parse(odp_packet_hdr_t *pkt_hdr, const uint8_t *parseptr);
diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c
index 6c9f7c1..f5e4673 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -843,8 +843,8 @@  cos_t *match_qos_l2_cos(pmr_l2_cos_t *l2_cos, const uint8_t *pkt_addr,
 	const odph_vlanhdr_t *vlan;
 	uint16_t qos;
 
-	if (hdr->input_flags.l2 && hdr->input_flags.vlan &&
-	    hdr->input_flags.eth) {
+	if (packet_hdr_has_l2(hdr) && hdr->input_flags.vlan &&
+	    packet_hdr_has_eth(hdr)) {
 		eth = (const odph_ethhdr_t *)(pkt_addr + hdr->l2_offset);
 		vlan = (const odph_vlanhdr_t *)(&eth->type);
 		qos = odp_be_to_cpu_16(vlan->tci);