From: Dmitry Eremin-Solenikov <dmitry.ereminsoleni...@linaro.org> Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsoleni...@linaro.org> --- /** Email created from pull request 18 (lumag:packet-zero) ** https://github.com/Linaro/odp/pull/18 ** Patch: https://github.com/Linaro/odp/pull/18.patch ** Base sha: bac3806356694060d30bf3c83e4133410fecd9ab ** Merge commit sha: a44d13fa3221bf63f7cfe5a00acb07d49dd6abc9 **/ platform/linux-generic/odp_packet.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 9ff642b..1a4b99f 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -1634,6 +1634,27 @@ int odp_packet_move_data(odp_packet_t pkt, uint32_t dst_offset, pkt, src_offset, len); } +int odp_packet_zero_data(odp_packet_t pkt, uint32_t offset, uint32_t len) +{ + void *mapaddr; + uint32_t seglen = 0; /* GCC */ + uint32_t zerolen; + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); + + if (offset + len > pkt_hdr->frame_len) + return -1; + + while (len > 0) { + mapaddr = packet_map(pkt_hdr, offset, &seglen, NULL); + zerolen = len > seglen ? seglen : len; + memset(mapaddr, 0, zerolen); + offset += zerolen; + len -= zerolen; + } + + return 0; +} + /* * * Debugging