@@ -11,6 +11,7 @@ AC_CONFIG_FILES([test/common_plat/Makefile
test/common_plat/validation/api/atomic/Makefile
test/common_plat/validation/api/barrier/Makefile
test/common_plat/validation/api/buffer/Makefile
+ test/common_plat/validation/api/chksum/Makefile
test/common_plat/validation/api/classification/Makefile
test/common_plat/validation/api/cpumask/Makefile
test/common_plat/validation/api/crypto/Makefile
@@ -1,6 +1,7 @@
ODP_MODULES = atomic \
barrier \
buffer \
+ chksum \
classification \
cpumask \
crypto \
new file mode 100644
@@ -0,0 +1 @@
+chksum_main
new file mode 100644
@@ -0,0 +1,5 @@
+include ../Makefile.inc
+
+test_PROGRAMS = chksum_main$(EXEEXT)
+chksum_main_SOURCES = chksum_main.c chksum.c chksum.h
+chksum_main_LDADD = $(LIBCUNIT_COMMON) $(LIBODP)
new file mode 100644
@@ -0,0 +1,134 @@
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp_api.h>
+#include <odp_cunit_common.h>
+#include "chksum.h"
+
+#define NUM_IP_HDR 5
+#define IP_HDR_LEN 20
+
+#define NUM_UDP 4
+#define MAX_UDP_LEN 128
+
+uint8_t ip_hdr_test_vect[NUM_IP_HDR][IP_HDR_LEN] ODP_ALIGNED(4) = {
+ { 0x45, 0x00, 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11,
+ 0xAB, 0x33, 0xC0, 0xA8, 0x2C, 0xA2, 0xC0, 0xA8, 0x21, 0x99
+ },
+ { 0x45, 0x00, 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11,
+ 0xAB, 0xCA, 0xC0, 0xA8, 0x2C, 0x5E, 0xC0, 0xA8, 0x21, 0x46
+ },
+ { 0x45, 0x00, 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11,
+ 0xAB, 0x64, 0xC0, 0xA8, 0x2C, 0x20, 0xC0, 0xA8, 0x21, 0xEA
+ },
+ { 0x45, 0x00, 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11,
+ 0xAB, 0x59, 0xC0, 0xA8, 0x2C, 0xD2, 0xC0, 0xA8, 0x21, 0x43
+ },
+ { 0x45, 0x00, 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11,
+ 0xAC, 0x06, 0xC0, 0xA8, 0x2C, 0x5C, 0xC0, 0xA8, 0x21, 0x0C
+ }
+};
+
+struct udp_test_vect_s {
+ uint32_t len;
+
+ uint8_t data[MAX_UDP_LEN];
+};
+
+struct udp_test_vect_s udp_test_vect[NUM_UDP] ODP_ALIGNED(4) = {
+ {.len = 38,
+ .data = { 0x00, 0x11, 0x00, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x1A, 0xFF, 0x3C,
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
+ 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xC7, 0xBF
+ } },
+
+ {.len = 39,
+ .data = { 0x00, 0x11, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x20, 0x40, 0x09, 0x35, 0x00, 0x1B, 0xD6, 0x43,
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
+ 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0xBF, 0xB7
+ } },
+
+ {.len = 59,
+ .data = { 0x00, 0x11, 0x00, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x32, 0x5F, 0x01, 0x71, 0x00, 0x2F, 0xCB, 0xC0,
+ 0x09, 0x8B, 0x61, 0x3E, 0x3A, 0x7F, 0x30, 0x0F, 0x4D, 0xEE,
+ 0x2D, 0x7D, 0x11, 0xBB, 0xBB, 0x34, 0x0E, 0x9E, 0xC5, 0x3D,
+ 0xBB, 0x81, 0x9A, 0x7F, 0xF2, 0x2A, 0xFC, 0x85, 0xA0, 0x1B,
+ 0x73, 0x81, 0xC1, 0xB6, 0xE8, 0x91, 0x8C, 0xD8, 0x7F
+ } },
+
+ {.len = 109,
+ .data = { 0x00, 0x11, 0x00, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x32, 0x5F, 0x01, 0x71, 0x00, 0x61, 0xCB, 0x5C,
+ 0x61, 0xAD, 0xFD, 0xE7, 0x4E, 0x98, 0x69, 0x59, 0x12, 0x3F,
+ 0xDF, 0xF6, 0x79, 0x8B, 0xB3, 0x94, 0x94, 0x9F, 0x8C, 0x0B,
+ 0x67, 0xBA, 0xBA, 0x3C, 0xE2, 0x5F, 0xCA, 0x52, 0x13, 0xB4,
+ 0x57, 0x48, 0x99, 0x29, 0x23, 0xAC, 0x5C, 0x59, 0x66, 0xA2,
+ 0x7B, 0x35, 0x65, 0x2B, 0x86, 0x5F, 0x47, 0xA7, 0xEE, 0xD4,
+ 0x24, 0x99, 0xB9, 0xCE, 0x60, 0xAB, 0x7A, 0xE9, 0x37, 0xF2,
+ 0x81, 0x84, 0x98, 0x72, 0x4F, 0x6A, 0x37, 0xE5, 0x4D, 0xB2,
+ 0xDE, 0xB8, 0xBD, 0xE3, 0x03, 0x57, 0xF0, 0x5C, 0xA0, 0xAA,
+ 0xB9, 0xF3, 0x3F, 0xDF, 0x23, 0xDD, 0x54, 0x2F, 0xCE
+ } }
+};
+
+/* Test ones complement sum with IPv4 headers */
+void chksum_ones_complement_ip(void)
+{
+ int i;
+ uint16_t sum, res;
+
+ for (i = 0; i < NUM_IP_HDR; i++) {
+ sum = odp_chksum_ones_comp16(ip_hdr_test_vect[i], IP_HDR_LEN);
+ res = ~sum;
+
+ CU_ASSERT(res == 0);
+ }
+}
+
+/* Test ones complement sum with various length pseudo UDP packets */
+void chksum_ones_complement_udp(void)
+{
+ int i;
+ uint16_t sum, res;
+
+ for (i = 0; i < NUM_UDP; i++) {
+ sum = odp_chksum_ones_comp16(udp_test_vect[i].data,
+ udp_test_vect[i].len);
+ res = ~sum;
+
+ CU_ASSERT(res == 0);
+ }
+}
+
+odp_testinfo_t chksum_suite[] = {
+ ODP_TEST_INFO(chksum_ones_complement_ip),
+ ODP_TEST_INFO(chksum_ones_complement_udp),
+ ODP_TEST_INFO_NULL,
+};
+
+odp_suiteinfo_t chksum_suites[] = {
+ {"Checksum", NULL, NULL, chksum_suite},
+ ODP_SUITE_INFO_NULL
+};
+
+int chksum_main(int argc, char *argv[])
+{
+ int ret;
+
+ /* parse common options: */
+ if (odp_cunit_parse_options(argc, argv))
+ return -1;
+
+ ret = odp_cunit_register(chksum_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
+}
new file mode 100644
@@ -0,0 +1,25 @@
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _ODP_TEST_CHKSUM_H_
+#define _ODP_TEST_CHKSUM_H_
+
+#include <odp_cunit_common.h>
+
+/* test functions: */
+void chksum_ones_complement_ip(void);
+void chksum_ones_complement_udp(void);
+
+/* test arrays: */
+extern odp_testinfo_t chksum_suite[];
+
+/* test registry: */
+extern odp_suiteinfo_t chksum_suites[];
+
+/* main test program: */
+int chksum_main(int argc, char *argv[]);
+
+#endif
new file mode 100644
@@ -0,0 +1,12 @@
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "chksum.h"
+
+int main(int argc, char *argv[])
+{
+ return chksum_main(argc, argv);
+}
@@ -13,6 +13,7 @@ TESTS = validation/api/pktio/pktio_run.sh \
$(ALL_API_VALIDATION_DIR)/atomic/atomic_main$(EXEEXT) \
$(ALL_API_VALIDATION_DIR)/barrier/barrier_main$(EXEEXT) \
$(ALL_API_VALIDATION_DIR)/buffer/buffer_main$(EXEEXT) \
+ $(ALL_API_VALIDATION_DIR)/chksum/chksum_main$(EXEEXT) \
$(ALL_API_VALIDATION_DIR)/classification/classification_main$(EXEEXT) \
$(ALL_API_VALIDATION_DIR)/cpumask/cpumask_main$(EXEEXT) \
$(ALL_API_VALIDATION_DIR)/crypto/crypto_main$(EXEEXT) \