diff mbox series

[04/10] ravb: Add support for RZ/G2L SoC

Message ID 20211001150636.7500-5-biju.das.jz@bp.renesas.com (mailing list archive)
State Accepted
Commit feab85c7cceac1dfbff18cce3d089b0ca5ead565
Delegated to: Netdev Maintainers
Headers show
Series Add Gigabit Ethernet driver support | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers warning 1 maintainers not CCed: s.shtylyov@omp.ru
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 130 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Biju Das Oct. 1, 2021, 3:06 p.m. UTC
RZ/G2L SoC has Gigabit Ethernet IP consisting of Ethernet controller
(E-MAC), Internal TCP/IP Offload Engine (TOE) and Dedicated Direct
memory access controller (DMAC).

This patch adds compatible string for RZ/G2L and fills up the
ravb_hw_info struct. Function stubs are added which will be used by
gbeth_hw_info and will be filled incrementally.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
RFC->v1:
 * Added compatible string for RZ/G2L.
 * Added feature bits max_rx_len, aligned_tx and tx_counters for RZ/G2L.
---
 drivers/net/ethernet/renesas/ravb.h      |  2 +
 drivers/net/ethernet/renesas/ravb_main.c | 62 ++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

Comments

Sergey Shtylyov Oct. 2, 2021, 7:43 p.m. UTC | #1
On 10/1/21 6:06 PM, Biju Das wrote:

> RZ/G2L SoC has Gigabit Ethernet IP consisting of Ethernet controller
> (E-MAC), Internal TCP/IP Offload Engine (TOE) and Dedicated Direct
> memory access controller (DMAC).
> 
> This patch adds compatible string for RZ/G2L and fills up the
> ravb_hw_info struct. Function stubs are added which will be used by
> gbeth_hw_info and will be filled incrementally.

   I've always been against this patch -- we get a support for the GbEther whihc doesn't work
after this patch. I believe we should have the GbEther support in the last patch. of the overall
series.

> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
> RFC->v1:
>  * Added compatible string for RZ/G2L.
>  * Added feature bits max_rx_len, aligned_tx and tx_counters for RZ/G2L.
> ---
>  drivers/net/ethernet/renesas/ravb.h      |  2 +
>  drivers/net/ethernet/renesas/ravb_main.c | 62 ++++++++++++++++++++++++
>  2 files changed, 64 insertions(+)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
> index c91e93e5590f..f6398fdcead2 100644
> --- a/drivers/net/ethernet/renesas/ravb.h
> +++ b/drivers/net/ethernet/renesas/ravb.h
[...]
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 8bf13586e90a..dc817b4d95a1 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
[...]
> @@ -2073,12 +2120,27 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
>  	.nc_queue = 1,
>  };
>  
> +static const struct ravb_hw_info gbeth_hw_info = {
> +	.rx_ring_free = ravb_rx_ring_free_gbeth,
> +	.rx_ring_format = ravb_rx_ring_format_gbeth,
> +	.alloc_rx_desc = ravb_alloc_rx_desc_gbeth,
> +	.receive = ravb_rx_gbeth,
> +	.set_rate = ravb_set_rate_gbeth,
> +	.set_feature = ravb_set_features_gbeth,
> +	.dmac_init = ravb_dmac_init_gbeth,
> +	.emac_init = ravb_emac_init_gbeth,
> +	.max_rx_len = GBETH_RX_BUFF_MAX + RAVB_ALIGN - 1,

   ALIGN(GBETH_RX_BUFF_MAX, RAVB_ALIGN)?

> +	.aligned_tx = 1,
> +	.tx_counters = 1,
> +};
> +

[...]

