diff mbox

[v6,1/3] helper: odph_tcp header description

Message ID 1418040176-9134-1-git-send-email-bala.manoharan@linaro.org
State Accepted
Commit 08796a4634fd40e558425752bd2352176e70f10d
Headers show

Commit Message

Balasubramanian Manoharan Dec. 8, 2014, 12:02 p.m. UTC
Adds TCP header description struct odph_tcphdr_t in helper directory.
This structure is used for accessing TCP header information from the packet

Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
---
V6: Incoporates review comments from Bill
 helper/include/odph_tcp.h                          | 81 ++++++++++++++++++++++
 platform/linux-generic/include/api/odp_byteorder.h |  7 ++
 2 files changed, 88 insertions(+)
 create mode 100644 helper/include/odph_tcp.h

Comments

Bill Fischofer Dec. 8, 2014, 12:06 p.m. UTC | #1
This patch is a pre-req for the packet patch I posted yesterday.  Please
merge this first.

On Mon, Dec 8, 2014 at 6:02 AM, Balasubramanian Manoharan <
bala.manoharan@linaro.org> wrote:

> Adds TCP header description struct odph_tcphdr_t in helper directory.
> This structure is used for accessing TCP header information from the packet
>
> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
>

Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>


> ---
> V6: Incoporates review comments from Bill
>  helper/include/odph_tcp.h                          | 81
> ++++++++++++++++++++++
>  platform/linux-generic/include/api/odp_byteorder.h |  7 ++
>  2 files changed, 88 insertions(+)
>  create mode 100644 helper/include/odph_tcp.h
>
> diff --git a/helper/include/odph_tcp.h b/helper/include/odph_tcp.h
> new file mode 100644
> index 0000000..3992ecf
> --- /dev/null
> +++ b/helper/include/odph_tcp.h
> @@ -0,0 +1,81 @@
> +/* 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>
> +
> +/** TCP header */
> +typedef struct ODP_PACKED {
> +       uint16be_t src_port; /**< Source port */
> +       uint16be_t dst_port; /**< Destination port */
> +       uint32be_t seq_no;   /**< Sequence number */
> +       uint32be_t ack_no;   /**< Acknowledgment number */
> +       union {
> +               uint16be_t doffset_flags;
> +#if defined(ODP_BIG_ENDIAN_BITFIELD)
> +               struct {
> +                       uint16be_t rsvd1:8;
> +                       uint16be_t flags:8; /**< TCP flags as a byte */
> +               };
> +               struct {
> +                       uint16be_t hl:4;    /**< Hdr len, in words */
> +                       uint16be_t rsvd3:4; /**< Reserved */
> +                       uint16be_t cwr:1;
> +                       uint16be_t ece:1;
> +                       uint16be_t urg:1;
> +                       uint16be_t ack:1;
> +                       uint16be_t psh:1;
> +                       uint16be_t rst:1;
> +                       uint16be_t syn:1;
> +                       uint16be_t fin:1;
> +               };
> +#elif defined(ODP_LITTLE_ENDIAN_BITFIELD)
> +               struct {
> +                       uint16be_t flags:8;
> +                       uint16be_t rsvd1:8; /**< TCP flags as a byte */
> +               };
> +               struct {
> +                       uint16be_t rsvd3:4; /**< Reserved */
> +                       uint16be_t hl:4;    /**< Hdr len, in words */
> +                       uint16be_t fin:1;
> +                       uint16be_t syn:1;
> +                       uint16be_t rst:1;
> +                       uint16be_t psh:1;
> +                       uint16be_t ack:1;
> +                       uint16be_t urg:1;
> +                       uint16be_t ece:1;
> +                       uint16be_t cwr:1;
> +               };
> +
> +#else
> +#error "Endian BitField order not defined!"
> +#endif
> +       };
> +       uint16be_t window; /**< 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/api/odp_byteorder.h
> b/platform/linux-generic/include/api/odp_byteorder.h
> index 79ddd75..5d7cceb 100644
> --- a/platform/linux-generic/include/api/odp_byteorder.h
> +++ b/platform/linux-generic/include/api/odp_byteorder.h
> @@ -19,6 +19,7 @@ extern "C" {
>  #endif
>
>  #include <endian.h>
> +#include <asm/byteorder.h>
>  #include <odp_std_types.h>
>  #include <odp_compiler.h>
>
> @@ -45,6 +46,12 @@ extern "C" {
>  /** Little endian byte order */
>  #define ODP_LITTLE_ENDIAN __LITTLE_ENDIAN
>
> +/** Big endian bit field */
> +#define ODP_BIG_ENDIAN_BITFIELD __BIG_ENDIAN_BITFIELD
> +
> +/** Little endian bit field */
> +#define ODP_LITTLE_ENDIAN_BITFIELD __LITTLE_ENDIAN_BITFIELD
> +
>  /** Selected byte order */
>  #if __BYTE_ORDER == __LITTLE_ENDIAN
>  #define ODP_BYTE_ORDER ODP_LITTLE_ENDIAN
> --
> 2.0.1.472.g6f92e5f
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Maxim Uvarov Dec. 9, 2014, 10:50 a.m. UTC | #2
Ciprian, Anders, Viktor, you commented on that patch. Do you like to add 
your sign-offs?

Maxim.

On 12/08/2014 03:02 PM, Balasubramanian Manoharan wrote:
> Adds TCP header description struct odph_tcphdr_t in helper directory.
> This structure is used for accessing TCP header information from the packet
>
> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
> ---
> V6: Incoporates review comments from Bill
>   helper/include/odph_tcp.h                          | 81 ++++++++++++++++++++++
>   platform/linux-generic/include/api/odp_byteorder.h |  7 ++
>   2 files changed, 88 insertions(+)
>   create mode 100644 helper/include/odph_tcp.h
>
> diff --git a/helper/include/odph_tcp.h b/helper/include/odph_tcp.h
> new file mode 100644
> index 0000000..3992ecf
> --- /dev/null
> +++ b/helper/include/odph_tcp.h
> @@ -0,0 +1,81 @@
> +/* 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>
> +
> +/** TCP header */
> +typedef struct ODP_PACKED {
> +	uint16be_t src_port; /**< Source port */
> +	uint16be_t dst_port; /**< Destination port */
> +	uint32be_t seq_no;   /**< Sequence number */
> +	uint32be_t ack_no;   /**< Acknowledgment number */
> +	union {
> +		uint16be_t doffset_flags;
> +#if defined(ODP_BIG_ENDIAN_BITFIELD)
> +		struct {
> +			uint16be_t rsvd1:8;
> +			uint16be_t flags:8; /**< TCP flags as a byte */
> +		};
> +		struct {
> +			uint16be_t hl:4;    /**< Hdr len, in words */
> +			uint16be_t rsvd3:4; /**< Reserved */
> +			uint16be_t cwr:1;
> +			uint16be_t ece:1;
> +			uint16be_t urg:1;
> +			uint16be_t ack:1;
> +			uint16be_t psh:1;
> +			uint16be_t rst:1;
> +			uint16be_t syn:1;
> +			uint16be_t fin:1;
> +		};
> +#elif defined(ODP_LITTLE_ENDIAN_BITFIELD)
> +		struct {
> +			uint16be_t flags:8;
> +			uint16be_t rsvd1:8; /**< TCP flags as a byte */
> +		};
> +		struct {
> +			uint16be_t rsvd3:4; /**< Reserved */
> +			uint16be_t hl:4;    /**< Hdr len, in words */
> +			uint16be_t fin:1;
> +			uint16be_t syn:1;
> +			uint16be_t rst:1;
> +			uint16be_t psh:1;
> +			uint16be_t ack:1;
> +			uint16be_t urg:1;
> +			uint16be_t ece:1;
> +			uint16be_t cwr:1;
> +		};
> +
> +#else
> +#error "Endian BitField order not defined!"
> +#endif
> +	};
> +	uint16be_t window; /**< 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/api/odp_byteorder.h b/platform/linux-generic/include/api/odp_byteorder.h
> index 79ddd75..5d7cceb 100644
> --- a/platform/linux-generic/include/api/odp_byteorder.h
> +++ b/platform/linux-generic/include/api/odp_byteorder.h
> @@ -19,6 +19,7 @@ extern "C" {
>   #endif
>   
>   #include <endian.h>
> +#include <asm/byteorder.h>
>   #include <odp_std_types.h>
>   #include <odp_compiler.h>
>   
> @@ -45,6 +46,12 @@ extern "C" {
>   /** Little endian byte order */
>   #define ODP_LITTLE_ENDIAN __LITTLE_ENDIAN
>   
> +/** Big endian bit field */
> +#define ODP_BIG_ENDIAN_BITFIELD __BIG_ENDIAN_BITFIELD
> +
> +/** Little endian bit field */
> +#define ODP_LITTLE_ENDIAN_BITFIELD __LITTLE_ENDIAN_BITFIELD
> +
>   /** Selected byte order */
>   #if __BYTE_ORDER == __LITTLE_ENDIAN
>   #define ODP_BYTE_ORDER ODP_LITTLE_ENDIAN
vkamensky Dec. 9, 2014, 5:59 p.m. UTC | #3
On 8 December 2014 at 04:02, Balasubramanian Manoharan
<bala.manoharan@linaro.org> wrote:
> Adds TCP header description struct odph_tcphdr_t in helper directory.
> This structure is used for accessing TCP header information from the packet
>
> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>

Reviewed-by: Victor Kamensky <victor.kamensky@linaro.org>

> ---
> V6: Incoporates review comments from Bill
>  helper/include/odph_tcp.h                          | 81 ++++++++++++++++++++++
>  platform/linux-generic/include/api/odp_byteorder.h |  7 ++
>  2 files changed, 88 insertions(+)
>  create mode 100644 helper/include/odph_tcp.h
>
> diff --git a/helper/include/odph_tcp.h b/helper/include/odph_tcp.h
> new file mode 100644
> index 0000000..3992ecf
> --- /dev/null
> +++ b/helper/include/odph_tcp.h
> @@ -0,0 +1,81 @@
> +/* 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>
> +
> +/** TCP header */
> +typedef struct ODP_PACKED {
> +       uint16be_t src_port; /**< Source port */
> +       uint16be_t dst_port; /**< Destination port */
> +       uint32be_t seq_no;   /**< Sequence number */
> +       uint32be_t ack_no;   /**< Acknowledgment number */
> +       union {
> +               uint16be_t doffset_flags;
> +#if defined(ODP_BIG_ENDIAN_BITFIELD)
> +               struct {
> +                       uint16be_t rsvd1:8;
> +                       uint16be_t flags:8; /**< TCP flags as a byte */
> +               };
> +               struct {
> +                       uint16be_t hl:4;    /**< Hdr len, in words */
> +                       uint16be_t rsvd3:4; /**< Reserved */
> +                       uint16be_t cwr:1;
> +                       uint16be_t ece:1;
> +                       uint16be_t urg:1;
> +                       uint16be_t ack:1;
> +                       uint16be_t psh:1;
> +                       uint16be_t rst:1;
> +                       uint16be_t syn:1;
> +                       uint16be_t fin:1;
> +               };
> +#elif defined(ODP_LITTLE_ENDIAN_BITFIELD)
> +               struct {
> +                       uint16be_t flags:8;
> +                       uint16be_t rsvd1:8; /**< TCP flags as a byte */
> +               };
> +               struct {
> +                       uint16be_t rsvd3:4; /**< Reserved */
> +                       uint16be_t hl:4;    /**< Hdr len, in words */
> +                       uint16be_t fin:1;
> +                       uint16be_t syn:1;
> +                       uint16be_t rst:1;
> +                       uint16be_t psh:1;
> +                       uint16be_t ack:1;
> +                       uint16be_t urg:1;
> +                       uint16be_t ece:1;
> +                       uint16be_t cwr:1;
> +               };
> +
> +#else
> +#error "Endian BitField order not defined!"
> +#endif
> +       };
> +       uint16be_t window; /**< 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/api/odp_byteorder.h b/platform/linux-generic/include/api/odp_byteorder.h
> index 79ddd75..5d7cceb 100644
> --- a/platform/linux-generic/include/api/odp_byteorder.h
> +++ b/platform/linux-generic/include/api/odp_byteorder.h
> @@ -19,6 +19,7 @@ extern "C" {
>  #endif
>
>  #include <endian.h>
> +#include <asm/byteorder.h>
>  #include <odp_std_types.h>
>  #include <odp_compiler.h>
>
> @@ -45,6 +46,12 @@ extern "C" {
>  /** Little endian byte order */
>  #define ODP_LITTLE_ENDIAN __LITTLE_ENDIAN
>
> +/** Big endian bit field */
> +#define ODP_BIG_ENDIAN_BITFIELD __BIG_ENDIAN_BITFIELD
> +
> +/** Little endian bit field */
> +#define ODP_LITTLE_ENDIAN_BITFIELD __LITTLE_ENDIAN_BITFIELD
> +
>  /** Selected byte order */
>  #if __BYTE_ORDER == __LITTLE_ENDIAN
>  #define ODP_BYTE_ORDER ODP_LITTLE_ENDIAN
> --
> 2.0.1.472.g6f92e5f
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
Maxim Uvarov Dec. 10, 2014, 1:10 p.m. UTC | #4
Patch set is merged,

Thanks!
Maxim.

On 12/08/2014 03:02 PM, Balasubramanian Manoharan wrote:
> Adds TCP header description struct odph_tcphdr_t in helper directory.
> This structure is used for accessing TCP header information from the packet
>
> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
> ---
> V6: Incoporates review comments from Bill
>   helper/include/odph_tcp.h                          | 81 ++++++++++++++++++++++
>   platform/linux-generic/include/api/odp_byteorder.h |  7 ++
>   2 files changed, 88 insertions(+)
>   create mode 100644 helper/include/odph_tcp.h
>
> diff --git a/helper/include/odph_tcp.h b/helper/include/odph_tcp.h
> new file mode 100644
> index 0000000..3992ecf
> --- /dev/null
> +++ b/helper/include/odph_tcp.h
> @@ -0,0 +1,81 @@
> +/* 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>
> +
> +/** TCP header */
> +typedef struct ODP_PACKED {
> +	uint16be_t src_port; /**< Source port */
> +	uint16be_t dst_port; /**< Destination port */
> +	uint32be_t seq_no;   /**< Sequence number */
> +	uint32be_t ack_no;   /**< Acknowledgment number */
> +	union {
> +		uint16be_t doffset_flags;
> +#if defined(ODP_BIG_ENDIAN_BITFIELD)
> +		struct {
> +			uint16be_t rsvd1:8;
> +			uint16be_t flags:8; /**< TCP flags as a byte */
> +		};
> +		struct {
> +			uint16be_t hl:4;    /**< Hdr len, in words */
> +			uint16be_t rsvd3:4; /**< Reserved */
> +			uint16be_t cwr:1;
> +			uint16be_t ece:1;
> +			uint16be_t urg:1;
> +			uint16be_t ack:1;
> +			uint16be_t psh:1;
> +			uint16be_t rst:1;
> +			uint16be_t syn:1;
> +			uint16be_t fin:1;
> +		};
> +#elif defined(ODP_LITTLE_ENDIAN_BITFIELD)
> +		struct {
> +			uint16be_t flags:8;
> +			uint16be_t rsvd1:8; /**< TCP flags as a byte */
> +		};
> +		struct {
> +			uint16be_t rsvd3:4; /**< Reserved */
> +			uint16be_t hl:4;    /**< Hdr len, in words */
> +			uint16be_t fin:1;
> +			uint16be_t syn:1;
> +			uint16be_t rst:1;
> +			uint16be_t psh:1;
> +			uint16be_t ack:1;
> +			uint16be_t urg:1;
> +			uint16be_t ece:1;
> +			uint16be_t cwr:1;
> +		};
> +
> +#else
> +#error "Endian BitField order not defined!"
> +#endif
> +	};
> +	uint16be_t window; /**< 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/api/odp_byteorder.h b/platform/linux-generic/include/api/odp_byteorder.h
> index 79ddd75..5d7cceb 100644
> --- a/platform/linux-generic/include/api/odp_byteorder.h
> +++ b/platform/linux-generic/include/api/odp_byteorder.h
> @@ -19,6 +19,7 @@ extern "C" {
>   #endif
>   
>   #include <endian.h>
> +#include <asm/byteorder.h>
>   #include <odp_std_types.h>
>   #include <odp_compiler.h>
>   
> @@ -45,6 +46,12 @@ extern "C" {
>   /** Little endian byte order */
>   #define ODP_LITTLE_ENDIAN __LITTLE_ENDIAN
>   
> +/** Big endian bit field */
> +#define ODP_BIG_ENDIAN_BITFIELD __BIG_ENDIAN_BITFIELD
> +
> +/** Little endian bit field */
> +#define ODP_LITTLE_ENDIAN_BITFIELD __LITTLE_ENDIAN_BITFIELD
> +
>   /** Selected byte order */
>   #if __BYTE_ORDER == __LITTLE_ENDIAN
>   #define ODP_BYTE_ORDER ODP_LITTLE_ENDIAN
diff mbox

Patch

diff --git a/helper/include/odph_tcp.h b/helper/include/odph_tcp.h
new file mode 100644
index 0000000..3992ecf
--- /dev/null
+++ b/helper/include/odph_tcp.h
@@ -0,0 +1,81 @@ 
+/* 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>
+
+/** TCP header */
+typedef struct ODP_PACKED {
+	uint16be_t src_port; /**< Source port */
+	uint16be_t dst_port; /**< Destination port */
+	uint32be_t seq_no;   /**< Sequence number */
+	uint32be_t ack_no;   /**< Acknowledgment number */
+	union {
+		uint16be_t doffset_flags;
+#if defined(ODP_BIG_ENDIAN_BITFIELD)
+		struct {
+			uint16be_t rsvd1:8;
+			uint16be_t flags:8; /**< TCP flags as a byte */
+		};
+		struct {
+			uint16be_t hl:4;    /**< Hdr len, in words */
+			uint16be_t rsvd3:4; /**< Reserved */
+			uint16be_t cwr:1;
+			uint16be_t ece:1;
+			uint16be_t urg:1;
+			uint16be_t ack:1;
+			uint16be_t psh:1;
+			uint16be_t rst:1;
+			uint16be_t syn:1;
+			uint16be_t fin:1;
+		};
+#elif defined(ODP_LITTLE_ENDIAN_BITFIELD)
+		struct {
+			uint16be_t flags:8;
+			uint16be_t rsvd1:8; /**< TCP flags as a byte */
+		};
+		struct {
+			uint16be_t rsvd3:4; /**< Reserved */
+			uint16be_t hl:4;    /**< Hdr len, in words */
+			uint16be_t fin:1;
+			uint16be_t syn:1;
+			uint16be_t rst:1;
+			uint16be_t psh:1;
+			uint16be_t ack:1;
+			uint16be_t urg:1;
+			uint16be_t ece:1;
+			uint16be_t cwr:1;
+		};
+
+#else
+#error "Endian BitField order not defined!"
+#endif
+	};
+	uint16be_t window; /**< 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/api/odp_byteorder.h b/platform/linux-generic/include/api/odp_byteorder.h
index 79ddd75..5d7cceb 100644
--- a/platform/linux-generic/include/api/odp_byteorder.h
+++ b/platform/linux-generic/include/api/odp_byteorder.h
@@ -19,6 +19,7 @@  extern "C" {
 #endif
 
 #include <endian.h>
+#include <asm/byteorder.h>
 #include <odp_std_types.h>
 #include <odp_compiler.h>
 
@@ -45,6 +46,12 @@  extern "C" {
 /** Little endian byte order */
 #define ODP_LITTLE_ENDIAN __LITTLE_ENDIAN
 
+/** Big endian bit field */
+#define ODP_BIG_ENDIAN_BITFIELD __BIG_ENDIAN_BITFIELD
+
+/** Little endian bit field */
+#define ODP_LITTLE_ENDIAN_BITFIELD __LITTLE_ENDIAN_BITFIELD
+
 /** Selected byte order */
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define ODP_BYTE_ORDER ODP_LITTLE_ENDIAN