diff mbox

[ODP/PATCHv1,2/3] Buffer Management changes for sync with classification

Message ID 1416222221-17496-2-git-send-email-bala.manoharan@linaro.org
State New
Headers show

Commit Message

Balasubramanian Manoharan Nov. 17, 2014, 11:03 a.m. UTC
This patch contains Buffer Management changes synced for classification compilation.
This patch will have to be redone once Packet Management change has been synced in repo.

Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
---
 helper/include/odph_ip.h                           |  6 +++
 helper/include/odph_tcp.h                          | 61 ++++++++++++++++++++++
 .../include/odp_buffer_pool_internal.h             | 10 ++++
 platform/linux-generic/odp_buffer_pool.c           | 10 ----
 4 files changed, 77 insertions(+), 10 deletions(-)
 create mode 100644 helper/include/odph_tcp.h
diff mbox

Patch

diff --git a/helper/include/odph_ip.h b/helper/include/odph_ip.h
index 2c83c0f..f78724e 100644
--- a/helper/include/odph_ip.h
+++ b/helper/include/odph_ip.h
@@ -35,6 +35,9 @@  extern "C" {
 /** @internal Returns IPv4 header length */
 #define ODPH_IPV4HDR_IHL(ver_ihl) ((ver_ihl) & 0x0f)
 
+/** @internal Returns IPv4 DSCP */
+#define ODPH_IPV4HDR_DSCP(tos) (((tos) & 0xfc) >> 2)
+
 /** @internal Returns IPv4 Don't fragment */
 #define ODPH_IPV4HDR_FLAGS_DONT_FRAG(frag_offset)  ((frag_offset) & 0x4000)
 
@@ -47,6 +50,9 @@  extern "C" {
 /** @internal Returns true if IPv4 packet is a fragment */
 #define ODPH_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset) & 0x3fff)
 
+/** @internal Returns IPv4 DSCP */
+#define ODPH_IPV6HDR_DSCP(ver_tc_flow) (uint8_t)((((ver_tc_flow) & 0x0fc00000) >> 22) & 0xff)
+
 /** IPv4 header */
 typedef struct ODP_PACKED {
 	uint8_t    ver_ihl;     /**< Version / Header length */
diff --git a/helper/include/odph_tcp.h b/helper/include/odph_tcp.h
new file mode 100644
index 0000000..4c5912b
--- /dev/null
+++ b/helper/include/odph_tcp.h
@@ -0,0 +1,61 @@ 
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+
+/**
+ * @file
+ *
+ * ODP TCP header
+ */
+
+#ifndef ODPH_TCP_H_
+#define ODPH_TCP_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp_align.h>
+#include <odp_debug.h>
+#include <odp_byteorder.h>
+
+/** UDP header length */
+#define ODPH_TCPHDR_LEN 8
+
+/** TCP header */
+typedef struct ODP_PACKED {
+	uint16be_t src_port; /**< Source port */
+	uint16be_t dst_port; /**< Destinatino port */
+	uint32be_t seq_no;   /**< Sequence number */
+	uint32be_t ack_no;   /**< Acknowledgment number */
+	union {
+		uint32be_t flags_and_window;
+		struct {
+			uint32be_t rsvd1:8;
+			uint32be_t flags:8; /**< TCP flags as a byte */
+			uint32be_t rsvd2:16;
+		};
+		struct {
+			uint32be_t hl:4;    /**< Hdr len, in words */
+			uint32be_t rsvd3:6; /**< Reserved */
+			uint32be_t urg:1;   /**< ACK */
+			uint32be_t ack:1;
+			uint32be_t psh:1;
+			uint32be_t rst:1;
+			uint32be_t syn:1;
+			uint32be_t fin:1;
+			uint32be_t window:16; /**< Window size */
+		};
+	};
+	uint16be_t cksm;   /**< Checksum */
+	uint16be_t urgptr; /**< Urgent pointer */
+} odph_tcphdr_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-generic/include/odp_buffer_pool_internal.h b/platform/linux-generic/include/odp_buffer_pool_internal.h
index e0210bd..bdbefff 100644
--- a/platform/linux-generic/include/odp_buffer_pool_internal.h
+++ b/platform/linux-generic/include/odp_buffer_pool_internal.h
@@ -64,6 +64,12 @@  struct pool_entry_s {
 	size_t                  hdr_size;
 };
 
+typedef union pool_entry_u {
+	struct pool_entry_s s;
+
+	uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct pool_entry_s))];
+
+} pool_entry_t;
 
 extern void *pool_entry_ptr[];
 
@@ -73,6 +79,10 @@  static inline void *get_pool_entry(uint32_t pool_id)
 	return pool_entry_ptr[pool_id];
 }
 
+static inline uint32_t pool_handle_to_index(odp_buffer_pool_t pool_hdl)
+{
+	return pool_hdl - 1;
+}
 
 static inline odp_buffer_hdr_t *odp_buf_to_hdr(odp_buffer_t buf)
 {
diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c
index a48d7d6..57393dd 100644
--- a/platform/linux-generic/odp_buffer_pool.c
+++ b/platform/linux-generic/odp_buffer_pool.c
@@ -56,12 +56,6 @@  typedef struct {
 } odp_any_buffer_hdr_t;
 
 
-typedef union pool_entry_u {
-	struct pool_entry_s s;
-
-	uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct pool_entry_s))];
-
-} pool_entry_t;
 
 
 typedef struct pool_table_t {
@@ -86,10 +80,6 @@  static inline odp_buffer_pool_t pool_index_to_handle(uint32_t pool_id)
 }
 
 
-static inline uint32_t pool_handle_to_index(odp_buffer_pool_t pool_hdl)
-{
-	return pool_hdl -1;
-}
 
 
 static inline void set_handle(odp_buffer_hdr_t *hdr,