diff mbox

[PATCHv2,7/8] api: packet: expose new packet APIs for events

Message ID 1421816266-31223-8-git-send-email-bill.fischofer@linaro.org
State New
Headers show

Commit Message

Bill Fischofer Jan. 21, 2015, 4:57 a.m. UTC
Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 platform/linux-generic/include/api/odp_packet.h    | 32 ++++++++++++++++++----
 .../linux-generic/include/odp_packet_internal.h    |  8 +++++-
 platform/linux-generic/odp_packet.c                | 14 ++++++++++
 3 files changed, 48 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/include/api/odp_packet.h b/platform/linux-generic/include/api/odp_packet.h
index 920a593..cdbf217 100644
--- a/platform/linux-generic/include/api/odp_packet.h
+++ b/platform/linux-generic/include/api/odp_packet.h
@@ -51,7 +51,7 @@  extern "C" {
  * Allocate a packet from a buffer pool
  *
  * Allocates a packet of the requested length from the specified buffer pool.
- * Pool must have been created with buffer type ODP_BUFFER_TYPE_PACKET. The
+ * Pool must have been created with ODP_POOL_PACKET type. The
  * packet is initialized with data pointers and lengths set according to the
  * specified len, and the default headroom and tailroom length settings. All
  * other packet metadata are set to their default values.
@@ -66,7 +66,7 @@  extern "C" {
  * the ODP_CONFIG_PACKET_HEADROOM and ODP_CONFIG_PACKET_TAILROOM defines in
  * odp_config.h.
  */
-odp_packet_t odp_packet_alloc(odp_buffer_pool_t pool, uint32_t len);
+odp_packet_t odp_packet_alloc(odp_pool_t pool, uint32_t len);
 
 /**
  * Free packet
@@ -96,6 +96,28 @@  void odp_packet_free(odp_packet_t pkt);
 int odp_packet_reset(odp_packet_t pkt, uint32_t len);
 
 /**
+ * Get packet handle from event
+ *
+ * Converts an ODP_EVENT_PACKET type event to a packet.
+ *
+ * @param ev   Event handle
+ *
+ * @return Packet handle
+ *
+ * @see odp_event_type()
+ */
+odp_packet_t odp_packet_from_event(odp_event_t ev);
+
+/**
+ * Convert packet handle to event
+ *
+ * @param buf  Packet handle
+ *
+ * @return Event handle
+ */
+odp_event_t odp_packet_to_event(odp_packet_t pkt);
+
+/**
  * Convert a buffer handle to a packet handle
  *
  * @param buf  Buffer handle
@@ -380,7 +402,7 @@  void *odp_packet_offset(odp_packet_t pkt, uint32_t offset, uint32_t *len,
  *
  * @return Buffer pool handle
  */
-odp_buffer_pool_t odp_packet_pool(odp_packet_t pkt);
+odp_pool_t odp_packet_pool(odp_packet_t pkt);
 
 /**
  * Packet input interface
@@ -771,14 +793,14 @@  odp_packet_t odp_packet_rem_data(odp_packet_t pkt, uint32_t offset,
  *
  * Create a new copy of the packet. The new packet is exact copy of the source
  * packet (incl. data and metadata). The pool must have been created with
- * buffer type ODP_BUFFER_TYPE_PACKET.
+ * ODP_POOL_PACKET type.
  *
  * @param pkt   Packet handle
  * @param pool  Buffer pool for allocation of the new packet.
  *
  * @return Handle to the copy of the packet, or ODP_PACKET_INVALID
  */
-odp_packet_t odp_packet_copy(odp_packet_t pkt, odp_buffer_pool_t pool);
+odp_packet_t odp_packet_copy(odp_packet_t pkt, odp_pool_t pool);
 
 /**
  * Copy data from packet
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index 179330c..0ebc14b 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -253,10 +253,16 @@  int _odp_packet_copy_to_packet(odp_packet_t srcpkt, uint32_t srcoffset,
 			       odp_packet_t dstpkt, uint32_t dstoffset,
 			       uint32_t len);
 
-odp_packet_t _odp_packet_alloc(odp_buffer_pool_t pool_hdl);
+odp_packet_t _odp_packet_alloc(odp_pool_t pool_hdl);
 
 int _odp_packet_parse(odp_packet_t pkt);
 
+/* Convert a packet handle to a buffer handle */
+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);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 257abec..1345618 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -25,6 +25,7 @@ 
  *
  */
 
+odp_packet_t odp_packet_alloc(odp_pool_t pool_hdl, uint32_t len)
 odp_packet_t odp_packet_alloc(odp_buffer_pool_t pool_hdl, uint32_t len)
 {
 	pool_entry_t *pool = odp_pool_to_entry(pool_hdl);
@@ -75,6 +76,16 @@  odp_buffer_t odp_packet_to_buffer(odp_packet_t pkt)
 	return (odp_buffer_t)pkt;
 }
 
+odp_packet_t odp_packet_from_event(odp_event_t ev)
+{
+	return (odp_packet_t)ev;
+}
+
+odp_event_t odp_packet_to_event(odp_packet_t pkt)
+{
+	return (odp_event_t)pkt;
+}
+
 /*
  *
  * Pointers and lengths
@@ -199,6 +210,7 @@  void *odp_packet_offset(odp_packet_t pkt, uint32_t offset, uint32_t *len,
  *
  */
 
+odp_pool_t odp_packet_pool(odp_packet_t pkt)
 odp_buffer_pool_t odp_packet_pool(odp_packet_t pkt)
 {
 	return odp_packet_hdr(pkt)->buf_hdr.pool_hdl;
@@ -453,6 +465,7 @@  odp_packet_t odp_packet_rem_data(odp_packet_t pkt, uint32_t offset,
  *
  */
 
+odp_packet_t odp_packet_copy(odp_packet_t pkt, odp_pool_t pool)
 odp_packet_t odp_packet_copy(odp_packet_t pkt, odp_buffer_pool_t pool)
 {
 	odp_packet_hdr_t *srchdr = odp_packet_hdr(pkt);
@@ -613,6 +626,7 @@  int _odp_packet_copy_to_packet(odp_packet_t srcpkt, uint32_t srcoffset,
 	return 0;
 }
 
+odp_packet_t _odp_packet_alloc(odp_pool_t pool_hdl)
 odp_packet_t _odp_packet_alloc(odp_buffer_pool_t pool_hdl)
 {
 	pool_entry_t *pool = odp_pool_to_entry(pool_hdl);