From: Sergei Shtylyov <sergei.shtylyov@gmail.com>
To: Biju Das <biju.das.jz@bp.renesas.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, 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 05/18] ravb: Replace chip type with a structure for driver data
Date: Thu, 22 Jul 2021 23:42:20 +0300 [thread overview]
Message-ID: <09e06a00-6b9e-c8b8-e5c3-67d82d900a74@gmail.com> (raw)
In-Reply-To: <20210722141351.13668-6-biju.das.jz@bp.renesas.com>
Hello!
On 7/22/21 5:13 PM, Biju Das wrote:
> The DMAC and EMAC blocks of Gigabit Ethernet IP is almost similar to
> Ethernet AVB. With few changes in driver we can support both the IP.
>
> This patch is in preparation for supporting the same by replacing chip
> type by a structure with values, feature bits and function pointers.
>
> Currently only values is added to structure and later patches will add
> features and function pointers.
>
> 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 | 14 +++++
> drivers/net/ethernet/renesas/ravb_main.c | 76 +++++++++++++++++-------
> 2 files changed, 67 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
> index 80e62ca2e3d3..0ed21262f26b 100644
> --- a/drivers/net/ethernet/renesas/ravb.h
> +++ b/drivers/net/ethernet/renesas/ravb.h
> @@ -988,6 +988,18 @@ enum ravb_chip_id {
> RCAR_GEN3,
> };
>
> +struct ravb_drv_data {
I'd rather suggest *struct* ravb_hw_info... This is hardly a driver data, more like
hwrdware's one. :-)
> + netdev_features_t net_features;
> + netdev_features_t net_hw_features;
> + const char (*gstrings_stats)[ETH_GSTRING_LEN];
> + size_t gstrings_size;
> + size_t stats_len;
> + u32 num_gstat_queue;
> + size_t skb_sz;
> + u8 num_tx_desc;
> + enum ravb_chip_id chip_id;
Mhm, I'd expect that chip_id is no longer needed with the feature structs...
[...]
> @@ -1040,6 +1052,8 @@ struct ravb_private {
> unsigned txcidm:1; /* TX Clock Internal Delay Mode */
> unsigned rgmii_override:1; /* Deprecated rgmii-*id behavior */
> int num_tx_desc; /* TX descriptors per packet */
> +
> + const struct ravb_drv_data *info;
So data or info? :-)
[...]
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 805397088850..84ebd6fef711 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
[...]
> @@ -1176,9 +1179,12 @@ static void ravb_get_ethtool_stats(struct net_device *ndev,
>
> static void ravb_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
> {
> + struct ravb_private *priv = netdev_priv(ndev);
> + const struct ravb_drv_data *info = priv->info;
> +
> switch (stringset) {
> case ETH_SS_STATS:
> - memcpy(data, ravb_gstrings_stats, sizeof(ravb_gstrings_stats));
> + memcpy(data, info->gstrings_stats, info->gstrings_size);
> break;
> }
> }
> @@ -1924,12 +1930,36 @@ static int ravb_mdio_release(struct ravb_private *priv)
> return 0;
> }
>
> +static const struct ravb_drv_data ravb_gen3_data = {
> + .net_features = NETIF_F_RXCSUM,
> + .net_hw_features = NETIF_F_RXCSUM,
> + .gstrings_stats = ravb_gstrings_stats,
> + .gstrings_size = sizeof(ravb_gstrings_stats),
> + .stats_len = ARRAY_SIZE(ravb_gstrings_stats),
> + .num_gstat_queue = NUM_RX_QUEUE,
> + .skb_sz = RX_BUF_SZ + RAVB_ALIGN - 1,
> + .num_tx_desc = NUM_TX_DESC_GEN3,
> + .chip_id = RCAR_GEN3,
> +};
> +
> +static const struct ravb_drv_data ravb_gen2_data = {
> + .net_features = NETIF_F_RXCSUM,
> + .net_hw_features = NETIF_F_RXCSUM,
Mhm, why have the fields that don't change from SoC to SoC anyway?
I do think they should be added when a new SoC support is added...
> + .gstrings_stats = ravb_gstrings_stats,
> + .gstrings_size = sizeof(ravb_gstrings_stats),
> + .stats_len = ARRAY_SIZE(ravb_gstrings_stats),
Same question...
> + .num_gstat_queue = NUM_RX_QUEUE,
> + .skb_sz = RX_BUF_SZ + RAVB_ALIGN - 1,
Again why?
> + .num_tx_desc = NUM_TX_DESC_GEN2,
> + .chip_id = RCAR_GEN2,
> +};
> +
[...]
> @@ -2052,15 +2082,15 @@ static int ravb_probe(struct platform_device *pdev)
> if (!ndev)
> return -ENOMEM;
>
> - ndev->features = NETIF_F_RXCSUM;
> - ndev->hw_features = NETIF_F_RXCSUM;
> + info = of_device_get_match_data(&pdev->dev);
> +
> + ndev->features = info->net_features;
> + ndev->hw_features = info->net_hw_features;
>
> pm_runtime_enable(&pdev->dev);
> pm_runtime_get_sync(&pdev->dev);
>
> - chip_id = (enum ravb_chip_id)of_device_get_match_data(&pdev->dev);
> -
> - if (chip_id == RCAR_GEN3)
> + if (info->chip_id == RCAR_GEN3)
Ugh...
> irq = platform_get_irq_byname(pdev, "ch22");
> else
> irq = platform_get_irq(pdev, 0);
[...]
> @@ -2099,7 +2130,7 @@ static int ravb_probe(struct platform_device *pdev)
> priv->avb_link_active_low =
> of_property_read_bool(np, "renesas,ether-link-active-low");
>
> - if (chip_id == RCAR_GEN3) {
> + if (info->chip_id == RCAR_GEN3) {
Ugh...
> irq = platform_get_irq_byname(pdev, "ch24");
> if (irq < 0) {
> error = irq;
[...]
> @@ -2184,7 +2214,7 @@ static int ravb_probe(struct platform_device *pdev)
> INIT_LIST_HEAD(&priv->ts_skb_list);
>
> /* Initialise PTP Clock driver */
> - if (chip_id != RCAR_GEN2)
> + if (info->chip_id != RCAR_GEN2)
> ravb_ptp_init(ndev, pdev);
Ugh...
>
> /* Debug message level */
> @@ -2232,7 +2262,7 @@ static int ravb_probe(struct platform_device *pdev)
> priv->desc_bat_dma);
>
> /* Stop PTP Clock driver */
> - if (chip_id != RCAR_GEN2)
> + if (info->chip_id != RCAR_GEN2)
> ravb_ptp_stop(ndev);
Ugh...
> out_disable_refclk:
> clk_disable_unprepare(priv->refclk);
MBR, Sergei
next prev parent reply other threads:[~2021-07-22 20:42 UTC|newest]
Thread overview: 55+ 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 02/18] drivers: clk: renesas: rzg2l-cpg: Add support to handle MUX clocks Biju Das
2021-07-23 10:26 ` Sergei Shtylyov
2021-07-23 12:12 ` Biju Das
2021-07-26 10:53 ` Geert Uytterhoeven
2021-07-26 12:23 ` Biju Das
2021-07-22 14:13 ` [PATCH net-next 03/18] drivers: clk: renesas: r9a07g044-cpg: Add ethernet clock sources Biju Das
2021-07-26 10:50 ` Geert Uytterhoeven
2021-07-26 11:43 ` Biju Das
2021-07-26 11:50 ` Geert Uytterhoeven
2021-07-22 14:13 ` [PATCH net-next 04/18] drivers: clk: renesas: r9a07g044-cpg: Add GbEthernet clock/reset Biju Das
2021-07-26 10:11 ` Geert Uytterhoeven
2021-07-26 10:18 ` 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 [this message]
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
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 14:13 ` [PATCH net-next 18/18] arm64: dts: renesas: r9a07g044: Add GbEther nodes Biju Das
2021-07-22 20:53 ` [PATCH net-next 00/18] Add Gigabit Ethernet driver support 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=09e06a00-6b9e-c8b8-e5c3-67d82d900a74@gmail.com \
--to=sergei.shtylyov@gmail.com \
--cc=Chris.Paterson2@renesas.com \
--cc=aford173@gmail.com \
--cc=andrew@lunn.ch \
--cc=ashiduka@fujitsu.com \
--cc=biju.das.jz@bp.renesas.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=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).