diff mbox series

[2/3] linux-generic: packet: implement odp_packet_zero_data()

Message ID 1493215206-6131-2-git-send-email-odpbot@yandex.ru
State New
Headers show
Series None | expand

Commit Message

Github ODP bot April 26, 2017, 2 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@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 mbox series

Patch

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