netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: DENG Qingfang <dqfext@gmail.com>
To: "René van Dorst" <opensource@vdorst.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Landen Chao <Landen.Chao@mediatek.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	Sean Wang <sean.wang@mediatek.com>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Vladimir Oltean <olteanv@gmail.com>,
	"moderated list:ARM/Mediatek SoC support" 
	<linux-mediatek@lists.infradead.org>,
	netdev <netdev@vger.kernel.org>,
	Sergio Paracuellos <sergio.paracuellos@gmail.com>,
	Frank Wunderlich <frank-w@public-files.de>
Subject: Re: [PATCH net-next] net: dsa: mt7530: Add support for EEE features
Date: Sat, 10 Apr 2021 13:25:31 +0800	[thread overview]
Message-ID: <CALW65jZRs4DBOpWiY+CxWZmX9wXhSP1cM-qeftC=xY2=Tr+HoA@mail.gmail.com> (raw)
In-Reply-To: <20210409225346.432312-1-opensource@vdorst.com>

Hi René,

On Sat, Apr 10, 2021 at 6:54 AM René van Dorst <opensource@vdorst.com> wrote:
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
> @@ -2568,6 +2568,11 @@ static void mt753x_phylink_mac_link_up(struct dsa_switch *ds, int port,
>                         mcr |= PMCR_TX_FC_EN;
>                 if (rx_pause)
>                         mcr |= PMCR_RX_FC_EN;
> +
> +               if (mode == MLO_AN_PHY && phydev &&
> +                   !(priv->eee_disabled & BIT(port)) &&
> +                   phy_init_eee(phydev, 0) >= 0)
> +                       mcr |= PMCR_FORCE_EEE1G | PMCR_FORCE_EEE100;

You should adjust this according to e->advertised.

>         }
>
>         mt7530_set(priv, MT7530_PMCR_P(port), mcr);
> @@ -2800,6 +2805,49 @@ mt753x_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val)
>         return priv->info->phy_write(ds, port, regnum, val);
>  }
>
> +static int mt753x_get_mac_eee(struct dsa_switch *ds, int port,
> +                             struct ethtool_eee *e)
> +{
> +       struct mt7530_priv *priv = ds->priv;
> +       u32 eeecr, pmsr;
> +
> +       e->eee_enabled = !(priv->eee_disabled & BIT(port));
> +
> +       if (e->eee_enabled) {
> +               eeecr = mt7530_read(priv, MT7530_PMEEECR_P(port));
> +               e->tx_lpi_enabled = !(eeecr & LPI_MODE_EN);
> +               e->tx_lpi_timer = GET_LPI_THRESH(eeecr);
> +               pmsr = mt7530_read(priv, MT7530_PMSR_P(port));
> +               e->eee_active = e->eee_enabled && !!(pmsr & PMSR_EEE1G);

eee_enabled and eee_active will be set in phy_ethtool_get_eee, no need
to set them here.

> +       }
> +
> +       return 0;
> +}
> +
> +static int mt753x_set_mac_eee(struct dsa_switch *ds, int port,
> +                             struct ethtool_eee *e)
> +{
> +       struct mt7530_priv *priv = ds->priv;
> +       u32 eeecr;
> +
> +       if (e->eee_enabled) {
> +               if (e->tx_lpi_timer > 0xFFF)
> +                       return -EINVAL;
> +               priv->eee_disabled &= ~BIT(port);
> +               eeecr = mt7530_read(priv, MT7530_PMEEECR_P(port));
> +               eeecr &= ~(LPI_THRESH_MASK | LPI_MODE_EN);
> +               if (!e->tx_lpi_enabled)
> +                       /* Force LPI Mode without a delay */
> +                       eeecr |= LPI_MODE_EN;
> +               eeecr |= SET_LPI_THRESH(e->tx_lpi_timer);
> +               mt7530_write(priv, MT7530_PMEEECR_P(port), eeecr);
> +       } else {
> +               priv->eee_disabled |= BIT(port);
> +       }
> +
> +       return 0;
> +}

  reply	other threads:[~2021-04-10  5:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-09 22:53 [PATCH net-next] net: dsa: mt7530: Add support for EEE features René van Dorst
2021-04-10  5:25 ` DENG Qingfang [this message]
2021-04-12  6:57   ` René van Dorst

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='CALW65jZRs4DBOpWiY+CxWZmX9wXhSP1cM-qeftC=xY2=Tr+HoA@mail.gmail.com' \
    --to=dqfext@gmail.com \
    --cc=Landen.Chao@mediatek.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=frank-w@public-files.de \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=matthias.bgg@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=opensource@vdorst.com \
    --cc=sean.wang@mediatek.com \
    --cc=sergio.paracuellos@gmail.com \
    --cc=vivien.didelot@gmail.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;
as well as URLs for NNTP newsgroup(s).