diff mbox series

[5/5] helper: use ABI mode for udp

Message ID 20170201131409.26631-6-mike.holmes@linaro.org
State New
Headers show
Series Add ABI compatibility to helper lib | expand

Commit Message

Mike Holmes Feb. 1, 2017, 1:14 p.m. UTC
Signed-off-by: Mike Holmes <mike.holmes@linaro.org>

---
 helper/Makefile.am                      |  4 +++-
 helper/include/odp/helper/udp.h         | 13 ++++++------
 helper/include/odp/helper/udp_inlines.h | 36 +++++++++++++++++++++++++++++++++
 helper/udp.c                            | 14 +++++++++++++
 4 files changed, 59 insertions(+), 8 deletions(-)
 create mode 100644 helper/include/odp/helper/udp_inlines.h
 create mode 100644 helper/udp.c

-- 
2.9.3
diff mbox series

Patch

diff --git a/helper/Makefile.am b/helper/Makefile.am
index 6820532..1bd2cda 100644
--- a/helper/Makefile.am
+++ b/helper/Makefile.am
@@ -34,6 +34,7 @@  helperinclude_HEADERS = \
 		  $(srcdir)/include/odp/helper/table.h\
 		  $(srcdir)/include/odp/helper/threads.h \
 		  $(srcdir)/include/odp/helper/udp.h \
+		  $(srcdir)/include/odp/helper/udp_inlines.h \
 		  $(srcdir)/include/odp/helper/udp_types.h
 
 if helper_extn
@@ -53,7 +54,8 @@  __LIB__libodphelper_@with_platform@_la_SOURCES = \
 					lineartable.c \
 					cuckootable.c \
 					iplookuptable.c \
-					threads.c
+					threads.c \
+					udp.c
 
 if helper_extn
 __LIB__libodphelper_@with_platform@_la_SOURCES += \
diff --git a/helper/include/odp/helper/udp.h b/helper/include/odp/helper/udp.h
index e1661de..e52dd4f 100644
--- a/helper/include/odp/helper/udp.h
+++ b/helper/include/odp/helper/udp.h
@@ -25,6 +25,7 @@  extern "C" {
  */
 
 /**
+ * @fn odph_ipv4_udp_chksum(odp_packet_t pkt)
  * UDP checksum
  *
  * This function calculates the UDP checksum given an odp packet.
@@ -32,14 +33,12 @@  extern "C" {
  * @param pkt  calculate chksum for pkt
  * @return  checksum value in BE endianness
  */
-static inline uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt)
-{
-	uint16_t chksum;
-	int      rc;
 
-	rc = odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_RETURN, &chksum);
-	return (rc == 0) ? chksum : 0;
-}
+#if ODP_HELPER_ABI_COMPAT == 0
+#include <odp/helper/udp_inlines.h>
+#else
+uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt);
+#endif
 
 /**
  * @}
diff --git a/helper/include/odp/helper/udp_inlines.h b/helper/include/odp/helper/udp_inlines.h
new file mode 100644
index 0000000..fa2fc4a
--- /dev/null
+++ b/helper/include/odp/helper/udp_inlines.h
@@ -0,0 +1,36 @@ 
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP UDP inline header
+ */
+
+#ifndef ODPH_UDP_INLINES_H_
+#define ODPH_UDP_INLINES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp/helper/static_inline.h>
+#include <odp/helper/udp.h>
+
+_HELPER_STATIC uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt)
+{
+	uint16_t chksum;
+	int      rc;
+
+	rc = odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_RETURN, &chksum);
+	return (rc == 0) ? chksum : 0;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/helper/udp.c b/helper/udp.c
new file mode 100644
index 0000000..0b9a634
--- /dev/null
+++ b/helper/udp.c
@@ -0,0 +1,14 @@ 
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include <odp/helper/udp.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#if ODP_ABI_COMPAT == 1
+#include <odp/helper/udp_inlines.h>
+#endif