[rtems-libbsd commit] if_ffec: Align send buffers to cache if necessary.

Christian Mauderer christianm at rtems.org
Fri Jul 31 06:32:44 UTC 2020


Module:    rtems-libbsd
Branch:    master
Commit:    4a05b2e41cd660413f68ec9b52e154efd6710f41
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=4a05b2e41cd660413f68ec9b52e154efd6710f41

Author:    Christian Mauderer <christian.mauderer at embedded-brains.de>
Date:      Wed May 27 13:49:08 2020 +0200

if_ffec: Align send buffers to cache if necessary.

---

 freebsd/sys/dev/ffec/if_ffec.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/freebsd/sys/dev/ffec/if_ffec.c b/freebsd/sys/dev/ffec/if_ffec.c
index aee2aa6..e8287ed 100644
--- a/freebsd/sys/dev/ffec/if_ffec.c
+++ b/freebsd/sys/dev/ffec/if_ffec.c
@@ -714,8 +714,16 @@ ffec_encap(struct ifnet *ifp, struct ffec_softc *sc, struct mbuf *m0,
 		tx_desc->buf_paddr = segs[i].ds_addr;
 		tx_desc->flags2 = flags2;
 #ifdef __rtems__
-		rtems_cache_flush_multiple_data_lines((void *)segs[i].ds_addr,
-		    segs[i].ds_len);
+		uintptr_t addr_flush = (uintptr_t)segs[i].ds_addr;
+		size_t len_flush = segs[i].ds_len;
+#ifdef CPU_CACHE_LINE_BYTES
+		/* mbufs should be cache line aligned. So we can just round. */
+		addr_flush = addr_flush & ~(CPU_CACHE_LINE_BYTES - 1);
+		len_flush = (len_flush + (CPU_CACHE_LINE_BYTES - 1)) &
+		    ~(CPU_CACHE_LINE_BYTES - 1);
+#endif
+		rtems_cache_flush_multiple_data_lines((void*)addr_flush,
+		    len_flush);
 #endif /* __rtems__ */
 
 		if (i == 0) {



More information about the vc mailing list