Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Oct 2024 16:01:35 GMT
From:      Osama Abboud <osamaabb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: b0830d2b6bbc - stable/14 - ena: Handle wrap around for prefetch in netmap
Message-ID:  <202410311601.49VG1ZVn071450@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by osamaabb:

URL: https://cgit.FreeBSD.org/src/commit/?id=b0830d2b6bbc76fcbfe937f674e06e14933ad3ef

commit b0830d2b6bbc76fcbfe937f674e06e14933ad3ef
Author:     Osama Abboud <osamaabb@amazon.com>
AuthorDate: 2024-08-07 06:24:20 +0000
Commit:     Osama Abboud <osamaabb@FreeBSD.org>
CommitDate: 2024-10-31 14:54:11 +0000

    ena: Handle wrap around for prefetch in netmap
    
    Netmap index wraps around based on the number of netmap kernel ring
    slots.
    Currently the driver prefetches the next slot using nm_i + 1 which may
    be wrong since it does not handle wrap around.
    This patch fixes that by using the kernel API for fetching the next
    netmap index.
    
    Approved by: cperciva (mentor)
    Sponsored by: Amazon, Inc.
    
    (cherry picked from commit ce20b51cb71bfb548fcaafc4bacb8290460f03d5)
---
 sys/dev/ena/ena_netmap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/dev/ena/ena_netmap.c b/sys/dev/ena/ena_netmap.c
index f14a4a9539d1..eef8021b8569 100644
--- a/sys/dev/ena/ena_netmap.c
+++ b/sys/dev/ena/ena_netmap.c
@@ -577,7 +577,7 @@ ena_netmap_tx_map_slots(struct ena_netmap_ctx *ctx,
 	remaining_len = *packet_len;
 	delta = 0;
 
-	__builtin_prefetch(&ctx->slots[ctx->nm_i + 1]);
+	__builtin_prefetch(&ctx->slots[nm_next(ctx->nm_i, ctx->lim)]);
 	if (tx_ring->tx_mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_DEV) {
 		/*
 		 * When the device is in LLQ mode, the driver will copy
@@ -664,7 +664,7 @@ ena_netmap_tx_map_slots(struct ena_netmap_ctx *ctx,
 		 * The first segment is already counted in.
 		 */
 		while (delta > 0) {
-			__builtin_prefetch(&ctx->slots[ctx->nm_i + 1]);
+			__builtin_prefetch(&ctx->slots[nm_next(ctx->nm_i, ctx->lim)]);
 			frag_len = slot->len;
 
 			/*
@@ -722,7 +722,7 @@ ena_netmap_tx_map_slots(struct ena_netmap_ctx *ctx,
 
 	/* Map all remaining data (regular routine for non-LLQ mode) */
 	while (remaining_len > 0) {
-		__builtin_prefetch(&ctx->slots[ctx->nm_i + 1]);
+		__builtin_prefetch(&ctx->slots[nm_next(ctx->nm_i, ctx->lim)]);
 
 		rc = ena_netmap_map_single_slot(ctx->na, slot,
 		    adapter->tx_buf_tag, *nm_maps, &vaddr, &paddr);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202410311601.49VG1ZVn071450>