All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC/PATCH 00/18] Add Gigabit Ethernet driver support
@ 2021-09-23 14:07 Biju Das
  2021-09-23 14:07 ` [RFC/PATCH 01/18] ravb: Rename "ravb_set_features_rx_csum" function to "ravb_set_features_rcar" Biju Das
                   ` (18 more replies)
  0 siblings, 19 replies; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:07 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

The DMAC and EMAC blocks of Gigabit Ethernet IP found on RZ/G2L SoC are
similar to the R-Car Ethernet AVB IP.

The Gigabit Ethernet IP consists of Ethernet controller (E-MAC), Internal
TCP/IP Offload Engine (TOE)  and Dedicated Direct memory access controller
(DMAC).

With a few changes in the driver we can support both IPs.

This patch series aims to add Gigabit ethernet driver support to RZ/G2L SoC.

Please provide your valuable comments.

Ref:-
 * https://lore.kernel.org/linux-renesas-soc/TYCPR01MB59334319695607A2683C1A5E86E59@TYCPR01MB5933.jpnprd01.prod.outlook.com/T/#t


Biju Das (18):
  ravb: Rename "ravb_set_features_rx_csum" function to
    "ravb_set_features_rcar"
  ravb: Rename the variables "no_ptp_cfg_active" and "ptp_cfg_active"
  ravb: Initialize GbEthernet dmac
  ravb: Enable aligned_tx and tx_counters for RZ/G2L
  ravb: Exclude gPTP feature support for RZ/G2L
  ravb: Add multi_tsrq to struct ravb_hw_info
  ravb: Add magic_pkt to struct ravb_hw_info
  ravb: Add mii_rgmii_selection to struct ravb_hw_info
  ravb: Add half_duplex to struct ravb_hw_info
  ravb: Initialize GbEthernet E-MAC
  ravb: Add rx_2k_buffers to struct ravb_hw_info
  ravb: Add timestamp to struct ravb_hw_info
  ravb: Add rx_ring_free function support for GbEthernet
  ravb: Add rx_ring_format function for GbEthernet
  ravb: Add rx_alloc helper function for GbEthernet
  ravb: Add Packet receive function for Gigabit Ethernet
  ravb: Add carrier_counters to struct ravb_hw_info
  ravb: Add set_feature support for RZ/G2L

 drivers/net/ethernet/renesas/ravb.h      |  91 +++-
 drivers/net/ethernet/renesas/ravb_main.c | 631 ++++++++++++++++++++---
 2 files changed, 630 insertions(+), 92 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 01/18] ravb: Rename "ravb_set_features_rx_csum" function to "ravb_set_features_rcar"
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
@ 2021-09-23 14:07 ` Biju Das
  2021-09-27 19:54   ` Sergey Shtylyov
  2021-09-23 14:07 ` [RFC/PATCH 02/18] ravb: Rename the variables "no_ptp_cfg_active" and "ptp_cfg_active" Biju Das
                   ` (17 subsequent siblings)
  18 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:07 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

Rename "ravb_set_features_rx_csum" function to "ravb_set_features_rcar" and
replace the function pointer "set_rx_csum_feature" with "set_feature".

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Suggested-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/net/ethernet/renesas/ravb.h      |  2 +-
 drivers/net/ethernet/renesas/ravb_main.c | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 47c5377e4f42..7363abae6e59 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -985,7 +985,7 @@ struct ravb_hw_info {
 	void *(*alloc_rx_desc)(struct net_device *ndev, int q);
 	bool (*receive)(struct net_device *ndev, int *quota, int q);
 	void (*set_rate)(struct net_device *ndev);
-	int (*set_rx_csum_feature)(struct net_device *ndev, netdev_features_t features);
+	int (*set_feature)(struct net_device *ndev, netdev_features_t features);
 	void (*dmac_init)(struct net_device *ndev);
 	void (*emac_init)(struct net_device *ndev);
 	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 0f85f2d97b18..8f2358caef34 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1918,8 +1918,8 @@ static void ravb_set_rx_csum(struct net_device *ndev, bool enable)
 	spin_unlock_irqrestore(&priv->lock, flags);
 }
 
-static int ravb_set_features_rx_csum(struct net_device *ndev,
-				     netdev_features_t features)
+static int ravb_set_features_rcar(struct net_device *ndev,
+				  netdev_features_t features)
 {
 	netdev_features_t changed = ndev->features ^ features;
 
@@ -1937,7 +1937,7 @@ static int ravb_set_features(struct net_device *ndev,
 	struct ravb_private *priv = netdev_priv(ndev);
 	const struct ravb_hw_info *info = priv->info;
 
-	return info->set_rx_csum_feature(ndev, features);
+	return info->set_feature(ndev, features);
 }
 
 static const struct net_device_ops ravb_netdev_ops = {
@@ -2006,7 +2006,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
 	.alloc_rx_desc = ravb_alloc_rx_desc,
 	.receive = ravb_rcar_rx,
 	.set_rate = ravb_set_rate,
-	.set_rx_csum_feature = ravb_set_features_rx_csum,
+	.set_feature = ravb_set_features_rcar,
 	.dmac_init = ravb_rcar_dmac_init,
 	.emac_init = ravb_rcar_emac_init,
 	.gstrings_stats = ravb_gstrings_stats,
@@ -2027,7 +2027,7 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.alloc_rx_desc = ravb_alloc_rx_desc,
 	.receive = ravb_rcar_rx,
 	.set_rate = ravb_set_rate,
-	.set_rx_csum_feature = ravb_set_features_rx_csum,
+	.set_feature = ravb_set_features_rcar,
 	.dmac_init = ravb_rcar_dmac_init,
 	.emac_init = ravb_rcar_emac_init,
 	.gstrings_stats = ravb_gstrings_stats,
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 02/18] ravb: Rename the variables "no_ptp_cfg_active" and "ptp_cfg_active"
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
  2021-09-23 14:07 ` [RFC/PATCH 01/18] ravb: Rename "ravb_set_features_rx_csum" function to "ravb_set_features_rcar" Biju Das
@ 2021-09-23 14:07 ` Biju Das
  2021-09-23 16:07   ` Sergey Shtylyov
  2021-09-23 14:07 ` [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac Biju Das
                   ` (16 subsequent siblings)
  18 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:07 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

Rename the variable "no_ptp_cfg_active" with "no_gptp" with inverted
checks and "ptp_cfg_active" with "ccc_gac".

There is no functional change.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Suggested-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/net/ethernet/renesas/ravb.h      |  4 ++--
 drivers/net/ethernet/renesas/ravb_main.c | 25 ++++++++++++------------
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 7363abae6e59..0ce0c13ef8cb 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1000,8 +1000,8 @@ struct ravb_hw_info {
 	unsigned internal_delay:1;	/* AVB-DMAC has internal delays */
 	unsigned tx_counters:1;		/* E-MAC has TX counters */
 	unsigned multi_irqs:1;		/* AVB-DMAC and E-MAC has multiple irqs */
-	unsigned no_ptp_cfg_active:1;	/* AVB-DMAC does not support gPTP active in config mode */
-	unsigned ptp_cfg_active:1;	/* AVB-DMAC has gPTP support active in config mode */
+	unsigned no_gptp:1;		/* AVB-DMAC does not support gPTP feature */
+	unsigned ccc_gac:1;		/* AVB-DMAC has gPTP support active in config mode */
 };
 
 struct ravb_private {
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 8f2358caef34..2422e74d9b4f 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1274,7 +1274,7 @@ static int ravb_set_ringparam(struct net_device *ndev,
 	if (netif_running(ndev)) {
 		netif_device_detach(ndev);
 		/* Stop PTP Clock driver */
-		if (info->no_ptp_cfg_active)
+		if (!info->no_gptp && !info->ccc_gac)
 			ravb_ptp_stop(ndev);
 		/* Wait for DMA stopping */
 		error = ravb_stop_dma(ndev);
@@ -1306,7 +1306,7 @@ static int ravb_set_ringparam(struct net_device *ndev,
 		ravb_emac_init(ndev);
 
 		/* Initialise PTP Clock driver */
-		if (info->no_ptp_cfg_active)
+		if (!info->no_gptp && !info->ccc_gac)
 			ravb_ptp_init(ndev, priv->pdev);
 
 		netif_device_attach(ndev);
@@ -1446,7 +1446,7 @@ static int ravb_open(struct net_device *ndev)
 	ravb_emac_init(ndev);
 
 	/* Initialise PTP Clock driver */
-	if (info->no_ptp_cfg_active)
+	if (!info->no_gptp && !info->ccc_gac)
 		ravb_ptp_init(ndev, priv->pdev);
 
 	netif_tx_start_all_queues(ndev);
@@ -1460,7 +1460,7 @@ static int ravb_open(struct net_device *ndev)
 
 out_ptp_stop:
 	/* Stop PTP Clock driver */
-	if (info->no_ptp_cfg_active)
+	if (!info->no_gptp && !info->ccc_gac)
 		ravb_ptp_stop(ndev);
 out_free_irq_nc_tx:
 	if (!info->multi_irqs)
@@ -1508,7 +1508,7 @@ static void ravb_tx_timeout_work(struct work_struct *work)
 	netif_tx_stop_all_queues(ndev);
 
 	/* Stop PTP Clock driver */
-	if (info->no_ptp_cfg_active)
+	if (!info->no_gptp && !info->ccc_gac)
 		ravb_ptp_stop(ndev);
 
 	/* Wait for DMA stopping */
@@ -1543,7 +1543,7 @@ static void ravb_tx_timeout_work(struct work_struct *work)
 
 out:
 	/* Initialise PTP Clock driver */
-	if (info->no_ptp_cfg_active)
+	if (!info->no_gptp && !info->ccc_gac)
 		ravb_ptp_init(ndev, priv->pdev);
 
 	netif_tx_start_all_queues(ndev);
@@ -1752,7 +1752,7 @@ static int ravb_close(struct net_device *ndev)
 	ravb_write(ndev, 0, TIC);
 
 	/* Stop PTP Clock driver */
-	if (info->no_ptp_cfg_active)
+	if (!info->no_gptp && !info->ccc_gac)
 		ravb_ptp_stop(ndev);
 
 	/* Set the config mode to stop the AVB-DMAC's processes */
@@ -2018,7 +2018,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
 	.internal_delay = 1,
 	.tx_counters = 1,
 	.multi_irqs = 1,
-	.ptp_cfg_active = 1,
+	.ccc_gac = 1,
 };
 
 static const struct ravb_hw_info ravb_gen2_hw_info = {
@@ -2037,7 +2037,6 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
 	.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
 	.aligned_tx = 1,
-	.no_ptp_cfg_active = 1,
 };
 
 static const struct of_device_id ravb_match_table[] = {
@@ -2080,7 +2079,7 @@ static void ravb_set_config_mode(struct net_device *ndev)
 	struct ravb_private *priv = netdev_priv(ndev);
 	const struct ravb_hw_info *info = priv->info;
 
-	if (info->no_ptp_cfg_active) {
+	if (!info->no_gptp && !info->ccc_gac) {
 		ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG);
 		/* Set CSEL value */
 		ravb_modify(ndev, CCC, CCC_CSEL, CCC_CSEL_HPB);
@@ -2301,7 +2300,7 @@ static int ravb_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&priv->ts_skb_list);
 
 	/* Initialise PTP Clock driver */
-	if (info->ptp_cfg_active)
+	if (info->ccc_gac)
 		ravb_ptp_init(ndev, pdev);
 
 	/* Debug message level */
@@ -2349,7 +2348,7 @@ static int ravb_probe(struct platform_device *pdev)
 			  priv->desc_bat_dma);
 
 	/* Stop PTP Clock driver */
-	if (info->ptp_cfg_active)
+	if (info->ccc_gac)
 		ravb_ptp_stop(ndev);
 out_disable_refclk:
 	clk_disable_unprepare(priv->refclk);
@@ -2369,7 +2368,7 @@ static int ravb_remove(struct platform_device *pdev)
 	const struct ravb_hw_info *info = priv->info;
 
 	/* Stop PTP Clock driver */
-	if (info->ptp_cfg_active)
+	if (info->ccc_gac)
 		ravb_ptp_stop(ndev);
 
 	clk_disable_unprepare(priv->refclk);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
  2021-09-23 14:07 ` [RFC/PATCH 01/18] ravb: Rename "ravb_set_features_rx_csum" function to "ravb_set_features_rcar" Biju Das
  2021-09-23 14:07 ` [RFC/PATCH 02/18] ravb: Rename the variables "no_ptp_cfg_active" and "ptp_cfg_active" Biju Das
@ 2021-09-23 14:07 ` Biju Das
  2021-09-23 17:41   ` Sergey Shtylyov
  2021-09-23 19:07   ` Sergey Shtylyov
  2021-09-23 14:07 ` [RFC/PATCH 04/18] ravb: Enable aligned_tx and tx_counters for RZ/G2L Biju Das
                   ` (15 subsequent siblings)
  18 siblings, 2 replies; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:07 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

Initialize GbEthernet dmac found on RZ/G2L SoC.
This patch also renames ravb_rcar_dmac_init to ravb_dmac_init_rcar
to be consistent with the naming convention used in sh_eth driver.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb.h      |  4 ++
 drivers/net/ethernet/renesas/ravb_main.c | 84 +++++++++++++++++++++++-
 2 files changed, 85 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 0ce0c13ef8cb..bee05e6fb815 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -81,6 +81,7 @@ enum ravb_reg {
 	RQC3	= 0x00A0,
 	RQC4	= 0x00A4,
 	RPC	= 0x00B0,
+	RTC	= 0x00B4,	/* RZ/G2L only */
 	UFCW	= 0x00BC,
 	UFCS	= 0x00C0,
 	UFCV0	= 0x00C4,
@@ -156,6 +157,7 @@ enum ravb_reg {
 	TIS	= 0x037C,
 	ISS	= 0x0380,
 	CIE	= 0x0384,	/* R-Car Gen3 only */
+	RIC3	= 0x0388,	/* RZ/G2L only */
 	GCCR	= 0x0390,
 	GMTT	= 0x0394,
 	GPTC	= 0x0398,
@@ -956,6 +958,8 @@ enum RAVB_QUEUE {
 
 #define RX_BUF_SZ	(2048 - ETH_FCS_LEN + sizeof(__sum16))
 
+#define RGETH_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 2422e74d9b4f..54c4d31a6950 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_rgeth_set_rate(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_rgeth(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_rgeth(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_rgeth_alloc_rx_desc(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_rgeth_emac_init(struct net_device *ndev)
+{
+	/* Place holder */
+}
+
 static void ravb_rcar_emac_init(struct net_device *ndev)
 {
 	/* Receive frame limit set register */
@@ -461,7 +487,32 @@ static void ravb_emac_init(struct net_device *ndev)
 	info->emac_init(ndev);
 }
 
-static void ravb_rcar_dmac_init(struct net_device *ndev)
+static void ravb_dmac_init_rgeth(struct net_device *ndev)
+{
+	/* Set AVB RX */
+	ravb_write(ndev, 0x60000000, RCR);
+
+	/* Set Max Frame Length (RTC) */
+	ravb_write(ndev, 0x7ffc0000 | RGETH_RX_BUFF_MAX, RTC);
+
+	/* Set FIFO size */
+	ravb_write(ndev, 0x00222200, TGC);
+
+	ravb_write(ndev, 0, TCCR);
+
+	/* Frame receive */
+	ravb_write(ndev, RIC0_FRE0, RIC0);
+	/* Disable FIFO full warning */
+	ravb_write(ndev, 0x0, RIC1);
+	/* Receive FIFO full error, descriptor empty */
+	ravb_write(ndev, RIC2_QFE0 | RIC2_RFFE, RIC2);
+
+	ravb_write(ndev, 0x0, RIC3);
+
+	ravb_write(ndev, TIC_FTE0, TIC);
+}
+
+static void ravb_dmac_init_rcar(struct net_device *ndev)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
 	const struct ravb_hw_info *info = priv->info;
@@ -579,6 +630,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_rgeth_rx(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);
@@ -1918,6 +1977,13 @@ static void ravb_set_rx_csum(struct net_device *ndev, bool enable)
 	spin_unlock_irqrestore(&priv->lock, flags);
 }
 
+static int ravb_set_features_rgeth(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)
 {
@@ -2007,7 +2073,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
 	.receive = ravb_rcar_rx,
 	.set_rate = ravb_set_rate,
 	.set_feature = ravb_set_features_rcar,
-	.dmac_init = ravb_rcar_dmac_init,
+	.dmac_init = ravb_dmac_init_rcar,
 	.emac_init = ravb_rcar_emac_init,
 	.gstrings_stats = ravb_gstrings_stats,
 	.gstrings_size = sizeof(ravb_gstrings_stats),
@@ -2028,7 +2094,7 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.receive = ravb_rcar_rx,
 	.set_rate = ravb_set_rate,
 	.set_feature = ravb_set_features_rcar,
-	.dmac_init = ravb_rcar_dmac_init,
+	.dmac_init = ravb_dmac_init_rcar,
 	.emac_init = ravb_rcar_emac_init,
 	.gstrings_stats = ravb_gstrings_stats,
 	.gstrings_size = sizeof(ravb_gstrings_stats),
@@ -2039,12 +2105,24 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.aligned_tx = 1,
 };
 
+static const struct ravb_hw_info rgeth_hw_info = {
+	.rx_ring_free = ravb_rx_ring_free_rgeth,
+	.rx_ring_format = ravb_rx_ring_format_rgeth,
+	.alloc_rx_desc = ravb_rgeth_alloc_rx_desc,
+	.receive = ravb_rgeth_rx,
+	.set_rate = ravb_rgeth_set_rate,
+	.set_feature = ravb_set_features_rgeth,
+	.dmac_init = ravb_dmac_init_rgeth,
+	.emac_init = ravb_rgeth_emac_init,
+};
+
 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 = &rgeth_hw_info },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ravb_match_table);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 04/18] ravb: Enable aligned_tx and tx_counters for RZ/G2L
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
                   ` (2 preceding siblings ...)
  2021-09-23 14:07 ` [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac Biju Das
@ 2021-09-23 14:07 ` Biju Das
  2021-09-23 18:05   ` Sergey Shtylyov
  2021-09-23 14:08 ` [RFC/PATCH 05/18] ravb: Exclude gPTP feature support " Biju Das
                   ` (14 subsequent siblings)
  18 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:07 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

RZ/G2L need 4byte address alignment like R-Car Gen2 and
it has tx_counters like R-Car Gen3. This patch enable
these features for RZ/G2L.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb.h      | 2 +-
 drivers/net/ethernet/renesas/ravb_main.c | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index bee05e6fb815..bb92469d770e 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -195,7 +195,7 @@ enum ravb_reg {
 	GECMR	= 0x05b0,
 	MAHR	= 0x05c0,
 	MALR	= 0x05c8,
-	TROCR	= 0x0700,	/* R-Car Gen3 only */
+	TROCR	= 0x0700,	/* R-Car Gen3 and RZ/G2L only */
 	CEFCR	= 0x0740,
 	FRECR	= 0x0748,
 	TSFRCR	= 0x0750,
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 54c4d31a6950..d38fc33a8e93 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2114,6 +2114,8 @@ static const struct ravb_hw_info rgeth_hw_info = {
 	.set_feature = ravb_set_features_rgeth,
 	.dmac_init = ravb_dmac_init_rgeth,
 	.emac_init = ravb_rgeth_emac_init,
+	.aligned_tx = 1,
+	.tx_counters = 1,
 };
 
 static const struct of_device_id ravb_match_table[] = {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 05/18] ravb: Exclude gPTP feature support for RZ/G2L
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
                   ` (3 preceding siblings ...)
  2021-09-23 14:07 ` [RFC/PATCH 04/18] ravb: Enable aligned_tx and tx_counters for RZ/G2L Biju Das
@ 2021-09-23 14:08 ` Biju Das
  2021-09-23 19:00   ` Sergey Shtylyov
  2021-09-23 14:08 ` [RFC/PATCH 06/18] ravb: Add multi_tsrq to struct ravb_hw_info Biju Das
                   ` (13 subsequent siblings)
  18 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:08 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

R-Car supports gPTP feature whereas RZ/G2L does not support it.
This patch excludes gtp feature support for RZ/G2L by enabling
no_gptp feature bit.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb_main.c | 46 ++++++++++++++----------
 1 file changed, 28 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index d38fc33a8e93..8663d83507a0 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -918,6 +918,7 @@ static irqreturn_t ravb_interrupt(int irq, void *dev_id)
 {
 	struct net_device *ndev = dev_id;
 	struct ravb_private *priv = netdev_priv(ndev);
+	const struct ravb_hw_info *info = priv->info;
 	irqreturn_t result = IRQ_NONE;
 	u32 iss;
 
@@ -953,7 +954,7 @@ static irqreturn_t ravb_interrupt(int irq, void *dev_id)
 	}
 
 	/* gPTP interrupt status summary */
-	if (iss & ISS_CGIS) {
+	if (!info->no_gptp && (iss & ISS_CGIS)) {
 		ravb_ptp_interrupt(ndev);
 		result = IRQ_HANDLED;
 	}
@@ -1378,6 +1379,7 @@ static int ravb_get_ts_info(struct net_device *ndev,
 			    struct ethtool_ts_info *info)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
+	const struct ravb_hw_info *hw_info = priv->info;
 
 	info->so_timestamping =
 		SOF_TIMESTAMPING_TX_SOFTWARE |
@@ -1391,7 +1393,8 @@ static int ravb_get_ts_info(struct net_device *ndev,
 		(1 << HWTSTAMP_FILTER_NONE) |
 		(1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
 		(1 << HWTSTAMP_FILTER_ALL);
-	info->phc_index = ptp_clock_index(priv->ptp.clock);
+	if (!hw_info->no_gptp)
+		info->phc_index = ptp_clock_index(priv->ptp.clock);
 
 	return 0;
 }
@@ -2116,6 +2119,7 @@ static const struct ravb_hw_info rgeth_hw_info = {
 	.emac_init = ravb_rgeth_emac_init,
 	.aligned_tx = 1,
 	.tx_counters = 1,
+	.no_gptp = 1,
 };
 
 static const struct of_device_id ravb_match_table[] = {
@@ -2159,13 +2163,15 @@ static void ravb_set_config_mode(struct net_device *ndev)
 	struct ravb_private *priv = netdev_priv(ndev);
 	const struct ravb_hw_info *info = priv->info;
 
-	if (!info->no_gptp && !info->ccc_gac) {
+	if (info->no_gptp) {
 		ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG);
-		/* Set CSEL value */
-		ravb_modify(ndev, CCC, CCC_CSEL, CCC_CSEL_HPB);
-	} else {
+	} else if (info->ccc_gac) {
 		ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG |
 			    CCC_GAC | CCC_CSEL_HPB);
+	} else {
+		ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG);
+		/* Set CSEL value */
+		ravb_modify(ndev, CCC, CCC_CSEL, CCC_CSEL_HPB);
 	}
 }
 
@@ -2348,13 +2354,15 @@ static int ravb_probe(struct platform_device *pdev)
 	/* Set AVB config mode */
 	ravb_set_config_mode(ndev);
 
-	/* Set GTI value */
-	error = ravb_set_gti(ndev);
-	if (error)
-		goto out_disable_refclk;
+	if (!info->no_gptp) {
+		/* Set GTI value */
+		error = ravb_set_gti(ndev);
+		if (error)
+			goto out_disable_refclk;
 
-	/* Request GTI loading */
-	ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI);
+		/* Request GTI loading */
+		ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI);
+	}
 
 	if (info->internal_delay) {
 		ravb_parse_delay_mode(np, ndev);
@@ -2547,13 +2555,15 @@ static int __maybe_unused ravb_resume(struct device *dev)
 	/* Set AVB config mode */
 	ravb_set_config_mode(ndev);
 
-	/* Set GTI value */
-	ret = ravb_set_gti(ndev);
-	if (ret)
-		return ret;
+	if (!info->no_gptp) {
+		/* Set GTI value */
+		ret = ravb_set_gti(ndev);
+		if (ret)
+			return ret;
 
-	/* Request GTI loading */
-	ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI);
+		/* Request GTI loading */
+		ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI);
+	}
 
 	if (info->internal_delay)
 		ravb_set_delay_mode(ndev);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 06/18] ravb: Add multi_tsrq to struct ravb_hw_info
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
                   ` (4 preceding siblings ...)
  2021-09-23 14:08 ` [RFC/PATCH 05/18] ravb: Exclude gPTP feature support " Biju Das
@ 2021-09-23 14:08 ` Biju Das
  2021-09-23 20:19   ` Sergey Shtylyov
  2021-09-23 14:08 ` [RFC/PATCH 07/18] ravb: Add magic_pkt " Biju Das
                   ` (12 subsequent siblings)
  18 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:08 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

R-Car AVB-DMAC has 4 Transmit start Request queues, whereas
RZ/G2L has only 1 Transmit start Request queue(Best Effort)

Add a multi_tsrq hw feature bit to struct ravb_hw_info to enable
this only for R-Car. This will allow us to add single TSRQ support for
RZ/G2L.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb.h      |  1 +
 drivers/net/ethernet/renesas/ravb_main.c | 12 ++++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index bb92469d770e..c043ee555be4 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1006,6 +1006,7 @@ struct ravb_hw_info {
 	unsigned multi_irqs:1;		/* AVB-DMAC and E-MAC has multiple irqs */
 	unsigned no_gptp:1;		/* AVB-DMAC does not support gPTP feature */
 	unsigned ccc_gac:1;		/* AVB-DMAC has gPTP support active in config mode */
+	unsigned multi_tsrq:1;		/* AVB-DMAC has MULTI TSRQ */
 };
 
 struct ravb_private {
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 8663d83507a0..d37d73f6d984 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -776,11 +776,17 @@ static void ravb_rcv_snd_enable(struct net_device *ndev)
 /* function for waiting dma process finished */
 static int ravb_stop_dma(struct net_device *ndev)
 {
+	struct ravb_private *priv = netdev_priv(ndev);
+	const struct ravb_hw_info *info = priv->info;
 	int error;
 
 	/* Wait for stopping the hardware TX process */
-	error = ravb_wait(ndev, TCCR,
-			  TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3, 0);
+	if (info->multi_tsrq)
+		error = ravb_wait(ndev, TCCR,
+				  TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3, 0);
+	else
+		error = ravb_wait(ndev, TCCR, TCCR_TSRQ0, 0);
+
 	if (error)
 		return error;
 
@@ -2088,6 +2094,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
 	.tx_counters = 1,
 	.multi_irqs = 1,
 	.ccc_gac = 1,
+	.multi_tsrq = 1,
 };
 
 static const struct ravb_hw_info ravb_gen2_hw_info = {
@@ -2106,6 +2113,7 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
 	.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
 	.aligned_tx = 1,
+	.multi_tsrq = 1,
 };
 
 static const struct ravb_hw_info rgeth_hw_info = {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 07/18] ravb: Add magic_pkt to struct ravb_hw_info
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
                   ` (5 preceding siblings ...)
  2021-09-23 14:08 ` [RFC/PATCH 06/18] ravb: Add multi_tsrq to struct ravb_hw_info Biju Das
@ 2021-09-23 14:08 ` Biju Das
  2021-09-23 20:42   ` Sergey Shtylyov
  2021-09-23 14:08 ` [RFC/PATCH 08/18] ravb: Add mii_rgmii_selection " Biju Das
                   ` (11 subsequent siblings)
  18 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:08 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

E-MAC on R-Car supports magic packet detection, whereas RZ/G2L
do not support this feature. Add magic_pkt to struct ravb_hw_info
and enable this feature only for R-Car.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb.h      | 1 +
 drivers/net/ethernet/renesas/ravb_main.c | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index c043ee555be4..bce480fadb91 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1007,6 +1007,7 @@ struct ravb_hw_info {
 	unsigned no_gptp:1;		/* AVB-DMAC does not support gPTP feature */
 	unsigned ccc_gac:1;		/* AVB-DMAC has gPTP support active in config mode */
 	unsigned multi_tsrq:1;		/* AVB-DMAC has MULTI TSRQ */
+	unsigned magic_pkt:1;		/* E-MAC supports magic packet detection */
 };
 
 struct ravb_private {
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index d37d73f6d984..529364d8f7fb 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -811,12 +811,13 @@ static int ravb_stop_dma(struct net_device *ndev)
 static void ravb_emac_interrupt_unlocked(struct net_device *ndev)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
+	const struct ravb_hw_info *info = priv->info;
 	u32 ecsr, psr;
 
 	ecsr = ravb_read(ndev, ECSR);
 	ravb_write(ndev, ecsr, ECSR);	/* clear interrupt */
 
-	if (ecsr & ECSR_MPD)
+	if (info->magic_pkt && (ecsr & ECSR_MPD))
 		pm_wakeup_event(&priv->pdev->dev, 0);
 	if (ecsr & ECSR_ICD)
 		ndev->stats.tx_carrier_errors++;
@@ -1416,8 +1417,9 @@ static void ravb_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
 static int ravb_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
+	const struct ravb_hw_info *info = priv->info;
 
-	if (wol->wolopts & ~WAKE_MAGIC)
+	if (!info->magic_pkt || (wol->wolopts & ~WAKE_MAGIC))
 		return -EOPNOTSUPP;
 
 	priv->wol_enabled = !!(wol->wolopts & WAKE_MAGIC);
@@ -2095,6 +2097,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
 	.multi_irqs = 1,
 	.ccc_gac = 1,
 	.multi_tsrq = 1,
+	.magic_pkt = 1,
 };
 
 static const struct ravb_hw_info ravb_gen2_hw_info = {
@@ -2114,6 +2117,7 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
 	.aligned_tx = 1,
 	.multi_tsrq = 1,
+	.magic_pkt = 1,
 };
 
 static const struct ravb_hw_info rgeth_hw_info = {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 08/18] ravb: Add mii_rgmii_selection to struct ravb_hw_info
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
                   ` (6 preceding siblings ...)
  2021-09-23 14:08 ` [RFC/PATCH 07/18] ravb: Add magic_pkt " Biju Das
@ 2021-09-23 14:08 ` Biju Das
  2021-09-24 19:49   ` Sergey Shtylyov
  2021-09-23 14:08 ` [RFC/PATCH 09/18] ravb: Add half_duplex " Biju Das
                   ` (10 subsequent siblings)
  18 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:08 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

E-MAC on RZ/G2L supports MII/RGMII selection. Add a
mii_rgmii_selection feature bit to struct ravb_hw_info
to support this for RZ/G2L.
Currently only selecting RGMII is supported.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb.h      | 17 +++++++++++++++++
 drivers/net/ethernet/renesas/ravb_main.c |  6 ++++++
 2 files changed, 23 insertions(+)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index bce480fadb91..dfaf3121da44 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -189,6 +189,8 @@ enum ravb_reg {
 	PIR	= 0x0520,
 	PSR	= 0x0528,
 	PIPR	= 0x052c,
+	CXR31	= 0x0530,	/* Documented for RZ/G2L only */
+	CXR35	= 0x0540,	/* Documented for RZ/G2L only */
 	MPR	= 0x0558,
 	PFTCR	= 0x055c,
 	PFRCR	= 0x0560,
@@ -951,6 +953,20 @@ enum RAVB_QUEUE {
 	RAVB_NC,	/* Network Control Queue */
 };
 
+enum CXR31_BIT {
+	CXR31_SEL_LINK0	= 0x00000001,
+	CXR31_SEL_LINK1	= 0x00000008,
+};
+
+enum CXR35_BIT {
+	CXR35_SEL_MODIN	= 0x00000100,
+};
+
+enum CSR0_BIT {
+	CSR0_TPE	= 0x00000010,
+	CSR0_RPE	= 0x00000020,
+};
+
 #define DBAT_ENTRY_NUM	22
 #define RX_QUEUE_OFFSET	4
 #define NUM_RX_QUEUE	2
@@ -1008,6 +1024,7 @@ struct ravb_hw_info {
 	unsigned ccc_gac:1;		/* AVB-DMAC has gPTP support active in config mode */
 	unsigned multi_tsrq:1;		/* AVB-DMAC has MULTI TSRQ */
 	unsigned magic_pkt:1;		/* E-MAC supports magic packet detection */
+	unsigned mii_rgmii_selection:1;	/* E-MAC supports mii/rgmii selection */
 };
 
 struct ravb_private {
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 529364d8f7fb..5d18681582b9 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1128,6 +1128,7 @@ static int ravb_phy_init(struct net_device *ndev)
 {
 	struct device_node *np = ndev->dev.parent->of_node;
 	struct ravb_private *priv = netdev_priv(ndev);
+	const struct ravb_hw_info *info = priv->info;
 	struct phy_device *phydev;
 	struct device_node *pn;
 	phy_interface_t iface;
@@ -1173,6 +1174,10 @@ static int ravb_phy_init(struct net_device *ndev)
 		netdev_info(ndev, "limited PHY to 100Mbit/s\n");
 	}
 
+	if (info->mii_rgmii_selection &&
+	    priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID)
+		ravb_write(ndev, ravb_read(ndev, CXR35) | CXR35_SEL_MODIN, CXR35);
+
 	/* 10BASE, Pause and Asym Pause is not supported */
 	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Half_BIT);
 	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Full_BIT);
@@ -2132,6 +2137,7 @@ static const struct ravb_hw_info rgeth_hw_info = {
 	.aligned_tx = 1,
 	.tx_counters = 1,
 	.no_gptp = 1,
+	.mii_rgmii_selection = 1,
 };
 
 static const struct of_device_id ravb_match_table[] = {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 09/18] ravb: Add half_duplex to struct ravb_hw_info
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
                   ` (7 preceding siblings ...)
  2021-09-23 14:08 ` [RFC/PATCH 08/18] ravb: Add mii_rgmii_selection " Biju Das
@ 2021-09-23 14:08 ` Biju Das
  2021-09-24 20:07   ` Sergey Shtylyov
  2021-09-23 14:08 ` [RFC/PATCH 10/18] ravb: Initialize GbEthernet E-MAC Biju Das
                   ` (9 subsequent siblings)
  18 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:08 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

RZ/G2L supports half duplex mode.
Add a half_duplex hw feature bit to struct ravb_hw_info for
supporting half duplex mode for RZ/G2L.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb.h      |  3 ++
 drivers/net/ethernet/renesas/ravb_main.c | 40 +++++++++++++++++++-----
 2 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index dfaf3121da44..7f68f9b8349c 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1025,6 +1025,7 @@ struct ravb_hw_info {
 	unsigned multi_tsrq:1;		/* AVB-DMAC has MULTI TSRQ */
 	unsigned magic_pkt:1;		/* E-MAC supports magic packet detection */
 	unsigned mii_rgmii_selection:1;	/* E-MAC supports mii/rgmii selection */
+	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
 };
 
 struct ravb_private {
@@ -1079,6 +1080,8 @@ struct ravb_private {
 	unsigned rgmii_override:1;	/* Deprecated rgmii-*id behavior */
 	unsigned int num_tx_desc;	/* TX descriptors per packet */
 
+	int duplex;
+
 	const struct ravb_hw_info *info;
 	struct reset_control *rstc;
 };
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 5d18681582b9..04bff44b7660 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1076,6 +1076,18 @@ static int ravb_poll(struct napi_struct *napi, int budget)
 	return budget - quota;
 }
 
+static void ravb_set_duplex_rgeth(struct net_device *ndev)
+{
+	struct ravb_private *priv = netdev_priv(ndev);
+	u32 ecmr = ravb_read(ndev, ECMR);
+
+	if (priv->duplex > 0)	/* Full */
+		ecmr |=  ECMR_DM;
+	else			/* Half */
+		ecmr &= ~ECMR_DM;
+	ravb_write(ndev, ecmr, ECMR);
+}
+
 /* PHY state control function */
 static void ravb_adjust_link(struct net_device *ndev)
 {
@@ -1092,6 +1104,12 @@ static void ravb_adjust_link(struct net_device *ndev)
 		ravb_rcv_snd_disable(ndev);
 
 	if (phydev->link) {
+		if (info->half_duplex && phydev->duplex != priv->duplex) {
+			new_state = true;
+			priv->duplex = phydev->duplex;
+			ravb_set_duplex_rgeth(ndev);
+		}
+
 		if (phydev->speed != priv->speed) {
 			new_state = true;
 			priv->speed = phydev->speed;
@@ -1106,6 +1124,8 @@ static void ravb_adjust_link(struct net_device *ndev)
 		new_state = true;
 		priv->link = 0;
 		priv->speed = 0;
+		if (info->half_duplex)
+			priv->duplex = -1;
 	}
 
 	/* Enable TX and RX right over here, if E-MAC change is ignored */
@@ -1136,6 +1156,7 @@ static int ravb_phy_init(struct net_device *ndev)
 
 	priv->link = 0;
 	priv->speed = 0;
+	priv->duplex = -1;
 
 	/* Try connecting to PHY */
 	pn = of_parse_phandle(np, "phy-handle", 0);
@@ -1178,15 +1199,17 @@ static int ravb_phy_init(struct net_device *ndev)
 	    priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID)
 		ravb_write(ndev, ravb_read(ndev, CXR35) | CXR35_SEL_MODIN, CXR35);
 
-	/* 10BASE, Pause and Asym Pause is not supported */
-	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Half_BIT);
-	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Full_BIT);
-	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_Pause_BIT);
-	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_Asym_Pause_BIT);
+	if (!info->half_duplex) {
+		/* 10BASE, Pause and Asym Pause is not supported */
+		phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Half_BIT);
+		phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Full_BIT);
+		phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_Pause_BIT);
+		phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_Asym_Pause_BIT);
 
