diff mbox series

[v2,6/11] linux-gen: packet: implement packet prefetch

Message ID 1517407211-19105-7-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [v2,1/11] linux-gen: packet: use inlined flow hash and ts set | expand

Commit Message

Github ODP bot Jan. 31, 2018, 2 p.m. UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


For minimal code complexity and negative impact, prefetch
only when the requested address is in the first segment and
prefetch only one cache line.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
/** Email created from pull request 437 (psavol:master-packet-optim)
 ** https://github.com/Linaro/odp/pull/437
 ** Patch: https://github.com/Linaro/odp/pull/437.patch
 ** Base sha: b95ccd3db6eeb7358a877541747e06354429acdd
 ** Merge commit sha: 3c2134ecc18e4fd52cd526b5c067815ca73864cc
 **/
 platform/linux-generic/include/odp/api/plat/packet_inlines.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

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 dee8f71ce..4c0f88aa2 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h
@@ -225,7 +225,14 @@  static inline odp_packet_seg_t _odp_packet_next_seg(odp_packet_t pkt,
 static inline void _odp_packet_prefetch(odp_packet_t pkt, uint32_t offset,
 					uint32_t len)
 {
-	(void)pkt; (void)offset; (void)len;
+	uint32_t seg_len = _odp_packet_seg_len(pkt);
+	uint8_t *data    = (uint8_t *)_odp_packet_data(pkt);
+	(void)len;
+
+	if (odp_unlikely(offset >= seg_len))
+		return;
+
+	odp_prefetch(data + offset);
 }
 
 static inline int _odp_packet_copy_from_mem(odp_packet_t pkt, uint32_t offset,