MBR. Sergey
Biju Das Oct. 3, 2021, 6:51 a.m. UTC | #2
> Subject: Re: [PATCH 04/10] ravb: Add support for RZ/G2L SoC
> 
> On 10/1/21 6:06 PM, Biju Das wrote:
> 
> > RZ/G2L SoC has Gigabit Ethernet IP consisting of Ethernet controller
> > (E-MAC), Internal TCP/IP Offload Engine (TOE) and Dedicated Direct
> > memory access controller (DMAC).
> >
> > This patch adds compatible string for RZ/G2L and fills up the
> > ravb_hw_info struct. Function stubs are added which will be used by
> > gbeth_hw_info and will be filled incrementally.
> 
>    I've always been against this patch -- we get a support for the GbEther
> whihc doesn't work after this patch. I believe we should have the GbEther
> support in the last patch. of the overall series.


This is the common practice. We use bricks to build a wall. The function stubs are just
Bricks. 

After filling stubs, we will add SoC dt and board DT, after that one will get GBsupport on
RZ/G2L platform.

Regards,
Biju

> 
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > ---
> > RFC->v1:
> >  * Added compatible string for RZ/G2L.
> >  * Added feature bits max_rx_len, aligned_tx and tx_counters for RZ/G2L.
> > ---
> >  drivers/net/ethernet/renesas/ravb.h      |  2 +
> >  drivers/net/ethernet/renesas/ravb_main.c | 62
> > ++++++++++++++++++++++++
> >  2 files changed, 64 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > b/drivers/net/ethernet/renesas/ravb.h
> > index c91e93e5590f..f6398fdcead2 100644
> > --- a/drivers/net/ethernet/renesas/ravb.h
> > +++ b/drivers/net/ethernet/renesas/ravb.h
> [...]
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index 8bf13586e90a..dc817b4d95a1 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> [...]
> > @@ -2073,12 +2120,27 @@ static const struct ravb_hw_info
> ravb_gen2_hw_info = {
> >  	.nc_queue = 1,
> >  };
> >
> > +static const struct ravb_hw_info gbeth_hw_info = {
> > +	.rx_ring_free = ravb_rx_ring_free_gbeth,
> > +	.rx_ring_format = ravb_rx_ring_format_gbeth,
> > +	.alloc_rx_desc = ravb_alloc_rx_desc_gbeth,
> > +	.receive = ravb_rx_gbeth,
> > +	.set_rate = ravb_set_rate_gbeth,
> > +	.set_feature = ravb_set_features_gbeth,
> > +	.dmac_init = ravb_dmac_init_gbeth,
> > +	.emac_init = ravb_emac_init_gbeth,
> > +	.max_rx_len = GBETH_RX_BUFF_MAX + RAVB_ALIGN - 1,
> 
>    ALIGN(GBETH_RX_BUFF_MAX, RAVB_ALIGN)?
> 
> > +	.aligned_tx = 1,
> > +	.tx_counters = 1,
> > +};
> > +
> 
> [...]
> 
> MBR. Sergey
Geert Uytterhoeven Oct. 4, 2021, 7:10 a.m. UTC | #3
Hi Biju,

On Sun, Oct 3, 2021 at 8:51 AM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> > Subject: Re: [PATCH 04/10] ravb: Add support for RZ/G2L SoC
> > On 10/1/21 6:06 PM, Biju Das wrote:
> > > RZ/G2L SoC has Gigabit Ethernet IP consisting of Ethernet controller
> > > (E-MAC), Internal TCP/IP Offload Engine (TOE) and Dedicated Direct
> > > memory access controller (DMAC).
> > >
> > > This patch adds compatible string for RZ/G2L and fills up the
> > > ravb_hw_info struct. Function stubs are added which will be used by
> > > gbeth_hw_info and will be filled incrementally.
> >
> >    I've always been against this patch -- we get a support for the GbEther
> > whihc doesn't work after this patch. I believe we should have the GbEther
> > support in the last patch. of the overall series.
>
> This is the common practice. We use bricks to build a wall. The function stubs are just
> Bricks.
>
> After filling stubs, we will add SoC dt and board DT, after that one will get GBsupport on
> RZ/G2L platform.