-	/* Half Duplex is not supported */
-	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_1000baseT_Half_BIT);
-	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_100baseT_Half_BIT);
+		/* Half Duplex is not supported */
+		phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_1000baseT_Half_BIT);
+		phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_100baseT_Half_BIT);
+	}
 
 	phy_attached_info(phydev);
 
@@ -2138,6 +2161,7 @@ static const struct ravb_hw_info rgeth_hw_info = {
 	.tx_counters = 1,
 	.no_gptp = 1,
 	.mii_rgmii_selection = 1,
+	.half_duplex = 1,
 };
 
 static const struct of_device_id ravb_match_table[] = {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 10/18] ravb: Initialize GbEthernet E-MAC
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
                   ` (8 preceding siblings ...)
  2021-09-23 14:08 ` [RFC/PATCH 09/18] ravb: Add half_duplex " Biju Das
@ 2021-09-23 14:08 ` Biju Das
  2021-09-24 20:44   ` Sergey Shtylyov
  2021-09-23 14:08 ` [RFC/PATCH 11/18] ravb: Add rx_2k_buffers to struct ravb_hw_info Biju Das
                   ` (8 subsequent siblings)
  18 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:08 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

Initialize GbEthernet E-MAC found on RZ/G2L SoC.
This patch also renames ravb_set_rate to ravb_set_rate_rcar and
ravb_rcar_emac_init to ravb_emac_init_rcar to be consistent with
the naming convention used in sh_eth driver.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb.h      | 15 ++++--
 drivers/net/ethernet/renesas/ravb_main.c | 64 +++++++++++++++++++-----
 2 files changed, 62 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 7f68f9b8349c..7532cb51d7b8 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -204,6 +204,7 @@ enum ravb_reg {
 	TLFRCR	= 0x0758,
 	RFCR	= 0x0760,
 	MAFCR	= 0x0778,
+	CSR0     = 0x0800,	/* Documented for RZ/G2L only */
 };
 
 
@@ -814,10 +815,11 @@ enum ECMR_BIT {
 	ECMR_TXF	= 0x00010000,	/* Documented for R-Car Gen3 only */
 	ECMR_RXF	= 0x00020000,
 	ECMR_PFR	= 0x00040000,
-	ECMR_ZPF	= 0x00080000,	/* Documented for R-Car Gen3 only */
+	ECMR_ZPF	= 0x00080000,	/* Documented for R-Car Gen3 and RZ/G2L */
 	ECMR_RZPF	= 0x00100000,
 	ECMR_DPAD	= 0x00200000,
 	ECMR_RCSC	= 0x00800000,
+	ECMR_RCPT	= 0x02000000,	/* Documented for RZ/G2L only */
 	ECMR_TRCCM	= 0x04000000,
 };
 
@@ -827,6 +829,7 @@ enum ECSR_BIT {
 	ECSR_MPD	= 0x00000002,
 	ECSR_LCHNG	= 0x00000004,
 	ECSR_PHYI	= 0x00000008,
+	ECSR_PFRI	= 0x00000010,
 };
 
 /* ECSIPR */
@@ -861,9 +864,13 @@ enum MPR_BIT {
 
 /* GECMR */
 enum GECMR_BIT {
-	GECMR_SPEED	= 0x00000001,
-	GECMR_SPEED_100	= 0x00000000,
-	GECMR_SPEED_1000 = 0x00000001,
+	GECMR_SPEED		= 0x00000001,
+	GECMR_SPEED_100		= 0x00000000,
+	GECMR_SPEED_1000	= 0x00000001,
+	RGETH_GECMR_SPEED	= 0x00000030,
+	RGETH_GECMR_SPEED_10	= 0x00000000,
+	RGETH_GECMR_SPEED_100	= 0x00000010,
+	RGETH_GECMR_SPEED_1000	= 0x00000020,
 };
 
 /* The Ethernet AVB descriptor definitions. */
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 04bff44b7660..7f06adbd00e1 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -83,12 +83,24 @@ static int ravb_config(struct net_device *ndev)
 	return error;
 }
 
-static void ravb_rgeth_set_rate(struct net_device *ndev)
+static void ravb_set_rate_rgeth(struct net_device *ndev)
 {
-	/* Place holder */
+	struct ravb_private *priv = netdev_priv(ndev);
+
+	switch (priv->speed) {
+	case 10:                /* 10BASE */
+		ravb_write(ndev, RGETH_GECMR_SPEED_10, GECMR);
+		break;
+	case 100:               /* 100BASE */
+		ravb_write(ndev, RGETH_GECMR_SPEED_100, GECMR);
+		break;
+	case 1000:              /* 1000BASE */
+		ravb_write(ndev, RGETH_GECMR_SPEED_1000, GECMR);
+		break;
+	}
 }
 
-static void ravb_set_rate(struct net_device *ndev)
+static void ravb_set_rate_rcar(struct net_device *ndev)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
 
@@ -447,12 +459,38 @@ static int ravb_ring_init(struct net_device *ndev, int q)
 	return -ENOMEM;
 }
 
-static void ravb_rgeth_emac_init(struct net_device *ndev)
+static void ravb_emac_init_rgeth(struct net_device *ndev)
 {
-	/* Place holder */
+	struct ravb_private *priv = netdev_priv(ndev);
+
+	/* Receive frame limit set register */
+	ravb_write(ndev, RGETH_RX_BUFF_MAX + ETH_FCS_LEN, RFLR);
+
+	/* PAUSE prohibition */
+	ravb_write(ndev, ECMR_ZPF | ((priv->duplex > 0) ? ECMR_DM : 0) |
+			 ECMR_TE | ECMR_RE | ECMR_RCPT |
+			 ECMR_TXF | ECMR_RXF | ECMR_PRM, ECMR);
+
+	ravb_set_rate_rgeth(ndev);
+
+	/* Set MAC address */
+	ravb_write(ndev,
+		   (ndev->dev_addr[0] << 24) | (ndev->dev_addr[1] << 16) |
+		   (ndev->dev_addr[2] << 8)  | (ndev->dev_addr[3]), MAHR);
+	ravb_write(ndev, (ndev->dev_addr[4] << 8)  | (ndev->dev_addr[5]), MALR);
+
+	/* E-MAC status register clear */
+	ravb_write(ndev, ECSR_ICD | ECSR_LCHNG | ECSR_PFRI, ECSR);
+	ravb_write(ndev, CSR0_TPE | CSR0_RPE, CSR0);
+
+	/* E-MAC interrupt enable register */
+	ravb_write(ndev, ECSIPR_ICDIP, ECSIPR);
+
+	ravb_write(ndev, ravb_read(ndev, CXR31) & ~CXR31_SEL_LINK1, CXR31);
+	ravb_write(ndev, ravb_read(ndev, CXR31) | CXR31_SEL_LINK0, CXR31);
 }
 
-static void ravb_rcar_emac_init(struct net_device *ndev)
+static void ravb_emac_init_rcar(struct net_device *ndev)
 {
 	/* Receive frame limit set register */
 	ravb_write(ndev, ndev->mtu + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN, RFLR);
@@ -462,7 +500,7 @@ static void ravb_rcar_emac_init(struct net_device *ndev)
 		   (ndev->features & NETIF_F_RXCSUM ? ECMR_RCSC : 0) |
 		   ECMR_TE | ECMR_RE, ECMR);
 
-	ravb_set_rate(ndev);
+	ravb_set_rate_rcar(ndev);
 
 	/* Set MAC address */
 	ravb_write(ndev,
@@ -2110,10 +2148,10 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
 	.rx_ring_format = ravb_rx_ring_format,
 	.alloc_rx_desc = ravb_alloc_rx_desc,
 	.receive = ravb_rcar_rx,
-	.set_rate = ravb_set_rate,
+	.set_rate = ravb_set_rate_rcar,
 	.set_feature = ravb_set_features_rcar,
 	.dmac_init = ravb_dmac_init_rcar,
-	.emac_init = ravb_rcar_emac_init,
+	.emac_init = ravb_emac_init_rcar,
 	.gstrings_stats = ravb_gstrings_stats,
 	.gstrings_size = sizeof(ravb_gstrings_stats),
 	.net_hw_features = NETIF_F_RXCSUM,
@@ -2133,10 +2171,10 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.rx_ring_format = ravb_rx_ring_format,
 	.alloc_rx_desc = ravb_alloc_rx_desc,
 	.receive = ravb_rcar_rx,
-	.set_rate = ravb_set_rate,
+	.set_rate = ravb_set_rate_rcar,
 	.set_feature = ravb_set_features_rcar,
 	.dmac_init = ravb_dmac_init_rcar,
-	.emac_init = ravb_rcar_emac_init,
+	.emac_init = ravb_emac_init_rcar,
 	.gstrings_stats = ravb_gstrings_stats,
 	.gstrings_size = sizeof(ravb_gstrings_stats),
 	.net_hw_features = NETIF_F_RXCSUM,
@@ -2153,10 +2191,10 @@ static const struct ravb_hw_info rgeth_hw_info = {
 	.rx_ring_format = ravb_rx_ring_format_rgeth,
 	.alloc_rx_desc = ravb_rgeth_alloc_rx_desc,
 	.receive = ravb_rgeth_rx,
-	.set_rate = ravb_rgeth_set_rate,
+	.set_rate = ravb_set_rate_rgeth,
 	.set_feature = ravb_set_features_rgeth,
 	.dmac_init = ravb_dmac_init_rgeth,
-	.emac_init = ravb_rgeth_emac_init,
+	.emac_init = ravb_emac_init_rgeth,
 	.aligned_tx = 1,
 	.tx_counters = 1,
 	.no_gptp = 1,
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 11/18] ravb: Add rx_2k_buffers to struct ravb_hw_info
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
                   ` (9 preceding siblings ...)
  2021-09-23 14:08 ` [RFC/PATCH 10/18] ravb: Initialize GbEthernet E-MAC Biju Das
@ 2021-09-23 14:08 ` Biju Das
  2021-09-24 19:35   ` Sergey Shtylyov
  2021-09-23 14:08 ` [RFC/PATCH 12/18] ravb: Add timestamp " Biju Das
                   ` (7 subsequent siblings)
  18 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:08 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

R-Car AVB-DMAC has Maximum 2K size on RZ buffer.
We need to Allow for changing the MTU within the
limit of the maximum size of a descriptor (2048 bytes).

Add a rx_2k_buffers hw feature bit to struct ravb_hw_info
to add this constraint only for R-Car.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb.h      | 1 +
 drivers/net/ethernet/renesas/ravb_main.c | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 7532cb51d7b8..ab4909244276 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1033,6 +1033,7 @@ struct ravb_hw_info {
 	unsigned magic_pkt:1;		/* E-MAC supports magic packet detection */
 	unsigned mii_rgmii_selection:1;	/* E-MAC supports mii/rgmii selection */
 	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
+	unsigned rx_2k_buffers:1;	/* AVB-DMAC has Max 2K buf size on RX */
 };
 
 struct ravb_private {
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 7f06adbd00e1..9c0d35f4b221 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2164,6 +2164,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
 	.ccc_gac = 1,
 	.multi_tsrq = 1,
 	.magic_pkt = 1,
+	.rx_2k_buffers = 1,
 };
 
 static const struct ravb_hw_info ravb_gen2_hw_info = {
@@ -2184,6 +2185,7 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.aligned_tx = 1,
 	.multi_tsrq = 1,
 	.magic_pkt = 1,
+	.rx_2k_buffers = 1,
 };
 
 static const struct ravb_hw_info rgeth_hw_info = {
@@ -2417,8 +2419,10 @@ static int ravb_probe(struct platform_device *pdev)
 	}
 	clk_prepare_enable(priv->refclk);
 
-	ndev->max_mtu = 2048 - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN);
-	ndev->min_mtu = ETH_MIN_MTU;
+	if (info->rx_2k_buffers) {
+		ndev->max_mtu = 2048 - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN);
+		ndev->min_mtu = ETH_MIN_MTU;
+	}
 
 	/* FIXME: R-Car Gen2 has 4byte alignment restriction for tx buffer
 	 * Use two descriptor to handle such situation. First descriptor to
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 12/18] ravb: Add timestamp to struct ravb_hw_info
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
                   ` (10 preceding siblings ...)
  2021-09-23 14:08 ` [RFC/PATCH 11/18] ravb: Add rx_2k_buffers to struct ravb_hw_info Biju Das
@ 2021-09-23 14:08 ` Biju Das
  2021-09-25 20:52   ` Sergey Shtylyov
  2021-09-23 14:08 ` [RFC/PATCH 13/18] ravb: Add rx_ring_free function support for GbEthernet Biju Das
                   ` (6 subsequent siblings)
  18 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:08 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

R-Car AVB-DMAC supports timestamp feature.
Add a timestamp hw feature bit to struct ravb_hw_info
to add this feature only for R-Car.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb.h      |  2 +
 drivers/net/ethernet/renesas/ravb_main.c | 68 +++++++++++++++---------
 2 files changed, 45 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index ab4909244276..2505de5d4a28 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1034,6 +1034,7 @@ struct ravb_hw_info {
 	unsigned mii_rgmii_selection:1;	/* E-MAC supports mii/rgmii selection */
 	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
 	unsigned rx_2k_buffers:1;	/* AVB-DMAC has Max 2K buf size on RX */
