Message ID | 20210722141351.13668-11-biju.das.jz@bp.renesas.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Geert Uytterhoeven |
Headers | show |
Series | Add Gigabit Ethernet driver support | expand |
On 7/22/21 5:13 PM, Biju Das wrote: > The ravb_ring_format function uses extended descriptor in rx for > R-Car where as it use normal descriptor for RZ/G2L. Factorise > rx ring buffer buildup to extend the support for later SoC. > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> > Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > --- > drivers/net/ethernet/renesas/ravb.h | 1 + > drivers/net/ethernet/renesas/ravb_main.c | 34 +++++++++++++++--------- > 2 files changed, 23 insertions(+), 12 deletions(-) > > diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h > index 3a9cf6e8671a..a3258c5d0c3d 100644 > --- a/drivers/net/ethernet/renesas/ravb.h > +++ b/drivers/net/ethernet/renesas/ravb.h > @@ -990,6 +990,7 @@ enum ravb_chip_id { > > struct ravb_ops { > void (*ring_free)(struct net_device *ndev, int q); > + void (*ring_format)(struct net_device *ndev, int q); Like I said, we don't need another indirection.... also both ops are for RX. [...] > diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c > index a3b8b243fd54..c23f0d420c70 100644 > --- a/drivers/net/ethernet/renesas/ravb_main.c > +++ b/drivers/net/ethernet/renesas/ravb_main.c > @@ -311,26 +311,15 @@ static void ravb_ring_free(struct net_device *ndev, int q) > } > > /* Format skb and descriptor buffer for Ethernet AVB */ > -static void ravb_ring_format(struct net_device *ndev, int q) > +static void ravb_ring_format_rx(struct net_device *ndev, int rxq) How about ravb_rx_ring_format(struct net_device *ndev, int q)? [...] MBR, Sergei
HI Sergei, Thanks for the feedback. > Subject: Re: [PATCH net-next 10/18] ravb: Factorise ravb_ring_format > function > > On 7/22/21 5:13 PM, Biju Das wrote: > > > The ravb_ring_format function uses extended descriptor in rx for R-Car > > where as it use normal descriptor for RZ/G2L. Factorise rx ring buffer > > buildup to extend the support for later SoC. > > > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> > > Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > --- > > drivers/net/ethernet/renesas/ravb.h | 1 + > > drivers/net/ethernet/renesas/ravb_main.c | 34 > > +++++++++++++++--------- > > 2 files changed, 23 insertions(+), 12 deletions(-) > > > > diff --git a/drivers/net/ethernet/renesas/ravb.h > > b/drivers/net/ethernet/renesas/ravb.h > > index 3a9cf6e8671a..a3258c5d0c3d 100644 > > --- a/drivers/net/ethernet/renesas/ravb.h > > +++ b/drivers/net/ethernet/renesas/ravb.h > > @@ -990,6 +990,7 @@ enum ravb_chip_id { > > > > struct ravb_ops { > > void (*ring_free)(struct net_device *ndev, int q); > > + void (*ring_format)(struct net_device *ndev, int q); > > Like I said, we don't need another indirection.... also both ops are > for RX. OK. Will add this as part of ravb_drv_data. > > [...] > > diff --git a/drivers/net/ethernet/renesas/ravb_main.c > > b/drivers/net/ethernet/renesas/ravb_main.c > > index a3b8b243fd54..c23f0d420c70 100644 > > --- a/drivers/net/ethernet/renesas/ravb_main.c > > +++ b/drivers/net/ethernet/renesas/ravb_main.c > > @@ -311,26 +311,15 @@ static void ravb_ring_free(struct net_device > > *ndev, int q) } > > > > /* Format skb and descriptor buffer for Ethernet AVB */ -static void > > ravb_ring_format(struct net_device *ndev, int q) > > +static void ravb_ring_format_rx(struct net_device *ndev, int rxq) > > How about ravb_rx_ring_format(struct net_device *ndev, int q)? Agreed. Cheers, Biju > > [...] > > MBR, Sergei
diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index 3a9cf6e8671a..a3258c5d0c3d 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -990,6 +990,7 @@ enum ravb_chip_id { struct ravb_ops { void (*ring_free)(struct net_device *ndev, int q); + void (*ring_format)(struct net_device *ndev, int q); }; struct ravb_drv_data { diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index a3b8b243fd54..c23f0d420c70 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -311,26 +311,15 @@ static void ravb_ring_free(struct net_device *ndev, int q) } /* Format skb and descriptor buffer for Ethernet AVB */ -static void ravb_ring_format(struct net_device *ndev, int q) +static void ravb_ring_format_rx(struct net_device *ndev, int q) { struct ravb_private *priv = netdev_priv(ndev); - int num_tx_desc = priv->num_tx_desc; struct ravb_ex_rx_desc *rx_desc; - struct ravb_tx_desc *tx_desc; - struct ravb_desc *desc; int rx_ring_size = sizeof(*rx_desc) * priv->num_rx_ring[q]; - int tx_ring_size = sizeof(*tx_desc) * priv->num_tx_ring[q] * - num_tx_desc; dma_addr_t dma_addr; int i; - priv->cur_rx[q] = 0; - priv->cur_tx[q] = 0; - priv->dirty_rx[q] = 0; - priv->dirty_tx[q] = 0; - memset(priv->rx_ring[q], 0, rx_ring_size); - /* Build RX ring buffer */ for (i = 0; i < priv->num_rx_ring[q]; i++) { /* RX descriptor */ rx_desc = &priv->rx_ring[q][i]; @@ -349,6 +338,26 @@ static void ravb_ring_format(struct net_device *ndev, int q) rx_desc = &priv->rx_ring[q][i]; rx_desc->dptr = cpu_to_le32((u32)priv->rx_desc_dma[q]); rx_desc->die_dt = DT_LINKFIX; /* type */ +} + +static void ravb_ring_format(struct net_device *ndev, int q) +{ + struct ravb_private *priv = netdev_priv(ndev); + const struct ravb_drv_data *info = priv->info; + int num_tx_desc = priv->num_tx_desc; + struct ravb_tx_desc *tx_desc; + struct ravb_desc *desc; + int tx_ring_size = sizeof(*tx_desc) * priv->num_tx_ring[q] * + num_tx_desc; + int i; + + priv->cur_rx[q] = 0; + priv->cur_tx[q] = 0; + priv->dirty_rx[q] = 0; + priv->dirty_tx[q] = 0; + + /* Build RX ring buffer */ + info->ravb_ops->ring_format(ndev, q); memset(priv->tx_ring[q], 0, tx_ring_size); /* Build TX ring buffer */ @@ -1998,6 +2007,7 @@ static int ravb_mdio_release(struct ravb_private *priv) static const struct ravb_ops ravb_gen3_ops = { .ring_free = ravb_ring_free_rx, + .ring_format = ravb_ring_format_rx, }; static const struct ravb_drv_data ravb_gen3_data = {