Not "after", but "in parallel".  The stubs will be filled in through
the netdev tree (1), while SoC DT and board DT will go through the
renesas-devel and soc trees (2).

So our main worry is: what happens if you have (2) but not (1)?

Gr{oetje,eeting}s,

                        Geert
Biju Das Oct. 4, 2021, 7:49 a.m. UTC | #4
Hi Geert,

Thanks for the feedback

> Subject: Re: [PATCH 04/10] ravb: Add support for RZ/G2L SoC
> 
> Hi Biju,
> 
> On Sun, Oct 3, 2021 at 8:51 AM Biju Das <biju.das.jz@bp.renesas.com>
> wrote:
> > > Subject: Re: [PATCH 04/10] ravb: Add support for RZ/G2L SoC On
> > > 10/1/21 6:06 PM, Biju Das wrote:
> > > > RZ/G2L SoC has Gigabit Ethernet IP consisting of Ethernet
> > > > controller (E-MAC), Internal TCP/IP Offload Engine (TOE) and
> > > > Dedicated Direct memory access controller (DMAC).
> > > >
> > > > This patch adds compatible string for RZ/G2L and fills up the
> > > > ravb_hw_info struct. Function stubs are added which will be used
> > > > by gbeth_hw_info and will be filled incrementally.
> > >
> > >    I've always been against this patch -- we get a support for the
> > > GbEther whihc doesn't work after this patch. I believe we should
> > > have the GbEther support in the last patch. of the overall series.
> >
> > This is the common practice. We use bricks to build a wall. The
> > function stubs are just Bricks.
> >
> > After filling stubs, we will add SoC dt and board DT, after that one
> > will get GBsupport on RZ/G2L platform.
> 
> Not "after", but "in parallel".  The stubs will be filled in through the
> netdev tree (1), while SoC DT and board DT will go through the renesas-
> devel and soc trees (2).
> 
> So our main worry is: what happens if you have (2) but not (1)?

Please find the test cases

Case a) (1) and then (2) RootFS mounted on NFS
----------------------------------------------------

root@smarc-rzg2l:~# cat /proc/cmdline
ignore_loglevel nfsrootdebug root=/dev/nfs rw nfsroot=192.168.10.1:/tftpboot/RZ-G2L,nfsvers=3 ip=192.168.10.2
root@smarc-rzg2l:~#

Case b) Have (2) but not (1)? RootFS mounted on USB
----------------------------------------------------

root@smarc-rzg2l:~# cat /proc/cmdline
rw rootwait earlycon root=/dev/sda1
root@smarc-rzg2l:~#

Case c) Have (2) but not (1)? RootFS mounted on NFS
---------------------------------------------------

It stops booting as we haven't filled RX stubs.

[    4.457432]  sda: sda1
[    4.465909] sd 0:0:0:0: [sda] Attached SCSI removable disk


If you look at Case B, that is the current case, which boots without any issues. There is no regression
at all with the current changes submitted.

The only issue is mounting with NFS which won't work as we haven't filled stubs to get full functionality.


Regards,
Biju
Biju Das Oct. 4, 2021, 1:28 p.m. UTC | #5
Hi Sergei,

