diff mbox series

[API-NEXT,v1,2/3] linux-gen: packet: implementation subtype api

Message ID 1533816007-30726-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v1,1/3] api: packet: add subtype call | expand

Commit Message

Github ODP bot Aug. 9, 2018, noon UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


Add inlined implementation of the new subtype API call and use
that internally.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
/** Email created from pull request 669 (psavol:next-packet-subtype)
 ** https://github.com/Linaro/odp/pull/669
 ** Patch: https://github.com/Linaro/odp/pull/669.patch
 ** Base sha: 9b2b5a9695ad66977c964c83691cd2fef4c45b85
 ** Merge commit sha: 3a6201b601ab55e07cbfd561fa9904ba48035478
 **/
 .../include/odp/api/plat/packet_inline_types.h             | 1 +
 .../linux-generic/include/odp/api/plat/packet_inlines.h    | 7 +++++++
 platform/linux-generic/include/odp_packet_internal.h       | 5 -----
 platform/linux-generic/odp_event.c                         | 5 +++--
 platform/linux-generic/odp_packet.c                        | 3 ++-
 platform/linux-generic/pktio/loop.c                        | 3 ++-
 6 files changed, 15 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/platform/linux-generic/include/odp/api/plat/packet_inline_types.h b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h
index 9a285fe4a..ca3abbfab 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_inline_types.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h
@@ -45,6 +45,7 @@  typedef struct _odp_packet_inline_offset_t {
 	uint16_t timestamp;
 	uint16_t input_flags;
 	uint16_t flags;
+	uint16_t subtype;
 
 } _odp_packet_inline_offset_t;
 
diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_inlines.h
index e2c32728c..ec5beb819 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h
@@ -19,6 +19,7 @@ 
 #include <odp/api/hints.h>
 #include <odp/api/time.h>
 #include <odp/api/abi/buffer.h>
+#include <odp/api/abi/event.h>
 
 #include <odp/api/plat/packet_inline_types.h>
 #include <odp/api/plat/pool_inline_types.h>
@@ -64,6 +65,7 @@ 
 	#define odp_packet_to_event __odp_packet_to_event
 	#define odp_packet_from_event_multi __odp_packet_from_event_multi
 	#define odp_packet_to_event_multi __odp_packet_to_event_multi
+	#define odp_packet_subtype __odp_packet_subtype
 #else
 	#undef _ODP_INLINE
 	#define _ODP_INLINE
@@ -355,6 +357,11 @@  _ODP_INLINE void odp_packet_to_event_multi(const odp_packet_t pkt[],
 		ev[i] = odp_packet_to_event(pkt[i]);
 }
 
+_ODP_INLINE odp_event_subtype_t odp_packet_subtype(odp_packet_t pkt)
+{
+	return (odp_event_subtype_t)_odp_pkt_get(pkt, int8_t, subtype);
+}
+
 /** @endcond */
 
 #endif
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index cd2db2ecd..9b995c61c 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -155,11 +155,6 @@  static inline seg_entry_t *seg_entry_last(odp_packet_hdr_t *hdr)
 	return &last->buf_hdr.seg[last_seg];
 }
 
-static inline odp_event_subtype_t packet_subtype(odp_packet_t pkt)
-{
-	return packet_hdr(pkt)->subtype;
-}
-
 static inline void packet_subtype_set(odp_packet_t pkt, int ev)
 {
 	packet_hdr(pkt)->subtype = ev;
diff --git a/platform/linux-generic/odp_event.c b/platform/linux-generic/odp_event.c
index fa20af5f5..bb378528b 100644
--- a/platform/linux-generic/odp_event.c
+++ b/platform/linux-generic/odp_event.c
@@ -19,6 +19,7 @@ 
 
 /* Inlined API functions */
 #include <odp/api/plat/event_inlines.h>
+#include <odp/api/plat/packet_inlines.h>
 
 odp_event_subtype_t odp_event_subtype(odp_event_t event)
 {
@@ -26,7 +27,7 @@  odp_event_subtype_t odp_event_subtype(odp_event_t event)
 			ODP_EVENT_PACKET)
 		return ODP_EVENT_NO_SUBTYPE;
 
-	return packet_subtype(odp_packet_from_event(event));
+	return odp_packet_subtype(odp_packet_from_event(event));
 }
 
 odp_event_type_t odp_event_types(odp_event_t event,
@@ -36,7 +37,7 @@  odp_event_type_t odp_event_types(odp_event_t event,
 	odp_event_type_t event_type = _odp_buffer_event_type(buf);
 
 	*subtype = event_type == ODP_EVENT_PACKET ?
-			packet_subtype(odp_packet_from_event(event)) :
+			odp_packet_subtype(odp_packet_from_event(event)) :
 			ODP_EVENT_NO_SUBTYPE;
 
 	return event_type;
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 11f8bd43d..7bb93e1e1 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -50,7 +50,8 @@  const _odp_packet_inline_offset_t ODP_ALIGNED_CACHE _odp_packet_inline = {
 	.flow_hash      = offsetof(odp_packet_hdr_t, flow_hash),
 	.timestamp      = offsetof(odp_packet_hdr_t, timestamp),
 	.input_flags    = offsetof(odp_packet_hdr_t, p.input_flags),
-	.flags          = offsetof(odp_packet_hdr_t, p.flags)
+	.flags          = offsetof(odp_packet_hdr_t, p.flags),
+	.subtype        = offsetof(odp_packet_hdr_t, subtype)
 
 };
 
diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c
index faaef3ab5..4c0cba3f9 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -18,6 +18,7 @@ 
 #include <odp/api/hints.h>
 #include <odp/api/plat/byteorder_inlines.h>
 #include <odp_queue_if.h>
+#include <odp/api/plat/packet_inlines.h>
 
 #include <protocols/eth.h>
 #include <protocols/ip.h>
@@ -309,7 +310,7 @@  static int loopback_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
 	for (i = 0; i < nb_tx; ++i) {
 		odp_ipsec_packet_result_t result;
 
-		if (packet_subtype(pkt_tbl[i]) ==
+		if (odp_packet_subtype(pkt_tbl[i]) ==
 				ODP_EVENT_PACKET_IPSEC &&
 		    pktio_entry->s.config.outbound_ipsec) {