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: Alexander Lobakin <aleksander.lobakin@intel.com>,
	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 v7 3/7] net: stmmac: refactor FPE verification process
Date: Wed, 4 Sep 2024 17:04:48 +0300	[thread overview]
Message-ID: <20240904140448.6hvjzj3ei2k7jdbe@skbuf> (raw)
In-Reply-To: <1e452525e496b28c0b1ea43afbdc3533c92930c6.1725441317.git.0x1207@gmail.com>

On Wed, Sep 04, 2024 at 05:21:18PM +0800, Furong Xu wrote:
> +/**
> + * stmmac_fpe_verify_timer - Timer for MAC Merge verification
> + * @t:  timer_list struct containing private info
> + *
> + * Verify the MAC Merge capability in the local TX direction, by
> + * transmitting Verify mPackets up to 3 times. Wait until link
> + * partner responds with a Response mPacket, otherwise fail.
> + */
> +static void stmmac_fpe_verify_timer(struct timer_list *t)
>  {
> -	struct stmmac_priv *priv = container_of(work, struct stmmac_priv,
> -						fpe_task);
> -	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;
> -	bool *enable = &fpe_cfg->enable;
> -	int retries = 20;
> -
> -	while (retries-- > 0) {
> -		/* Bail out immediately if FPE handshake is OFF */
> -		if (*lo_state == FPE_STATE_OFF || !*hs_enable)
> -			break;
> -
> -		if (*lo_state == FPE_STATE_ENTERING_ON &&
> -		    *lp_state == FPE_STATE_ENTERING_ON) {
> -			stmmac_fpe_configure(priv, priv->ioaddr,
> -					     fpe_cfg,
> -					     priv->plat->tx_queues_to_use,
> -					     priv->plat->rx_queues_to_use,
> -					     *enable);
> -
> -			netdev_info(priv->dev, "configured FPE\n");
> +	struct stmmac_fpe_cfg *fpe_cfg = from_timer(fpe_cfg, t, verify_timer);
> +	struct stmmac_priv *priv = container_of(fpe_cfg, struct stmmac_priv,
> +						fpe_cfg);
> +	struct ethtool_mm_state *state = &fpe_cfg->state;
> +	unsigned long flags;
> +	bool rearm = false;
>  
> -			*lo_state = FPE_STATE_ON;
> -			*lp_state = FPE_STATE_ON;
> -			netdev_info(priv->dev, "!!! BOTH FPE stations ON\n");
> -			break;
> -		}
> +	spin_lock_irqsave(&fpe_cfg->lock, flags);
>  
> -		if ((*lo_state == FPE_STATE_CAPABLE ||
> -		     *lo_state == FPE_STATE_ENTERING_ON) &&
> -		     *lp_state != FPE_STATE_ON) {
> -			netdev_info(priv->dev, SEND_VERIFY_MPAKCET_FMT,
> -				    *lo_state, *lp_state);
> +	switch (state->verify_status) {
> +	case ETHTOOL_MM_VERIFY_STATUS_INITIAL:
> +	case ETHTOOL_MM_VERIFY_STATUS_VERIFYING:
> +		if (fpe_cfg->verify_retries != 0) {
>  			stmmac_fpe_send_mpacket(priv, priv->ioaddr,
> -						fpe_cfg,
> -						MPACKET_VERIFY);
> +						fpe_cfg, MPACKET_VERIFY);
> +			rearm = true;
> +		} else {
> +			state->verify_status = ETHTOOL_MM_VERIFY_STATUS_FAILED;
>  		}
> -		/* Sleep then retry */
> -		msleep(500);
> +
> +		fpe_cfg->verify_retries--;
> +	break;

Odd indentation... "break;" should be on the same level with the code,
not with the "case" statements. Not sure which editor you use, but even
if you hit "==" in vim on this line, it will shift it by one tab to the
right.

> +
> +	case ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED:
> +		stmmac_fpe_configure(priv, priv->ioaddr, fpe_cfg,
> +				     priv->plat->tx_queues_to_use,
> +				     priv->plat->rx_queues_to_use,
> +				     true, true);
> +	break;

Same comment here and below.

> +
> +	default:
> +	break;
> +	}
> +
> +	if (rearm) {
> +		mod_timer(&fpe_cfg->verify_timer,
> +			  jiffies + msecs_to_jiffies(state->verify_time));
>  	}
>  
> -	clear_bit(__FPE_TASK_SCHED, &priv->fpe_task_state);
> +	spin_unlock_irqrestore(&fpe_cfg->lock, flags);
> +}

  parent reply	other threads:[~2024-09-04 14:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-04  9:21 [PATCH net-next v7 0/7] net: stmmac: FPE via ethtool + tc Furong Xu
2024-09-04  9:21 ` [PATCH net-next v7 1/7] net: stmmac: move stmmac_fpe_cfg to stmmac_priv data Furong Xu
2024-09-04  9:21 ` [PATCH net-next v7 2/7] net: stmmac: drop stmmac_fpe_handshake Furong Xu
2024-09-04  9:21 ` [PATCH net-next v7 3/7] net: stmmac: refactor FPE verification process Furong Xu
2024-09-04 13:02   ` Vladimir Oltean
2024-09-04 14:04   ` Vladimir Oltean [this message]
2024-09-04 14:58   ` Vladimir Oltean
2024-09-04  9:21 ` [PATCH net-next v7 4/7] net: stmmac: configure FPE via ethtool-mm Furong Xu
2024-09-04  9:21 ` [PATCH net-next v7 5/7] net: stmmac: support fp parameter of tc-mqprio Furong Xu
2024-09-04 15:42   ` Vladimir Oltean
2024-09-04  9:21 ` [PATCH net-next v7 6/7] net: stmmac: support fp parameter of tc-taprio Furong Xu
2024-09-04 15:55   ` Vladimir Oltean
2024-09-04  9:21 ` [PATCH net-next v7 7/7] net: stmmac: silence FPE kernel logs Furong Xu
2024-09-04 16:00   ` Vladimir Oltean

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=20240904140448.6hvjzj3ei2k7jdbe@skbuf \
    --to=olteanv@gmail.com \
    --cc=0x1207@gmail.com \
    --cc=aleksander.lobakin@intel.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