> Subject: RE: [PATCH 04/10] ravb: Add support for RZ/G2L SoC
> 
> > Subject: Re: [PATCH 04/10] ravb: Add support for RZ/G2L SoC
> >
> > On 10/1/21 6:06 PM, Biju Das wrote:
> >
> > > RZ/G2L SoC has Gigabit Ethernet IP consisting of Ethernet controller
> > > (E-MAC), Internal TCP/IP Offload Engine (TOE) and Dedicated Direct
> > > memory access controller (DMAC).
> > >
> > > This patch adds compatible string for RZ/G2L and fills up the
> > > ravb_hw_info struct. Function stubs are added which will be used by
> > > gbeth_hw_info and will be filled incrementally.
> >
> >    I've always been against this patch -- we get a support for the
> > GbEther whihc doesn't work after this patch. I believe we should have
> > the GbEther support in the last patch. of the overall series.
> 
> 
> This is the common practice. We use bricks to build a wall. The function
> stubs are just Bricks.
> 
> After filling stubs, we will add SoC dt and board DT, after that one will
> get GBsupport on RZ/G2L platform.
> 
> Regards,
> Biju
> 
> >
> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > > Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > ---
> > > RFC->v1:
> > >  * Added compatible string for RZ/G2L.
> > >  * Added feature bits max_rx_len, aligned_tx and tx_counters for
> RZ/G2L.
> > > ---
> > >  drivers/net/ethernet/renesas/ravb.h      |  2 +
> > >  drivers/net/ethernet/renesas/ravb_main.c | 62
> > > ++++++++++++++++++++++++
> > >  2 files changed, 64 insertions(+)
> > >
> > > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > > b/drivers/net/ethernet/renesas/ravb.h
> > > index c91e93e5590f..f6398fdcead2 100644
> > > --- a/drivers/net/ethernet/renesas/ravb.h
> > > +++ b/drivers/net/ethernet/renesas/ravb.h
> > [...]
> > > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > > b/drivers/net/ethernet/renesas/ravb_main.c
> > > index 8bf13586e90a..dc817b4d95a1 100644
> > > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > [...]
> > > @@ -2073,12 +2120,27 @@ static const struct ravb_hw_info
> > ravb_gen2_hw_info = {
> > >  	.nc_queue = 1,
> > >  };
> > >
> > > +static const struct ravb_hw_info gbeth_hw_info = {
> > > +	.rx_ring_free = ravb_rx_ring_free_gbeth,
> > > +	.rx_ring_format = ravb_rx_ring_format_gbeth,
> > > +	.alloc_rx_desc = ravb_alloc_rx_desc_gbeth,
> > > +	.receive = ravb_rx_gbeth,
> > > +	.set_rate = ravb_set_rate_gbeth,
> > > +	.set_feature = ravb_set_features_gbeth,
> > > +	.dmac_init = ravb_dmac_init_gbeth,
> > > +	.emac_init = ravb_emac_init_gbeth,
> > > +	.max_rx_len = GBETH_RX_BUFF_MAX + RAVB_ALIGN - 1,
> >
> >    ALIGN(GBETH_RX_BUFF_MAX, RAVB_ALIGN)?

Will send this change as RFC.

Regards,
Biju

> >
> > > +	.aligned_tx = 1,
> > > +	.tx_counters = 1,
> > > +};
> > > +
> >
> > [...]
> >
> > MBR. Sergey
diff mbox series

Patch

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index c91e93e5590f..f6398fdcead2 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -956,6 +956,8 @@  enum RAVB_QUEUE {
 
 #define RX_BUF_SZ	(2048 - ETH_FCS_LEN + sizeof(__sum16))
 
+#define GBETH_RX_BUFF_MAX 8192
+
 struct ravb_tstamp_skb {
 	struct list_head list;
 	struct sk_buff *skb;
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 8bf13586e90a..dc817b4d95a1 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -83,6 +83,11 @@  static int ravb_config(struct net_device *ndev)
 	return error;
 }
 
+static void ravb_set_rate_gbeth(struct net_device *ndev)
+{
+	/* Place holder */
+}
+
 static void ravb_set_rate(struct net_device *ndev)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
@@ -217,6 +222,11 @@  static int ravb_tx_free(struct net_device *ndev, int q, bool free_txed_only)
 	return free_num;
 }
 
+static void ravb_rx_ring_free_gbeth(struct net_device *ndev, int q)
+{
+	/* Place holder */
+}
+
 static void ravb_rx_ring_free(struct net_device *ndev, int q)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
@@ -283,6 +293,11 @@  static void ravb_ring_free(struct net_device *ndev, int q)
 	priv->tx_skb[q] = NULL;
 }
 
