From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.225 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796425259; b=I/yWU8Ekm80Ttv87L0B8yQk72nNg3YQuKJAsqj6lAblg0mQfnHaCQLVU5crL1zqWZOAv DIDz6hfl6EeFnFjiiIRtmVvWY/AAeIlNFqQluUo0G/DpX5CDFlgT8m/PKrZuf8DwAxjo6 5oybBqNTE7p04wopKSxk98llYJFL3u+fAJn1aE6HK+qcOeqO++FVUUHkNJ3gZxWcSxT6j ORmYu6afaIRKtK0UhlsBl1h+TTnHUhYN4C2DwqHplAPQsX7NDdBcm0Ste25QqBw5YRr/f XJPRyH9k0i7F3lUzsbyknIUz9dTYCYl5j6yJs4Rymgtnf1+QqIkq57wlsTPSdHUZ11g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796425259; h=DMARC-Filter:Received:X-Google-DKIM-Signature:X-Gm-Message-State: X-Gm-Gg:X-Received:Received:X-Relaying-Domain:X-CFilter-Loop:Received: DKIM-Signature:X-Received:X-Received:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-DetectorID-Processed; bh=GdSSMe8PIf20SvNhGTxC1jTx1NxGAfmoOU2Ix7D3bew=; b=ol1wbhcso2y08WPESTpOrTVppvKldrHjSOiGBnkth8JWyvme1iHoGnbhEghKNP1XYZqQ ipDYtX89eayWmdVYbI8EnKoG4zApKFUYYXE0Q6h/tcrRUb7My21IE4AQKGGan+AnFb3Hb YAjxg5Py3gkb+fhkOzT6jeO26pF9Yr36zVMvC582py4b5eIzpG+1bLN9yTmFvR8w1/Y2/ K2Flcv4KzwsCai+oP8ppZCCkpw3t1RUlzAmnY1VBOQda9oe6SOp43xcAiYzai/lrs4Mdy +RXIkzHvFS81R7LOMly1oIbGrc4F3JkEc1qn6fTFUIkBByB9y5bHsPtSkdvsJR2bwZQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=I04AWCM+; arc=none smtp.remote-ip=209.85.215.225 Received: from mail-pg1-f225.google.com (mail-pg1-f225.google.com [209.85.215.225]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F620606A32C for ; Fri, 4 Dec 2026 23:00:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6F620606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=I04AWCM+ Received: by mail-pg1-f225.google.com with SMTP id 41be03b00d2f7-cd69954c755so1411867a12.3 for ; Fri, 04 Dec 2026 15:00:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796425259; x=1797030059; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=GdSSMe8PIf20SvNhGTxC1jTx1NxGAfmoOU2Ix7D3bew=; b=An0pOX6HPyp/xEllauQwNWFyOiTVAGANb/LPZ4maX/wMAVh2cnIka2hFFmLgXaPKMf kP3CdN8Fn4xa79UwUPdvJXwW2WeLVLJVGaHyom5hpMDpORFG5zQh99IAaW8FRM4ZkxVT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3028991a91.21.1796425258655; Fri, 04 Dec 2026 15:00:58 -0800 (PST) Received: from smtp-us-east1-p01-i01-si01.dlp.protect.broadcom.com (address-144-49-247-26.dlp.protect.broadcom.com. [144.49.247.26]) by smtp-relay.gmail.com with ESMTPS id 98e67ed59e1d1-3b6168eb918sm149395a91.3.2026.12.04.15.00.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Dec 2026 15:00:58 -0800 (PST) X-Relaying-Domain: broadcom.com X-CFilter-Loop: Reflected Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-38355b03cb8so60922eec.0 for ; Fri, 04 Dec 2026 15:00:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1796425256; x=1797030056; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=GdSSMe8PIf20SvNhGTxC1jTx1NxGAfmoOU2Ix7D3bew=; b=I04AWCM+F5/iIg8aTKIWczggHlH1RM+BwUiNXGykdPootaVpN7gUpT4Xy+HTykc5YG VIq4kZt8J95nXcYhVlFjG9zON5yHREMJSfK1S9o3IbQP52bNdTaxDvKsxAuHC+sZRZ6j /Vjxu7OQbU2unkJlL3AtpjlN4EZ+lpSl7fxng= X-Received: by 2002:a05:693c:60d4:b0:386:9f89:aa80 with SMTP id 5a478bee46e88-38751e556d2mr3732714eec.0.1796425255325; Fri, 04 Dec 2026 15:00:55 -0800 (PST) X-Received: by 2002:a05:693c:60d4:b0:386:9f89:aa80 with SMTP id 5a478bee46e88-38751e556d2mr3732627eec.0.1796425254049; Fri, 04 Dec 2026 15:00:54 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875218c6a6sm11719545eec.5.2026.12.04.15.00.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 15:00:53 -0800 (PST) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Doug Berger , Nicolai Buchwitz , Broadcom internal kernel review list , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net-next 2/2] net: bcmgenet: add support for NETIF_F_RXFCS Date: Fri, 4 Dec 2026 15:00:48 -0800 Message-ID: <20261204230048.3554713-3-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204230048.3554713-1-florian.fainelli@broadcom.com> References: <20261204230048.3554713-1-florian.fainelli@broadcom.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-DetectorID-Processed: b00c1d49-9d2e-4205-b15f-d015386d3d5e Allow the Ethernet FCS to be delivered to the network stack, which is useful for packet capture and for debugging link-level corruption. The feature is off by default and is toggled with "ethtool -K rx-fcs on|off". bcmgenet_set_features() now programs CMD_CRC_FWD in UMAC_CMD according to NETIF_F_RXFCS, and keeps RBUF_SKIP_FCS in RBUF_CHK_CTRL in sync so the RX checksum block ignores the forwarded FCS. This replaces the previous read-back of CMD_CRC_FWD into priv->crc_fwd_en, which is still updated and still used by the Wake-on-LAN code. In bcmgenet_desc_rx() the FCS is only trimmed when it was forwarded and NETIF_F_RXFCS is off. The hardware checksum does not cover the FCS, so it cannot be reported as CHECKSUM_COMPLETE for frames that still carry it; such frames are left to the stack to verify. Frames already queued in the RX rings were written with the previous setting and cannot be told apart from new ones, so a change on a running interface is refused with -EBUSY. The request is kept in the device's wanted features, and bcmgenet_close() calls netdev_update_features() so that it takes effect once the interface is down. Changing the feature while the interface is down only needs the register update. The open and resume paths re-apply the current features and are not affected. Signed-off-by: Florian Fainelli --- .../net/ethernet/broadcom/genet/bcmgenet.c | 46 ++++++++++++++++--- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index 93a773d0ccf3..35a0fe425acd 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -814,14 +814,40 @@ static int bcmgenet_set_features(struct net_device *dev, u32 reg; int ret; + /* Frames already queued in the RX rings were written with the old FCS + * setting and cannot be told apart from new ones, so refuse a live + * change. The request stays in wanted_features and is applied by + * bcmgenet_close(). Re-applying the current features from open and + * resume does not change the flag and is not affected. + */ + if (netif_running(dev) && ((features ^ dev->features) & NETIF_F_RXFCS)) + return -EBUSY; + ret = clk_prepare_enable(priv->clk); if (ret) return ret; - /* Make sure we reflect the value of CRC_CMD_FWD */ + /* Forward the FCS to the host when NETIF_F_RXFCS is requested. + * RBUF_SKIP_FCS tells the RX checksum block to ignore the forwarded + * FCS, so keep it in sync with CMD_CRC_FWD. + */ + spin_lock_bh(&priv->reg_lock); reg = bcmgenet_umac_readl(priv, UMAC_CMD); + if (features & NETIF_F_RXFCS) + reg |= CMD_CRC_FWD; + else + reg &= ~CMD_CRC_FWD; + bcmgenet_umac_writel(priv, reg, UMAC_CMD); priv->crc_fwd_en = !!(reg & CMD_CRC_FWD); + reg = bcmgenet_rbuf_readl(priv, RBUF_CHK_CTRL); + if (priv->crc_fwd_en) + reg |= RBUF_SKIP_FCS; + else + reg &= ~RBUF_SKIP_FCS; + bcmgenet_rbuf_writel(priv, reg, RBUF_CHK_CTRL); + spin_unlock_bh(&priv->reg_lock); + clk_disable_unprepare(priv->clk); return ret; @@ -2461,12 +2487,15 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring, skb_reserve(skb, GENET_RSB_PAD); __skb_put(skb, len - GENET_RSB_PAD); - if (priv->crc_fwd_en) { + /* Strip the FCS unless the user asked to receive it */ + if (priv->crc_fwd_en && !(dev->features & NETIF_F_RXFCS)) skb_trim(skb, skb->len - ETH_FCS_LEN); - } - /* Set up checksum offload */ - if (dev->features & NETIF_F_RXCSUM) { + /* Set up checksum offload. The hardware checksum excludes the + * FCS, so it cannot be used when the FCS is passed up. + */ + if ((dev->features & NETIF_F_RXCSUM) && + !(dev->features & NETIF_F_RXFCS)) { rx_csum = (__force __be16)(status->rx_csum & 0xffff); if (rx_csum) { skb->csum = (__force __wsum)ntohs(rx_csum); @@ -3552,6 +3581,11 @@ static int bcmgenet_close(struct net_device *dev) clk_disable_unprepare(priv->clk); + /* Apply a feature change, e.g. NETIF_F_RXFCS, that was refused while + * the interface was running. The device is not running anymore. + */ + netdev_update_features(dev); + return ret; } @@ -4098,7 +4132,7 @@ static int bcmgenet_probe(struct platform_device *pdev) /* Set default features */ dev->features |= NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_RXCSUM; - dev->hw_features |= dev->features; + dev->hw_features |= dev->features | NETIF_F_RXFCS; dev->vlan_features |= dev->features; netdev_sw_irq_coalesce_default_on(dev); -- 2.56.1