@@ -134,6 +134,7 @@ noinst_HEADERS = \
include/odp_bitmap_internal.h \
include/odp_bitset.h \
include/odp_buffer_internal.h \
+ include/odp_chksum_internal.h \
include/odp_classification_datamodel.h \
include/odp_classification_inlines.h \
include/odp_classification_internal.h \
new file mode 100644
@@ -0,0 +1,59 @@
+/* Copyright (c) 2013, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP checksum - implementation internal
+ */
+
+#ifndef ODP_CHKSUM_INTERNAL_H_
+#define ODP_CHKSUM_INTERNAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Simple implementation of ones complement sum.
+ * Based on RFC1071 and its errata.
+ */
+static uint32_t _odp_chksum_ones_comp16_32(const void *p, uint32_t len,
+ odp_bool_t odd_offset)
+
+{
+ uint32_t sum = 0;
+ const uint16_t *data = p;
+
+ if (odd_offset) {
+ uint16_t left_over = 0;
+
+ *(uint8_t *)&left_over = *(const uint8_t *)data;
+ sum = left_over;
+ data++;
+ len--;
+ }
+
+ while (len > 1) {
+ sum += *data++;
+ len -= 2;
+ }
+
+ /* Add left-over byte, if any */
+ if (len > 0) {
+ uint16_t left_over = 0;
+
+ *(uint8_t *)&left_over = *(const uint8_t *)data;
+ sum += left_over;
+ }
+
+ return sum;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
@@ -7,26 +7,14 @@
#include <odp/api/chksum.h>
#include <odp/api/std_types.h>
+#include <odp_chksum_internal.h>
+
/* Simple implementation of ones complement sum.
* Based on RFC1071 and its errata.
*/
uint16_t odp_chksum_ones_comp16(const void *p, uint32_t len)
{
- uint32_t sum = 0;
- const uint16_t *data = p;
-
- while (len > 1) {
- sum += *data++;
- len -= 2;
- }
-
- /* Add left-over byte, if any */
- if (len > 0) {
- uint16_t left_over = 0;
-
- *(uint8_t *)&left_over = *(const uint8_t *)data;
- sum += left_over;
- }
+ uint32_t sum = _odp_chksum_ones_comp16_32(p, len, false);
/* Fold 32-bit sum to 16 bits */
while (sum >> 16)