From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 652182ED843 for ; Thu, 26 Mar 2026 17:20:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774545619; cv=none; b=bshT/qIae16q3LfIargoGRdPwwdc5CjDKjoHmPtc9yhZyh2ta2cVB6MITMwbQgOXRFl9M4jnPWQ5SmoYnGkNFCPZCZ1WvDJ/5L6WwEQ+ObAp1Xk5X8qA9BbRRNrBmbVbrtILTS3pocVwIMj+N/k0sWX7REwdh2/zB/+CY45Ud2Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774545619; c=relaxed/simple; bh=gBM9UZ79pVI/XsfVcJ4cNZouZvLoOVOeU7DLOTD8WO8=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=Jxki0W7xs+I0kv5hrsD8FguNxVYZqLgOZtAQMOd83VH4IrvG18qxL64+7kP/m++YVfkyqSLZOxHun8tQOlOIzGwAAEvH0CPRXbgwmtIYMa1eVdvIAokKfnYOHi504TDogTAJ+E28xxeDNwADUgpv8cuV5wQXspH0kNn15p+zx+4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=R7Zg45YK; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=dxItS10F; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="R7Zg45YK"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="dxItS10F" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774545617; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IQbXc6Nx5DuqMWqXvo+PJJuItcBdEyCvSXgl+nvd2bs=; b=R7Zg45YKA1pznlwnqEDlh3v2jszVFS7iG6Uqa2UMFKiCsWkgxQvrotsujW38YK+aKl2RWk lzLeM5tc6v8c5Y+eu+rAxUqK5WW9K3Ri11jBgjBE0TcCl2ytwtWs7dOKr0V3Eg0COL/bff wLgY8enBpDlRRDmVk9AfyTf8ZqUOd74= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-295-qR584TG9M_SUdpiBvd0Eig-1; Thu, 26 Mar 2026 13:20:16 -0400 X-MC-Unique: qR584TG9M_SUdpiBvd0Eig-1 X-Mimecast-MFC-AGG-ID: qR584TG9M_SUdpiBvd0Eig_1774545614 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4853466655dso550905e9.3 for ; Thu, 26 Mar 2026 10:20:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1774545614; x=1775150414; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=IQbXc6Nx5DuqMWqXvo+PJJuItcBdEyCvSXgl+nvd2bs=; b=dxItS10FZGeMH17fBvn4qWObwc1pzk9DBXrnSFqVGjrxtHNQ7Rf0HgrLCXASWMNKXt wSv5dtONayw/qKrALceca2Pvaa1oDhGJuhfaad4RzxCusmLd+96li869oiYwgl2/ZJih GzwBMtH3wX53wIbqyr9QRBYyWjNlRG8H/lLbpfVZbgFYGuxkqT4voKWs8PXj6wv5aJoy DIK/6lKWyTq0Szpn/7/VYnPIslExguOl8mmpmKon9rgtDo/T+mLtPqt9AC7cJc/p1KHd nsZ8pkMldGf+ipe5D8bPg5DAnYiTpqhLKGwbgE1atGYxqzSDsG84QDwa5a6BOemBBg/O yqpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774545614; x=1775150414; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IQbXc6Nx5DuqMWqXvo+PJJuItcBdEyCvSXgl+nvd2bs=; b=MtHgjUYkbE4u0YxnDk/CnBhJ75AQ+Jsj++GD/acKOlSZoP2g2kQAraZNB1JZHW3+gP kdSGpyfgScSnjVxi0+kuEgAo3WaY+lFWVfovVGQmVJ7kAkIMY1Xi6MvXQFaUbPy4QJ55 HKeGdBrcGxbEu0DmtuqS9MDpv8tjAATmJgOr9nfXtAT355fu6pq0ZyMtNanzb3cTsajJ u40Y5t9pQL//RdUVg0odntheo7sZ2a4e2wrIaZ5kf5H3/PtLEIl0cejRWAyHRaYAbNWm dbvJQzyE0wClKI1miShOwR7pDEyfDY7HHsrIHBITfkYS8/Ce/YUGvIOIT/ud85nag2Zw TkXg== X-Forwarded-Encrypted: i=1; AJvYcCXb0GZG+BSU+wmmH7CcyLg5vjy+1L0Aq86bq+xU0ro8BealcpL52WqddnvNhbI6f4iPQ0tPD4TOHweI3pI=@vger.kernel.org X-Gm-Message-State: AOJu0Yz1zIbd+fySnUUP3A3qw10kj2/3PJnDCea8wTz8VqxFSNX2sZMb 9TzUvGVqMAdMvrUmnyqVRYouMZYWe4i3O1sYRQfEPNMLjwrOfvfIbF3vXNHVb/Cv0L67Peu74qI aaM7Ia2unETdh4omZ3Q3uTVxCbV75GUw3x8j4JiW1RPqZOCQTwrZnAdWYkZZIfiYuHQ== X-Gm-Gg: ATEYQzz2g9J7JTe6s7ET4RDRw0sVW9g/VUJ2Tc/ODxXkfNDN8Plo+73lXoOcsBd9EeZ 6i6HW4lHCTyzs87FYgrMPsaOpBccNE8LPNhnInqx3qHk9nz9anWFbS5U58G7hkTkOZmLrXaP25u lLd4vKL3E//43wQfzjsWnyu+NejbF/YhOJK2kIS62mo01l3acnXS04hLPYJExKyCl6SxqHOdKnK YXWdNLmLE/8w7/uz2SQBHLCEWP2UYgiJTR8sgug+wtsjPuceYc089pdtfm9lOVgrM4NUqtL211s oubkuvjsB/RuvJ795lXrhJ9WWFqBWDguEdrmONp3U2irnwZxPA/b6DS+xx8VmT8uK5eAHZw2Pcr W7N7Eq8W6WHUylVnwaUypZQbkXWtsaxwCjGhc/05Vy5gZOsz6J+CAs4MJ X-Received: by 2002:a05:600c:4685:b0:47d:8479:78d5 with SMTP id 5b1f17b1804b1-48715fc38e8mr133758805e9.7.1774545613780; Thu, 26 Mar 2026 10:20:13 -0700 (PDT) X-Received: by 2002:a05:600c:4685:b0:47d:8479:78d5 with SMTP id 5b1f17b1804b1-48715fc38e8mr133758095e9.7.1774545613194; Thu, 26 Mar 2026 10:20:13 -0700 (PDT) Received: from [192.168.88.32] ([212.105.153.60]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48722cb10fcsm41184135e9.14.2026.03.26.10.20.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Mar 2026 10:20:12 -0700 (PDT) Message-ID: Date: Thu, 26 Mar 2026 18:20:11 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [net-next v5 09/12] net: bnxt: Add SW GSO completion and teardown support To: Joe Damato , netdev@vger.kernel.org, Michael Chan , Pavan Chebbi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , horms@kernel.org, linux-kernel@vger.kernel.org, leon@kernel.org References: <20260323183844.3146982-1-joe@dama.to> <20260323183844.3146982-10-joe@dama.to> Content-Language: en-US From: Paolo Abeni In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 3/26/26 6:02 PM, Joe Damato wrote: > On Thu, Mar 26, 2026 at 01:39:17PM +0100, Paolo Abeni wrote: >> On 3/23/26 7:38 PM, Joe Damato wrote: >>> Update __bnxt_tx_int and bnxt_free_one_tx_ring_skbs to handle SW GSO >>> segments: >>> >>> - MID segments: adjust tx_pkts/tx_bytes accounting and skip skb free >>> (the skb is shared across all segments and freed only once) >>> >>> - LAST segments: if the DMA IOVA path was used, use dma_iova_destroy to >>> tear down the contiguous mapping. On the fallback path, payload DMA >>> unmapping is handled by the existing per-BD dma_unmap_len walk. >>> >>> Both MID and LAST completions advance tx_inline_cons to release the >>> segment's inline header slot back to the ring. >>> >>> is_sw_gso is initialized to zero, so the new code paths are not run. >>> >>> Suggested-by: Jakub Kicinski >>> Reviewed-by: Pavan Chebbi >>> Signed-off-by: Joe Damato >>> --- >>> v5: >>> - Added Pavan's Reviewed-by. No functional changes. >>> >>> v3: >>> - completion paths updated to use DMA IOVA APIs to teardown mappings. >>> >>> rfcv2: >>> - Update the shared header buffer consumer on TX completion. >>> >>> drivers/net/ethernet/broadcom/bnxt/bnxt.c | 82 +++++++++++++++++-- >>> .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 19 ++++- >>> 2 files changed, 91 insertions(+), 10 deletions(-) >>> >>> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c >>> index 2759a4e2b148..40a16f96feba 100644 >>> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c >>> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c >>> @@ -74,6 +74,8 @@ >>> #include "bnxt_debugfs.h" >>> #include "bnxt_coredump.h" >>> #include "bnxt_hwmon.h" >>> +#include "bnxt_gso.h" >>> +#include >>> >>> #define BNXT_TX_TIMEOUT (5 * HZ) >>> #define BNXT_DEF_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_HW | \ >>> @@ -817,12 +819,13 @@ static bool __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, >>> bool rc = false; >>> >>> while (RING_TX(bp, cons) != hw_cons) { >>> - struct bnxt_sw_tx_bd *tx_buf; >>> + struct bnxt_sw_tx_bd *tx_buf, *head_buf; >>> struct sk_buff *skb; >>> bool is_ts_pkt; >>> int j, last; >>> >>> tx_buf = &txr->tx_buf_ring[RING_TX(bp, cons)]; >>> + head_buf = tx_buf; >>> skb = tx_buf->skb; >>> >>> if (unlikely(!skb)) { >>> @@ -869,6 +872,23 @@ static bool __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, >>> DMA_TO_DEVICE, 0); >>> } >>> } >>> + >>> + if (unlikely(head_buf->is_sw_gso)) { >>> + txr->tx_inline_cons++; >>> + if (head_buf->is_sw_gso == BNXT_SW_GSO_LAST) { >>> + if (dma_use_iova(&head_buf->iova_state)) >> >> I'm likely lost, but AFAICS the previous patch/bnxt_sw_udp_gso_xmit() >> initialize head_buf->iova_state only when >> `dma_use_iova(&head_buf->iova_state) == true`. I.e. in fallback scenario >> the previous iova_state is maintained. > > Note that calling dma_iova_try_alloc zeroes the state before returning whether > the IOVA DMA API can be used or not and I call that uncoditionally (see > below). > >> Additionally AFAICS dma_iova_destroy does not clear `head_buf->iova_state`. > > That's my understanding, too, that dma_iova_destroy doesn't clear the state. > >> It looks like that 2 consecutive skb hitting the same slot use a >> different dma mapping strategy (fallback vs iova) bat things will >> happen?!? should the previous patch always initializing >> head_buf->iova_state? > > AFAICT, to switch the IOMMU domain would require unbind the device, changing > the IOMMU type, and re-binding the device... which would destroy all the rings > in the process and thus this wouldn't happen. > > The only way I could potentially imagine this happening would be in extreme > IOVA pressure (maybe?): > - packet A in slot N, dma_iova_try_alloc suceeds -> head_buf->iova_state > copied > - completion the packet occurs, dma_iova_destroy is called, > head_buf->iova_state is not cleared > - packet B in slot N, dma_iova_try_alloc fails due to IOVA pressure... > head_buf->iova_state is stale > > I'm pretty skeptical that this is a realistic case, TBH. > > That said and since it seems my v5 got CR, I can send a v6 with this slight > change to address the case you've mentioned above. > > I'll send in a couple hours unless I hear otherwise: > > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_gso.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_gso.c > index 9c30ee063ef5..7c198847a771 100644 > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_gso.c > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_gso.c > @@ -142,8 +142,12 @@ netdev_tx_t bnxt_sw_udp_gso_xmit(struct bnxt *bp, > > tx_buf->is_sw_gso = last ? BNXT_SW_GSO_LAST : BNXT_SW_GSO_MID; > > - /* Store IOVA state on the last segment for completion */ > - if (last && tso_dma_map_use_iova(&map)) { > + /* Store IOVA state on the last segment for completion. > + * Always copy so that a stale iova_state from a prior > + * occupant of this ring slot cannot be misread by > + * dma_use_iova() in the completion path. > + */ > + if (last) { > tx_buf->iova_state = map.iova_state; > tx_buf->iova_total_len = map.total_len; > } > Since tso_dma_map_use_iova(&map) is the likely option, I tend to think that the above change is worthy even if the problem I feared about is extremely unlikely if possible at all: the code is IMHO easier to follow, and FWIW does not overoptimize an unlikely scenario. /P