RE: [PATCH v2 net-next 4/5] net: fec: add change_mtu to support dynamic buffer allocation

From: Wei Fang
Date: Sun Aug 24 2025 - 22:14:02 EST


> > > +static int fec_change_mtu(struct net_device *ndev, int new_mtu) {
> > > + struct fec_enet_private *fep = netdev_priv(ndev);
> > > + int order, done;
> > > + bool running;
> > > +
> > > + order = get_order(new_mtu + ETH_HLEN + ETH_FCS_LEN);
> > > + if (fep->pagepool_order == order) {
> > > + WRITE_ONCE(ndev->mtu, new_mtu);
> > > + return 0;
> > > + }
> > > +
> > > + fep->pagepool_order = order;
> > > + fep->rx_frame_size = (PAGE_SIZE << order) -
> > FEC_ENET_XDP_HEADROOM
> > > + - SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
> > > +
> >
> > I think we need to add a check for rx_frame_size, as FEC_R_CNTRL[MAX_FL]
> and
> > FEC_FTRL[TRUNC_FL] only have 14 bits.
>
> That would be redundant, since rx_frame_size cannot exceed max_buf_size
> which value
> would either be PKT_MAXBUF_SIZE or MAX_JUMBO_BUF_SIZE.
>

Looked at the entire patch set, the rx_frame_size is set to FEC_FTRL[TRUNC_FL]
and FEC_R_CNTRL[MAX_FL], and both TRUNC_FL and MAX_FL are 14 bits, if the
value set exceeds the hardware capability, the driver should return an error.

For example, the order is 3, so rx_frame_size is 0x7dc0, but MAX_FL will be set
to 0x3dc0, that is not correct.