+	unsigned timestamp:1;		/* AVB-DMAC has timestamp */
 };
 
 struct ravb_private {
@@ -1089,6 +1090,7 @@ struct ravb_private {
 	unsigned int num_tx_desc;	/* TX descriptors per packet */
 
 	int duplex;
+	struct ravb_rx_desc *rgeth_rx_ring[NUM_RX_QUEUE];
 
 	const struct ravb_hw_info *info;
 	struct reset_control *rstc;
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 9c0d35f4b221..2c375002ebcb 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -949,11 +949,14 @@ static bool ravb_queue_interrupt(struct net_device *ndev, int q)
 
 static bool ravb_timestamp_interrupt(struct net_device *ndev)
 {
+	struct ravb_private *priv = netdev_priv(ndev);
+	const struct ravb_hw_info *info = priv->info;
 	u32 tis = ravb_read(ndev, TIS);
 
 	if (tis & TIS_TFUF) {
 		ravb_write(ndev, ~(TIS_TFUF | TIS_RESERVED), TIS);
-		ravb_get_tx_tstamp(ndev);
+		if (info->timestamp)
+			ravb_get_tx_tstamp(ndev);
 		return true;
 	}
 	return false;
@@ -1071,16 +1074,24 @@ static int ravb_poll(struct napi_struct *napi, int budget)
 	struct net_device *ndev = napi->dev;
 	struct ravb_private *priv = netdev_priv(ndev);
 	const struct ravb_hw_info *info = priv->info;
+	struct ravb_rx_desc *desc;
 	unsigned long flags;
 	int q = napi - priv->napi;
 	int mask = BIT(q);
 	int quota = budget;
+	unsigned int entry;
 
+	if (!info->timestamp) {
+		entry = priv->cur_rx[q] % priv->num_rx_ring[q];
+		desc = &priv->rgeth_rx_ring[q][entry];
+	}
 	/* Processing RX Descriptor Ring */
 	/* Clear RX interrupt */
 	ravb_write(ndev, ~(mask | RIS0_RESERVED), RIS0);
-	if (ravb_rx(ndev, &quota, q))
-		goto out;
+	if (info->timestamp || desc->die_dt != DT_FEMPTY) {
+		if (ravb_rx(ndev, &quota, q))
+			goto out;
+	}
 
 	/* Processing TX Descriptor Ring */
 	spin_lock_irqsave(&priv->lock, flags);
@@ -1689,6 +1700,7 @@ static void ravb_tx_timeout_work(struct work_struct *work)
 static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
+	const struct ravb_hw_info *info = priv->info;
 	unsigned int num_tx_desc = priv->num_tx_desc;
 	u16 q = skb_get_queue_mapping(skb);
 	struct ravb_tstamp_skb *ts_skb;
@@ -1765,28 +1777,30 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev)
 	desc->dptr = cpu_to_le32(dma_addr);
 
 	/* TX timestamp required */
-	if (q == RAVB_NC) {
-		ts_skb = kmalloc(sizeof(*ts_skb), GFP_ATOMIC);
-		if (!ts_skb) {
-			if (num_tx_desc > 1) {
-				desc--;
-				dma_unmap_single(ndev->dev.parent, dma_addr,
-						 len, DMA_TO_DEVICE);
+	if (info->timestamp) {
+		if (q == RAVB_NC) {
+			ts_skb = kmalloc(sizeof(*ts_skb), GFP_ATOMIC);
+			if (!ts_skb) {
+				if (num_tx_desc > 1) {
+					desc--;
+					dma_unmap_single(ndev->dev.parent, dma_addr,
+							 len, DMA_TO_DEVICE);
+				}
+				goto unmap;
 			}
-			goto unmap;
+			ts_skb->skb = skb_get(skb);
+			ts_skb->tag = priv->ts_skb_tag++;
+			priv->ts_skb_tag &= 0x3ff;
+			list_add_tail(&ts_skb->list, &priv->ts_skb_list);
+
+			/* TAG and timestamp required flag */
+			skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
+			desc->tagh_tsr = (ts_skb->tag >> 4) | TX_TSR;
+			desc->ds_tagl |= cpu_to_le16(ts_skb->tag << 12);
 		}
-		ts_skb->skb = skb_get(skb);
-		ts_skb->tag = priv->ts_skb_tag++;
-		priv->ts_skb_tag &= 0x3ff;
-		list_add_tail(&ts_skb->list, &priv->ts_skb_list);
 
-		/* TAG and timestamp required flag */
-		skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
-		desc->tagh_tsr = (ts_skb->tag >> 4) | TX_TSR;
-		desc->ds_tagl |= cpu_to_le16(ts_skb->tag << 12);
+		skb_tx_timestamp(skb);
 	}
-
-	skb_tx_timestamp(skb);
 	/* Descriptor type must be set after all the above writes */
 	dma_wmb();
 	if (num_tx_desc > 1) {
@@ -1897,10 +1911,12 @@ static int ravb_close(struct net_device *ndev)
 			   "device will be stopped after h/w processes are done.\n");
 
 	/* Clear the timestamp list */
-	list_for_each_entry_safe(ts_skb, ts_skb2, &priv->ts_skb_list, list) {
-		list_del(&ts_skb->list);
-		kfree_skb(ts_skb->skb);
-		kfree(ts_skb);
+	if (info->timestamp) {
+		list_for_each_entry_safe(ts_skb, ts_skb2, &priv->ts_skb_list, list) {
+			list_del(&ts_skb->list);
+			kfree_skb(ts_skb->skb);
+			kfree(ts_skb);
+		}
 	}
 
 	/* PHY disconnect */
@@ -2165,6 +2181,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
 	.multi_tsrq = 1,
 	.magic_pkt = 1,
 	.rx_2k_buffers = 1,
+	.timestamp = 1,
 };
 
 static const struct ravb_hw_info ravb_gen2_hw_info = {
@@ -2186,6 +2203,7 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.multi_tsrq = 1,
 	.magic_pkt = 1,
 	.rx_2k_buffers = 1,
+	.timestamp = 1,
 };
 
 static const struct ravb_hw_info rgeth_hw_info = {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 13/18] ravb: Add rx_ring_free function support for GbEthernet
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
                   ` (11 preceding siblings ...)
  2021-09-23 14:08 ` [RFC/PATCH 12/18] ravb: Add timestamp " Biju Das
@ 2021-09-23 14:08 ` Biju Das
  2021-09-27 19:28   ` Sergey Shtylyov
  2021-09-23 14:08 ` [RFC/PATCH 14/18] ravb: Add rx_ring_format function " Biju Das
                   ` (5 subsequent siblings)
  18 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:08 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

This patch adds rx_ring_free function support for GbEthernet
found on RZ/G2L SoC.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb_main.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 2c375002ebcb..038af36141bb 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -236,7 +236,27 @@ static int ravb_tx_free(struct net_device *ndev, int q, bool free_txed_only)
 
 static void ravb_rx_ring_free_rgeth(struct net_device *ndev, int q)
 {
-	/* Place holder */
+	struct ravb_private *priv = netdev_priv(ndev);
+	unsigned int ring_size;
+	unsigned int i;
+
+	if (!priv->rgeth_rx_ring[q])
+		return;
+
+	for (i = 0; i < priv->num_rx_ring[q]; i++) {
+		struct ravb_rx_desc *desc = &priv->rgeth_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),
+					 RGETH_RX_BUFF_MAX,
+					 DMA_FROM_DEVICE);
+	}
+	ring_size = sizeof(struct ravb_rx_desc) * (priv->num_rx_ring[q] + 1);
+	dma_free_coherent(ndev->dev.parent, ring_size, priv->rgeth_rx_ring[q],
+			  priv->rx_desc_dma[q]);
+	priv->rgeth_rx_ring[q] = NULL;
 }
 
 static void ravb_rx_ring_free(struct net_device *ndev, int q)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 14/18] ravb: Add rx_ring_format function for GbEthernet
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
                   ` (12 preceding siblings ...)
  2021-09-23 14:08 ` [RFC/PATCH 13/18] ravb: Add rx_ring_free function support for GbEthernet Biju Das
@ 2021-09-23 14:08 ` Biju Das
  2021-09-27 20:32   ` Sergey Shtylyov
  2021-09-23 14:08 ` [RFC/PATCH 15/18] ravb: Add rx_alloc helper " Biju Das
                   ` (4 subsequent siblings)
  18 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:08 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

This patch adds rx_ring_format function for GbEthernet found on
RZ/G2L SoC.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb.h      |  1 +
 drivers/net/ethernet/renesas/ravb_main.c | 27 +++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 2505de5d4a28..b0e067a6a8ee 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -982,6 +982,7 @@ enum CSR0_BIT {
 #define RX_BUF_SZ	(2048 - ETH_FCS_LEN + sizeof(__sum16))
 
 #define RGETH_RX_BUFF_MAX 8192
+#define RGETH_RX_DESC_DATA_SIZE 4080
 
 struct ravb_tstamp_skb {
 	struct list_head list;
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 038af36141bb..ee1066fedc4a 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -327,7 +327,32 @@ static void ravb_ring_free(struct net_device *ndev, int q)
 
 static void ravb_rx_ring_format_rgeth(struct net_device *ndev, int q)
 {
-	/* Place holder */
+	struct ravb_private *priv = netdev_priv(ndev);
+	struct ravb_rx_desc *rx_desc;
+	unsigned int rx_ring_size = sizeof(*rx_desc) * priv->num_rx_ring[q];
+	dma_addr_t dma_addr;
+	unsigned int i;
+
+	memset(priv->rgeth_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->rgeth_rx_ring[q][i];
+		rx_desc->ds_cc = cpu_to_le16(RGETH_RX_DESC_DATA_SIZE);
+		dma_addr = dma_map_single(ndev->dev.parent, priv->rx_skb[q][i]->data,
+					  RGETH_RX_BUFF_MAX,
+					  DMA_FROM_DEVICE);
+		/* We just set the data size to 0 for a failed mapping which
+		 * should prevent DMA from happening...
+		 */
+		if (dma_mapping_error(ndev->dev.parent, dma_addr))
+			rx_desc->ds_cc = cpu_to_le16(0);
+		rx_desc->dptr = cpu_to_le32(dma_addr);
+		rx_desc->die_dt = DT_FEMPTY;
+	}
+	rx_desc = &priv->rgeth_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_rx_ring_format(struct net_device *ndev, int q)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 15/18] ravb: Add rx_alloc helper function for GbEthernet
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
                   ` (13 preceding siblings ...)
  2021-09-23 14:08 ` [RFC/PATCH 14/18] ravb: Add rx_ring_format function " Biju Das
@ 2021-09-23 14:08 ` Biju Das
  2021-09-23 14:08 ` [RFC/PATCH 16/18] ravb: Add Packet receive function for Gigabit Ethernet Biju Das
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:08 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

This patch adds rx_alloc helper function for GbEthernet found on
RZ/G2L SoC.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb_main.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index ee1066fedc4a..a08da7a37b92 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -430,8 +430,15 @@ static void ravb_ring_format(struct net_device *ndev, int q)
 
 static void *ravb_rgeth_alloc_rx_desc(struct net_device *ndev, int q)
 {
-	/* Place holder */
-	return NULL;
+	struct ravb_private *priv = netdev_priv(ndev);
+	unsigned int ring_size;
+
+	ring_size = sizeof(struct ravb_rx_desc) * (priv->num_rx_ring[q] + 1);
+
+	priv->rgeth_rx_ring[q] = dma_alloc_coherent(ndev->dev.parent, ring_size,
+						    &priv->rx_desc_dma[q],
+						    GFP_KERNEL);
+	return priv->rgeth_rx_ring[q];
 }
 
 static void *ravb_alloc_rx_desc(struct net_device *ndev, int q)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 16/18] ravb: Add Packet receive function for Gigabit Ethernet
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
                   ` (14 preceding siblings ...)
  2021-09-23 14:08 ` [RFC/PATCH 15/18] ravb: Add rx_alloc helper " Biju Das
@ 2021-09-23 14:08 ` Biju Das
  2021-10-01 17:27   ` Sergey Shtylyov
  2021-09-23 14:08 ` [RFC/PATCH 17/18] ravb: Add carrier_counters to struct ravb_hw_info Biju Das
                   ` (2 subsequent siblings)
  18 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:08 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

This patch series adds RX(packet receive) function for
Gigabit Ethernet found on RZ/G2L SoC.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb.h      |   1 +
 drivers/net/ethernet/renesas/ravb_main.c | 157 ++++++++++++++++++++++-
 2 files changed, 156 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index b0e067a6a8ee..85260f89e1cd 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1092,6 +1092,7 @@ struct ravb_private {
 
 	int duplex;
 	struct ravb_rx_desc *rgeth_rx_ring[NUM_RX_QUEUE];
+	struct sk_buff *rxtop_skb;
 
 	const struct ravb_hw_info *info;
 	struct reset_control *rstc;
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index a08da7a37b92..867e180e6655 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -705,6 +705,23 @@ static void ravb_get_tx_tstamp(struct net_device *ndev)
 	}
 }
 
+static void ravb_rx_csum_rgeth(struct sk_buff *skb)
+{
+	u8 *hw_csum;
+
+	/* The hardware checksum is contained in sizeof(__sum16) (2) bytes
+	 * appended to packet data
+	 */
+	if (unlikely(skb->len < sizeof(__sum16)))
+		return;
+	hw_csum = skb_tail_pointer(skb) - sizeof(__sum16);
+
+	if (*hw_csum == 0)
+		skb->ip_summed = CHECKSUM_UNNECESSARY;
+	else
+		skb->ip_summed = CHECKSUM_NONE;
+}
+
 static void ravb_rx_csum(struct sk_buff *skb)
 {
 	u8 *hw_csum;
@@ -720,11 +737,147 @@ static void ravb_rx_csum(struct sk_buff *skb)
 	skb_trim(skb, skb->len - sizeof(__sum16));
 }
 
+static struct sk_buff *ravb_get_skb_rgeth(struct net_device *ndev,  int q,
+					  int entry, struct ravb_rx_desc *desc)
+{
+	struct ravb_private *priv = netdev_priv(ndev);
+	struct sk_buff *skb;
+
+	skb = priv->rx_skb[q][entry];
+	priv->rx_skb[q][entry] = NULL;
+	dma_unmap_single(ndev->dev.parent, le32_to_cpu(desc->dptr),
+			 ALIGN(RGETH_RX_BUFF_MAX, 16), DMA_FROM_DEVICE);
+
+	return skb;
+}
+
 /* Packet receive function for Gigabit Ethernet */
 static bool ravb_rgeth_rx(struct net_device *ndev, int *quota, int q)
 {
-	/* Place holder */
-	return true;
+	struct ravb_private *priv = netdev_priv(ndev);
+	int entry = priv->cur_rx[q] % priv->num_rx_ring[q];
+	int boguscnt = priv->dirty_rx[q] + priv->num_rx_ring[q] - priv->cur_rx[q];
+	struct net_device_stats *stats = &priv->stats[q];
+	struct ravb_rx_desc *desc;
+	struct sk_buff *skb;
+	dma_addr_t dma_addr;
+	u8  desc_status;
+	u8  die_dt;
+	u16 pkt_len;
+	int limit;
+
+	boguscnt = min(boguscnt, *quota);
+	limit = boguscnt;
+	desc = &priv->rgeth_rx_ring[q][entry];
+	while (desc->die_dt != DT_FEMPTY) {
+		/* Descriptor type must be checked before all other reads */
+		dma_rmb();
+		desc_status = desc->msc;
+		pkt_len = le16_to_cpu(desc->ds_cc) & RX_DS;
+
+		if (--boguscnt < 0)
+			break;
+
+		/* We use 0-byte descriptors to mark the DMA mapping errors */
+		if (!pkt_len)
+			continue;
+
+		if (desc_status & MSC_MC)
+			stats->multicast++;
+
+		if (desc_status & (MSC_CRC | MSC_RFE | MSC_RTSF | MSC_RTLF | MSC_CEEF)) {
+			stats->rx_errors++;
+			if (desc_status & MSC_CRC)
+				stats->rx_crc_errors++;
+			if (desc_status & MSC_RFE)
+				stats->rx_frame_errors++;
+			if (desc_status & (MSC_RTLF | MSC_RTSF))
+				stats->rx_length_errors++;
+			if (desc_status & MSC_CEEF)
+				stats->rx_missed_errors++;
+		} else {
+			die_dt = desc->die_dt & 0xF0;
+			switch (die_dt) {
+			case DT_FSINGLE:
+				skb = ravb_get_skb_rgeth(ndev, q, entry, desc);
+				skb_put(skb, pkt_len);
+				skb->protocol = eth_type_trans(skb, ndev);
+				if (ndev->features & NETIF_F_RXCSUM)
+					ravb_rx_csum_rgeth(skb);
+				napi_gro_receive(&priv->napi[q], skb);
+				stats->rx_packets++;
+				stats->rx_bytes += pkt_len;
+				break;
+			case DT_FSTART:
+				priv->rxtop_skb = ravb_get_skb_rgeth(ndev, q, entry, desc);
+				skb_put(priv->rxtop_skb, pkt_len);
+				break;
+			case DT_FMID:
+				skb = ravb_get_skb_rgeth(ndev, q, entry, desc);
+				skb_copy_to_linear_data_offset(priv->rxtop_skb,
+							       priv->rxtop_skb->len,
+							       skb->data,
+							       pkt_len);
+				skb_put(priv->rxtop_skb, pkt_len);
+				dev_kfree_skb(skb);
+				break;
+			case DT_FEND:
+				skb = ravb_get_skb_rgeth(ndev, q, entry, desc);
+				skb_copy_to_linear_data_offset(priv->rxtop_skb,
+							       priv->rxtop_skb->len,
+							       skb->data,
+							       pkt_len);
+				skb_put(priv->rxtop_skb, pkt_len);
+				dev_kfree_skb(skb);
+				priv->rxtop_skb->protocol =
+					eth_type_trans(priv->rxtop_skb, ndev);
+				if (ndev->features & NETIF_F_RXCSUM)
+					ravb_rx_csum_rgeth(skb);
+				napi_gro_receive(&priv->napi[q],
+						 priv->rxtop_skb);
+				stats->rx_packets++;
+				stats->rx_bytes += priv->rxtop_skb->len;
+				break;
+			}
+		}
+
+		entry = (++priv->cur_rx[q]) % priv->num_rx_ring[q];
+		desc = &priv->rgeth_rx_ring[q][entry];
+	}
+
+	/* Refill the RX ring buffers. */
+	for (; priv->cur_rx[q] - priv->dirty_rx[q] > 0; priv->dirty_rx[q]++) {
+		entry = priv->dirty_rx[q] % priv->num_rx_ring[q];
+		desc = &priv->rgeth_rx_ring[q][entry];
+		desc->ds_cc = cpu_to_le16(RGETH_RX_DESC_DATA_SIZE);
+
+		if (!priv->rx_skb[q][entry]) {
+			skb = netdev_alloc_skb(ndev,
+					       RGETH_RX_BUFF_MAX + RAVB_ALIGN - 1);
+			if (!skb)
+				break;
+			ravb_set_buffer_align(skb);
+			dma_addr = dma_map_single(ndev->dev.parent,
+						  skb->data,
+						  le16_to_cpu(desc->ds_cc),
+						  DMA_FROM_DEVICE);
+			skb_checksum_none_assert(skb);
+			/* We just set the data size to 0 for a failed mapping
+			 * which should prevent DMA  from happening...
+			 */
+			if (dma_mapping_error(ndev->dev.parent, dma_addr))
+				desc->ds_cc = cpu_to_le16(0);
+			desc->dptr = cpu_to_le32(dma_addr);
+			priv->rx_skb[q][entry] = skb;
+		}
+		/* Descriptor type must be set after all the above writes */
+		dma_wmb();
+		desc->die_dt = DT_FEMPTY;
+	}
+
+	*quota -= limit - (++boguscnt);
+
+	return boguscnt <= 0;
 }
 
 /* Packet receive function for Ethernet AVB */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 17/18] ravb: Add carrier_counters to struct ravb_hw_info
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
                   ` (15 preceding siblings ...)
  2021-09-23 14:08 ` [RFC/PATCH 16/18] ravb: Add Packet receive function for Gigabit Ethernet Biju Das
@ 2021-09-23 14:08 ` Biju Das
  2021-09-28 20:50   ` Sergey Shtylyov
  2021-09-23 14:08 ` [RFC/PATCH 18/18] ravb: Add set_feature support for RZ/G2L Biju Das
  2021-09-23 15:11 ` [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Sergey Shtylyov
  18 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:08 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

RZ/G2L E-MAC supports carrier counters.
Add a carrier_counter hw feature bit to struct ravb_hw_info
to add this feature only for RZ/G2L.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb.h      |  5 +++++
 drivers/net/ethernet/renesas/ravb_main.c | 13 +++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 85260f89e1cd..d42e8ea981df 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -198,11 +198,15 @@ enum ravb_reg {
 	MAHR	= 0x05c0,
 	MALR	= 0x05c8,
 	TROCR	= 0x0700,	/* R-Car Gen3 and RZ/G2L only */
+	CXR41	= 0x0708,	/* Documented for RZ/G2L only */
+	CXR42	= 0x0710,	/* Documented for RZ/G2L only */
 	CEFCR	= 0x0740,
 	FRECR	= 0x0748,
 	TSFRCR	= 0x0750,
 	TLFRCR	= 0x0758,
 	RFCR	= 0x0760,
+	CXR55	= 0x0768,	/* Documented for RZ/G2L only */
+	CXR56	= 0x0770,	/* Documented for RZ/G2L only */
 	MAFCR	= 0x0778,
 	CSR0     = 0x0800,	/* Documented for RZ/G2L only */
 };
@@ -1036,6 +1040,7 @@ struct ravb_hw_info {
 	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
 	unsigned rx_2k_buffers:1;	/* AVB-DMAC has Max 2K buf size on RX */
 	unsigned timestamp:1;		/* AVB-DMAC has timestamp */
+	unsigned carrier_counters:1;	/* E-MAC has carrier counters */
 };
 
 struct ravb_private {
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 867e180e6655..72aea5875bc5 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2060,6 +2060,18 @@ static struct net_device_stats *ravb_get_stats(struct net_device *ndev)
 		ravb_write(ndev, 0, TROCR);	/* (write clear) */
 	}
 
+	if (info->carrier_counters) {
+		nstats->collisions += ravb_read(ndev, CXR41);
+		ravb_write(ndev, 0, CXR41);	/* (write clear) */
+		nstats->tx_carrier_errors += ravb_read(ndev, CXR42);
+		ravb_write(ndev, 0, CXR42);	/* (write clear) */
+
+		nstats->tx_carrier_errors += ravb_read(ndev, CXR55);
+		ravb_write(ndev, 0, CXR55);	/* (write clear) */
+		nstats->tx_carrier_errors += ravb_read(ndev, CXR56);
+		ravb_write(ndev, 0, CXR56);	/* (write clear) */
+	}
+
 	nstats->rx_packets = stats0->rx_packets + stats1->rx_packets;
 	nstats->tx_packets = stats0->tx_packets + stats1->tx_packets;
 	nstats->rx_bytes = stats0->rx_bytes + stats1->rx_bytes;
@@ -2425,6 +2437,7 @@ static const struct ravb_hw_info rgeth_hw_info = {
 	.no_gptp = 1,
 	.mii_rgmii_selection = 1,
 	.half_duplex = 1,
+	.carrier_counters = 1,
 };
 
 static const struct of_device_id ravb_match_table[] = {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* [RFC/PATCH 18/18] ravb: Add set_feature support for RZ/G2L
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
                   ` (16 preceding siblings ...)
  2021-09-23 14:08 ` [RFC/PATCH 17/18] ravb: Add carrier_counters to struct ravb_hw_info Biju Das
@ 2021-09-23 14:08 ` Biju Das
  2021-09-30 20:39   ` Sergey Shtylyov
  2021-09-23 15:11 ` [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Sergey Shtylyov
  18 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 14:08 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

This patch adds set_feature support for RZ/G2L.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb.h      | 32 ++++++++++++++
 drivers/net/ethernet/renesas/ravb_main.c | 56 +++++++++++++++++++++++-
 2 files changed, 87 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index d42e8ea981df..2275f27c0672 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -209,6 +209,8 @@ enum ravb_reg {
 	CXR56	= 0x0770,	/* Documented for RZ/G2L only */
 	MAFCR	= 0x0778,
 	CSR0     = 0x0800,	/* Documented for RZ/G2L only */
+	CSR1     = 0x0804,	/* Documented for RZ/G2L only */
+	CSR2     = 0x0808,	/* Documented for RZ/G2L only */
 };
 
 
@@ -978,6 +980,36 @@ enum CSR0_BIT {
 	CSR0_RPE	= 0x00000020,
 };
 
+enum CSR1_BIT {
+	CSR1_TIP4	= 0x00000001,
+	CSR1_TTCP4	= 0x00000010,
+	CSR1_TUDP4	= 0x00000020,
+	CSR1_TICMP4	= 0x00000040,
+	CSR1_TTCP6	= 0x00100000,
+	CSR1_TUDP6	= 0x00200000,
+	CSR1_TICMP6	= 0x00400000,
+	CSR1_THOP	= 0x01000000,
+	CSR1_TROUT	= 0x02000000,
+	CSR1_TAHD	= 0x04000000,
+	CSR1_TDHD	= 0x08000000,
+	CSR1_ALL	= 0x0F700071,
+};
+
+enum CSR2_BIT {
+	CSR2_RIP4	= 0x00000001,
+	CSR2_RTCP4	= 0x00000010,
+	CSR2_RUDP4	= 0x00000020,
+	CSR2_RICMP4	= 0x00000040,
+	CSR2_RTCP6	= 0x00100000,
+	CSR2_RUDP6	= 0x00200000,
+	CSR2_RICMP6	= 0x00400000,
+	CSR2_RHOP	= 0x01000000,
+	CSR2_RROUT	= 0x02000000,
+	CSR2_RAHD	= 0x04000000,
+	CSR2_RDHD	= 0x08000000,
+	CSR2_ALL	= 0x0F700071,
+};
+
 #define DBAT_ENTRY_NUM	22
 #define RX_QUEUE_OFFSET	4
 #define NUM_RX_QUEUE	2
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 72aea5875bc5..641ae5553b64 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1506,6 +1506,24 @@ static void ravb_set_msglevel(struct net_device *ndev, u32 value)
 	priv->msg_enable = value;
 }
 
+static const char ravb_gstrings_stats_rgeth[][ETH_GSTRING_LEN] = {
+	"rx_queue_0_current",
+	"tx_queue_0_current",
+	"rx_queue_0_dirty",
+	"tx_queue_0_dirty",
+	"rx_queue_0_packets",
+	"tx_queue_0_packets",
+	"rx_queue_0_bytes",
+	"tx_queue_0_bytes",
+	"rx_queue_0_mcast_packets",
+	"rx_queue_0_errors",
+	"rx_queue_0_crc_errors",
+	"rx_queue_0_frame_errors",
+	"rx_queue_0_length_errors",
+	"rx_queue_0_csum_offload_errors",
+	"rx_queue_0_over_errors",
+};
+
 static const char ravb_gstrings_stats[][ETH_GSTRING_LEN] = {
 	"rx_queue_0_current",
 	"tx_queue_0_current",
@@ -2290,7 +2308,38 @@ static void ravb_set_rx_csum(struct net_device *ndev, bool enable)
 static int ravb_set_features_rgeth(struct net_device *ndev,
 				   netdev_features_t features)
 {
-	/* Place holder */
+	netdev_features_t changed = features ^ ndev->features;
+	unsigned int reg;
+	int error;
+
+	reg = ravb_read(ndev, CSR0);
+
+	ravb_write(ndev, reg & ~(CSR0_RPE | CSR0_TPE), CSR0);
+	error = ravb_wait(ndev, CSR0, CSR0_RPE | CSR0_TPE, 0);
+	if (error) {
+		ravb_write(ndev, reg, CSR0);
+		return error;
+	}
+
+	if (changed & NETIF_F_RXCSUM) {
+		if (features & NETIF_F_RXCSUM)
+			ravb_write(ndev, CSR2_ALL, CSR2);
+		else
+			ravb_write(ndev, 0, CSR2);
+	}
+
+	if (changed & NETIF_F_HW_CSUM) {
+		if (features & NETIF_F_HW_CSUM) {
+			ravb_write(ndev, CSR1_ALL, CSR1);
+			ndev->features |= NETIF_F_CSUM_MASK;
+		} else {
+			ravb_write(ndev, 0, CSR1);
+		}
+	}
+	ravb_write(ndev, reg, CSR0);
+
+	ndev->features = features;
+
 	return 0;
 }
 
@@ -2432,6 +2481,11 @@ static const struct ravb_hw_info rgeth_hw_info = {
 	.set_feature = ravb_set_features_rgeth,
 	.dmac_init = ravb_dmac_init_rgeth,
 	.emac_init = ravb_emac_init_rgeth,
+	.net_hw_features = (NETIF_F_HW_CSUM | NETIF_F_RXCSUM),
+	.gstrings_stats = ravb_gstrings_stats_rgeth,
+	.gstrings_size = sizeof(ravb_gstrings_stats_rgeth),
+	.stats_len = ARRAY_SIZE(ravb_gstrings_stats_rgeth),
+	.max_rx_len = RGETH_RX_BUFF_MAX + RAVB_ALIGN - 1,
 	.aligned_tx = 1,
 	.tx_counters = 1,
 	.no_gptp = 1,
-- 
2.17.1


^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 00/18] Add Gigabit Ethernet driver support
  2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
                   ` (17 preceding siblings ...)
  2021-09-23 14:08 ` [RFC/PATCH 18/18] ravb: Add set_feature support for RZ/G2L Biju Das
@ 2021-09-23 15:11 ` Sergey Shtylyov
  2021-09-23 15:13   ` Sergey Shtylyov
  2021-09-23 15:37   ` Jakub Kicinski
  18 siblings, 2 replies; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-23 15:11 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Sergei Shtylyov, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

Hello!

On 9/23/21 5:07 PM, Biju Das wrote:

> The DMAC and EMAC blocks of Gigabit Ethernet IP found on RZ/G2L SoC are
> similar to the R-Car Ethernet AVB IP.
> 
> The Gigabit Ethernet IP consists of Ethernet controller (E-MAC), Internal
> TCP/IP Offload Engine (TOE)  and Dedicated Direct memory access controller
> (DMAC).
> 
> With a few changes in the driver we can support both IPs.
> 
> This patch series aims to add Gigabit ethernet driver support to RZ/G2L SoC.
> 
> Please provide your valuable comments.

   Note to Dav: I will, in the coming couple days...

> Ref:-
>  * https://lore.kernel.org/linux-renesas-soc/TYCPR01MB59334319695607A2683C1A5E86E59@TYCPR01MB5933.jpnprd01.prod.outlook.com/T/#t
> 
> 
> Biju Das (18):
>   ravb: Rename "ravb_set_features_rx_csum" function to
>     "ravb_set_features_rcar"
>   ravb: Rename the variables "no_ptp_cfg_active" and "ptp_cfg_active"
>   ravb: Initialize GbEthernet dmac
>   ravb: Enable aligned_tx and tx_counters for RZ/G2L
>   ravb: Exclude gPTP feature support for RZ/G2L
>   ravb: Add multi_tsrq to struct ravb_hw_info
>   ravb: Add magic_pkt to struct ravb_hw_info
>   ravb: Add mii_rgmii_selection to struct ravb_hw_info
>   ravb: Add half_duplex to struct ravb_hw_info
>   ravb: Initialize GbEthernet E-MAC
>   ravb: Add rx_2k_buffers to struct ravb_hw_info
>   ravb: Add timestamp to struct ravb_hw_info
>   ravb: Add rx_ring_free function support for GbEthernet
>   ravb: Add rx_ring_format function for GbEthernet
>   ravb: Add rx_alloc helper function for GbEthernet
>   ravb: Add Packet receive function for Gigabit Ethernet
>   ravb: Add carrier_counters to struct ravb_hw_info
>   ravb: Add set_feature support for RZ/G2L
> 
>  drivers/net/ethernet/renesas/ravb.h      |  91 +++-
>  drivers/net/ethernet/renesas/ravb_main.c | 631 ++++++++++++++++++++---
>  2 files changed, 630 insertions(+), 92 deletions(-)

   There's a lot of new code....

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 00/18] Add Gigabit Ethernet driver support
  2021-09-23 15:11 ` [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Sergey Shtylyov
@ 2021-09-23 15:13   ` Sergey Shtylyov
  2021-09-23 15:37   ` Jakub Kicinski
  1 sibling, 0 replies; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-23 15:13 UTC (permalink / raw)
  To: Sergey Shtylyov, Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

On 9/23/21 6:11 PM, Sergey Shtylyov wrote:
> Hello!
> 
> On 9/23/21 5:07 PM, Biju Das wrote:
> 
>> The DMAC and EMAC blocks of Gigabit Ethernet IP found on RZ/G2L SoC are
>> similar to the R-Car Ethernet AVB IP.
>>
>> The Gigabit Ethernet IP consists of Ethernet controller (E-MAC), Internal
>> TCP/IP Offload Engine (TOE)  and Dedicated Direct memory access controller
>> (DMAC).
>>
>> With a few changes in the driver we can support both IPs.
>>
>> This patch series aims to add Gigabit ethernet driver support to RZ/G2L SoC.
>>
>> Please provide your valuable comments.
> 
>    Note to Dav: I will, in the coming couple days...

   Sorry, I thought I typed DaveM. :-)

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 00/18] Add Gigabit Ethernet driver support
  2021-09-23 15:11 ` [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Sergey Shtylyov
  2021-09-23 15:13   ` Sergey Shtylyov
@ 2021-09-23 15:37   ` Jakub Kicinski
  2021-09-23 17:43     ` Sergey Shtylyov
  1 sibling, 1 reply; 79+ messages in thread
From: Jakub Kicinski @ 2021-09-23 15:37 UTC (permalink / raw)
  To: Sergey Shtylyov
  Cc: Biju Das, David S. Miller, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

On Thu, 23 Sep 2021 18:11:49 +0300 Sergey Shtylyov wrote:
> >  drivers/net/ethernet/renesas/ravb_main.c | 631 ++++++++++++++++++++---
> >  2 files changed, 630 insertions(+), 92 deletions(-)  
> 
>    There's a lot of new code....

TBH the patches look small an reasonably split to me.

Thanks for the "intending to review" note :)

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 02/18] ravb: Rename the variables "no_ptp_cfg_active" and "ptp_cfg_active"
  2021-09-23 14:07 ` [RFC/PATCH 02/18] ravb: Rename the variables "no_ptp_cfg_active" and "ptp_cfg_active" Biju Das
@ 2021-09-23 16:07   ` Sergey Shtylyov
  2021-09-23 16:35     ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-23 16:07 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Sergei Shtylyov, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

On 9/23/21 5:07 PM, Biju Das wrote:

> Rename the variable "no_ptp_cfg_active" with "no_gptp" with inverted
> checks and "ptp_cfg_active" with "ccc_gac".

   That's not exactly rename, no? At least for the 1st case...

> There is no functional change.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> Suggested-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> ---
>  drivers/net/ethernet/renesas/ravb.h      |  4 ++--
>  drivers/net/ethernet/renesas/ravb_main.c | 25 ++++++++++++------------
>  2 files changed, 14 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
> index 7363abae6e59..0ce0c13ef8cb 100644
> --- a/drivers/net/ethernet/renesas/ravb.h
> +++ b/drivers/net/ethernet/renesas/ravb.h
> @@ -1000,8 +1000,8 @@ struct ravb_hw_info {
>  	unsigned internal_delay:1;	/* AVB-DMAC has internal delays */
>  	unsigned tx_counters:1;		/* E-MAC has TX counters */
>  	unsigned multi_irqs:1;		/* AVB-DMAC and E-MAC has multiple irqs */
> -	unsigned no_ptp_cfg_active:1;	/* AVB-DMAC does not support gPTP active in config mode */
> -	unsigned ptp_cfg_active:1;	/* AVB-DMAC has gPTP support active in config mode */
> +	unsigned no_gptp:1;		/* AVB-DMAC does not support gPTP feature */

   Judging on the flag usage (which ensues using logical not in every case), I'd suggest to
invert this flag and call it 'gptp'...

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 02/18] ravb: Rename the variables "no_ptp_cfg_active" and "ptp_cfg_active"
  2021-09-23 16:07   ` Sergey Shtylyov
@ 2021-09-23 16:35     ` Biju Das
  2021-09-23 17:57       ` Sergey Shtylyov
  0 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 16:35 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

Thanks for the feedback.

> -----Original Message-----
> Subject: Re: [RFC/PATCH 02/18] ravb: Rename the variables
> "no_ptp_cfg_active" and "ptp_cfg_active"
> 
> On 9/23/21 5:07 PM, Biju Das wrote:
> 
> > Rename the variable "no_ptp_cfg_active" with "no_gptp" with inverted
> > checks and "ptp_cfg_active" with "ccc_gac".
> 
>    That's not exactly rename, no? At least for the 1st case...

This is what we agreed as per last discussion[1]. 

https://patchwork.kernel.org/project/linux-renesas-soc/patch/20210825070154.14336-5-biju.das.jz@bp.renesas.com/


> 
> > There is no functional change.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > Suggested-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> > ---
> >  drivers/net/ethernet/renesas/ravb.h      |  4 ++--
> >  drivers/net/ethernet/renesas/ravb_main.c | 25
> > ++++++++++++------------
> >  2 files changed, 14 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > b/drivers/net/ethernet/renesas/ravb.h
> > index 7363abae6e59..0ce0c13ef8cb 100644
> > --- a/drivers/net/ethernet/renesas/ravb.h
> > +++ b/drivers/net/ethernet/renesas/ravb.h
> > @@ -1000,8 +1000,8 @@ struct ravb_hw_info {
> >  	unsigned internal_delay:1;	/* AVB-DMAC has internal delays */
> >  	unsigned tx_counters:1;		/* E-MAC has TX counters */
> >  	unsigned multi_irqs:1;		/* AVB-DMAC and E-MAC has multiple
> irqs */
> > -	unsigned no_ptp_cfg_active:1;	/* AVB-DMAC does not support gPTP
> active in config mode */
> > -	unsigned ptp_cfg_active:1;	/* AVB-DMAC has gPTP support active in
> config mode */
> > +	unsigned no_gptp:1;		/* AVB-DMAC does not support gPTP
> feature */
> 
>    Judging on the flag usage (which ensues using logical not in every
> case), I'd suggest to invert this flag and call it 'gptp'...

We have the following cases 
Case 1) On R-Car Gen3, gPTP support is active in config mode.
Case 2) On R-Car Gen2, gPTP support is not active in config mode.
Case 3) RZ/G2L does not support the gPTP feature.

And I came up with patches [1] and [2]. Then as per discussion we agreed for gPTP support active in config(ccc_gac) which take care of Case 1, no_gptp which take care of case 3 
And the cases not under 1 and 3 falls to 2.

[1]
https://patchwork.kernel.org/project/linux-renesas-soc/patch/20210825070154.14336-4-biju.das.jz@bp.renesas.com/
[2]
https://patchwork.kernel.org/project/linux-renesas-soc/patch/20210825070154.14336-5-biju.das.jz@bp.renesas.com/

So please clear on your proposals to accomodate the 3 use cases as mentioned below.

Case 1) On R-Car Gen3, gPTP support is active in config mode.
Case 2) On R-Car Gen2, gPTP support is not active in config mode.
Case 3) RZ/G2L does not support the gPTP feature.

Regards,
Biju






> 
> [...]
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac
  2021-09-23 14:07 ` [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac Biju Das
@ 2021-09-23 17:41   ` Sergey Shtylyov
  2021-09-23 18:42     ` Biju Das
  2021-09-23 19:07   ` Sergey Shtylyov
  1 sibling, 1 reply; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-23 17:41 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Sergei Shtylyov, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

On 9/23/21 5:07 PM, Biju Das wrote:

> Initialize GbEthernet dmac found on RZ/G2L SoC.

   DMAC (or AVB-DMAC).

> This patch also renames ravb_rcar_dmac_init to ravb_dmac_init_rcar
> to be consistent with the naming convention used in sh_eth driver.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/net/ethernet/renesas/ravb.h      |  4 ++
>  drivers/net/ethernet/renesas/ravb_main.c | 84 +++++++++++++++++++++++-
>  2 files changed, 85 insertions(+), 3 deletions(-)

[...]
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 2422e74d9b4f..54c4d31a6950 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_rgeth_set_rate(struct net_device *ndev)

   What does 'rgeth' stand for? And why not the trailing part of the name, like the other cases? 

> +{
> +	/* 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_rgeth(struct net_device *ndev, int q)

   rgeth?

> +{
> +	/* 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_rgeth(struct net_device *ndev, int q)

   rgeth?

> +{
> +	/* 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_rgeth_alloc_rx_desc(struct net_device *ndev, int q)

   Again, why rgeth is not in the symbol's tail?

> +{
> +	/* 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_rgeth_emac_init(struct net_device *ndev)

   Same here...

> +{
> +	/* Place holder */
> +}
> +
>  static void ravb_rcar_emac_init(struct net_device *ndev)
>  {
>  	/* Receive frame limit set register */
> @@ -461,7 +487,32 @@ static void ravb_emac_init(struct net_device *ndev)
>  	info->emac_init(ndev);
>  }
>  
> -static void ravb_rcar_dmac_init(struct net_device *ndev)
> +static void ravb_dmac_init_rgeth(struct net_device *ndev)
> +{
> +	/* Set AVB RX */
> +	ravb_write(ndev, 0x60000000, RCR);
> +
> +	/* Set Max Frame Length (RTC) */
> +	ravb_write(ndev, 0x7ffc0000 | RGETH_RX_BUFF_MAX, RTC);
> +
> +	/* Set FIFO size */
> +	ravb_write(ndev, 0x00222200, TGC);
> +
> +	ravb_write(ndev, 0, TCCR);
> +
> +	/* Frame receive */
> +	ravb_write(ndev, RIC0_FRE0, RIC0);
> +	/* Disable FIFO full warning */
> +	ravb_write(ndev, 0x0, RIC1);
> +	/* Receive FIFO full error, descriptor empty */
> +	ravb_write(ndev, RIC2_QFE0 | RIC2_RFFE, RIC2);
> +
> +	ravb_write(ndev, 0x0, RIC3);
> +
> +	ravb_write(ndev, TIC_FTE0, TIC);
> +}

   Ah, so 'rgeth' stands for GbEthernet... why not 'gbeth' then?

[...]
> @@ -579,6 +630,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_rgeth_rx(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);
> @@ -1918,6 +1977,13 @@ static void ravb_set_rx_csum(struct net_device *ndev, bool enable)
>  	spin_unlock_irqrestore(&priv->lock, flags);
>  }
>  
> +static int ravb_set_features_rgeth(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)
>  {
> @@ -2007,7 +2073,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
>  	.receive = ravb_rcar_rx,
>  	.set_rate = ravb_set_rate,
>  	.set_feature = ravb_set_features_rcar,
> -	.dmac_init = ravb_rcar_dmac_init,
> +	.dmac_init = ravb_dmac_init_rcar,
>  	.emac_init = ravb_rcar_emac_init,
>  	.gstrings_stats = ravb_gstrings_stats,
>  	.gstrings_size = sizeof(ravb_gstrings_stats),
> @@ -2028,7 +2094,7 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
>  	.receive = ravb_rcar_rx,
>  	.set_rate = ravb_set_rate,
>  	.set_feature = ravb_set_features_rcar,
> -	.dmac_init = ravb_rcar_dmac_init,
> +	.dmac_init = ravb_dmac_init_rcar,
>  	.emac_init = ravb_rcar_emac_init,
>  	.gstrings_stats = ravb_gstrings_stats,
>  	.gstrings_size = sizeof(ravb_gstrings_stats),
> @@ -2039,12 +2105,24 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
>  	.aligned_tx = 1,
>  };
>  
> +static const struct ravb_hw_info rgeth_hw_info = {
> +	.rx_ring_free = ravb_rx_ring_free_rgeth,
> +	.rx_ring_format = ravb_rx_ring_format_rgeth,
> +	.alloc_rx_desc = ravb_rgeth_alloc_rx_desc,
> +	.receive = ravb_rgeth_rx,
> +	.set_rate = ravb_rgeth_set_rate,
> +	.set_feature = ravb_set_features_rgeth,
> +	.dmac_init = ravb_dmac_init_rgeth,
> +	.emac_init = ravb_rgeth_emac_init,
> +};
> +>  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 = &rgeth_hw_info },

    Mhm, I thought this parch should come lst of the series, without any placeholders...

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 00/18] Add Gigabit Ethernet driver support
  2021-09-23 15:37   ` Jakub Kicinski
@ 2021-09-23 17:43     ` Sergey Shtylyov
  0 siblings, 0 replies; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-23 17:43 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Biju Das, David S. Miller, Lad Prabhakar, Andrew Lunn,
	Sergei Shtylyov, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

On 9/23/21 6:37 PM, Jakub Kicinski wrote:

>>>  drivers/net/ethernet/renesas/ravb_main.c | 631 ++++++++++++++++++++---
>>>  2 files changed, 630 insertions(+), 92 deletions(-)  
>>
>>    There's a lot of new code....
> 
> TBH the patches look small an reasonably split to me.

    They only /look/ reasonably split. :-)

> Thanks for the "intending to review" note :)

   I was afraid DaveM would merge the series without any review. :-) 

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 02/18] ravb: Rename the variables "no_ptp_cfg_active" and "ptp_cfg_active"
  2021-09-23 16:35     ` Biju Das
@ 2021-09-23 17:57       ` Sergey Shtylyov
  2021-09-23 18:20         ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-23 17:57 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

On 9/23/21 7:35 PM, Biju Das wrote:

[...]
>>> Rename the variable "no_ptp_cfg_active" with "no_gptp" with inverted
>>> checks and "ptp_cfg_active" with "ccc_gac".
>>
>>    That's not exactly rename, no? At least for the 1st case...
> 
> This is what we agreed as per last discussion[1]. 
> 
> https://patchwork.kernel.org/project/linux-renesas-soc/patch/20210825070154.14336-5-biju.das.jz@bp.renesas.com/

   Sorry, I've changed my mind about 'no_gpgp' after seeing all the checks. I'd like to avoiud the double negations
in those checks -- this should make the code more clear. My 1st idea (just 'gp[tp') turned out to be more practical,
sorry about this going back-and-forth. :-<

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 04/18] ravb: Enable aligned_tx and tx_counters for RZ/G2L
  2021-09-23 14:07 ` [RFC/PATCH 04/18] ravb: Enable aligned_tx and tx_counters for RZ/G2L Biju Das
@ 2021-09-23 18:05   ` Sergey Shtylyov
  2021-09-23 18:10     ` Sergey Shtylyov
  2021-09-23 18:13     ` Biju Das
  0 siblings, 2 replies; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-23 18:05 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

On 9/23/21 5:07 PM, Biju Das wrote:

   Somehow this patch haven't reached my OMP email -- I got it only thru
 the linux-renesas-soc list... :-/

> RZ/G2L need 4byte address alignment like R-Car Gen2 and
> it has tx_counters like R-Car Gen3. This patch enable
> these features for RZ/G2L.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/net/ethernet/renesas/ravb.h      | 2 +-
>  drivers/net/ethernet/renesas/ravb_main.c | 2 ++
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
> index bee05e6fb815..bb92469d770e 100644
> --- a/drivers/net/ethernet/renesas/ravb.h
> +++ b/drivers/net/ethernet/renesas/ravb.h
> @@ -195,7 +195,7 @@ enum ravb_reg {
>  	GECMR	= 0x05b0,
>  	MAHR	= 0x05c0,
>  	MALR	= 0x05c8,
> -	TROCR	= 0x0700,	/* R-Car Gen3 only */
> +	TROCR	= 0x0700,	/* R-Car Gen3 and RZ/G2L only */
>  	CEFCR	= 0x0740,
>  	FRECR	= 0x0748,
>  	TSFRCR	= 0x0750,
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 54c4d31a6950..d38fc33a8e93 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -2114,6 +2114,8 @@ static const struct ravb_hw_info rgeth_hw_info = {
>  	.set_feature = ravb_set_features_rgeth,
>  	.dmac_init = ravb_dmac_init_rgeth,
>  	.emac_init = ravb_rgeth_emac_init,
> +	.aligned_tx = 1,
> +	.tx_counters = 1,

   Mhm, I don't see a connection between those 2 (other than they're both for RX). And anyway, this prolly
should be a part of the previous patch...

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 04/18] ravb: Enable aligned_tx and tx_counters for RZ/G2L
  2021-09-23 18:05   ` Sergey Shtylyov
@ 2021-09-23 18:10     ` Sergey Shtylyov
  2021-09-23 18:13     ` Biju Das
  1 sibling, 0 replies; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-23 18:10 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

On 9/23/21 9:05 PM, Sergey Shtylyov wrote:

>    Somehow this patch haven't reached my OMP email -- I got it only thru
>  the linux-renesas-soc list... :-/
> 
>> RZ/G2L need 4byte address alignment like R-Car Gen2 and
>> it has tx_counters like R-Car Gen3. This patch enable
>> these features for RZ/G2L.
>>
>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
[...]
>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
>> index 54c4d31a6950..d38fc33a8e93 100644
>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>> @@ -2114,6 +2114,8 @@ static const struct ravb_hw_info rgeth_hw_info = {
>>  	.set_feature = ravb_set_features_rgeth,
>>  	.dmac_init = ravb_dmac_init_rgeth,
>>  	.emac_init = ravb_rgeth_emac_init,
>> +	.aligned_tx = 1,
>> +	.tx_counters = 1,
> 
>    Mhm, I don't see a connection between those 2 (other than they're both for RX). And anyway, this prolly

  TX, of/c. :-)

> should be a part of the previous patch...
> 
> [...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 04/18] ravb: Enable aligned_tx and tx_counters for RZ/G2L
  2021-09-23 18:05   ` Sergey Shtylyov
  2021-09-23 18:10     ` Sergey Shtylyov
@ 2021-09-23 18:13     ` Biju Das
  2021-09-26 13:40       ` Biju Das
  1 sibling, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 18:13 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

Hi Sergei,

Thanks for the review.

> Subject: Re: [RFC/PATCH 04/18] ravb: Enable aligned_tx and tx_counters for
> RZ/G2L
> 
> On 9/23/21 5:07 PM, Biju Das wrote:
> 
>    Somehow this patch haven't reached my OMP email -- I got it only thru
> the linux-renesas-soc list... :-/
> 
> > RZ/G2L need 4byte address alignment like R-Car Gen2 and it has
> > tx_counters like R-Car Gen3. This patch enable these features for
> > RZ/G2L.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  drivers/net/ethernet/renesas/ravb.h      | 2 +-
> >  drivers/net/ethernet/renesas/ravb_main.c | 2 ++
> >  2 files changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > b/drivers/net/ethernet/renesas/ravb.h
> > index bee05e6fb815..bb92469d770e 100644
> > --- a/drivers/net/ethernet/renesas/ravb.h
> > +++ b/drivers/net/ethernet/renesas/ravb.h
> > @@ -195,7 +195,7 @@ enum ravb_reg {
> >  	GECMR	= 0x05b0,
> >  	MAHR	= 0x05c0,
> >  	MALR	= 0x05c8,
> > -	TROCR	= 0x0700,	/* R-Car Gen3 only */
> > +	TROCR	= 0x0700,	/* R-Car Gen3 and RZ/G2L only */
> >  	CEFCR	= 0x0740,
> >  	FRECR	= 0x0748,
> >  	TSFRCR	= 0x0750,
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index 54c4d31a6950..d38fc33a8e93 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > @@ -2114,6 +2114,8 @@ static const struct ravb_hw_info rgeth_hw_info = {
> >  	.set_feature = ravb_set_features_rgeth,
> >  	.dmac_init = ravb_dmac_init_rgeth,
> >  	.emac_init = ravb_rgeth_emac_init,
> > +	.aligned_tx = 1,
> > +	.tx_counters = 1,
> 
>    Mhm, I don't see a connection between those 2 (other than they're both
> for RX). And anyway, this prolly should be a part of the previous patch...

There was a discussion to make smaller patches. If there is no objection, on
the next revision I will add this as part of previous patch.

Regards,
Biju



^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 02/18] ravb: Rename the variables "no_ptp_cfg_active" and "ptp_cfg_active"
  2021-09-23 17:57       ` Sergey Shtylyov