+static void ravb_rx_ring_format_gbeth(struct net_device *ndev, int q)
+{
+	/* Place holder */
+}
+
 static void ravb_rx_ring_format(struct net_device *ndev, int q)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
@@ -356,6 +371,12 @@  static void ravb_ring_format(struct net_device *ndev, int q)
 	desc->dptr = cpu_to_le32((u32)priv->tx_desc_dma[q]);
 }
 
+static void *ravb_alloc_rx_desc_gbeth(struct net_device *ndev, int q)
+{
+	/* Place holder */
+	return NULL;
+}
+
 static void *ravb_alloc_rx_desc(struct net_device *ndev, int q)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
@@ -426,6 +447,11 @@  static int ravb_ring_init(struct net_device *ndev, int q)
 	return -ENOMEM;
 }
 
+static void ravb_emac_init_gbeth(struct net_device *ndev)
+{
+	/* Place holder */
+}
+
 static void ravb_rcar_emac_init(struct net_device *ndev)
 {
 	/* Receive frame limit set register */
@@ -461,6 +487,12 @@  static void ravb_emac_init(struct net_device *ndev)
 	info->emac_init(ndev);
 }
 
+static int ravb_dmac_init_gbeth(struct net_device *ndev)
+{
+	/* Place holder */
+	return 0;
+}
+
 static int ravb_dmac_init_rcar(struct net_device *ndev)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
@@ -584,6 +616,14 @@  static void ravb_rx_csum(struct sk_buff *skb)
 	skb_trim(skb, skb->len - sizeof(__sum16));
 }
 
+/* Packet receive function for Gigabit Ethernet */
+static bool ravb_rx_gbeth(struct net_device *ndev, int *quota, int q)
+{
+	/* Place holder */
+	return true;
+}
+
+/* Packet receive function for Ethernet AVB */
 static bool ravb_rcar_rx(struct net_device *ndev, int *quota, int q)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
@@ -1949,6 +1989,13 @@  static void ravb_set_rx_csum(struct net_device *ndev, bool enable)
 	spin_unlock_irqrestore(&priv->lock, flags);
 }
 
+static int ravb_set_features_gbeth(struct net_device *ndev,
+				   netdev_features_t features)
+{
+	/* Place holder */
+	return 0;
+}
+
 static int ravb_set_features_rcar(struct net_device *ndev,
 				  netdev_features_t features)
 {
@@ -2073,12 +2120,27 @@  static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.nc_queue = 1,
 };
 
+static const struct ravb_hw_info gbeth_hw_info = {
+	.rx_ring_free = ravb_rx_ring_free_gbeth,
+	.rx_ring_format = ravb_rx_ring_format_gbeth,
+	.alloc_rx_desc = ravb_alloc_rx_desc_gbeth,
+	.receive = ravb_rx_gbeth,
+	.set_rate = ravb_set_rate_gbeth,
+	.set_feature = ravb_set_features_gbeth,
+	.dmac_init = ravb_dmac_init_gbeth,
+	.emac_init = ravb_emac_init_gbeth,
+	.max_rx_len = GBETH_RX_BUFF_MAX + RAVB_ALIGN - 1,
+	.aligned_tx = 1,
+	.tx_counters = 1,
+};
+
 static const struct of_device_id ravb_match_table[] = {
 	{ .compatible = "renesas,etheravb-r8a7790", .data = &ravb_gen2_hw_info },
 	{ .compatible = "renesas,etheravb-r8a7794", .data = &ravb_gen2_hw_info },
 	{ .compatible = "renesas,etheravb-rcar-gen2", .data = &ravb_gen2_hw_info },
 	{ .compatible = "renesas,etheravb-r8a7795", .data = &ravb_gen3_hw_info },
 	{ .compatible = "renesas,etheravb-rcar-gen3", .data = &ravb_gen3_hw_info },
+	{ .compatible = "renesas,rzg2l-gbeth", .data = &gbeth_hw_info },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ravb_match_table);