From: Biju Das <biju.das.jz@bp.renesas.com>
To: Sergei Shtylyov <sergei.shtylyov@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>,
Sergey Shtylyov <s.shtylyov@omprussia.ru>,
Adam Ford <aford173@gmail.com>, Andrew Lunn <andrew@lunn.ch>,
Yuusuke Ashizuka <ashiduka@fujitsu.com>,
Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-renesas-soc@vger.kernel.org"
<linux-renesas-soc@vger.kernel.org>,
Chris Paterson <Chris.Paterson2@renesas.com>,
Biju Das <biju.das@bp.renesas.com>,
Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>
Subject: RE: [PATCH net-next 09/18] ravb: Factorise ravb_ring_free function
Date: Fri, 30 Jul 2021 06:21:45 +0000 [thread overview]
Message-ID: <OS0PR01MB59223D88215676866ABD813586EC9@OS0PR01MB5922.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <a0d1bb7e-0e0a-8237-c30a-e4533b5580dd@gmail.com>
Hi Sergei,
Thanks for the feedback.
> Subject: Re: [PATCH net-next 09/18] ravb: Factorise ravb_ring_free
> function
>
> Hello!
>
> On 7/22/21 5:13 PM, Biju Das wrote:
>
> > Extended descriptor support in RX is available for R-Car where as it
> > is a normal descriptor for RZ/G2L. Factorise ravb_ring_free function
> > so that it can support 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 | 5 +++
> > drivers/net/ethernet/renesas/ravb_main.c | 49
> > ++++++++++++++++--------
> > 2 files changed, 37 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > b/drivers/net/ethernet/renesas/ravb.h
> > index a474ed68db22..3a9cf6e8671a 100644
> > --- a/drivers/net/ethernet/renesas/ravb.h
> > +++ b/drivers/net/ethernet/renesas/ravb.h
> > @@ -988,7 +988,12 @@ enum ravb_chip_id {
> > RCAR_GEN3,
> > };
> >
> > +struct ravb_ops {
> > + void (*ring_free)(struct net_device *ndev, int q);
>
> Hmm, why not store it right in the *struct* ravb_drv_data?
OK.
>
> > +};
> > +
> > struct ravb_drv_data {
> > + const struct ravb_ops *ravb_ops;
> > netdev_features_t net_features;
> > netdev_features_t net_hw_features;
> > const char (*gstrings_stats)[ETH_GSTRING_LEN];
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index 4ef2565534d2..a3b8b243fd54 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > @@ -247,30 +247,39 @@ static int ravb_tx_free(struct net_device *ndev,
> > int q, bool free_txed_only) }
> >
> > /* Free skb's and DMA buffers for Ethernet AVB */ -static void
> > ravb_ring_free(struct net_device *ndev, int q)
> > +static void ravb_ring_free_rx(struct net_device *ndev, int q)
>
> How about ravb_rx_ring_free() instead?
Agreed.
>
> > {
> > struct ravb_private *priv = netdev_priv(ndev);
> > - int num_tx_desc = priv->num_tx_desc;
> > int ring_size;
> > int i;
> >
> > - if (priv->rx_ring[q]) {
> > - for (i = 0; i < priv->num_rx_ring[q]; i++) {
> > - struct ravb_ex_rx_desc *desc = &priv->rx_ring[q][i];
> > + for (i = 0; i < priv->num_rx_ring[q]; i++) {
> > + struct ravb_ex_rx_desc *desc = &priv->rx_ring[q][i];
> >
> > - if (!dma_mapping_error(ndev->dev.parent,
> > - le32_to_cpu(desc->dptr)))
> > - dma_unmap_single(ndev->dev.parent,
> > - le32_to_cpu(desc->dptr),
> > - RX_BUF_SZ,
> > - DMA_FROM_DEVICE);
> > - }
> > - ring_size = sizeof(struct ravb_ex_rx_desc) *
> > - (priv->num_rx_ring[q] + 1);
> > - dma_free_coherent(ndev->dev.parent, ring_size, priv-
> >rx_ring[q],
> > - priv->rx_desc_dma[q]);
> > - priv->rx_ring[q] = NULL;
> > + if (!dma_mapping_error(ndev->dev.parent,
> > + le32_to_cpu(desc->dptr)))
> > + dma_unmap_single(ndev->dev.parent,
> > + le32_to_cpu(desc->dptr),
> > + RX_BUF_SZ,
> > + DMA_FROM_DEVICE);
> > }
> > + ring_size = sizeof(struct ravb_ex_rx_desc) *
> > + (priv->num_rx_ring[q] + 1);
> > + dma_free_coherent(ndev->dev.parent, ring_size, priv->rx_ring[q],
> > + priv->rx_desc_dma[q]);
> > + priv->rx_ring[q] = NULL;
>
> Couldn't this be moved into the new ravb_ring_free(), like the initial
> NULL check?
For RZ/G2L, it is priv->rgeth_rx_ring, that is the reason.
I can move the initial NULL check here, so the generic ravb_ring_free does not differentiate between
priv->rx_ring and priv->rgeth_rx_ring. See below.
>
> > +}
> > +
> > +static void ravb_ring_free(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;
> > + int ring_size;
> > + int i;
> > +
> > + if (priv->rx_ring[q])
> > + info->ravb_ops->ring_free(ndev, q);
>
> ... here?
It will be just info->ravb_ops->ring_free(ndev, q);
And NULL check will be handled respective rx helper function.
What do you think?
Cheers,
Biju
>
> [...]
>
> MBR, Sergei
next prev parent reply other threads:[~2021-07-30 6:21 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-22 14:13 [PATCH net-next 00/18] Add Gigabit Ethernet driver support Biju Das
2021-07-22 14:13 ` [PATCH net-next 01/18] dt-bindings: net: renesas,etheravb: Document Gigabit Ethernet IP Biju Das
2021-07-22 14:13 ` [PATCH net-next 05/18] ravb: Replace chip type with a structure for driver data Biju Das
2021-07-22 20:42 ` Sergei Shtylyov
2021-07-23 6:08 ` Biju Das
2021-07-22 14:13 ` [PATCH net-next 06/18] ravb: Factorise ptp feature Biju Das
2021-07-23 20:56 ` Sergei Shtylyov
2021-07-26 9:01 ` Biju Das
2021-07-26 13:08 ` Andrew Lunn
2021-07-26 13:41 ` Biju Das
2021-07-22 14:13 ` [PATCH net-next 07/18] ravb: Add features specific to R-Car Gen3 Biju Das
2021-07-22 14:13 ` [PATCH net-next 08/18] ravb: Add R-Car common features Biju Das
2021-07-27 20:48 ` Sergei Shtylyov
2021-07-28 10:13 ` Biju Das
2021-07-28 13:45 ` Andrew Lunn
2021-07-29 15:10 ` Biju Das
2021-07-22 14:13 ` [PATCH net-next 09/18] ravb: Factorise ravb_ring_free function Biju Das
2021-07-29 18:02 ` Sergei Shtylyov
2021-07-30 6:21 ` Biju Das [this message]
2021-08-20 15:32 ` Biju Das
2021-07-22 14:13 ` [PATCH net-next 10/18] ravb: Factorise ravb_ring_format function Biju Das
2021-07-29 18:30 ` Sergei Shtylyov
2021-07-30 6:24 ` Biju Das
2021-07-22 14:13 ` [PATCH net-next 11/18] ravb: Factorise ravb_ring_init function Biju Das
2021-07-29 18:53 ` Sergei Shtylyov
2021-07-30 6:54 ` Biju Das
2021-07-22 14:13 ` [PATCH net-next 12/18] ravb: Factorise {emac,dmac} init function Biju Das
2021-08-02 19:41 ` Sergei Shtylyov
2021-08-20 15:42 ` Biju Das
2021-08-20 18:57 ` Sergey Shtylyov
2021-08-20 19:44 ` Biju Das
2021-07-22 14:13 ` [PATCH net-next 13/18] ravb: Factorise ravb_rx function Biju Das
2021-07-22 14:13 ` [PATCH net-next 14/18] ravb: Factorise ravb_adjust_link function Biju Das
2021-07-22 14:13 ` [PATCH net-next 15/18] ravb: Factorise ravb_set_features Biju Das
2021-07-22 14:13 ` [PATCH net-next 16/18] ravb: Add reset support Biju Das
2021-07-22 14:13 ` [PATCH net-next 17/18] ravb: Add GbEthernet driver support Biju Das
2021-07-22 20:53 ` [PATCH net-next 00/18] Add Gigabit Ethernet " Sergei Shtylyov
2021-07-22 21:07 ` Andrew Lunn
2021-07-23 6:28 ` Biju Das
2021-07-26 10:55 ` Geert Uytterhoeven
2021-07-26 13:49 ` Arnd Bergmann
2021-07-23 6:23 ` Biju Das
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=OS0PR01MB59223D88215676866ABD813586EC9@OS0PR01MB5922.jpnprd01.prod.outlook.com \
--to=biju.das.jz@bp.renesas.com \
--cc=Chris.Paterson2@renesas.com \
--cc=aford173@gmail.com \
--cc=andrew@lunn.ch \
--cc=ashiduka@fujitsu.com \
--cc=biju.das@bp.renesas.com \
--cc=davem@davemloft.net \
--cc=geert+renesas@glider.be \
--cc=kuba@kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=s.shtylyov@omprussia.ru \
--cc=sergei.shtylyov@gmail.com \
--cc=yoshihiro.shimoda.uh@renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).