RE: [PATCH net-next v20 06/13] rtase: Implement .ndo_start_xmit function

From: Justin Lai
Date: Wed Jun 12 2024 - 00:21:33 EST


> On 2024-06-07 at 14:13:14, Justin Lai (justinlai0215@xxxxxxxxxxx) wrote:
> > Implement .ndo_start_xmit function to fill the information of the
> > packet to be transmitted into the tx descriptor, and then the hardware
> > will transmit the packet using the information in the tx descriptor.
> > In addition, we also implemented the tx_handler function to enable the
> > tx descriptor to be reused.
> >
> > Signed-off-by: Justin Lai <justinlai0215@xxxxxxxxxxx>
> > ---
> > .../net/ethernet/realtek/rtase/rtase_main.c | 285 ++++++++++++++++++
> > 1 file changed, 285 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > index 23406c195cff..6bdb4edbfbc1 100644
> > --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > @@ -256,6 +256,68 @@ static void rtase_mark_to_asic(union rtase_rx_desc
> *desc, u32 rx_buf_sz)
> > cpu_to_le32(RTASE_DESC_OWN | eor | rx_buf_sz)); }
> >
> > +static u32 rtase_tx_avail(struct rtase_ring *ring) {
> > + return READ_ONCE(ring->dirty_idx) + RTASE_NUM_DESC -
> > + READ_ONCE(ring->cur_idx); }
> dirty_idx and cur_idx wont wrap ? its 32bit in size.
>
> >
cur_idx and dirty_idx may wrap, but all we want is the difference between
them, so this won't have any effect. In addition, the difference between
the two will not exceed RTASE_NUM_DESC, and dirty_idx will not exceed
cur_idx, so the calculation won't go wrong.