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, next has been updated via ba35a19abe1f5d3022975ce9b14a30ff3c4c1ae5 (commit) via 9a03587efe2571aaf9de561781b6c43d2e6a554f (commit) via 493bfccaae853707eeb6c08144c7e0a253cba761 (commit) via f275346606fdf487975cdef6654f81987c2df666 (commit) via 73d3de15ddcf99ac67fe14a59ba6e2f70907bcfe (commit) from 23e7745272bd405483da737824af25e2e18c8b21 (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 ba35a19abe1f5d3022975ce9b14a30ff3c4c1ae5 Author: Petri Savolainen petri.savolainen@nokia.com Date: Tue Jan 10 11:19:09 2017 +0200
validation: packet: limit number of failed asserts
When data compare fails on one byte, it will likely fail on many other bytes and flood CUnit output with asserts. Limit the number of failed asserts to one.
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/common_plat/validation/api/packet/packet.c b/test/common_plat/validation/api/packet/packet.c index a48b238..fa5206f 100644 --- a/test/common_plat/validation/api/packet/packet.c +++ b/test/common_plat/validation/api/packet/packet.c @@ -1564,12 +1564,20 @@ void packet_test_extend_small(void) CU_ASSERT(odp_packet_copy_to_mem(pkt, 0, len, buf) == 0);
for (i = 0; i < len; i++) { + int match; + if (tail) { - /* assert needs brackets */ - CU_ASSERT(buf[i] == (i % 256)); + match = (buf[i] == (i % 256)); + CU_ASSERT(match); } else { - CU_ASSERT(buf[len - 1 - i] == (i % 256)); + match = (buf[len - 1 - i] == (i % 256)); + CU_ASSERT(match); } + + /* Limit the number of failed asserts to + one per packet */ + if (!match) + break; }
odp_packet_free(pkt); @@ -1613,13 +1621,6 @@ void packet_test_extend_large(void) ext_len = len / div; cur_len = ext_len;
- div++; - if (div > num_div) { - /* test extend head */ - div = 1; - tail = 0; - } - pkt = odp_packet_alloc(pool, ext_len); CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
@@ -1678,15 +1679,30 @@ void packet_test_extend_large(void) CU_ASSERT(odp_packet_copy_to_mem(pkt, 0, len, buf) == 0);
for (i = 0; i < len; i++) { + int match; + if (tail) { - /* assert needs brackets */ - CU_ASSERT(buf[i] == (i % 256)); + match = (buf[i] == (i % 256)); + CU_ASSERT(match); } else { - CU_ASSERT(buf[len - 1 - i] == (i % 256)); + match = (buf[len - 1 - i] == (i % 256)); + CU_ASSERT(match); } + + /* Limit the number of failed asserts to + one per packet */ + if (!match) + break; }
odp_packet_free(pkt); + + div++; + if (div > num_div) { + /* test extend head */ + div = 1; + tail = 0; + } }
CU_ASSERT(odp_pool_destroy(pool) == 0); @@ -1782,12 +1798,20 @@ void packet_test_extend_mix(void) CU_ASSERT(odp_packet_copy_to_mem(pkt, 0, len, buf) == 0);
for (i = 0; i < len; i++) { + int match; + if (tail) { - /* assert needs brackets */ - CU_ASSERT(buf[i] == (i % 256)); + match = (buf[i] == (i % 256)); + CU_ASSERT(match); } else { - CU_ASSERT(buf[len - 1 - i] == (i % 256)); + match = (buf[len - 1 - i] == (i % 256)); + CU_ASSERT(match); } + + /* Limit the number of failed asserts to + one per packet */ + if (!match) + break; }
odp_packet_free(pkt);
commit 9a03587efe2571aaf9de561781b6c43d2e6a554f Author: Petri Savolainen petri.savolainen@nokia.com Date: Tue Jan 10 11:19:08 2017 +0200
validation: packet: add line number to compare data checks
Added line number to identify which compare data call fails.
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/common_plat/validation/api/packet/packet.c b/test/common_plat/validation/api/packet/packet.c index cf11c01..a48b238 100644 --- a/test/common_plat/validation/api/packet/packet.c +++ b/test/common_plat/validation/api/packet/packet.c @@ -32,11 +32,19 @@ static struct udata_struct { "abcdefg", };
-static void _packet_compare_data(odp_packet_t pkt1, odp_packet_t pkt2) +#define packet_compare_offset(pkt1, off1, pkt2, off2, len) \ + _packet_compare_offset((pkt1), (off1), (pkt2), (off2), (len), __LINE__) + +#define packet_compare_data(pkt1, pkt2) \ + _packet_compare_data((pkt1), (pkt2), __LINE__) + +static void _packet_compare_data(odp_packet_t pkt1, odp_packet_t pkt2, + int line) { uint32_t len = odp_packet_len(pkt1); uint32_t offset = 0; uint32_t seglen1, seglen2, cmplen; + int ret;
CU_ASSERT_FATAL(len == odp_packet_len(pkt2));
@@ -47,7 +55,14 @@ static void _packet_compare_data(odp_packet_t pkt1, odp_packet_t pkt2) CU_ASSERT_PTR_NOT_NULL_FATAL(pkt1map); CU_ASSERT_PTR_NOT_NULL_FATAL(pkt2map); cmplen = seglen1 < seglen2 ? seglen1 : seglen2; - CU_ASSERT(!memcmp(pkt1map, pkt2map, cmplen)); + ret = memcmp(pkt1map, pkt2map, cmplen); + + if (ret) { + printf("\ncompare_data failed: line %i, offset %" + PRIu32 "\n", line, offset); + } + + CU_ASSERT(ret == 0);
offset += cmplen; len -= cmplen; @@ -422,7 +437,7 @@ void packet_test_event_conversion(void) tmp_pkt = odp_packet_from_event(ev); CU_ASSERT_FATAL(tmp_pkt != ODP_PACKET_INVALID); CU_ASSERT(tmp_pkt == pkt); - _packet_compare_data(tmp_pkt, pkt); + packet_compare_data(tmp_pkt, pkt); }
void packet_test_basic_metadata(void) @@ -1062,9 +1077,10 @@ static void _packet_compare_udata(odp_packet_t pkt1, odp_packet_t pkt2)
static void _packet_compare_offset(odp_packet_t pkt1, uint32_t off1, odp_packet_t pkt2, uint32_t off2, - uint32_t len) + uint32_t len, int line) { uint32_t seglen1, seglen2, cmplen; + int ret;
if (off1 + len > odp_packet_len(pkt1) || off2 + len > odp_packet_len(pkt2)) @@ -1079,7 +1095,15 @@ static void _packet_compare_offset(odp_packet_t pkt1, uint32_t off1, cmplen = seglen1 < seglen2 ? seglen1 : seglen2; if (len < cmplen) cmplen = len; - CU_ASSERT(!memcmp(pkt1map, pkt2map, cmplen)); + + ret = memcmp(pkt1map, pkt2map, cmplen); + + if (ret) { + printf("\ncompare_offset failed: line %i, off1 %" + PRIu32 ", off2 %" PRIu32 "\n", line, off1, off2); + } + + CU_ASSERT(ret == 0);
off1 += cmplen; off2 += cmplen; @@ -1102,7 +1126,7 @@ void packet_test_copy(void)
pkt = odp_packet_copy(test_packet, odp_packet_pool(test_packet)); CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); - _packet_compare_data(pkt, test_packet); + packet_compare_data(pkt, test_packet); pool = odp_packet_pool(pkt); CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); pkt_copy = odp_packet_copy(pkt, pool); @@ -1113,7 +1137,7 @@ void packet_test_copy(void) CU_ASSERT(odp_packet_len(pkt) == odp_packet_len(pkt_copy));
_packet_compare_inflags(pkt, pkt_copy); - _packet_compare_data(pkt, pkt_copy); + packet_compare_data(pkt, pkt_copy); CU_ASSERT(odp_packet_user_area_size(pkt) == odp_packet_user_area_size(test_packet)); _packet_compare_udata(pkt, pkt_copy); @@ -1122,7 +1146,7 @@ void packet_test_copy(void)
pkt = odp_packet_copy(test_packet, packet_pool_double_uarea); CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); - _packet_compare_data(pkt, test_packet); + packet_compare_data(pkt, test_packet); pool = odp_packet_pool(pkt); CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); pkt_copy = odp_packet_copy(pkt, pool); @@ -1133,7 +1157,7 @@ void packet_test_copy(void) CU_ASSERT(odp_packet_len(pkt) == odp_packet_len(pkt_copy));
_packet_compare_inflags(pkt, pkt_copy); - _packet_compare_data(pkt, pkt_copy); + packet_compare_data(pkt, pkt_copy); CU_ASSERT(odp_packet_user_area_size(pkt) == 2 * odp_packet_user_area_size(test_packet)); _packet_compare_udata(pkt, pkt_copy); @@ -1152,7 +1176,7 @@ void packet_test_copy(void) CU_ASSERT(odp_packet_data(pkt) != odp_packet_data(pkt_part)); CU_ASSERT(odp_packet_len(pkt) == odp_packet_len(pkt_part));
- _packet_compare_data(pkt, pkt_part); + packet_compare_data(pkt, pkt_part); odp_packet_free(pkt_part);
plen = odp_packet_len(pkt); @@ -1160,14 +1184,14 @@ void packet_test_copy(void) pkt_part = odp_packet_copy_part(pkt, i, plen / 4, pool); CU_ASSERT_FATAL(pkt_part != ODP_PACKET_INVALID); CU_ASSERT(odp_packet_len(pkt_part) == plen / 4); - _packet_compare_offset(pkt_part, 0, pkt, i, plen / 4); + packet_compare_offset(pkt_part, 0, pkt, i, plen / 4); odp_packet_free(pkt_part); }
/* Test copy and move apis */ CU_ASSERT(odp_packet_copy_data(pkt, 0, plen - plen / 8, plen / 8) == 0); - _packet_compare_offset(pkt, 0, pkt, plen - plen / 8, plen / 8); - _packet_compare_offset(pkt, 0, test_packet, plen - plen / 8, plen / 8); + packet_compare_offset(pkt, 0, pkt, plen - plen / 8, plen / 8); + packet_compare_offset(pkt, 0, test_packet, plen - plen / 8, plen / 8);
/* Test segment crossing if we support segments */ pkt_data = odp_packet_offset(pkt, 0, &seg_len, NULL); @@ -1183,7 +1207,7 @@ void packet_test_copy(void)
pkt_part = odp_packet_copy_part(pkt, src_offset, 20, pool); CU_ASSERT(odp_packet_move_data(pkt, dst_offset, src_offset, 20) == 0); - _packet_compare_offset(pkt, dst_offset, pkt_part, 0, 20); + packet_compare_offset(pkt, dst_offset, pkt_part, 0, 20);
odp_packet_free(pkt_part); odp_packet_free(pkt); @@ -1232,7 +1256,7 @@ void packet_test_copydata(void) 1) == 0); }
- _packet_compare_offset(pkt, 0, test_packet, 0, pkt_len / 2); + packet_compare_offset(pkt, 0, test_packet, 0, pkt_len / 2); odp_packet_free(pkt);
pkt = odp_packet_alloc(odp_packet_pool(segmented_test_packet), @@ -1242,9 +1266,9 @@ void packet_test_copydata(void) CU_ASSERT(odp_packet_copy_from_pkt(pkt, 0, segmented_test_packet, odp_packet_len(pkt) / 4, odp_packet_len(pkt)) == 0); - _packet_compare_offset(pkt, 0, segmented_test_packet, - odp_packet_len(pkt) / 4, - odp_packet_len(pkt)); + packet_compare_offset(pkt, 0, segmented_test_packet, + odp_packet_len(pkt) / 4, + odp_packet_len(pkt)); odp_packet_free(pkt); }
@@ -1266,14 +1290,14 @@ void packet_test_concatsplit(void)
CU_ASSERT(odp_packet_concat(&pkt, pkt2) >= 0); CU_ASSERT(odp_packet_len(pkt) == pkt_len * 2); - _packet_compare_offset(pkt, 0, pkt, pkt_len, pkt_len); + packet_compare_offset(pkt, 0, pkt, pkt_len, pkt_len);
CU_ASSERT(odp_packet_split(&pkt, pkt_len, &pkt2) == 0); CU_ASSERT(pkt != pkt2); CU_ASSERT(odp_packet_data(pkt) != odp_packet_data(pkt2)); CU_ASSERT(odp_packet_len(pkt) == odp_packet_len(pkt2)); - _packet_compare_data(pkt, pkt2); - _packet_compare_data(pkt, test_packet); + packet_compare_data(pkt, pkt2); + packet_compare_data(pkt, test_packet);
odp_packet_free(pkt); odp_packet_free(pkt2); @@ -1283,26 +1307,26 @@ void packet_test_concatsplit(void) CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); pkt_len = odp_packet_len(pkt);
- _packet_compare_data(pkt, segmented_test_packet); + packet_compare_data(pkt, segmented_test_packet); CU_ASSERT(odp_packet_split(&pkt, pkt_len / 2, &splits[0]) == 0); CU_ASSERT(pkt != splits[0]); CU_ASSERT(odp_packet_data(pkt) != odp_packet_data(splits[0])); CU_ASSERT(odp_packet_len(pkt) == pkt_len / 2); CU_ASSERT(odp_packet_len(pkt) + odp_packet_len(splits[0]) == pkt_len);
- _packet_compare_offset(pkt, 0, segmented_test_packet, 0, pkt_len / 2); - _packet_compare_offset(splits[0], 0, segmented_test_packet, - pkt_len / 2, odp_packet_len(splits[0])); + packet_compare_offset(pkt, 0, segmented_test_packet, 0, pkt_len / 2); + packet_compare_offset(splits[0], 0, segmented_test_packet, + pkt_len / 2, odp_packet_len(splits[0]));
CU_ASSERT(odp_packet_concat(&pkt, splits[0]) >= 0); - _packet_compare_offset(pkt, 0, segmented_test_packet, 0, pkt_len / 2); - _packet_compare_offset(pkt, pkt_len / 2, segmented_test_packet, - pkt_len / 2, pkt_len / 2); - _packet_compare_offset(pkt, 0, segmented_test_packet, 0, - pkt_len); + packet_compare_offset(pkt, 0, segmented_test_packet, 0, pkt_len / 2); + packet_compare_offset(pkt, pkt_len / 2, segmented_test_packet, + pkt_len / 2, pkt_len / 2); + packet_compare_offset(pkt, 0, segmented_test_packet, 0, + pkt_len);
CU_ASSERT(odp_packet_len(pkt) == odp_packet_len(segmented_test_packet)); - _packet_compare_data(pkt, segmented_test_packet); + packet_compare_data(pkt, segmented_test_packet);
CU_ASSERT(odp_packet_split(&pkt, pkt_len / 2, &splits[0]) == 0); CU_ASSERT(odp_packet_split(&pkt, pkt_len / 4, &splits[1]) == 0); @@ -1316,7 +1340,7 @@ void packet_test_concatsplit(void) CU_ASSERT(odp_packet_concat(&pkt, splits[0]) >= 0);
CU_ASSERT(odp_packet_len(pkt) == odp_packet_len(segmented_test_packet)); - _packet_compare_data(pkt, segmented_test_packet); + packet_compare_data(pkt, segmented_test_packet);
odp_packet_free(pkt); } @@ -1803,9 +1827,9 @@ void packet_test_align(void) /* Alignment doesn't change packet length or contents */ CU_ASSERT(odp_packet_len(pkt) == pkt_len); (void)odp_packet_offset(pkt, offset, &aligned_seglen, NULL); - _packet_compare_offset(pkt, offset, - segmented_test_packet, offset, - aligned_seglen); + packet_compare_offset(pkt, offset, + segmented_test_packet, offset, + aligned_seglen);
/* Verify requested contiguous addressabilty */ CU_ASSERT(aligned_seglen >= seg_len + 2); @@ -1825,8 +1849,8 @@ void packet_test_align(void) aligned_data = odp_packet_offset(pkt, offset, &aligned_seglen, NULL);
CU_ASSERT(odp_packet_len(pkt) == pkt_len); - _packet_compare_offset(pkt, offset, segmented_test_packet, offset, - aligned_seglen); + packet_compare_offset(pkt, offset, segmented_test_packet, offset, + aligned_seglen); CU_ASSERT((uintptr_t)aligned_data % max_align == 0);
odp_packet_free(pkt);
commit 493bfccaae853707eeb6c08144c7e0a253cba761 Author: Petri Savolainen petri.savolainen@nokia.com Date: Tue Jan 10 11:19:07 2017 +0200
linux-gen: packet: replace base_len with constant
Only packets used base_len of buffer header. Replace the struct field with constant. This improves performance as the constant data is not read any more and buffer header size is smaller.
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h index 326c025..076abe9 100644 --- a/platform/linux-generic/include/odp_buffer_internal.h +++ b/platform/linux-generic/include/odp_buffer_internal.h @@ -56,7 +56,6 @@ struct odp_buffer_hdr_t { /* Initial buffer data pointer and length */ uint8_t *base_data; uint8_t *buf_end; - uint32_t base_len;
/* Max data size */ uint32_t size; @@ -64,9 +63,6 @@ struct odp_buffer_hdr_t { /* Pool type */ int8_t type;
- /* Event type. Maybe different than pool type (crypto compl event) */ - int8_t event_type; - /* Burst counts */ uint8_t burst_num; uint8_t burst_first; @@ -97,6 +93,9 @@ struct odp_buffer_hdr_t { /* User area size */ uint32_t uarea_size;
+ /* Event type. Maybe different than pool type (crypto compl event) */ + int8_t event_type; + /* Burst table */ struct odp_buffer_hdr_t *burst[BUFFER_BURST_SIZE];
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index d3f521f..f632a51 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -20,6 +20,9 @@ #include <stdio.h> #include <inttypes.h>
+/* Initial packet segment data length */ +#define BASE_LEN CONFIG_PACKET_MAX_SEG_LEN + static inline odp_packet_t packet_handle(odp_packet_hdr_t *pkt_hdr) { return (odp_packet_t)pkt_hdr->buf_hdr.handle.handle; @@ -260,7 +263,7 @@ static inline void init_segments(odp_packet_hdr_t *pkt_hdr[], int num) hdr = pkt_hdr[0];
hdr->buf_hdr.seg[0].data = hdr->buf_hdr.base_data; - hdr->buf_hdr.seg[0].len = hdr->buf_hdr.base_len; + hdr->buf_hdr.seg[0].len = BASE_LEN;
/* Link segments */ if (CONFIG_PACKET_MAX_SEGS != 1) { @@ -273,7 +276,7 @@ static inline void init_segments(odp_packet_hdr_t *pkt_hdr[], int num) buf_hdr = &pkt_hdr[i]->buf_hdr; hdr->buf_hdr.seg[i].hdr = buf_hdr; hdr->buf_hdr.seg[i].data = buf_hdr->base_data; - hdr->buf_hdr.seg[i].len = buf_hdr->base_len; + hdr->buf_hdr.seg[i].len = BASE_LEN; } } } @@ -709,7 +712,7 @@ static inline uint32_t pack_seg_tail(odp_packet_hdr_t *pkt_hdr, int seg) odp_buffer_hdr_t *hdr = pkt_hdr->buf_hdr.seg[seg].hdr; uint32_t len = pkt_hdr->buf_hdr.seg[seg].len; uint8_t *src = pkt_hdr->buf_hdr.seg[seg].data; - uint8_t *dst = hdr->base_data + hdr->base_len - len; + uint8_t *dst = hdr->base_data + BASE_LEN - len;
if (dst != src) { memmove(dst, src, len); @@ -777,19 +780,17 @@ static inline uint32_t fill_seg_tail(odp_packet_hdr_t *pkt_hdr, int dst_seg, static inline int move_data_to_head(odp_packet_hdr_t *pkt_hdr, int segs) { int dst_seg, src_seg; - uint32_t base_len, len, free_len; + uint32_t len, free_len; uint32_t moved = 0;
- base_len = pkt_hdr->buf_hdr.base_len; - for (dst_seg = 0; dst_seg < segs; dst_seg++) { len = pack_seg_head(pkt_hdr, dst_seg); moved += len;
- if (len == base_len) + if (len == BASE_LEN) continue;
- free_len = base_len - len; + free_len = BASE_LEN - len;
for (src_seg = dst_seg + 1; src_seg < segs; src_seg++) { len = fill_seg_head(pkt_hdr, dst_seg, src_seg, @@ -816,19 +817,17 @@ static inline int move_data_to_head(odp_packet_hdr_t *pkt_hdr, int segs) static inline int move_data_to_tail(odp_packet_hdr_t *pkt_hdr, int segs) { int dst_seg, src_seg; - uint32_t base_len, len, free_len; + uint32_t len, free_len; uint32_t moved = 0;
- base_len = pkt_hdr->buf_hdr.base_len; - for (dst_seg = segs - 1; dst_seg >= 0; dst_seg--) { len = pack_seg_tail(pkt_hdr, dst_seg); moved += len;
- if (len == base_len) + if (len == BASE_LEN) continue;
- free_len = base_len - len; + free_len = BASE_LEN - len;
for (src_seg = dst_seg - 1; src_seg >= 0; src_seg--) { len = fill_seg_tail(pkt_hdr, dst_seg, src_seg, @@ -857,12 +856,11 @@ static inline void reset_seg(odp_packet_hdr_t *pkt_hdr, int first, int num) odp_buffer_hdr_t *hdr; void *base; int i; - uint32_t base_len = pkt_hdr->buf_hdr.base_len;
for (i = first; i < first + num; i++) { hdr = pkt_hdr->buf_hdr.seg[i].hdr; base = hdr->base_data; - pkt_hdr->buf_hdr.seg[i].len = base_len; + pkt_hdr->buf_hdr.seg[i].len = BASE_LEN; pkt_hdr->buf_hdr.seg[i].data = base; } } @@ -891,7 +889,6 @@ int odp_packet_extend_head(odp_packet_t *pkt, uint32_t len, odp_packet_hdr_t *new_hdr; int new_segs = 0; int free_segs = 0; - uint32_t base_len = pkt_hdr->buf_hdr.base_len; uint32_t offset;
num = num_segments(frame_len + len); @@ -932,7 +929,7 @@ int odp_packet_extend_head(odp_packet_t *pkt, uint32_t len, }
frame_len += len; - offset = (segs * base_len) - frame_len; + offset = (segs * BASE_LEN) - frame_len;
pkt_hdr->buf_hdr.seg[0].data += offset; pkt_hdr->buf_hdr.seg[0].len -= offset; @@ -1058,7 +1055,6 @@ int odp_packet_extend_tail(odp_packet_t *pkt, uint32_t len, odp_packet_hdr_t *new_hdr; int new_segs = 0; int free_segs = 0; - uint32_t base_len = pkt_hdr->buf_hdr.base_len; uint32_t offset;
num = num_segments(frame_len + len); @@ -1091,7 +1087,7 @@ int odp_packet_extend_tail(odp_packet_t *pkt, uint32_t len, }
frame_len += len; - offset = (segs * base_len) - frame_len; + offset = (segs * BASE_LEN) - frame_len;
pkt_hdr->buf_hdr.seg[segs - 1].len -= offset;
diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c index d288bd6..090a55f 100644 --- a/platform/linux-generic/odp_pool.c +++ b/platform/linux-generic/odp_pool.c @@ -272,7 +272,6 @@ static void init_buffers(pool_t *pool)
/* Store base values for fast init */ buf_hdr->base_data = buf_hdr->seg[0].data; - buf_hdr->base_len = buf_hdr->seg[0].len; buf_hdr->buf_end = &data[offset + pool->data_size + pool->tailroom];
commit f275346606fdf487975cdef6654f81987c2df666 Author: Petri Savolainen petri.savolainen@nokia.com Date: Tue Jan 10 11:19:06 2017 +0200
linux-gen: packet: optimize alloc and init
Convert buffer and pool handles to pointers only once and pass pointers between functions (instead of handles).
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h index 4915bda..b0805ac 100644 --- a/platform/linux-generic/include/odp_pool_internal.h +++ b/platform/linux-generic/include/odp_pool_internal.h @@ -91,17 +91,15 @@ static inline pool_t *pool_entry_from_hdl(odp_pool_t pool_hdl) return &pool_tbl->pool[_odp_typeval(pool_hdl)]; }
-static inline odp_buffer_hdr_t *buf_hdl_to_hdr(odp_buffer_t buf) +static inline odp_buffer_hdr_t *pool_buf_hdl_to_hdr(pool_t *pool, + odp_buffer_t buf) { odp_buffer_bits_t handle; - uint32_t pool_id, index, block_offset; - pool_t *pool; + uint32_t index, block_offset; odp_buffer_hdr_t *buf_hdr;
handle.handle = buf; - pool_id = handle.pool_id; index = handle.index; - pool = pool_entry(pool_id); block_offset = index * pool->block_size;
/* clang requires cast to uintptr_t */ @@ -110,6 +108,19 @@ static inline odp_buffer_hdr_t *buf_hdl_to_hdr(odp_buffer_t buf) return buf_hdr; }
+static inline odp_buffer_hdr_t *buf_hdl_to_hdr(odp_buffer_t buf) +{ + odp_buffer_bits_t handle; + uint32_t pool_id; + pool_t *pool; + + handle.handle = buf; + pool_id = handle.pool_id; + pool = pool_entry(pool_id); + + return pool_buf_hdl_to_hdr(pool, buf); +} + int buffer_alloc_multi(pool_t *pool, odp_buffer_t buf[], odp_buffer_hdr_t *buf_hdr[], int num); void buffer_free_multi(const odp_buffer_t buf[], int num_free); diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 4397889..d3f521f 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -251,37 +251,32 @@ static inline void packet_init(odp_packet_hdr_t *pkt_hdr, uint32_t len, pkt_hdr->input = ODP_PKTIO_INVALID; }
-static inline odp_packet_hdr_t *init_segments(odp_buffer_t buf[], int num) +static inline void init_segments(odp_packet_hdr_t *pkt_hdr[], int num) { - odp_packet_hdr_t *pkt_hdr; + odp_packet_hdr_t *hdr; int i;
- /* First buffer is the packet descriptor */ - pkt_hdr = odp_packet_hdr((odp_packet_t)buf[0]); + /* First segment is the packet descriptor */ + hdr = pkt_hdr[0];
- pkt_hdr->buf_hdr.seg[0].data = pkt_hdr->buf_hdr.base_data; - pkt_hdr->buf_hdr.seg[0].len = pkt_hdr->buf_hdr.base_len; + hdr->buf_hdr.seg[0].data = hdr->buf_hdr.base_data; + hdr->buf_hdr.seg[0].len = hdr->buf_hdr.base_len;
/* Link segments */ - if (odp_unlikely(CONFIG_PACKET_MAX_SEGS != 1)) { - pkt_hdr->buf_hdr.segcount = num; + if (CONFIG_PACKET_MAX_SEGS != 1) { + hdr->buf_hdr.segcount = num;
if (odp_unlikely(num > 1)) { for (i = 1; i < num; i++) { - odp_packet_hdr_t *hdr; - odp_buffer_hdr_t *b_hdr; + odp_buffer_hdr_t *buf_hdr;
- hdr = odp_packet_hdr((odp_packet_t)buf[i]); - b_hdr = &hdr->buf_hdr; - - pkt_hdr->buf_hdr.seg[i].hdr = hdr; - pkt_hdr->buf_hdr.seg[i].data = b_hdr->base_data; - pkt_hdr->buf_hdr.seg[i].len = b_hdr->base_len; + buf_hdr = &pkt_hdr[i]->buf_hdr; + hdr->buf_hdr.seg[i].hdr = buf_hdr; + hdr->buf_hdr.seg[i].data = buf_hdr->base_data; + hdr->buf_hdr.seg[i].len = buf_hdr->base_len; } } } - - return pkt_hdr; }
/* Calculate the number of segments */ @@ -338,9 +333,10 @@ static inline void copy_num_segs(odp_packet_hdr_t *to, odp_packet_hdr_t *from, static inline odp_packet_hdr_t *alloc_segments(pool_t *pool, int num) { odp_buffer_t buf[num]; + odp_packet_hdr_t *pkt_hdr[num]; int ret;
- ret = buffer_alloc_multi(pool, buf, NULL, num); + ret = buffer_alloc_multi(pool, buf, (odp_buffer_hdr_t **)pkt_hdr, num); if (odp_unlikely(ret != num)) { if (ret > 0) buffer_free_multi(buf, ret); @@ -348,7 +344,9 @@ static inline odp_packet_hdr_t *alloc_segments(pool_t *pool, int num) return NULL; }
- return init_segments(buf, num); + init_segments(pkt_hdr, num); + + return pkt_hdr[0]; }
static inline odp_packet_hdr_t *add_segments(odp_packet_hdr_t *pkt_hdr, @@ -461,8 +459,10 @@ static inline int packet_alloc(pool_t *pool, uint32_t len, int max_pkt, int num = max_pkt; int max_buf = max_pkt * num_seg; odp_buffer_t buf[max_buf]; + odp_packet_hdr_t *pkt_hdr[max_buf];
- num_buf = buffer_alloc_multi(pool, buf, NULL, max_buf); + num_buf = buffer_alloc_multi(pool, buf, (odp_buffer_hdr_t **)pkt_hdr, + max_buf);
/* Failed to allocate all segments */ if (odp_unlikely(num_buf != max_buf)) { @@ -479,13 +479,14 @@ static inline int packet_alloc(pool_t *pool, uint32_t len, int max_pkt, }
for (i = 0; i < num; i++) { - odp_packet_hdr_t *pkt_hdr; + odp_packet_hdr_t *hdr;
/* First buffer is the packet descriptor */ - pkt[i] = (odp_packet_t)buf[i * num_seg]; - pkt_hdr = init_segments(&buf[i * num_seg], num_seg); + pkt[i] = (odp_packet_t)buf[i * num_seg]; + hdr = pkt_hdr[i * num_seg]; + init_segments(&pkt_hdr[i * num_seg], num_seg);
- packet_init(pkt_hdr, len, parse); + packet_init(hdr, len, parse); }
return num; diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c index 626e277..d288bd6 100644 --- a/platform/linux-generic/odp_pool.c +++ b/platform/linux-generic/odp_pool.c @@ -606,6 +606,7 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_t buf[], uint32_t mask, i; pool_cache_t *cache; uint32_t cache_num, num_ch, num_deq, burst; + odp_buffer_hdr_t *hdr;
cache = local.cache[pool->pool_idx];
@@ -624,9 +625,13 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_t buf[], }
/* Get buffers from the cache */ - for (i = 0; i < num_ch; i++) + for (i = 0; i < num_ch; i++) { buf[i] = cache->buf[cache_num - num_ch + i];
+ if (odp_likely(buf_hdr != NULL)) + buf_hdr[i] = pool_buf_hdl_to_hdr(pool, buf[i]); + } + /* If needed, get more from the global pool */ if (odp_unlikely(num_deq)) { /* Temporary copy needed since odp_buffer_t is uintptr_t @@ -647,13 +652,11 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_t buf[], uint32_t idx = num_ch + i;
buf[idx] = (odp_buffer_t)(uintptr_t)data[i]; + hdr = pool_buf_hdl_to_hdr(pool, buf[idx]); + odp_prefetch(hdr);
- if (buf_hdr) { - buf_hdr[idx] = buf_hdl_to_hdr(buf[idx]); - /* Prefetch newly allocated and soon to be used - * buffer headers. */ - odp_prefetch(buf_hdr[idx]); - } + if (odp_likely(buf_hdr != NULL)) + buf_hdr[idx] = hdr; }
/* Cache extra buffers. Cache is currently empty. */ @@ -666,11 +669,6 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_t buf[], cache->num = cache_num - num_ch; }
- if (buf_hdr) { - for (i = 0; i < num_ch; i++) - buf_hdr[i] = buf_hdl_to_hdr(buf[i]); - } - return num_ch + num_deq; }
commit 73d3de15ddcf99ac67fe14a59ba6e2f70907bcfe Author: Petri Savolainen petri.savolainen@nokia.com Date: Tue Jan 10 11:19:05 2017 +0200
linux-gen: packet: clean and pack packet header struct
Optimized buffer and packet header struct cache usage by: * removing unused fields * packed remaining fields * arrange fields for more optimal cache line usage
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h index 6149290..326c025 100644 --- a/platform/linux-generic/include/odp_buffer_internal.h +++ b/platform/linux-generic/include/odp_buffer_internal.h @@ -50,59 +50,73 @@ typedef union odp_buffer_bits_t {
/* Common buffer header */ struct odp_buffer_hdr_t { - struct odp_buffer_hdr_t *next; /* next buf in a list--keep 1st */ - union { /* Multi-use secondary link */ - struct odp_buffer_hdr_t *prev; - struct odp_buffer_hdr_t *link; - }; - odp_buffer_bits_t handle; /* handle */ + /* Handle union */ + odp_buffer_bits_t handle;
- int burst_num; - int burst_first; - struct odp_buffer_hdr_t *burst[BUFFER_BURST_SIZE]; + /* Initial buffer data pointer and length */ + uint8_t *base_data; + uint8_t *buf_end; + uint32_t base_len; + + /* Max data size */ + uint32_t size;
+ /* Pool type */ + int8_t type; + + /* Event type. Maybe different than pool type (crypto compl event) */ + int8_t event_type; + + /* Burst counts */ + uint8_t burst_num; + uint8_t burst_first; + + /* Segment count */ + uint8_t segcount; + + /* Segments */ struct { void *hdr; uint8_t *data; - /* Used only if _ODP_PKTIO_IPC is set. - * ipc mapped process can not walk over pointers, - * offset has to be used */ - uint64_t ipc_data_offset; uint32_t len; } seg[CONFIG_PACKET_MAX_SEGS];
- /* max data size */ - uint32_t size; - - /* Initial buffer data pointer and length */ - uint8_t *base_data; - uint32_t base_len; - uint8_t *buf_end; - - union { - uint32_t all; - struct { - uint32_t hdrdata:1; /* Data is in buffer hdr */ - }; - } flags; + /* Next buf in a list */ + struct odp_buffer_hdr_t *next;
- int8_t type; /* buffer type */ - odp_event_type_t event_type; /* for reuse as event */ - odp_pool_t pool_hdl; /* buffer pool handle */ + /* User context pointer or u64 */ union { - uint64_t buf_u64; /* user u64 */ - void *buf_ctx; /* user context */ - const void *buf_cctx; /* const alias for ctx */ + uint64_t buf_u64; + void *buf_ctx; + const void *buf_cctx; /* const alias for ctx */ }; - void *uarea_addr; /* user area address */ - uint32_t uarea_size; /* size of user area */ - uint32_t segcount; /* segment count */ - uint32_t segsize; /* segment size */ + + /* User area pointer */ + void *uarea_addr; + + /* User area size */ + uint32_t uarea_size; + + /* Burst table */ + struct odp_buffer_hdr_t *burst[BUFFER_BURST_SIZE]; + + /* Used only if _ODP_PKTIO_IPC is set. + * ipc mapped process can not walk over pointers, + * offset has to be used */ + uint64_t ipc_data_offset; + + /* Pool handle */ + odp_pool_t pool_hdl;
/* Data or next header */ uint8_t data[0]; };
+ODP_STATIC_ASSERT(CONFIG_PACKET_MAX_SEGS < 256, + "CONFIG_PACKET_MAX_SEGS_TOO_LARGE"); + +ODP_STATIC_ASSERT(BUFFER_BURST_SIZE < 256, "BUFFER_BURST_SIZE_TOO_LARGE"); + /* Forward declarations */ int seg_alloc_tail(odp_buffer_hdr_t *buf_hdr, int segcount); void seg_free_tail(odp_buffer_hdr_t *buf_hdr, int segcount); diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index d09231e..e6e9d74 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -114,13 +114,14 @@ typedef union { uint32_t all;
struct { + /** adjustment for traffic mgr */ + uint32_t shaper_len_adj:8; + /* Bitfield flags for each output option */ uint32_t l3_chksum_set:1; /**< L3 chksum bit is valid */ uint32_t l3_chksum:1; /**< L3 chksum override */ uint32_t l4_chksum_set:1; /**< L3 chksum bit is valid */ uint32_t l4_chksum:1; /**< L4 chksum override */ - - int8_t shaper_len_adj; /**< adjustment for traffic mgr */ }; } output_flags_t;
@@ -154,9 +155,9 @@ typedef struct { uint32_t l3_len; /**< Layer 3 length */ uint32_t l4_len; /**< Layer 4 length */
- layer_t parsed_layers; /**< Highest parsed protocol stack layer */ uint16_t ethtype; /**< EtherType */ - uint8_t ip_proto; /**< IP protocol */ + uint8_t ip_proto; /**< IP protocol */ + uint8_t parsed_layers; /**< Highest parsed protocol stack layer */
} packet_parser_t;
@@ -171,22 +172,33 @@ typedef struct { /* common buffer header */ odp_buffer_hdr_t buf_hdr;
- /* Following members are initialized by packet_init() */ + /* + * Following members are initialized by packet_init() + */ + packet_parser_t p;
+ odp_pktio_t input; + uint32_t frame_len; uint32_t headroom; uint32_t tailroom;
- odp_pktio_t input; + /* + * Members below are not initialized by packet_init() + */ + + /* Flow hash value */ + uint32_t flow_hash;
- /* Members below are not initialized by packet_init() */ - odp_queue_t dst_queue; /**< Classifier destination queue */ + /* Timestamp value */ + odp_time_t timestamp;
- uint32_t flow_hash; /**< Flow hash value */ - odp_time_t timestamp; /**< Timestamp value */ + /* Classifier destination queue */ + odp_queue_t dst_queue;
- odp_crypto_generic_op_result_t op_result; /**< Result for crypto */ + /* Result for crypto */ + odp_crypto_generic_op_result_t op_result;
/* Packet data storage */ uint8_t data[0]; diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 58b6f32..4397889 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -1506,7 +1506,7 @@ int odp_packet_align(odp_packet_t *pkt, uint32_t offset, uint32_t len, return 0; shift = align - misalign; } else { - if (len > pkt_hdr->buf_hdr.segsize) + if (len > pkt_hdr->buf_hdr.size) return -1; shift = len - seglen; uaddr -= shift; diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c index 932efe3..626e277 100644 --- a/platform/linux-generic/odp_pool.c +++ b/platform/linux-generic/odp_pool.c @@ -264,7 +264,6 @@ static void init_buffers(pool_t *pool) /* Show user requested size through API */ buf_hdr->uarea_size = pool->params.pkt.uarea_size; buf_hdr->segcount = 1; - buf_hdr->segsize = seg_size;
/* Pointer to data start (of the first segment) */ buf_hdr->seg[0].hdr = buf_hdr; diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index d9cb9f3..aafe567 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -500,9 +500,6 @@ int odp_queue_enq(odp_queue_t handle, odp_event_t ev) queue = queue_to_qentry(handle); buf_hdr = buf_hdl_to_hdr(odp_buffer_from_event(ev));
- /* No chains via this entry */ - buf_hdr->link = NULL; - return queue->s.enqueue(queue, buf_hdr); }
diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c index c9df043..377f20e 100644 --- a/platform/linux-generic/pktio/ipc.c +++ b/platform/linux-generic/pktio/ipc.c @@ -459,7 +459,7 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, if (odp_unlikely(pool == ODP_POOL_INVALID)) ODP_ABORT("invalid pool");
- data_pool_off = phdr->buf_hdr.seg[0].ipc_data_offset; + data_pool_off = phdr->buf_hdr.ipc_data_offset;
pkt = odp_packet_alloc(pool, phdr->frame_len); if (odp_unlikely(pkt == ODP_PACKET_INVALID)) { @@ -586,12 +586,12 @@ static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, (uint8_t *)odp_shm_addr(pool->shm);
/* compile all function code even if ipc disabled with config */ - pkt_hdr->buf_hdr.seg[0].ipc_data_offset = data_pool_off; + pkt_hdr->buf_hdr.ipc_data_offset = data_pool_off; IPC_ODP_DBG("%d/%d send packet %llx, pool %llx," "phdr = %p, offset %x\n", i, len, odp_packet_to_u64(pkt), odp_pool_to_u64(pool_hdl), - pkt_hdr, pkt_hdr->buf_hdr.seg[0].ipc_data_offset); + pkt_hdr, pkt_hdr->buf_hdr.ipc_data_offset); }
/* Put packets to ring to be processed by other process. */
-----------------------------------------------------------------------
Summary of changes: .../linux-generic/include/odp_buffer_internal.h | 87 +++++++----- .../linux-generic/include/odp_packet_internal.h | 34 +++-- platform/linux-generic/include/odp_pool_internal.h | 21 ++- platform/linux-generic/odp_packet.c | 83 ++++++----- platform/linux-generic/odp_pool.c | 24 ++-- platform/linux-generic/odp_queue.c | 3 - platform/linux-generic/pktio/ipc.c | 6 +- test/common_plat/validation/api/packet/packet.c | 154 ++++++++++++++------- 8 files changed, 243 insertions(+), 169 deletions(-)
hooks/post-receive