From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BA125C021B3 for ; Fri, 21 Feb 2025 16:11:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 69DB741271; Fri, 21 Feb 2025 16:11:25 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id FdYALsTzU1VR; Fri, 21 Feb 2025 16:11:23 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 6F68041260 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1740154283; bh=Qp8DvYGUWgTHXAPWqbMBZV8Rl/qxPnTYUxFzmDOOo1U=; h=Date:From:To:Cc:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=QhyjltAGElkjUg2f/KxsC43rFBzibrXUEGlWgRiVOLER0/j8h8l1wv5gcCGTmaONH j//3LsnaIenkV9p3hpMZdiIUI5GEU7IXBTJycvBELvJu9WJEcV5i4u2tnUI6iBpsAp gatbRVa9/S65kBGHTjUItQBjaULsun8w/c9jFHZ/8ipi0V7tHWtTbU4IHu/8erQXka mztDA8ESJVnQE7GWZz7zUADqPoWAULmXJ70u4262NMgpFBdUYGZROj8oTyuPN8eYnE HOVaKl6oBU4GID2vBdJh1Wr3GHv+hNLKOrY4KBK9KoTlNCxw2fMcS9RBsdRFCksW4K 4c4CQ9/mrAs+w== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp4.osuosl.org (Postfix) with ESMTP id 6F68041260; Fri, 21 Feb 2025 16:11:23 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists1.osuosl.org (Postfix) with ESMTP id F062F194 for ; Fri, 21 Feb 2025 09:43:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id B477C83AF2 for ; Fri, 21 Feb 2025 09:43:09 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 8YdemcwkGVEa for ; Fri, 21 Feb 2025 09:43:08 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::102e; helo=mail-pj1-x102e.google.com; envelope-from=0x1207@gmail.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org 68CF583B5A DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 68CF583B5A Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by smtp1.osuosl.org (Postfix) with ESMTPS id 68CF583B5A for ; Fri, 21 Feb 2025 09:43:08 +0000 (UTC) Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-2fbf77b2b64so3853419a91.2 for ; Fri, 21 Feb 2025 01:43:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740130987; x=1740735787; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Qp8DvYGUWgTHXAP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:2e0d:b0:2fa:2124:8782 with SMTP id 98e67ed59e1d1-2fce7b1f6afmr4454759a91.25.1740130987274; Fri, 21 Feb 2025 01:43:07 -0800 (PST) Received: from localhost ([129.146.253.192]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fcb844c60asm3042021a91.0.2025.02.21.01.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2025 01:43:07 -0800 (PST) Date: Fri, 21 Feb 2025 17:42:49 +0800 From: Furong Xu <0x1207@gmail.com> To: Faizal Rahim Cc: Tony Nguyen , Przemek Kitszel , Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Alexandre Torgue , Simon Horman , Russell King , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Russell King , Vladimir Oltean , Serge Semin , Xiaolei Wang , Suraj Jaiswal , Kory Maincent , Gal Pressman , Jesper Nilsson , Andrew Halaney , Choong Yong Liang , Kunihiko Hayashi , Vinicius Costa Gomes , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, bpf@vger.kernel.org Message-ID: <20250221174249.000000cc@gmail.com> In-Reply-To: <20250220025349.3007793-2-faizal.abdul.rahim@linux.intel.com> References: <20250220025349.3007793-1-faizal.abdul.rahim@linux.intel.com> <20250220025349.3007793-2-faizal.abdul.rahim@linux.intel.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Fri, 21 Feb 2025 16:11:22 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740130987; x=1740735787; darn=lists.osuosl.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=Qp8DvYGUWgTHXAPWqbMBZV8Rl/qxPnTYUxFzmDOOo1U=; b=jo7Kau9+RkC6DPeI2+r5yv2ohWMTI2GD4CaC1WldQ3ETcg8Y8Sdp3LfQVSr/OSGExd 6GMiFJLm7I/mg9SweGrqV5Xpm46cxTGYe3D8wGjplgQHDydmDpNrVEF+vQb4i19PUqF/ JpnwH/o+dRNmFCxAQR1R7EPt6mddK0AFk1e7R4wLvR/EPhtaeg98voM+Fafkb0AGfWoO 2tVQzvYtIbTHgTjecYpE0A47FpgFju7GJglNgzsLCXcgZk1v9wjIr24noYPfDTMQdjbw HBh+q8fqYAVj+D76pli2UZ4e6GZRciw8C9mRkd2nq7TNTePlrUathbWaiSCS4uOWHM1z WdZQ== X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=gmail.com X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=jo7Kau9+ Subject: Re: [Intel-wired-lan] [PATCH iwl-next v5 1/9] net: ethtool: mm: extract stmmac verification logic into common library X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" On Wed, 19 Feb 2025 21:53:41 -0500, Faizal Rahim wrote: > From: Vladimir Oltean > > It appears that stmmac is not the only hardware which requires a > software-driven verification state machine for the MAC Merge layer. > > While on the one hand it's good to encourage hardware implementations, > on the other hand it's quite difficult to tolerate multiple drivers > implementing independently fairly non-trivial logic. > > Extract the hardware-independent logic from stmmac into library code and > put it in ethtool. Name the state structure "mmsv" for MAC Merge > Software Verification. Let this expose an operations structure for > executing the hardware stuff: sync hardware with the tx_active boolean > (result of verification process), enable/disable the pMAC, send mPackets, > notify library of external events (reception of mPackets), as well as > link state changes. > > Note that it is assumed that the external events are received in hardirq > context. If they are not, it is probably a good idea to disable hardirqs > when calling ethtool_mmsv_event_handle(), because the library does not > do so. > > Also, the MM software verification process has no business with the > tx_min_frag_size, that is all the driver's to handle. > > Signed-off-by: Vladimir Oltean > Co-developed-by: Choong Yong Liang > Signed-off-by: Choong Yong Liang > Co-developed-by: Faizal Rahim > Signed-off-by: Faizal Rahim > Tested-by: Choong Yong Liang > --- > drivers/net/ethernet/stmicro/stmmac/stmmac.h | 16 +- > .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 41 +--- > .../net/ethernet/stmicro/stmmac/stmmac_fpe.c | 174 +++----------- > .../net/ethernet/stmicro/stmmac/stmmac_fpe.h | 5 - > .../net/ethernet/stmicro/stmmac/stmmac_main.c | 8 +- > include/linux/ethtool.h | 131 ++++++++++ > net/ethtool/mm.c | 225 +++++++++++++++++- > 7 files changed, 399 insertions(+), 201 deletions(-) > [...] > +void ethtool_mmsv_link_state_handle(struct ethtool_mmsv *mmsv, bool up) > +{ > + unsigned long flags; > + > + ethtool_mmsv_stop(mmsv); > + > + spin_lock_irqsave(&mmsv->lock, flags); > + > + if (up && mmsv->pmac_enabled) { > + /* VERIFY process requires pMAC enabled when NIC comes up */ > + ethtool_mmsv_configure_pmac(mmsv, true); > + > + /* New link => maybe new partner => new verification process */ > + ethtool_mmsv_apply(mmsv); > + } else { > + mmsv->status = ETHTOOL_MM_VERIFY_STATUS_INITIAL; Tested this patch on my side, everything works well, but the verify-status is a little weird: # kernel booted, check initial states: ethtool --include-statistics --json --show-mm eth1 [ { "ifname": "eth1", "pmac-enabled": false, "tx-enabled": false, "tx-active": false, "tx-min-frag-size": 60, "rx-min-frag-size": 60, "verify-enabled": false, "verify-time": 128, "max-verify-time": 128, "verify-status": "INITIAL", "statistics": { "MACMergeFrameAssErrorCount": 0, "MACMergeFrameSmdErrorCount": 0, "MACMergeFrameAssOkCount": 0, "MACMergeFragCountRx": 0, "MACMergeFragCountTx": 0, "MACMergeHoldCount": 0 } } ] # Enable pMAC by: ethtool --set-mm eth1 pmac-enabled on ethtool --include-statistics --json --show-mm eth1 [ { "ifname": "eth1", "pmac-enabled": true, "tx-enabled": false, "tx-active": false, "tx-min-frag-size": 60, "rx-min-frag-size": 60, "verify-enabled": false, "verify-time": 128, "max-verify-time": 128, "verify-status": "DISABLED", "statistics": { "MACMergeFrameAssErrorCount": 0, "MACMergeFrameSmdErrorCount": 0, "MACMergeFrameAssOkCount": 0, "MACMergeFragCountRx": 0, "MACMergeFragCountTx": 0, "MACMergeHoldCount": 0 } } ] # Disable pMAC by: ethtool --set-mm eth1 pmac-enabled off ethtool --include-statistics --json --show-mm eth1 [ { "ifname": "eth1", "pmac-enabled": true, "tx-enabled": false, "tx-active": false, "tx-min-frag-size": 60, "rx-min-frag-size": 60, "verify-enabled": false, "verify-time": 128, "max-verify-time": 128, "verify-status": "DISABLED", "statistics": { "MACMergeFrameAssErrorCount": 0, "MACMergeFrameSmdErrorCount": 0, "MACMergeFrameAssOkCount": 0, "MACMergeFragCountRx": 0, "MACMergeFragCountTx": 0, "MACMergeHoldCount": 0 } } ] verify-status always normal on other cases. @Vladimir, maybe we shouldn't update mmsv->status in ethtool_mmsv_link_state_handle()? Or, update mmsv->status like below: mmsv->status = mmsv->pmac_enabled ? ETHTOOL_MM_VERIFY_STATUS_INITIAL : ETHTOOL_MM_VERIFY_STATUS_DISABLED; Anyway, this is too minor, so: Tested-by: Furong Xu <0x1207@gmail.com> > + mmsv->verify_retries = ETHTOOL_MM_MAX_VERIFY_RETRIES; > + > + /* No link or pMAC not enabled */ > + ethtool_mmsv_configure_pmac(mmsv, false); > + ethtool_mmsv_configure_tx(mmsv, false); > + } > + > + spin_unlock_irqrestore(&mmsv->lock, flags); > +} > +EXPORT_SYMBOL_GPL(ethtool_mmsv_link_state_handle);