On 06/06/16 11:44, huanggaoyang wrote:
Signed-off-by: huanggaoyang <[email protected]>
---
  helper/compatible.c                | 24 +++++++++++++
  helper/include/odp/helper/chksum.h | 71 +++++++++++++++++++++-----------------
  helper/include/odp/helper/ip.h     | 11 ++++--
  3 files changed, 72 insertions(+), 34 deletions(-)
  create mode 100644 helper/compatible.c

diff --git a/helper/compatible.c b/helper/compatible.c
new file mode 100644
index 0000000..725bd6f
--- /dev/null
+++ b/helper/compatible.c
@@ -0,0 +1,24 @@
+/* Copyright (c) 2015, Linaro Limited

2016

Maxim.

+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+/**
+  This file is the location to implement those functions not inline any more
+*/
+#if (ODP_BINARY_COMPATIBLE == 1)
+
+/* may be lots of warning "no previous prototype for function ..."
+   ignore them here because it's not necessary to resolve them
+ */
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+
+#define ODPH_STATIC
+#define ODPH_INLINE
+#define ODPH_ENABLE_INLINE 1
+
+#include <odp/helper/ip.h>
+#include <odp/helper/chksum.h>
+
+#endif
diff --git a/helper/include/odp/helper/chksum.h 
b/helper/include/odp/helper/chksum.h
index 07d0be3..7e505a5 100644
--- a/helper/include/odp/helper/chksum.h
+++ b/helper/include/odp/helper/chksum.h
@@ -17,6 +17,7 @@ extern "C" {
  #endif
#include <odp_api.h>
+#include <odp/api/compatible.h>
/** @addtogroup odph_chksum ODPH CHECK SUM
   *  @{
@@ -35,33 +36,6 @@ typedef enum {
  } odph_chksum_op_t;
/**
- * Checksum
- *
- * @param buffer calculate chksum for buffer
- * @param len    buffer length
- *
- * @return checksum value in host cpu order
- */
-static inline odp_u16sum_t odph_chksum(void *buffer, int len)
-{
-       uint16_t *buf = buffer;
-       uint32_t sum = 0;
-       uint16_t result;
-
-       for (sum = 0; len > 1; len -= 2)
-               sum += *buf++;
-
-       if (len == 1)
-               sum += *(unsigned char *)buf;
-
-       sum = (sum >> 16) + (sum & 0xFFFF);
-       sum += (sum >> 16);
-       result = ~sum;
-
-       return  (__odp_force odp_u16sum_t) result;
-}
-
-/**
   * General Purpose TCP/UDP checksum function
   *
   * This function handles all the different checksum operations like
@@ -104,6 +78,34 @@ int odph_udp_tcp_chksum(odp_packet_t     odp_pkt,
                        odph_chksum_op_t op,
                        uint16_t        *chksum_ptr);
+#if (ODPH_ENABLE_INLINE == 1)
+/**
+ * Checksum
+ *
+ * @param buffer calculate chksum for buffer
+ * @param len    buffer length
+ *
+ * @return checksum value in host cpu order
+ */
+ODPH_STATIC ODPH_INLINE odp_u16sum_t odph_chksum(void *buffer, int len)
+{
+       uint16_t *buf = buffer;
+       uint32_t sum = 0;
+       uint16_t result;
+
+       for (sum = 0; len > 1; len -= 2)
+               sum += *buf++;
+
+       if (len == 1)
+               sum += *(unsigned char *)buf;
+
+       sum = (sum >> 16) + (sum & 0xFFFF);
+       sum += (sum >> 16);
+       result = ~sum;
+
+       return  (__odp_force odp_u16sum_t) result;
+}
+
  /**
   * Generate TCP checksum
   *
@@ -123,7 +125,7 @@ int odph_udp_tcp_chksum(odp_packet_t     odp_pkt,
   *                     be over IPv4 or IPv6.
   * @return             0 upon success and < 0 upon failure.
   */
-static inline int odph_tcp_chksum_set(odp_packet_t odp_pkt)
+ODPH_STATIC ODPH_INLINE int odph_tcp_chksum_set(odp_packet_t odp_pkt)
  {
        if (!odp_packet_has_tcp(odp_pkt))
                return -1;
@@ -150,7 +152,7 @@ static inline int odph_tcp_chksum_set(odp_packet_t odp_pkt)
   *                     be over IPv4 or IPv6.
   * @return             0 upon success and < 0 upon failure.
   */
-static inline int odph_udp_chksum_set(odp_packet_t odp_pkt)
+ODPH_STATIC ODPH_INLINE int odph_udp_chksum_set(odp_packet_t odp_pkt)
  {
        if (!odp_packet_has_udp(odp_pkt))
                return -1;
@@ -178,7 +180,7 @@ static inline int odph_udp_chksum_set(odp_packet_t odp_pkt)
   *                     the incoming chksum field is correct, else returns 2
   *                     when the chksum field is incorrect or 0.
   */
-static inline int odph_tcp_chksum_verify(odp_packet_t odp_pkt)
+ODPH_STATIC ODPH_INLINE int odph_tcp_chksum_verify(odp_packet_t odp_pkt)
  {
        if (!odp_packet_has_tcp(odp_pkt))
                return -1;
@@ -208,13 +210,20 @@ static inline int odph_tcp_chksum_verify(odp_packet_t 
odp_pkt)
   *                     if the incoming chksum field is correct, else returns 2
   *                     when the chksum field is incorrect.
   */
-static inline int odph_udp_chksum_verify(odp_packet_t odp_pkt)
+ODPH_STATIC ODPH_INLINE int odph_udp_chksum_verify(odp_packet_t odp_pkt)
  {
        if (!odp_packet_has_udp(odp_pkt))
                return -1;
return odph_udp_tcp_chksum(odp_pkt, ODPH_CHKSUM_VERIFY, NULL);
  }
+#else
+odp_u16sum_t odph_chksum(void *buffer, int len);
+int odph_tcp_chksum_set(odp_packet_t odp_pkt);
+int odph_udp_chksum_set(odp_packet_t odp_pkt);
+int odph_tcp_chksum_verify(odp_packet_t odp_pkt);
+int odph_udp_chksum_verify(odp_packet_t odp_pkt);
+#endif
/**
   * @}
diff --git a/helper/include/odp/helper/ip.h b/helper/include/odp/helper/ip.h
index 4cfc00f..0593e0a 100644
--- a/helper/include/odp/helper/ip.h
+++ b/helper/include/odp/helper/ip.h
@@ -21,7 +21,7 @@ extern "C" {
  #include <odp/helper/chksum.h>
#include <string.h>
-
+#include <odp/api/compatible.h>
  /** @addtogroup odph_header ODPH HEADER
   *  @{
   */
@@ -92,6 +92,7 @@ typedef struct ODP_PACKED {
  ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN,
                  "ODPH_IPV4HDR_T__SIZE_ERROR");
+#if (ODPH_ENABLE_INLINE == 1)
  /**
   * Check if IPv4 checksum is valid
   *
@@ -99,7 +100,7 @@ ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN,
   *
   * @return 1 if checksum is valid, otherwise 0
   */
-static inline int odph_ipv4_csum_valid(odp_packet_t pkt)
+ODPH_STATIC ODPH_INLINE int odph_ipv4_csum_valid(odp_packet_t pkt)
  {
        odp_u16be_t res = 0;
        uint16_t *w;
@@ -131,7 +132,7 @@ static inline int odph_ipv4_csum_valid(odp_packet_t pkt)
   *
   * @return IPv4 checksum in host cpu order, or 0 on failure
   */
-static inline odp_u16sum_t odph_ipv4_csum_update(odp_packet_t pkt)
+ODPH_STATIC ODPH_INLINE odp_u16sum_t odph_ipv4_csum_update(odp_packet_t pkt)
  {
        uint16_t *w;
        odph_ipv4hdr_t *ip;
@@ -145,6 +146,10 @@ static inline odp_u16sum_t 
odph_ipv4_csum_update(odp_packet_t pkt)
        ip->chksum = odph_chksum(w, nleft);
        return ip->chksum;
  }
+#else
+int odph_ipv4_csum_valid(odp_packet_t pkt);
+odp_u16sum_t odph_ipv4_csum_update(odp_packet_t pkt);
+#endif
/** IPv6 version */
  #define ODPH_IPV6 6

_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to