@ 2021-09-23 18:20         ` Biju Das
  2021-09-26 13:34           ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 18:20 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

> Subject: Re: [RFC/PATCH 02/18] ravb: Rename the variables
> "no_ptp_cfg_active" and "ptp_cfg_active"
> 
> On 9/23/21 7:35 PM, Biju Das wrote:
> 
> [...]
> >>> Rename the variable "no_ptp_cfg_active" with "no_gptp" with inverted
> >>> checks and "ptp_cfg_active" with "ccc_gac".
> >>
> >>    That's not exactly rename, no? At least for the 1st case...
> >
> > This is what we agreed as per last discussion[1].
> >
> > https://jpn01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatc
> > hwork.kernel.org%2Fproject%2Flinux-renesas-soc%2Fpatch%2F2021082507015
> > 4.14336-5-biju.das.jz%40bp.renesas.com%2F&amp;data=04%7C01%7Cbiju.das.
> > jz%40bp.renesas.com%7Cec41661b87e14f9e810808d97ebbae07%7C53d82571da194
> > 7e49cb4625a166a4a2a%7C0%7C0%7C637680166814248680%7CUnknown%7CTWFpbGZsb
> > 3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%
> > 7C1000&amp;sdata=ze0ica0K57exFOSQ9LyMuQ%2FFimvOW4PtH8ETxYJ8o6Y%3D&amp;
> > reserved=0
> 
>    Sorry, I've changed my mind about 'no_gpgp' after seeing all the
> checks. I'd like to avoiud the double negations in those checks -- this
> should make the code more clear. My 1st idea (just 'gp[tp') turned out to
> be more practical, sorry about this going back-and-forth. :-<

So Just to confirm the name to be used are "ccc_gac" and "gptp".

Case 1) On R-Car Gen3, gPTP support is active in config mode. (replace "ptp_cfg_active" with "ccc_gac")
Case 2) On R-Car Gen2, gPTP support is not active in config mode ( replace "no_ptp_cfg_active" with "gptp")
Case 3) RZ/G2L does not support the gPTP feature(if "no_gac" or "gptp" then it falls to case 3).

Regards,
Biju

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac
  2021-09-23 17:41   ` Sergey Shtylyov
@ 2021-09-23 18:42     ` Biju Das
  0 siblings, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-23 18:42 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

> Subject: Re: [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac
> 
> On 9/23/21 5:07 PM, Biju Das wrote:
> 
> > Initialize GbEthernet dmac found on RZ/G2L SoC.
> 
>    DMAC (or AVB-DMAC).

OK will change it to DMAC. AVB-DMAC is not applicable for GbEthernet.

> 
> > This patch also renames ravb_rcar_dmac_init to ravb_dmac_init_rcar to
> > be consistent with the naming convention used in sh_eth driver.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  drivers/net/ethernet/renesas/ravb.h      |  4 ++
> >  drivers/net/ethernet/renesas/ravb_main.c | 84
> > +++++++++++++++++++++++-
> >  2 files changed, 85 insertions(+), 3 deletions(-)
> 
> [...]
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index 2422e74d9b4f..54c4d31a6950 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_rgeth_set_rate(struct net_device *ndev)
> 
>    What does 'rgeth' stand for? And why not the trailing part of the name,
> like the other cases?

'rgeth' stands for Renesas Gigabit Ethernet like 'ravb' renesas AVB.
OK it can be moved to trailing part.

> 
> > +{
> > +	/* 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_rgeth(struct net_device *ndev, int q)
> 
>    rgeth? 

Are you ok with this function name right? Since based on previous comment
to trailing part.

> 
> > +{
> > +	/* 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_rgeth(struct net_device *ndev, int q)
> 
>    rgeth?
Are you ok with this function name right? Since based on previous comment
to trailing part.

> 
> > +{
> > +	/* 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_rgeth_alloc_rx_desc(struct net_device *ndev, int q)
> 
>    Again, why rgeth is not in the symbol's tail?

Ok will move to the tail.
> 
> > +{
> > +	/* 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_rgeth_emac_init(struct net_device *ndev)
> 
>    Same here...
OK will move to the tail.
> 
> > +{
> > +	/* Place holder */
> > +}
> > +
> >  static void ravb_rcar_emac_init(struct net_device *ndev)  {
> >  	/* Receive frame limit set register */ @@ -461,7 +487,32 @@ static
> > void ravb_emac_init(struct net_device *ndev)
> >  	info->emac_init(ndev);
> >  }
> >
> > -static void ravb_rcar_dmac_init(struct net_device *ndev)
> > +static void ravb_dmac_init_rgeth(struct net_device *ndev) {
> > +	/* Set AVB RX */
> > +	ravb_write(ndev, 0x60000000, RCR);
> > +
> > +	/* Set Max Frame Length (RTC) */
> > +	ravb_write(ndev, 0x7ffc0000 | RGETH_RX_BUFF_MAX, RTC);
> > +
> > +	/* Set FIFO size */
> > +	ravb_write(ndev, 0x00222200, TGC);
> > +
> > +	ravb_write(ndev, 0, TCCR);
> > +
> > +	/* Frame receive */
> > +	ravb_write(ndev, RIC0_FRE0, RIC0);
> > +	/* Disable FIFO full warning */
> > +	ravb_write(ndev, 0x0, RIC1);
> > +	/* Receive FIFO full error, descriptor empty */
> > +	ravb_write(ndev, RIC2_QFE0 | RIC2_RFFE, RIC2);
> > +
> > +	ravb_write(ndev, 0x0, RIC3);
> > +
> > +	ravb_write(ndev, TIC_FTE0, TIC);
> > +}
> 
>    Ah, so 'rgeth' stands for GbEthernet... why not 'gbeth' then?

'rgeth" is Renesas Gigabit ethernet. If needed I can change it to 'gbeth' if there is no 
Objection from others.

> 
> [...]
> > @@ -579,6 +630,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_rgeth_rx(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); @@ -1918,6 +1977,13
> > @@ static void ravb_set_rx_csum(struct net_device *ndev, bool enable)
> >  	spin_unlock_irqrestore(&priv->lock, flags);  }
> >
> > +static int ravb_set_features_rgeth(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)
> >  {
> > @@ -2007,7 +2073,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info
> = {
> >  	.receive = ravb_rcar_rx,
> >  	.set_rate = ravb_set_rate,
> >  	.set_feature = ravb_set_features_rcar,
> > -	.dmac_init = ravb_rcar_dmac_init,
> > +	.dmac_init = ravb_dmac_init_rcar,
> >  	.emac_init = ravb_rcar_emac_init,
> >  	.gstrings_stats = ravb_gstrings_stats,
> >  	.gstrings_size = sizeof(ravb_gstrings_stats), @@ -2028,7 +2094,7 @@
> > static const struct ravb_hw_info ravb_gen2_hw_info = {
> >  	.receive = ravb_rcar_rx,
> >  	.set_rate = ravb_set_rate,
> >  	.set_feature = ravb_set_features_rcar,
> > -	.dmac_init = ravb_rcar_dmac_init,
> > +	.dmac_init = ravb_dmac_init_rcar,
> >  	.emac_init = ravb_rcar_emac_init,
> >  	.gstrings_stats = ravb_gstrings_stats,
> >  	.gstrings_size = sizeof(ravb_gstrings_stats), @@ -2039,12 +2105,24
> > @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
> >  	.aligned_tx = 1,
> >  };
> >
> > +static const struct ravb_hw_info rgeth_hw_info = {
> > +	.rx_ring_free = ravb_rx_ring_free_rgeth,
> > +	.rx_ring_format = ravb_rx_ring_format_rgeth,
> > +	.alloc_rx_desc = ravb_rgeth_alloc_rx_desc,
> > +	.receive = ravb_rgeth_rx,
> > +	.set_rate = ravb_rgeth_set_rate,
> > +	.set_feature = ravb_set_features_rgeth,
> > +	.dmac_init = ravb_dmac_init_rgeth,
> > +	.emac_init = ravb_rgeth_emac_init,
> > +};
> > +>  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 = &rgeth_hw_info },
> 
>     Mhm, I thought this parch should come lst of the series, without any
> placeholders...

It is OK. 

Like you commented on https://patchwork.kernel.org/project/linux-renesas-soc/patch/20210923140813.13541-5-biju.das.jz@bp.renesas.com/, why there is a patch required for this feature bits?

Cheers,
Biju

> 
> [...]
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 05/18] ravb: Exclude gPTP feature support for RZ/G2L
  2021-09-23 14:08 ` [RFC/PATCH 05/18] ravb: Exclude gPTP feature support " Biju Das
