[PATCH v2 01/10] net: tsec: add support for promiscuous mode

Ramon Fried rfried.dev at gmail.com
Sat Oct 30 09:45:38 CEST 2021


On Thu, Oct 28, 2021 at 9:45 PM Ramon Fried <rfried.dev at gmail.com> wrote:
>
> On Sat, Oct 16, 2021 at 9:30 PM Ramon Fried <rfried.dev at gmail.com> wrote:
> >
> > On Wed, Sep 29, 2021 at 6:05 PM Vladimir Oltean <vladimir.oltean at nxp.com> wrote:
> > >
> > > The Freescale TSEC can be a DSA master, and the ports of the attached
> > > DSA switch can have different MAC addresses compared to the TSEC.
> > > Nonetheless, the TSEC must receive the packets on behalf of those switch
> > > ports. Therefore, implement the promiscuous mode method to allow DSA to
> > > set this.
> > >
> > > Note that the init_registers() function called from eth_ops :: start
> > > overwrites this setting. There is no reason why the RCTRL register
> > > should be zero-initialized, so just stop clearing it so that the setting
> > > we applied in eth_ops :: set_promisc sticks.
> > >
> > > Signed-off-by: Vladimir Oltean <vladimir.oltean at nxp.com>
> > > Reviewed-by: Ramon Fried <rfried.dev at gmail.com>
> > > Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
> > > ---
> > > v1->v2: none
> > >
> > >  drivers/net/tsec.c | 20 ++++++++++++++++----
> > >  include/tsec.h     |  2 ++
> > >  2 files changed, 18 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
> > > index 0ce97656715f..4354753cab9c 100644
> > > --- a/drivers/net/tsec.c
> > > +++ b/drivers/net/tsec.c
> > > @@ -156,6 +156,19 @@ static int tsec_mcast_addr(struct udevice *dev, const u8 *mcast_mac, int join)
> > >         return 0;
> > >  }
> > >
> > > +static int tsec_set_promisc(struct udevice *dev, bool enable)
> > > +{
> > > +       struct tsec_private *priv = dev_get_priv(dev);
> > > +       struct tsec __iomem *regs = priv->regs;
> > > +
> > > +       if (enable)
> > > +               setbits_be32(&regs->rctrl, RCTRL_PROM);
> > > +       else
> > > +               clrbits_be32(&regs->rctrl, RCTRL_PROM);
> > > +
> > > +       return 0;
> > > +}
> > > +
> > >  /*
> > >   * Initialized required registers to appropriate values, zeroing
> > >   * those we don't care about (unless zero is bad, in which case,
> > > @@ -186,8 +199,6 @@ static void init_registers(struct tsec __iomem *regs)
> > >         out_be32(&regs->hash.gaddr6, 0);
> > >         out_be32(&regs->hash.gaddr7, 0);
> > >
> > > -       out_be32(&regs->rctrl, 0x00000000);
> > > -
> > >         /* Init RMON mib registers */
> > >         memset((void *)&regs->rmon, 0, sizeof(regs->rmon));
> > >
> > > @@ -454,7 +465,7 @@ void redundant_init(struct tsec_private *priv)
> > >                 0x71, 0x72};
> > >
> > >         /* Enable promiscuous mode */
> > > -       setbits_be32(&regs->rctrl, 0x8);
> > > +       setbits_be32(&regs->rctrl, RCTRL_PROM);
> > >         /* Enable loopback mode */
> > >         setbits_be32(&regs->maccfg1, MACCFG1_LOOPBACK);
> > >         /* Enable transmit and receive */
> > > @@ -506,7 +517,7 @@ void redundant_init(struct tsec_private *priv)
> > >         if (fail)
> > >                 panic("eTSEC init fail!\n");
> > >         /* Disable promiscuous mode */
> > > -       clrbits_be32(&regs->rctrl, 0x8);
> > > +       clrbits_be32(&regs->rctrl, RCTRL_PROM);
> > >         /* Disable loopback mode */
> > >         clrbits_be32(&regs->maccfg1, MACCFG1_LOOPBACK);
> > >  }
> > > @@ -932,6 +943,7 @@ static const struct eth_ops tsec_ops = {
> > >         .free_pkt = tsec_free_pkt,
> > >         .stop = tsec_halt,
> > >         .mcast = tsec_mcast_addr,
> > > +       .set_promisc = tsec_set_promisc,
> > >  };
> > >
> > >  static struct tsec_data etsec2_data = {
> > > diff --git a/include/tsec.h b/include/tsec.h
> > > index 5433cfd96610..044ee35a91bd 100644
> > > --- a/include/tsec.h
> > > +++ b/include/tsec.h
> > > @@ -122,6 +122,8 @@
> > >  #define ECNTRL_REDUCED_MII_MODE        0x00000004
> > >  #define ECNTRL_SGMII_MODE      0x00000002
> > >
> > > +#define RCTRL_PROM             0x00000008
> > > +
> > >  #ifndef CONFIG_SYS_TBIPA_VALUE
> > >  # define CONFIG_SYS_TBIPA_VALUE        0x1f
> > >  #endif
> > > --
> > > 2.25.1
> > >
> > Reviewed-by: Ramon Fried <rfried.dev at gmail.com>
> Series applied to u-boot-net/next
> Thanks,
> Ramon.

CI Build for 32bit ARM targets failed for this patch:
drivers/net/tsec.c:159:12: error: 'tsec_set_promisc' defined but not
used [-Werror=unused-function]
159 | static int tsec_set_promisc(struct udevice *dev, bool enable)
| ^~~~~~~~~~~~~~~~


More information about the U-Boot mailing list