This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, api-next has been updated via a1312ccf383637b5711c0f8c4bab6f43e63325dc (commit) via 4da1cb6040dece2ece108cd383ab4212e7f7fe85 (commit) via f6d3bc302664e2c4121e798e86758d93fdb156f5 (commit) via 6333b39f1bd5ebe184780260566b84340104efeb (commit) via 78ced32df325dac7ff58ff28684fdb941f5ec1b3 (commit) via fbb6a7feba146acb1495fbdcd93e1b691a7363a0 (commit) via 23b6eee83bc5717f4797441bddbb035e3388ff10 (commit) via 0ec5bc6b5c3a178d7b316bdf9e18db452ba5ed58 (commit) via 9c389e1785fd000203eb2198f9fc2778be8f83e6 (commit) from 3d254a24a1a911aad72f0535412644824872307f (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit a1312ccf383637b5711c0f8c4bab6f43e63325dc Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Oct 20 11:08:52 2017 +0300
validation: packet: add call to ones complement
Call ones complement function. Actual validation of correctness of the sum is to be done, when an implementation exist which sets the sum on packet input.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index f96347b5..ce4d66c0 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -504,6 +504,7 @@ void packet_test_basic_metadata(void) { odp_packet_t pkt = test_packet; odp_time_t ts; + odp_packet_data_range_t range;
CU_ASSERT_PTR_NOT_NULL(odp_packet_head(pkt)); CU_ASSERT_PTR_NOT_NULL(odp_packet_data(pkt)); @@ -513,6 +514,11 @@ void packet_test_basic_metadata(void) CU_ASSERT(odp_packet_input(pkt) == ODP_PKTIO_INVALID); CU_ASSERT(odp_packet_input_index(pkt) < 0);
+ /* Packet was not received from a packet IO, shouldn't have ones + * complement calculated. */ + odp_packet_ones_comp(pkt, &range); + CU_ASSERT(range.length == 0); + odp_packet_flow_hash_set(pkt, UINT32_MAX); CU_ASSERT(odp_packet_has_flow_hash(pkt)); CU_ASSERT(odp_packet_flow_hash(pkt) == UINT32_MAX); diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c index 72070735..004379cd 100644 --- a/test/validation/api/pktio/pktio.c +++ b/test/validation/api/pktio/pktio.c @@ -48,6 +48,9 @@ static int num_ifaces; interface that just become up.*/ static bool wait_for_network;
+/* Dummy global variable to avoid compiler optimizing out API calls */ +static volatile uint64_t test_pktio_dummy_u64; + /** local container for pktio attributes */ typedef struct { const char *name; @@ -661,10 +664,24 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, pktio_info_t *pktio_b, CU_ASSERT(num_rx == num_pkts);
for (i = 0; i < num_rx; ++i) { - CU_ASSERT_FATAL(rx_pkt[i] != ODP_PACKET_INVALID); - CU_ASSERT(odp_packet_input(rx_pkt[i]) == pktio_b->id); - CU_ASSERT(odp_packet_has_error(rx_pkt[i]) == 0); - odp_packet_free(rx_pkt[i]); + odp_packet_data_range_t range; + uint16_t sum; + odp_packet_t pkt = rx_pkt[i]; + + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + CU_ASSERT(odp_packet_input(pkt) == pktio_b->id); + CU_ASSERT(odp_packet_has_error(pkt) == 0); + + /* Dummy read to ones complement in case pktio has set it */ + sum = odp_packet_ones_comp(pkt, &range); + if (range.length > 0) + test_pktio_dummy_u64 += sum; + + /* Dummy read to flow hash in case pktio has set it */ + if (odp_packet_has_flow_hash(pkt)) + test_pktio_dummy_u64 += odp_packet_flow_hash(pkt); + + odp_packet_free(pkt); } }
commit 4da1cb6040dece2ece108cd383ab4212e7f7fe85 Author: Petri Savolainen petri.savolainen@linaro.org Date: Thu Oct 19 17:07:33 2017 +0300
linux-gen: packet: dummy ones complement implementation
Added dummy implementation of ones complement calls. Linux generic implementation does not calculate the sum for all incoming packets as it would be wasteful in SW. It's better to wait until application asks it with odp_chksum_ones_comp16(). Later on, the sum could be stored into the packet header, if we found a way to get it from the HW.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 0bba3098..74e3ff2b 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -1284,6 +1284,14 @@ int odp_packet_l4_offset_set(odp_packet_t pkt, uint32_t offset) return 0; }
+uint16_t odp_packet_ones_comp(odp_packet_t pkt, odp_packet_data_range_t *range) +{ + (void)pkt; + range->length = 0; + range->offset = 0; + return 0; +} + void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t flow_hash) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
commit f6d3bc302664e2c4121e798e86758d93fdb156f5 Author: Petri Savolainen petri.savolainen@linaro.org Date: Thu Oct 19 16:48:45 2017 +0300
api: packet: ones complement sum
Added packet metadata for ones complement sum over packet data. Some NICs calculate the sum during packet input (at least for IP fragments) and store the value into the packet descriptor. This offloads L4 checksum calculation for IP fragments as SW does not need sum all payload data, but just combine pre-calculated sums from packet descriptors and remove extra header fields from the sum.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h index da522c6c..b897c9d3 100644 --- a/include/odp/api/spec/packet.h +++ b/include/odp/api/spec/packet.h @@ -1556,6 +1556,26 @@ void odp_packet_l3_chksum_insert(odp_packet_t pkt, int insert); */ void odp_packet_l4_chksum_insert(odp_packet_t pkt, int insert);
+/** + * Ones' complement sum of packet data + * + * Returns 16-bit ones' complement sum that was calculated over a portion of + * packet data during a packet processing operation (e.g. packet input or + * IPSEC offload). The data range is output with 'range' parameter, and usually + * includes IP payload (L4 headers and payload). When 'range.length' is zero, + * the sum has not been calculated. In case of odd number of bytes, + * calculation uses a zero byte as padding at the end. The sum may be used as + * part of e.g. UDP/TCP checksum checking, especially with IP fragments. + * + * @param pkt Packet handle + * @param[out] range Data range of the sum (output). The calculation started + * from range.offset and included range.length bytes. When + * range.length is zero, the sum has not been calculated. + * + * @return Ones' complement sum over the data range + */ +uint16_t odp_packet_ones_comp(odp_packet_t pkt, odp_packet_data_range_t *range); + /** * Packet flow hash value *
commit 6333b39f1bd5ebe184780260566b84340104efeb Author: Petri Savolainen petri.savolainen@linaro.org Date: Wed Nov 8 14:40:13 2017 +0200
validation: packet: add parse tests
Added validation tests for the new packet parse APIs.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index 37550a2f..f96347b5 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -10,6 +10,7 @@
#include <odp_api.h> #include <odp_cunit_common.h> +#include <test_packet_parser.h> #include "packet.h"
/* Reserve some tailroom for tests */ @@ -2390,6 +2391,201 @@ void packet_test_ref(void) odp_packet_free(ref_pkt[1]); }
+void packet_test_parse(void) +{ + odp_pool_t pool; + odp_pool_param_t param; + odp_packet_parse_param_t parse; + int ret, num_test_pkt, i; + uint32_t len, max_len; + int num_pkt = 10; + odp_packet_t pkt[num_pkt]; + uint32_t offset[num_pkt]; + uint32_t test_pkt_len[] = {sizeof(test_packet_arp), + sizeof(test_packet_ipv4_icmp), + sizeof(test_packet_ipv4_tcp), + sizeof(test_packet_ipv4_udp), + sizeof(test_packet_vlan_ipv4_udp), + sizeof(test_packet_vlan_qinq_ipv4_udp), + sizeof(test_packet_ipv6_icmp), + sizeof(test_packet_ipv6_tcp), + sizeof(test_packet_ipv6_udp), + sizeof(test_packet_vlan_ipv6_udp) }; + + num_test_pkt = sizeof(test_pkt_len) / sizeof(uint32_t); + max_len = 0; + + for (i = 0; i < num_test_pkt; i++) { + if (max_len < test_pkt_len[i]) + max_len = test_pkt_len[i]; + } + + odp_pool_param_init(¶m); + + param.type = ODP_POOL_PACKET; + param.pkt.seg_len = max_len; + param.pkt.len = max_len; + param.pkt.num = 100; + + pool = odp_pool_create("test_parse_pool", ¶m); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + /* Ethernet/IPv4/UDP */ + len = sizeof(test_packet_ipv4_udp); + ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); + CU_ASSERT_FATAL(ret == num_pkt); + + for (i = 0; i < num_pkt; i++) { + ret = odp_packet_copy_from_mem(pkt[i], 0, len, + test_packet_ipv4_udp); + CU_ASSERT(ret == 0); + + offset[i] = 0; + } + + parse.proto = ODP_PROTO_ETH; + parse.layer = ODP_PROTO_LAYER_ALL; + parse.all_check = 0; + + CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); + CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], + num_pkt - 1, &parse) == (num_pkt - 1)); + + for (i = 0; i < num_pkt; i++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_udp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); + + /* IPv4/UDP */ + len = sizeof(test_packet_ipv4_udp); + ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); + CU_ASSERT_FATAL(ret == num_pkt); + + for (i = 0; i < num_pkt; i++) { + ret = odp_packet_copy_from_mem(pkt[i], 0, len, + test_packet_ipv4_udp); + CU_ASSERT(ret == 0); + + offset[i] = 14; + } + + parse.proto = ODP_PROTO_IPV4; + parse.layer = ODP_PROTO_LAYER_L4; + parse.all_check = 0; + + CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); + CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], + num_pkt - 1, &parse) == (num_pkt - 1)); + + for (i = 0; i < num_pkt; i++) { + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_udp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); + + /* Ethernet/IPv4/TCP */ + len = sizeof(test_packet_ipv4_tcp); + ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); + CU_ASSERT_FATAL(ret == num_pkt); + + for (i = 0; i < num_pkt; i++) { + ret = odp_packet_copy_from_mem(pkt[i], 0, len, + test_packet_ipv4_tcp); + CU_ASSERT(ret == 0); + + offset[i] = 0; + } + + parse.proto = ODP_PROTO_ETH; + parse.layer = ODP_PROTO_LAYER_L4; + parse.all_check = 0; + + CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); + CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], + num_pkt - 1, &parse) == (num_pkt - 1)); + + for (i = 0; i < num_pkt; i++) { + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_udp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); + + /* Ethernet/IPv6/UDP */ + len = sizeof(test_packet_ipv6_udp); + ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); + CU_ASSERT_FATAL(ret == num_pkt); + + for (i = 0; i < num_pkt; i++) { + ret = odp_packet_copy_from_mem(pkt[i], 0, len, + test_packet_ipv6_udp); + CU_ASSERT(ret == 0); + + offset[i] = 0; + } + + parse.proto = ODP_PROTO_ETH; + parse.layer = ODP_PROTO_LAYER_L4; + parse.all_check = 0; + + CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); + CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], + num_pkt - 1, &parse) == (num_pkt - 1)); + + for (i = 0; i < num_pkt; i++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(odp_packet_has_udp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); + + /* Ethernet/IPv6/TCP */ + len = sizeof(test_packet_ipv6_tcp); + ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); + CU_ASSERT_FATAL(ret == num_pkt); + + for (i = 0; i < num_pkt; i++) { + ret = odp_packet_copy_from_mem(pkt[i], 0, len, + test_packet_ipv6_tcp); + CU_ASSERT(ret == 0); + + offset[i] = 0; + } + + parse.proto = ODP_PROTO_ETH; + parse.layer = ODP_PROTO_LAYER_ALL; + parse.all_check = 0; + + CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); + CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], + num_pkt - 1, &parse) == (num_pkt - 1)); + + for (i = 0; i < num_pkt; i++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(!odp_packet_has_udp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); + + odp_pool_destroy(pool); +} + odp_testinfo_t packet_suite[] = { ODP_TEST_INFO(packet_test_alloc_free), ODP_TEST_INFO(packet_test_alloc_free_multi), @@ -2420,6 +2616,7 @@ odp_testinfo_t packet_suite[] = { ODP_TEST_INFO(packet_test_align), ODP_TEST_INFO(packet_test_offset), ODP_TEST_INFO(packet_test_ref), + ODP_TEST_INFO(packet_test_parse), ODP_TEST_INFO_NULL, };
diff --git a/test/validation/api/packet/packet.h b/test/validation/api/packet/packet.h index 783b7a11..4e99679e 100644 --- a/test/validation/api/packet/packet.h +++ b/test/validation/api/packet/packet.h @@ -39,6 +39,7 @@ void packet_test_extend_ref(void); void packet_test_align(void); void packet_test_offset(void); void packet_test_ref(void); +void packet_test_parse(void);
/* test arrays: */ extern odp_testinfo_t packet_suite[];
commit 78ced32df325dac7ff58ff28684fdb941f5ec1b3 Author: Petri Savolainen petri.savolainen@linaro.org Date: Wed Nov 8 13:52:13 2017 +0200
validation: pktio: add parser test packet header
Moved parser test packet definitions into a new, common header file. The same test packets can be used in various test suites.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/common/Makefile.am b/test/common/Makefile.am index a3419e0f..fbd5d52f 100644 --- a/test/common/Makefile.am +++ b/test/common/Makefile.am @@ -14,5 +14,5 @@ libthrmask_common_la_CFLAGS = $(AM_CFLAGS) -DTEST_THRMASK
endif
-noinst_HEADERS = test_debug.h +noinst_HEADERS = test_debug.h test_packet_parser.h dist_test_SCRIPTS = run-test.sh diff --git a/test/validation/api/pktio/parser.h b/test/common/test_packet_parser.h similarity index 88% copy from test/validation/api/pktio/parser.h copy to test/common/test_packet_parser.h index 5cc2b988..918e0ad6 100644 --- a/test/validation/api/pktio/parser.h +++ b/test/common/test_packet_parser.h @@ -4,29 +4,20 @@ * SPDX-License-Identifier: BSD-3-Clause */
-#ifndef _ODP_TEST_PARSER_H_ -#define _ODP_TEST_PARSER_H_ - -#include <odp_cunit_common.h> - -/* test functions: */ -void parser_test_arp(void); -void parser_test_ipv4_icmp(void); -void parser_test_ipv4_tcp(void); -void parser_test_ipv4_udp(void); -void parser_test_vlan_ipv4_udp(void); -void parser_test_vlan_qinq_ipv4_udp(void); -void parser_test_ipv6_icmp(void); -void parser_test_ipv6_tcp(void); -void parser_test_ipv6_udp(void); -void parser_test_vlan_ipv6_udp(void); - -/* test array init/term functions: */ -int parser_suite_term(void); -int parser_suite_init(void); - -/* test arrays: */ -extern odp_testinfo_t parser_suite[]; +/** + * @file + * + * Test packets for parser tests + */ + +#ifndef TEST_PACKET_PARSER_H_ +#define TEST_PACKET_PARSER_H_ + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif
/* Test packets without CRC */
@@ -177,4 +168,8 @@ static const uint8_t test_packet_vlan_ipv6_udp[] = { 0x9B, 0x68 };
+#ifdef __cplusplus +} +#endif + #endif diff --git a/test/validation/api/pktio/parser.c b/test/validation/api/pktio/parser.c index dd293a44..66e726d0 100644 --- a/test/validation/api/pktio/parser.c +++ b/test/validation/api/pktio/parser.c @@ -8,6 +8,7 @@
#include <odp_api.h> #include <odp_cunit_common.h> +#include <test_packet_parser.h>
#include <odp/helper/odph_api.h>
diff --git a/test/validation/api/pktio/parser.h b/test/validation/api/pktio/parser.h index 5cc2b988..d95ecca1 100644 --- a/test/validation/api/pktio/parser.h +++ b/test/validation/api/pktio/parser.h @@ -28,153 +28,4 @@ int parser_suite_init(void); /* test arrays: */ extern odp_testinfo_t parser_suite[];
-/* Test packets without CRC */ - -/** - * ARP request - */ -static const uint8_t test_packet_arp[] = { - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x08, 0x06, 0x00, 0x01, - 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0xC0, 0xA8, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xA8, - 0x01, 0x02, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, - 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, - 0x0E, 0x0F, 0x10, 0x11 -}; - -/** - * ICMPv4 echo reply - */ -static const uint8_t test_packet_ipv4_icmp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x08, 0x00, 0x45, 0x00, - 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, - 0xF3, 0x7B, 0xC0, 0xA8, 0x01, 0x01, 0xC4, 0xA8, - 0x01, 0x02, 0x00, 0x00, 0xB7, 0xAB, 0x00, 0x01, - 0x00, 0x02, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, - 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, - 0x0E, 0x0F, 0x10, 0x11 -}; - -/** - * IPv4 TCP - */ -static const uint8_t test_packet_ipv4_tcp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x08, 0x00, 0x45, 0x00, - 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x06, - 0xF3, 0x76, 0xC0, 0xA8, 0x01, 0x02, 0xC4, 0xA8, - 0x01, 0x01, 0x04, 0xD2, 0x10, 0xE1, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x50, 0x00, - 0x00, 0x00, 0x0C, 0xCC, 0x00, 0x00, 0x00, 0x01, - 0x02, 0x03, 0x04, 0x05 -}; - -/** - * IPv4 UDP - */ -static const uint8_t test_packet_ipv4_udp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x08, 0x00, 0x45, 0x00, - 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11, - 0xF3, 0x6B, 0xC0, 0xA8, 0x01, 0x02, 0xC4, 0xA8, - 0x01, 0x01, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x1A, - 0x2F, 0x97, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, - 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, - 0x0E, 0x0F, 0x10, 0x11 -}; - -/** - * VLAN IPv4 UDP - * - ID: 23 - */ -static const uint8_t test_packet_vlan_ipv4_udp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x81, 0x00, 0x00, 0x17, - 0x08, 0x00, 0x45, 0x00, 0x00, 0x2A, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x11, 0xF3, 0x6F, 0xC0, 0xA8, - 0x01, 0x02, 0xC4, 0xA8, 0x01, 0x01, 0x00, 0x3F, - 0x00, 0x3F, 0x00, 0x16, 0x4D, 0xBF, 0x00, 0x01, - 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, - 0x0A, 0x0B, 0x0C, 0x0D -}; - -/** - * VLAN Q-in-Q IPv4 UDP - * - Outer: Tag Protocol ID 0x88a8, VLAN ID 1 - * - Inner: Tag Protocol ID 0x8100, VLAN ID 2 - */ -static const uint8_t test_packet_vlan_qinq_ipv4_udp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x88, 0xA8, 0x00, 0x01, - 0x81, 0x00, 0x00, 0x02, 0x08, 0x00, 0x45, 0x00, - 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11, - 0xF3, 0x73, 0xC0, 0xA8, 0x01, 0x02, 0xC4, 0xA8, - 0x01, 0x01, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x12, - 0x63, 0xDF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, - 0x06, 0x07, 0x08, 0x09 -}; - -/** - * ICMPv6 echo request - */ -static const uint8_t test_packet_ipv6_icmp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x86, 0xDD, 0x60, 0x30, - 0x00, 0x00, 0x00, 0x08, 0x3A, 0xFF, 0xFE, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x09, 0xFF, 0xFE, 0x00, 0x04, 0x00, 0x35, 0x55, - 0x55, 0x55, 0x66, 0x66, 0x66, 0x66, 0x77, 0x77, - 0x77, 0x77, 0x88, 0x88, 0x88, 0x88, 0x80, 0x00, - 0x1B, 0xC2, 0x00, 0x01, 0x00, 0x02 -}; - -/** - * IPv6 TCP - */ -static const uint8_t test_packet_ipv6_tcp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x86, 0xDD, 0x60, 0x30, - 0x00, 0x00, 0x00, 0x14, 0x06, 0xFF, 0xFE, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x09, 0xFF, 0xFE, 0x00, 0x04, 0x00, 0x35, 0x55, - 0x55, 0x55, 0x66, 0x66, 0x66, 0x66, 0x77, 0x77, - 0x77, 0x77, 0x88, 0x88, 0x88, 0x88, 0x04, 0xD2, - 0x10, 0xE1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x02, 0x50, 0x00, 0x00, 0x00, 0x36, 0x37, - 0x00, 0x00 -}; - -/** - * IPv6 UDP - */ -static const uint8_t test_packet_ipv6_udp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x86, 0xDD, 0x60, 0x30, - 0x00, 0x00, 0x00, 0x08, 0x11, 0xFF, 0xFE, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x09, 0xFF, 0xFE, 0x00, 0x04, 0x00, 0x35, 0x55, - 0x55, 0x55, 0x66, 0x66, 0x66, 0x66, 0x77, 0x77, - 0x77, 0x77, 0x88, 0x88, 0x88, 0x88, 0x00, 0x3F, - 0x00, 0x3F, 0x00, 0x08, 0x9B, 0x68 -}; - -/** - * VLAN IPv6 - * - ID: 23 - */ -static const uint8_t test_packet_vlan_ipv6_udp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x81, 0x00, 0x00, 0x17, - 0x86, 0xDD, 0x60, 0x30, 0x00, 0x00, 0x00, 0x08, - 0x11, 0xFF, 0xFE, 0x80, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0x00, 0x09, 0xFF, 0xFE, 0x00, - 0x04, 0x00, 0x35, 0x55, 0x55, 0x55, 0x66, 0x66, - 0x66, 0x66, 0x77, 0x77, 0x77, 0x77, 0x88, 0x88, - 0x88, 0x88, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x08, - 0x9B, 0x68 -}; - #endif
commit fbb6a7feba146acb1495fbdcd93e1b691a7363a0 Author: Petri Savolainen petri.savolainen@linaro.org Date: Wed Nov 8 13:31:27 2017 +0200
linux-gen: packet: add parse API
Implemented new API functions for packet parsing.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index fed562aa..97efcec4 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -322,8 +322,7 @@ static inline void packet_set_ts(odp_packet_hdr_t *pkt_hdr, odp_time_t *ts) }
int packet_parse_common(packet_parser_t *pkt_hdr, const uint8_t *ptr, - uint32_t pkt_len, uint32_t seg_len, - odp_pktio_parser_layer_t layer); + uint32_t pkt_len, uint32_t seg_len, int layer);
int _odp_cls_parse(odp_packet_hdr_t *pkt_hdr, const uint8_t *parseptr);
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 3b2fac21..0bba3098 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -2098,8 +2098,7 @@ static inline int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, uint32_t offset, uint32_t frame_len, uint32_t seg_len, - odp_pktio_parser_layer_t layer, - uint16_t ethtype) + int layer, uint16_t ethtype) { uint8_t ip_proto;
@@ -2199,7 +2198,7 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, */ int packet_parse_common(packet_parser_t *prs, const uint8_t *ptr, uint32_t frame_len, uint32_t seg_len, - odp_pktio_parser_layer_t layer) + int layer) { uint32_t offset; uint16_t ethtype; @@ -2252,6 +2251,63 @@ int packet_parse_l3_l4(odp_packet_hdr_t *pkt_hdr, layer, ethtype); }
+int odp_packet_parse(odp_packet_t pkt, uint32_t offset, + const odp_packet_parse_param_t *param) +{ + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); + void *data; + uint32_t seg_len; + uint32_t packet_len = pkt_hdr->frame_len; + odp_proto_t proto = param->proto; + odp_proto_layer_t layer = param->layer; + int ret; + uint16_t ethtype; + + if (proto == ODP_PROTO_NONE || layer == ODP_PROTO_LAYER_NONE) + return -1; + + data = packet_map(pkt_hdr, offset, &seg_len, NULL); + + if (data == NULL) + return -1; + + packet_parse_reset(pkt_hdr); + + if (proto == ODP_PROTO_ETH) { + ret = packet_parse_common(&pkt_hdr->p, data, packet_len, + seg_len, layer); + + if (ret) + return -1; + } else { + if (proto == ODP_PROTO_IPV4) + ethtype = _ODP_ETHTYPE_IPV4; + else + ethtype = _ODP_ETHTYPE_IPV6; + + ret = packet_parse_common_l3_l4(&pkt_hdr->p, data, offset, + packet_len, seg_len, + layer, ethtype); + + if (ret) + return -1; + } + + return 0; +} + +int odp_packet_parse_multi(const odp_packet_t pkt[], const uint32_t offset[], + int num, const odp_packet_parse_param_t *param) +{ + int i; + + for (i = 0; i < num; i++) + if (odp_packet_parse(pkt[i], offset[i], param)) + return i; + + return num; +} + uint64_t odp_packet_to_u64(odp_packet_t hdl) { return _odp_pri(hdl);
commit 23b6eee83bc5717f4797441bddbb035e3388ff10 Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Nov 3 14:19:52 2017 +0200
api: ipsec: use common protocol layer enum
Use common values between ipsec parse and packet protocol layer enums.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h index 26e852fc..4a33af8e 100644 --- a/include/odp/api/spec/ipsec.h +++ b/include/odp/api/spec/ipsec.h @@ -74,19 +74,19 @@ typedef enum odp_ipsec_op_mode_t { */ typedef enum odp_ipsec_proto_layer_t { /** No layers */ - ODP_IPSEC_LAYER_NONE = 0, + ODP_IPSEC_LAYER_NONE = ODP_PROTO_LAYER_NONE,
/** Layer L2 protocols (Ethernet, VLAN, etc) */ - ODP_IPSEC_LAYER_L2, + ODP_IPSEC_LAYER_L2 = ODP_PROTO_LAYER_L2,
/** Layer L3 protocols (IPv4, IPv6, ICMP, IPSEC, etc) */ - ODP_IPSEC_LAYER_L3, + ODP_IPSEC_LAYER_L3 = ODP_PROTO_LAYER_L3,
/** Layer L4 protocols (UDP, TCP, SCTP) */ - ODP_IPSEC_LAYER_L4, + ODP_IPSEC_LAYER_L4 = ODP_PROTO_LAYER_L4,
/** All layers */ - ODP_IPSEC_LAYER_ALL + ODP_IPSEC_LAYER_ALL = ODP_PROTO_LAYER_ALL
} odp_ipsec_proto_layer_t;
commit 0ec5bc6b5c3a178d7b316bdf9e18db452ba5ed58 Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Nov 3 13:48:38 2017 +0200
api: pktio: use common protocol layer enum
Use common values between pktio parser layer and packet protocol layer enums.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/include/odp/api/spec/packet_io.h b/include/odp/api/spec/packet_io.h index 52af646a..6e4f8810 100644 --- a/include/odp/api/spec/packet_io.h +++ b/include/odp/api/spec/packet_io.h @@ -23,6 +23,7 @@ extern "C" { #include <odp/api/packet_io_stats.h> #include <odp/api/queue.h> #include <odp/api/time.h> +#include <odp/api/packet.h>
/** @defgroup odp_packet_io ODP PACKET IO * Operations on a packet Input/Output interface. @@ -381,19 +382,19 @@ typedef union odp_pktout_config_opt_t { */ typedef enum odp_pktio_parser_layer_t { /** No layers */ - ODP_PKTIO_PARSER_LAYER_NONE = 0, + ODP_PKTIO_PARSER_LAYER_NONE = ODP_PROTO_LAYER_NONE,
/** Layer L2 protocols (Ethernet, VLAN, ARP, etc) */ - ODP_PKTIO_PARSER_LAYER_L2, + ODP_PKTIO_PARSER_LAYER_L2 = ODP_PROTO_LAYER_L2,
/** Layer L3 protocols (IPv4, IPv6, ICMP, IPsec, etc) */ - ODP_PKTIO_PARSER_LAYER_L3, + ODP_PKTIO_PARSER_LAYER_L3 = ODP_PROTO_LAYER_L3,
/** Layer L4 protocols (UDP, TCP, SCTP) */ - ODP_PKTIO_PARSER_LAYER_L4, + ODP_PKTIO_PARSER_LAYER_L4 = ODP_PROTO_LAYER_L4,
/** All layers */ - ODP_PKTIO_PARSER_LAYER_ALL + ODP_PKTIO_PARSER_LAYER_ALL = ODP_PROTO_LAYER_ALL
} odp_pktio_parser_layer_t;
diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_inlines.h index 1804fa6f..22f5aca3 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -15,7 +15,9 @@
#include <odp/api/plat/packet_types.h> #include <odp/api/pool.h> -#include <odp/api/packet_io.h> +#include <odp/api/time.h> +#include <odp/api/plat/packet_io_types.h> +#include <odp/api/plat/buffer_types.h> #include <odp/api/hints.h>
/** @internal Inline function offsets */
commit 9c389e1785fd000203eb2198f9fc2778be8f83e6 Author: Petri Savolainen petri.savolainen@linaro.org Date: Thu Nov 2 16:02:32 2017 +0200
api: packet: add parse functions
Application may need help on packet parsing e.g. after decrypt or IP reassembly of a packet. Application specifies from where to start and where to stop parsing. Implementation may be vectorized (more efficient) when multiple packets are parsed together with the same parse requirements.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h index fac7790b..da522c6c 100644 --- a/include/odp/api/spec/packet.h +++ b/include/odp/api/spec/packet.h @@ -71,6 +71,45 @@ extern "C" { * Packet is red */
+/** + * Protocol + */ +typedef enum odp_proto_t { + /** No protocol defined */ + ODP_PROTO_NONE = 0, + + /** Ethernet (including VLAN) */ + ODP_PROTO_ETH, + + /** IP version 4 */ + ODP_PROTO_IPV4, + + /** IP version 6 */ + ODP_PROTO_IPV6 + +} odp_proto_t; + +/** + * Protocol layer + */ +typedef enum odp_proto_layer_t { + /** No layers */ + ODP_PROTO_LAYER_NONE = 0, + + /** Layer L2 protocols (Ethernet, VLAN, etc) */ + ODP_PROTO_LAYER_L2, + + /** Layer L3 protocols (IPv4, IPv6, ICMP, IPSEC, etc) */ + ODP_PROTO_LAYER_L3, + + /** Layer L4 protocols (UDP, TCP, SCTP) */ + ODP_PROTO_LAYER_L4, + + /** All layers */ + ODP_PROTO_LAYER_ALL + +} odp_proto_layer_t; + /** * Packet API data range specifier */ @@ -1139,6 +1178,87 @@ int odp_packet_move_data(odp_packet_t pkt, uint32_t dst_offset, * */
+/** + * Packet parse parameters + */ +typedef struct odp_packet_parse_param_t { + /** Protocol header at parse starting point. Valid values for this + * field are: ODP_PROTO_ETH, ODP_PROTO_IPV4, ODP_PROTO_IPV6. */ + odp_proto_t proto; + + /** Continue parsing until this layer. Must be the same or higher + * layer than the layer of 'proto'. */ + odp_proto_layer_t layer; + + /** Flags to control payload data checks up to the selected parse + * layer. Checksum checking status can be queried for each packet with + * odp_packet_l3_chksum_status() and odp_packet_l4_chksum_status(). + */ + union { + /** Individual check bits. */ + struct { + /** Check IPv4 header checksum */ + uint32_t ipv4_chksum : 1; + + /** Check UDP checksum */ + uint32_t udp_chksum : 1; + + /** Check TCP checksum */ + uint32_t tcp_chksum : 1; + + /** Check SCTP checksum */ + uint32_t sctp_chksum : 1; + + } check; + + /** All check bits. This can be used to set/clear all flags. */ + uint32_t all_check; + }; + +} odp_packet_parse_param_t; + +/** + * Parse packet + * + * Parse protocol headers in packet data. Parsing starts at 'offset', which + * is the first header byte of protocol 'param.proto'. Parameter 'param.layer' + * defines the last layer application is interested about. + * Use ODP_PROTO_LAYER_ALL for all layers. A successful operation sets or resets + * packet metadata for all layers from the layer of 'param.proto' to the + * application defined last layer. Metadata of other layers have undefined + * values. When operation fails, metadata of all protocol layers have undefined + * values. + * + * @param pkt Packet handle + * @param offset Byte offset into the packet + * @param param Parse parameters. Proto and layer fields must be set. Clear + * all check bits that are not used. + * + * @retval 0 on success + * @retval <0 on failure + */ +int odp_packet_parse(odp_packet_t pkt, uint32_t offset, + const odp_packet_parse_param_t *param); + +/** + * Parse multiple packets + * + * Otherwise like odp_packet_parse(), but parses multiple packets. Packets may + * have unique offsets, but must start with the same protocol. Also, packets are + * parsed up to the same protocol layer. + * + * @param pkt Packet handle array + * @param offset Byte offsets into the packets + * @param num Number of packets and offsets + * @param param Parse parameters. Proto and layer fields must be set. Clear + * all check bits that are not used. + * + * @return Number of packets parsed successfully (0 ... num) + * @retval <0 on failure + */ +int odp_packet_parse_multi(const odp_packet_t pkt[], const uint32_t offset[], + int num, const odp_packet_parse_param_t *param); + /** * Packet pool *
-----------------------------------------------------------------------
Summary of changes: include/odp/api/spec/ipsec.h | 10 +- include/odp/api/spec/packet.h | 140 ++++++++++++++ include/odp/api/spec/packet_io.h | 11 +- .../include/odp/api/plat/packet_inlines.h | 4 +- .../linux-generic/include/odp_packet_internal.h | 3 +- platform/linux-generic/odp_packet.c | 70 ++++++- test/common/Makefile.am | 2 +- .../pktio/parser.h => common/test_packet_parser.h} | 41 ++--- test/validation/api/packet/packet.c | 203 +++++++++++++++++++++ test/validation/api/packet/packet.h | 1 + test/validation/api/pktio/parser.c | 1 + test/validation/api/pktio/parser.h | 149 --------------- test/validation/api/pktio/pktio.c | 25 ++- 13 files changed, 467 insertions(+), 193 deletions(-) copy test/{validation/api/pktio/parser.h => common/test_packet_parser.h} (88%)
hooks/post-receive