@ 2021-09-23 19:00   ` Sergey Shtylyov
  2021-09-23 19:13     ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-23 19:00 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Sergei Shtylyov, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

On 9/23/21 5:08 PM, Biju Das wrote:

> R-Car supports gPTP feature whereas RZ/G2L does not support it.
> This patch excludes gtp feature support for RZ/G2L by enabling
> no_gptp feature bit.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/net/ethernet/renesas/ravb_main.c | 46 ++++++++++++++----------
>  1 file changed, 28 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index d38fc33a8e93..8663d83507a0 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
[...]
> @@ -953,7 +954,7 @@ static irqreturn_t ravb_interrupt(int irq, void *dev_id)
>  	}
>  
>  	/* gPTP interrupt status summary */
> -	if (iss & ISS_CGIS) {

   Isn't this bit always 0 on RZ/G2L?

> +	if (!info->no_gptp && (iss & ISS_CGIS)) {
>  		ravb_ptp_interrupt(ndev);
>  		result = IRQ_HANDLED;
>  	}
> @@ -1378,6 +1379,7 @@ static int ravb_get_ts_info(struct net_device *ndev,
>  			    struct ethtool_ts_info *info)
>  {
>  	struct ravb_private *priv = netdev_priv(ndev);
> +	const struct ravb_hw_info *hw_info = priv->info;
>  
>  	info->so_timestamping =
>  		SOF_TIMESTAMPING_TX_SOFTWARE |
> @@ -1391,7 +1393,8 @@ static int ravb_get_ts_info(struct net_device *ndev,
>  		(1 << HWTSTAMP_FILTER_NONE) |
>  		(1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
>  		(1 << HWTSTAMP_FILTER_ALL);
> -	info->phc_index = ptp_clock_index(priv->ptp.clock);
> +	if (!hw_info->no_gptp)
> +		info->phc_index = ptp_clock_index(priv->ptp.clock);
>  
>  	return 0;
>  }
> @@ -2116,6 +2119,7 @@ static const struct ravb_hw_info rgeth_hw_info = {
>  	.emac_init = ravb_rgeth_emac_init,
>  	.aligned_tx = 1,
>  	.tx_counters = 1,
> +	.no_gptp = 1,

   Mhm, I definitely don't like the way you "extend" the GbEthernet info structure. All the applicable flags
should be set in the last patch of the series, not amidst of it.

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac
  2021-09-23 14:07 ` [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac Biju Das
  2021-09-23 17:41   ` Sergey Shtylyov
@ 2021-09-23 19:07   ` Sergey Shtylyov
  2021-09-23 19:22     ` Biju Das
  1 sibling, 1 reply; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-23 19:07 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Sergei Shtylyov, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

On 9/23/21 5:07 PM, Biju Das wrote:

> Initialize GbEthernet dmac found on RZ/G2L SoC.
> This patch also renames ravb_rcar_dmac_init to ravb_dmac_init_rcar
> to be consistent with the naming convention used in sh_eth driver.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/net/ethernet/renesas/ravb.h      |  4 ++
>  drivers/net/ethernet/renesas/ravb_main.c | 84 +++++++++++++++++++++++-
>  2 files changed, 85 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
> index 0ce0c13ef8cb..bee05e6fb815 100644
> --- a/drivers/net/ethernet/renesas/ravb.h
> +++ b/drivers/net/ethernet/renesas/ravb.h
> @@ -81,6 +81,7 @@ enum ravb_reg {
>  	RQC3	= 0x00A0,
>  	RQC4	= 0x00A4,
>  	RPC	= 0x00B0,
> +	RTC	= 0x00B4,	/* RZ/G2L only */

   My gen3 manual says the regiuster exists there...

>  	UFCW	= 0x00BC,
>  	UFCS	= 0x00C0,
>  	UFCV0	= 0x00C4,
> @@ -156,6 +157,7 @@ enum ravb_reg {
>  	TIS	= 0x037C,
>  	ISS	= 0x0380,
>  	CIE	= 0x0384,	/* R-Car Gen3 only */
> +	RIC3	= 0x0388,	/* RZ/G2L only */

   Again, this register (along with RIS3) exists on gen3...

>  	GCCR	= 0x0390,
>  	GMTT	= 0x0394,
>  	GPTC	= 0x0398,
> @@ -956,6 +958,8 @@ enum RAVB_QUEUE {
>  
>  #define RX_BUF_SZ	(2048 - ETH_FCS_LEN + sizeof(__sum16))
>  
> +#define RGETH_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 2422e74d9b4f..54c4d31a6950 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_rgeth_set_rate(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_rgeth(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_rgeth(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_rgeth_alloc_rx_desc(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_rgeth_emac_init(struct net_device *ndev)
> +{
> +	/* Place holder */
> +}
> +
>  static void ravb_rcar_emac_init(struct net_device *ndev)
>  {
>  	/* Receive frame limit set register */
> @@ -461,7 +487,32 @@ static void ravb_emac_init(struct net_device *ndev)
>  	info->emac_init(ndev);
>  }
>  
> -static void ravb_rcar_dmac_init(struct net_device *ndev)
> +static void ravb_dmac_init_rgeth(struct net_device *ndev)
> +{
> +	/* Set AVB RX */
> +	ravb_write(ndev, 0x60000000, RCR);
> +
> +	/* Set Max Frame Length (RTC) */
> +	ravb_write(ndev, 0x7ffc0000 | RGETH_RX_BUFF_MAX, RTC);

   Should be init'ed on gen3 as well?

> +
> +	/* Set FIFO size */
> +	ravb_write(ndev, 0x00222200, TGC);
> +
> +	ravb_write(ndev, 0, TCCR);
> +
> +	/* Frame receive */
> +	ravb_write(ndev, RIC0_FRE0, RIC0);
> +	/* Disable FIFO full warning */
> +	ravb_write(ndev, 0x0, RIC1);
> +	/* Receive FIFO full error, descriptor empty */
> +	ravb_write(ndev, RIC2_QFE0 | RIC2_RFFE, RIC2);
> +
> +	ravb_write(ndev, 0x0, RIC3);

   Should be init'ed on gen3 as well? Matter of a separate patch, I can do it prolly...

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 05/18] ravb: Exclude gPTP feature support for RZ/G2L
  2021-09-23 19:00   ` Sergey Shtylyov
@ 2021-09-23 19:13     ` Biju Das
  2021-09-23 19:41       ` Sergey Shtylyov
  0 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 19:13 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

Thanks for the review.

> -----Original Message-----
> From: Sergey Shtylyov <s.shtylyov@omp.ru>
> Sent: 23 September 2021 20:00
> To: Biju Das <biju.das.jz@bp.renesas.com>; David S. Miller
> <davem@davemloft.net>; Jakub Kicinski <kuba@kernel.org>
> Cc: Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>;
> Andrew Lunn <andrew@lunn.ch>; Sergei Shtylyov <sergei.shtylyov@gmail.com>;
> Geert Uytterhoeven <geert+renesas@glider.be>; Adam Ford
> <aford173@gmail.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>
> Subject: Re: [RFC/PATCH 05/18] ravb: Exclude gPTP feature support for
> RZ/G2L
> 
> On 9/23/21 5:08 PM, Biju Das wrote:
> 
> > R-Car supports gPTP feature whereas RZ/G2L does not support it.
> > This patch excludes gtp feature support for RZ/G2L by enabling no_gptp
> > feature bit.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  drivers/net/ethernet/renesas/ravb_main.c | 46
> > ++++++++++++++----------
> >  1 file changed, 28 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index d38fc33a8e93..8663d83507a0 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> [...]
> > @@ -953,7 +954,7 @@ static irqreturn_t ravb_interrupt(int irq, void
> *dev_id)
> >  	}
> >
> >  	/* gPTP interrupt status summary */
> > -	if (iss & ISS_CGIS) {
> 
>    Isn't this bit always 0 on RZ/G2L?

This CGIM bit(BIT13) which is present on R-Car Gen3 is not present in RZ/G2L. As per the HW manual
BIT13 is reserved bit and read is always 0.

> 
> > +	if (!info->no_gptp && (iss & ISS_CGIS)) {
> >  		ravb_ptp_interrupt(ndev);
> >  		result = IRQ_HANDLED;
> >  	}
> > @@ -1378,6 +1379,7 @@ static int ravb_get_ts_info(struct net_device
> *ndev,
> >  			    struct ethtool_ts_info *info)
> >  {
> >  	struct ravb_private *priv = netdev_priv(ndev);
> > +	const struct ravb_hw_info *hw_info = priv->info;
> >
> >  	info->so_timestamping =
> >  		SOF_TIMESTAMPING_TX_SOFTWARE |
> > @@ -1391,7 +1393,8 @@ static int ravb_get_ts_info(struct net_device
> *ndev,
> >  		(1 << HWTSTAMP_FILTER_NONE) |
> >  		(1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
> >  		(1 << HWTSTAMP_FILTER_ALL);
> > -	info->phc_index = ptp_clock_index(priv->ptp.clock);
> > +	if (!hw_info->no_gptp)
> > +		info->phc_index = ptp_clock_index(priv->ptp.clock);
> >
> >  	return 0;
> >  }
> > @@ -2116,6 +2119,7 @@ static const struct ravb_hw_info rgeth_hw_info = {
> >  	.emac_init = ravb_rgeth_emac_init,
> >  	.aligned_tx = 1,
> >  	.tx_counters = 1,
> > +	.no_gptp = 1,
> 
>    Mhm, I definitely don't like the way you "extend" the GbEthernet info
> structure. All the applicable flags should be set in the last patch of the
> series, not amidst of it.

According to me, It is clearer with smaller patches like, what we have done with previous 2 patch sets for factorisation.
Please correct me, if any one have different opinion.

Regards,
Biju

> 
> [...]
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac
  2021-09-23 19:07   ` Sergey Shtylyov
@ 2021-09-23 19:22     ` Biju Das
  2021-09-23 19:29       ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 19:22 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

HI Sergei,

> Subject: Re: [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac
> 
> On 9/23/21 5:07 PM, Biju Das wrote:
> 
> > Initialize GbEthernet dmac found on RZ/G2L SoC.
> > This patch also renames ravb_rcar_dmac_init to ravb_dmac_init_rcar to
> > be consistent with the naming convention used in sh_eth driver.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  drivers/net/ethernet/renesas/ravb.h      |  4 ++
> >  drivers/net/ethernet/renesas/ravb_main.c | 84
> > +++++++++++++++++++++++-
> >  2 files changed, 85 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > b/drivers/net/ethernet/renesas/ravb.h
> > index 0ce0c13ef8cb..bee05e6fb815 100644
> > --- a/drivers/net/ethernet/renesas/ravb.h
> > +++ b/drivers/net/ethernet/renesas/ravb.h
> > @@ -81,6 +81,7 @@ enum ravb_reg {
> >  	RQC3	= 0x00A0,
> >  	RQC4	= 0x00A4,
> >  	RPC	= 0x00B0,
> > +	RTC	= 0x00B4,	/* RZ/G2L only */
> 
>    My gen3 manual says the regiuster exists there...
> 
> >  	UFCW	= 0x00BC,
> >  	UFCS	= 0x00C0,
> >  	UFCV0	= 0x00C4,
> > @@ -156,6 +157,7 @@ enum ravb_reg {
> >  	TIS	= 0x037C,
> >  	ISS	= 0x0380,
> >  	CIE	= 0x0384,	/* R-Car Gen3 only */
> > +	RIC3	= 0x0388,	/* RZ/G2L only */
> 
>    Again, this register (along with RIS3) exists on gen3...
> 
> >  	GCCR	= 0x0390,
> >  	GMTT	= 0x0394,
> >  	GPTC	= 0x0398,
> > @@ -956,6 +958,8 @@ enum RAVB_QUEUE {
> >
> >  #define RX_BUF_SZ	(2048 - ETH_FCS_LEN + sizeof(__sum16))
> >
> > +#define RGETH_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 2422e74d9b4f..54c4d31a6950 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_rgeth_set_rate(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_rgeth(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_rgeth(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_rgeth_alloc_rx_desc(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_rgeth_emac_init(struct net_device *ndev) {
> > +	/* Place holder */
> > +}
> > +
> >  static void ravb_rcar_emac_init(struct net_device *ndev)  {
> >  	/* Receive frame limit set register */ @@ -461,7 +487,32 @@ static
> > void ravb_emac_init(struct net_device *ndev)
> >  	info->emac_init(ndev);
> >  }
> >
> > -static void ravb_rcar_dmac_init(struct net_device *ndev)
> > +static void ravb_dmac_init_rgeth(struct net_device *ndev) {
> > +	/* Set AVB RX */
> > +	ravb_write(ndev, 0x60000000, RCR);
> > +
> > +	/* Set Max Frame Length (RTC) */
> > +	ravb_write(ndev, 0x7ffc0000 | RGETH_RX_BUFF_MAX, RTC);
> 
>    Should be init'ed on gen3 as well?

Rcar gen3 has separate initialization routine, This part is RZ/G2L specific, the buffer size is different.

> 
> > +
> > +	/* Set FIFO size */
> > +	ravb_write(ndev, 0x00222200, TGC);
> > +
> > +	ravb_write(ndev, 0, TCCR);
> > +
> > +	/* Frame receive */
> > +	ravb_write(ndev, RIC0_FRE0, RIC0);
> > +	/* Disable FIFO full warning */
> > +	ravb_write(ndev, 0x0, RIC1);
> > +	/* Receive FIFO full error, descriptor empty */
> > +	ravb_write(ndev, RIC2_QFE0 | RIC2_RFFE, RIC2);
> > +
> > +	ravb_write(ndev, 0x0, RIC3);
> 
>    Should be init'ed on gen3 as well? Matter of a separate patch, I can do
> it prolly...

OK. May be after completing RZ/G2L, I can investigate on gen3 stuff or If you have R-Car board and confirm this change 
Won't break anything on R-Car gen3, you can submit the patch.

Regards,
Biju


> 
> [...]
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac
  2021-09-23 19:22     ` Biju Das
@ 2021-09-23 19:29       ` Biju Das
  2021-09-26 13:38         ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 19:29 UTC (permalink / raw)
  To: Biju Das, Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergey,

> Subject: RE: [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac
> 
> HI Sergei,
> 
> > Subject: Re: [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac
> >
> > On 9/23/21 5:07 PM, Biju Das wrote:
> >
> > > Initialize GbEthernet dmac found on RZ/G2L SoC.
> > > This patch also renames ravb_rcar_dmac_init to ravb_dmac_init_rcar
> > > to be consistent with the naming convention used in sh_eth driver.
> > >
> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > > ---
> > >  drivers/net/ethernet/renesas/ravb.h      |  4 ++
> > >  drivers/net/ethernet/renesas/ravb_main.c | 84
> > > +++++++++++++++++++++++-
> > >  2 files changed, 85 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > > b/drivers/net/ethernet/renesas/ravb.h
> > > index 0ce0c13ef8cb..bee05e6fb815 100644
> > > --- a/drivers/net/ethernet/renesas/ravb.h
> > > +++ b/drivers/net/ethernet/renesas/ravb.h
> > > @@ -81,6 +81,7 @@ enum ravb_reg {
> > >  	RQC3	= 0x00A0,
> > >  	RQC4	= 0x00A4,
> > >  	RPC	= 0x00B0,
> > > +	RTC	= 0x00B4,	/* RZ/G2L only */
> >
> >    My gen3 manual says the regiuster exists there...

The existing driver is not using it. Since manual says there is RTC, I will document for Gen3 as well.

> >
> > >  	UFCW	= 0x00BC,
> > >  	UFCS	= 0x00C0,
> > >  	UFCV0	= 0x00C4,
> > > @@ -156,6 +157,7 @@ enum ravb_reg {
> > >  	TIS	= 0x037C,
> > >  	ISS	= 0x0380,
> > >  	CIE	= 0x0384,	/* R-Car Gen3 only */
> > > +	RIC3	= 0x0388,	/* RZ/G2L only */
> >
> >    Again, this register (along with RIS3) exists on gen3...

RIS3 is not used by R-Car or RZ/G2L hence it not documented.
But RIC3 is used by RZ/G2L. As per gen3 hw manual it is present, so I will update the comment.

> >
> > >  	GCCR	= 0x0390,
> > >  	GMTT	= 0x0394,
> > >  	GPTC	= 0x0398,
> > > @@ -956,6 +958,8 @@ enum RAVB_QUEUE {
> > >
> > >  #define RX_BUF_SZ	(2048 - ETH_FCS_LEN + sizeof(__sum16))
> > >
> > > +#define RGETH_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 2422e74d9b4f..54c4d31a6950 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_rgeth_set_rate(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_rgeth(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_rgeth(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_rgeth_alloc_rx_desc(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_rgeth_emac_init(struct net_device *ndev) {
> > > +	/* Place holder */
> > > +}
> > > +
> > >  static void ravb_rcar_emac_init(struct net_device *ndev)  {
> > >  	/* Receive frame limit set register */ @@ -461,7 +487,32 @@ static
> > > void ravb_emac_init(struct net_device *ndev)
> > >  	info->emac_init(ndev);
> > >  }
> > >
> > > -static void ravb_rcar_dmac_init(struct net_device *ndev)
> > > +static void ravb_dmac_init_rgeth(struct net_device *ndev) {
> > > +	/* Set AVB RX */
> > > +	ravb_write(ndev, 0x60000000, RCR);
> > > +
> > > +	/* Set Max Frame Length (RTC) */
> > > +	ravb_write(ndev, 0x7ffc0000 | RGETH_RX_BUFF_MAX, RTC);
> >
> >    Should be init'ed on gen3 as well?
> 
> Rcar gen3 has separate initialization routine, This part is RZ/G2L
> specific, the buffer size is different.
> 
> >
> > > +
> > > +	/* Set FIFO size */
> > > +	ravb_write(ndev, 0x00222200, TGC);
> > > +
> > > +	ravb_write(ndev, 0, TCCR);
> > > +
> > > +	/* Frame receive */
> > > +	ravb_write(ndev, RIC0_FRE0, RIC0);
> > > +	/* Disable FIFO full warning */
> > > +	ravb_write(ndev, 0x0, RIC1);
> > > +	/* Receive FIFO full error, descriptor empty */
> > > +	ravb_write(ndev, RIC2_QFE0 | RIC2_RFFE, RIC2);
> > > +
> > > +	ravb_write(ndev, 0x0, RIC3);
> >
> >    Should be init'ed on gen3 as well? Matter of a separate patch, I
> > can do it prolly...
> 
> OK. May be after completing RZ/G2L, I can investigate on gen3 stuff or If
> you have R-Car board and confirm this change Won't break anything on R-Car
> gen3, you can submit the patch.
> 
> Regards,
> Biju
> 
> 
> >
> > [...]
> >
> > MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 05/18] ravb: Exclude gPTP feature support for RZ/G2L
  2021-09-23 19:13     ` Biju Das
@ 2021-09-23 19:41       ` Sergey Shtylyov
  2021-09-23 19:45         ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-23 19:41 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

On 9/23/21 10:13 PM, Biju Das wrote:

[...]
>>> R-Car supports gPTP feature whereas RZ/G2L does not support it.
>>> This patch excludes gtp feature support for RZ/G2L by enabling no_gptp
>>> feature bit.
>>>
>>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
>>> ---
>>>  drivers/net/ethernet/renesas/ravb_main.c | 46
>>> ++++++++++++++----------
>>>  1 file changed, 28 insertions(+), 18 deletions(-)
>>>
>>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>>> b/drivers/net/ethernet/renesas/ravb_main.c
>>> index d38fc33a8e93..8663d83507a0 100644
>>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>> [...]
>>> @@ -953,7 +954,7 @@ static irqreturn_t ravb_interrupt(int irq, void
>> *dev_id)
>>>  	}
>>>
>>>  	/* gPTP interrupt status summary */
>>> -	if (iss & ISS_CGIS) {
>>
>>    Isn't this bit always 0 on RZ/G2L?
> 
> This CGIM bit(BIT13) which is present on R-Car Gen3 is not present in RZ/G2L. As per the HW manual
> BIT13 is reserved bit and read is always 0.
> 
>>
>>> +	if (!info->no_gptp && (iss & ISS_CGIS)) {

   Then extending this check doesn't seem necessary?

>>>  		ravb_ptp_interrupt(ndev);
>>>  		result = IRQ_HANDLED;
>>>  	}
[...]
>>> @@ -2116,6 +2119,7 @@ static const struct ravb_hw_info rgeth_hw_info = {
>>>  	.emac_init = ravb_rgeth_emac_init,
>>>  	.aligned_tx = 1,
>>>  	.tx_counters = 1,
>>> +	.no_gptp = 1,
>>
>>    Mhm, I definitely don't like the way you "extend" the GbEthernet info
>> structure. All the applicable flags should be set in the last patch of the
>> series, not amidst of it.
> 
> According to me, It is clearer with smaller patches like, what we have done with previous 2 patch sets for factorisation.
> Please correct me, if any one have different opinion.

   I'm afraid you'd get a partly functioning device with the RZ/G2 info introduced amidst of the series
and then the necessary flags/values added to it. This should definitely be avoided.

> Regards,
> Biju

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 05/18] ravb: Exclude gPTP feature support for RZ/G2L
  2021-09-23 19:41       ` Sergey Shtylyov
@ 2021-09-23 19:45         ` Biju Das
  2021-09-26 13:48           ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-23 19:45 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

> Subject: Re: [RFC/PATCH 05/18] ravb: Exclude gPTP feature support for
> RZ/G2L
> 
> On 9/23/21 10:13 PM, Biju Das wrote:
> 
> [...]
> >>> R-Car supports gPTP feature whereas RZ/G2L does not support it.
> >>> This patch excludes gtp feature support for RZ/G2L by enabling
> >>> no_gptp feature bit.
> >>>
> >>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> >>> ---
> >>>  drivers/net/ethernet/renesas/ravb_main.c | 46
> >>> ++++++++++++++----------
> >>>  1 file changed, 28 insertions(+), 18 deletions(-)
> >>>
> >>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> >>> b/drivers/net/ethernet/renesas/ravb_main.c
> >>> index d38fc33a8e93..8663d83507a0 100644
> >>> --- a/drivers/net/ethernet/renesas/ravb_main.c
> >>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> >> [...]
> >>> @@ -953,7 +954,7 @@ static irqreturn_t ravb_interrupt(int irq, void
> >> *dev_id)
> >>>  	}
> >>>
> >>>  	/* gPTP interrupt status summary */
> >>> -	if (iss & ISS_CGIS) {
> >>
> >>    Isn't this bit always 0 on RZ/G2L?
> >
> > This CGIM bit(BIT13) which is present on R-Car Gen3 is not present in
> > RZ/G2L. As per the HW manual
> > BIT13 is reserved bit and read is always 0.
> >
> >>
> >>> +	if (!info->no_gptp && (iss & ISS_CGIS)) {
> 
>    Then extending this check doesn't seem necessary?
> 
> >>>  		ravb_ptp_interrupt(ndev);
> >>>  		result = IRQ_HANDLED;
> >>>  	}
> [...]
> >>> @@ -2116,6 +2119,7 @@ static const struct ravb_hw_info rgeth_hw_info =
> {
> >>>  	.emac_init = ravb_rgeth_emac_init,
> >>>  	.aligned_tx = 1,
> >>>  	.tx_counters = 1,
> >>> +	.no_gptp = 1,
> >>
> >>    Mhm, I definitely don't like the way you "extend" the GbEthernet
> >> info structure. All the applicable flags should be set in the last
> >> patch of the series, not amidst of it.
> >
> > According to me, It is clearer with smaller patches like, what we have
> done with previous 2 patch sets for factorisation.
> > Please correct me, if any one have different opinion.
> 
>    I'm afraid you'd get a partly functioning device with the RZ/G2 info
> introduced amidst of the series and then the necessary flags/values added
> to it. This should definitely be avoided.

It is ok, It is understood, After replacing all  the place holders only we get full functionality.
That is the reason place holders added in first patch, so that we can fill each function at later stage
By smaller patcher. Same case for feature bits.

Regards,
Biju

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 06/18] ravb: Add multi_tsrq to struct ravb_hw_info
  2021-09-23 14:08 ` [RFC/PATCH 06/18] ravb: Add multi_tsrq to struct ravb_hw_info Biju Das
@ 2021-09-23 20:19   ` Sergey Shtylyov
  2021-09-24  6:19     ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-23 20:19 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Sergei Shtylyov, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

On 9/23/21 5:08 PM, Biju Das wrote:

> R-Car AVB-DMAC has 4 Transmit start Request queues, whereas
> RZ/G2L has only 1 Transmit start Request queue(Best Effort)
> 
> Add a multi_tsrq hw feature bit to struct ravb_hw_info to enable
> this only for R-Car. This will allow us to add single TSRQ support for
> RZ/G2L.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/net/ethernet/renesas/ravb.h      |  1 +
>  drivers/net/ethernet/renesas/ravb_main.c | 12 ++++++++++--
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
> index bb92469d770e..c043ee555be4 100644
> --- a/drivers/net/ethernet/renesas/ravb.h
> +++ b/drivers/net/ethernet/renesas/ravb.h
> @@ -1006,6 +1006,7 @@ struct ravb_hw_info {
>  	unsigned multi_irqs:1;		/* AVB-DMAC and E-MAC has multiple irqs */
>  	unsigned no_gptp:1;		/* AVB-DMAC does not support gPTP feature */
>  	unsigned ccc_gac:1;		/* AVB-DMAC has gPTP support active in config mode */
> +	unsigned multi_tsrq:1;		/* AVB-DMAC has MULTI TSRQ */

   Maybe 'single_tx_q' instead?

>  };
>  
>  struct ravb_private {
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 8663d83507a0..d37d73f6d984 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -776,11 +776,17 @@ static void ravb_rcv_snd_enable(struct net_device *ndev)
>  /* function for waiting dma process finished */
>  static int ravb_stop_dma(struct net_device *ndev)
>  {
> +	struct ravb_private *priv = netdev_priv(ndev);
> +	const struct ravb_hw_info *info = priv->info;
>  	int error;
>  
>  	/* Wait for stopping the hardware TX process */
> -	error = ravb_wait(ndev, TCCR,
> -			  TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3, 0);
> +	if (info->multi_tsrq)
> +		error = ravb_wait(ndev, TCCR,
> +				  TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3, 0);
> +	else
> +		error = ravb_wait(ndev, TCCR, TCCR_TSRQ0, 0);

   Aren't the TSRQ1/2/3 bits reserved on RZ/G2L? If so, this new flag adds a little value, I think... unless
you plan to use this flag further in the series?

MBR, Sergei

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 07/18] ravb: Add magic_pkt to struct ravb_hw_info
  2021-09-23 14:08 ` [RFC/PATCH 07/18] ravb: Add magic_pkt " Biju Das
@ 2021-09-23 20:42   ` Sergey Shtylyov
  2021-09-24  6:24     ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-23 20:42 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Sergei Shtylyov, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

On 9/23/21 5:08 PM, Biju Das wrote:

> E-MAC on R-Car supports magic packet detection, whereas RZ/G2L
> do not support this feature. Add magic_pkt to struct ravb_hw_info
> and enable this feature only for R-Car.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
[...]
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index d37d73f6d984..529364d8f7fb 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -811,12 +811,13 @@ static int ravb_stop_dma(struct net_device *ndev)
>  static void ravb_emac_interrupt_unlocked(struct net_device *ndev)
>  {
>  	struct ravb_private *priv = netdev_priv(ndev);
> +	const struct ravb_hw_info *info = priv->info;
>  	u32 ecsr, psr;
>  
>  	ecsr = ravb_read(ndev, ECSR);
>  	ravb_write(ndev, ecsr, ECSR);	/* clear interrupt */
>  
> -	if (ecsr & ECSR_MPD)
> +	if (info->magic_pkt && (ecsr & ECSR_MPD))

   I think masking the MPD interrupt would be enough.

>  		pm_wakeup_event(&priv->pdev->dev, 0);
>  	if (ecsr & ECSR_ICD)
>  		ndev->stats.tx_carrier_errors++;
> @@ -1416,8 +1417,9 @@ static void ravb_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)

   Didn't you miss ravb_get_wol() -- it needs a change as well...

>  static int ravb_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
>  {
>  	struct ravb_private *priv = netdev_priv(ndev);
> +	const struct ravb_hw_info *info = priv->info;
>  
> -	if (wol->wolopts & ~WAKE_MAGIC)
> +	if (!info->magic_pkt || (wol->wolopts & ~WAKE_MAGIC))
>  		return -EOPNOTSUPP;
>  
>  	priv->wol_enabled = !!(wol->wolopts & WAKE_MAGIC);
[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 06/18] ravb: Add multi_tsrq to struct ravb_hw_info
  2021-09-23 20:19   ` Sergey Shtylyov
@ 2021-09-24  6:19     ` Biju Das
  2021-09-26 13:54       ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-24  6:19 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

Thanks for the feedback.

> Subject: Re: [RFC/PATCH 06/18] ravb: Add multi_tsrq to struct ravb_hw_info
> 
> On 9/23/21 5:08 PM, Biju Das wrote:
> 
> > R-Car AVB-DMAC has 4 Transmit start Request queues, whereas RZ/G2L has
> > only 1 Transmit start Request queue(Best Effort)
> >
> > Add a multi_tsrq hw feature bit to struct ravb_hw_info to enable this
> > only for R-Car. This will allow us to add single TSRQ support for
> > RZ/G2L.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  drivers/net/ethernet/renesas/ravb.h      |  1 +
> >  drivers/net/ethernet/renesas/ravb_main.c | 12 ++++++++++--
> >  2 files changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > b/drivers/net/ethernet/renesas/ravb.h
> > index bb92469d770e..c043ee555be4 100644
> > --- a/drivers/net/ethernet/renesas/ravb.h
> > +++ b/drivers/net/ethernet/renesas/ravb.h
> > @@ -1006,6 +1006,7 @@ struct ravb_hw_info {
> >  	unsigned multi_irqs:1;		/* AVB-DMAC and E-MAC has multiple
> irqs */
> >  	unsigned no_gptp:1;		/* AVB-DMAC does not support gPTP
> feature */
> >  	unsigned ccc_gac:1;		/* AVB-DMAC has gPTP support active in
> config mode */
> > +	unsigned multi_tsrq:1;		/* AVB-DMAC has MULTI TSRQ */
> 
>    Maybe 'single_tx_q' instead? 

Since it is called transmit start request queue, it is better to be named as single_tsrq
to match with hardware manual and I will update the comment with "GbEthernet DMAC has single TSRQ"
Please let me know are you ok with it. Other wise I would like to use existing name.

> 
> >  };
> >
> >  struct ravb_private {
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index 8663d83507a0..d37d73f6d984 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > @@ -776,11 +776,17 @@ static void ravb_rcv_snd_enable(struct
> > net_device *ndev)
> >  /* function for waiting dma process finished */  static int
> > ravb_stop_dma(struct net_device *ndev)  {
> > +	struct ravb_private *priv = netdev_priv(ndev);
> > +	const struct ravb_hw_info *info = priv->info;
> >  	int error;
> >
> >  	/* Wait for stopping the hardware TX process */
> > -	error = ravb_wait(ndev, TCCR,
> > -			  TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3, 0);
> > +	if (info->multi_tsrq)
> > +		error = ravb_wait(ndev, TCCR,
> > +				  TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 |
> TCCR_TSRQ3, 0);
> > +	else
> > +		error = ravb_wait(ndev, TCCR, TCCR_TSRQ0, 0);
> 
>    Aren't the TSRQ1/2/3 bits reserved on RZ/G2L? If so, this new flag adds
> a little value, I think... unless you plan to use this flag further in the
> series?

It will be confusing for RZ/G2L users. HW manual does not describes TSRQ1/2/3
and we are writing undocumented registers which is reserved.

Tomorrow it can happen that this reserved bits(90% it will not happen) will be used for describing something else.

It is unsafe to use reserved bits. Are you agreeing with this?

Regards,
Biju

> 
> MBR, Sergei

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 07/18] ravb: Add magic_pkt to struct ravb_hw_info
  2021-09-23 20:42   ` Sergey Shtylyov
@ 2021-09-24  6:24     ` Biju Das
  2021-09-26 13:56       ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-24  6:24 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

Thanks for the feedback.

> Subject: Re: [RFC/PATCH 07/18] ravb: Add magic_pkt to struct ravb_hw_info
> 
> On 9/23/21 5:08 PM, Biju Das wrote:
> 
> > E-MAC on R-Car supports magic packet detection, whereas RZ/G2L do not
> > support this feature. Add magic_pkt to struct ravb_hw_info and enable
> > this feature only for R-Car.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> [...]
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index d37d73f6d984..529364d8f7fb 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > @@ -811,12 +811,13 @@ static int ravb_stop_dma(struct net_device
> > *ndev)  static void ravb_emac_interrupt_unlocked(struct net_device
> > *ndev)  {
> >  	struct ravb_private *priv = netdev_priv(ndev);
> > +	const struct ravb_hw_info *info = priv->info;
> >  	u32 ecsr, psr;
> >
> >  	ecsr = ravb_read(ndev, ECSR);
> >  	ravb_write(ndev, ecsr, ECSR);	/* clear interrupt */
> >
> > -	if (ecsr & ECSR_MPD)
> > +	if (info->magic_pkt && (ecsr & ECSR_MPD))
> 
>    I think masking the MPD interrupt would be enough.

Agreed.

> 
> >  		pm_wakeup_event(&priv->pdev->dev, 0);
> >  	if (ecsr & ECSR_ICD)
> >  		ndev->stats.tx_carrier_errors++;
> > @@ -1416,8 +1417,9 @@ static void ravb_get_wol(struct net_device
> > *ndev, struct ethtool_wolinfo *wol)
> 
>    Didn't you miss ravb_get_wol() -- it needs a change as well...

I don't think it is required. Framework is taking care of this. Please see the output from target.

root@smarc-rzg2l:~# ethtool -s eth0 wol g
netlink error: Operation not supported
root@smarc-rzg2l:~#


Regards,
Biju

> 
> >  static int ravb_set_wol(struct net_device *ndev, struct
> > ethtool_wolinfo *wol)  {
> >  	struct ravb_private *priv = netdev_priv(ndev);
> > +	const struct ravb_hw_info *info = priv->info;
> >
> > -	if (wol->wolopts & ~WAKE_MAGIC)
> > +	if (!info->magic_pkt || (wol->wolopts & ~WAKE_MAGIC))
> >  		return -EOPNOTSUPP;
> >
> >  	priv->wol_enabled = !!(wol->wolopts & WAKE_MAGIC);
> [...]
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 11/18] ravb: Add rx_2k_buffers to struct ravb_hw_info
  2021-09-23 14:08 ` [RFC/PATCH 11/18] ravb: Add rx_2k_buffers to struct ravb_hw_info Biju Das
@ 2021-09-24 19:35   ` Sergey Shtylyov
  2021-09-26 15:48     ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-24 19:35 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Sergei Shtylyov, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

On 9/23/21 5:08 PM, Biju Das wrote:

> R-Car AVB-DMAC has Maximum 2K size on RZ buffer.
> We need to Allow for changing the MTU within the
> limit of the maximum size of a descriptor (2048 bytes).
> 
> Add a rx_2k_buffers hw feature bit to struct ravb_hw_info
> to add this constraint only for R-Car.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/net/ethernet/renesas/ravb.h      | 1 +
>  drivers/net/ethernet/renesas/ravb_main.c | 8 ++++++--
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
> index 7532cb51d7b8..ab4909244276 100644
> --- a/drivers/net/ethernet/renesas/ravb.h
> +++ b/drivers/net/ethernet/renesas/ravb.h
> @@ -1033,6 +1033,7 @@ struct ravb_hw_info {
>  	unsigned magic_pkt:1;		/* E-MAC supports magic packet detection */
>  	unsigned mii_rgmii_selection:1;	/* E-MAC supports mii/rgmii selection */
>  	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
> +	unsigned rx_2k_buffers:1;	/* AVB-DMAC has Max 2K buf size on RX */

   It seems more flexible to specify the buffer size, not just a bit like this...

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 08/18] ravb: Add mii_rgmii_selection to struct ravb_hw_info
  2021-09-23 14:08 ` [RFC/PATCH 08/18] ravb: Add mii_rgmii_selection " Biju Das
@ 2021-09-24 19:49   ` Sergey Shtylyov
  2021-09-25  6:23     ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-24 19:49 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Sergei Shtylyov, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

On 9/23/21 5:08 PM, Biju Das wrote:

> E-MAC on RZ/G2L supports MII/RGMII selection. Add a
> mii_rgmii_selection feature bit to struct ravb_hw_info
> to support this for RZ/G2L.
> Currently only selecting RGMII is supported.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/net/ethernet/renesas/ravb.h      | 17 +++++++++++++++++
>  drivers/net/ethernet/renesas/ravb_main.c |  6 ++++++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
> index bce480fadb91..dfaf3121da44 100644
> --- a/drivers/net/ethernet/renesas/ravb.h
> +++ b/drivers/net/ethernet/renesas/ravb.h
[...]
> @@ -951,6 +953,20 @@ enum RAVB_QUEUE {
>  	RAVB_NC,	/* Network Control Queue */
>  };
>  
> +enum CXR31_BIT {
> +	CXR31_SEL_LINK0	= 0x00000001,
> +	CXR31_SEL_LINK1	= 0x00000008,
> +};
> +
> +enum CXR35_BIT {
> +	CXR35_SEL_MODIN	= 0x00000100,
> +};
> +
> +enum CSR0_BIT {
> +	CSR0_TPE	= 0x00000010,
> +	CSR0_RPE	= 0x00000020,
> +};

   I don't see those used? What is CSR0?

[...]
> @@ -1008,6 +1024,7 @@ struct ravb_hw_info {
>  	unsigned ccc_gac:1;		/* AVB-DMAC has gPTP support active in config mode */
>  	unsigned multi_tsrq:1;		/* AVB-DMAC has MULTI TSRQ */
>  	unsigned magic_pkt:1;		/* E-MAC supports magic packet detection */
> +	unsigned mii_rgmii_selection:1;	/* E-MAC supports mii/rgmii selection */

   Perhaps just 'mii_rgmii_sel'?

[...]
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 529364d8f7fb..5d18681582b9 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
[...]
> @@ -1173,6 +1174,10 @@ static int ravb_phy_init(struct net_device *ndev)
>  		netdev_info(ndev, "limited PHY to 100Mbit/s\n");
>  	}
>  
> +	if (info->mii_rgmii_selection &&
> +	    priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID)

   Not MII?

> +		ravb_write(ndev, ravb_read(ndev, CXR35) | CXR35_SEL_MODIN, CXR35);

   We have ravb_mnodify() for that...

> +
>  	/* 10BASE, Pause and Asym Pause is not supported */
>  	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Half_BIT);
>  	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Full_BIT);
> @@ -2132,6 +2137,7 @@ static const struct ravb_hw_info rgeth_hw_info = {
>  	.aligned_tx = 1,
>  	.tx_counters = 1,
>  	.no_gptp = 1,
> +	.mii_rgmii_selection = 1,

   I don't see where we handle MII?

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 09/18] ravb: Add half_duplex to struct ravb_hw_info
  2021-09-23 14:08 ` [RFC/PATCH 09/18] ravb: Add half_duplex " Biju Das
@ 2021-09-24 20:07   ` Sergey Shtylyov
  2021-09-25  6:37     ` Biju Das
  2021-09-26 15:51     ` Biju Das
  0 siblings, 2 replies; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-24 20:07 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Sergei Shtylyov, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

On 9/23/21 5:08 PM, Biju Das wrote:

> RZ/G2L supports half duplex mode.
> Add a half_duplex hw feature bit to struct ravb_hw_info for
> supporting half duplex mode for RZ/G2L.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
[...]

Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>

   Just a little bit of change needed...

[...]
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 5d18681582b9..04bff44b7660 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -1076,6 +1076,18 @@ static int ravb_poll(struct napi_struct *napi, int budget)
>  	return budget - quota;
>  }
>  
> +static void ravb_set_duplex_rgeth(struct net_device *ndev)
> +{
> +	struct ravb_private *priv = netdev_priv(ndev);
> +	u32 ecmr = ravb_read(ndev, ECMR);
> +
> +	if (priv->duplex > 0)	/* Full */
> +		ecmr |=  ECMR_DM;
> +	else			/* Half */
> +		ecmr &= ~ECMR_DM;
> +	ravb_write(ndev, ecmr, ECMR);

   I think we should do that like sh_eth.c:

	ravb_modify(ndev, ECMR, ECMR_DM, priv->duplex > 0 ? ECMR_DM : 0);

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 10/18] ravb: Initialize GbEthernet E-MAC
  2021-09-23 14:08 ` [RFC/PATCH 10/18] ravb: Initialize GbEthernet E-MAC Biju Das
@ 2021-09-24 20:44   ` Sergey Shtylyov
  2021-09-25  6:38     ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-24 20:44 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Sergei Shtylyov, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

On 9/23/21 5:08 PM, Biju Das wrote:

> Initialize GbEthernet E-MAC found on RZ/G2L SoC.
> This patch also renames ravb_set_rate to ravb_set_rate_rcar and
> ravb_rcar_emac_init to ravb_emac_init_rcar to be consistent with
> the naming convention used in sh_eth driver.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/net/ethernet/renesas/ravb.h      | 15 ++++--
>  drivers/net/ethernet/renesas/ravb_main.c | 64 +++++++++++++++++++-----
>  2 files changed, 62 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
> index 7f68f9b8349c..7532cb51d7b8 100644
> --- a/drivers/net/ethernet/renesas/ravb.h
> +++ b/drivers/net/ethernet/renesas/ravb.h
> @@ -204,6 +204,7 @@ enum ravb_reg {
>  	TLFRCR	= 0x0758,
>  	RFCR	= 0x0760,
>  	MAFCR	= 0x0778,
> +	CSR0     = 0x0800,	/* Documented for RZ/G2L only */

   Ah, the CSR0 bit *enum* belongs here! :-) 

[...]
> @@ -827,6 +829,7 @@ enum ECSR_BIT {
>  	ECSR_MPD	= 0x00000002,
>  	ECSR_LCHNG	= 0x00000004,
>  	ECSR_PHYI	= 0x00000008,
> +	ECSR_PFRI	= 0x00000010,

   It's not documented on gen2, perhaps it just doesn't exist there...

[...]
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 04bff44b7660..7f06adbd00e1 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
[...]
> @@ -447,12 +459,38 @@ static int ravb_ring_init(struct net_device *ndev, int q)
>  	return -ENOMEM;
>  }
>  
> -static void ravb_rgeth_emac_init(struct net_device *ndev)
> +static void ravb_emac_init_rgeth(struct net_device *ndev)
>  {
> -	/* Place holder */
> +	struct ravb_private *priv = netdev_priv(ndev);
> +
> +	/* Receive frame limit set register */
> +	ravb_write(ndev, RGETH_RX_BUFF_MAX + ETH_FCS_LEN, RFLR);
> +
> +	/* PAUSE prohibition */
> +	ravb_write(ndev, ECMR_ZPF | ((priv->duplex > 0) ? ECMR_DM : 0) |
> +			 ECMR_TE | ECMR_RE | ECMR_RCPT |
> +			 ECMR_TXF | ECMR_RXF | ECMR_PRM, ECMR);
> +
> +	ravb_set_rate_rgeth(ndev);
> +
> +	/* Set MAC address */
> +	ravb_write(ndev,
> +		   (ndev->dev_addr[0] << 24) | (ndev->dev_addr[1] << 16) |
> +		   (ndev->dev_addr[2] << 8)  | (ndev->dev_addr[3]), MAHR);
> +	ravb_write(ndev, (ndev->dev_addr[4] << 8)  | (ndev->dev_addr[5]), MALR);
> +
> +	/* E-MAC status register clear */
> +	ravb_write(ndev, ECSR_ICD | ECSR_LCHNG | ECSR_PFRI, ECSR);
> +	ravb_write(ndev, CSR0_TPE | CSR0_RPE, CSR0);
> +
> +	/* E-MAC interrupt enable register */
> +	ravb_write(ndev, ECSIPR_ICDIP, ECSIPR);
> +
> +	ravb_write(ndev, ravb_read(ndev, CXR31) & ~CXR31_SEL_LINK1, CXR31);
> +	ravb_write(ndev, ravb_read(ndev, CXR31) | CXR31_SEL_LINK0, CXR31);

   We have ravb_modify() for that, it'll help to avoid the double read/write...

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 08/18] ravb: Add mii_rgmii_selection to struct ravb_hw_info
  2021-09-24 19:49   ` Sergey Shtylyov
@ 2021-09-25  6:23     ` Biju Das
  2021-09-26 15:49       ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-09-25  6:23 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

Thanks for the feedback.

> Subject: Re: [RFC/PATCH 08/18] ravb: Add mii_rgmii_selection to struct
> ravb_hw_info
> 
> On 9/23/21 5:08 PM, Biju Das wrote:
> 
> > E-MAC on RZ/G2L supports MII/RGMII selection. Add a
> > mii_rgmii_selection feature bit to struct ravb_hw_info to support this
> > for RZ/G2L.
> > Currently only selecting RGMII is supported.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  drivers/net/ethernet/renesas/ravb.h      | 17 +++++++++++++++++
> >  drivers/net/ethernet/renesas/ravb_main.c |  6 ++++++
> >  2 files changed, 23 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > b/drivers/net/ethernet/renesas/ravb.h
> > index bce480fadb91..dfaf3121da44 100644
> > --- a/drivers/net/ethernet/renesas/ravb.h
> > +++ b/drivers/net/ethernet/renesas/ravb.h
> [...]
> > @@ -951,6 +953,20 @@ enum RAVB_QUEUE {
> >  	RAVB_NC,	/* Network Control Queue */
> >  };
> >
> > +enum CXR31_BIT {
> > +	CXR31_SEL_LINK0	= 0x00000001,
> > +	CXR31_SEL_LINK1	= 0x00000008,
> > +};
> > +
> > +enum CXR35_BIT {
> > +	CXR35_SEL_MODIN	= 0x00000100,
> > +};
> > +
> > +enum CSR0_BIT {
> > +	CSR0_TPE	= 0x00000010,
> > +	CSR0_RPE	= 0x00000020,
> > +};
> 
>    I don't see those used? What is CSR0?

OK, This has to be part of later patch for emac_init. CSR is checksum operating mode register in TOE.

> 
> [...]
> > @@ -1008,6 +1024,7 @@ struct ravb_hw_info {
> >  	unsigned ccc_gac:1;		/* AVB-DMAC has gPTP support active in
> config mode */
> >  	unsigned multi_tsrq:1;		/* AVB-DMAC has MULTI TSRQ */
> >  	unsigned magic_pkt:1;		/* E-MAC supports magic packet
> detection */
> > +	unsigned mii_rgmii_selection:1;	/* E-MAC supports mii/rgmii
> selection */
> 
>    Perhaps just 'mii_rgmii_sel'?
OK.

> 
> [...]
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index 529364d8f7fb..5d18681582b9 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> [...]
> > @@ -1173,6 +1174,10 @@ static int ravb_phy_init(struct net_device *ndev)
> >  		netdev_info(ndev, "limited PHY to 100Mbit/s\n");
> >  	}
> >
> > +	if (info->mii_rgmii_selection &&
> > +	    priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID)
> 
>    Not MII?

Currently only RGMII supported, see the commit message.
> 
> > +		ravb_write(ndev, ravb_read(ndev, CXR35) | CXR35_SEL_MODIN,
> CXR35);
> 
>    We have ravb_mnodify() for that...
> 
> > +
> >  	/* 10BASE, Pause and Asym Pause is not supported */
> >  	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Half_BIT);
> >  	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Full_BIT);
> > @@ -2132,6 +2137,7 @@ static const struct ravb_hw_info rgeth_hw_info = {
> >  	.aligned_tx = 1,
> >  	.tx_counters = 1,
> >  	.no_gptp = 1,
> > +	.mii_rgmii_selection = 1,
> 
>    I don't see where we handle MII?

See the commit message. "Currently only selecting RGMII is supported."
We have a plan to support this at later.

Regards,
Biju

> 
> [...]
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 09/18] ravb: Add half_duplex to struct ravb_hw_info
  2021-09-24 20:07   ` Sergey Shtylyov
@ 2021-09-25  6:37     ` Biju Das
  2021-09-26 15:51     ` Biju Das
  1 sibling, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-25  6:37 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

Thanks for the feedback.

> Subject: Re: [RFC/PATCH 09/18] ravb: Add half_duplex to struct
> ravb_hw_info
> 
> On 9/23/21 5:08 PM, Biju Das wrote:
> 
> > RZ/G2L supports half duplex mode.
> > Add a half_duplex hw feature bit to struct ravb_hw_info for supporting
> > half duplex mode for RZ/G2L.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> [...]
> 
> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> 
>    Just a little bit of change needed...
> 
> [...]
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index 5d18681582b9..04bff44b7660 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > @@ -1076,6 +1076,18 @@ static int ravb_poll(struct napi_struct *napi,
> int budget)
> >  	return budget - quota;
> >  }
> >
> > +static void ravb_set_duplex_rgeth(struct net_device *ndev) {
> > +	struct ravb_private *priv = netdev_priv(ndev);
> > +	u32 ecmr = ravb_read(ndev, ECMR);
> > +
> > +	if (priv->duplex > 0)	/* Full */
> > +		ecmr |=  ECMR_DM;
> > +	else			/* Half */
> > +		ecmr &= ~ECMR_DM;
> > +	ravb_write(ndev, ecmr, ECMR);
> 
>    I think we should do that like sh_eth.c:
> 
> 	ravb_modify(ndev, ECMR, ECMR_DM, priv->duplex > 0 ? ECMR_DM : 0);
OK. Will do

Regards,
Biju

> 
> [...]
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 10/18] ravb: Initialize GbEthernet E-MAC
  2021-09-24 20:44   ` Sergey Shtylyov
@ 2021-09-25  6:38     ` Biju Das
  0 siblings, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-25  6:38 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

Thanks for the feedback.

> Subject: Re: [RFC/PATCH 10/18] ravb: Initialize GbEthernet E-MAC
> 
> On 9/23/21 5:08 PM, Biju Das wrote:
> 
> > Initialize GbEthernet E-MAC found on RZ/G2L SoC.
> > This patch also renames ravb_set_rate to ravb_set_rate_rcar and
> > ravb_rcar_emac_init to ravb_emac_init_rcar to be consistent with the
> > naming convention used in sh_eth driver.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  drivers/net/ethernet/renesas/ravb.h      | 15 ++++--
> >  drivers/net/ethernet/renesas/ravb_main.c | 64
> > +++++++++++++++++++-----
> >  2 files changed, 62 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > b/drivers/net/ethernet/renesas/ravb.h
> > index 7f68f9b8349c..7532cb51d7b8 100644
> > --- a/drivers/net/ethernet/renesas/ravb.h
> > +++ b/drivers/net/ethernet/renesas/ravb.h
> > @@ -204,6 +204,7 @@ enum ravb_reg {
> >  	TLFRCR	= 0x0758,
> >  	RFCR	= 0x0760,
> >  	MAFCR	= 0x0778,
> > +	CSR0     = 0x0800,	/* Documented for RZ/G2L only */
> 
>    Ah, the CSR0 bit *enum* belongs here! :-)

Yes, will move enum bits from previous patch

> 
> [...]
> > @@ -827,6 +829,7 @@ enum ECSR_BIT {
> >  	ECSR_MPD	= 0x00000002,
> >  	ECSR_LCHNG	= 0x00000004,
> >  	ECSR_PHYI	= 0x00000008,
> > +	ECSR_PFRI	= 0x00000010,
> 
>    It's not documented on gen2, perhaps it just doesn't exist there...
> 
> [...]
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index 04bff44b7660..7f06adbd00e1 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> [...]
> > @@ -447,12 +459,38 @@ static int ravb_ring_init(struct net_device *ndev,
> int q)
> >  	return -ENOMEM;
> >  }
> >
> > -static void ravb_rgeth_emac_init(struct net_device *ndev)
> > +static void ravb_emac_init_rgeth(struct net_device *ndev)
> >  {
> > -	/* Place holder */
> > +	struct ravb_private *priv = netdev_priv(ndev);
> > +
> > +	/* Receive frame limit set register */
> > +	ravb_write(ndev, RGETH_RX_BUFF_MAX + ETH_FCS_LEN, RFLR);
> > +
> > +	/* PAUSE prohibition */
> > +	ravb_write(ndev, ECMR_ZPF | ((priv->duplex > 0) ? ECMR_DM : 0) |
> > +			 ECMR_TE | ECMR_RE | ECMR_RCPT |
> > +			 ECMR_TXF | ECMR_RXF | ECMR_PRM, ECMR);
> > +
> > +	ravb_set_rate_rgeth(ndev);
> > +
> > +	/* Set MAC address */
> > +	ravb_write(ndev,
> > +		   (ndev->dev_addr[0] << 24) | (ndev->dev_addr[1] << 16) |
> > +		   (ndev->dev_addr[2] << 8)  | (ndev->dev_addr[3]), MAHR);
> > +	ravb_write(ndev, (ndev->dev_addr[4] << 8)  | (ndev->dev_addr[5]),
> > +MALR);
> > +
> > +	/* E-MAC status register clear */
> > +	ravb_write(ndev, ECSR_ICD | ECSR_LCHNG | ECSR_PFRI, ECSR);
> > +	ravb_write(ndev, CSR0_TPE | CSR0_RPE, CSR0);
> > +
> > +	/* E-MAC interrupt enable register */
> > +	ravb_write(ndev, ECSIPR_ICDIP, ECSIPR);
> > +
> > +	ravb_write(ndev, ravb_read(ndev, CXR31) & ~CXR31_SEL_LINK1, CXR31);
> > +	ravb_write(ndev, ravb_read(ndev, CXR31) | CXR31_SEL_LINK0, CXR31);
> 
>    We have ravb_modify() for that, it'll help to avoid the double
> read/write...

OK

Regards,
Biju

> 
> [...]
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 12/18] ravb: Add timestamp to struct ravb_hw_info
  2021-09-23 14:08 ` [RFC/PATCH 12/18] ravb: Add timestamp " Biju Das
@ 2021-09-25 20:52   ` Sergey Shtylyov
  2021-09-26  6:34     ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-25 20:52 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Sergei Shtylyov, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

On 9/23/21 5:08 PM, Biju Das wrote:

> R-Car AVB-DMAC supports timestamp feature.
> Add a timestamp hw feature bit to struct ravb_hw_info
> to add this feature only for R-Car.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/net/ethernet/renesas/ravb.h      |  2 +
>  drivers/net/ethernet/renesas/ravb_main.c | 68 +++++++++++++++---------
>  2 files changed, 45 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
> index ab4909244276..2505de5d4a28 100644
> --- a/drivers/net/ethernet/renesas/ravb.h
> +++ b/drivers/net/ethernet/renesas/ravb.h
> @@ -1034,6 +1034,7 @@ struct ravb_hw_info {
>  	unsigned mii_rgmii_selection:1;	/* E-MAC supports mii/rgmii selection */
>  	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
>  	unsigned rx_2k_buffers:1;	/* AVB-DMAC has Max 2K buf size on RX */
> +	unsigned timestamp:1;		/* AVB-DMAC has timestamp */

   Isn't this a matter of the gPTP support as well, i.e. no separate flag needed?

[...]
> @@ -1089,6 +1090,7 @@ struct ravb_private {
>  	unsigned int num_tx_desc;	/* TX descriptors per packet */
>  
>  	int duplex;
> +	struct ravb_rx_desc *rgeth_rx_ring[NUM_RX_QUEUE];

   Strange place to declare this...

>  
>  	const struct ravb_hw_info *info;
>  	struct reset_control *rstc;
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 9c0d35f4b221..2c375002ebcb 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -949,11 +949,14 @@ static bool ravb_queue_interrupt(struct net_device *ndev, int q)
>  
>  static bool ravb_timestamp_interrupt(struct net_device *ndev)
>  {
> +	struct ravb_private *priv = netdev_priv(ndev);
> +	const struct ravb_hw_info *info = priv->info;
>  	u32 tis = ravb_read(ndev, TIS);
>  
>  	if (tis & TIS_TFUF) {
>  		ravb_write(ndev, ~(TIS_TFUF | TIS_RESERVED), TIS);
> -		ravb_get_tx_tstamp(ndev);
> +		if (info->timestamp)
> +			ravb_get_tx_tstamp(ndev);

   Shouldn't we just disable TIS.TFUF permanently instead for the non-gPTP case?

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 12/18] ravb: Add timestamp to struct ravb_hw_info
  2021-09-25 20:52   ` Sergey Shtylyov
@ 2021-09-26  6:34     ` Biju Das
  2021-09-26 16:52       ` Biju Das
  2021-09-26 20:45       ` Sergey Shtylyov
  0 siblings, 2 replies; 79+ messages in thread
From: Biju Das @ 2021-09-26  6:34 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

HI Sergei,

Thanks for the feedback.

> -----Original Message-----
> Subject: Re: [RFC/PATCH 12/18] ravb: Add timestamp to struct ravb_hw_info
> 
> On 9/23/21 5:08 PM, Biju Das wrote:
> 
> > R-Car AVB-DMAC supports timestamp feature.
> > Add a timestamp hw feature bit to struct ravb_hw_info to add this
> > feature only for R-Car.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  drivers/net/ethernet/renesas/ravb.h      |  2 +
> >  drivers/net/ethernet/renesas/ravb_main.c | 68
> > +++++++++++++++---------
> >  2 files changed, 45 insertions(+), 25 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > b/drivers/net/ethernet/renesas/ravb.h
> > index ab4909244276..2505de5d4a28 100644
> > --- a/drivers/net/ethernet/renesas/ravb.h
> > +++ b/drivers/net/ethernet/renesas/ravb.h
> > @@ -1034,6 +1034,7 @@ struct ravb_hw_info {
> >  	unsigned mii_rgmii_selection:1;	/* E-MAC supports mii/rgmii
> selection */
> >  	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
> >  	unsigned rx_2k_buffers:1;	/* AVB-DMAC has Max 2K buf size on RX
> */
> > +	unsigned timestamp:1;		/* AVB-DMAC has timestamp */
> 
>    Isn't this a matter of the gPTP support as well, i.e. no separate flag
> needed?

Agreed. Previously it is suggested to use timestamp. I will change it to as part of gPTP support cases.

> 
> [...]
> > @@ -1089,6 +1090,7 @@ struct ravb_private {
> >  	unsigned int num_tx_desc;	/* TX descriptors per packet */
> >
> >  	int duplex;
> > +	struct ravb_rx_desc *rgeth_rx_ring[NUM_RX_QUEUE];
> 
>    Strange place to declare this...

Agreed. This has to be on later patch. Will move it.

> 
> >
> >  	const struct ravb_hw_info *info;
> >  	struct reset_control *rstc;
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index 9c0d35f4b221..2c375002ebcb 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > @@ -949,11 +949,14 @@ static bool ravb_queue_interrupt(struct
> > net_device *ndev, int q)
> >
> >  static bool ravb_timestamp_interrupt(struct net_device *ndev)  {
> > +	struct ravb_private *priv = netdev_priv(ndev);
> > +	const struct ravb_hw_info *info = priv->info;
> >  	u32 tis = ravb_read(ndev, TIS);
> >
> >  	if (tis & TIS_TFUF) {
> >  		ravb_write(ndev, ~(TIS_TFUF | TIS_RESERVED), TIS);
> > -		ravb_get_tx_tstamp(ndev);
> > +		if (info->timestamp)
> > +			ravb_get_tx_tstamp(ndev);
> 
>    Shouldn't we just disable TIS.TFUF permanently instead for the non-gPTP
> case?

Good catch. As ravb_dmac_init_rgeth(will be renamed to "ravb_dmac_init_gbeth") is not enabling this interrupt as it is not documented in RZ/G2L hardware manual.
So this function never gets called for non-gPTP case.

I will remove this check.

Regards,
Biju


> 
> [...]
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 02/18] ravb: Rename the variables "no_ptp_cfg_active" and "ptp_cfg_active"
  2021-09-23 18:20         ` Biju Das
@ 2021-09-26 13:34           ` Biju Das
  0 siblings, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-26 13:34 UTC (permalink / raw)
  To: Biju Das, Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

> Subject: RE: [RFC/PATCH 02/18] ravb: Rename the variables
> "no_ptp_cfg_active" and "ptp_cfg_active"
> 
> Hi Sergei,
> 
> > Subject: Re: [RFC/PATCH 02/18] ravb: Rename the variables
> > "no_ptp_cfg_active" and "ptp_cfg_active"
> >
> > On 9/23/21 7:35 PM, Biju Das wrote:
> >
> > [...]
> > >>> Rename the variable "no_ptp_cfg_active" with "no_gptp" with
> > >>> inverted checks and "ptp_cfg_active" with "ccc_gac".
> > >>
> > >>    That's not exactly rename, no? At least for the 1st case...
> > >
> > > This is what we agreed as per last discussion[1].
> > >
> > > https://jpn01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpa
> > > tc
> > > hwork.kernel.org%2Fproject%2Flinux-renesas-soc%2Fpatch%2F20210825070
> > > 15
> > > 4.14336-5-biju.das.jz%40bp.renesas.com%2F&amp;data=04%7C01%7Cbiju.das.
> > > jz%40bp.renesas.com%7Cec41661b87e14f9e810808d97ebbae07%7C53d82571da1
> > > 94
> > > 7e49cb4625a166a4a2a%7C0%7C0%7C637680166814248680%7CUnknown%7CTWFpbGZ
> > > sb
> > > 3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3
> > > D%
> > > 7C1000&amp;sdata=ze0ica0K57exFOSQ9LyMuQ%2FFimvOW4PtH8ETxYJ8o6Y%3D&am
> > > p;
> > > reserved=0
> >
> >    Sorry, I've changed my mind about 'no_gpgp' after seeing all the
> > checks. I'd like to avoiud the double negations in those checks --
> > this should make the code more clear. My 1st idea (just 'gp[tp')
> > turned out to be more practical, sorry about this going
> > back-and-forth. :-<
> 
> So Just to confirm the name to be used are "ccc_gac" and "gptp".
> 
> Case 1) On R-Car Gen3, gPTP support is active in config mode. (replace
> "ptp_cfg_active" with "ccc_gac") Case 2) On R-Car Gen2, gPTP support is
> not active in config mode ( replace "no_ptp_cfg_active" with "gptp") Case
> 3) RZ/G2L does not support the gPTP feature(if "no_gac" or "gptp" then it
> falls to case 3).

As per the above discussion, I have prepared a new patch.

Regards,
Biju

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac
  2021-09-23 19:29       ` Biju Das
@ 2021-09-26 13:38         ` Biju Das
  0 siblings, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-26 13:38 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

> Subject: RE: [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac
> 
> Hi Sergey,
> 
> > Subject: RE: [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac
> >
> > HI Sergei,
> >
> > > Subject: Re: [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac
> > >
> > > On 9/23/21 5:07 PM, Biju Das wrote:
> > >
> > > > Initialize GbEthernet dmac found on RZ/G2L SoC.
> > > > This patch also renames ravb_rcar_dmac_init to ravb_dmac_init_rcar
> > > > to be consistent with the naming convention used in sh_eth driver.
> > > >
> > > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > > > ---
> > > >  drivers/net/ethernet/renesas/ravb.h      |  4 ++
> > > >  drivers/net/ethernet/renesas/ravb_main.c | 84
> > > > +++++++++++++++++++++++-
> > > >  2 files changed, 85 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > > > b/drivers/net/ethernet/renesas/ravb.h
> > > > index 0ce0c13ef8cb..bee05e6fb815 100644
> > > > --- a/drivers/net/ethernet/renesas/ravb.h
> > > > +++ b/drivers/net/ethernet/renesas/ravb.h
> > > > @@ -81,6 +81,7 @@ enum ravb_reg {
> > > >  	RQC3	= 0x00A0,
> > > >  	RQC4	= 0x00A4,
> > > >  	RPC	= 0x00B0,
> > > > +	RTC	= 0x00B4,	/* RZ/G2L only */
> > >
> > >    My gen3 manual says the regiuster exists there...
> 
> The existing driver is not using it. Since manual says there is RTC, I
> will document for Gen3 as well.
> 
> > >
> > > >  	UFCW	= 0x00BC,
> > > >  	UFCS	= 0x00C0,
> > > >  	UFCV0	= 0x00C4,
> > > > @@ -156,6 +157,7 @@ enum ravb_reg {
> > > >  	TIS	= 0x037C,
> > > >  	ISS	= 0x0380,
> > > >  	CIE	= 0x0384,	/* R-Car Gen3 only */
> > > > +	RIC3	= 0x0388,	/* RZ/G2L only */
> > >
> > >    Again, this register (along with RIS3) exists on gen3...
> 
> RIS3 is not used by R-Car or RZ/G2L hence it not documented.
> But RIC3 is used by RZ/G2L. As per gen3 hw manual it is present, so I will
> update the comment.

I am dropping RIC3 for RZ/G2L as default value  is 0 and code is initializing with 0
Which is not needed.

> 
> > >
> > > >  	GCCR	= 0x0390,
> > > >  	GMTT	= 0x0394,
> > > >  	GPTC	= 0x0398,
> > > > @@ -956,6 +958,8 @@ enum RAVB_QUEUE {
> > > >
> > > >  #define RX_BUF_SZ	(2048 - ETH_FCS_LEN + sizeof(__sum16))
> > > >
> > > > +#define RGETH_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 2422e74d9b4f..54c4d31a6950 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_rgeth_set_rate(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_rgeth(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_rgeth(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_rgeth_alloc_rx_desc(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_rgeth_emac_init(struct net_device *ndev) {
> > > > +	/* Place holder */
> > > > +}
> > > > +
> > > >  static void ravb_rcar_emac_init(struct net_device *ndev)  {
> > > >  	/* Receive frame limit set register */ @@ -461,7 +487,32 @@
> > > > static void ravb_emac_init(struct net_device *ndev)
> > > >  	info->emac_init(ndev);
> > > >  }
> > > >
> > > > -static void ravb_rcar_dmac_init(struct net_device *ndev)
> > > > +static void ravb_dmac_init_rgeth(struct net_device *ndev) {
> > > > +	/* Set AVB RX */
> > > > +	ravb_write(ndev, 0x60000000, RCR);
> > > > +
> > > > +	/* Set Max Frame Length (RTC) */
> > > > +	ravb_write(ndev, 0x7ffc0000 | RGETH_RX_BUFF_MAX, RTC);
> > >
> > >    Should be init'ed on gen3 as well?
> >
> > Rcar gen3 has separate initialization routine, This part is RZ/G2L
> > specific, the buffer size is different.
> >
> > >
> > > > +
> > > > +	/* Set FIFO size */
> > > > +	ravb_write(ndev, 0x00222200, TGC);
> > > > +
> > > > +	ravb_write(ndev, 0, TCCR);
> > > > +
> > > > +	/* Frame receive */
> > > > +	ravb_write(ndev, RIC0_FRE0, RIC0);
> > > > +	/* Disable FIFO full warning */
> > > > +	ravb_write(ndev, 0x0, RIC1);
> > > > +	/* Receive FIFO full error, descriptor empty */
> > > > +	ravb_write(ndev, RIC2_QFE0 | RIC2_RFFE, RIC2);
> > > > +
> > > > +	ravb_write(ndev, 0x0, RIC3);
> > >
> > >    Should be init'ed on gen3 as well? Matter of a separate patch, I
> > > can do it prolly...
> >
> > OK. May be after completing RZ/G2L, I can investigate on gen3 stuff or
> > If you have R-Car board and confirm this change Won't break anything
> > on R-Car gen3, you can submit the patch.

As mentioned above I am dropping this initialization for RIC3, as per H/W manual
Reset value of RIC3 is 0.

Regards,
Biju

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 04/18] ravb: Enable aligned_tx and tx_counters for RZ/G2L
  2021-09-23 18:13     ` Biju Das
@ 2021-09-26 13:40       ` Biju Das
  0 siblings, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-26 13:40 UTC (permalink / raw)
  To: Biju Das, Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

Hi Sergei,

> Subject: RE: [RFC/PATCH 04/18] ravb: Enable aligned_tx and tx_counters for
> RZ/G2L
> 
> Hi Sergei,
> 
> Thanks for the review.
> 
> > Subject: Re: [RFC/PATCH 04/18] ravb: Enable aligned_tx and tx_counters
> > for RZ/G2L
> >
> > On 9/23/21 5:07 PM, Biju Das wrote:
> >
> >    Somehow this patch haven't reached my OMP email -- I got it only
> > thru the linux-renesas-soc list... :-/
> >
> > > RZ/G2L need 4byte address alignment like R-Car Gen2 and it has
> > > tx_counters like R-Car Gen3. This patch enable these features for
> > > RZ/G2L.
> > >
> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > > ---
> > >  drivers/net/ethernet/renesas/ravb.h      | 2 +-
> > >  drivers/net/ethernet/renesas/ravb_main.c | 2 ++
> > >  2 files changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > > b/drivers/net/ethernet/renesas/ravb.h
> > > index bee05e6fb815..bb92469d770e 100644
> > > --- a/drivers/net/ethernet/renesas/ravb.h
> > > +++ b/drivers/net/ethernet/renesas/ravb.h
> > > @@ -195,7 +195,7 @@ enum ravb_reg {
> > >  	GECMR	= 0x05b0,
> > >  	MAHR	= 0x05c0,
> > >  	MALR	= 0x05c8,
> > > -	TROCR	= 0x0700,	/* R-Car Gen3 only */
> > > +	TROCR	= 0x0700,	/* R-Car Gen3 and RZ/G2L only */
> > >  	CEFCR	= 0x0740,
> > >  	FRECR	= 0x0748,
> > >  	TSFRCR	= 0x0750,
> > > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > > b/drivers/net/ethernet/renesas/ravb_main.c
> > > index 54c4d31a6950..d38fc33a8e93 100644
> > > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > > @@ -2114,6 +2114,8 @@ static const struct ravb_hw_info rgeth_hw_info =
> {
> > >  	.set_feature = ravb_set_features_rgeth,
> > >  	.dmac_init = ravb_dmac_init_rgeth,
> > >  	.emac_init = ravb_rgeth_emac_init,
> > > +	.aligned_tx = 1,
> > > +	.tx_counters = 1,
> >
> >    Mhm, I don't see a connection between those 2 (other than they're
> > both for RX). And anyway, this prolly should be a part of the previous
> patch...
> 
> There was a discussion to make smaller patches. If there is no objection,
> on the next revision I will add this as part of previous patch.
> 

Thanks, As discussed, I have merged this with previous patch, as it is trivial change.

Regards,
Biju

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 05/18] ravb: Exclude gPTP feature support for RZ/G2L
  2021-09-23 19:45         ` Biju Das
@ 2021-09-26 13:48           ` Biju Das
  0 siblings, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-26 13:48 UTC (permalink / raw)
  To: Biju Das, Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

> Subject: RE: [RFC/PATCH 05/18] ravb: Exclude gPTP feature support for
> RZ/G2L
> 
> Hi Sergei,
> 
> > Subject: Re: [RFC/PATCH 05/18] ravb: Exclude gPTP feature support for
> > RZ/G2L
> >
> > On 9/23/21 10:13 PM, Biju Das wrote:
> >
> > [...]
> > >>> R-Car supports gPTP feature whereas RZ/G2L does not support it.
> > >>> This patch excludes gtp feature support for RZ/G2L by enabling
> > >>> no_gptp feature bit.
> > >>>
> > >>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > >>> ---
> > >>>  drivers/net/ethernet/renesas/ravb_main.c | 46
> > >>> ++++++++++++++----------
> > >>>  1 file changed, 28 insertions(+), 18 deletions(-)
> > >>>
> > >>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > >>> b/drivers/net/ethernet/renesas/ravb_main.c
> > >>> index d38fc33a8e93..8663d83507a0 100644
> > >>> --- a/drivers/net/ethernet/renesas/ravb_main.c
> > >>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > >> [...]
> > >>> @@ -953,7 +954,7 @@ static irqreturn_t ravb_interrupt(int irq,
> > >>> void
> > >> *dev_id)
> > >>>  	}
> > >>>
> > >>>  	/* gPTP interrupt status summary */
> > >>> -	if (iss & ISS_CGIS) {
> > >>
> > >>    Isn't this bit always 0 on RZ/G2L?
> > >
> > > This CGIM bit(BIT13) which is present on R-Car Gen3 is not present
> > > in RZ/G2L. As per the HW manual
> > > BIT13 is reserved bit and read is always 0.

> > >
> > >>
> > >>> +	if (!info->no_gptp && (iss & ISS_CGIS)) {
> >
> >    Then extending this check doesn't seem necessary?

I have dropped this check in new version.

> >
> > >>>  		ravb_ptp_interrupt(ndev);
> > >>>  		result = IRQ_HANDLED;
> > >>>  	}
> > [...]
> > >>> @@ -2116,6 +2119,7 @@ static const struct ravb_hw_info
> > >>> rgeth_hw_info =
> > {
> > >>>  	.emac_init = ravb_rgeth_emac_init,
> > >>>  	.aligned_tx = 1,
> > >>>  	.tx_counters = 1,
> > >>> +	.no_gptp = 1,
> > >>
> > >>    Mhm, I definitely don't like the way you "extend" the GbEthernet
> > >> info structure. All the applicable flags should be set in the last
> > >> patch of the series, not amidst of it.
> > >
> > > According to me, It is clearer with smaller patches like, what we
> > > have
> > done with previous 2 patch sets for factorisation.
> > > Please correct me, if any one have different opinion.
> >
> >    I'm afraid you'd get a partly functioning device with the RZ/G2
> > info introduced amidst of the series and then the necessary
> > flags/values added to it. This should definitely be avoided.
> 
> It is ok, It is understood, After replacing all  the place holders only we
> get full functionality.
> That is the reason place holders added in first patch, so that we can fill
> each function at later stage By smaller patcher. Same case for feature
> bits.
> 

OK, the new patch excluded gPTP support for RZ/G2L and Also as per your suggestion,dropped timestamp feature bit and merged that code in this patch.

Regards,
Biju

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 06/18] ravb: Add multi_tsrq to struct ravb_hw_info
  2021-09-24  6:19     ` Biju Das
@ 2021-09-26 13:54       ` Biju Das
  0 siblings, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-26 13:54 UTC (permalink / raw)
  To: Biju Das, Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

> Subject: RE: [RFC/PATCH 06/18] ravb: Add multi_tsrq to struct ravb_hw_info
> 
> Hi Sergei,
> 
> Thanks for the feedback.
> 
> > Subject: Re: [RFC/PATCH 06/18] ravb: Add multi_tsrq to struct
> > ravb_hw_info
> >
> > On 9/23/21 5:08 PM, Biju Das wrote:
> >
> > > R-Car AVB-DMAC has 4 Transmit start Request queues, whereas RZ/G2L
> > > has only 1 Transmit start Request queue(Best Effort)
> > >
> > > Add a multi_tsrq hw feature bit to struct ravb_hw_info to enable
> > > this only for R-Car. This will allow us to add single TSRQ support
> > > for RZ/G2L.
> > >
> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > > ---
> > >  drivers/net/ethernet/renesas/ravb.h      |  1 +
> > >  drivers/net/ethernet/renesas/ravb_main.c | 12 ++++++++++--
> > >  2 files changed, 11 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > > b/drivers/net/ethernet/renesas/ravb.h
> > > index bb92469d770e..c043ee555be4 100644
> > > --- a/drivers/net/ethernet/renesas/ravb.h
> > > +++ b/drivers/net/ethernet/renesas/ravb.h
> > > @@ -1006,6 +1006,7 @@ struct ravb_hw_info {
> > >  	unsigned multi_irqs:1;		/* AVB-DMAC and E-MAC has multiple
> > irqs */
> > >  	unsigned no_gptp:1;		/* AVB-DMAC does not support gPTP
> > feature */
> > >  	unsigned ccc_gac:1;		/* AVB-DMAC has gPTP support active in
> > config mode */
> > > +	unsigned multi_tsrq:1;		/* AVB-DMAC has MULTI TSRQ */
> >
> >    Maybe 'single_tx_q' instead?
> 
> Since it is called transmit start request queue, it is better to be named
> as single_tsrq to match with hardware manual and I will update the comment
> with "GbEthernet DMAC has single TSRQ"
> Please let me know are you ok with it. Other wise I would like to use
> existing name.

On the next revision as you proposed for [1],
I will use a u32 tsrq, instead of bit, there by we can avoid a check.

https://patchwork.kernel.org/project/linux-renesas-soc/patch/20210923140813.13541-12-biju.das.jz@bp.renesas.com/
> 
> >
> > >  };
> > >
> > >  struct ravb_private {
> > > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > > b/drivers/net/ethernet/renesas/ravb_main.c
> > > index 8663d83507a0..d37d73f6d984 100644
> > > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > > @@ -776,11 +776,17 @@ static void ravb_rcv_snd_enable(struct
> > > net_device *ndev)
> > >  /* function for waiting dma process finished */  static int
> > > ravb_stop_dma(struct net_device *ndev)  {
> > > +	struct ravb_private *priv = netdev_priv(ndev);
> > > +	const struct ravb_hw_info *info = priv->info;
> > >  	int error;
> > >
> > >  	/* Wait for stopping the hardware TX process */
> > > -	error = ravb_wait(ndev, TCCR,
> > > -			  TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3, 0);
> > > +	if (info->multi_tsrq)
> > > +		error = ravb_wait(ndev, TCCR,
> > > +				  TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 |
> > TCCR_TSRQ3, 0);
> > > +	else
> > > +		error = ravb_wait(ndev, TCCR, TCCR_TSRQ0, 0);
> >
> >    Aren't the TSRQ1/2/3 bits reserved on RZ/G2L? If so, this new flag
> > adds a little value, I think... unless you plan to use this flag
> > further in the series?
> 
> It will be confusing for RZ/G2L users. HW manual does not describes
> TSRQ1/2/3 and we are writing undocumented registers which is reserved.
> 
> Tomorrow it can happen that this reserved bits(90% it will not happen)
> will be used for describing something else.
> 
> It is unsafe to use reserved bits. Are you agreeing with this?

As per the above discussion, we can replace the above check as you proposed for [1]

error = ravb_wait(ndev, TCCR, info->tsrq, 0);

[1] https://patchwork.kernel.org/project/linux-renesas-soc/patch/20210923140813.13541-12-biju.das.jz@bp.renesas.com/

regards,
Biju

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 07/18] ravb: Add magic_pkt to struct ravb_hw_info
  2021-09-24  6:24     ` Biju Das
@ 2021-09-26 13:56       ` Biju Das
  0 siblings, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-26 13:56 UTC (permalink / raw)
  To: Biju Das, Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

> Subject: RE: [RFC/PATCH 07/18] ravb: Add magic_pkt to struct ravb_hw_info
> 
> Hi Sergei,
> 
> Thanks for the feedback.
> 
> > Subject: Re: [RFC/PATCH 07/18] ravb: Add magic_pkt to struct
> > ravb_hw_info
> >
> > On 9/23/21 5:08 PM, Biju Das wrote:
> >
> > > E-MAC on R-Car supports magic packet detection, whereas RZ/G2L do
> > > not support this feature. Add magic_pkt to struct ravb_hw_info and
> > > enable this feature only for R-Car.
> > >
> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > [...]
> > > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > > b/drivers/net/ethernet/renesas/ravb_main.c
> > > index d37d73f6d984..529364d8f7fb 100644
> > > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > > @@ -811,12 +811,13 @@ static int ravb_stop_dma(struct net_device
> > > *ndev)  static void ravb_emac_interrupt_unlocked(struct net_device
> > > *ndev)  {
> > >  	struct ravb_private *priv = netdev_priv(ndev);
> > > +	const struct ravb_hw_info *info = priv->info;
> > >  	u32 ecsr, psr;
> > >
> > >  	ecsr = ravb_read(ndev, ECSR);
> > >  	ravb_write(ndev, ecsr, ECSR);	/* clear interrupt */
> > >
> > > -	if (ecsr & ECSR_MPD)
> > > +	if (info->magic_pkt && (ecsr & ECSR_MPD))
> >
> >    I think masking the MPD interrupt would be enough.
> 
> Agreed.
> 
> >
> > >  		pm_wakeup_event(&priv->pdev->dev, 0);
> > >  	if (ecsr & ECSR_ICD)
> > >  		ndev->stats.tx_carrier_errors++;
> > > @@ -1416,8 +1417,9 @@ static void ravb_get_wol(struct net_device
> > > *ndev, struct ethtool_wolinfo *wol)
> >
> >    Didn't you miss ravb_get_wol() -- it needs a change as well...
> 
> I don't think it is required. Framework is taking care of this. Please see
> the output from target.
> 
> root@smarc-rzg2l:~# ethtool -s eth0 wol g netlink error: Operation not
> supported root@smarc-rzg2l:~#
> 
> >
> > >  static int ravb_set_wol(struct net_device *ndev, struct
> > > ethtool_wolinfo *wol)  {
> > >  	struct ravb_private *priv = netdev_priv(ndev);
> > > +	const struct ravb_hw_info *info = priv->info;
> > >
> > > -	if (wol->wolopts & ~WAKE_MAGIC)
> > > +	if (!info->magic_pkt || (wol->wolopts & ~WAKE_MAGIC))
> > >  		return -EOPNOTSUPP;
> > >
> > >  	priv->wol_enabled = !!(wol->wolopts & WAKE_MAGIC);
> > [...]
> >

As discussed, the new patch removes info->magic_pkt from interrupt routine.

Regards,
Biju


^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 11/18] ravb: Add rx_2k_buffers to struct ravb_hw_info
  2021-09-24 19:35   ` Sergey Shtylyov
@ 2021-09-26 15:48     ` Biju Das
  0 siblings, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-26 15:48 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

> Subject: Re: [RFC/PATCH 11/18] ravb: Add rx_2k_buffers to struct
> ravb_hw_info
> 
> On 9/23/21 5:08 PM, Biju Das wrote:
> 
> > R-Car AVB-DMAC has Maximum 2K size on RZ buffer.
> > We need to Allow for changing the MTU within the limit of the maximum
> > size of a descriptor (2048 bytes).
> >
> > Add a rx_2k_buffers hw feature bit to struct ravb_hw_info to add this
> > constraint only for R-Car.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  drivers/net/ethernet/renesas/ravb.h      | 1 +
> >  drivers/net/ethernet/renesas/ravb_main.c | 8 ++++++--
> >  2 files changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > b/drivers/net/ethernet/renesas/ravb.h
> > index 7532cb51d7b8..ab4909244276 100644
> > --- a/drivers/net/ethernet/renesas/ravb.h
> > +++ b/drivers/net/ethernet/renesas/ravb.h
> > @@ -1033,6 +1033,7 @@ struct ravb_hw_info {
> >  	unsigned magic_pkt:1;		/* E-MAC supports magic packet
> detection */
> >  	unsigned mii_rgmii_selection:1;	/* E-MAC supports mii/rgmii
> selection */
> >  	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
> > +	unsigned rx_2k_buffers:1;	/* AVB-DMAC has Max 2K buf size on RX
> */
> 
>    It seems more flexible to specify the buffer size, not just a bit like
> this...

Agreed, will use rx_max_buf_size variable on the next version.

Regards,
Biju

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 08/18] ravb: Add mii_rgmii_selection to struct ravb_hw_info
  2021-09-25  6:23     ` Biju Das
@ 2021-09-26 15:49       ` Biju Das
  0 siblings, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-26 15:49 UTC (permalink / raw)
  To: Biju Das, Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

> Subject: RE: [RFC/PATCH 08/18] ravb: Add mii_rgmii_selection to struct
> ravb_hw_info
> 
> Hi Sergei,
> 
> Thanks for the feedback.
> 
> > Subject: Re: [RFC/PATCH 08/18] ravb: Add mii_rgmii_selection to struct
> > ravb_hw_info
> >
> > On 9/23/21 5:08 PM, Biju Das wrote:
> >
> > > E-MAC on RZ/G2L supports MII/RGMII selection. Add a
> > > mii_rgmii_selection feature bit to struct ravb_hw_info to support
> > > this for RZ/G2L.
> > > Currently only selecting RGMII is supported.
> > >
> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > > ---
> > >  drivers/net/ethernet/renesas/ravb.h      | 17 +++++++++++++++++
> > >  drivers/net/ethernet/renesas/ravb_main.c |  6 ++++++
> > >  2 files changed, 23 insertions(+)
> > >
> > > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > > b/drivers/net/ethernet/renesas/ravb.h
> > > index bce480fadb91..dfaf3121da44 100644
> > > --- a/drivers/net/ethernet/renesas/ravb.h
> > > +++ b/drivers/net/ethernet/renesas/ravb.h
> > [...]
> > > @@ -951,6 +953,20 @@ enum RAVB_QUEUE {
> > >  	RAVB_NC,	/* Network Control Queue */
> > >  };
> > >
> > > +enum CXR31_BIT {
> > > +	CXR31_SEL_LINK0	= 0x00000001,
> > > +	CXR31_SEL_LINK1	= 0x00000008,
> > > +};
> > > +
> > > +enum CXR35_BIT {
> > > +	CXR35_SEL_MODIN	= 0x00000100,
> > > +};
> > > +
> > > +enum CSR0_BIT {
> > > +	CSR0_TPE	= 0x00000010,
> > > +	CSR0_RPE	= 0x00000020,
> > > +};
> >
> >    I don't see those used? What is CSR0?
> 
> OK, This has to be part of later patch for emac_init. CSR is checksum
> operating mode register in TOE.
> 
> >
> > [...]
> > > @@ -1008,6 +1024,7 @@ struct ravb_hw_info {
> > >  	unsigned ccc_gac:1;		/* AVB-DMAC has gPTP support active in
> > config mode */
> > >  	unsigned multi_tsrq:1;		/* AVB-DMAC has MULTI TSRQ */
> > >  	unsigned magic_pkt:1;		/* E-MAC supports magic packet
> > detection */
> > > +	unsigned mii_rgmii_selection:1;	/* E-MAC supports mii/rgmii
> > selection */
> >
> >    Perhaps just 'mii_rgmii_sel'?
> OK.
> 
> >
> > [...]
> > > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > > b/drivers/net/ethernet/renesas/ravb_main.c
> > > index 529364d8f7fb..5d18681582b9 100644
> > > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > [...]
> > > @@ -1173,6 +1174,10 @@ static int ravb_phy_init(struct net_device
> *ndev)
> > >  		netdev_info(ndev, "limited PHY to 100Mbit/s\n");
> > >  	}
> > >
> > > +	if (info->mii_rgmii_selection &&
> > > +	    priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID)
> >
> >    Not MII?
> 
> Currently only RGMII supported, see the commit message.
> >
> > > +		ravb_write(ndev, ravb_read(ndev, CXR35) | CXR35_SEL_MODIN,
> > CXR35);
> >
> >    We have ravb_mnodify() for that...
> >
> > > +
> > >  	/* 10BASE, Pause and Asym Pause is not supported */
> > >  	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Half_BIT);
> > >  	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Full_BIT);
> > > @@ -2132,6 +2137,7 @@ static const struct ravb_hw_info rgeth_hw_info =
> {
> > >  	.aligned_tx = 1,
> > >  	.tx_counters = 1,
> > >  	.no_gptp = 1,
> > > +	.mii_rgmii_selection = 1,
> >
> >    I don't see where we handle MII?
> 
> See the commit message. "Currently only selecting RGMII is supported."
> We have a plan to support this at later.
> 

I have prepared a patch with "mii_rgmii_sel", will send next revision soon.

Regards,
Biju



^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 09/18] ravb: Add half_duplex to struct ravb_hw_info
  2021-09-24 20:07   ` Sergey Shtylyov
  2021-09-25  6:37     ` Biju Das
@ 2021-09-26 15:51     ` Biju Das
  1 sibling, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-26 15:51 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

> Subject: Re: [RFC/PATCH 09/18] ravb: Add half_duplex to struct
> ravb_hw_info
> 
> On 9/23/21 5:08 PM, Biju Das wrote:
> 
> > RZ/G2L supports half duplex mode.
> > Add a half_duplex hw feature bit to struct ravb_hw_info for supporting
> > half duplex mode for RZ/G2L.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> [...]
> 
> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> 
>    Just a little bit of change needed...
> 
> [...]
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index 5d18681582b9..04bff44b7660 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > @@ -1076,6 +1076,18 @@ static int ravb_poll(struct napi_struct *napi,
> int budget)
> >  	return budget - quota;
> >  }
> >
> > +static void ravb_set_duplex_rgeth(struct net_device *ndev) {
> > +	struct ravb_private *priv = netdev_priv(ndev);
> > +	u32 ecmr = ravb_read(ndev, ECMR);
> > +
> > +	if (priv->duplex > 0)	/* Full */
> > +		ecmr |=  ECMR_DM;
> > +	else			/* Half */
> > +		ecmr &= ~ECMR_DM;
> > +	ravb_write(ndev, ecmr, ECMR);
> 
>    I think we should do that like sh_eth.c:
> 
> 	ravb_modify(ndev, ECMR, ECMR_DM, priv->duplex > 0 ? ECMR_DM : 0);
> 

I have prepared a patch with this changes and also renamed the function "ravb_set_duplex_rgeth" to " ravb_set_duplex_gbeth"
As you suggested.

Regards,
Biju

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 12/18] ravb: Add timestamp to struct ravb_hw_info
  2021-09-26  6:34     ` Biju Das
@ 2021-09-26 16:52       ` Biju Das
  2021-09-26 20:45       ` Sergey Shtylyov
  1 sibling, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-26 16:52 UTC (permalink / raw)
  To: Biju Das, Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

> Subject: RE: [RFC/PATCH 12/18] ravb: Add timestamp to struct ravb_hw_info
> 
> HI Sergei,
> 
> Thanks for the feedback.
> 
> > -----Original Message-----
> > Subject: Re: [RFC/PATCH 12/18] ravb: Add timestamp to struct
> > ravb_hw_info
> >
> > On 9/23/21 5:08 PM, Biju Das wrote:
> >
> > > R-Car AVB-DMAC supports timestamp feature.
> > > Add a timestamp hw feature bit to struct ravb_hw_info to add this
> > > feature only for R-Car.
> > >
> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > > ---
> > >  drivers/net/ethernet/renesas/ravb.h      |  2 +
> > >  drivers/net/ethernet/renesas/ravb_main.c | 68
> > > +++++++++++++++---------
> > >  2 files changed, 45 insertions(+), 25 deletions(-)
> > >
> > > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > > b/drivers/net/ethernet/renesas/ravb.h
> > > index ab4909244276..2505de5d4a28 100644
> > > --- a/drivers/net/ethernet/renesas/ravb.h
> > > +++ b/drivers/net/ethernet/renesas/ravb.h
> > > @@ -1034,6 +1034,7 @@ struct ravb_hw_info {
> > >  	unsigned mii_rgmii_selection:1;	/* E-MAC supports mii/rgmii
> > selection */
> > >  	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
> > >  	unsigned rx_2k_buffers:1;	/* AVB-DMAC has Max 2K buf size on RX
> > */
> > > +	unsigned timestamp:1;		/* AVB-DMAC has timestamp */
> >
> >    Isn't this a matter of the gPTP support as well, i.e. no separate
> > flag needed?
> 
> Agreed. Previously it is suggested to use timestamp. I will change it to
> as part of gPTP support cases.
> 
> >
> > [...]
> > > @@ -1089,6 +1090,7 @@ struct ravb_private {
> > >  	unsigned int num_tx_desc;	/* TX descriptors per packet */
> > >
> > >  	int duplex;
> > > +	struct ravb_rx_desc *rgeth_rx_ring[NUM_RX_QUEUE];
> >
> >    Strange place to declare this...
> 
> Agreed. This has to be on later patch. Will move it.
> 
> >
> > >
> > >  	const struct ravb_hw_info *info;
> > >  	struct reset_control *rstc;
> > > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > > b/drivers/net/ethernet/renesas/ravb_main.c
> > > index 9c0d35f4b221..2c375002ebcb 100644
> > > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > > @@ -949,11 +949,14 @@ static bool ravb_queue_interrupt(struct
> > > net_device *ndev, int q)
> > >
> > >  static bool ravb_timestamp_interrupt(struct net_device *ndev)  {
> > > +	struct ravb_private *priv = netdev_priv(ndev);
> > > +	const struct ravb_hw_info *info = priv->info;
> > >  	u32 tis = ravb_read(ndev, TIS);
> > >
> > >  	if (tis & TIS_TFUF) {
> > >  		ravb_write(ndev, ~(TIS_TFUF | TIS_RESERVED), TIS);
> > > -		ravb_get_tx_tstamp(ndev);
> > > +		if (info->timestamp)
> > > +			ravb_get_tx_tstamp(ndev);
> >
> >    Shouldn't we just disable TIS.TFUF permanently instead for the
> > non-gPTP case?
> 
> Good catch. As ravb_dmac_init_rgeth(will be renamed to
> "ravb_dmac_init_gbeth") is not enabling this interrupt as it is not
> documented in RZ/G2L hardware manual.
> So this function never gets called for non-gPTP case.
> 
> I will remove this check.


As discussed, I will drop this patch in the next version and contents of this patch will be added to gPTP support cases.

Regards,
Biju

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 12/18] ravb: Add timestamp to struct ravb_hw_info
  2021-09-26  6:34     ` Biju Das
  2021-09-26 16:52       ` Biju Das
@ 2021-09-26 20:45       ` Sergey Shtylyov
  2021-09-26 20:48         ` Sergei Shtylyov
  2021-09-27  6:04         ` Biju Das
  1 sibling, 2 replies; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-26 20:45 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

On 9/26/21 9:34 AM, Biju Das wrote:

>> -----Original Message-----
>> Subject: Re: [RFC/PATCH 12/18] ravb: Add timestamp to struct ravb_hw_info
>>
>> On 9/23/21 5:08 PM, Biju Das wrote:
>>
>>> R-Car AVB-DMAC supports timestamp feature.
>>> Add a timestamp hw feature bit to struct ravb_hw_info to add this
>>> feature only for R-Car.
>>>
>>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
>>> ---
>>>  drivers/net/ethernet/renesas/ravb.h      |  2 +
>>>  drivers/net/ethernet/renesas/ravb_main.c | 68
>>> +++++++++++++++---------
>>>  2 files changed, 45 insertions(+), 25 deletions(-)
>>>
>>> diff --git a/drivers/net/ethernet/renesas/ravb.h
>>> b/drivers/net/ethernet/renesas/ravb.h
>>> index ab4909244276..2505de5d4a28 100644
>>> --- a/drivers/net/ethernet/renesas/ravb.h
>>> +++ b/drivers/net/ethernet/renesas/ravb.h
>>> @@ -1034,6 +1034,7 @@ struct ravb_hw_info {
>>>  	unsigned mii_rgmii_selection:1;	/* E-MAC supports mii/rgmii
>> selection */
>>>  	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
>>>  	unsigned rx_2k_buffers:1;	/* AVB-DMAC has Max 2K buf size on RX
>> */
>>> +	unsigned timestamp:1;		/* AVB-DMAC has timestamp */
>>
>>    Isn't this a matter of the gPTP support as well, i.e. no separate flag
>> needed?
> 
> Agreed. Previously it is suggested to use timestamp. I will change it to as part of gPTP support cases.

   TIA. :-)

>>
>> [...]
>>> @@ -1089,6 +1090,7 @@ struct ravb_private {
>>>  	unsigned int num_tx_desc;	/* TX descriptors per packet */
>>>
>>>  	int duplex;
>>> +	struct ravb_rx_desc *rgeth_rx_ring[NUM_RX_QUEUE];
>>
>>    Strange place to declare this...
> 
> Agreed. This has to be on later patch. Will move it.

   I only meant that these fields should go together with rx_ring[]. Apparently
we have a case of wrong patch ordering here (as this patch needs this field declared)...

>>>  	const struct ravb_hw_info *info;
>>>  	struct reset_control *rstc;
>>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>>> b/drivers/net/ethernet/renesas/ravb_main.c
>>> index 9c0d35f4b221..2c375002ebcb 100644
>>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>>> @@ -949,11 +949,14 @@ static bool ravb_queue_interrupt(struct
>>> net_device *ndev, int q)
>>>
>>>  static bool ravb_timestamp_interrupt(struct net_device *ndev)  {
>>> +	struct ravb_private *priv = netdev_priv(ndev);
>>> +	const struct ravb_hw_info *info = priv->info;
>>>  	u32 tis = ravb_read(ndev, TIS);
>>>
>>>  	if (tis & TIS_TFUF) {
>>>  		ravb_write(ndev, ~(TIS_TFUF | TIS_RESERVED), TIS);
>>> -		ravb_get_tx_tstamp(ndev);
>>> +		if (info->timestamp)
>>> +			ravb_get_tx_tstamp(ndev);
>>
>>    Shouldn't we just disable TIS.TFUF permanently instead for the non-gPTP
>> case?
> 
> Good catch. As ravb_dmac_init_rgeth(will be renamed to "ravb_dmac_init_gbeth") is not enabling this interrupt as it is not documented in RZ/G2L hardware manual.
> So this function never gets called for non-gPTP case.
> 
> I will remove this check.

   TIA!

> Regards,
> Biju

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 12/18] ravb: Add timestamp to struct ravb_hw_info
  2021-09-26 20:45       ` Sergey Shtylyov
@ 2021-09-26 20:48         ` Sergei Shtylyov
  2021-09-27  6:10           ` Biju Das
  2021-09-27  6:04         ` Biju Das
  1 sibling, 1 reply; 79+ messages in thread
From: Sergei Shtylyov @ 2021-09-26 20:48 UTC (permalink / raw)
  To: Sergey Shtylyov, Biju Das, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

On 9/26/21 11:45 PM, Sergey Shtylyov wrote:

>>> -----Original Message-----
>>> Subject: Re: [RFC/PATCH 12/18] ravb: Add timestamp to struct ravb_hw_info
>>>
>>> On 9/23/21 5:08 PM, Biju Das wrote:
>>>
>>>> R-Car AVB-DMAC supports timestamp feature.
>>>> Add a timestamp hw feature bit to struct ravb_hw_info to add this
>>>> feature only for R-Car.
>>>>
>>>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
>>>> ---
>>>>  drivers/net/ethernet/renesas/ravb.h      |  2 +
>>>>  drivers/net/ethernet/renesas/ravb_main.c | 68
>>>> +++++++++++++++---------
>>>>  2 files changed, 45 insertions(+), 25 deletions(-)
>>>>
>>>> diff --git a/drivers/net/ethernet/renesas/ravb.h
>>>> b/drivers/net/ethernet/renesas/ravb.h
>>>> index ab4909244276..2505de5d4a28 100644
>>>> --- a/drivers/net/ethernet/renesas/ravb.h
>>>> +++ b/drivers/net/ethernet/renesas/ravb.h
>>>> @@ -1034,6 +1034,7 @@ struct ravb_hw_info {
>>>>  	unsigned mii_rgmii_selection:1;	/* E-MAC supports mii/rgmii
>>> selection */
>>>>  	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
>>>>  	unsigned rx_2k_buffers:1;	/* AVB-DMAC has Max 2K buf size on RX
>>> */
>>>> +	unsigned timestamp:1;		/* AVB-DMAC has timestamp */
>>>
>>>    Isn't this a matter of the gPTP support as well, i.e. no separate flag
>>> needed?
>>
>> Agreed. Previously it is suggested to use timestamp. I will change it to as part of gPTP support cases.
> 
>    TIA. :-)
> 
>>>
>>> [...]
>>>> @@ -1089,6 +1090,7 @@ struct ravb_private {
>>>>  	unsigned int num_tx_desc;	/* TX descriptors per packet */
>>>>
>>>>  	int duplex;
>>>> +	struct ravb_rx_desc *rgeth_rx_ring[NUM_RX_QUEUE];
>>>
>>>    Strange place to declare this...
>>
>> Agreed. This has to be on later patch. Will move it.
> 
>    I only meant that these fields should go together with rx_ring[]. Apparently

   Sorry, this field.

> we have a case of wrong patch ordering here (as this patch needs this field declared)...
[...]

>> Regards,
>> Biju

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 12/18] ravb: Add timestamp to struct ravb_hw_info
  2021-09-26 20:45       ` Sergey Shtylyov
  2021-09-26 20:48         ` Sergei Shtylyov
@ 2021-09-27  6:04         ` Biju Das
  1 sibling, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-27  6:04 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

> Subject: Re: [RFC/PATCH 12/18] ravb: Add timestamp to struct ravb_hw_info
> 
> On 9/26/21 9:34 AM, Biju Das wrote:
> 
> >> -----Original Message-----
> >> Subject: Re: [RFC/PATCH 12/18] ravb: Add timestamp to struct
> >> ravb_hw_info
> >>
> >> On 9/23/21 5:08 PM, Biju Das wrote:
> >>
> >>> R-Car AVB-DMAC supports timestamp feature.
> >>> Add a timestamp hw feature bit to struct ravb_hw_info to add this
> >>> feature only for R-Car.
> >>>
> >>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> >>> ---
> >>>  drivers/net/ethernet/renesas/ravb.h      |  2 +
> >>>  drivers/net/ethernet/renesas/ravb_main.c | 68
> >>> +++++++++++++++---------
> >>>  2 files changed, 45 insertions(+), 25 deletions(-)
> >>>
> >>> diff --git a/drivers/net/ethernet/renesas/ravb.h
> >>> b/drivers/net/ethernet/renesas/ravb.h
> >>> index ab4909244276..2505de5d4a28 100644
> >>> --- a/drivers/net/ethernet/renesas/ravb.h
> >>> +++ b/drivers/net/ethernet/renesas/ravb.h
> >>> @@ -1034,6 +1034,7 @@ struct ravb_hw_info {
> >>>  	unsigned mii_rgmii_selection:1;	/* E-MAC supports mii/rgmii
> >> selection */
> >>>  	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
> >>>  	unsigned rx_2k_buffers:1;	/* AVB-DMAC has Max 2K buf size on RX
> >> */
> >>> +	unsigned timestamp:1;		/* AVB-DMAC has timestamp */
> >>
> >>    Isn't this a matter of the gPTP support as well, i.e. no separate
> >> flag needed?
> >
> > Agreed. Previously it is suggested to use timestamp. I will change it to
> as part of gPTP support cases.
> 
>    TIA. :-)
> 
> >>
> >> [...]
> >>> @@ -1089,6 +1090,7 @@ struct ravb_private {
> >>>  	unsigned int num_tx_desc;	/* TX descriptors per packet */
> >>>
> >>>  	int duplex;
> >>> +	struct ravb_rx_desc *rgeth_rx_ring[NUM_RX_QUEUE];
> >>
> >>    Strange place to declare this...
> >
> > Agreed. This has to be on later patch. Will move it.
> 
>    I only meant that these fields should go together with rx_ring[].
> Apparently we have a case of wrong patch ordering here (as this patch
> needs this field declared)...

Exactly that is the case, it is moved to later patch (https://patchwork.kernel.org/project/linux-renesas-soc/patch/20210923140813.13541-14-biju.das.jz@bp.renesas.com/) which is the first user of
This variable.

Regards,
Biju
> 
> >>>  	const struct ravb_hw_info *info;
> >>>  	struct reset_control *rstc;
> >>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> >>> b/drivers/net/ethernet/renesas/ravb_main.c
> >>> index 9c0d35f4b221..2c375002ebcb 100644
> >>> --- a/drivers/net/ethernet/renesas/ravb_main.c
> >>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> >>> @@ -949,11 +949,14 @@ static bool ravb_queue_interrupt(struct
> >>> net_device *ndev, int q)
> >>>
> >>>  static bool ravb_timestamp_interrupt(struct net_device *ndev)  {
> >>> +	struct ravb_private *priv = netdev_priv(ndev);
> >>> +	const struct ravb_hw_info *info = priv->info;
> >>>  	u32 tis = ravb_read(ndev, TIS);
> >>>
> >>>  	if (tis & TIS_TFUF) {
> >>>  		ravb_write(ndev, ~(TIS_TFUF | TIS_RESERVED), TIS);
> >>> -		ravb_get_tx_tstamp(ndev);
> >>> +		if (info->timestamp)
> >>> +			ravb_get_tx_tstamp(ndev);
> >>
> >>    Shouldn't we just disable TIS.TFUF permanently instead for the
> >> non-gPTP case?
> >
> > Good catch. As ravb_dmac_init_rgeth(will be renamed to
> "ravb_dmac_init_gbeth") is not enabling this interrupt as it is not
> documented in RZ/G2L hardware manual.
> > So this function never gets called for non-gPTP case.
> >
> > I will remove this check.
> 
>    TIA!
> 
> > Regards,
> > Biju
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 12/18] ravb: Add timestamp to struct ravb_hw_info
  2021-09-26 20:48         ` Sergei Shtylyov
@ 2021-09-27  6:10           ` Biju Das
  0 siblings, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-27  6:10 UTC (permalink / raw)
  To: Sergei Shtylyov, Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

Hi Sergei,

> Subject: Re: [RFC/PATCH 12/18] ravb: Add timestamp to struct ravb_hw_info
> 
> On 9/26/21 11:45 PM, Sergey Shtylyov wrote:
> 
> >>> -----Original Message-----
> >>> Subject: Re: [RFC/PATCH 12/18] ravb: Add timestamp to struct
> >>> ravb_hw_info
> >>>
> >>> On 9/23/21 5:08 PM, Biju Das wrote:
> >>>
> >>>> R-Car AVB-DMAC supports timestamp feature.
> >>>> Add a timestamp hw feature bit to struct ravb_hw_info to add this
> >>>> feature only for R-Car.
> >>>>
> >>>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> >>>> ---
> >>>>  drivers/net/ethernet/renesas/ravb.h      |  2 +
> >>>>  drivers/net/ethernet/renesas/ravb_main.c | 68
> >>>> +++++++++++++++---------
> >>>>  2 files changed, 45 insertions(+), 25 deletions(-)
> >>>>
> >>>> diff --git a/drivers/net/ethernet/renesas/ravb.h
> >>>> b/drivers/net/ethernet/renesas/ravb.h
> >>>> index ab4909244276..2505de5d4a28 100644
> >>>> --- a/drivers/net/ethernet/renesas/ravb.h
> >>>> +++ b/drivers/net/ethernet/renesas/ravb.h
> >>>> @@ -1034,6 +1034,7 @@ struct ravb_hw_info {
> >>>>  	unsigned mii_rgmii_selection:1;	/* E-MAC supports
> mii/rgmii
> >>> selection */
> >>>>  	unsigned half_duplex:1;		/* E-MAC supports half duplex
> mode */
> >>>>  	unsigned rx_2k_buffers:1;	/* AVB-DMAC has Max 2K buf size
> on RX
> >>> */
> >>>> +	unsigned timestamp:1;		/* AVB-DMAC has timestamp */
> >>>
> >>>    Isn't this a matter of the gPTP support as well, i.e. no separate
> >>> flag needed?
> >>
> >> Agreed. Previously it is suggested to use timestamp. I will change it
> to as part of gPTP support cases.
> >
> >    TIA. :-)
> >
> >>>
> >>> [...]
> >>>> @@ -1089,6 +1090,7 @@ struct ravb_private {
> >>>>  	unsigned int num_tx_desc;	/* TX descriptors per packet */
> >>>>
> >>>>  	int duplex;
> >>>> +	struct ravb_rx_desc *rgeth_rx_ring[NUM_RX_QUEUE];
> >>>
> >>>    Strange place to declare this...
> >>
> >> Agreed. This has to be on later patch. Will move it.
> >
> >    I only meant that these fields should go together with rx_ring[].
> > Apparently
> 
>    Sorry, this field.

It is a mistake from my side which ended up this variable in this patch.

Function pointers are introduced to avoid more checks and only rx functions pf RZ/G2L are using
this variable. 

It will be clear you to once you finish reviewing the remaining patches(patch 13 - patch 18).

Regards,
Biju

Regards,
Biju

> 
> > we have a case of wrong patch ordering here (as this patch needs this
> field declared)...
> [...]
> 
> >> Regards,
> >> Biju
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 13/18] ravb: Add rx_ring_free function support for GbEthernet
  2021-09-23 14:08 ` [RFC/PATCH 13/18] ravb: Add rx_ring_free function support for GbEthernet Biju Das
@ 2021-09-27 19:28   ` Sergey Shtylyov
  2021-09-28  9:24     ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-27 19:28 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

On 9/23/21 5:08 PM, Biju Das wrote:

> This patch adds rx_ring_free function support for GbEthernet
> found on RZ/G2L SoC.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/net/ethernet/renesas/ravb_main.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 2c375002ebcb..038af36141bb 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -236,7 +236,27 @@ static int ravb_tx_free(struct net_device *ndev, int q, bool free_txed_only)
>  
>  static void ravb_rx_ring_free_rgeth(struct net_device *ndev, int q)
>  {
> -	/* Place holder */
> +	struct ravb_private *priv = netdev_priv(ndev);
> +	unsigned int ring_size;
> +	unsigned int i;
> +
> +	if (!priv->rgeth_rx_ring[q])

   Is the network control queue present on your hardware at all? Perhaps we can ignore q for now?

> +		return;
> +
> +	for (i = 0; i < priv->num_rx_ring[q]; i++) {
> +		struct ravb_rx_desc *desc = &priv->rgeth_rx_ring[q][i];

   Looks like patch #12 should come after this one, not before...

> +
> +		if (!dma_mapping_error(ndev->dev.parent,
> +				       le32_to_cpu(desc->dptr)))
> +			dma_unmap_single(ndev->dev.parent,
> +					 le32_to_cpu(desc->dptr),
> +					 RGETH_RX_BUFF_MAX,
> +					 DMA_FROM_DEVICE);
> +	}
> +	ring_size = sizeof(struct ravb_rx_desc) * (priv->num_rx_ring[q] + 1);
> +	dma_free_coherent(ndev->dev.parent, ring_size, priv->rgeth_rx_ring[q],
> +			  priv->rx_desc_dma[q]);
> +	priv->rgeth_rx_ring[q] = NULL;
>  }
>  
>  static void ravb_rx_ring_free(struct net_device *ndev, int q)

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 01/18] ravb: Rename "ravb_set_features_rx_csum" function to "ravb_set_features_rcar"
  2021-09-23 14:07 ` [RFC/PATCH 01/18] ravb: Rename "ravb_set_features_rx_csum" function to "ravb_set_features_rcar" Biju Das
@ 2021-09-27 19:54   ` Sergey Shtylyov
  0 siblings, 0 replies; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-27 19:54 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Sergei Shtylyov, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

On 9/23/21 5:07 PM, Biju Das wrote:

> Rename "ravb_set_features_rx_csum" function to "ravb_set_features_rcar" and
> replace the function pointer "set_rx_csum_feature" with "set_feature".
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> Suggested-by: Sergey Shtylyov <s.shtylyov@omp.ru>

Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 14/18] ravb: Add rx_ring_format function for GbEthernet
  2021-09-23 14:08 ` [RFC/PATCH 14/18] ravb: Add rx_ring_format function " Biju Das
@ 2021-09-27 20:32   ` Sergey Shtylyov
  2021-09-29  7:49     ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-27 20:32 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Geert Uytterhoeven, Adam Ford,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das

On 9/23/21 5:08 PM, Biju Das wrote:

> This patch adds rx_ring_format function for GbEthernet found on
> RZ/G2L SoC.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/net/ethernet/renesas/ravb.h      |  1 +
>  drivers/net/ethernet/renesas/ravb_main.c | 27 +++++++++++++++++++++++-
>  2 files changed, 27 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
> index 2505de5d4a28..b0e067a6a8ee 100644
> --- a/drivers/net/ethernet/renesas/ravb.h
> +++ b/drivers/net/ethernet/renesas/ravb.h
> @@ -982,6 +982,7 @@ enum CSR0_BIT {
>  #define RX_BUF_SZ	(2048 - ETH_FCS_LEN + sizeof(__sum16))
>  
>  #define RGETH_RX_BUFF_MAX 8192
> +#define RGETH_RX_DESC_DATA_SIZE 4080
>  
>  struct ravb_tstamp_skb {
>  	struct list_head list;
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 038af36141bb..ee1066fedc4a 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -327,7 +327,32 @@ static void ravb_ring_free(struct net_device *ndev, int q)
>  
>  static void ravb_rx_ring_format_rgeth(struct net_device *ndev, int q)
>  {
> -	/* Place holder */
> +	struct ravb_private *priv = netdev_priv(ndev);
> +	struct ravb_rx_desc *rx_desc;
> +	unsigned int rx_ring_size = sizeof(*rx_desc) * priv->num_rx_ring[q];
> +	dma_addr_t dma_addr;
> +	unsigned int i;
> +
> +	memset(priv->rgeth_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->rgeth_rx_ring[q][i];

   Looks like this patch shold come bafore the patch #12 as well...

> +		rx_desc->ds_cc = cpu_to_le16(RGETH_RX_DESC_DATA_SIZE);
> +		dma_addr = dma_map_single(ndev->dev.parent, priv->rx_skb[q][i]->data,
> +					  RGETH_RX_BUFF_MAX,

    Allocation buffer size more then the real data size? Does that make sense?

> +					  DMA_FROM_DEVICE);
> +		/* We just set the data size to 0 for a failed mapping which
> +		 * should prevent DMA from happening...
> +		 */
> +		if (dma_mapping_error(ndev->dev.parent, dma_addr))
> +			rx_desc->ds_cc = cpu_to_le16(0);
> +		rx_desc->dptr = cpu_to_le32(dma_addr);
> +		rx_desc->die_dt = DT_FEMPTY;
> +	}
> +	rx_desc = &priv->rgeth_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_rx_ring_format(struct net_device *ndev, int q)

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 13/18] ravb: Add rx_ring_free function support for GbEthernet
  2021-09-27 19:28   ` Sergey Shtylyov
@ 2021-09-28  9:24     ` Biju Das
  0 siblings, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-28  9:24 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

Hi Sergei,

Thanks for the feedback.

> Subject: Re: [RFC/PATCH 13/18] ravb: Add rx_ring_free function support for
> GbEthernet
> 
> On 9/23/21 5:08 PM, Biju Das wrote:
> 
> > This patch adds rx_ring_free function support for GbEthernet found on
> > RZ/G2L SoC.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  drivers/net/ethernet/renesas/ravb_main.c | 22 +++++++++++++++++++++-
> >  1 file changed, 21 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index 2c375002ebcb..038af36141bb 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > @@ -236,7 +236,27 @@ static int ravb_tx_free(struct net_device *ndev,
> > int q, bool free_txed_only)
> >
> >  static void ravb_rx_ring_free_rgeth(struct net_device *ndev, int q)
> > {
> > -	/* Place holder */
> > +	struct ravb_private *priv = netdev_priv(ndev);
> > +	unsigned int ring_size;
> > +	unsigned int i;
> > +
> > +	if (!priv->rgeth_rx_ring[q])
> 
>    Is the network control queue present on your hardware at all? Perhaps
> we can ignore q for now?

NC queue is not present on RZ/G2L. Will add a feature flag and function pointer related changes to
minimize the check for NC and avoid using NC queue for RZ/G2L platform.

Please let me know, if you think otherwise.

> 
> > +		return;
> > +
> > +	for (i = 0; i < priv->num_rx_ring[q]; i++) {
> > +		struct ravb_rx_desc *desc = &priv->rgeth_rx_ring[q][i];
> 
>    Looks like patch #12 should come after this one, not before...

Patch#12 is timestamp related and we agreed to merge with gPTP support case.

Regards,
Biju

> 
> > +
> > +		if (!dma_mapping_error(ndev->dev.parent,
> > +				       le32_to_cpu(desc->dptr)))
> > +			dma_unmap_single(ndev->dev.parent,
> > +					 le32_to_cpu(desc->dptr),
> > +					 RGETH_RX_BUFF_MAX,
> > +					 DMA_FROM_DEVICE);
> > +	}
> > +	ring_size = sizeof(struct ravb_rx_desc) * (priv->num_rx_ring[q] +
> 1);
> > +	dma_free_coherent(ndev->dev.parent, ring_size, priv-
> >rgeth_rx_ring[q],
> > +			  priv->rx_desc_dma[q]);
> > +	priv->rgeth_rx_ring[q] = NULL;
> >  }
> >
> >  static void ravb_rx_ring_free(struct net_device *ndev, int q)
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 17/18] ravb: Add carrier_counters to struct ravb_hw_info
  2021-09-23 14:08 ` [RFC/PATCH 17/18] ravb: Add carrier_counters to struct ravb_hw_info Biju Das
@ 2021-09-28 20:50   ` Sergey Shtylyov
  0 siblings, 0 replies; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-28 20:50 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Sergei Shtylyov, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

On 9/23/21 5:08 PM, Biju Das wrote:

> RZ/G2L E-MAC supports carrier counters.
> Add a carrier_counter hw feature bit to struct ravb_hw_info
> to add this feature only for RZ/G2L.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>

  I have to trust you on this one:

Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>


[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 14/18] ravb: Add rx_ring_format function for GbEthernet
  2021-09-27 20:32   ` Sergey Shtylyov
@ 2021-09-29  7:49     ` Biju Das
  0 siblings, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-09-29  7:49 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

Hi Sergei,

> Subject: Re: [RFC/PATCH 14/18] ravb: Add rx_ring_format function for
> GbEthernet
> 
> On 9/23/21 5:08 PM, Biju Das wrote:
> 
> > This patch adds rx_ring_format function for GbEthernet found on RZ/G2L
> > SoC.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  drivers/net/ethernet/renesas/ravb.h      |  1 +
> >  drivers/net/ethernet/renesas/ravb_main.c | 27
> > +++++++++++++++++++++++-
> >  2 files changed, 27 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > b/drivers/net/ethernet/renesas/ravb.h
> > index 2505de5d4a28..b0e067a6a8ee 100644
> > --- a/drivers/net/ethernet/renesas/ravb.h
> > +++ b/drivers/net/ethernet/renesas/ravb.h
> > @@ -982,6 +982,7 @@ enum CSR0_BIT {
> >  #define RX_BUF_SZ	(2048 - ETH_FCS_LEN + sizeof(__sum16))
> >
> >  #define RGETH_RX_BUFF_MAX 8192
> > +#define RGETH_RX_DESC_DATA_SIZE 4080
> >
> >  struct ravb_tstamp_skb {
> >  	struct list_head list;
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index 038af36141bb..ee1066fedc4a 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > @@ -327,7 +327,32 @@ static void ravb_ring_free(struct net_device
> > *ndev, int q)
> >
> >  static void ravb_rx_ring_format_rgeth(struct net_device *ndev, int q)
> > {
> > -	/* Place holder */
> > +	struct ravb_private *priv = netdev_priv(ndev);
> > +	struct ravb_rx_desc *rx_desc;
> > +	unsigned int rx_ring_size = sizeof(*rx_desc) * priv->num_rx_ring[q];
> > +	dma_addr_t dma_addr;
> > +	unsigned int i;
> > +
> > +	memset(priv->rgeth_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->rgeth_rx_ring[q][i];
> 
>    Looks like this patch shold come bafore the patch #12 as well...

Patch#12 is timestamp related and we agreed to merge timestamp related code to gPTP support.

> 
> > +		rx_desc->ds_cc = cpu_to_le16(RGETH_RX_DESC_DATA_SIZE);
> > +		dma_addr = dma_map_single(ndev->dev.parent, priv-
> >rx_skb[q][i]->data,
> > +					  RGETH_RX_BUFF_MAX,
> 
>     Allocation buffer size more then the real data size? Does that make
> sense?

Allocated buffer is 8K and mapping buffer size is 8K. So there won't be any issues
for dma/cpu operations.

You can refer to cip kernel[1] for details
[1] https://github.com/renesas-rz/rz_linux-cip/blob/rzg2l-cip41/drivers/net/ethernet/renesas/ravb_main.c#L326

> 
> > +					  DMA_FROM_DEVICE);
> > +		/* We just set the data size to 0 for a failed mapping which
> > +		 * should prevent DMA from happening...
> > +		 */
> > +		if (dma_mapping_error(ndev->dev.parent, dma_addr))
> > +			rx_desc->ds_cc = cpu_to_le16(0);
> > +		rx_desc->dptr = cpu_to_le32(dma_addr);
> > +		rx_desc->die_dt = DT_FEMPTY;
> > +	}
> > +	rx_desc = &priv->rgeth_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_rx_ring_format(struct net_device *ndev, int q)
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 18/18] ravb: Add set_feature support for RZ/G2L
  2021-09-23 14:08 ` [RFC/PATCH 18/18] ravb: Add set_feature support for RZ/G2L Biju Das
@ 2021-09-30 20:39   ` Sergey Shtylyov
  2021-10-01  6:53     ` Biju Das
  2021-10-01  8:22     ` Biju Das
  0 siblings, 2 replies; 79+ messages in thread
From: Sergey Shtylyov @ 2021-09-30 20:39 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Sergei Shtylyov, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

On 9/23/21 5:08 PM, Biju Das wrote:

> This patch adds set_feature support for RZ/G2L.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/net/ethernet/renesas/ravb.h      | 32 ++++++++++++++
>  drivers/net/ethernet/renesas/ravb_main.c | 56 +++++++++++++++++++++++-
>  2 files changed, 87 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
> index d42e8ea981df..2275f27c0672 100644
> --- a/drivers/net/ethernet/renesas/ravb.h
> +++ b/drivers/net/ethernet/renesas/ravb.h
> @@ -209,6 +209,8 @@ enum ravb_reg {
>  	CXR56	= 0x0770,	/* Documented for RZ/G2L only */
>  	MAFCR	= 0x0778,
>  	CSR0     = 0x0800,	/* Documented for RZ/G2L only */
> +	CSR1     = 0x0804,	/* Documented for RZ/G2L only */
> +	CSR2     = 0x0808,	/* Documented for RZ/G2L only */

   These are the TOE regs (CSR0 included), they only exist on RZ/G2L, no?

[...]
> @@ -978,6 +980,36 @@ enum CSR0_BIT {
>  	CSR0_RPE	= 0x00000020,
>  };
>  

   *enum* CSR0_BIT should be here (as we concluded).

> +enum CSR1_BIT {
[...]
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 72aea5875bc5..641ae5553b64 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
[...]
> @@ -2290,7 +2308,38 @@ static void ravb_set_rx_csum(struct net_device *ndev, bool enable)
>  static int ravb_set_features_rgeth(struct net_device *ndev,
>  				   netdev_features_t features)
>  {
> -	/* Place holder */
> +	netdev_features_t changed = features ^ ndev->features;
> +	unsigned int reg;

   u32 reg;

> +	int error;
> +
> +	reg = ravb_read(ndev, CSR0);

   ... as this function returns u32.

> +
> +	ravb_write(ndev, reg & ~(CSR0_RPE | CSR0_TPE), CSR0);
> +	error = ravb_wait(ndev, CSR0, CSR0_RPE | CSR0_TPE, 0);
> +	if (error) {
> +		ravb_write(ndev, reg, CSR0);
> +		return error;
> +	}
> +
> +	if (changed & NETIF_F_RXCSUM) {
> +		if (features & NETIF_F_RXCSUM)
> +			ravb_write(ndev, CSR2_ALL, CSR2);
> +		else
> +			ravb_write(ndev, 0, CSR2);
> +	}
> +
> +	if (changed & NETIF_F_HW_CSUM) {
> +		if (features & NETIF_F_HW_CSUM) {
> +			ravb_write(ndev, CSR1_ALL, CSR1);
> +			ndev->features |= NETIF_F_CSUM_MASK;

   Hm, I don't understand this... it would be nice if someone knowledgeable about the offloads
would look at this... Although, without the register documentation it's possibly vain...

> +		} else {
> +			ravb_write(ndev, 0, CSR1);
> +		}
> +	}
> +	ravb_write(ndev, reg, CSR0);
> +
> +	ndev->features = features;
> +
>  	return 0;
>  }
>  
> @@ -2432,6 +2481,11 @@ static const struct ravb_hw_info rgeth_hw_info = {
>  	.set_feature = ravb_set_features_rgeth,
>  	.dmac_init = ravb_dmac_init_rgeth,
>  	.emac_init = ravb_emac_init_rgeth,
> +	.net_hw_features = (NETIF_F_HW_CSUM | NETIF_F_RXCSUM),
> +	.gstrings_stats = ravb_gstrings_stats_rgeth,
> +	.gstrings_size = sizeof(ravb_gstrings_stats_rgeth),
> +	.stats_len = ARRAY_SIZE(ravb_gstrings_stats_rgeth),

    These seem unrelated, couldn't it be moved to a spearate patch?

> +	.max_rx_len = RGETH_RX_BUFF_MAX + RAVB_ALIGN - 1,

   This seems unrelsated and misplaced too.

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 18/18] ravb: Add set_feature support for RZ/G2L
  2021-09-30 20:39   ` Sergey Shtylyov
@ 2021-10-01  6:53     ` Biju Das
  2021-10-01  9:13       ` Sergey Shtylyov
  2021-10-01  8:22     ` Biju Das
  1 sibling, 1 reply; 79+ messages in thread
From: Biju Das @ 2021-10-01  6:53 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergei,

Thanks for the feedback.

> Subject: Re: [RFC/PATCH 18/18] ravb: Add set_feature support for RZ/G2L
> 
> On 9/23/21 5:08 PM, Biju Das wrote:
> 
> > This patch adds set_feature support for RZ/G2L.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  drivers/net/ethernet/renesas/ravb.h      | 32 ++++++++++++++
> >  drivers/net/ethernet/renesas/ravb_main.c | 56
> > +++++++++++++++++++++++-
> >  2 files changed, 87 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > b/drivers/net/ethernet/renesas/ravb.h
> > index d42e8ea981df..2275f27c0672 100644
> > --- a/drivers/net/ethernet/renesas/ravb.h
> > +++ b/drivers/net/ethernet/renesas/ravb.h
> > @@ -209,6 +209,8 @@ enum ravb_reg {
> >  	CXR56	= 0x0770,	/* Documented for RZ/G2L only */
> >  	MAFCR	= 0x0778,
> >  	CSR0     = 0x0800,	/* Documented for RZ/G2L only */
> > +	CSR1     = 0x0804,	/* Documented for RZ/G2L only */
> > +	CSR2     = 0x0808,	/* Documented for RZ/G2L only */
> 
>    These are the TOE regs (CSR0 included), they only exist on RZ/G2L, no?

See just one line above you can see CSR0 registers and comments on the right clearly
mentions "/* Documented for RZ/G2L only */

OK will do CSR0 initialisation as part of this patch instead of patch #10.


> [...]
> > @@ -978,6 +980,36 @@ enum CSR0_BIT {
> >  	CSR0_RPE	= 0x00000020,
> >  };
> >
> 
>    *enum* CSR0_BIT should be here (as we concluded).

It is already there. See above.
As discussed above it will be moved from patch #10 to here.

> 
> > +enum CSR1_BIT {
> [...]
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index 72aea5875bc5..641ae5553b64 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> [...]
> > @@ -2290,7 +2308,38 @@ static void ravb_set_rx_csum(struct net_device
> > *ndev, bool enable)  static int ravb_set_features_rgeth(struct
> net_device *ndev,
> >  				   netdev_features_t features)
> >  {
> > -	/* Place holder */
> > +	netdev_features_t changed = features ^ ndev->features;
> > +	unsigned int reg;
> 
>    u32 reg;
> 
> > +	int error;
> > +
> > +	reg = ravb_read(ndev, CSR0);
> 
>    ... as this function returns u32.
> 
> > +
> > +	ravb_write(ndev, reg & ~(CSR0_RPE | CSR0_TPE), CSR0);
> > +	error = ravb_wait(ndev, CSR0, CSR0_RPE | CSR0_TPE, 0);
> > +	if (error) {
> > +		ravb_write(ndev, reg, CSR0);
> > +		return error;
> > +	}
> > +
> > +	if (changed & NETIF_F_RXCSUM) {
> > +		if (features & NETIF_F_RXCSUM)
> > +			ravb_write(ndev, CSR2_ALL, CSR2);
> > +		else
> > +			ravb_write(ndev, 0, CSR2);
> > +	}
> > +
> > +	if (changed & NETIF_F_HW_CSUM) {
> > +		if (features & NETIF_F_HW_CSUM) {
> > +			ravb_write(ndev, CSR1_ALL, CSR1);
> > +			ndev->features |= NETIF_F_CSUM_MASK;
> 
>    Hm, I don't understand this... it would be nice if someone
> knowledgeable about the offloads would look at this... Although, without
> the register documentation it's possibly vain...
> 
> > +		} else {
> > +			ravb_write(ndev, 0, CSR1);
> > +		}
> > +	}
> > +	ravb_write(ndev, reg, CSR0);
> > +
> > +	ndev->features = features;
> > +
> >  	return 0;
> >  }
> >
> > @@ -2432,6 +2481,11 @@ static const struct ravb_hw_info rgeth_hw_info =
> {
> >  	.set_feature = ravb_set_features_rgeth,
> >  	.dmac_init = ravb_dmac_init_rgeth,
> >  	.emac_init = ravb_emac_init_rgeth,
> > +	.net_hw_features = (NETIF_F_HW_CSUM | NETIF_F_RXCSUM),
> > +	.gstrings_stats = ravb_gstrings_stats_rgeth,
> > +	.gstrings_size = sizeof(ravb_gstrings_stats_rgeth),
> > +	.stats_len = ARRAY_SIZE(ravb_gstrings_stats_rgeth),
> 
>     These seem unrelated, couldn't it be moved to a spearate patch?

Ok will split into 2. Adding  set_feature support in first patch
and stats in second patch.

> 
> > +	.max_rx_len = RGETH_RX_BUFF_MAX + RAVB_ALIGN - 1,
> 
>    This seems unrelsated and misplaced too.

Agreed. It is a mistake. Will be taken care in next version.

Regards,
Biju

> 
> [...]
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 18/18] ravb: Add set_feature support for RZ/G2L
  2021-09-30 20:39   ` Sergey Shtylyov
  2021-10-01  6:53     ` Biju Das
@ 2021-10-01  8:22     ` Biju Das
  1 sibling, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-10-01  8:22 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das



> -----Original Message-----
> From: Sergey Shtylyov <s.shtylyov@omp.ru>
> Sent: 30 September 2021 21:39
> To: Biju Das <biju.das.jz@bp.renesas.com>; David S. Miller
> <davem@davemloft.net>; Jakub Kicinski <kuba@kernel.org>
> Cc: Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>;
> Andrew Lunn <andrew@lunn.ch>; Sergei Shtylyov <sergei.shtylyov@gmail.com>;
> Geert Uytterhoeven <geert+renesas@glider.be>; Adam Ford
> <aford173@gmail.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>
> Subject: Re: [RFC/PATCH 18/18] ravb: Add set_feature support for RZ/G2L
> 
> On 9/23/21 5:08 PM, Biju Das wrote:
> 
> > This patch adds set_feature support for RZ/G2L.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  drivers/net/ethernet/renesas/ravb.h      | 32 ++++++++++++++
> >  drivers/net/ethernet/renesas/ravb_main.c | 56
> > +++++++++++++++++++++++-
> >  2 files changed, 87 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > b/drivers/net/ethernet/renesas/ravb.h
> > index d42e8ea981df..2275f27c0672 100644
> > --- a/drivers/net/ethernet/renesas/ravb.h
> > +++ b/drivers/net/ethernet/renesas/ravb.h
> > @@ -209,6 +209,8 @@ enum ravb_reg {
> >  	CXR56	= 0x0770,	/* Documented for RZ/G2L only */
> >  	MAFCR	= 0x0778,
> >  	CSR0     = 0x0800,	/* Documented for RZ/G2L only */
> > +	CSR1     = 0x0804,	/* Documented for RZ/G2L only */
> > +	CSR2     = 0x0808,	/* Documented for RZ/G2L only */
> 
>    These are the TOE regs (CSR0 included), they only exist on RZ/G2L, no?
> 
> [...]
> > @@ -978,6 +980,36 @@ enum CSR0_BIT {
> >  	CSR0_RPE	= 0x00000020,
> >  };
> >
> 
>    *enum* CSR0_BIT should be here (as we concluded).
> 
> > +enum CSR1_BIT {
> [...]
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index 72aea5875bc5..641ae5553b64 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> [...]
> > @@ -2290,7 +2308,38 @@ static void ravb_set_rx_csum(struct net_device
> > *ndev, bool enable)  static int ravb_set_features_rgeth(struct
> net_device *ndev,
> >  				   netdev_features_t features)
> >  {
> > -	/* Place holder */
> > +	netdev_features_t changed = features ^ ndev->features;
> > +	unsigned int reg;
> 
>    u32 reg;
> 
> > +	int error;
> > +
> > +	reg = ravb_read(ndev, CSR0);
> 
>    ... as this function returns u32.
> 
> > +
> > +	ravb_write(ndev, reg & ~(CSR0_RPE | CSR0_TPE), CSR0);
> > +	error = ravb_wait(ndev, CSR0, CSR0_RPE | CSR0_TPE, 0);
> > +	if (error) {
> > +		ravb_write(ndev, reg, CSR0);
> > +		return error;
> > +	}
> > +
> > +	if (changed & NETIF_F_RXCSUM) {
> > +		if (features & NETIF_F_RXCSUM)
> > +			ravb_write(ndev, CSR2_ALL, CSR2);
> > +		else
> > +			ravb_write(ndev, 0, CSR2);
> > +	}
> > +
> > +	if (changed & NETIF_F_HW_CSUM) {
> > +		if (features & NETIF_F_HW_CSUM) {
> > +			ravb_write(ndev, CSR1_ALL, CSR1);
> > +			ndev->features |= NETIF_F_CSUM_MASK;
> 
>    Hm, I don't understand this... it would be nice if someone
> knowledgeable about the offloads would look at this... Although, without
> the register documentation it's possibly vain...

You can download the document from here [1]

[1] https://www.renesas.com/document/mah/rzg2l-group-rzg2lc-group-users-manual-hardware-0?language=en&r=1467981

Regards,
Biju


> 
> > +		} else {
> > +			ravb_write(ndev, 0, CSR1);
> > +		}
> > +	}
> > +	ravb_write(ndev, reg, CSR0);
> > +
> > +	ndev->features = features;
> > +
> >  	return 0;
> >  }
> >
> > @@ -2432,6 +2481,11 @@ static const struct ravb_hw_info rgeth_hw_info =
> {
> >  	.set_feature = ravb_set_features_rgeth,
> >  	.dmac_init = ravb_dmac_init_rgeth,
> >  	.emac_init = ravb_emac_init_rgeth,
> > +	.net_hw_features = (NETIF_F_HW_CSUM | NETIF_F_RXCSUM),
> > +	.gstrings_stats = ravb_gstrings_stats_rgeth,
> > +	.gstrings_size = sizeof(ravb_gstrings_stats_rgeth),
> > +	.stats_len = ARRAY_SIZE(ravb_gstrings_stats_rgeth),
> 
>     These seem unrelated, couldn't it be moved to a spearate patch?
> 
> > +	.max_rx_len = RGETH_RX_BUFF_MAX + RAVB_ALIGN - 1,
> 
>    This seems unrelsated and misplaced too.
> 
> [...]
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 18/18] ravb: Add set_feature support for RZ/G2L
  2021-10-01  6:53     ` Biju Das
@ 2021-10-01  9:13       ` Sergey Shtylyov
  2021-10-01  9:26         ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Sergey Shtylyov @ 2021-10-01  9:13 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

On 01.10.2021 9:53, Biju Das wrote:

[...]
>>> This patch adds set_feature support for RZ/G2L.
>>>
>>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
>>> ---
>>>   drivers/net/ethernet/renesas/ravb.h      | 32 ++++++++++++++
>>>   drivers/net/ethernet/renesas/ravb_main.c | 56
>>> +++++++++++++++++++++++-
>>>   2 files changed, 87 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/net/ethernet/renesas/ravb.h
>>> b/drivers/net/ethernet/renesas/ravb.h
>>> index d42e8ea981df..2275f27c0672 100644
>>> --- a/drivers/net/ethernet/renesas/ravb.h
>>> +++ b/drivers/net/ethernet/renesas/ravb.h
>>> @@ -209,6 +209,8 @@ enum ravb_reg {
>>>   	CXR56	= 0x0770,	/* Documented for RZ/G2L only */
>>>   	MAFCR	= 0x0778,
>>>   	CSR0     = 0x0800,	/* Documented for RZ/G2L only */
>>> +	CSR1     = 0x0804,	/* Documented for RZ/G2L only */
>>> +	CSR2     = 0x0808,	/* Documented for RZ/G2L only */
>>
>>     These are the TOE regs (CSR0 included), they only exist on RZ/G2L, no?
> 
> See just one line above you can see CSR0 registers and comments on the right clearly
> mentions "/* Documented for RZ/G2L only */

    What I meant was commenting on them as /* RZ/GL2 only */ or some such. 
Sorry for not being clear enough.

> OK will do CSR0 initialisation as part of this patch instead of patch #10.

    TIA!

>> [...]
>>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>>> b/drivers/net/ethernet/renesas/ravb_main.c
>>> index 72aea5875bc5..641ae5553b64 100644
>>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>> [...]
>>> @@ -2290,7 +2308,38 @@ static void ravb_set_rx_csum(struct net_device
>>> *ndev, bool enable)  static int ravb_set_features_rgeth(struct
>> net_device *ndev,
>>>   				   netdev_features_t features)
>>>   {
>>> -	/* Place holder */
>>> +	netdev_features_t changed = features ^ ndev->features;
>>> +	unsigned int reg;
>>
>>     u32 reg;
>>
>>> +	int error;
>>> +
>>> +	reg = ravb_read(ndev, CSR0);
>>
>>     ... as this function returns u32.

    I'm even suggesting to call this variable 'csr0'.

[...]

> Regards,
> Biju

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 18/18] ravb: Add set_feature support for RZ/G2L
  2021-10-01  9:13       ` Sergey Shtylyov
@ 2021-10-01  9:26         ` Biju Das
  0 siblings, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-10-01  9:26 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

> Subject: Re: [RFC/PATCH 18/18] ravb: Add set_feature support for RZ/G2L
> 
> On 01.10.2021 9:53, Biju Das wrote:
> 
> [...]
> >>> This patch adds set_feature support for RZ/G2L.
> >>>
> >>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> >>> ---
> >>>   drivers/net/ethernet/renesas/ravb.h      | 32 ++++++++++++++
> >>>   drivers/net/ethernet/renesas/ravb_main.c | 56
> >>> +++++++++++++++++++++++-
> >>>   2 files changed, 87 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/drivers/net/ethernet/renesas/ravb.h
> >>> b/drivers/net/ethernet/renesas/ravb.h
> >>> index d42e8ea981df..2275f27c0672 100644
> >>> --- a/drivers/net/ethernet/renesas/ravb.h
> >>> +++ b/drivers/net/ethernet/renesas/ravb.h
> >>> @@ -209,6 +209,8 @@ enum ravb_reg {
> >>>   	CXR56	= 0x0770,	/* Documented for RZ/G2L only */
> >>>   	MAFCR	= 0x0778,
> >>>   	CSR0     = 0x0800,	/* Documented for RZ/G2L only */
> >>> +	CSR1     = 0x0804,	/* Documented for RZ/G2L only */
> >>> +	CSR2     = 0x0808,	/* Documented for RZ/G2L only */
> >>
> >>     These are the TOE regs (CSR0 included), they only exist on RZ/G2L,
> no?
> >
> > See just one line above you can see CSR0 registers and comments on the
> > right clearly mentions "/* Documented for RZ/G2L only */
> 
>     What I meant was commenting on them as /* RZ/GL2 only */ or some such.
> Sorry for not being clear enough.
> 

OK.

> > OK will do CSR0 initialisation as part of this patch instead of patch
> #10.
> 
>     TIA!
> 
> >> [...]
> >>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> >>> b/drivers/net/ethernet/renesas/ravb_main.c
> >>> index 72aea5875bc5..641ae5553b64 100644
> >>> --- a/drivers/net/ethernet/renesas/ravb_main.c
> >>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> >> [...]
> >>> @@ -2290,7 +2308,38 @@ static void ravb_set_rx_csum(struct
> >>> net_device *ndev, bool enable)  static int
> >>> ravb_set_features_rgeth(struct
> >> net_device *ndev,
> >>>   				   netdev_features_t features)
> >>>   {
> >>> -	/* Place holder */
> >>> +	netdev_features_t changed = features ^ ndev->features;
> >>> +	unsigned int reg;
> >>
> >>     u32 reg;
> >>
> >>> +	int error;
> >>> +
> >>> +	reg = ravb_read(ndev, CSR0);
> >>
> >>     ... as this function returns u32.
> 
>     I'm even suggesting to call this variable 'csr0'.

OK. Will change to u32 csr0.

> 
> [...]
> 
> > Regards,
> > Biju
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [RFC/PATCH 16/18] ravb: Add Packet receive function for Gigabit Ethernet
  2021-09-23 14:08 ` [RFC/PATCH 16/18] ravb: Add Packet receive function for Gigabit Ethernet Biju Das
@ 2021-10-01 17:27   ` Sergey Shtylyov
  2021-10-04 14:56     ` Biju Das
  0 siblings, 1 reply; 79+ messages in thread
From: Sergey Shtylyov @ 2021-10-01 17:27 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Lad Prabhakar, Andrew Lunn, Sergei Shtylyov, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

On 9/23/21 5:08 PM, Biju Das wrote:

> This patch series adds RX(packet receive) function for
> Gigabit Ethernet found on RZ/G2L SoC.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/net/ethernet/renesas/ravb.h      |   1 +
>  drivers/net/ethernet/renesas/ravb_main.c | 157 ++++++++++++++++++++++-
>  2 files changed, 156 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
> index b0e067a6a8ee..85260f89e1cd 100644
> --- a/drivers/net/ethernet/renesas/ravb.h
> +++ b/drivers/net/ethernet/renesas/ravb.h
> @@ -1092,6 +1092,7 @@ struct ravb_private {
>  
>  	int duplex;
>  	struct ravb_rx_desc *rgeth_rx_ring[NUM_RX_QUEUE];
> +	struct sk_buff *rxtop_skb;

   I'd prefer for this one declared earler in the *struct*, as well. And why not e.g 'rx_1st_skb'?

>  
>  	const struct ravb_hw_info *info;
>  	struct reset_control *rstc;
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index a08da7a37b92..867e180e6655 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -705,6 +705,23 @@ static void ravb_get_tx_tstamp(struct net_device *ndev)
>  	}
>  }
>  
> +static void ravb_rx_csum_rgeth(struct sk_buff *skb)
> +{
> +	u8 *hw_csum;
> +
> +	/* The hardware checksum is contained in sizeof(__sum16) (2) bytes
> +	 * appended to packet data
> +	 */
> +	if (unlikely(skb->len < sizeof(__sum16)))
> +		return;
> +	hw_csum = skb_tail_pointer(skb) - sizeof(__sum16);
> +
> +	if (*hw_csum == 0)
> +		skb->ip_summed = CHECKSUM_UNNECESSARY;
> +	else
> +		skb->ip_summed = CHECKSUM_NONE;

   Mhm, what's the point of this whole function then? Why it can't be a copy of the R-Car analog?

[...]
> @@ -720,11 +737,147 @@ static void ravb_rx_csum(struct sk_buff *skb)
[...]
>  /* Packet receive function for Gigabit Ethernet */
>  static bool ravb_rgeth_rx(struct net_device *ndev, int *quota, int q)
>  {
> -	/* Place holder */
> -	return true;
> +	struct ravb_private *priv = netdev_priv(ndev);
> +	int entry = priv->cur_rx[q] % priv->num_rx_ring[q];
> +	int boguscnt = priv->dirty_rx[q] + priv->num_rx_ring[q] - priv->cur_rx[q];
> +	struct net_device_stats *stats = &priv->stats[q];

   [q] should be dropped, as we've agreed...

> +	struct ravb_rx_desc *desc;
> +	struct sk_buff *skb;
> +	dma_addr_t dma_addr;
> +	u8  desc_status;
> +	u8  die_dt;
> +	u16 pkt_len;
> +	int limit;
> +
> +	boguscnt = min(boguscnt, *quota);
> +	limit = boguscnt;
> +	desc = &priv->rgeth_rx_ring[q][entry];
> +	while (desc->die_dt != DT_FEMPTY) {
> +		/* Descriptor type must be checked before all other reads */
> +		dma_rmb();
> +		desc_status = desc->msc;
> +		pkt_len = le16_to_cpu(desc->ds_cc) & RX_DS;
> +
> +		if (--boguscnt < 0)
> +			break;
> +
> +		/* We use 0-byte descriptors to mark the DMA mapping errors */
> +		if (!pkt_len)
> +			continue;
> +
> +		if (desc_status & MSC_MC)
> +			stats->multicast++;
> +
> +		if (desc_status & (MSC_CRC | MSC_RFE | MSC_RTSF | MSC_RTLF | MSC_CEEF)) {
> +			stats->rx_errors++;
> +			if (desc_status & MSC_CRC)
> +				stats->rx_crc_errors++;
> +			if (desc_status & MSC_RFE)
> +				stats->rx_frame_errors++;
> +			if (desc_status & (MSC_RTLF | MSC_RTSF))
> +				stats->rx_length_errors++;
> +			if (desc_status & MSC_CEEF)
> +				stats->rx_missed_errors++;
> +		} else {
> +			die_dt = desc->die_dt & 0xF0;
> +			switch (die_dt) {
> +			case DT_FSINGLE:
> +				skb = ravb_get_skb_rgeth(ndev, q, entry, desc);
> +				skb_put(skb, pkt_len);
> +				skb->protocol = eth_type_trans(skb, ndev);
> +				if (ndev->features & NETIF_F_RXCSUM)
> +					ravb_rx_csum_rgeth(skb);
> +				napi_gro_receive(&priv->napi[q], skb);
> +				stats->rx_packets++;
> +				stats->rx_bytes += pkt_len;
> +				break;
> +			case DT_FSTART:
> +				priv->rxtop_skb = ravb_get_skb_rgeth(ndev, q, entry, desc);

   But don't you need to  copy the data in this case?

> +				skb_put(priv->rxtop_skb, pkt_len);
> +				break;
> +			case DT_FMID:
> +				skb = ravb_get_skb_rgeth(ndev, q, entry, desc);
> +				skb_copy_to_linear_data_offset(priv->rxtop_skb,
> +							       priv->rxtop_skb->len,
> +							       skb->data,
> +							       pkt_len);
> +				skb_put(priv->rxtop_skb, pkt_len);
> +				dev_kfree_skb(skb);
> +				break;
> +			case DT_FEND:
> +				skb = ravb_get_skb_rgeth(ndev, q, entry, desc);
> +				skb_copy_to_linear_data_offset(priv->rxtop_skb,
> +							       priv->rxtop_skb->len,
> +							       skb->data,
> +							       pkt_len);
> +				skb_put(priv->rxtop_skb, pkt_len);
> +				dev_kfree_skb(skb);
> +				priv->rxtop_skb->protocol =
> +					eth_type_trans(priv->rxtop_skb, ndev);
> +				if (ndev->features & NETIF_F_RXCSUM)
> +					ravb_rx_csum_rgeth(skb);
> +				napi_gro_receive(&priv->napi[q],
> +						 priv->rxtop_skb);
> +				stats->rx_packets++;
> +				stats->rx_bytes += priv->rxtop_skb->len;
> +				break;
> +			}
> +		}
> +
> +		entry = (++priv->cur_rx[q]) % priv->num_rx_ring[q];
> +		desc = &priv->rgeth_rx_ring[q][entry];
> +	}
> +
> +	/* Refill the RX ring buffers. */
> +	for (; priv->cur_rx[q] - priv->dirty_rx[q] > 0; priv->dirty_rx[q]++) {
> +		entry = priv->dirty_rx[q] % priv->num_rx_ring[q];
> +		desc = &priv->rgeth_rx_ring[q][entry];
> +		desc->ds_cc = cpu_to_le16(RGETH_RX_DESC_DATA_SIZE);
> +
> +		if (!priv->rx_skb[q][entry]) {
> +			skb = netdev_alloc_skb(ndev,
> +					       RGETH_RX_BUFF_MAX + RAVB_ALIGN - 1);

   ALIGN(RGETH_RX_BUFF_MAX, RAVB_ALIGN)?

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

* RE: [RFC/PATCH 16/18] ravb: Add Packet receive function for Gigabit Ethernet
  2021-10-01 17:27   ` Sergey Shtylyov
@ 2021-10-04 14:56     ` Biju Das
  0 siblings, 0 replies; 79+ messages in thread
From: Biju Das @ 2021-10-04 14:56 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Prabhakar Mahadev Lad, Andrew Lunn, Sergei Shtylyov,
	Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das

Hi Sergey,

Thanks for the feedback.

> Subject: Re: [RFC/PATCH 16/18] ravb: Add Packet receive function for
> Gigabit Ethernet
> 
> On 9/23/21 5:08 PM, Biju Das wrote:
> 
> > This patch series adds RX(packet receive) function for Gigabit
> > Ethernet found on RZ/G2L SoC.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  drivers/net/ethernet/renesas/ravb.h      |   1 +
> >  drivers/net/ethernet/renesas/ravb_main.c | 157
> > ++++++++++++++++++++++-
> >  2 files changed, 156 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > b/drivers/net/ethernet/renesas/ravb.h
> > index b0e067a6a8ee..85260f89e1cd 100644
> > --- a/drivers/net/ethernet/renesas/ravb.h
> > +++ b/drivers/net/ethernet/renesas/ravb.h
> > @@ -1092,6 +1092,7 @@ struct ravb_private {
> >
> >  	int duplex;
> >  	struct ravb_rx_desc *rgeth_rx_ring[NUM_RX_QUEUE];
> > +	struct sk_buff *rxtop_skb;
> 
>    I'd prefer for this one declared earler in the *struct*, as well. And
> why not e.g 'rx_1st_skb'?

OK Will use 'rx_1st_skb' in the next RFC version.

> 
> >
> >  	const struct ravb_hw_info *info;
> >  	struct reset_control *rstc;
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index a08da7a37b92..867e180e6655 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > @@ -705,6 +705,23 @@ static void ravb_get_tx_tstamp(struct net_device
> *ndev)
> >  	}
> >  }
> >
> > +static void ravb_rx_csum_rgeth(struct sk_buff *skb) {
> > +	u8 *hw_csum;
> > +
> > +	/* The hardware checksum is contained in sizeof(__sum16) (2) bytes
> > +	 * appended to packet data
> > +	 */
> > +	if (unlikely(skb->len < sizeof(__sum16)))
> > +		return;
> > +	hw_csum = skb_tail_pointer(skb) - sizeof(__sum16);
> > +
> > +	if (*hw_csum == 0)
> > +		skb->ip_summed = CHECKSUM_UNNECESSARY;
> > +	else
> > +		skb->ip_summed = CHECKSUM_NONE;
> 
>    Mhm, what's the point of this whole function then? Why it can't be a
> copy of the R-Car analog?

This function should come after CSR initialization. Next RFC I will taken care of this.
*hwcsum == 0 means, there is no error in checksum. So it should be OK.

> 
> [...]
> > @@ -720,11 +737,147 @@ static void ravb_rx_csum(struct sk_buff *skb)
> [...]
> >  /* Packet receive function for Gigabit Ethernet */  static bool
> > ravb_rgeth_rx(struct net_device *ndev, int *quota, int q)  {
> > -	/* Place holder */
> > -	return true;
> > +	struct ravb_private *priv = netdev_priv(ndev);
> > +	int entry = priv->cur_rx[q] % priv->num_rx_ring[q];
> > +	int boguscnt = priv->dirty_rx[q] + priv->num_rx_ring[q] - priv-
> >cur_rx[q];
> > +	struct net_device_stats *stats = &priv->stats[q];
> 
>    [q] should be dropped, as we've agreed...

nc_queue feature bit will take care of this. So the q will be always RVAB_BE.

> 
> > +	struct ravb_rx_desc *desc;
> > +	struct sk_buff *skb;
> > +	dma_addr_t dma_addr;
> > +	u8  desc_status;
> > +	u8  die_dt;
> > +	u16 pkt_len;
> > +	int limit;
> > +
> > +	boguscnt = min(boguscnt, *quota);
> > +	limit = boguscnt;
> > +	desc = &priv->rgeth_rx_ring[q][entry];
> > +	while (desc->die_dt != DT_FEMPTY) {
> > +		/* Descriptor type must be checked before all other reads */
> > +		dma_rmb();
> > +		desc_status = desc->msc;
> > +		pkt_len = le16_to_cpu(desc->ds_cc) & RX_DS;
> > +
> > +		if (--boguscnt < 0)
> > +			break;
> > +
> > +		/* We use 0-byte descriptors to mark the DMA mapping errors */
> > +		if (!pkt_len)
> > +			continue;
> > +
> > +		if (desc_status & MSC_MC)
> > +			stats->multicast++;
> > +
> > +		if (desc_status & (MSC_CRC | MSC_RFE | MSC_RTSF | MSC_RTLF |
> MSC_CEEF)) {
> > +			stats->rx_errors++;
> > +			if (desc_status & MSC_CRC)
> > +				stats->rx_crc_errors++;
> > +			if (desc_status & MSC_RFE)
> > +				stats->rx_frame_errors++;
> > +			if (desc_status & (MSC_RTLF | MSC_RTSF))
> > +				stats->rx_length_errors++;
> > +			if (desc_status & MSC_CEEF)
> > +				stats->rx_missed_errors++;
> > +		} else {
> > +			die_dt = desc->die_dt & 0xF0;
> > +			switch (die_dt) {
> > +			case DT_FSINGLE:
> > +				skb = ravb_get_skb_rgeth(ndev, q, entry, desc);
> > +				skb_put(skb, pkt_len);
> > +				skb->protocol = eth_type_trans(skb, ndev);
> > +				if (ndev->features & NETIF_F_RXCSUM)
> > +					ravb_rx_csum_rgeth(skb);
> > +				napi_gro_receive(&priv->napi[q], skb);
> > +				stats->rx_packets++;
> > +				stats->rx_bytes += pkt_len;
> > +				break;
> > +			case DT_FSTART:
> > +				priv->rxtop_skb = ravb_get_skb_rgeth(ndev, q,
> entry, desc);
> 
>    But don't you need to  copy the data in this case?

It is not required, here. 

> 
> > +				skb_put(priv->rxtop_skb, pkt_len);
> > +				break;
> > +			case DT_FMID:
> > +				skb = ravb_get_skb_rgeth(ndev, q, entry, desc);
> > +				skb_copy_to_linear_data_offset(priv->rxtop_skb,
> > +							       priv->rxtop_skb->len,
> > +							       skb->data,
> > +							       pkt_len);
> > +				skb_put(priv->rxtop_skb, pkt_len);
> > +				dev_kfree_skb(skb);
> > +				break;
> > +			case DT_FEND:
> > +				skb = ravb_get_skb_rgeth(ndev, q, entry, desc);
> > +				skb_copy_to_linear_data_offset(priv->rxtop_skb,
> > +							       priv->rxtop_skb->len,
> > +							       skb->data,
> > +							       pkt_len);
> > +				skb_put(priv->rxtop_skb, pkt_len);
> > +				dev_kfree_skb(skb);
> > +				priv->rxtop_skb->protocol =
> > +					eth_type_trans(priv->rxtop_skb, ndev);
> > +				if (ndev->features & NETIF_F_RXCSUM)
> > +					ravb_rx_csum_rgeth(skb);
> > +				napi_gro_receive(&priv->napi[q],
> > +						 priv->rxtop_skb);
> > +				stats->rx_packets++;
> > +				stats->rx_bytes += priv->rxtop_skb->len;
> > +				break;
> > +			}
> > +		}
> > +
> > +		entry = (++priv->cur_rx[q]) % priv->num_rx_ring[q];
> > +		desc = &priv->rgeth_rx_ring[q][entry];
> > +	}
> > +
> > +	/* Refill the RX ring buffers. */
> > +	for (; priv->cur_rx[q] - priv->dirty_rx[q] > 0; priv->dirty_rx[q]++)
> {
> > +		entry = priv->dirty_rx[q] % priv->num_rx_ring[q];
> > +		desc = &priv->rgeth_rx_ring[q][entry];
> > +		desc->ds_cc = cpu_to_le16(RGETH_RX_DESC_DATA_SIZE);
> > +
> > +		if (!priv->rx_skb[q][entry]) {
> > +			skb = netdev_alloc_skb(ndev,
> > +					       RGETH_RX_BUFF_MAX + RAVB_ALIGN - 1);
> 
>    ALIGN(RGETH_RX_BUFF_MAX, RAVB_ALIGN)?

It is taken care in next RFC.

Regards,
Biju

> 
> [...]
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 79+ messages in thread

end of thread, other threads:[~2021-10-04 14:56 UTC | newest]

Thread overview: 79+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-23 14:07 [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Biju Das
2021-09-23 14:07 ` [RFC/PATCH 01/18] ravb: Rename "ravb_set_features_rx_csum" function to "ravb_set_features_rcar" Biju Das
2021-09-27 19:54   ` Sergey Shtylyov
2021-09-23 14:07 ` [RFC/PATCH 02/18] ravb: Rename the variables "no_ptp_cfg_active" and "ptp_cfg_active" Biju Das
2021-09-23 16:07   ` Sergey Shtylyov
2021-09-23 16:35     ` Biju Das
2021-09-23 17:57       ` Sergey Shtylyov
2021-09-23 18:20         ` Biju Das
2021-09-26 13:34           ` Biju Das
2021-09-23 14:07 ` [RFC/PATCH 03/18] ravb: Initialize GbEthernet dmac Biju Das
2021-09-23 17:41   ` Sergey Shtylyov
2021-09-23 18:42     ` Biju Das
2021-09-23 19:07   ` Sergey Shtylyov
2021-09-23 19:22     ` Biju Das
2021-09-23 19:29       ` Biju Das
2021-09-26 13:38         ` Biju Das
2021-09-23 14:07 ` [RFC/PATCH 04/18] ravb: Enable aligned_tx and tx_counters for RZ/G2L Biju Das
2021-09-23 18:05   ` Sergey Shtylyov
2021-09-23 18:10     ` Sergey Shtylyov
2021-09-23 18:13     ` Biju Das
2021-09-26 13:40       ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 05/18] ravb: Exclude gPTP feature support " Biju Das
2021-09-23 19:00   ` Sergey Shtylyov
2021-09-23 19:13     ` Biju Das
2021-09-23 19:41       ` Sergey Shtylyov
2021-09-23 19:45         ` Biju Das
2021-09-26 13:48           ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 06/18] ravb: Add multi_tsrq to struct ravb_hw_info Biju Das
2021-09-23 20:19   ` Sergey Shtylyov
2021-09-24  6:19     ` Biju Das
2021-09-26 13:54       ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 07/18] ravb: Add magic_pkt " Biju Das
2021-09-23 20:42   ` Sergey Shtylyov
2021-09-24  6:24     ` Biju Das
2021-09-26 13:56       ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 08/18] ravb: Add mii_rgmii_selection " Biju Das
2021-09-24 19:49   ` Sergey Shtylyov
2021-09-25  6:23     ` Biju Das
2021-09-26 15:49       ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 09/18] ravb: Add half_duplex " Biju Das
2021-09-24 20:07   ` Sergey Shtylyov
2021-09-25  6:37     ` Biju Das
2021-09-26 15:51     ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 10/18] ravb: Initialize GbEthernet E-MAC Biju Das
2021-09-24 20:44   ` Sergey Shtylyov
2021-09-25  6:38     ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 11/18] ravb: Add rx_2k_buffers to struct ravb_hw_info Biju Das
2021-09-24 19:35   ` Sergey Shtylyov
2021-09-26 15:48     ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 12/18] ravb: Add timestamp " Biju Das
2021-09-25 20:52   ` Sergey Shtylyov
2021-09-26  6:34     ` Biju Das
2021-09-26 16:52       ` Biju Das
2021-09-26 20:45       ` Sergey Shtylyov
2021-09-26 20:48         ` Sergei Shtylyov
2021-09-27  6:10           ` Biju Das
2021-09-27  6:04         ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 13/18] ravb: Add rx_ring_free function support for GbEthernet Biju Das
2021-09-27 19:28   ` Sergey Shtylyov
2021-09-28  9:24     ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 14/18] ravb: Add rx_ring_format function " Biju Das
2021-09-27 20:32   ` Sergey Shtylyov
2021-09-29  7:49     ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 15/18] ravb: Add rx_alloc helper " Biju Das
2021-09-23 14:08 ` [RFC/PATCH 16/18] ravb: Add Packet receive function for Gigabit Ethernet Biju Das
2021-10-01 17:27   ` Sergey Shtylyov
2021-10-04 14:56     ` Biju Das
2021-09-23 14:08 ` [RFC/PATCH 17/18] ravb: Add carrier_counters to struct ravb_hw_info Biju Das
2021-09-28 20:50   ` Sergey Shtylyov
2021-09-23 14:08 ` [RFC/PATCH 18/18] ravb: Add set_feature support for RZ/G2L Biju Das
2021-09-30 20:39   ` Sergey Shtylyov
2021-10-01  6:53     ` Biju Das
2021-10-01  9:13       ` Sergey Shtylyov
2021-10-01  9:26         ` Biju Das
2021-10-01  8:22     ` Biju Das
2021-09-23 15:11 ` [RFC/PATCH 00/18] Add Gigabit Ethernet driver support Sergey Shtylyov
2021-09-23 15:13   ` Sergey Shtylyov
2021-09-23 15:37   ` Jakub Kicinski
2021-09-23 17:43     ` Sergey Shtylyov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.