Re: [PATCH net-next v4 5/9] net: dsa: microchip: add support for different DCB app configurations
From: Oleksij Rempel
Date: Tue Apr 09 2024 - 00:32:17 EST
Hi Arun,
On Mon, Apr 08, 2024 at 04:10:15PM +0000, Arun.Ramadoss@xxxxxxxxxxxxx wrote:
> > +int ksz_port_get_default_prio(struct dsa_switch *ds, int port)
> > +{
> > + struct ksz_device *dev = ds->priv;
> > + int ret, reg, shift;
> > + u8 data, mask;
> > +
> > + ksz_get_defult_port_prio_reg(dev, ®, &mask, &shift);
> > +
> > + ret = ksz_pread8(dev, port, reg, &data);
> > + if (ret)
> > + return ret;
> > +
> > + return (data & mask) >> shift;
>
> I assume we can use retrun FIELD_GET(mask, data), since mask is GENMASK
> format.
>
> >
> > +int ksz_port_set_default_prio(struct dsa_switch *ds, int port, u8
> > prio)
> > prio)
> > +{
> > + struct ksz_device *dev = ds->priv;
> > + int reg, shift;
> > + u8 mask;
> > +
> > + if (prio >= dev->info->num_tx_queues)
> > + return -EINVAL;
> > +
> > + ksz_get_defult_port_prio_reg(dev, ®, &mask, &shift);
> > +
> > + return ksz_prmw8(dev, port, reg, mask, (prio << shift) &
> > mask);
>
> FIELD_PREP(mask, prio)
Sadly, FIELD_GET() and FIELD_PREP() do not work with dynamic masks.
Regards,
Oleksij
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |