Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 02 Apr 2026 22:50:55 +0000
From:      Arthur Kiyanovski <akiyano@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Cc:        Arthur Kiyanovski <akiyano@amazon.com>
Subject:   git: f5370d118335 - stable/13 - ena: Verify that an ENA ring is in netmap only in native mode
Message-ID:  <69cef2cf.472ee.534f3cfd@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/13 has been updated by akiyano:

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

commit f5370d118335defda098f0589ee96e84e3645174
Author:     Arthur Kiyanovski <akiyano@amazon.com>
AuthorDate: 2026-02-14 01:34:50 +0000
Commit:     Arthur Kiyanovski <akiyano@FreeBSD.org>
CommitDate: 2026-04-02 22:50:05 +0000

    ena: Verify that an ENA ring is in netmap only in native mode
    
    netmap operates in two modes:
    1) Emulated - netmap handling is done by the network stack, the
    NIC driver operates transparently to netmap.
    2) Native - netmap management is done by the NIC driver.
    
    When checking whether a specific ENA ring is running in netmap
    mode, only the following checks were done:
    1. IFCAP_NETMAP - Check whether netmap capability is enabled on
    the device.
    2. NKR_NETMAP_ON - Check whether netmap is actively using this
    ring.
    
    The above checks implied that the netmap mode is native and the
    ENA driver needs to handle the netmap logic.
    The code was missing an explicit check on whether native mode
    is actually on (NAF_NATIVE).
    This led to a case where though emulated mode was used and
    a netmap application was turned on, the ENA driver still managed
    netmap logic partially and caused missing buffers and lack of
    refill as part of the datapath.
    
    Note: Enabling netmap emulated mode is insufficient and there's
    a need to load a netmap program in order to trigger this use-case.
    
    Add an explicit check of whether NAF_NATIVE mode is set.
    
    The issue was reported in [1].
    
    [1]: https://github.com/amzn/amzn-drivers/issues/361
    
    Fixes: 358bcc4c6cde ("Add support for ENA NETMAP partial initialization")
    Reviewed by: cperciva
    Differential Revision: https://reviews.freebsd.org/D55697
    Sponsored by: Amazon, Inc.
    
    (cherry picked from commit 97e84c587d6f86aa883720296449b380adcf6915)
---
 sys/dev/ena/ena_netmap.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sys/dev/ena/ena_netmap.c b/sys/dev/ena/ena_netmap.c
index 41eb8abab39d..6a6ef67f9561 100644
--- a/sys/dev/ena/ena_netmap.c
+++ b/sys/dev/ena/ena_netmap.c
@@ -223,9 +223,11 @@ ena_ring_in_netmap(struct ena_adapter *adapter, int qid, enum txrx x)
 
 	if (adapter->ifp->if_capenable & IFCAP_NETMAP) {
 		na = NA(adapter->ifp);
-		kring = (x == NR_RX) ? na->rx_rings[qid] : na->tx_rings[qid];
-		if (kring->nr_mode == NKR_NETMAP_ON)
-			return true;
+		if (na->na_flags & NAF_NATIVE) {
+			kring = (x == NR_RX) ? na->rx_rings[qid] : na->tx_rings[qid];
+			if (kring->nr_mode == NKR_NETMAP_ON)
+				return true;
+		}
 	}
 	return false;
 }


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69cef2cf.472ee.534f3cfd>