Re: [PATCH net-next v1] net: stmmac: Refactor Frame Preemption(FPE) implementation

From: Furong Xu
Date: Mon Jul 08 2024 - 22:14:29 EST


On Mon, 8 Jul 2024 20:44:31 +0200
Andrew Lunn <andrew@xxxxxxx> wrote:

> > +static void fpe_configure(struct stmmac_priv *priv, struct stmmac_fpe_cfg *cfg,
> > + u32 num_txq, u32 num_rxq, bool enable)
> > +{
> > + u32 value;
> > +
> > + if (enable) {
> > + cfg->fpe_csr = FPE_CTRL_STS_EFPE;
> > + if (priv->plat->has_xgmac) {
> > + value = readl(priv->ioaddr + XGMAC_RXQ_CTRL1);
> > + value &= ~XGMAC_FPRQ;
> > + value |= (num_rxq - 1) << XGMAC_FPRQ_SHIFT;
> > + writel(value, priv->ioaddr + XGMAC_RXQ_CTRL1);
> > + } else if (priv->plat->has_gmac4) {
> > + value = readl(priv->ioaddr + GMAC_RXQ_CTRL1);
> > + value &= ~GMAC_RXQCTRL_FPRQ;
> > + value |= (num_rxq - 1) << GMAC_RXQCTRL_FPRQ_SHIFT;
> > + writel(value, priv->ioaddr + GMAC_RXQ_CTRL1);
> > + }
>
> Since you are using a structure of function pointers, it would seem
> more logical to have a fpe_xgmac_configure() and a
> fpe_gmac4_configure(), and then xgmac_fpe_ops and gmac4_fpe_ops.
>
> > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > @@ -974,8 +974,7 @@ static void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up)
> > bool *hs_enable = &fpe_cfg->hs_enable;
> >
> > if (is_up && *hs_enable) {
> > - stmmac_fpe_send_mpacket(priv, priv->ioaddr, fpe_cfg,
> > - MPACKET_VERIFY);
> > + stmmac_fpe_send_mpacket(priv, priv, fpe_cfg, MPACKET_VERIFY);
>
> passing priv twice looks very odd! It makes me think the API is
> designed wrong. This could be because of the refactoring changes you
> made? Maybe add another patch cleaning this up?

Hi Andrew

Thanks for your comments.
This patch is almost a clone of "net: stmmac: Refactor EST implementation"
https://github.com/torvalds/linux/commit/c3f3b97238f6fd87b9d90b9a995ee5e69f751a74
Many decisions were made based on that patch.

I will submit a new patchset with splited patches and make function callbacks more logical.