From nobody Tue Nov 24 11:37:52 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=194.13.80.246 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795425454; b=cYiLj4H5h+Xook3D0GmHaPCboI1lppmXQo9ERZaH/nqW3q26x+ODHZpv89sEgrp4gbpD FEKSAtSLYmJXqYPnMlZMGnxPaMAZjwrwqoPlVZbcAylkV7hGCBziZUbxKaAZjaGBqDn4B KBdLrGzMtrrSduJxjuR6+MwZjC/wfrNoY/mQjpPUxAJiJ04jHmznXSIjMJR9fMK9ipJ+b JoDUUpQZUntq97Zw2WU6mTjo9+Wr2lDzaAon/ZilqKxnYpYWZWrJ6ZDrJod64Z7Am/04y oCgVs2xMDhtApChHSEJ0t2SBpoHWqJ60hK+12qn6C4TsZjI1JmhqXixw8bRkoyfv11A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795425454; h=DMARC-Filter:Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Last-TLS-Session-Version; bh=bizW6+iW5LLnjnz0mtnjldfKd92aJLeeYiKp4M9Rixo=; b=HZn0L2sDtoYU6uquu8SlPV8eXKgKsK0vU2QmwvUJrVcCXR5afyfYLAEtKhrDhfhIo4hM Dloa+47oLgEJnyOvSR0B1RWindzIHF8XcmwbVmYFk+s9gGW+JOLicm+BuESzRqQWZYprX RR0b9REp2OwrGGd0/DeQTshYx4ozBhyy8TwV57wdVCFcVVZ5WSXS4O5uLr227hYRJkgkT OEqLeSBP4/oRDQ9QVDsj+vWOz5FbyXfK7eqfNhQVBqo8Xwc4qm4DG3Cs0oQ3NM/m9yWRk a9f981ZwBYKuiXVTnzXLTaHWPzcJe44ued1AGd8RfhgAWWCVqjtcpw4kNOx6zhhnm0Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=tipi-net.de; spf=pass smtp.mailfrom=tipi-net.de; dkim=pass header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=oII3YwmO; arc=none smtp.remote-ip=194.13.80.246 Received: from mail.tipi-net.de (mail.tipi-net.de [194.13.80.246]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D641606A336; Mon, 23 Nov 2026 09:17:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6D641606A336 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=oII3YwmO Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 2B526A0900; Mon, 23 Nov 2026 10:17:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tipi-net.de; s=dkim; t=1795425451; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=bizW6+iW5LLnjnz0mtnjldfKd92aJLeeYiKp4M9Rixo=; b=oII3YwmOZkVAlfj53HTzceiAPzDUknlgivwxK4QflJfprReznydFx0FelbIA1FgE83RxMs lZTWbFpoksZdXpb2HwC+vNAKvP3otca6gYKisTy80nzarw/Dz+ECqyndOMjqefaGOe5+4X J1wW9qG2WUZVytD0TeuQBW1CgTb0itfqjBWopU0tqKIN9wo/9fgFBs87QjSTHMQE0PYVTK 4VOwPQtejvoJRj5G4wn1Fgc/Qo4vQv9kXBIv41zHeA6N7gKxAemUYj8JP5MJjy3LMsjvCz SOe6pmZ3WW+SrB8qjIUN/80QaJgUxRb8AMjYBdcgwI1Xmmztean8Nn+CZzHv4g== From: Nicolai Buchwitz Date: Mon, 23 Nov 2026 10:17:09 +0100 Subject: [PATCH net-next v9 1/8] net: bcmgenet: let the caller decide whether to start the PHY X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-nb-genet-mtu-nn-v2-v9-1-4f93ded19bbb@tipi-net.de> References: <20261123-nb-genet-mtu-nn-v2-v9-0-4f93ded19bbb@tipi-net.de> In-Reply-To: <20261123-nb-genet-mtu-nn-v2-v9-0-4f93ded19bbb@tipi-net.de> To: Doug Berger , Florian Fainelli , Nicolai Buchwitz , Broadcom internal kernel review list , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.16.0 X-Last-TLS-Session-Version: TLSv1.3 bcmgenet_netif_stop() already takes stop_phy, bcmgenet_netif_start() does not. The MTU change in a later patch leaves the PHY running while the datapath goes down and comes back, and phy_start() expects a stopped PHY. Add the same parameter to the start side. No functional change. Signed-off-by: Nicolai Buchwitz Reviewed-by: Florian Fainelli --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/e= thernet/broadcom/genet/bcmgenet.c index 6545caf3232d..77c1b4088a7e 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -3385,7 +3385,7 @@ static void bcmgenet_get_hw_addr(struct bcmgenet_priv= *priv, put_unaligned_be16(addr_tmp, &addr[4]); } =20 -static void bcmgenet_netif_start(struct net_device *dev) +static void bcmgenet_netif_start(struct net_device *dev, bool start_phy) { struct bcmgenet_priv *priv =3D netdev_priv(dev); =20 @@ -3402,7 +3402,8 @@ static void bcmgenet_netif_start(struct net_device *d= ev) /* Monitor link interrupts now */ bcmgenet_link_intr_enable(priv); =20 - phy_start(dev->phydev); + if (start_phy) + phy_start(dev->phydev); } =20 static int bcmgenet_open(struct net_device *dev) @@ -3465,7 +3466,7 @@ static int bcmgenet_open(struct net_device *dev) =20 bcmgenet_phy_pause_set(dev, priv->rx_pause, priv->tx_pause); =20 - bcmgenet_netif_start(dev); + bcmgenet_netif_start(dev, true); =20 netif_tx_start_all_queues(dev); =20 @@ -4364,7 +4365,7 @@ static int bcmgenet_resume(struct device *d) if (!device_may_wakeup(d)) phy_resume(dev->phydev); =20 - bcmgenet_netif_start(dev); + bcmgenet_netif_start(dev, true); =20 netif_device_attach(dev); =20 --=20 2.53.0 From nobody Tue Nov 24 11:37:52 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=194.13.80.246 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795425454; b=p9+WtVq/rM5imR4LHwbNeg9RDCwDsmPWinh70a8eLr0wGbkl4tkXA0aADB5PwdFfcV/4 mN+/PehJ1zdbRxV2Uc19Di1/aoQDxXkNPmD2TAyHLp8w/CMqasf0w7X1EiNqZvmWf+PVr Bqzti+iH96Tm7aiv8AwRhbEzLfWAWcyVj/Dbu6ScwAAc0EXDz/t6yREvM0YI96y7ZiEID i/cu3rW1ecXCRuF+TkQLlzkz1Y90/2qAJS3ftMSBlOWgJ/J9dN2beGjm6wPUXzUvxkyrP Dt0aMA9DaAuFI4wFMAT4EZEJc6j/EztqLdqWqRwATAflE3yMKhsz6WD6lTrGtFi3sWQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795425454; h=DMARC-Filter:Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Last-TLS-Session-Version; bh=GGVqoHM+KKBJo0C82Wkjw/21Q2PXYTZiP8lDiYrSUfc=; b=B2VLOfAgWzoMjYWwTM8bjrlD2mJ3y/3+P0UMu/1jqwPZMZ72KQraL6DMjClGx+zDrI7H 2naFlFVEtTob4jsIB5vWBw3Srk0XgYF6FW4bv2hCKIurDs04Fah43bfVr1z2LjyYipxKT 4WLCjkTLoqe+TveStQTlo6EKoTd7hKXzljMvkpEDBfgwwtA/qvoSOD+5zQqWEBdIcJXy7 NdksnHE1ESW1tsdWoaVY7RwR6PpZNs/Q8rqBWE3IFW/bt6mjLEuBAe45TEpKz/Vkhd1D0 4Z1uxIGewLFnAKySIkcijzXUA+765nvnkwzTYLF0ysiYdKpN9T2Hof6spTpYPz3jrKQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=tipi-net.de; spf=pass smtp.mailfrom=tipi-net.de; dkim=pass header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=OihSSxJY; arc=none smtp.remote-ip=194.13.80.246 Received: from mail.tipi-net.de (mail.tipi-net.de [194.13.80.246]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6513E606A6B3; Mon, 23 Nov 2026 09:17:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6513E606A6B3 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=OihSSxJY Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1B498A167B; Mon, 23 Nov 2026 10:17:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tipi-net.de; s=dkim; t=1795425452; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=GGVqoHM+KKBJo0C82Wkjw/21Q2PXYTZiP8lDiYrSUfc=; b=OihSSxJYZ4zca+OjuGx963tI2eyllP7p5VY0FX37TdvF/YSiij3E+TRqYkKfGyMBIkW08u iXY2lwQkuVA5DWPWZuIVOy8Frq7mJGSTDhDioBI0x1LX1t0L3q92R7TvhXOEFYZlXHakQe D3fOmD2dRbenNCRaVHRJ9Jmi2MewvOLEdMHGYXnhV8h1vIQutvUfN/rRVbst/TMD4OEkr0 Xg3U64Pfohkrc/Z8aBBUfY5HPbWCy0m6q9p0ltRrYLhg2P0tVXhs9CfF4wDFONCyQ9cNgx lIJM85C3FAazC2taMePL1AcxtTbPSuNpgtA6BOhuaPwBTaLlaTdwFROg4G7fAw== From: Nicolai Buchwitz Date: Mon, 23 Nov 2026 10:17:10 +0100 Subject: [PATCH net-next v9 2/8] net: bcmgenet: allow a continuation descriptor without the alignment pad X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-nb-genet-mtu-nn-v2-v9-2-4f93ded19bbb@tipi-net.de> References: <20261123-nb-genet-mtu-nn-v2-v9-0-4f93ded19bbb@tipi-net.de> In-Reply-To: <20261123-nb-genet-mtu-nn-v2-v9-0-4f93ded19bbb@tipi-net.de> To: Doug Berger , Florian Fainelli , Nicolai Buchwitz , Broadcom internal kernel review list , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Pierre-Marin Leclercq X-Mailer: b4 0.16.0 X-Last-TLS-Session-Version: TLSv1.3 A frame longer than the packet ready threshold arrives in several descriptors, each with its own status block. Only the first one also carries the two alignment bytes. The length check assumes the pad is always there, so a continuation holding a single byte looks a byte too short and the whole frame is dropped. Account for the pad on the first descriptor only. The MTU cannot produce a frame past the threshold yet, so nothing hits this today. It is preparation for the larger MTU. Tested-by: Pierre-Marin Leclercq Reviewed-by: Florian Fainelli Signed-off-by: Nicolai Buchwitz --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/e= thernet/broadcom/genet/bcmgenet.c index 77c1b4088a7e..c4f190212e46 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -53,7 +53,8 @@ =20 /* Page pool RX buffer layout: * RSB(64) + pad(2) | frame data | skb_shared_info - * The HW writes the 64B RSB + 2B alignment padding before the frame. + * The HW writes the 64B RSB before every descriptor of a frame. Only the + * first one also gets the 2B alignment padding. */ #define GENET_RSB_PAD (sizeof(struct status_64) + 2) =20 @@ -2358,6 +2359,7 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_= rx_ring *ring, unsigned int rx_offset, rx_size; struct status_64 *status; struct page *rx_page; + unsigned int min_len; void *hard_start; __be16 rx_csum; =20 @@ -2394,8 +2396,12 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet= _rx_ring *ring, __func__, p_index, ring->c_index, ring->read_ptr, dma_length_status); =20 + /* Only the first descriptor carries the alignment pad */ + min_len =3D dma_flag & DMA_SOP ? GENET_RSB_PAD + : sizeof(struct status_64); + /* Reject lengths that would underflow the SKB build path. */ - if (unlikely(len > RX_BUF_LENGTH || len < GENET_RSB_PAD)) { + if (unlikely(len > RX_BUF_LENGTH || len < min_len)) { netif_err(priv, rx_status, dev, "invalid packet length %d\n", len); BCMGENET_STATS64_INC(stats, length_errors); --=20 2.53.0 From nobody Tue Nov 24 11:37:52 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=194.13.80.246 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795425456; b=INbfkmZmHXoQ7pACZUBhMAJtHgzKRWg8RJ6zPlTW2VeLQ6b41BYIjdhmyR5UK0ZmFXNM 3aPD24TkcBSA1fZiCZyDk2fMVyT2wE0k0SOjWMEyxy21fxXcc1FHU2F/J7NdoILrqzokR TqzEPng8GWHjPNccln9QJGeN0rczaCWCeijgDia0wNMdCOQ/i2aALuOL2yKtX5XGFkB9C Y9Yj3J2iVzK90dQhLOIGcic8+P8sgPJsDkntDphGTRUi74qShWMY5cM3hy8txF4B7Jdrl J0NDW4oVqbi12ZkpRU2P9wN2JL+fIqL25YcACE1gQO8ckxgRzjYh+Y1XXPjLLMGyUHw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795425456; h=DMARC-Filter:Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Last-TLS-Session-Version; bh=84xUTKsOpH/hWUd6EceLC74e11NkwZd3pUz06QVDxNo=; b=Pa2Ew92F83Sp3ylpZIu/Fsw7W2HqUvFuwkisBh6IjkOOLyRwT4JszjRvIlfwqGmXI/Ey O59VRQPP+dij49EZ5T9n00KGDgB3PnfFGaFhYmOAvugEk8m6OylJLHZnczE5qDtjQh1eP ihKBmL7D9caHv1Ss1MEGEV6kZmcvObFwKIEpsbzhDmihgdTu2UUtUHVl4/k5onYcLf+tT RVZMyR/jK8XtV3Ghuv6VNH2iAk2/r6/q5+9Rr3p4dCmkfLQa8GYKKur+TeDxVo/LJ2zh1 Bbun71F2QKwK4DY5oiCMNCE+1i5D6DdVSuL5tPad7V1NXwITp9NPMyueKgNPpgvEbYw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=tipi-net.de; spf=pass smtp.mailfrom=tipi-net.de; dkim=pass header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=nQbpYu9R; arc=none smtp.remote-ip=194.13.80.246 Received: from mail.tipi-net.de (mail.tipi-net.de [194.13.80.246]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B231A60A2618; Mon, 23 Nov 2026 09:17:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B231A60A2618 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=nQbpYu9R Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 0571FA4B33; Mon, 23 Nov 2026 10:17:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tipi-net.de; s=dkim; t=1795425453; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=84xUTKsOpH/hWUd6EceLC74e11NkwZd3pUz06QVDxNo=; b=nQbpYu9RZu8fb8X0V09T4UJpVtLnC++gjmvgwZ/WxyVUp/rrzzPrmWkDGNq5IxFSJtr32c JRRo88HkP0zYb+L3cxwW71ov5w/JlsEBFDEHLq/OJ7476YVBRI4c/bohw9URDRQBq5JEAj 3lkUniMBHhuPbmzu7IWfoB9q/hPlWv2GP5R1ev7x7t+B9Sh6ypnH6LDhoAQtKSJcQVGBdg 3wVBIjikituEgr8Ts2Cz6TNn4BjVmN0vZdiyqT0SSQ77u3MHdfd3jqQFZ74AIQ6eG0OLx4 P5yA7wrmMXoag2FXUT+VM3VXhnaUkfDaPcFI6A6Ag3ZeeOtExBzWdXjhmzjgWQ== From: Nicolai Buchwitz Date: Mon, 23 Nov 2026 10:17:11 +0100 Subject: [PATCH net-next v9 3/8] net: bcmgenet: rename ENET_MAX_MTU_SIZE to ENET_MAX_FRAME_LEN X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-nb-genet-mtu-nn-v2-v9-3-4f93ded19bbb@tipi-net.de> References: <20261123-nb-genet-mtu-nn-v2-v9-0-4f93ded19bbb@tipi-net.de> In-Reply-To: <20261123-nb-genet-mtu-nn-v2-v9-0-4f93ded19bbb@tipi-net.de> To: Doug Berger , Florian Fainelli , Nicolai Buchwitz , Broadcom internal kernel review list , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.16.0 X-Last-TLS-Session-Version: TLSv1.3 ENET_MAX_MTU_SIZE holds a frame length, not an MTU. Both users program it into hardware that expects a frame length. The name is wrong once the MTU is no longer fixed at ETH_DATA_LEN. No functional change. Reviewed-by: Florian Fainelli Signed-off-by: Nicolai Buchwitz --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 4 ++-- drivers/net/ethernet/broadcom/genet/bcmgenet.h | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/e= thernet/broadcom/genet/bcmgenet.c index c4f190212e46..602b0a77d218 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -2668,7 +2668,7 @@ static void init_umac(struct bcmgenet_priv *priv) UMAC_MIB_CTRL); bcmgenet_umac_writel(priv, 0, UMAC_MIB_CTRL); =20 - bcmgenet_umac_writel(priv, ENET_MAX_MTU_SIZE, UMAC_MAX_FRAME_LEN); + bcmgenet_umac_writel(priv, ENET_MAX_FRAME_LEN, UMAC_MAX_FRAME_LEN); =20 /* init tx registers, enable TSB */ reg =3D bcmgenet_tbuf_ctrl_get(priv); @@ -2776,7 +2776,7 @@ static void bcmgenet_init_tx_ring(struct bcmgenet_pri= v *priv, =20 /* Set flow period for ring !=3D 0 */ if (index) - flow_period_val =3D ENET_MAX_MTU_SIZE << 16; + flow_period_val =3D ENET_MAX_FRAME_LEN << 16; =20 bcmgenet_tdma_ring_writel(priv, index, 0, TDMA_PROD_INDEX); bcmgenet_tdma_ring_writel(priv, index, 0, TDMA_CONS_INDEX); diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/e= thernet/broadcom/genet/bcmgenet.h index 6ab3f7347555..afaccb769933 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h @@ -28,12 +28,11 @@ /* which ring is descriptor based */ #define DESC_INDEX 16 =20 -/* Body(1500) + EH_SIZE(14) + VLANTAG(4) + BRCMTAG(6) + FCS(4) =3D 1528. - * 1536 is multiple of 256 bytes - */ #define ENET_BRCM_TAG_LEN 6 #define ENET_PAD 8 -#define ENET_MAX_MTU_SIZE (ETH_DATA_LEN + ETH_HLEN + VLAN_HLEN + \ + +/* Longest frame the MAC must accept for the default MTU */ +#define ENET_MAX_FRAME_LEN (ETH_DATA_LEN + ETH_HLEN + VLAN_HLEN + \ ENET_BRCM_TAG_LEN + ETH_FCS_LEN + ENET_PAD) #define DMA_MAX_BURST_LENGTH 0x10 =20 --=20 2.53.0 From nobody Tue Nov 24 11:37:52 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=194.13.80.246 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795425457; b=oGcMJIzN11VRCgxbafEIiD+DtVNftxitQcgp4k2Rh1jK7ifvyYnSsPzbXwW/104p2acp 09rs4vIpnzBqu0cWAlS5Aww0K4FuLY14lSJNleqvzBagt6OrBEJcG2LmF+ndsbtIX2BfJ UEqKb+8ELOdHXWge7+ZgxBG5GUnZ+3bsoWNfZGBs5FQJkC7ihtJcfETh7cG6Whk8x6Wvp fbPpkfKcVPVi3AOzsQqQU3fS1fFRgyzIBpdmDA4FQMhe4icGmAsVIB5gdDbV8SQb70rmk PvvYFETDxLahN51c+0bVoXhVarHfZLHFGSpw1j4CodNDAsJlGxddZ0y8EpsGktm9B0A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795425457; h=DMARC-Filter:Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Last-TLS-Session-Version; bh=gXd4E1aPNANnDRXQ+Ka6tGZbR0CeOAtkfMIM0t59etk=; b=emlbYnh4Ab0LVtvyMEeV6xN0Tk5lsUij/NDDyaLPZTCZQHoXeNee6NnDcl7pQPuTc2m6 5QM068zSb5XIrQL/BiqxnjgG92CD8CwKwqvQO0vjeMOQNiMuW4YgvgqFXFaaOB/Rbp7KL oFOZK004YuoPuGBufsmTG0JKxzKZsrMNf0FZR594WpjeBF3LbSsAmaSM3LAb/4o4viXXo s+8wn9XGAaVoIicr1yL2tMKumDT6R0dRYmsWxb6tsQIRdCaX5IclPpPcZP/1iKW/gMXcE lIltbyIt4zXCnkOsEnMTVo4xrF9lq2EfPH0EUp4WYpoFEFE1mtaqDn2puwGsdO8XwLg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=tipi-net.de; spf=pass smtp.mailfrom=tipi-net.de; dkim=pass header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=oKVA3X6f; arc=none smtp.remote-ip=194.13.80.246 Received: from mail.tipi-net.de (mail.tipi-net.de [194.13.80.246]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BDDF60A263A; Mon, 23 Nov 2026 09:17:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9BDDF60A263A Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=oKVA3X6f Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3F0FCA4B35; Mon, 23 Nov 2026 10:17:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tipi-net.de; s=dkim; t=1795425454; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=gXd4E1aPNANnDRXQ+Ka6tGZbR0CeOAtkfMIM0t59etk=; b=oKVA3X6fcALr2a6XsZRYv1X5Pi2+NwnLgijzkBP65unRkuCWMeTF+SBKwCuvfKEyja4DD5 qDd1xKfRtP2ArWCDFHPS+pQ1Nbdlutj1tPnnjQHqTxpOv026TPT108uYabxgAA0t1UFBUI dus8HMGAOH0MrsXtK7VasNbTDV/FsXDLeIWhAL9Lo2hQhHRXDQnpBN6fGcvOp3nM9Zi6C9 +ANWQCvLVncSp9rg5SZWPRp/FaYX122wnZ6XTg8yNC4CSV40Jr80aZHB5nmSE0Hz8ZSV8J tL6TIKZMgyjKcvTBKnjWWHNHlzKsmPE/gJGKx19ydXBx/K80hHx4phSjU1i8rQ== From: Nicolai Buchwitz Date: Mon, 23 Nov 2026 10:17:12 +0100 Subject: [PATCH net-next v9 4/8] net: bcmgenet: derive the receive buffer length from the MTU X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-nb-genet-mtu-nn-v2-v9-4-4f93ded19bbb@tipi-net.de> References: <20261123-nb-genet-mtu-nn-v2-v9-0-4f93ded19bbb@tipi-net.de> In-Reply-To: <20261123-nb-genet-mtu-nn-v2-v9-0-4f93ded19bbb@tipi-net.de> To: Doug Berger , Florian Fainelli , Nicolai Buchwitz , Broadcom internal kernel review list , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.16.0 X-Last-TLS-Session-Version: TLSv1.3 The receive buffer length is a fixed 2048 bytes. The packet ready thresholds keep whatever value the reset left. Neither follows the MTU. Compute the receive threshold from the MTU and program it into RBUF. The buffer length follows from it, with the status block on top. The MTU is still fixed at ETH_DATA_LEN, so the threshold comes out at the reset default and the buffer only grows by the status block the hardware already wrote. Derive UMAC_MAX_FRAME_LEN and the flow period from the MTU too, with a floor at ETH_DATA_LEN so a lower MTU does not stop the MAC accepting a standard frame. Suggested-by: Dave Stevenson Signed-off-by: Nicolai Buchwitz --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 90 +++++++++++++++++++++-= ---- drivers/net/ethernet/broadcom/genet/bcmgenet.h | 18 +++++- 2 files changed, 90 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/e= thernet/broadcom/genet/bcmgenet.c index 602b0a77d218..893cf61f8828 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -48,18 +48,41 @@ #define GENET_Q0_TX_BD_CNT \ (TOTAL_DESC - priv->hw_params->tx_queues * priv->hw_params->tx_bds_per_q) =20 -#define RX_BUF_LENGTH 2048 #define SKB_ALIGNMENT 32 =20 +/* The transmit descriptors carry their own lengths, so this is unused and + * keeps the reset value. + */ +#define TX_RING_BUF_SIZE 2048 + +/* RBUF and TBUF hand a frame to the DMA once the threshold is reached. Bo= th + * registers are 8 bit in units of 16 bytes and want a multiple of the 256 + * byte burst size, so 0xf0 is the largest usable value. + */ +#define ENET_THLD_UNIT 16 +#define ENET_THLD_BURST 256 +#define ENET_THLD_DEFAULT 0x80 +#define ENET_THLD_MAX 0xf0 + /* Page pool RX buffer layout: * RSB(64) + pad(2) | frame data | skb_shared_info * The HW writes the 64B RSB before every descriptor of a frame. Only the * first one also gets the 2B alignment padding. */ -#define GENET_RSB_PAD (sizeof(struct status_64) + 2) +#define GENET_RBUF_ALIGN 2 +#define GENET_RSB_PAD (sizeof(struct status_64) + GENET_RBUF_ALIGN) =20 -/* RX buffer plus the skb_shared_info napi_build_skb() places behind it */ -#define GENET_RX_BUF_SIZE SKB_HEAD_ALIGN(RX_BUF_LENGTH) +/* A descriptor never spans more than one page, which also holds + * skb_shared_info behind the frame, so on 4K pages the page bounds the + * threshold before the register does. Larger pages fit several descriptor= s. + */ +#define ENET_SHINFO_LEN SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +#define ENET_THLD_PAGE_LEN round_down(PAGE_SIZE - ENET_SHINFO_LEN - \ + sizeof(struct status_64), \ + ENET_THLD_BURST) +#define ENET_THLD_MAX_LEN min_t(unsigned int, \ + ENET_THLD_MAX * ENET_THLD_UNIT, \ + ENET_THLD_PAGE_LEN) =20 /* Tx/Rx DMA register offset, skip 256 descriptors */ #define WORDS_PER_BD(p) (p->hw_params->words_per_bd) @@ -2282,7 +2305,7 @@ static int bcmgenet_rx_refill(struct bcmgenet_rx_ring= *ring, struct enet_cb *cb) { struct bcmgenet_priv *priv =3D ring->priv; - unsigned int size =3D GENET_RX_BUF_SIZE; + unsigned int size =3D SKB_HEAD_ALIGN(priv->rx_buf_len); unsigned int offset; dma_addr_t mapping; struct page *page; @@ -2297,7 +2320,7 @@ static int bcmgenet_rx_refill(struct bcmgenet_rx_ring= *ring, =20 /* page_pool handles DMA mapping via PP_FLAG_DMA_MAP */ mapping =3D page_pool_get_dma_addr(page) + offset; - dma_sync_single_for_device(&priv->pdev->dev, mapping, RX_BUF_LENGTH, + dma_sync_single_for_device(&priv->pdev->dev, mapping, priv->rx_buf_len, DMA_FROM_DEVICE); =20 cb->rx_page =3D page; @@ -2376,10 +2399,10 @@ static unsigned int bcmgenet_desc_rx(struct bcmgene= t_rx_ring *ring, } =20 /* Sync the full buffer; the HW may have written anywhere - * up to RX_BUF_LENGTH. + * up to priv->rx_buf_len. */ page_pool_dma_sync_for_cpu(ring->page_pool, rx_page, rx_offset, - RX_BUF_LENGTH); + priv->rx_buf_len); =20 hard_start =3D page_address(rx_page) + rx_offset; status =3D (struct status_64 *)hard_start; @@ -2401,7 +2424,7 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_= rx_ring *ring, : sizeof(struct status_64); =20 /* Reject lengths that would underflow the SKB build path. */ - if (unlikely(len > RX_BUF_LENGTH || len < min_len)) { + if (unlikely(len > priv->rx_buf_len || len < min_len)) { netif_err(priv, rx_status, dev, "invalid packet length %d\n", len); BCMGENET_STATS64_INC(stats, length_errors); @@ -2652,6 +2675,41 @@ static void bcmgenet_link_intr_enable(struct bcmgene= t_priv *priv) bcmgenet_intrl2_0_writel(priv, int0_enable, INTRL2_CPU_MASK_CLEAR); } =20 +/* Receive threshold in register units. Covers the alignment bytes and the + * frame, but not the status block, which the hardware adds on top. + */ +static unsigned int bcmgenet_pkt_rdy_thld(unsigned int mtu) +{ + unsigned int len =3D GENET_RBUF_ALIGN + mtu + ETH_HLEN + VLAN_HLEN; + + len =3D round_up(len, ENET_THLD_BURST) / ENET_THLD_UNIT; + + /* Keep the reset default for the common MTUs */ + return clamp_t(unsigned int, len, ENET_THLD_DEFAULT, + ENET_THLD_MAX_LEN / ENET_THLD_UNIT); +} + +/* A buffer has to hold everything the threshold lets the hardware deliver= */ +static unsigned int bcmgenet_rx_buf_len(unsigned int mtu) +{ + return sizeof(struct status_64) + + bcmgenet_pkt_rdy_thld(mtu) * ENET_THLD_UNIT; +} + +/* Call with the MAC disabled */ +static void bcmgenet_set_mtu_regs(struct bcmgenet_priv *priv, unsigned int= mtu) +{ + u32 thld =3D bcmgenet_pkt_rdy_thld(mtu); + + bcmgenet_umac_writel(priv, ENET_MAC_FRAME_LEN(mtu), UMAC_MAX_FRAME_LEN); + + /* GENET v1 maps other registers at these offsets */ + if (GENET_IS_V1(priv)) + return; + + bcmgenet_rbuf_writel(priv, thld, RBUF_PKT_RDY_THLD); +} + static void init_umac(struct bcmgenet_priv *priv) { struct device *kdev =3D &priv->pdev->dev; @@ -2668,7 +2726,7 @@ static void init_umac(struct bcmgenet_priv *priv) UMAC_MIB_CTRL); bcmgenet_umac_writel(priv, 0, UMAC_MIB_CTRL); =20 - bcmgenet_umac_writel(priv, ENET_MAX_FRAME_LEN, UMAC_MAX_FRAME_LEN); + bcmgenet_set_mtu_regs(priv, priv->dev->mtu); =20 /* init tx registers, enable TSB */ reg =3D bcmgenet_tbuf_ctrl_get(priv); @@ -2776,7 +2834,7 @@ static void bcmgenet_init_tx_ring(struct bcmgenet_pri= v *priv, =20 /* Set flow period for ring !=3D 0 */ if (index) - flow_period_val =3D ENET_MAX_FRAME_LEN << 16; + flow_period_val =3D ENET_MAC_FRAME_LEN(priv->dev->mtu) << 16; =20 bcmgenet_tdma_ring_writel(priv, index, 0, TDMA_PROD_INDEX); bcmgenet_tdma_ring_writel(priv, index, 0, TDMA_CONS_INDEX); @@ -2787,7 +2845,7 @@ static void bcmgenet_init_tx_ring(struct bcmgenet_pri= v *priv, TDMA_FLOW_PERIOD); bcmgenet_tdma_ring_writel(priv, index, ((size << DMA_RING_SIZE_SHIFT) | - RX_BUF_LENGTH), DMA_RING_BUF_SIZE); + TX_RING_BUF_SIZE), DMA_RING_BUF_SIZE); =20 /* Set start and end address, read and write pointers */ bcmgenet_tdma_ring_writel(priv, index, start_ptr * words_per_bd, @@ -2806,8 +2864,9 @@ static void bcmgenet_init_tx_ring(struct bcmgenet_pri= v *priv, static int bcmgenet_rx_ring_create_pool(struct bcmgenet_priv *priv, struct bcmgenet_rx_ring *ring) { - /* Buffers share a page. bcmgenet_rx_refill() syncs each one for the - * device, PP_FLAG_DMA_SYNC_DEV would sync the whole page. + /* Buffers may share a page, depending on PAGE_SIZE and the MTU. + * bcmgenet_rx_refill() syncs each one for the device, + * PP_FLAG_DMA_SYNC_DEV would sync the whole page. */ struct page_pool_params pp_params =3D { .order =3D 0, @@ -2870,7 +2929,7 @@ static int bcmgenet_init_rx_ring(struct bcmgenet_priv= *priv, bcmgenet_rdma_ring_writel(priv, index, 0, RDMA_CONS_INDEX); bcmgenet_rdma_ring_writel(priv, index, ((size << DMA_RING_SIZE_SHIFT) | - RX_BUF_LENGTH), DMA_RING_BUF_SIZE); + priv->rx_buf_len), DMA_RING_BUF_SIZE); bcmgenet_rdma_ring_writel(priv, index, (DMA_FC_THRESH_LO << DMA_XOFF_THRESHOLD_SHIFT) | @@ -4149,6 +4208,7 @@ static int bcmgenet_probe(struct platform_device *pde= v) /* Mii wait queue */ init_waitqueue_head(&priv->wq); bcmgenet_hfb_init(priv); + priv->rx_buf_len =3D bcmgenet_rx_buf_len(dev->mtu); INIT_WORK(&priv->bcmgenet_irq_work, bcmgenet_irq_task); =20 priv->clk_wol =3D devm_clk_get_optional(&priv->pdev->dev, "enet-wol"); diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/e= thernet/broadcom/genet/bcmgenet.h index afaccb769933..b40e56872132 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h @@ -31,9 +31,17 @@ #define ENET_BRCM_TAG_LEN 6 #define ENET_PAD 8 =20 -/* Longest frame the MAC must accept for the default MTU */ -#define ENET_MAX_FRAME_LEN (ETH_DATA_LEN + ETH_HLEN + VLAN_HLEN + \ - ENET_BRCM_TAG_LEN + ETH_FCS_LEN + ENET_PAD) +/* Longest frame the MAC must accept for a given MTU. ENET_PAD is slack the + * driver has always carried, it rounded the default up to 1536 from 1528. + */ +#define ENET_FRAME_OVERHEAD (ETH_HLEN + VLAN_HLEN + ENET_BRCM_TAG_LEN + \ + ETH_FCS_LEN + ENET_PAD) +#define ENET_MAX_FRAME_LEN(mtu) ((mtu) + ENET_FRAME_OVERHEAD) + +/* The MAC keeps accepting a standard frame below the default MTU */ +#define ENET_MAC_FRAME_LEN(mtu) ENET_MAX_FRAME_LEN(max_t(unsigned int, (mt= u), \ + ETH_DATA_LEN)) + #define DMA_MAX_BURST_LENGTH 0x10 =20 /* misc. configuration */ @@ -218,6 +226,8 @@ struct bcmgenet_rx_stats64 { #define RBUF_ALIGN_2B (1 << 1) #define RBUF_BAD_DIS (1 << 2) =20 +#define RBUF_PKT_RDY_THLD 0x08 + #define RBUF_STATUS 0x0C #define RBUF_STATUS_WOL (1 << 0) #define RBUF_STATUS_MPD_INTR_ACTIVE (1 << 1) @@ -248,6 +258,7 @@ struct bcmgenet_rx_stats64 { #define TBUF_CTRL 0x00 #define TBUF_64B_EN (1 << 0) #define TBUF_BP_MC 0x0C +#define TBUF_PKT_RDY_THLD 0x10 #define TBUF_ENERGY_CTRL 0x14 #define TBUF_EEE_EN (1 << 0) #define TBUF_PM_EN (1 << 1) @@ -614,6 +625,7 @@ struct bcmgenet_priv { void __iomem *rx_bds; struct enet_cb *rx_cbs; unsigned int num_rx_bds; + unsigned int rx_buf_len; struct bcmgenet_rxnfc_rule rxnfc_rules[MAX_NUM_OF_FS_RULES]; struct list_head rxnfc_list; =20 --=20 2.53.0 From nobody Tue Nov 24 11:37:52 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=194.13.80.246 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795425458; b=llSQtN7q1GT/co/YdPZN2h1O50yRE31Em+69KBoHv4WBqWqSupeqEEqzhk0pLZiGXcM3 hk0kw0vOa+TpfVWVL2ttHunXIbprLCvzc1YxPiTtC0BmymDycB8RS8e7DqiYs4SyV6B6A 8Skj0I3idx+XLXtbluhB88TJkI8MbYYYjEGrmGU88cn6r+pY9E5N5tNIajDLniXuNgZEw 88yers/Oyk+XmRoTdBoxgRwFWjaY5i/CPfg0ZuNKEHbgq7db5B1C+qqeAeS5gjod9lpx6 RwF2j1e2sbSxr8chNvmcmLtFkwKF4t7rwnmaFJ6kgu3KNaJfh2Xa4BAIMouGlNXWfIA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795425458; h=DMARC-Filter:Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Last-TLS-Session-Version; bh=QeRYX4VAajglrkor4q6M1mrSZr1O76o0QwHgNLXpR7A=; b=Z6eh4jaLQi0T2dsTn9p3vXoEjU6yfSRqCckS0nNGcm9cNUmJ9L0oEW4a9plTmnZ4nPUD tuKfh5oLI2f/sPtzqWyw6FdPsAATJQYY4Ee3i5qNCuiV0jENxvu/18t/iXq3iwll4fb1J xBnkJovj7n/pvzjJUp6jwK0Es3WAKjgYPgusm4nzXklN0JQ/zI51MDSTTAhwU6LH2bfJM IJ85Fy3BAAIFG46cvkyyV7ecYhvKjec+QiAb5ppoo5YN0dqx4vQCnMC19PkhZrrjhgUag aa3j00ScR/quVmWnybRUYn/DBH7VHiHiIrF5b/eYjObEugY+XRpXLcI6P6gLw4cURiw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=tipi-net.de; spf=pass smtp.mailfrom=tipi-net.de; dkim=pass header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=gTGXXNTg; arc=none smtp.remote-ip=194.13.80.246 Received: from mail.tipi-net.de (mail.tipi-net.de [194.13.80.246]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E8BB60A3802; Mon, 23 Nov 2026 09:17:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5E8BB60A3802 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=gTGXXNTg Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 273DFA4B38; Mon, 23 Nov 2026 10:17:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tipi-net.de; s=dkim; t=1795425455; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=QeRYX4VAajglrkor4q6M1mrSZr1O76o0QwHgNLXpR7A=; b=gTGXXNTguQXWukXG7qRS5u28Yd/Nq9N06aNffZQjwOBICPq4lu8PZ8RwWqaeDKhp/HKLPl nmAAIN2eNSRbaV0ycbh0S8pN0Y0FvI5coLVorZVQMubN9Bu+ZAvb5zeeH9GDYGns/Kc8lo DdkaoiL37emZl5qhlkzUvdcc4oLQXt05eR+d6Q8lyFQhQQzNQkhRPi9NDFhRgBA8+DbLTW RUXB9j7UsX2Jkj0o0dNYeDsn0Zeb2mF18C70IA8QNjVMkSBykwN2/f4ai5pvRGANvz+FXy smEn/IbFa9Q//NkZGV4aWWPnUsbDaw4K8BmTH4/NQ3cVAK8c3WVUBjiQXGqLDQ== From: Nicolai Buchwitz Date: Mon, 23 Nov 2026 10:17:13 +0100 Subject: [PATCH net-next v9 5/8] net: bcmgenet: split frames that end just past the transmit threshold X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-nb-genet-mtu-nn-v2-v9-5-4f93ded19bbb@tipi-net.de> References: <20261123-nb-genet-mtu-nn-v2-v9-0-4f93ded19bbb@tipi-net.de> In-Reply-To: <20261123-nb-genet-mtu-nn-v2-v9-0-4f93ded19bbb@tipi-net.de> To: Doug Berger , Florian Fainelli , Nicolai Buchwitz , Broadcom internal kernel review list , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.16.0 X-Last-TLS-Session-Version: TLSv1.3 A frame that ends a few bytes past the transmit packet ready threshold stops the transmitter as soon as a shorter frame follows. Tx DMA then refuses to halt, so every later bcmgenet_init_dma() fails and the interface cannot be opened again. IP fragmentation generates that pattern on every datagram, full frames and a short tail. At the default MTU no frame is long enough to reach the threshold, so the stall needs the larger MTU that comes later in this series. The window starts one byte past the threshold and never reaches 64 bytes. On a v5 it ends 28, 32 and 46 bytes past thresholds of 2560, 3584 and 3840, and link speed makes no difference. That is one DMA transfer wide, which wtschueller measured and proposed to split around. The bcm2711 programs a burst of 0x08 and sends nothing at all at 0x10, so the window follows the burst length to cover the parts that program the larger value. Splitting such a frame over two descriptors keeps its end out of that transfer. Both share the one mapping, so the wire bytes do not change. The split costs one descriptor, so the queue stops and wakes one earlier, and a frame is flattened one fragment sooner. The threshold kept its reset value until now. Raising it only once the MTU asks for more than ETH_DATA_LEN leaves the common MTUs as they were. The MAC inserts a checksum only into a frame it holds in full, so a longer one has to fall back to software. Signed-off-by: Nicolai Buchwitz --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 173 +++++++++++++++++++--= ---- drivers/net/ethernet/broadcom/genet/bcmgenet.h | 4 + 2 files changed, 140 insertions(+), 37 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/e= thernet/broadcom/genet/bcmgenet.c index 893cf61f8828..766203e7c482 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -64,6 +64,13 @@ #define ENET_THLD_DEFAULT 0x80 #define ENET_THLD_MAX 0xf0 =20 +/* A frame that ends within one DMA transfer past the transmit threshold + * stops the transmitter once a shorter frame follows. The burst register + * has no documented unit, 8 bytes per count matches the 46 bytes measured + * on a bcm2711, which programs 0x08. + */ +#define ENET_BURST_UNIT 8 + /* Page pool RX buffer layout: * RSB(64) + pad(2) | frame data | skb_shared_info * The HW writes the 64B RSB before every descriptor of a frame. Only the @@ -1915,15 +1922,19 @@ static struct sk_buff *bcmgenet_free_tx_cb(struct d= evice *dev, =20 if (skb) { cb->skb =3D NULL; - if (cb =3D=3D GENET_CB(skb)->first_cb) - dma_unmap_single(dev, dma_unmap_addr(cb, dma_addr), - dma_unmap_len(cb, dma_len), - DMA_TO_DEVICE); - else - dma_unmap_page(dev, dma_unmap_addr(cb, dma_addr), - dma_unmap_len(cb, dma_len), - DMA_TO_DEVICE); - dma_unmap_addr_set(cb, dma_addr, 0); + /* A cut descriptor left its mapping to the one after it */ + if (cb !=3D GENET_CB(skb)->split_cb) { + if (cb =3D=3D GENET_CB(skb)->head_cb) + dma_unmap_single(dev, + dma_unmap_addr(cb, dma_addr), + dma_unmap_len(cb, dma_len), + DMA_TO_DEVICE); + else + dma_unmap_page(dev, dma_unmap_addr(cb, dma_addr), + dma_unmap_len(cb, dma_len), + DMA_TO_DEVICE); + dma_unmap_addr_set(cb, dma_addr, 0); + } =20 if (cb =3D=3D GENET_CB(skb)->last_cb) return skb; @@ -2150,7 +2161,10 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb= , struct net_device *dev) { struct bcmgenet_priv *priv =3D netdev_priv(dev); struct device *kdev =3D &priv->pdev->dev; + unsigned int split_i =3D 0, split_at =3D 0; struct bcmgenet_tx_ring *ring =3D NULL; + dma_addr_t split_mapping =3D 0; + unsigned int split_size =3D 0; struct enet_cb *tx_cb_ptr; struct netdev_queue *txq; int nr_frags, index; @@ -2158,6 +2172,7 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb,= struct net_device *dev) unsigned int size; skb_frag_t *frag; u32 len_stat; + bool split; int ret; int i; =20 @@ -2167,8 +2182,14 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb= , struct net_device *dev) =20 nr_frags =3D skb_shinfo(skb)->nr_frags; =20 + /* Cut a frame ending in that window in two at the threshold, its end + * then lands in a separate transfer. + */ + split =3D unlikely(skb->len > priv->tx_thld_len && + skb->len < priv->tx_thld_len + priv->tx_thld_window); + /* The check below would always refuse this frame */ - if (unlikely(nr_frags + 1 >=3D ring->size)) { + if (unlikely(nr_frags + 1 + split >=3D ring->size)) { skb =3D skb_share_check(skb, GFP_ATOMIC); if (skb && skb_linearize(skb)) { dev_kfree_skb_any(skb); @@ -2184,7 +2205,7 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb,= struct net_device *dev) } =20 spin_lock(&ring->lock); - if (ring->free_bds <=3D (nr_frags + 1)) { + if (ring->free_bds <=3D (nr_frags + 1 + split)) { if (!netif_tx_queue_stopped(txq)) netif_tx_stop_queue(txq); ret =3D NETDEV_TX_BUSY; @@ -2201,6 +2222,20 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb= , struct net_device *dev) goto out; } =20 + /* The MAC inserts a checksum only into a frame it holds in full and + * silently drops a longer one, so fall back to software. + */ + if (unlikely(skb->len > priv->tx_thld_len) && + skb->ip_summed =3D=3D CHECKSUM_PARTIAL) { + if (skb_checksum_help(skb)) { + BCMGENET_STATS64_INC((&ring->stats64), dropped); + dev_kfree_skb_any(skb); + ret =3D NETDEV_TX_OK; + goto out; + } + nr_frags =3D skb_shinfo(skb)->nr_frags; + } + /* Retain how many bytes will be sent on the wire, without TSB inserted * by transmit checksum offload */ @@ -2213,34 +2248,79 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *sk= b, struct net_device *dev) goto out; } =20 - for (i =3D 0; i <=3D nr_frags; i++) { + /* A threshold that already ends a buffer needs no cut */ + if (split) { + unsigned int buf =3D skb_headlen(skb); + unsigned int covered =3D buf - sizeof(struct status_64); + + while (covered < priv->tx_thld_len) { + frag =3D &skb_shinfo(skb)->frags[split_i++]; + buf =3D skb_frag_size(frag); + covered +=3D buf; + } + + split_at =3D buf - (covered - priv->tx_thld_len); + split =3D split_at && split_at < buf; + } + + for (i =3D 0; i <=3D nr_frags + split; i++) { + unsigned int f =3D i - (split && i > split_i); + bool cont =3D split && i =3D=3D split_i + 1; + tx_cb_ptr =3D bcmgenet_get_txcb(priv, ring); =20 BUG_ON(!tx_cb_ptr); =20 - if (!i) { - /* Transmit single SKB or head of fragment list */ - GENET_CB(skb)->first_cb =3D tx_cb_ptr; - size =3D skb_headlen(skb); - mapping =3D dma_map_single(kdev, skb->data, size, - DMA_TO_DEVICE); + if (cont) { + /* Rest of the buffer cut above. It unmaps for both, + * the hardware is done with it only now. + */ + mapping =3D split_mapping + split_at; + size =3D split_size - split_at; + dma_unmap_addr_set(tx_cb_ptr, dma_addr, split_mapping); + dma_unmap_len_set(tx_cb_ptr, dma_len, split_size); + + /* A cut head buffer leaves its mapping here too */ + if (!split_i) + GENET_CB(skb)->head_cb =3D tx_cb_ptr; } else { - /* xmit fragment */ - frag =3D &skb_shinfo(skb)->frags[i - 1]; - size =3D skb_frag_size(frag); - mapping =3D skb_frag_dma_map(kdev, frag, 0, size, - DMA_TO_DEVICE); - } + if (!f) { + /* Transmit single SKB or head of frag list */ + GENET_CB(skb)->first_cb =3D tx_cb_ptr; + GENET_CB(skb)->head_cb =3D tx_cb_ptr; + GENET_CB(skb)->split_cb =3D NULL; + size =3D skb_headlen(skb); + mapping =3D dma_map_single(kdev, skb->data, + size, DMA_TO_DEVICE); + } else { + /* xmit fragment */ + frag =3D &skb_shinfo(skb)->frags[f - 1]; + size =3D skb_frag_size(frag); + mapping =3D skb_frag_dma_map(kdev, frag, 0, size, + DMA_TO_DEVICE); + } =20 - ret =3D dma_mapping_error(kdev, mapping); - if (ret) { - priv->mib.tx_dma_failed++; - netif_err(priv, tx_err, dev, "Tx DMA map failed\n"); - ret =3D NETDEV_TX_OK; - goto out_unmap_frags; + ret =3D dma_mapping_error(kdev, mapping); + if (ret) { + priv->mib.tx_dma_failed++; + netif_err(priv, tx_err, dev, + "Tx DMA map failed\n"); + ret =3D NETDEV_TX_OK; + goto out_unmap_frags; + } + dma_unmap_addr_set(tx_cb_ptr, dma_addr, mapping); + dma_unmap_len_set(tx_cb_ptr, dma_len, size); + + /* The cut hands buffer and mapping to the next one */ + if (split && i =3D=3D split_i) { + GENET_CB(skb)->split_cb =3D tx_cb_ptr; + split_mapping =3D mapping; + split_size =3D size; + size =3D split_at; + dma_unmap_addr_set(tx_cb_ptr, dma_addr, 0); + dma_unmap_len_set(tx_cb_ptr, dma_len, 0); + } } - dma_unmap_addr_set(tx_cb_ptr, dma_addr, mapping); - dma_unmap_len_set(tx_cb_ptr, dma_len, size); =20 tx_cb_ptr->skb =3D skb; =20 @@ -2257,7 +2337,7 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb,= struct net_device *dev) if (skb->ip_summed =3D=3D CHECKSUM_PARTIAL) len_stat |=3D DMA_TX_DO_CSUM; } - if (i =3D=3D nr_frags) + if (i =3D=3D nr_frags + split) len_stat |=3D DMA_EOP; =20 dmadesc_set(priv, tx_cb_ptr->bd_addr, mapping, len_stat); @@ -2269,8 +2349,8 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb,= struct net_device *dev) skb_tx_timestamp(skb); =20 /* Decrement total BD count and advance our write pointer */ - ring->free_bds -=3D nr_frags + 1; - ring->prod_index +=3D nr_frags + 1; + ring->free_bds -=3D nr_frags + 1 + split; + ring->prod_index +=3D nr_frags + 1 + split; ring->prod_index &=3D DMA_P_INDEX_MASK; =20 netdev_tx_sent_queue(txq, GENET_CB(skb)->bytes_sent); @@ -2689,6 +2769,17 @@ static unsigned int bcmgenet_pkt_rdy_thld(unsigned i= nt mtu) ENET_THLD_MAX_LEN / ENET_THLD_UNIT); } =20 +/* The transmit threshold in register units. Keep the reset value while the + * MTU has no use for more, the hardware never reaches it below ETH_DATA_L= EN. + */ +static unsigned int bcmgenet_tx_pkt_rdy_thld(unsigned int mtu) +{ + if (mtu <=3D ETH_DATA_LEN) + return ENET_THLD_DEFAULT; + + return ENET_THLD_MAX; +} + /* A buffer has to hold everything the threshold lets the hardware deliver= */ static unsigned int bcmgenet_rx_buf_len(unsigned int mtu) { @@ -2699,8 +2790,10 @@ static unsigned int bcmgenet_rx_buf_len(unsigned int= mtu) /* Call with the MAC disabled */ static void bcmgenet_set_mtu_regs(struct bcmgenet_priv *priv, unsigned int= mtu) { + u32 tx_thld =3D bcmgenet_tx_pkt_rdy_thld(mtu); u32 thld =3D bcmgenet_pkt_rdy_thld(mtu); =20 + priv->tx_thld_len =3D tx_thld * ENET_THLD_UNIT; bcmgenet_umac_writel(priv, ENET_MAC_FRAME_LEN(mtu), UMAC_MAX_FRAME_LEN); =20 /* GENET v1 maps other registers at these offsets */ @@ -2708,6 +2801,8 @@ static void bcmgenet_set_mtu_regs(struct bcmgenet_pri= v *priv, unsigned int mtu) return; =20 bcmgenet_rbuf_writel(priv, thld, RBUF_PKT_RDY_THLD); + bcmgenet_writel(tx_thld, priv->base + priv->hw_params->tbuf_offset + + TBUF_PKT_RDY_THLD); } =20 static void init_umac(struct bcmgenet_priv *priv) @@ -2822,8 +2917,10 @@ static void bcmgenet_init_tx_ring(struct bcmgenet_pr= iv *priv, ring->index =3D index; ring->cbs =3D priv->tx_cbs + start_ptr; ring->size =3D size; - /* An empty ring must be able to wake the queue */ - ring->stop_thld =3D min_t(unsigned int, MAX_SKB_FRAGS + 1, size - 1); + /* An empty ring must be able to wake the queue, a split frame takes + * one descriptor more. + */ + ring->stop_thld =3D min_t(unsigned int, MAX_SKB_FRAGS + 2, size - 1); ring->clean_ptr =3D start_ptr; ring->c_index =3D 0; ring->free_bds =3D size; @@ -4209,6 +4306,8 @@ static int bcmgenet_probe(struct platform_device *pde= v) init_waitqueue_head(&priv->wq); bcmgenet_hfb_init(priv); priv->rx_buf_len =3D bcmgenet_rx_buf_len(dev->mtu); + priv->tx_thld_len =3D bcmgenet_tx_pkt_rdy_thld(dev->mtu) * ENET_THLD_UNIT; + priv->tx_thld_window =3D priv->dma_max_burst_length * ENET_BURST_UNIT; INIT_WORK(&priv->bcmgenet_irq_work, bcmgenet_irq_task); =20 priv->clk_wol =3D devm_clk_get_optional(&priv->pdev->dev, "enet-wol"); diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/e= thernet/broadcom/genet/bcmgenet.h index b40e56872132..906639c1f012 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h @@ -543,7 +543,9 @@ struct bcmgenet_hw_params { =20 struct bcmgenet_skb_cb { struct enet_cb *first_cb; /* First control block of SKB */ + struct enet_cb *head_cb; /* Owns the head mapping */ struct enet_cb *last_cb; /* Last control block of SKB */ + struct enet_cb *split_cb; /* Cut, the next one unmaps for both */ unsigned int bytes_sent; /* bytes on the wire (no TSB) */ }; =20 @@ -618,6 +620,8 @@ struct bcmgenet_priv { void __iomem *tx_bds; struct enet_cb *tx_cbs; unsigned int num_tx_bds; + unsigned int tx_thld_len; + unsigned int tx_thld_window; =20 struct bcmgenet_tx_ring tx_rings[GENET_MAX_MQ_CNT + 1]; =20 --=20 2.53.0 From nobody Tue Nov 24 11:37:52 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=194.13.80.246 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795425459; b=U3UtzMWu8Ppyd7aPwutLqHNf+fkF62qwANhKkak/ZDowxKRKGEpO3PZo7uGKKvy6Etdy Vx20fl9dSbxjRnIK6/JmEphNcjWXH1ogmRTNrEf21SuZYXAFOlNw0apsYsDGt4CI3Q/EC 3k0X2pTWoEf7x4EPyT6XQlTh/G+8nkTmI4swDNiL7f6HKyerJ9pTPIxj4diifzIBp+AvA WDjIeAw0GZFF77GCClcc7kJwUgxzqMQW4eqYtrxPhyN7C1PZb50zv9Jk+NGwRl51EAuZW syZPVKYpd4/czplwYMsuF3FWXSna0OwSAvPPGl46S8UWyfzvJuaeJFzL894/bnroTwg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795425459; h=DMARC-Filter:Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Last-TLS-Session-Version; bh=wrlA3V//0g5+UC43BthGF5ANlIs14j10QBscIr0XFzE=; b=nVAcdneyVUcNjt1A99ge6Ib5FuSYQbRb+kG9cYhLgxH+VVBs/uobntm0av/9G+DnfRYz kfW8UwGaeix7DlRIYFqCqkhCdHDrnv5xuUC+APdwxua+ZV5EXJuWnlC/29rsulfPdC+xR +A0zmHH0CX1qZP+TjR5prSXWlnPRiKEp6YctdAodcvSw0zrET+U4phfR1EIRASUGHfyC+ S+43vHs18ikz413B/2SeOW7kXkRDtZbnGYwscPIdpfk27nReTK6w4ZPj64TjxjuZCsH0n Xcdsm5Jd5zBYTQyRktNdbibURvF0SW3D7yKGHnII8gZqjXK3ZlTpBunBBVNa4Y+wuOA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=tipi-net.de; spf=pass smtp.mailfrom=tipi-net.de; dkim=pass header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=DG9UouWT; arc=none smtp.remote-ip=194.13.80.246 Received: from mail.tipi-net.de (mail.tipi-net.de [194.13.80.246]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46C34606A33D; Mon, 23 Nov 2026 09:17:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 46C34606A33D Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=DG9UouWT Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id ECAEBA4B39; Mon, 23 Nov 2026 10:17:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tipi-net.de; s=dkim; t=1795425456; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=wrlA3V//0g5+UC43BthGF5ANlIs14j10QBscIr0XFzE=; b=DG9UouWT6xpAeUDe33NyAcTQ9Pr4DYPpNejx4t74pNZvYPOCUwrLgTULydb8HJiu1/RiEh 0NngXSGgzTg6Zh56zC3/2Wyj2it82N8+TyqWPJ+64T2i43q/no1m5o/M26rMiMKoMkcwho rVzVV3KpUVPTTbddNC+sFwHdUpl/7iplGDXiozJPTCoOu7yUUoWA3Jm4sWCb0FiIeHC3UY 3X1CqJMWWzRSnOLdmO54rq8EMF4sWIrgNdPnUNVm31gimj+9BoQCf/fn6nvDDGZvz2hpMM cAQupZfP1rGUtVzQQlx10OkEMwgFPWX8ecC5/lmIVh5p5aGrEfZ2RPRfxr+sbA== From: Nicolai Buchwitz Date: Mon, 23 Nov 2026 10:17:14 +0100 Subject: [PATCH net-next v9 6/8] net: bcmgenet: build the DMA rings before giving up the running ones X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-nb-genet-mtu-nn-v2-v9-6-4f93ded19bbb@tipi-net.de> References: <20261123-nb-genet-mtu-nn-v2-v9-0-4f93ded19bbb@tipi-net.de> In-Reply-To: <20261123-nb-genet-mtu-nn-v2-v9-0-4f93ded19bbb@tipi-net.de> To: Doug Berger , Florian Fainelli , Nicolai Buchwitz , Broadcom internal kernel review list , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.16.0 X-Last-TLS-Session-Version: TLSv1.3 bcmgenet_init_dma() allocates the new rings only after its callers have torn the running ones down, so a failure under memory pressure leaves the interface with no datapath at all. The MTU change in the next patch runs the same path on a live interface, where that takes a working link down. Allocate into a set of its own first and install it only once it is complete, so a failed allocation costs the running datapath nothing. The receive buffers can only reach the hardware at install time, the descriptors of a running ring must not be rewritten. Signed-off-by: Nicolai Buchwitz --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 248 +++++++++++++++------= ---- drivers/net/ethernet/broadcom/genet/bcmgenet.h | 9 + 2 files changed, 158 insertions(+), 99 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/e= thernet/broadcom/genet/bcmgenet.c index 766203e7c482..ae20c4b3c570 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -2381,16 +2381,15 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *sk= b, struct net_device *dev) goto out; } =20 -static int bcmgenet_rx_refill(struct bcmgenet_rx_ring *ring, - struct enet_cb *cb) +static int bcmgenet_rx_alloc_cb(struct bcmgenet_priv *priv, + struct page_pool *pool, unsigned int buf_len, + struct enet_cb *cb) { - struct bcmgenet_priv *priv =3D ring->priv; - unsigned int size =3D SKB_HEAD_ALIGN(priv->rx_buf_len); + unsigned int size =3D SKB_HEAD_ALIGN(buf_len); unsigned int offset; - dma_addr_t mapping; struct page *page; =20 - page =3D page_pool_dev_alloc(ring->page_pool, &offset, &size); + page =3D page_pool_dev_alloc(pool, &offset, &size); if (!page) { priv->mib.alloc_rx_buff_failed++; netif_err(priv, rx_err, priv->dev, @@ -2398,15 +2397,36 @@ static int bcmgenet_rx_refill(struct bcmgenet_rx_ri= ng *ring, return -ENOMEM; } =20 + cb->rx_page =3D page; + cb->rx_offset =3D offset; + cb->rx_size =3D size; + + return 0; +} + +static void bcmgenet_rx_arm_cb(struct bcmgenet_priv *priv, struct enet_cb = *cb) +{ + dma_addr_t mapping; + /* page_pool handles DMA mapping via PP_FLAG_DMA_MAP */ - mapping =3D page_pool_get_dma_addr(page) + offset; + mapping =3D page_pool_get_dma_addr(cb->rx_page) + cb->rx_offset; dma_sync_single_for_device(&priv->pdev->dev, mapping, priv->rx_buf_len, DMA_FROM_DEVICE); =20 - cb->rx_page =3D page; - cb->rx_offset =3D offset; - cb->rx_size =3D size; dmadesc_set_addr(priv, cb->bd_addr, mapping); +} + +static int bcmgenet_rx_refill(struct bcmgenet_rx_ring *ring, + struct enet_cb *cb) +{ + struct bcmgenet_priv *priv =3D ring->priv; + int ret; + + ret =3D bcmgenet_rx_alloc_cb(priv, ring->page_pool, priv->rx_buf_len, cb); + if (ret) + return ret; + + bcmgenet_rx_arm_cb(priv, cb); =20 return 0; } @@ -2654,22 +2674,15 @@ static void bcmgenet_dim_work(struct work_struct *w= ork) } =20 /* Assign page_pool pages to RX DMA descriptors. */ -static int bcmgenet_alloc_rx_buffers(struct bcmgenet_priv *priv, - struct bcmgenet_rx_ring *ring) +static void bcmgenet_arm_rx_buffers(struct bcmgenet_priv *priv, + struct bcmgenet_rx_ring *ring) { - struct enet_cb *cb; int i; =20 netif_dbg(priv, hw, priv->dev, "%s\n", __func__); =20 - /* loop here for each buffer needing assign */ - for (i =3D 0; i < ring->size; i++) { - cb =3D ring->cbs + i; - if (bcmgenet_rx_refill(ring, cb)) - return -ENOMEM; - } - - return 0; + for (i =3D 0; i < ring->size; i++) + bcmgenet_rx_arm_cb(priv, ring->cbs + i); } =20 static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv) @@ -2958,41 +2971,33 @@ static void bcmgenet_init_tx_ring(struct bcmgenet_p= riv *priv, netif_napi_add_tx(priv->dev, &ring->napi, bcmgenet_tx_poll); } =20 -static int bcmgenet_rx_ring_create_pool(struct bcmgenet_priv *priv, - struct bcmgenet_rx_ring *ring) +static struct page_pool *bcmgenet_create_rx_pool(struct bcmgenet_priv *pri= v, + unsigned int size) { /* Buffers may share a page, depending on PAGE_SIZE and the MTU. - * bcmgenet_rx_refill() syncs each one for the device, + * bcmgenet_rx_arm_cb() syncs each one for the device, * PP_FLAG_DMA_SYNC_DEV would sync the whole page. */ struct page_pool_params pp_params =3D { .order =3D 0, .flags =3D PP_FLAG_DMA_MAP, - .pool_size =3D ring->size, + .pool_size =3D size, .nid =3D NUMA_NO_NODE, .dev =3D &priv->pdev->dev, .dma_dir =3D DMA_FROM_DEVICE, }; - int err; - - ring->page_pool =3D page_pool_create(&pp_params); - if (IS_ERR(ring->page_pool)) { - err =3D PTR_ERR(ring->page_pool); - ring->page_pool =3D NULL; - return err; - } =20 - return 0; + return page_pool_create(&pp_params); } =20 /* Initialize a RDMA ring */ -static int bcmgenet_init_rx_ring(struct bcmgenet_priv *priv, - unsigned int index, unsigned int size, - unsigned int start_ptr, unsigned int end_ptr) +static void bcmgenet_init_rx_ring(struct bcmgenet_priv *priv, + unsigned int index, unsigned int size, + unsigned int start_ptr, unsigned int end_ptr, + struct page_pool *pool) { struct bcmgenet_rx_ring *ring =3D &priv->rx_rings[index]; u32 words_per_bd =3D WORDS_PER_BD(priv); - int ret, i; =20 ring->priv =3D priv; ring->index =3D index; @@ -3002,19 +3007,9 @@ static int bcmgenet_init_rx_ring(struct bcmgenet_pri= v *priv, ring->read_ptr =3D start_ptr; ring->cb_ptr =3D start_ptr; ring->end_ptr =3D end_ptr - 1; + ring->page_pool =3D pool; =20 - ret =3D bcmgenet_rx_ring_create_pool(priv, ring); - if (ret) - return ret; - - ret =3D bcmgenet_alloc_rx_buffers(priv, ring); - if (ret) { - for (i =3D 0; i < ring->size; i++) - bcmgenet_free_rx_cb(ring->cbs + i, ring->page_pool); - page_pool_destroy(ring->page_pool); - ring->page_pool =3D NULL; - return ret; - } + bcmgenet_arm_rx_buffers(priv, ring); =20 bcmgenet_init_dim(ring, bcmgenet_dim_work); bcmgenet_init_rx_coalesce(ring); @@ -3041,8 +3036,6 @@ static int bcmgenet_init_rx_ring(struct bcmgenet_priv= *priv, RDMA_WRITE_PTR); bcmgenet_rdma_ring_writel(priv, index, end_ptr * words_per_bd - 1, DMA_END_ADDR); - - return ret; } =20 static void bcmgenet_enable_tx_napi(struct bcmgenet_priv *priv) @@ -3230,18 +3223,17 @@ static void bcmgenet_destroy_rx_page_pools(struct b= cmgenet_priv *priv) * * Queue 0 is also the default Rx queue with GENET_Q0_RX_BD_CNT descriptor= s. */ -static int bcmgenet_init_rx_queues(struct net_device *dev) +static void bcmgenet_init_rx_queues(struct net_device *dev, + struct bcmgenet_dma_set *set) { struct bcmgenet_priv *priv =3D netdev_priv(dev); unsigned int start =3D 0, end =3D GENET_Q0_RX_BD_CNT; u32 i, ring_mask; - int ret; =20 /* Initialize Rx priority queues */ for (i =3D 0; i <=3D priv->hw_params->rx_queues; i++) { - ret =3D bcmgenet_init_rx_ring(priv, i, end - start, start, end); - if (ret) - return ret; + bcmgenet_init_rx_ring(priv, i, end - start, start, end, + set->page_pool[i]); =20 start =3D end; end +=3D priv->hw_params->rx_bds_per_q; @@ -3254,8 +3246,6 @@ static int bcmgenet_init_rx_queues(struct net_device = *dev) /* Enable Rx rings */ ring_mask <<=3D DMA_RING_BUF_EN_SHIFT; bcmgenet_rdma_writel(priv, ring_mask, DMA_CTRL); - - return 0; } =20 static int bcmgenet_dma_teardown(struct bcmgenet_priv *priv) @@ -3301,11 +3291,86 @@ static void bcmgenet_fini_dma(struct bcmgenet_priv = *priv) priv->tx_cbs =3D NULL; } =20 -/* init_edma: Initialize DMA control register */ -static int bcmgenet_init_dma(struct bcmgenet_priv *priv, bool flush_rx) +/* Hand back a set that was never installed */ +static void bcmgenet_free_dma_set(struct bcmgenet_priv *priv, + struct bcmgenet_dma_set *set) +{ + unsigned int start =3D 0, end =3D GENET_Q0_RX_BD_CNT; + unsigned int i, q; + + for (q =3D 0; q <=3D priv->hw_params->rx_queues; q++) { + if (set->page_pool[q]) { + for (i =3D start; i < end; i++) + bcmgenet_free_rx_cb(set->rx_cbs + i, + set->page_pool[q]); + page_pool_destroy(set->page_pool[q]); + } + + start =3D end; + end +=3D priv->hw_params->rx_bds_per_q; + } + + kfree(set->rx_cbs); + kfree(set->tx_cbs); + memset(set, 0, sizeof(*set)); +} + +/* Build everything a datapath of this buffer length needs. The running one + * keeps its own until the caller installs this set, so a failure here cos= ts + * nothing. + */ +static int bcmgenet_alloc_dma(struct bcmgenet_priv *priv, unsigned int buf= _len, + struct bcmgenet_dma_set *set) +{ + unsigned int start =3D 0, end =3D GENET_Q0_RX_BD_CNT; + unsigned int i, q; + + memset(set, 0, sizeof(*set)); + + set->rx_cbs =3D kzalloc_objs(struct enet_cb, TOTAL_DESC); + set->tx_cbs =3D kzalloc_objs(struct enet_cb, TOTAL_DESC); + if (!set->rx_cbs || !set->tx_cbs) + goto err; + + for (i =3D 0; i < TOTAL_DESC; i++) { + set->rx_cbs[i].bd_addr =3D priv->base + + priv->hw_params->rdma_offset + + i * DMA_DESC_SIZE; + set->tx_cbs[i].bd_addr =3D priv->base + + priv->hw_params->tdma_offset + + i * DMA_DESC_SIZE; + } + + for (q =3D 0; q <=3D priv->hw_params->rx_queues; q++) { + set->page_pool[q] =3D bcmgenet_create_rx_pool(priv, end - start); + if (IS_ERR(set->page_pool[q])) { + set->page_pool[q] =3D NULL; + goto err; + } + + for (i =3D start; i < end; i++) + if (bcmgenet_rx_alloc_cb(priv, set->page_pool[q], + buf_len, set->rx_cbs + i)) + goto err; + + start =3D end; + end +=3D priv->hw_params->rx_bds_per_q; + } + + return 0; + +err: + bcmgenet_free_dma_set(priv, set); + + return -ENOMEM; +} + +/* Install a set built by bcmgenet_alloc_dma() and start the engines. The = set + * is consumed either way, a failure frees it and leaves no datapath behin= d. + */ +static int bcmgenet_init_dma(struct bcmgenet_priv *priv, bool flush_rx, + struct bcmgenet_dma_set *set) { - struct enet_cb *cb; - unsigned int i; int ret; u32 reg; =20 @@ -3315,14 +3380,14 @@ static int bcmgenet_init_dma(struct bcmgenet_priv *= priv, bool flush_rx) ret =3D bcmgenet_tdma_disable(priv); if (ret) { netdev_err(priv->dev, "failed to halt Tx DMA\n"); - return ret; + goto err; } =20 /* Disable RX DMA */ ret =3D bcmgenet_rdma_disable(priv); if (ret) { netdev_err(priv->dev, "failed to halt Rx DMA\n"); - return ret; + goto err; } =20 /* Flush TX queues */ @@ -3338,49 +3403,21 @@ static int bcmgenet_init_dma(struct bcmgenet_priv *= priv, bool flush_rx) udelay(10); } =20 - /* Initialize common Rx ring structures */ + /* The set belongs to the datapath from here on */ priv->rx_bds =3D priv->base + priv->hw_params->rdma_offset; priv->num_rx_bds =3D TOTAL_DESC; - priv->rx_cbs =3D kzalloc_objs(struct enet_cb, priv->num_rx_bds); - if (!priv->rx_cbs) - return -ENOMEM; + priv->rx_cbs =3D set->rx_cbs; =20 - for (i =3D 0; i < priv->num_rx_bds; i++) { - cb =3D priv->rx_cbs + i; - cb->bd_addr =3D priv->rx_bds + i * DMA_DESC_SIZE; - } - - /* Initialize common TX ring structures */ priv->tx_bds =3D priv->base + priv->hw_params->tdma_offset; priv->num_tx_bds =3D TOTAL_DESC; - priv->tx_cbs =3D kzalloc_objs(struct enet_cb, priv->num_tx_bds); - if (!priv->tx_cbs) { - kfree(priv->rx_cbs); - priv->rx_cbs =3D NULL; - return -ENOMEM; - } - - for (i =3D 0; i < priv->num_tx_bds; i++) { - cb =3D priv->tx_cbs + i; - cb->bd_addr =3D priv->tx_bds + i * DMA_DESC_SIZE; - } + priv->tx_cbs =3D set->tx_cbs; =20 /* Init rDma */ bcmgenet_rdma_writel(priv, priv->dma_max_burst_length, DMA_SCB_BURST_SIZE); =20 /* Initialize Rx queues */ - ret =3D bcmgenet_init_rx_queues(priv->dev); - if (ret) { - netdev_err(priv->dev, "failed to initialize Rx queues\n"); - bcmgenet_free_rx_buffers(priv); - bcmgenet_destroy_rx_page_pools(priv); - kfree(priv->rx_cbs); - priv->rx_cbs =3D NULL; - kfree(priv->tx_cbs); - priv->tx_cbs =3D NULL; - return ret; - } + bcmgenet_init_rx_queues(priv->dev, set); =20 /* Init tDma */ bcmgenet_tdma_writel(priv, priv->dma_max_burst_length, @@ -3399,6 +3436,11 @@ static int bcmgenet_init_dma(struct bcmgenet_priv *p= riv, bool flush_rx) bcmgenet_tdma_writel(priv, reg, DMA_CTRL); =20 return 0; + +err: + bcmgenet_free_dma_set(priv, set); + + return ret; } =20 /* Interrupt bottom half */ @@ -3571,6 +3613,7 @@ static void bcmgenet_netif_start(struct net_device *d= ev, bool start_phy) static int bcmgenet_open(struct net_device *dev) { struct bcmgenet_priv *priv =3D netdev_priv(dev); + struct bcmgenet_dma_set set; int ret; =20 netif_dbg(priv, ifup, dev, "bcmgenet_open\n"); @@ -3600,7 +3643,11 @@ static int bcmgenet_open(struct net_device *dev) bcmgenet_hfb_restore(priv); =20 /* Reinitialize TDMA and RDMA and SW housekeeping */ - ret =3D bcmgenet_init_dma(priv, true); + ret =3D bcmgenet_alloc_dma(priv, priv->rx_buf_len, &set); + if (ret) + goto err_clk_disable; + + ret =3D bcmgenet_init_dma(priv, true, &set); if (ret) { netdev_err(dev, "failed to initialize DMA\n"); goto err_clk_disable; @@ -4455,6 +4502,7 @@ static int bcmgenet_resume(struct device *d) struct net_device *dev =3D dev_get_drvdata(d); struct bcmgenet_priv *priv =3D netdev_priv(dev); struct bcmgenet_rxnfc_rule *rule; + struct bcmgenet_dma_set set; int ret; u32 reg; =20 @@ -4520,7 +4568,9 @@ static int bcmgenet_resume(struct device *d) bcmgenet_hfb_restore(priv); =20 /* Reinitialize TDMA and RDMA and SW housekeeping */ - ret =3D bcmgenet_init_dma(priv, false); + ret =3D bcmgenet_alloc_dma(priv, priv->rx_buf_len, &set); + if (!ret) + ret =3D bcmgenet_init_dma(priv, false, &set); if (ret) { /* Leave the block clocked, close and suspend tear it down */ netdev_err(dev, "failed to initialize DMA\n"); diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/e= thernet/broadcom/genet/bcmgenet.h index 906639c1f012..1f48a67c5c01 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h @@ -541,6 +541,15 @@ struct bcmgenet_hw_params { u32 words_per_bd; }; =20 +/* Everything an open datapath needs that can fail to be allocated. Built + * before the running one is given up, so a failure changes nothing. + */ +struct bcmgenet_dma_set { + struct enet_cb *rx_cbs; + struct enet_cb *tx_cbs; + struct page_pool *page_pool[GENET_MAX_MQ_CNT + 1]; +}; + struct bcmgenet_skb_cb { struct enet_cb *first_cb; /* First control block of SKB */ struct enet_cb *head_cb; /* Owns the head mapping */ --=20 2.53.0 From nobody Tue Nov 24 11:37:52 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=194.13.80.246 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795425459; b=Z+7AD5DdANjmEiTdYMkIJpm/LbEjBKreg3jbQPyqN+qqhNmt3+CukiKatw6i8sMLa86i iM1VUWRbvuV44yON/WtAEGmQeNYMCw87dNm/ihfaygx7ueJX9qdXuwgwfhNStEth2sO9d vv9Q+YcEs31Wlx9kNRd6QjArh4wqUff7im93GIeSUqxQRaw5QGz+wTf89+yn5d9hFIEbr vENhe5r4WAGB+gSFhQXNmwJBItQy4tBuaBouY6IzwFSVb6n4JnFTkEsoBbQuB5i0I1RKN ZZg7nmJ6SDb/qabi3h+RQ62JIHxQ7jweF/kIcZ15tEy1fAKOG5aJ1qVHY3bhnWvHVdg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795425459; h=DMARC-Filter:Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Last-TLS-Session-Version; bh=scULwfSS6H8D57RpiRf700PDIe2LlM97htd+XHYiKwM=; b=xXLy0RbgtWIF7k/kfBz12bMH/FOtjubYitLzJUR9JDYcfi6GNOmEDyPpdpxAnzR53Aai KXyAoylwQhFbZ8YxxcwZOAAWMEMXL7fB6NbSf6VEbC4P/Z2hVd011FtBK24PKkYCTI4BR TlD+AdMiQ8ZYV43AuXpAJ2PP/Uaes0x9QKAFBg2KYKwDX4csIDPGtk9uou474iJYxgPrw /6mNqCV+0QmPDYXgIOyiUarjLHzkFKMf/CnHaEywQ5TbNqUFF2/JuHoz2FyOvDgpDl7Wm c/PVbVhhSF7wZiq3GkKNy3RqNSSYEJbJ8Y1VIokrwZkanWvt89dTaYqEjPwMlNQ7jHA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=tipi-net.de; spf=pass smtp.mailfrom=tipi-net.de; dkim=pass header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=GKorEHrO; arc=none smtp.remote-ip=194.13.80.246 Received: from mail.tipi-net.de (mail.tipi-net.de [194.13.80.246]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CA36606A335; Mon, 23 Nov 2026 09:17:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0CA36606A335 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=GKorEHrO Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D7CF4A9338; Mon, 23 Nov 2026 10:17:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tipi-net.de; s=dkim; t=1795425457; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=scULwfSS6H8D57RpiRf700PDIe2LlM97htd+XHYiKwM=; b=GKorEHrOBsyv9YOdDy80ICW4xL/YocmF+cfRvjFYvi6WrXEayw5vANU46Uz7FIsuXNrUo5 zHfHbtaaRtokrGIAyVX9iNIcEy0E8I1gB+tTWYnGxX/u1Ml2HfwG2hVrIH71Q6hlkv42JA Odb0Resmxo/igDODOvvxsQdLocKkRTZfIw1mrk7cjC9YUviP/YJDuESlQPK4VC4Bz6ILav 5Xq52lAiRLbjkqGgrvbMTcCkGlLohXxFsHKKhzSWw08DKFFpz0lehpdcHS4acCPfVMaCds JaLULFSV0VZytr/0OC3w6XWxQ1TmKobGEQUD0C2wTuW38h6d7VNzPbqXnS4cuw== From: Nicolai Buchwitz Date: Mon, 23 Nov 2026 10:17:15 +0100 Subject: [PATCH net-next v9 7/8] net: bcmgenet: allow the MTU to be changed X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-nb-genet-mtu-nn-v2-v9-7-4f93ded19bbb@tipi-net.de> References: <20261123-nb-genet-mtu-nn-v2-v9-0-4f93ded19bbb@tipi-net.de> In-Reply-To: <20261123-nb-genet-mtu-nn-v2-v9-0-4f93ded19bbb@tipi-net.de> To: Doug Berger , Florian Fainelli , Nicolai Buchwitz , Broadcom internal kernel review list , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.16.0 X-Last-TLS-Session-Version: TLSv1.3 The driver never sets dev->max_mtu, so the MTU is stuck at ETH_DATA_LEN. One descriptor reaches as far as the packet ready threshold, so derive the maximum from it. The threshold registers are 8 bit in units of 16 bytes and want a multiple of the 256 byte burst size. A descriptor is one page and also holds skb_shared_info behind the frame. On 4K pages the page is the tighter limit and leaves 3564 bytes. That includes room for a VLAN tag so a VLAN interface can run at the parent MTU. The MAC accepts a little more than one descriptor holds, so a double tagged frame at that maximum is dropped as fragmented until a later patch reassembles those. The PHY keeps running across the change so the link stays up, with its lock held so that a link event cannot enable the MAC while the registers change. Two MTUs at or below ETH_DATA_LEN derive the same values, so a change between them needs no restart at all. Only v5 is known to size the TBUF for a long frame and to carry the full length in a transmit descriptor, so the older parts keep the default MTU until someone confirms them. Only a DMA that refuses to halt still takes the interface down, because nothing is left to run on. Suggested-by: Dave Stevenson Link: https://github.com/raspberrypi/linux/issues/5561 Signed-off-by: Nicolai Buchwitz --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 99 ++++++++++++++++++++++= ++++ 1 file changed, 99 insertions(+) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/e= thernet/broadcom/genet/bcmgenet.c index ae20c4b3c570..8dcee6951be3 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -91,6 +91,12 @@ ENET_THLD_MAX * ENET_THLD_UNIT, \ ENET_THLD_PAGE_LEN) =20 +/* Largest MTU that fits one descriptor, with room for a VLAN tag so a VLAN + * interface can use the parent MTU. + */ +#define ENET_MAX_MTU (ENET_THLD_MAX_LEN - GENET_RBUF_ALIGN - \ + ETH_HLEN - VLAN_HLEN) + /* Tx/Rx DMA register offset, skip 256 descriptors */ #define WORDS_PER_BD(p) (p->hw_params->words_per_bd) #define DMA_DESC_SIZE (WORDS_PER_BD(priv) * sizeof(u32)) @@ -3988,6 +3994,89 @@ static int bcmgenet_change_carrier(struct net_device= *dev, bool new_carrier) return 0; } =20 +static int bcmgenet_change_mtu(struct net_device *dev, int new_mtu) +{ + struct bcmgenet_priv *priv =3D netdev_priv(dev); + unsigned int old_mtu =3D dev->mtu; + struct bcmgenet_dma_set set; + int ret; + + /* A failed resume left the datapath down, nothing to reprogram */ + if (!netif_running(dev) || !priv->tx_cbs) { + WRITE_ONCE(dev->mtu, new_mtu); + priv->rx_buf_len =3D bcmgenet_rx_buf_len(new_mtu); + return 0; + } + + /* Below ETH_DATA_LEN everything is floored, so there is nothing to + * reprogram and rx_buf_len stays as the receive path reads it. + */ + if (max_t(unsigned int, old_mtu, ETH_DATA_LEN) =3D=3D + max_t(unsigned int, new_mtu, ETH_DATA_LEN)) { + WRITE_ONCE(dev->mtu, new_mtu); + return 0; + } + + ret =3D bcmgenet_alloc_dma(priv, bcmgenet_rx_buf_len(new_mtu), &set); + if (ret) + return ret; + + /* The watchdog trips on an idle queue once the rings are gone */ + netif_device_detach(dev); + + /* The PHY stays up, hold its lock. A link event would otherwise take + * the MAC out of reset and enable it mid rewrite. + */ + mutex_lock(&dev->phydev->lock); + bcmgenet_netif_stop(dev, false); + + WRITE_ONCE(dev->mtu, new_mtu); + priv->rx_buf_len =3D bcmgenet_rx_buf_len(new_mtu); + bcmgenet_set_mtu_regs(priv, new_mtu); + + ret =3D bcmgenet_init_dma(priv, true, &set); + if (ret) { + /* The datapath is gone, do not leave the interface up */ + netdev_err(dev, "failed to initialize DMA, closing\n"); + WRITE_ONCE(dev->mtu, old_mtu); + priv->rx_buf_len =3D bcmgenet_rx_buf_len(old_mtu); + mutex_unlock(&dev->phydev->lock); + /* bcmgenet_close() attaches the device again */ + netif_close(dev); + return ret; + } + + bcmgenet_hfb_restore(priv); + bcmgenet_netif_start(dev, false); + + /* bcmgenet_netif_start() only restores the link interrupt */ + if (bcmgenet_has_mdio_intr(priv)) + bcmgenet_intrl2_0_writel(priv, UMAC_IRQ_MDIO_EVENT, + INTRL2_CPU_MASK_CLEAR); + + mutex_unlock(&dev->phydev->lock); + + /* Interrupts were off, so a latched link event is lost. Internal PHYs + * on v1-v4 are not polled either. + */ + phy_mac_interrupt(dev->phydev); + + /* An energy detect event cancelled with the work is still latched */ + if (READ_ONCE(priv->irq0_stat)) + schedule_work(&priv->bcmgenet_irq_work); + + netif_device_attach(dev); + + /* Filter updates that came in while the device was detached got + * dropped. An IPv6 join does not hold RTNL. + */ + netif_addr_lock_bh(dev); + bcmgenet_set_rx_mode(dev); + netif_addr_unlock_bh(dev); + + return 0; +} + static const struct net_device_ops bcmgenet_netdev_ops =3D { .ndo_open =3D bcmgenet_open, .ndo_stop =3D bcmgenet_close, @@ -3999,6 +4088,7 @@ static const struct net_device_ops bcmgenet_netdev_op= s =3D { .ndo_set_features =3D bcmgenet_set_features, .ndo_get_stats64 =3D bcmgenet_get_stats64, .ndo_change_carrier =3D bcmgenet_change_carrier, + .ndo_change_mtu =3D bcmgenet_change_mtu, }; =20 /* GENET hardware parameters/characteristics */ @@ -4352,9 +4442,18 @@ static int bcmgenet_probe(struct platform_device *pd= ev) /* Mii wait queue */ init_waitqueue_head(&priv->wq); bcmgenet_hfb_init(priv); + priv->rx_buf_len =3D bcmgenet_rx_buf_len(dev->mtu); priv->tx_thld_len =3D bcmgenet_tx_pkt_rdy_thld(dev->mtu) * ENET_THLD_UNIT; priv->tx_thld_window =3D priv->dma_max_burst_length * ENET_BURST_UNIT; + + /* Only v5 is known to size the TBUF for a long frame and to carry the + * full length in a transmit descriptor, the older parts stay at the + * default MTU + */ + if (GENET_IS_V5(priv)) + dev->max_mtu =3D ENET_MAX_MTU; + INIT_WORK(&priv->bcmgenet_irq_work, bcmgenet_irq_task); =20 priv->clk_wol =3D devm_clk_get_optional(&priv->pdev->dev, "enet-wol"); --=20 2.53.0 From nobody Tue Nov 24 11:37:52 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=194.13.80.246 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795425460; b=VZf8KxBATMn2DTp/e1gbn8PGm6a0vbuqZ9Tm2Z/kivpjwY9opkga3dfCSGrVJJ5/2QGH 18byaodkxlbAPF67FQ7ZjiNpaFsf/kN8fw+uT/sNYcAhS6HJf2N/mbzxXH/Wf0+NsgZPi qX6N9p96TZfh1dOY6rmonD2e29cVrQSdnqaOvC0t2D5GLCknTH5qNH1KqweSM9y2PUCWI vTkArS+jeAqy4DD4pYF+HrzpwEJ4BS0/2UfELg/fO26QAa8lLEjbSXN1TfVJAdgrSd4ER 6ZjzICN4PJaMnoC0zEzrBjKbvhDwAr1AtAKgs5r1e2Hrmcgl1TA8AK5u0OFdGk+XURw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795425460; h=DMARC-Filter:Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Last-TLS-Session-Version; bh=JQUYCkB366SxBfPGtuA4byxlG9aEEXGd8G/yHMo4qGI=; b=oMrraTIxlxCtqVh5vw10bPW0wKVPhEyZ3AwokTKerbYqWWM9ZuU9pTiD/jDb7dYZ73ZJ Jjc1UKE8lT+dCNqjCxcdakloCbQ6e9LSB1/zSkCRksl7NcbY3IRFvGFnxX4KM7FWTjbQ3 tuj1376jtuNHy4/8tVzwfGX1CC2O11nrD7E2tj14DJGDQsffEJ8Bbrl1j02F20NByiJSP qS6zGpo4ku7qzFf7Xi/cWKfGAbKzbJK5V5TX8PrpgFyYpsD7J/Lgd2vNF63pQg0e+yyjZ XZQ1Gs9RZ0bK4n+YAd+xRdLPKEiCCVgaWNe2c8thONejmF/wAixkp3yPDhenB1bEdqw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=tipi-net.de; spf=pass smtp.mailfrom=tipi-net.de; dkim=pass header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b="xkaC/xYX"; arc=none smtp.remote-ip=194.13.80.246 Received: from mail.tipi-net.de (mail.tipi-net.de [194.13.80.246]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC76860A383B; Mon, 23 Nov 2026 09:17:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DC76860A383B Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tipi-net.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=xkaC/xYX Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id BF8C3A933A; Mon, 23 Nov 2026 10:17:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tipi-net.de; s=dkim; t=1795425458; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=JQUYCkB366SxBfPGtuA4byxlG9aEEXGd8G/yHMo4qGI=; b=xkaC/xYXkiudmfJug/61JgZCA6+NZUq6CSU4cQP07RakW4k/cXLpjgLp30CaMhiikFnfqU ssVadYyXdkl038g/TltjSor0t/+3j3NMVxVXZ9wIhJOgFixh1T43ggNUT1mdT82ChxctSY CIBfV8XW9oyueFkLI6fmxdOi7IugWLA5wDUc/iofJLlTu6UcHb5BmD0O3Bd0q2RJrgeriJ 2FoSlwVEHntwgA+sfpCPDMI0ZtWjmMy/tH+xDVS2/tyrWslx9KCUo1koWUV7Jw9V7wZTf9 vjF0lXSzIfMirmpY9eAW+yA9pmwLnooUEgMJaDkyMNe8RG9LfSFavdmisZrHmQ== From: Nicolai Buchwitz Date: Mon, 23 Nov 2026 10:17:16 +0100 Subject: [PATCH net-next v9 8/8] net: bcmgenet: reassemble jumbo frames from status block fragments X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-nb-genet-mtu-nn-v2-v9-8-4f93ded19bbb@tipi-net.de> References: <20261123-nb-genet-mtu-nn-v2-v9-0-4f93ded19bbb@tipi-net.de> In-Reply-To: <20261123-nb-genet-mtu-nn-v2-v9-0-4f93ded19bbb@tipi-net.de> To: Doug Berger , Florian Fainelli , Nicolai Buchwitz , Broadcom internal kernel review list , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Justin Chen X-Mailer: b4 0.16.0 X-Last-TLS-Session-Version: TLSv1.3 The hardware does not truncate a frame longer than the packet ready threshold. It splits the frame across descriptors and writes a status block at the start of each one. The first fragment then arrives with SOP and no EOP and is dropped as fragmented. This caps the MTU. Strip the status blocks and reassemble the fragments. Only the last block holds the checksum of the whole frame. Broadcom confirmed from the RTL that every GENET revision splits long frames this way, not just the v5 this was tested on. On transmit the MAC only checksums a frame it holds in full, so anything longer than the threshold falls back to software. At jumbo sizes the larger frame saves more per packet overhead than the checksum costs. UMAC_MAX_FRAME_LEN is 14 bit and counts the FCS. That puts the maximum MTU at 16347. The TX descriptor length field is wider than DMA_BUFLENGTH_MASK suggests, that mask only extracts the length from the RX status word. A frame of 16361 bytes, the largest untagged frame that MTU allows, came back byte exact 200 times over UMAC loopback. Suggested-by: Justin Chen Signed-off-by: Nicolai Buchwitz --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 133 +++++++++++++++++++++= ---- drivers/net/ethernet/broadcom/genet/bcmgenet.h | 4 +- 2 files changed, 114 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/e= thernet/broadcom/genet/bcmgenet.c index 8dcee6951be3..b4e3fe21a5d6 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -91,11 +91,8 @@ ENET_THLD_MAX * ENET_THLD_UNIT, \ ENET_THLD_PAGE_LEN) =20 -/* Largest MTU that fits one descriptor, with room for a VLAN tag so a VLAN - * interface can use the parent MTU. - */ -#define ENET_MAX_MTU (ENET_THLD_MAX_LEN - GENET_RBUF_ALIGN - \ - ETH_HLEN - VLAN_HLEN) +/* UMAC_MAX_FRAME_LEN is 14 bits wide and counts the FCS */ +#define ENET_MAX_MTU (GENMASK(13, 0) - ENET_FRAME_OVERHEAD) =20 /* Tx/Rx DMA register offset, skip 256 descriptors */ #define WORDS_PER_BD(p) (p->hw_params->words_per_bd) @@ -2437,6 +2434,52 @@ static int bcmgenet_rx_refill(struct bcmgenet_rx_rin= g *ring, return 0; } =20 +/* The rest of the frame carries no SOP. Drop it and do not count it again + * until the next SOP, unless this descriptor already ended the frame. + */ +static void bcmgenet_discard_frags(struct bcmgenet_rx_ring *ring, bool eop) +{ + ring->frag_drop =3D !eop; + + if (!ring->frag_head) + return; + + dev_kfree_skb_any(ring->frag_head); + ring->frag_head =3D NULL; +} + +/* A frame longer than the threshold arrives in several descriptors, each = with + * its own status block. Returns the frame once EOP is in. NULL means eith= er + * more descriptors are coming or the frame is gone. + */ +static struct sk_buff *bcmgenet_add_frag(struct bcmgenet_rx_ring *ring, + struct page *page, + unsigned int offset, + unsigned int size, + unsigned int dma_flag, + unsigned int len) +{ + struct sk_buff *head =3D ring->frag_head; + + if (unlikely(skb_shinfo(head)->nr_frags >=3D MAX_SKB_FRAGS)) { + BCMGENET_STATS64_INC((&ring->stats64), fragmented_errors); + bcmgenet_discard_frags(ring, dma_flag & DMA_EOP); + page_pool_put_full_page(ring->page_pool, page, true); + return NULL; + } + + skb_add_rx_frag(head, skb_shinfo(head)->nr_frags, page, + offset + sizeof(struct status_64), + len - sizeof(struct status_64), size); + + if (!(dma_flag & DMA_EOP)) + return NULL; + + ring->frag_head =3D NULL; + + return head; +} + /* bcmgenet_desc_rx - descriptor based rx process. * this could be called from bottom half, or from NAPI polling method. */ @@ -2454,6 +2497,7 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_= rx_ring *ring, unsigned int rxpktprocessed =3D 0, rxpkttoprocess; unsigned int bytes_processed =3D 0; unsigned int p_index, mask; + unsigned int rxframes =3D 0; unsigned int discards; =20 /* Clear status before servicing to reduce spurious interrupts */ @@ -2501,6 +2545,7 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_= rx_ring *ring, =20 if (bcmgenet_rx_refill(ring, cb)) { BCMGENET_STATS64_INC(stats, dropped); + bcmgenet_discard_frags(ring, false); goto next; } =20 @@ -2525,24 +2570,43 @@ static unsigned int bcmgenet_desc_rx(struct bcmgene= t_rx_ring *ring, __func__, p_index, ring->c_index, ring->read_ptr, dma_length_status); =20 - /* Only the first descriptor carries the alignment pad */ - min_len =3D dma_flag & DMA_SOP ? GENET_RSB_PAD - : sizeof(struct status_64); + /* Only the first descriptor carries the alignment pad. A head + * with more to come needs the Ethernet header in it, a + * continuation needs at least one payload byte. + */ + if (dma_flag & DMA_SOP) { + min_len =3D GENET_RSB_PAD; + if (!(dma_flag & DMA_EOP)) + min_len +=3D ETH_HLEN; + } else { + min_len =3D sizeof(struct status_64) + 1; + } =20 /* Reject lengths that would underflow the SKB build path. */ if (unlikely(len > priv->rx_buf_len || len < min_len)) { netif_err(priv, rx_status, dev, "invalid packet length %d\n", len); BCMGENET_STATS64_INC(stats, length_errors); + if ((dma_flag & DMA_SOP) && ring->frag_head) + BCMGENET_STATS64_INC(stats, fragmented_errors); + bcmgenet_discard_frags(ring, dma_flag & DMA_EOP); page_pool_put_full_page(ring->page_pool, rx_page, true); goto next; } =20 - if (unlikely(!(dma_flag & DMA_EOP) || !(dma_flag & DMA_SOP))) { - netif_err(priv, rx_status, dev, - "dropping fragmented packet!\n"); - BCMGENET_STATS64_INC(stats, fragmented_errors); + /* A new SOP picks up again after an incomplete frame */ + if (dma_flag & DMA_SOP) { + if (ring->frag_head) { + BCMGENET_STATS64_INC(stats, fragmented_errors); + bcmgenet_discard_frags(ring, false); + } + ring->frag_drop =3D false; + } else if (unlikely(!ring->frag_head)) { + /* Rest of a dropped frame, or no SOP seen yet */ + if (!ring->frag_drop) + BCMGENET_STATS64_INC(stats, fragmented_errors); + ring->frag_drop =3D !(dma_flag & DMA_EOP); page_pool_put_full_page(ring->page_pool, rx_page, true); goto next; @@ -2572,17 +2636,27 @@ static unsigned int bcmgenet_desc_rx(struct bcmgene= t_rx_ring *ring, DMA_RX_RXER)) =3D=3D DMA_RX_RXER) u64_stats_inc(&stats->errors); u64_stats_update_end(&stats->syncp); + bcmgenet_discard_frags(ring, dma_flag & DMA_EOP); page_pool_put_full_page(ring->page_pool, rx_page, true); goto next; } /* error packet */ =20 + if (!(dma_flag & DMA_SOP)) { + skb =3D bcmgenet_add_frag(ring, rx_page, rx_offset, + rx_size, dma_flag, len); + if (!skb) + goto next; + goto deliver; + } + /* Build SKB from the page - data starts at hard_start, * frame begins after RSB(64) + pad(2) =3D 66 bytes. */ skb =3D napi_build_skb(hard_start, rx_size); if (unlikely(!skb)) { BCMGENET_STATS64_INC(stats, dropped); + bcmgenet_discard_frags(ring, dma_flag & DMA_EOP); page_pool_put_full_page(ring->page_pool, rx_page, true); goto next; @@ -2594,17 +2668,26 @@ static unsigned int bcmgenet_desc_rx(struct bcmgene= t_rx_ring *ring, skb_reserve(skb, GENET_RSB_PAD); __skb_put(skb, len - GENET_RSB_PAD); =20 - if (priv->crc_fwd_en) { - skb_trim(skb, skb->len - ETH_FCS_LEN); + if (unlikely(!(dma_flag & DMA_EOP))) { + ring->frag_head =3D skb; + goto next; + } + +deliver: + /* The FCS trim may release the page with the last status block */ + rx_csum =3D (__force __be16)(status->rx_csum & 0xffff); + + if (priv->crc_fwd_en && + unlikely(pskb_trim(skb, skb->len - ETH_FCS_LEN))) { + BCMGENET_STATS64_INC(stats, dropped); + dev_kfree_skb_any(skb); + goto next; } =20 /* Set up checksum offload */ - if (dev->features & NETIF_F_RXCSUM) { - rx_csum =3D (__force __be16)(status->rx_csum & 0xffff); - if (rx_csum) { - skb->csum =3D (__force __wsum)ntohs(rx_csum); - skb->ip_summed =3D CHECKSUM_COMPLETE; - } + if ((dev->features & NETIF_F_RXCSUM) && rx_csum) { + skb->csum =3D (__force __wsum)ntohs(rx_csum); + skb->ip_summed =3D CHECKSUM_COMPLETE; } =20 len =3D skb->len; @@ -2612,6 +2695,7 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_= rx_ring *ring, =20 /*Finish setting up the received SKB and send it to the kernel*/ skb->protocol =3D eth_type_trans(skb, priv->dev); + rxframes++; =20 u64_stats_update_begin(&stats->syncp); u64_stats_inc(&stats->packets); @@ -2638,7 +2722,8 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_= rx_ring *ring, } =20 ring->dim.bytes =3D bytes_processed; - ring->dim.packets =3D rxpktprocessed; + /* A long frame spans several descriptors but is one packet */ + ring->dim.packets =3D rxframes; =20 return rxpktprocessed; } @@ -2705,6 +2790,8 @@ static void bcmgenet_free_rx_buffers(struct bcmgenet_= priv *priv) cb =3D ring->cbs + i; bcmgenet_free_rx_cb(cb, ring->page_pool); } + /* A partial frame still holds pages of this pool */ + bcmgenet_discard_frags(ring, true); } } =20 @@ -2775,7 +2862,9 @@ static void bcmgenet_link_intr_enable(struct bcmgenet= _priv *priv) } =20 /* Receive threshold in register units. Covers the alignment bytes and the - * frame, but not the status block, which the hardware adds on top. + * frame, but not the status block, which the hardware adds on top. The + * usable maximum is whichever of register and page is smaller. A longer + * frame arrives in several descriptors. */ static unsigned int bcmgenet_pkt_rdy_thld(unsigned int mtu) { diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/e= thernet/broadcom/genet/bcmgenet.h index 1f48a67c5c01..8f432a830a5a 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h @@ -446,7 +446,7 @@ struct bcmgenet_rx_stats64 { #define DMA_RATE_ADJ_MASK 0xFF =20 /* Tx/Rx Dma Descriptor common bits*/ -#define DMA_BUFLENGTH_MASK 0x0fff +#define DMA_BUFLENGTH_MASK 0x0fff /* RX status word only */ #define DMA_BUFLENGTH_SHIFT 16 #define DMA_OWN 0x8000 #define DMA_EOP 0x4000 @@ -598,6 +598,8 @@ struct bcmgenet_rx_ring { unsigned int cb_ptr; /* Rx ring initial CB ptr */ unsigned int end_ptr; /* Rx ring end CB ptr */ unsigned int old_discards; + struct sk_buff *frag_head; /* frame being reassembled */ + bool frag_drop; /* discarding until the next SOP */ struct bcmgenet_net_dim dim; u32 rx_max_coalesced_frames; u32 rx_coalesce_usecs; --=20 2.53.0