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 65d690fbcf03c6a4d5eb3f01bde36807833feaaa (commit) via 8e2b2acb39e27ff172461b425abf2fef6413f522 (commit) via d43523f0e0175ade19a7d944ef7fbd98247f5d7a (commit) via 428099c6200e764bd50581b65084e1e4cbe07dce (commit) via d187988a5f1c16efc67e2bc70730bd3735683742 (commit) via f2092a68171e9cdd83ce9f055b81cba4f9b5899d (commit) via 58a6affec5db9c2e21d21ad5513d45e4b9e07c63 (commit) via cc727d927fe007c1fb85d97bd3225fbb4a044166 (commit) via 0405287898a99821691928e4fd1f9afe91681c3a (commit) via bb77b93e77c75a4a7507543ff0d38d32fe8b51ed (commit) via b8c85795ffd6fc98813b4882ba671866d19762ba (commit) via 015674f10e67c319e6299fe99332787c491d59c2 (commit) from 0c7769e1e8e7893f3631d7c8b8297f87b718d27d (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 65d690fbcf03c6a4d5eb3f01bde36807833feaaa Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Dec 1 16:18:54 2017 +0200
validation: event: filter packet test
Test the new filter packet function.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Balasubramanian Manoharan bala.manoharan@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/api/event/event.c b/test/validation/api/event/event.c index 901fe6ed..5add99c3 100644 --- a/test/validation/api/event/event.c +++ b/test/validation/api/event/event.c @@ -348,11 +348,50 @@ static void event_test_type_multi(void) CU_ASSERT(odp_pool_destroy(pkt_pool) == 0); }
+static void event_test_filter_packet(void) +{ + odp_pool_t buf_pool, pkt_pool; + int i, num_pkt, num_rem; + int num = 2 * NUM_TYPE_TEST; + odp_event_t buf_event[NUM_TYPE_TEST]; + odp_event_t pkt_event[NUM_TYPE_TEST]; + odp_event_t event[num]; + odp_packet_t packet[num]; + odp_event_t remain[num]; + + type_test_init(&buf_pool, &pkt_pool, buf_event, pkt_event, event); + + for (i = 0; i < num; i++) { + packet[i] = ODP_PACKET_INVALID; + remain[i] = ODP_EVENT_INVALID; + } + + num_pkt = odp_event_filter_packet(event, packet, remain, num); + CU_ASSERT(num_pkt == NUM_TYPE_TEST); + + for (i = 0; i < num_pkt; i++) + CU_ASSERT(packet[i] != ODP_PACKET_INVALID); + + num_rem = num - num_pkt; + CU_ASSERT(num_rem == NUM_TYPE_TEST); + + for (i = 0; i < num_rem; i++) { + CU_ASSERT(remain[i] != ODP_EVENT_INVALID); + CU_ASSERT(odp_event_type(remain[i]) == ODP_EVENT_BUFFER); + } + + odp_event_free_multi(event, num); + + CU_ASSERT(odp_pool_destroy(buf_pool) == 0); + CU_ASSERT(odp_pool_destroy(pkt_pool) == 0); +} + odp_testinfo_t event_suite[] = { ODP_TEST_INFO(event_test_free), ODP_TEST_INFO(event_test_free_multi), ODP_TEST_INFO(event_test_free_multi_mixed), ODP_TEST_INFO(event_test_type_multi), + ODP_TEST_INFO(event_test_filter_packet), ODP_TEST_INFO_NULL, };
commit 8e2b2acb39e27ff172461b425abf2fef6413f522 Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Dec 1 15:02:35 2017 +0200
linux-gen: packet: implement event filter packet
Simple implementation of the new event filter packets function.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Balasubramanian Manoharan bala.manoharan@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 cdcb62d2..222fa8c8 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -967,6 +967,27 @@ void odp_packet_to_event_multi(const odp_packet_t pkt[], odp_event_t ev[], ev[i] = odp_packet_to_event(pkt[i]); }
+int odp_event_filter_packet(const odp_event_t event[], + odp_packet_t packet[], + odp_event_t remain[], int num) +{ + int i; + int num_pkt = 0; + int num_rem = 0; + + for (i = 0; i < num; i++) { + if (odp_event_type(event[i]) == ODP_EVENT_PACKET) { + packet[num_pkt] = odp_packet_from_event(event[i]); + num_pkt++; + } else { + remain[num_rem] = event[i]; + num_rem++; + } + } + + return num_pkt; +} + /* * * Pointers and lengths
commit d43523f0e0175ade19a7d944ef7fbd98247f5d7a Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Dec 1 14:44:18 2017 +0200
api: event: filter and convert packets
This call optimizes into a single call the common case of first checking that events are packets and then converting those to packet handles.
while (1) { num = odp_schedule_multi(NULL, 0, event, max_num);
if (num <= 0) continue;
num_pkt = odp_event_filter_packet(event, packet, remain, num);
packet_foo(packet, num_pkt);
other_foo(remain, num - num_pkt); ... }
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Balasubramanian Manoharan bala.manoharan@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/include/odp/api/spec/event.h b/include/odp/api/spec/event.h index e5edaacc..2228c596 100644 --- a/include/odp/api/spec/event.h +++ b/include/odp/api/spec/event.h @@ -19,12 +19,13 @@ extern "C" { #endif
+#include <odp/api/packet.h> + /** @defgroup odp_event ODP EVENT * Operations on an event. * @{ */
- /** * @typedef odp_event_t * ODP event @@ -141,6 +142,27 @@ odp_event_type_t odp_event_types(odp_event_t event, int odp_event_type_multi(const odp_event_t event[], int num, odp_event_type_t *type);
+/** + * Filter and convert packet events + * + * Checks event type of all input events, converts all packet events and outputs + * packet handles. Returns the number packet handles outputted. Outputs the + * remaining, non-packet event handles to 'remain' array. Handles are outputted + * to both arrays in the same order those are stored in 'event' array. Both + * output arrays must fit 'num' elements. + * + * @param event Array of event handles + * @param[out] packet Packet handle array for output + * @param[out] remain Event handle array for output of remaining, non-packet + * events + * @param num Number of events (> 0) + * + * @return Number of packets outputted (0 ... num) + */ +int odp_event_filter_packet(const odp_event_t event[], + odp_packet_t packet[], + odp_event_t remain[], int num); + /** * Get printable value for an odp_event_t *
commit 428099c6200e764bd50581b65084e1e4cbe07dce Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Dec 1 15:41:07 2017 +0200
validation: event: type multi
Test the new event type multi function.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Balasubramanian Manoharan bala.manoharan@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/api/event/event.c b/test/validation/api/event/event.c index fc048c1d..901fe6ed 100644 --- a/test/validation/api/event/event.c +++ b/test/validation/api/event/event.c @@ -245,10 +245,114 @@ static void event_test_free_multi_mixed(void) CU_ASSERT(odp_pool_destroy(pool3) == 0); }
+#define NUM_TYPE_TEST 6 + +static void type_test_init(odp_pool_t *buf_pool, odp_pool_t *pkt_pool, + odp_event_t buf_event[], + odp_event_t pkt_event[], + odp_event_t event[]) +{ + odp_pool_t pool1, pool2; + odp_pool_param_t pool_param; + int i; + odp_buffer_t buf; + odp_packet_t pkt; + + /* Buffer events */ + odp_pool_param_init(&pool_param); + pool_param.buf.num = NUM_EVENTS; + pool_param.buf.size = EVENT_SIZE; + pool_param.type = ODP_POOL_BUFFER; + + pool1 = odp_pool_create("event_type_buf", &pool_param); + CU_ASSERT_FATAL(pool1 != ODP_POOL_INVALID); + + for (i = 0; i < NUM_TYPE_TEST; i++) { + buf = odp_buffer_alloc(pool1); + CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID); + buf_event[i] = odp_buffer_to_event(buf); + } + + /* Packet events */ + odp_pool_param_init(&pool_param); + pool_param.pkt.num = NUM_EVENTS; + pool_param.pkt.len = EVENT_SIZE; + pool_param.type = ODP_POOL_PACKET; + + pool2 = odp_pool_create("event_type_pkt", &pool_param); + CU_ASSERT_FATAL(pool2 != ODP_POOL_INVALID); + + for (i = 0; i < NUM_TYPE_TEST; i++) { + pkt = odp_packet_alloc(pool2, EVENT_SIZE); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + pkt_event[i] = odp_packet_to_event(pkt); + } + + /* 1 buf, 1 pkt, 2 buf, 2 pkt, 3 buf, 3 pkt */ + event[0] = buf_event[0]; + event[1] = pkt_event[0]; + event[2] = buf_event[1]; + event[3] = buf_event[2]; + event[4] = pkt_event[1]; + event[5] = pkt_event[2]; + event[6] = buf_event[3]; + event[7] = buf_event[4]; + event[8] = buf_event[5]; + event[9] = pkt_event[3]; + event[10] = pkt_event[4]; + event[11] = pkt_event[5]; + + *buf_pool = pool1; + *pkt_pool = pool2; +} + +static void event_test_type_multi(void) +{ + odp_pool_t buf_pool, pkt_pool; + odp_event_type_t type; + int num; + odp_event_t buf_event[NUM_TYPE_TEST]; + odp_event_t pkt_event[NUM_TYPE_TEST]; + odp_event_t event[2 * NUM_TYPE_TEST]; + + type_test_init(&buf_pool, &pkt_pool, buf_event, pkt_event, event); + + num = odp_event_type_multi(&event[0], 12, &type); + CU_ASSERT(num == 1); + CU_ASSERT(type == ODP_EVENT_BUFFER); + + num = odp_event_type_multi(&event[1], 11, &type); + CU_ASSERT(num == 1); + CU_ASSERT(type == ODP_EVENT_PACKET); + + num = odp_event_type_multi(&event[2], 10, &type); + CU_ASSERT(num == 2); + CU_ASSERT(type == ODP_EVENT_BUFFER); + + num = odp_event_type_multi(&event[4], 8, &type); + CU_ASSERT(num == 2); + CU_ASSERT(type == ODP_EVENT_PACKET); + + num = odp_event_type_multi(&event[6], 6, &type); + CU_ASSERT(num == 3); + CU_ASSERT(type == ODP_EVENT_BUFFER); + + num = odp_event_type_multi(&event[9], 3, &type); + CU_ASSERT(num == 3); + CU_ASSERT(type == ODP_EVENT_PACKET); + + odp_event_free_multi(buf_event, NUM_TYPE_TEST); + odp_event_free_multi(pkt_event, NUM_TYPE_TEST); + + CU_ASSERT(odp_pool_destroy(buf_pool) == 0); + CU_ASSERT(odp_pool_destroy(pkt_pool) == 0); +} + odp_testinfo_t event_suite[] = { ODP_TEST_INFO(event_test_free), ODP_TEST_INFO(event_test_free_multi), ODP_TEST_INFO(event_test_free_multi_mixed), + ODP_TEST_INFO(event_test_type_multi), ODP_TEST_INFO_NULL, };
commit d187988a5f1c16efc67e2bc70730bd3735683742 Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Dec 1 15:13:02 2017 +0200
linux-gen: event: implement type multi
Simple implementation of the new event type multi function.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Balasubramanian Manoharan bala.manoharan@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/odp_event.c b/platform/linux-generic/odp_event.c index fe12cfbc..d8cc0051 100644 --- a/platform/linux-generic/odp_event.c +++ b/platform/linux-generic/odp_event.c @@ -45,6 +45,22 @@ odp_event_type_t odp_event_types(odp_event_t event, return event_type; }
+int odp_event_type_multi(const odp_event_t event[], int num, + odp_event_type_t *type_out) +{ + int i; + odp_event_type_t type = odp_event_type(event[0]); + + for (i = 1; i < num; i++) { + if (odp_event_type(event[i]) != type) + break; + } + + *type_out = type; + + return i; +} + void odp_event_free(odp_event_t event) { switch (odp_event_type(event)) {
commit f2092a68171e9cdd83ce9f055b81cba4f9b5899d Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Dec 1 14:10:59 2017 +0200
api: event: event type multi
This functions allows application to check event type of multiple events with single call e.g. after receiving those from odp_schedule_multi(). Performance is optimized when application can pass a burst of packets (or other events) from one API call to another.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Balasubramanian Manoharan bala.manoharan@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/include/odp/api/spec/event.h b/include/odp/api/spec/event.h index 7e895c31..e5edaacc 100644 --- a/include/odp/api/spec/event.h +++ b/include/odp/api/spec/event.h @@ -125,6 +125,22 @@ odp_event_subtype_t odp_event_subtype(odp_event_t event); odp_event_type_t odp_event_types(odp_event_t event, odp_event_subtype_t *subtype);
+/** + * Event type of multiple events + * + * Returns the number of first events in the array which have the same event + * type. Outputs the event type of those events. + * + * @param event Array of event handles + * @param num Number of events (> 0) + * @param[out] type Event type pointer for output + * + * @return Number of first events (1 ... num) with the same event type + * (includes event[0]) + */ +int odp_event_type_multi(const odp_event_t event[], int num, + odp_event_type_t *type); + /** * Get printable value for an odp_event_t *
commit 58a6affec5db9c2e21d21ad5513d45e4b9e07c63 Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Dec 1 13:26:23 2017 +0200
validation: packet: multi converts and single pool free
Added tests for the new multi convert and single pool free functions.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Balasubramanian Manoharan bala.manoharan@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 703dfb56..b3ef6980 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -396,6 +396,50 @@ void packet_test_alloc_free_multi(void) CU_ASSERT(odp_pool_destroy(pool[1]) == 0); }
+void packet_test_free_sp(void) +{ + const int num_pkt = 10; + odp_pool_t pool; + int i, ret; + odp_packet_t packet[num_pkt]; + odp_pool_param_t params; + odp_pool_capability_t capa; + uint32_t len = packet_len; + + CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0); + + if (capa.pkt.max_len < len) + len = capa.pkt.max_len; + + odp_pool_param_init(¶ms); + + params.type = ODP_POOL_PACKET; + params.pkt.len = len; + params.pkt.num = num_pkt; + + pool = odp_pool_create("packet_pool_free_sp", ¶ms); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + ret = packet_alloc_multi(pool, len, packet, num_pkt); + CU_ASSERT_FATAL(ret == num_pkt); + for (i = 0; i < num_pkt; i++) { + CU_ASSERT_FATAL(packet[i] != ODP_PACKET_INVALID); + CU_ASSERT(odp_packet_len(packet[i]) == len); + } + odp_packet_free_sp(packet, num_pkt); + + /* Check that all the packets were returned back to the pool */ + ret = packet_alloc_multi(pool, len, packet, num_pkt); + CU_ASSERT_FATAL(ret == num_pkt); + for (i = 0; i < num_pkt; i++) { + CU_ASSERT_FATAL(packet[i] != ODP_PACKET_INVALID); + CU_ASSERT(odp_packet_len(packet[i]) == len); + } + odp_packet_free_sp(packet, num_pkt); + + CU_ASSERT(odp_pool_destroy(pool) == 0); +} + void packet_test_alloc_segmented(void) { const int num = 5; @@ -481,23 +525,41 @@ void packet_test_alloc_segmented(void)
void packet_test_event_conversion(void) { - odp_packet_t pkt = test_packet; + odp_packet_t pkt0 = test_packet; + odp_packet_t pkt1 = segmented_test_packet; odp_packet_t tmp_pkt; - odp_event_t ev; + odp_event_t event; odp_event_subtype_t subtype; - - ev = odp_packet_to_event(pkt); - CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID); - CU_ASSERT(odp_event_type(ev) == ODP_EVENT_PACKET); - CU_ASSERT(odp_event_subtype(ev) == ODP_EVENT_PACKET_BASIC); - CU_ASSERT(odp_event_types(ev, &subtype) == + odp_packet_t pkt[2] = {pkt0, pkt1}; + odp_event_t ev[2]; + int i; + + event = odp_packet_to_event(pkt0); + CU_ASSERT_FATAL(event != ODP_EVENT_INVALID); + CU_ASSERT(odp_event_type(event) == ODP_EVENT_PACKET); + CU_ASSERT(odp_event_subtype(event) == ODP_EVENT_PACKET_BASIC); + CU_ASSERT(odp_event_types(event, &subtype) == ODP_EVENT_PACKET); CU_ASSERT(subtype == ODP_EVENT_PACKET_BASIC);
- tmp_pkt = odp_packet_from_event(ev); + tmp_pkt = odp_packet_from_event(event); CU_ASSERT_FATAL(tmp_pkt != ODP_PACKET_INVALID); - CU_ASSERT(tmp_pkt == pkt); - packet_compare_data(tmp_pkt, pkt); + CU_ASSERT(tmp_pkt == pkt0); + packet_compare_data(tmp_pkt, pkt0); + + odp_packet_to_event_multi(pkt, ev, 2); + + for (i = 0; i < 2; i++) { + CU_ASSERT_FATAL(ev[i] != ODP_EVENT_INVALID); + CU_ASSERT(odp_event_type(ev[i]) == ODP_EVENT_PACKET); + CU_ASSERT(odp_event_subtype(ev[i]) == ODP_EVENT_PACKET_BASIC); + } + + odp_packet_from_event_multi(pkt, ev, 2); + CU_ASSERT(pkt[0] == pkt0); + CU_ASSERT(pkt[1] == pkt1); + packet_compare_data(pkt[0], pkt0); + packet_compare_data(pkt[1], pkt1); }
void packet_test_basic_metadata(void) @@ -2595,6 +2657,7 @@ void packet_test_parse(void) odp_testinfo_t packet_suite[] = { ODP_TEST_INFO(packet_test_alloc_free), ODP_TEST_INFO(packet_test_alloc_free_multi), + ODP_TEST_INFO(packet_test_free_sp), ODP_TEST_INFO(packet_test_alloc_segmented), ODP_TEST_INFO(packet_test_basic_metadata), ODP_TEST_INFO(packet_test_debug), diff --git a/test/validation/api/packet/packet.h b/test/validation/api/packet/packet.h index 4e99679e..1d9947af 100644 --- a/test/validation/api/packet/packet.h +++ b/test/validation/api/packet/packet.h @@ -12,6 +12,7 @@ /* test functions: */ void packet_test_alloc_free(void); void packet_test_alloc_free_multi(void); +void packet_test_free_sp(void); void packet_test_alloc_segmented(void); void packet_test_event_conversion(void); void packet_test_basic_metadata(void);
commit cc727d927fe007c1fb85d97bd3225fbb4a044166 Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Dec 1 13:02:25 2017 +0200
linux-gen: packet: multi converts and single pool free
Simple implement of the new multi convert and single pool free functions.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Balasubramanian Manoharan bala.manoharan@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 bdcb482f..cdcb62d2 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -912,6 +912,11 @@ void odp_packet_free_multi(const odp_packet_t pkt[], int num) packet_free_multi(buf_hdr, num - num_freed); }
+void odp_packet_free_sp(const odp_packet_t pkt[], int num) +{ + odp_packet_free_multi(pkt, num); +} + int odp_packet_reset(odp_packet_t pkt, uint32_t len) { odp_packet_hdr_t *const pkt_hdr = packet_hdr(pkt); @@ -944,6 +949,24 @@ odp_event_t odp_packet_to_event(odp_packet_t pkt) return (odp_event_t)buffer_handle(packet_hdr(pkt)); }
+void odp_packet_from_event_multi(odp_packet_t pkt[], const odp_event_t ev[], + int num) +{ + int i; + + for (i = 0; i < num; i++) + pkt[i] = odp_packet_from_event(ev[i]); +} + +void odp_packet_to_event_multi(const odp_packet_t pkt[], odp_event_t ev[], + int num) +{ + int i; + + for (i = 0; i < num; i++) + ev[i] = odp_packet_to_event(pkt[i]); +} + /* * * Pointers and lengths
commit 0405287898a99821691928e4fd1f9afe91681c3a Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Dec 1 12:55:20 2017 +0200
api: packet: multi converts and single pool free
Added multi versions for better throughput. Convert multiple packets/events with a single call. Free multiple packets into the same originating pool.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Balasubramanian Manoharan bala.manoharan@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 19572034..bb62ef87 100644 --- a/include/odp/api/spec/packet.h +++ b/include/odp/api/spec/packet.h @@ -204,6 +204,17 @@ void odp_packet_free(odp_packet_t pkt); */ void odp_packet_free_multi(const odp_packet_t pkt[], int num);
+/** + * Free multiple packets to the same pool + * + * Otherwise like odp_packet_free_multi(), but all packets must be from the + * same originating pool. + * + * @param pkt Array of packet handles + * @param num Number of packets to free + */ +void odp_packet_free_sp(const odp_packet_t pkt[], int num); + /** * Reset packet * @@ -235,6 +246,18 @@ int odp_packet_reset(odp_packet_t pkt, uint32_t len); */ odp_packet_t odp_packet_from_event(odp_event_t ev);
+/** + * Convert multiple packet events to packet handles + * + * All events must be of type ODP_EVENT_PACKET. + * + * @param[out] pkt Packet handle array for output + * @param ev Array of event handles to convert + * @param num Number of packets and events + */ +void odp_packet_from_event_multi(odp_packet_t pkt[], const odp_event_t ev[], + int num); + /** * Convert packet handle to event * @@ -244,6 +267,16 @@ odp_packet_t odp_packet_from_event(odp_event_t ev); */ odp_event_t odp_packet_to_event(odp_packet_t pkt);
+/** + * Convert multiple packet handles to events + * + * @param pkt Array of packet handles to convert + * @param[out] ev Event handle array for output + * @param num Number of packets and events + */ +void odp_packet_to_event_multi(const odp_packet_t pkt[], odp_event_t ev[], + int num); + /* * * Pointers and lengths
commit bb77b93e77c75a4a7507543ff0d38d32fe8b51ed Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Dec 1 11:19:30 2017 +0200
validation: event: add event test suite
Added suite for event API tests. Test event types, free and free multiple event functions.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Balasubramanian Manoharan bala.manoharan@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/m4/configure.m4 b/test/m4/configure.m4 index ef6096e8..dd07839f 100644 --- a/test/m4/configure.m4 +++ b/test/m4/configure.m4 @@ -15,6 +15,7 @@ AC_CONFIG_FILES([test/Makefile test/validation/api/cpumask/Makefile test/validation/api/crypto/Makefile test/validation/api/errno/Makefile + test/validation/api/event/Makefile test/validation/api/hash/Makefile test/validation/api/init/Makefile test/validation/api/ipsec/Makefile diff --git a/test/validation/api/Makefile.am b/test/validation/api/Makefile.am index be3fb63e..0503e092 100644 --- a/test/validation/api/Makefile.am +++ b/test/validation/api/Makefile.am @@ -6,6 +6,7 @@ ODP_MODULES = atomic \ cpumask \ crypto \ errno \ + event \ hash \ init \ ipsec \ @@ -38,6 +39,7 @@ TESTS = \ cpumask/cpumask_main$(EXEEXT) \ crypto/crypto_main$(EXEEXT) \ errno/errno_main$(EXEEXT) \ + event/event_main$(EXEEXT) \ hash/hash_main$(EXEEXT) \ init/init_main_ok$(EXEEXT) \ init/init_main_abort$(EXEEXT) \ diff --git a/test/validation/api/event/.gitignore b/test/validation/api/event/.gitignore new file mode 100644 index 00000000..05d34d7c --- /dev/null +++ b/test/validation/api/event/.gitignore @@ -0,0 +1 @@ +event_main diff --git a/test/validation/api/event/Makefile.am b/test/validation/api/event/Makefile.am new file mode 100644 index 00000000..be4764b5 --- /dev/null +++ b/test/validation/api/event/Makefile.am @@ -0,0 +1,5 @@ +include ../Makefile.inc + +test_PROGRAMS = event_main +event_main_SOURCES = event_main.c event.c event.h +event_main_LDADD = $(LIBCUNIT_COMMON) $(LIBODP) diff --git a/test/validation/api/event/event.c b/test/validation/api/event/event.c new file mode 100644 index 00000000..fc048c1d --- /dev/null +++ b/test/validation/api/event/event.c @@ -0,0 +1,274 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "config.h" +#include <odp_api.h> +#include <odp_cunit_common.h> +#include "event.h" + +#define NUM_EVENTS 100 +#define EVENT_SIZE 100 +#define EVENT_BURST 10 + +static void event_test_free(void) +{ + odp_pool_t pool; + odp_pool_param_t pool_param; + int i; + odp_buffer_t buf; + odp_packet_t pkt; + odp_timeout_t tmo; + odp_event_subtype_t subtype; + odp_event_t event[EVENT_BURST]; + + /* Buffer events */ + odp_pool_param_init(&pool_param); + pool_param.buf.num = NUM_EVENTS; + pool_param.buf.size = EVENT_SIZE; + pool_param.type = ODP_POOL_BUFFER; + + pool = odp_pool_create("event_free", &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + for (i = 0; i < EVENT_BURST; i++) { + buf = odp_buffer_alloc(pool); + CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID); + event[i] = odp_buffer_to_event(buf); + CU_ASSERT(odp_event_type(event[i]) == ODP_EVENT_BUFFER); + CU_ASSERT(odp_event_subtype(event[i]) == ODP_EVENT_NO_SUBTYPE); + CU_ASSERT(odp_event_types(event[i], &subtype) == + ODP_EVENT_BUFFER); + CU_ASSERT(subtype == ODP_EVENT_NO_SUBTYPE); + } + + for (i = 0; i < EVENT_BURST; i++) + odp_event_free(event[i]); + + CU_ASSERT(odp_pool_destroy(pool) == 0); + + /* Packet events */ + odp_pool_param_init(&pool_param); + pool_param.pkt.num = NUM_EVENTS; + pool_param.pkt.len = EVENT_SIZE; + pool_param.type = ODP_POOL_PACKET; + + pool = odp_pool_create("event_free", &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + for (i = 0; i < EVENT_BURST; i++) { + pkt = odp_packet_alloc(pool, EVENT_SIZE); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + event[i] = odp_packet_to_event(pkt); + CU_ASSERT(odp_event_type(event[i]) == ODP_EVENT_PACKET); + CU_ASSERT(odp_event_subtype(event[i]) == + ODP_EVENT_PACKET_BASIC); + CU_ASSERT(odp_event_types(event[i], &subtype) == + ODP_EVENT_PACKET); + CU_ASSERT(subtype == ODP_EVENT_PACKET_BASIC); + } + + for (i = 0; i < EVENT_BURST; i++) + odp_event_free(event[i]); + + CU_ASSERT(odp_pool_destroy(pool) == 0); + + /* Timeout events */ + odp_pool_param_init(&pool_param); + pool_param.tmo.num = NUM_EVENTS; + pool_param.type = ODP_POOL_TIMEOUT; + + pool = odp_pool_create("event_free", &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + for (i = 0; i < EVENT_BURST; i++) { + tmo = odp_timeout_alloc(pool); + CU_ASSERT_FATAL(tmo != ODP_TIMEOUT_INVALID); + event[i] = odp_timeout_to_event(tmo); + CU_ASSERT(odp_event_type(event[i]) == ODP_EVENT_TIMEOUT); + CU_ASSERT(odp_event_subtype(event[i]) == ODP_EVENT_NO_SUBTYPE); + CU_ASSERT(odp_event_types(event[i], &subtype) == + ODP_EVENT_TIMEOUT); + CU_ASSERT(subtype == ODP_EVENT_NO_SUBTYPE); + } + + for (i = 0; i < EVENT_BURST; i++) + odp_event_free(event[i]); + + CU_ASSERT(odp_pool_destroy(pool) == 0); +} + +static void event_test_free_multi(void) +{ + odp_pool_t pool; + odp_pool_param_t pool_param; + int i, j; + odp_buffer_t buf; + odp_packet_t pkt; + odp_timeout_t tmo; + odp_event_t event[EVENT_BURST]; + + /* Buffer events */ + odp_pool_param_init(&pool_param); + pool_param.buf.num = NUM_EVENTS; + pool_param.buf.size = EVENT_SIZE; + pool_param.type = ODP_POOL_BUFFER; + + pool = odp_pool_create("event_free", &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + for (j = 0; j < 2; j++) { + for (i = 0; i < EVENT_BURST; i++) { + buf = odp_buffer_alloc(pool); + CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID); + event[i] = odp_buffer_to_event(buf); + } + + if (j == 0) + odp_event_free_multi(event, EVENT_BURST); + else + odp_event_free_sp(event, EVENT_BURST); + } + + CU_ASSERT(odp_pool_destroy(pool) == 0); + + /* Packet events */ + odp_pool_param_init(&pool_param); + pool_param.pkt.num = NUM_EVENTS; + pool_param.pkt.len = EVENT_SIZE; + pool_param.type = ODP_POOL_PACKET; + + pool = odp_pool_create("event_free", &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + for (j = 0; j < 2; j++) { + for (i = 0; i < EVENT_BURST; i++) { + pkt = odp_packet_alloc(pool, EVENT_SIZE); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + event[i] = odp_packet_to_event(pkt); + } + + if (j == 0) + odp_event_free_multi(event, EVENT_BURST); + else + odp_event_free_sp(event, EVENT_BURST); + } + + CU_ASSERT(odp_pool_destroy(pool) == 0); + + /* Timeout events */ + odp_pool_param_init(&pool_param); + pool_param.tmo.num = NUM_EVENTS; + pool_param.type = ODP_POOL_TIMEOUT; + + pool = odp_pool_create("event_free", &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + for (j = 0; j < 2; j++) { + for (i = 0; i < EVENT_BURST; i++) { + tmo = odp_timeout_alloc(pool); + CU_ASSERT_FATAL(tmo != ODP_TIMEOUT_INVALID); + event[i] = odp_timeout_to_event(tmo); + } + + if (j == 0) + odp_event_free_multi(event, EVENT_BURST); + else + odp_event_free_sp(event, EVENT_BURST); + } + + CU_ASSERT(odp_pool_destroy(pool) == 0); +} + +static void event_test_free_multi_mixed(void) +{ + odp_pool_t pool1, pool2, pool3; + odp_pool_param_t pool_param; + int i, j; + odp_buffer_t buf; + odp_packet_t pkt; + odp_timeout_t tmo; + odp_event_t event[3 * EVENT_BURST]; + + /* Buffer events */ + odp_pool_param_init(&pool_param); + pool_param.buf.num = NUM_EVENTS; + pool_param.buf.size = EVENT_SIZE; + pool_param.type = ODP_POOL_BUFFER; + + pool1 = odp_pool_create("event_free1", &pool_param); + CU_ASSERT_FATAL(pool1 != ODP_POOL_INVALID); + + /* Packet events */ + odp_pool_param_init(&pool_param); + pool_param.pkt.num = NUM_EVENTS; + pool_param.pkt.len = EVENT_SIZE; + pool_param.type = ODP_POOL_PACKET; + + pool2 = odp_pool_create("event_free2", &pool_param); + CU_ASSERT_FATAL(pool2 != ODP_POOL_INVALID); + + /* Timeout events */ + odp_pool_param_init(&pool_param); + pool_param.tmo.num = NUM_EVENTS; + pool_param.type = ODP_POOL_TIMEOUT; + + pool3 = odp_pool_create("event_free3", &pool_param); + CU_ASSERT_FATAL(pool3 != ODP_POOL_INVALID); + + for (j = 0; j < 2; j++) { + for (i = 0; i < 3 * EVENT_BURST;) { + buf = odp_buffer_alloc(pool1); + CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID); + event[i] = odp_buffer_to_event(buf); + i++; + pkt = odp_packet_alloc(pool2, EVENT_SIZE); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + event[i] = odp_packet_to_event(pkt); + i++; + tmo = odp_timeout_alloc(pool3); + CU_ASSERT_FATAL(tmo != ODP_TIMEOUT_INVALID); + event[i] = odp_timeout_to_event(tmo); + i++; + } + + if (j == 0) + odp_event_free_multi(event, 3 * EVENT_BURST); + else + odp_event_free_sp(event, 3 * EVENT_BURST); + } + + CU_ASSERT(odp_pool_destroy(pool1) == 0); + CU_ASSERT(odp_pool_destroy(pool2) == 0); + CU_ASSERT(odp_pool_destroy(pool3) == 0); +} + +odp_testinfo_t event_suite[] = { + ODP_TEST_INFO(event_test_free), + ODP_TEST_INFO(event_test_free_multi), + ODP_TEST_INFO(event_test_free_multi_mixed), + ODP_TEST_INFO_NULL, +}; + +odp_suiteinfo_t event_suites[] = { + {"Event", NULL, NULL, event_suite}, + ODP_SUITE_INFO_NULL, +}; + +int event_main(int argc, char *argv[]) +{ + int ret; + + /* parse common options: */ + if (odp_cunit_parse_options(argc, argv)) + return -1; + + ret = odp_cunit_register(event_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; +} diff --git a/test/validation/api/event/event.h b/test/validation/api/event/event.h new file mode 100644 index 00000000..1d2b6e69 --- /dev/null +++ b/test/validation/api/event/event.h @@ -0,0 +1,12 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _ODP_TEST_EVENT_H_ +#define _ODP_TEST_EVENT_H_ + +int event_main(int argc, char *argv[]); + +#endif diff --git a/test/validation/api/event/event_main.c b/test/validation/api/event/event_main.c new file mode 100644 index 00000000..3fbefdb8 --- /dev/null +++ b/test/validation/api/event/event_main.c @@ -0,0 +1,13 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "config.h" +#include "event.h" + +int main(int argc, char *argv[]) +{ + return event_main(argc, argv); +}
commit b8c85795ffd6fc98813b4882ba671866d19762ba Author: Petri Savolainen petri.savolainen@linaro.org Date: Thu Nov 30 16:25:34 2017 +0200
linux-gen: event: free multiple functions
Simple implementation of the new functions.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Balasubramanian Manoharan bala.manoharan@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/odp_event.c b/platform/linux-generic/odp_event.c index 4a37b5e4..fe12cfbc 100644 --- a/platform/linux-generic/odp_event.c +++ b/platform/linux-generic/odp_event.c @@ -68,6 +68,19 @@ void odp_event_free(odp_event_t event) } }
+void odp_event_free_multi(const odp_event_t event[], int num) +{ + int i; + + for (i = 0; i < num; i++) + odp_event_free(event[i]); +} + +void odp_event_free_sp(const odp_event_t event[], int num) +{ + odp_event_free_multi(event, num); +} + uint64_t odp_event_to_u64(odp_event_t hdl) { return _odp_pri(hdl);
commit 015674f10e67c319e6299fe99332787c491d59c2 Author: Petri Savolainen petri.savolainen@linaro.org Date: Thu Nov 30 16:20:36 2017 +0200
api: event: add free multiple
It's more efficient to free multiple events with a single call than with separate calls.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Balasubramanian Manoharan bala.manoharan@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/include/odp/api/spec/event.h b/include/odp/api/spec/event.h index f924973f..7e895c31 100644 --- a/include/odp/api/spec/event.h +++ b/include/odp/api/spec/event.h @@ -149,6 +149,28 @@ uint64_t odp_event_to_u64(odp_event_t hdl); */ void odp_event_free(odp_event_t event);
+/** + * Free multiple events + * + * Otherwise like odp_event_free(), but frees multiple events to their + * originating pools. + * + * @param event Array of event handles + * @param num Number of events to free + */ +void odp_event_free_multi(const odp_event_t event[], int num); + +/** + * Free multiple events to the same pool + * + * Otherwise like odp_event_free_multi(), but all events must be from the + * same originating pool. + * + * @param event Array of event handles + * @param num Number of events to free + */ +void odp_event_free_sp(const odp_event_t event[], int num); + /** * @} */
-----------------------------------------------------------------------
Summary of changes: include/odp/api/spec/event.h | 62 ++- include/odp/api/spec/packet.h | 33 ++ platform/linux-generic/odp_event.c | 29 ++ platform/linux-generic/odp_packet.c | 44 +++ test/m4/configure.m4 | 1 + test/validation/api/Makefile.am | 2 + test/validation/api/event/.gitignore | 1 + test/validation/api/event/Makefile.am | 5 + test/validation/api/event/event.c | 417 +++++++++++++++++++++ .../api/{chksum/chksum_main.c => event/event.h} | 10 +- .../{chksum/chksum_main.c => event/event_main.c} | 5 +- test/validation/api/packet/packet.c | 85 ++++- test/validation/api/packet/packet.h | 1 + 13 files changed, 676 insertions(+), 19 deletions(-) create mode 100644 test/validation/api/event/.gitignore create mode 100644 test/validation/api/event/Makefile.am create mode 100644 test/validation/api/event/event.c copy test/validation/api/{chksum/chksum_main.c => event/event.h} (53%) copy test/validation/api/{chksum/chksum_main.c => event/event_main.c} (68%)
hooks/post-receive