Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Oct 2024 17:43:15 GMT
From:      Osama Abboud <osamaabb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: ce20b51cb71b - main - ena: Handle wrap around for prefetch in netmap
Message-ID:  <202410151743.49FHhFog062495@gitrepo.freebsd.org>

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

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

commit ce20b51cb71bfb548fcaafc4bacb8290460f03d5
Author:     Osama Abboud <osamaabb@amazon.com>
AuthorDate: 2024-08-07 06:24:20 +0000
Commit:     Osama Abboud <osamaabb@FreeBSD.org>
CommitDate: 2024-10-15 17:38:32 +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)
    MFC after: 2 weeks
    Sponsored by: Amazon, Inc.
---
 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?202410151743.49FHhFog062495>