public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Furong Xu <0x1207@gmail.com>
Cc: Serge Semin <fancer.lancer@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Jose Abreu <joabreu@synopsys.com>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Joao Pinto <jpinto@synopsys.com>,
	netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, rmk+kernel@armlinux.org.uk,
	linux@armlinux.org.uk, xfr@outlook.com,
	Vladimir Oltean <vladimir.oltean@nxp.com>
Subject: Re: [PATCH net-next v9 3/7] net: stmmac: refactor FPE verification process
Date: Fri, 6 Sep 2024 15:52:58 +0300	[thread overview]
Message-ID: <20240906125258.d7rhhcjdic3quqg2@skbuf> (raw)
In-Reply-To: <13f5833e52a47895864db726f090f323ec691c62.1725597121.git.0x1207@gmail.com>

On Fri, Sep 06, 2024 at 12:55:58PM +0800, Furong Xu wrote:
> @@ -5979,44 +5956,29 @@ static int stmmac_set_features(struct net_device *netdev,
>  static void stmmac_fpe_event_status(struct stmmac_priv *priv, int status)
>  {
>  	struct stmmac_fpe_cfg *fpe_cfg = &priv->fpe_cfg;
> -	enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state;
> -	enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state;
> -	bool *hs_enable = &fpe_cfg->hs_enable;
>  
> -	if (status == FPE_EVENT_UNKNOWN || !*hs_enable)
> -		return;
> +	/* This is interrupt context, just spin_lock() */
> +	spin_lock(&fpe_cfg->lock);
>  
> -	/* If LP has sent verify mPacket, LP is FPE capable */
> -	if ((status & FPE_EVENT_RVER) == FPE_EVENT_RVER) {
> -		if (*lp_state < FPE_STATE_CAPABLE)
> -			*lp_state = FPE_STATE_CAPABLE;
> +	if (!fpe_cfg->pmac_enabled || status == FPE_EVENT_UNKNOWN)
> +		goto unlock_out;
>  
> -		/* If user has requested FPE enable, quickly response */
> -		if (*hs_enable)
> -			stmmac_fpe_send_mpacket(priv, priv->ioaddr,
> -						fpe_cfg,
> -						MPACKET_RESPONSE);
> -	}
> +	/* LP has sent verify mPacket */
> +	if ((status & FPE_EVENT_RVER) == FPE_EVENT_RVER)
> +		stmmac_fpe_send_mpacket(priv, priv->ioaddr, fpe_cfg,
> +					MPACKET_RESPONSE);
>  
> -	/* If Local has sent verify mPacket, Local is FPE capable */
> -	if ((status & FPE_EVENT_TVER) == FPE_EVENT_TVER) {
> -		if (*lo_state < FPE_STATE_CAPABLE)
> -			*lo_state = FPE_STATE_CAPABLE;
> -	}
> +	/* Local has sent verify mPacket */
> +	if ((status & FPE_EVENT_TVER) == FPE_EVENT_TVER &&
> +	    fpe_cfg->status != ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED)
> +		fpe_cfg->status = ETHTOOL_MM_VERIFY_STATUS_VERIFYING;
>  
> -	/* If LP has sent response mPacket, LP is entering FPE ON */
> +	/* LP has sent response mPacket */
>  	if ((status & FPE_EVENT_RRSP) == FPE_EVENT_RRSP)
> -		*lp_state = FPE_STATE_ENTERING_ON;
> +		fpe_cfg->status = ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED;

Nitpick, doesn't affect normal behavior.
If the link partner crafts an unsolicited Response mPacket, and we have
verify_enabled = false, what we should do is we should ignore it.
But what the code does is to transition the state to SUCCEEDED, as if
verify_enabled was true.

We should ignore FPE_EVENT_RRSP events if we are in the
ETHTOOL_MM_VERIFY_STATUS_DISABLED state.

Depending on how the maintainers feel, this could also be handled in a
subsequent patch.

>  
> -	/* If Local has sent response mPacket, Local is entering FPE ON */
> -	if ((status & FPE_EVENT_TRSP) == FPE_EVENT_TRSP)
> -		*lo_state = FPE_STATE_ENTERING_ON;
> -
> -	if (!test_bit(__FPE_REMOVING, &priv->fpe_task_state) &&
> -	    !test_and_set_bit(__FPE_TASK_SCHED, &priv->fpe_task_state) &&
> -	    priv->fpe_wq) {
> -		queue_work(priv->fpe_wq, &priv->fpe_task);
> -	}
> +unlock_out:
> +	spin_unlock(&fpe_cfg->lock);
>  }
>  
>  static void stmmac_common_interrupt(struct stmmac_priv *priv)

  parent reply	other threads:[~2024-09-06 12:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-06  4:55 [PATCH net-next v9 0/7] net: stmmac: FPE via ethtool + tc Furong Xu
2024-09-06  4:55 ` [PATCH net-next v9 1/7] net: stmmac: move stmmac_fpe_cfg to stmmac_priv data Furong Xu
2024-09-06  4:55 ` [PATCH net-next v9 2/7] net: stmmac: drop stmmac_fpe_handshake Furong Xu
2024-09-06  4:55 ` [PATCH net-next v9 3/7] net: stmmac: refactor FPE verification process Furong Xu
2024-09-06 12:41   ` Vladimir Oltean
2024-09-06 12:49     ` Vladimir Oltean
2024-09-06 12:52   ` Vladimir Oltean [this message]
2024-09-06  4:55 ` [PATCH net-next v9 4/7] net: stmmac: configure FPE via ethtool-mm Furong Xu
2024-09-06 12:44   ` Vladimir Oltean
2024-09-06  4:56 ` [PATCH net-next v9 5/7] net: stmmac: support fp parameter of tc-mqprio Furong Xu
2024-09-06  4:56 ` [PATCH net-next v9 6/7] net: stmmac: support fp parameter of tc-taprio Furong Xu
2024-09-06  4:56 ` [PATCH net-next v9 7/7] net: stmmac: silence FPE kernel logs Furong Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240906125258.d7rhhcjdic3quqg2@skbuf \
    --to=olteanv@gmail.com \
    --cc=0x1207@gmail.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fancer.lancer@gmail.com \
    --cc=joabreu@synopsys.com \
    --cc=jpinto@synopsys.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux@armlinux.org.uk \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=vladimir.oltean@nxp.com \
    --cc=xfr@outlook.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox