RE: [PATCH/RFC 2/2] ravb: Add GbEthernet driver support
From: Biju Das <biju.das.jz@bp.renesas.com>
Date: 2021-07-15 10:31:28
Also in:
linux-renesas-soc
Hi Geert, Thanks for the feedback.
Subject: Re: [PATCH/RFC 2/2] ravb: Add GbEthernet driver support Hi Biju, On Wed, Jul 14, 2021 at 4:54 PM Biju Das [off-list ref] wrote:quoted
Add Gigabit Ethernet driver support. The Gigabit Etherner IP consists of Ethernet controller (E-MAC), Internal TCP/IP Offload Engine (TOE) and Dedicated Direct memory access controller (DMAC). Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>Thanks for your patch!quoted
--- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.hquoted
@@ -986,6 +1068,7 @@ struct ravb_ptp { enum ravb_chip_id { RCAR_GEN2, RCAR_GEN3, + RZ_G2L, };Instead of adding another chip type, it may be better to replace the chip type by a structure with feature bits, values, and function pointers (see examples below).
BTW given the ravb driver is based on the sh_eth driver ("Ethernet AVB
includes an Gigabit Ethernet controller (E-MAC) that is basically
compatible with SuperH Gigabit Ethernet E-MAC"), and seeing the amount of
changes, I'm wondering if rgeth is closer to sh_eth? ;-)With sh_eth driver,We can reuse only E-MAC IP. But with RAVB we can reuse both DMAC and E-MAC. Hence I believe it is closer to AVB.
quoted
--- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.cquoted
@@ -247,8 +288,12 @@ static void ravb_ring_free(struct net_device *ndev,int q)quoted
int ring_size; int i; - if (priv->rx_ring[q]) { - ravb_ring_free_ex(ndev, q); + if (priv->chip_id == RZ_G2L) { + if (priv->rgeth_rx_ring[q]) + rgeth_ring_free_ex(ndev, q); + } else { + if (priv->rx_ring[q]) + ravb_ring_free_ex(ndev, q); }Could be called through a function pointer instead.
OK.
quoted
@@ -356,7 +434,7 @@ static void ravb_ring_format(struct net_device*ndev, int q) static int ravb_ring_init(struct net_device *ndev, int q) { struct ravb_private *priv = netdev_priv(ndev); - size_t skb_sz = RX_BUF_SZ; + size_t skb_sz = (priv->chip_id == RZ_G2L) ? RGETH_RCV_BUFF_MAX + : RX_BUF_SZ;Could use a value in the structure.
OK.
quoted
@@ -730,7 +1054,7 @@ static void ravb_emac_interrupt_unlocked(structnet_device *ndev)quoted
ecsr = ravb_read(ndev, ECSR); ravb_write(ndev, ecsr, ECSR); /* clear interrupt */ - if (ecsr & ECSR_MPD) + if (priv->chip_id != RZ_G2L && (ecsr & ECSR_MPD))Could use a feature bit.
OK.
quoted
@@ -2104,11 +2578,19 @@ static int ravb_probe(struct platform_device*pdev)quoted
priv = netdev_priv(ndev); priv->chip_id = chip_id; - ndev->features = NETIF_F_RXCSUM; - ndev->hw_features = NETIF_F_RXCSUM; - - pm_runtime_enable(&pdev->dev); - pm_runtime_get_sync(&pdev->dev); + if (chip_id == RZ_G2L) { + ndev->hw_features |= (NETIF_F_HW_CSUM | NETIF_F_RXCSUM); + priv->rstc = devm_reset_control_get(&pdev->dev, NULL);R-Car Gen2 and Gen3 describe a reset in DT, too. Does it hurt to always use the reset?
OK will use reset.
quoted
+ if (IS_ERR(priv->rstc)) { + dev_err(&pdev->dev, "failed to get cpg + reset\n");dev_err_probe(), to avoid printing an error on -EPROBE_DEFER.
OK. Regards, Biju
quoted
+ free_netdev(ndev); + return PTR_ERR(priv->rstc); + } + reset_control_deassert(priv->rstc); + } else { + ndev->features = NETIF_F_RXCSUM; + ndev->hw_features = NETIF_F_RXCSUM; + }Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux- m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds