diff mbox series

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

Message ID 1517328009-16379-7-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [v1,1/11] linux-gen: packet: use inlined flow hash set | expand

Commit Message

Github ODP bot Jan. 30, 2018, 4 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: ab7875c186fe80cfe103c5be5634b0eda312aed4
 **/
 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,