RE: [PATCH net 2/3] net: fec: recycle pages for transmitted XDP frames

From: Wei Fang
Date: Tue Jul 04 2023 - 21:56:25 EST



> -----Original Message-----
> From: Andrew Lunn <andrew@xxxxxxx>
> Sent: 2023年7月5日 7:48
> To: Wei Fang <wei.fang@xxxxxxx>
> Cc: davem@xxxxxxxxxxxxx; edumazet@xxxxxxxxxx; kuba@xxxxxxxxxx;
> pabeni@xxxxxxxxxx; ast@xxxxxxxxxx; daniel@xxxxxxxxxxxxx;
> hawk@xxxxxxxxxx; john.fastabend@xxxxxxxxx; Shenwei Wang
> <shenwei.wang@xxxxxxx>; Clark Wang <xiaoning.wang@xxxxxxx>;
> netdev@xxxxxxxxxxxxxxx; dl-linux-imx <linux-imx@xxxxxxx>;
> linux-kernel@xxxxxxxxxxxxxxx; bpf@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH net 2/3] net: fec: recycle pages for transmitted XDP frames
>
> > /* Save skb pointer */
> > - txq->tx_skbuff[index] = skb;
> > + txq->tx_buf[index].skb = skb;
>
> What about txq->tx_buf[index].type ?
>
we restore the buffer type to FEC_TXBUF_T_SKB when recycling the buffer descriptor,
so there is no need to set it again here.

> > @@ -862,7 +860,7 @@ static int fec_enet_txq_submit_tso(struct
> fec_enet_priv_tx_q *txq,
> > }
> >
> > /* Save skb pointer */
> > - txq->tx_skbuff[index] = skb;
> > + txq->tx_buf[index].skb = skb;
>
> here as well.
>
> > + /* restore default tx buffer type: FEC_TXBUF_T_SKB */
> > + txq->tx_buf[i].type = FEC_TXBUF_T_SKB;
>
> Seems error prone. It would be safer to explicitly set it next to
> assigning .skb/.xdp.
I also considered this method, but in the case when skb has frags or TSO,
we only need to set skb pointer for the first txq->tx_buf, but we need to
explicitly set the type for all txq->tx_buf corresponding to the skb. This may
confuse others.
As for your concern about being error-prone. I don't think it should be, I
reset the type to FEC_TXBUF_T_SKB in all places where buffers are recycled
or cleared.

>
> Andrew