All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver
@ 2021-10-12 16:35 Biju Das
  2021-10-12 16:36 ` [PATCH net-next v3 01/14] ravb: Use ALIGN macro for max_rx_len Biju Das
                   ` (15 more replies)
  0 siblings, 16 replies; 31+ messages in thread
From: Biju Das @ 2021-10-12 16:35 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Sergei Shtylyov, Lad Prabhakar,
	Andrew Lunn, 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 is aims to add functional support for Gigabit Ethernet driver
by filling all the stubs except set_features.

set_feature patch will send as separate RFC patch along with rx_checksum
patch, as it needs further discussion related to HW checksum.

With this series, we can do boot kernel with rootFS mounted on NFS on RZ/G2L
platforms.

Ref:-
 https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=557655

v2->v3:
 * Enabled TPE/RPE of TOE, as disabling causes loopback test to fail
 * Documented CSR0 register bits
 * Removed PRM setting from EMAC configuration mode
 * Updated EMAC configuration mode.
 * Added Sergey's Rb tag

V1->V2:
 * Removed the unrelated comment "GbEthernet TOE Hardware checksum status"
   and macros TOE_IPV4_RX_CSUM_OK and TOE_IPV6_RX_CSUM_OK which is accidentally
   introduced as part of RFC discussion from patch #6.

RFC->V1:
 * Removed patch#3 will send it as RFC
 * Removed rx_csum functionality from patch#7, will send it as RFC
 * Renamed "nc_queue" -> "nc_queues"
 * Separated the comment patch into 2 separate patches.
 * Documented PFRI register bit
 * Added Sergey's Rb tag

RFC changes:
 * used ALIGN macro for calculating the value for max_rx_len.
 * used rx_max_buf_size instead of rx_2k_buffers feature bit.
 * moved struct ravb_rx_desc *gbeth_rx_ring near to ravb_private::rx_ring
   and allocating it for 1 RX queue.
 * Started using gbeth_rx_ring instead of gbeth_rx_ring[q].
 * renamed ravb_alloc_rx_desc to ravb_alloc_rx_desc_rcar
 * renamed ravb_rx_ring_free to ravb_rx_ring_free_rcar
 * renamed ravb_rx_ring_format to ravb_rx_ring_format_rcar
 * renamed ravb_rcar_rx to ravb_rx_rcar
 * renamed "tsrq" variable
 * Updated the comments

Biju Das (14):
  ravb: Use ALIGN macro for max_rx_len
  ravb: Add rx_max_buf_size to struct ravb_hw_info
  ravb: Fillup ravb_alloc_rx_desc_gbeth() stub
  ravb: Fillup ravb_rx_ring_free_gbeth() stub
  ravb: Fillup ravb_rx_ring_format_gbeth() stub
  ravb: Fillup ravb_rx_gbeth() stub
  ravb: Add carrier_counters to struct ravb_hw_info
  ravb: Add support to retrieve stats for GbEthernet
  ravb: Rename "tsrq" variable
  ravb: Optimize ravb_emac_init_gbeth function
  ravb: Rename "nc_queue" feature bit
  ravb: Document PFRI register bit
  ravb: Update ravb_emac_init_gbeth()
  ravb: Fix typo AVB->DMAC

 drivers/net/ethernet/renesas/ravb.h      |  19 +-
 drivers/net/ethernet/renesas/ravb_main.c | 328 +++++++++++++++++++----
 2 files changed, 295 insertions(+), 52 deletions(-)

-- 
2.17.1


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

* [PATCH net-next v3 01/14] ravb: Use ALIGN macro for max_rx_len
  2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
@ 2021-10-12 16:36 ` Biju Das
  2021-10-12 16:36 ` [PATCH net-next v3 02/14] ravb: Add rx_max_buf_size to struct ravb_hw_info Biju Das
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Biju Das @ 2021-10-12 16:36 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Sergei Shtylyov, Lad Prabhakar,
	Andrew Lunn, Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda,
	netdev, linux-renesas-soc, Chris Paterson, Biju Das

Use ALIGN macro for calculating the value for max_rx_len.

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>
---
v2->v3:
 * No change.
v1->v2:
 * No change.
RFC->v1:
 * No Change. Added Sergey's Rb tag
---
 drivers/net/ethernet/renesas/ravb_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 50038e76c72f..0e3cda1140e5 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2227,7 +2227,7 @@ static const struct ravb_hw_info gbeth_hw_info = {
 	.set_feature = ravb_set_features_gbeth,
 	.dmac_init = ravb_dmac_init_gbeth,
 	.emac_init = ravb_emac_init_gbeth,
-	.max_rx_len = GBETH_RX_BUFF_MAX + RAVB_ALIGN - 1,
+	.max_rx_len = ALIGN(GBETH_RX_BUFF_MAX, RAVB_ALIGN),
 	.tsrq = TCCR_TSRQ0,
 	.aligned_tx = 1,
 	.tx_counters = 1,
-- 
2.17.1


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

* [PATCH net-next v3 02/14] ravb: Add rx_max_buf_size to struct ravb_hw_info
  2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
  2021-10-12 16:36 ` [PATCH net-next v3 01/14] ravb: Use ALIGN macro for max_rx_len Biju Das
@ 2021-10-12 16:36 ` Biju Das
  2021-10-12 16:36 ` [PATCH net-next v3 03/14] ravb: Fillup ravb_alloc_rx_desc_gbeth() stub Biju Das
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Biju Das @ 2021-10-12 16:36 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Sergei Shtylyov, Geert Uytterhoeven,
	Adam Ford, Andrew Lunn, Yuusuke Ashizuka, Yoshihiro Shimoda,
	netdev, linux-renesas-soc, Chris Paterson, Biju Das,
	Prabhakar Mahadev Lad

R-Car AVB-DMAC has maximum 2K size on RX buffer, whereas on RZ/G2L
it is 8K. We need to allow for changing the MTU within the limit
of the maximum size of a descriptor.

Add a rx_max_buf_size variable to struct ravb_hw_info to handle
this difference.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
v2->v3:
 * No change
V1->v2:
 * No change
RFC->V1:
 * No Change. Added Sergey's Rb tag
---
 drivers/net/ethernet/renesas/ravb.h      | 1 +
 drivers/net/ethernet/renesas/ravb_main.c | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 5dc1324786e0..b147c4a0dc0b 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1010,6 +1010,7 @@ struct ravb_hw_info {
 	int stats_len;
 	size_t max_rx_len;
 	u32 tsrq;
+	u32 rx_max_buf_size;
 	unsigned aligned_tx: 1;
 
 	/* hardware features */
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 0e3cda1140e5..fe3449fb4135 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2188,6 +2188,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
 	.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
 	.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
 	.tsrq = TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3,
+	.rx_max_buf_size = SZ_2K,
 	.internal_delay = 1,
 	.tx_counters = 1,
 	.multi_irqs = 1,
@@ -2212,6 +2213,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,
 	.tsrq = TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3,
+	.rx_max_buf_size = SZ_2K,
 	.aligned_tx = 1,
 	.gptp = 1,
 	.nc_queue = 1,
@@ -2229,6 +2231,7 @@ static const struct ravb_hw_info gbeth_hw_info = {
 	.emac_init = ravb_emac_init_gbeth,
 	.max_rx_len = ALIGN(GBETH_RX_BUFF_MAX, RAVB_ALIGN),
 	.tsrq = TCCR_TSRQ0,
+	.rx_max_buf_size = SZ_8K,
 	.aligned_tx = 1,
 	.tx_counters = 1,
 	.half_duplex = 1,
@@ -2452,7 +2455,7 @@ 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->max_mtu = info->rx_max_buf_size - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN);
 	ndev->min_mtu = ETH_MIN_MTU;
 
 	/* FIXME: R-Car Gen2 has 4byte alignment restriction for tx buffer
-- 
2.17.1


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

* [PATCH net-next v3 03/14] ravb: Fillup ravb_alloc_rx_desc_gbeth() stub
  2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
  2021-10-12 16:36 ` [PATCH net-next v3 01/14] ravb: Use ALIGN macro for max_rx_len Biju Das
  2021-10-12 16:36 ` [PATCH net-next v3 02/14] ravb: Add rx_max_buf_size to struct ravb_hw_info Biju Das
@ 2021-10-12 16:36 ` Biju Das
  2021-10-12 16:36 ` [PATCH net-next v3 04/14] ravb: Fillup ravb_rx_ring_free_gbeth() stub Biju Das
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Biju Das @ 2021-10-12 16:36 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Geert Uytterhoeven, Sergey Shtylyov,
	Adam Ford, Andrew Lunn, Yuusuke Ashizuka, Yoshihiro Shimoda,
	netdev, linux-renesas-soc, Chris Paterson, Biju Das,
	Prabhakar Mahadev Lad

Fillup ravb_alloc_rx_desc_gbeth() function to support RZ/G2L.

This patch also renames ravb_alloc_rx_desc to ravb_alloc_rx_desc_rcar
to be consistent with the naming convention used in sh_eth driver.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
v2->v3:
 * No change
V1->v2:
 * No change
RFC->V1:
 * No Change. Added Sergey's Rb tag
RFC:
 * started allocating 1 rx queue for "gbeth_rx_ring"
 * Moved gbeth_rx_ring near to rx_ring in priv structure
 * renamed ravb_alloc_rx_desc to ravb_alloc_rx_desc_rcar
---
 drivers/net/ethernet/renesas/ravb.h      |  1 +
 drivers/net/ethernet/renesas/ravb_main.c | 30 ++++++++++++++++++------
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index b147c4a0dc0b..ed771ead61b9 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1038,6 +1038,7 @@ struct ravb_private {
 	struct ravb_desc *desc_bat;
 	dma_addr_t rx_desc_dma[NUM_RX_QUEUE];
 	dma_addr_t tx_desc_dma[NUM_TX_QUEUE];
+	struct ravb_rx_desc *gbeth_rx_ring;
 	struct ravb_ex_rx_desc *rx_ring[NUM_RX_QUEUE];
 	struct ravb_tx_desc *tx_ring[NUM_TX_QUEUE];
 	void *tx_align[NUM_TX_QUEUE];
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index fe3449fb4135..c6bab0dfd3bc 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -385,11 +385,18 @@ static void ravb_ring_format(struct net_device *ndev, int q)
 
 static void *ravb_alloc_rx_desc_gbeth(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->gbeth_rx_ring = dma_alloc_coherent(ndev->dev.parent, ring_size,
+						 &priv->rx_desc_dma[q],
+						 GFP_KERNEL);
+	return priv->gbeth_rx_ring;
 }
 
-static void *ravb_alloc_rx_desc(struct net_device *ndev, int q)
+static void *ravb_alloc_rx_desc_rcar(struct net_device *ndev, int q)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
 	unsigned int ring_size;
@@ -1084,16 +1091,25 @@ 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;
+	bool gptp = info->gptp || info->ccc_gac;
+	struct ravb_rx_desc *desc;
 	unsigned long flags;
 	int q = napi - priv->napi;
 	int mask = BIT(q);
 	int quota = budget;
+	unsigned int entry;
 
+	if (!gptp) {
+		entry = priv->cur_rx[q] % priv->num_rx_ring[q];
+		desc = &priv->gbeth_rx_ring[entry];
+	}
 	/* Processing RX Descriptor Ring */
 	/* Clear RX interrupt */
 	ravb_write(ndev, ~(mask | RIS0_RESERVED), RIS0);
-	if (ravb_rx(ndev, &quota, q))
-		goto out;
+	if (gptp || desc->die_dt != DT_FEMPTY) {
+		if (ravb_rx(ndev, &quota, q))
+			goto out;
+	}
 
 	/* Processing TX Descriptor Ring */
 	spin_lock_irqsave(&priv->lock, flags);
@@ -2175,7 +2191,7 @@ static int ravb_mdio_release(struct ravb_private *priv)
 static const struct ravb_hw_info ravb_gen3_hw_info = {
 	.rx_ring_free = ravb_rx_ring_free,
 	.rx_ring_format = ravb_rx_ring_format,
-	.alloc_rx_desc = ravb_alloc_rx_desc,
+	.alloc_rx_desc = ravb_alloc_rx_desc_rcar,
 	.receive = ravb_rcar_rx,
 	.set_rate = ravb_set_rate_rcar,
 	.set_feature = ravb_set_features_rcar,
@@ -2200,7 +2216,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
 static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.rx_ring_free = ravb_rx_ring_free,
 	.rx_ring_format = ravb_rx_ring_format,
-	.alloc_rx_desc = ravb_alloc_rx_desc,
+	.alloc_rx_desc = ravb_alloc_rx_desc_rcar,
 	.receive = ravb_rcar_rx,
 	.set_rate = ravb_set_rate_rcar,
 	.set_feature = ravb_set_features_rcar,
-- 
2.17.1


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

* [PATCH net-next v3 04/14] ravb: Fillup ravb_rx_ring_free_gbeth() stub
  2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
                   ` (2 preceding siblings ...)
  2021-10-12 16:36 ` [PATCH net-next v3 03/14] ravb: Fillup ravb_alloc_rx_desc_gbeth() stub Biju Das
@ 2021-10-12 16:36 ` Biju Das
  2021-10-12 16:36 ` [PATCH net-next v3 05/14] ravb: Fillup ravb_rx_ring_format_gbeth() stub Biju Das
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Biju Das @ 2021-10-12 16:36 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Sergei Shtylyov, Geert Uytterhoeven,
	Sergey Shtylyov, Adam Ford, Andrew Lunn, Yuusuke Ashizuka,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das, Prabhakar Mahadev Lad

Fillup ravb_rx_ring_free_gbeth() function to support RZ/G2L.

This patch also renames ravb_rx_ring_free to ravb_rx_ring_free_rcar
to be consistent with the naming convention used in sh_eth driver.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
v2->v3:
 * No change
v1->v2:
 * No change
RFC->V1:
 * No change. Added Sergey's Rb tag.
RFC Changes:
 * moved "gbeth_rx_ring" to previous patch
 * started using "gbeth_rx_ring" instead of gbeth_rx_ring[q].
 * renamed ravb_rx_ring_free to ravb_rx_ring_free_rcar
---
 drivers/net/ethernet/renesas/ravb_main.c | 28 ++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index c6bab0dfd3bc..1ea25a8d208e 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -236,10 +236,30 @@ static int ravb_tx_free(struct net_device *ndev, int q, bool free_txed_only)
 
 static void ravb_rx_ring_free_gbeth(struct net_device *ndev, int q)
 {
-	/* Place holder */
+	struct ravb_private *priv = netdev_priv(ndev);
+	unsigned int ring_size;
+	unsigned int i;
+
+	if (!priv->gbeth_rx_ring)
+		return;
+
+	for (i = 0; i < priv->num_rx_ring[q]; i++) {
+		struct ravb_rx_desc *desc = &priv->gbeth_rx_ring[i];
+
+		if (!dma_mapping_error(ndev->dev.parent,
+				       le32_to_cpu(desc->dptr)))
+			dma_unmap_single(ndev->dev.parent,
+					 le32_to_cpu(desc->dptr),
+					 GBETH_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->gbeth_rx_ring,
+			  priv->rx_desc_dma[q]);
+	priv->gbeth_rx_ring = NULL;
 }
 
-static void ravb_rx_ring_free(struct net_device *ndev, int q)
+static void ravb_rx_ring_free_rcar(struct net_device *ndev, int q)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
 	unsigned int ring_size;
@@ -2189,7 +2209,7 @@ static int ravb_mdio_release(struct ravb_private *priv)
 }
 
 static const struct ravb_hw_info ravb_gen3_hw_info = {
-	.rx_ring_free = ravb_rx_ring_free,
+	.rx_ring_free = ravb_rx_ring_free_rcar,
 	.rx_ring_format = ravb_rx_ring_format,
 	.alloc_rx_desc = ravb_alloc_rx_desc_rcar,
 	.receive = ravb_rcar_rx,
@@ -2214,7 +2234,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
 };
 
 static const struct ravb_hw_info ravb_gen2_hw_info = {
-	.rx_ring_free = ravb_rx_ring_free,
+	.rx_ring_free = ravb_rx_ring_free_rcar,
 	.rx_ring_format = ravb_rx_ring_format,
 	.alloc_rx_desc = ravb_alloc_rx_desc_rcar,
 	.receive = ravb_rcar_rx,
-- 
2.17.1


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

* [PATCH net-next v3 05/14] ravb: Fillup ravb_rx_ring_format_gbeth() stub
  2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
                   ` (3 preceding siblings ...)
  2021-10-12 16:36 ` [PATCH net-next v3 04/14] ravb: Fillup ravb_rx_ring_free_gbeth() stub Biju Das
@ 2021-10-12 16:36 ` Biju Das
  2021-10-12 16:36 ` [PATCH net-next v3 06/14] ravb: Fillup ravb_rx_gbeth() stub Biju Das
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Biju Das @ 2021-10-12 16:36 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Geert Uytterhoeven, Sergey Shtylyov,
	Adam Ford, Andrew Lunn, Yuusuke Ashizuka, Yoshihiro Shimoda,
	netdev, linux-renesas-soc, Chris Paterson, Biju Das,
	Prabhakar Mahadev Lad

Fillup ravb_rx_ring_format_gbeth() function to support RZ/G2L.

This patch also renames ravb_rx_ring_format to ravb_rx_ring_format_rcar
to be consistent with the naming convention used in sh_eth driver.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
v2->v3:
 * No change
V1->V2:
 * No change
RFC->V1:
 * No change. Added Sergey's Rb tag.
RFC changes:
 * Started using gbeth_rx_ring instead of gbeth_rx_ring[q].
 * renamed ravb_rx_ring_format to ravb_rx_ring_format_rcar
---
 drivers/net/ethernet/renesas/ravb.h      |  1 +
 drivers/net/ethernet/renesas/ravb_main.c | 34 +++++++++++++++++++++---
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index ed771ead61b9..e9de3f8306ce 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -970,6 +970,7 @@ enum CXR31_BIT {
 #define RX_BUF_SZ	(2048 - ETH_FCS_LEN + sizeof(__sum16))
 
 #define GBETH_RX_BUFF_MAX 8192
+#define GBETH_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 1ea25a8d208e..f7ce9b6e596f 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -327,10 +327,36 @@ static void ravb_ring_free(struct net_device *ndev, int q)
 
 static void ravb_rx_ring_format_gbeth(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;
+	dma_addr_t dma_addr;
+	unsigned int i;
+
+	rx_ring_size = sizeof(*rx_desc) * priv->num_rx_ring[q];
+	memset(priv->gbeth_rx_ring, 0, rx_ring_size);
+	/* Build RX ring buffer */
+	for (i = 0; i < priv->num_rx_ring[q]; i++) {
+		/* RX descriptor */
+		rx_desc = &priv->gbeth_rx_ring[i];
+		rx_desc->ds_cc = cpu_to_le16(GBETH_RX_DESC_DATA_SIZE);
+		dma_addr = dma_map_single(ndev->dev.parent, priv->rx_skb[q][i]->data,
+					  GBETH_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->gbeth_rx_ring[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)
+static void ravb_rx_ring_format_rcar(struct net_device *ndev, int q)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
 	struct ravb_ex_rx_desc *rx_desc;
@@ -2210,7 +2236,7 @@ static int ravb_mdio_release(struct ravb_private *priv)
 
 static const struct ravb_hw_info ravb_gen3_hw_info = {
 	.rx_ring_free = ravb_rx_ring_free_rcar,
-	.rx_ring_format = ravb_rx_ring_format,
+	.rx_ring_format = ravb_rx_ring_format_rcar,
 	.alloc_rx_desc = ravb_alloc_rx_desc_rcar,
 	.receive = ravb_rcar_rx,
 	.set_rate = ravb_set_rate_rcar,
@@ -2235,7 +2261,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
 
 static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.rx_ring_free = ravb_rx_ring_free_rcar,
-	.rx_ring_format = ravb_rx_ring_format,
+	.rx_ring_format = ravb_rx_ring_format_rcar,
 	.alloc_rx_desc = ravb_alloc_rx_desc_rcar,
 	.receive = ravb_rcar_rx,
 	.set_rate = ravb_set_rate_rcar,
-- 
2.17.1


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

* [PATCH net-next v3 06/14] ravb: Fillup ravb_rx_gbeth() stub
  2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
                   ` (4 preceding siblings ...)
  2021-10-12 16:36 ` [PATCH net-next v3 05/14] ravb: Fillup ravb_rx_ring_format_gbeth() stub Biju Das
@ 2021-10-12 16:36 ` Biju Das
  2021-10-12 16:36 ` [PATCH net-next v3 07/14] ravb: Add carrier_counters to struct ravb_hw_info Biju Das
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Biju Das @ 2021-10-12 16:36 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Sergei Shtylyov, Geert Uytterhoeven,
	Sergey Shtylyov, Adam Ford, Andrew Lunn, Yuusuke Ashizuka,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das, Prabhakar Mahadev Lad

Fillup ravb_rx_gbeth() function to support RZ/G2L.

This patch also renames ravb_rcar_rx to ravb_rx_rcar to be
consistent with the naming convention used in sh_eth driver.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
v2->v3:
 * Added Sergey's Rb tag
V1->V2:
 * Removed the unrelated comment "GbEthernet TOE Hardware checksum status"
   and macros TOE_IPV4_RX_CSUM_OK and TOE_IPV6_RX_CSUM_OK which is accidentally
   introduced as part of RFC discussion.
RFC->v1:
 * Removed ravb_rx_csum_gbeth() and will post this as seperate RFC 
   patch.
---
 drivers/net/ethernet/renesas/ravb.h      |   1 +
 drivers/net/ethernet/renesas/ravb_main.c | 146 ++++++++++++++++++++++-
 2 files changed, 142 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index e9de3f8306ce..99164318db26 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1043,6 +1043,7 @@ struct ravb_private {
 	struct ravb_ex_rx_desc *rx_ring[NUM_RX_QUEUE];
 	struct ravb_tx_desc *tx_ring[NUM_TX_QUEUE];
 	void *tx_align[NUM_TX_QUEUE];
+	struct sk_buff *rx_1st_skb;
 	struct sk_buff **rx_skb[NUM_RX_QUEUE];
 	struct sk_buff **tx_skb[NUM_TX_QUEUE];
 	u32 rx_over_errors;
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index f7ce9b6e596f..1a5ebc58682d 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -734,15 +734,151 @@ static void ravb_rx_csum(struct sk_buff *skb)
 	skb_trim(skb, skb->len - sizeof(__sum16));
 }
 
+static struct sk_buff *ravb_get_skb_gbeth(struct net_device *ndev, int entry,
+					  struct ravb_rx_desc *desc)
+{
+	struct ravb_private *priv = netdev_priv(ndev);
+	struct sk_buff *skb;
+
+	skb = priv->rx_skb[RAVB_BE][entry];
+	priv->rx_skb[RAVB_BE][entry] = NULL;
+	dma_unmap_single(ndev->dev.parent, le32_to_cpu(desc->dptr),
+			 ALIGN(GBETH_RX_BUFF_MAX, 16), DMA_FROM_DEVICE);
+
+	return skb;
+}
+
 /* Packet receive function for Gigabit Ethernet */
 static bool ravb_rx_gbeth(struct net_device *ndev, int *quota, int q)
 {
-	/* Place holder */
-	return true;
+	struct ravb_private *priv = netdev_priv(ndev);
+	const struct ravb_hw_info *info = priv->info;
+	struct net_device_stats *stats;
+	struct ravb_rx_desc *desc;
+	struct sk_buff *skb;
+	dma_addr_t dma_addr;
+	u8  desc_status;
+	int boguscnt;
+	u16 pkt_len;
+	u8  die_dt;
+	int entry;
+	int limit;
+
+	entry = priv->cur_rx[q] % priv->num_rx_ring[q];
+	boguscnt = priv->dirty_rx[q] + priv->num_rx_ring[q] - priv->cur_rx[q];
+	stats = &priv->stats[q];
+
+	boguscnt = min(boguscnt, *quota);
+	limit = boguscnt;
+	desc = &priv->gbeth_rx_ring[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_gbeth(ndev, entry, desc);
+				skb_put(skb, pkt_len);
+				skb->protocol = eth_type_trans(skb, ndev);
+				napi_gro_receive(&priv->napi[q], skb);
+				stats->rx_packets++;
+				stats->rx_bytes += pkt_len;
+				break;
+			case DT_FSTART:
+				priv->rx_1st_skb = ravb_get_skb_gbeth(ndev, entry, desc);
+				skb_put(priv->rx_1st_skb, pkt_len);
+				break;
+			case DT_FMID:
+				skb = ravb_get_skb_gbeth(ndev, entry, desc);
+				skb_copy_to_linear_data_offset(priv->rx_1st_skb,
+							       priv->rx_1st_skb->len,
+							       skb->data,
+							       pkt_len);
+				skb_put(priv->rx_1st_skb, pkt_len);
+				dev_kfree_skb(skb);
+				break;
+			case DT_FEND:
+				skb = ravb_get_skb_gbeth(ndev, entry, desc);
+				skb_copy_to_linear_data_offset(priv->rx_1st_skb,
+							       priv->rx_1st_skb->len,
+							       skb->data,
+							       pkt_len);
+				skb_put(priv->rx_1st_skb, pkt_len);
+				dev_kfree_skb(skb);
+				priv->rx_1st_skb->protocol =
+					eth_type_trans(priv->rx_1st_skb, ndev);
+				napi_gro_receive(&priv->napi[q],
+						 priv->rx_1st_skb);
+				stats->rx_packets++;
+				stats->rx_bytes += priv->rx_1st_skb->len;
+				break;
+			}
+		}
+
+		entry = (++priv->cur_rx[q]) % priv->num_rx_ring[q];
+		desc = &priv->gbeth_rx_ring[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->gbeth_rx_ring[entry];
+		desc->ds_cc = cpu_to_le16(GBETH_RX_DESC_DATA_SIZE);
+
+		if (!priv->rx_skb[q][entry]) {
+			skb = netdev_alloc_skb(ndev, info->max_rx_len);
+			if (!skb)
+				break;
+			ravb_set_buffer_align(skb);
+			dma_addr = dma_map_single(ndev->dev.parent,
+						  skb->data,
+						  GBETH_RX_BUFF_MAX,
+						  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 */
-static bool ravb_rcar_rx(struct net_device *ndev, int *quota, int q)
+static bool ravb_rx_rcar(struct net_device *ndev, int *quota, int q)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
 	const struct ravb_hw_info *info = priv->info;
@@ -2238,7 +2374,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
 	.rx_ring_free = ravb_rx_ring_free_rcar,
 	.rx_ring_format = ravb_rx_ring_format_rcar,
 	.alloc_rx_desc = ravb_alloc_rx_desc_rcar,
-	.receive = ravb_rcar_rx,
+	.receive = ravb_rx_rcar,
 	.set_rate = ravb_set_rate_rcar,
 	.set_feature = ravb_set_features_rcar,
 	.dmac_init = ravb_dmac_init_rcar,
@@ -2263,7 +2399,7 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.rx_ring_free = ravb_rx_ring_free_rcar,
 	.rx_ring_format = ravb_rx_ring_format_rcar,
 	.alloc_rx_desc = ravb_alloc_rx_desc_rcar,
-	.receive = ravb_rcar_rx,
+	.receive = ravb_rx_rcar,
 	.set_rate = ravb_set_rate_rcar,
 	.set_feature = ravb_set_features_rcar,
 	.dmac_init = ravb_dmac_init_rcar,
-- 
2.17.1


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

* [PATCH net-next v3 07/14] ravb: Add carrier_counters to struct ravb_hw_info
  2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
                   ` (5 preceding siblings ...)
  2021-10-12 16:36 ` [PATCH net-next v3 06/14] ravb: Fillup ravb_rx_gbeth() stub Biju Das
@ 2021-10-12 16:36 ` Biju Das
  2021-10-12 16:36 ` [PATCH net-next v3 08/14] ravb: Add support to retrieve stats for GbEthernet Biju Das
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Biju Das @ 2021-10-12 16:36 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Geert Uytterhoeven, Sergey Shtylyov,
	Adam Ford, Andrew Lunn, Yuusuke Ashizuka, Yoshihiro Shimoda,
	netdev, linux-renesas-soc, Chris Paterson, Biju Das,
	Prabhakar Mahadev Lad

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>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
v2->v3;
 * No change
V1->V2:
 * No change
RFC->V1:
 * Moved carrier_counters near to tx_counters.
 * removed CXR55 and CXR56 registers as it is rx related registers.
 * Retained Sergey's Rb tag as it is trivial change.
RFC changes:
 * Added Sergey's Rb tag.
---
 drivers/net/ethernet/renesas/ravb.h      | 3 +++
 drivers/net/ethernet/renesas/ravb_main.c | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 99164318db26..527e865dee81 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -196,6 +196,8 @@ enum ravb_reg {
 	MAHR	= 0x05c0,
 	MALR	= 0x05c8,
 	TROCR	= 0x0700,	/* R-Car Gen3 and RZ/G2L only */
+	CXR41	= 0x0708,	/* RZ/G2L only */
+	CXR42	= 0x0710,	/* RZ/G2L only */
 	CEFCR	= 0x0740,
 	FRECR	= 0x0748,
 	TSFRCR	= 0x0750,
@@ -1017,6 +1019,7 @@ struct ravb_hw_info {
 	/* hardware features */
 	unsigned internal_delay:1;	/* AVB-DMAC has internal delays */
 	unsigned tx_counters:1;		/* E-MAC has TX counters */
+	unsigned carrier_counters:1;	/* E-MAC has carrier counters */
 	unsigned multi_irqs:1;		/* AVB-DMAC and E-MAC has multiple irqs */
 	unsigned gptp:1;		/* AVB-DMAC has gPTP support */
 	unsigned ccc_gac:1;		/* AVB-DMAC has gPTP support active in config mode */
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 1a5ebc58682d..2221a2565397 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2053,6 +2053,13 @@ 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->rx_packets = stats0->rx_packets;
 	nstats->tx_packets = stats0->tx_packets;
 	nstats->rx_bytes = stats0->rx_bytes;
@@ -2432,6 +2439,7 @@ static const struct ravb_hw_info gbeth_hw_info = {
 	.rx_max_buf_size = SZ_8K,
 	.aligned_tx = 1,
 	.tx_counters = 1,
+	.carrier_counters = 1,
 	.half_duplex = 1,
 };
 
-- 
2.17.1


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

* [PATCH net-next v3 08/14] ravb: Add support to retrieve stats for GbEthernet
  2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
                   ` (6 preceding siblings ...)
  2021-10-12 16:36 ` [PATCH net-next v3 07/14] ravb: Add carrier_counters to struct ravb_hw_info Biju Das
@ 2021-10-12 16:36 ` Biju Das
  2021-10-12 16:36 ` [PATCH net-next v3 09/14] ravb: Rename "tsrq" variable Biju Das
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Biju Das @ 2021-10-12 16:36 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Geert Uytterhoeven, Sergey Shtylyov,
	Adam Ford, Andrew Lunn, Yuusuke Ashizuka, Yoshihiro Shimoda,
	netdev, linux-renesas-soc, Chris Paterson, Biju Das,
	Prabhakar Mahadev Lad

Add support for retrieving stats information for GbEthernet.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
v2->v3:
 * No change
V1->V2:
 * No change
RFC->v1:
 * No change. Added Sergey's Rb tag.
RFC changes:
 * New patch.
---
 drivers/net/ethernet/renesas/ravb_main.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 2221a2565397..c984875e8ae0 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1493,6 +1493,24 @@ static void ravb_set_msglevel(struct net_device *ndev, u32 value)
 	priv->msg_enable = value;
 }
 
+static const char ravb_gstrings_stats_gbeth[][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",
@@ -2434,6 +2452,9 @@ static const struct ravb_hw_info gbeth_hw_info = {
 	.set_feature = ravb_set_features_gbeth,
 	.dmac_init = ravb_dmac_init_gbeth,
 	.emac_init = ravb_emac_init_gbeth,
+	.gstrings_stats = ravb_gstrings_stats_gbeth,
+	.gstrings_size = sizeof(ravb_gstrings_stats_gbeth),
+	.stats_len = ARRAY_SIZE(ravb_gstrings_stats_gbeth),
 	.max_rx_len = ALIGN(GBETH_RX_BUFF_MAX, RAVB_ALIGN),
 	.tsrq = TCCR_TSRQ0,
 	.rx_max_buf_size = SZ_8K,
-- 
2.17.1


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

* [PATCH net-next v3 09/14] ravb: Rename "tsrq" variable
  2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
                   ` (7 preceding siblings ...)
  2021-10-12 16:36 ` [PATCH net-next v3 08/14] ravb: Add support to retrieve stats for GbEthernet Biju Das
@ 2021-10-12 16:36 ` Biju Das
  2021-10-12 16:36 ` [PATCH net-next v3 10/14] ravb: Optimize ravb_emac_init_gbeth function Biju Das
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Biju Das @ 2021-10-12 16:36 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Geert Uytterhoeven, Sergey Shtylyov,
	Adam Ford, Andrew Lunn, Yuusuke Ashizuka, Yoshihiro Shimoda,
	netdev, linux-renesas-soc, Chris Paterson, Biju Das,
	Prabhakar Mahadev Lad

Rename the variable "tsrq" with "tccr_mask" as we are passing
TCCR mask to the ravb_wait() function.

There is no functional change.

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>
---
V2->v3:
 * No change
V1->v2:
 * No change
RFC->v1:
 * No Change. Added Sergey's Rb tag.
RFC changes:
 * New patch.
---
 drivers/net/ethernet/renesas/ravb.h      | 2 +-
 drivers/net/ethernet/renesas/ravb_main.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 527e865dee81..99d666a5fb49 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1012,7 +1012,7 @@ struct ravb_hw_info {
 	netdev_features_t net_features;
 	int stats_len;
 	size_t max_rx_len;
-	u32 tsrq;
+	u32 tccr_mask;
 	u32 rx_max_buf_size;
 	unsigned aligned_tx: 1;
 
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index c984875e8ae0..d9b5297e38c8 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1021,7 +1021,7 @@ static int ravb_stop_dma(struct net_device *ndev)
 	int error;
 
 	/* Wait for stopping the hardware TX process */
-	error = ravb_wait(ndev, TCCR, info->tsrq, 0);
+	error = ravb_wait(ndev, TCCR, info->tccr_mask, 0);
 
 	if (error)
 		return error;
@@ -2410,7 +2410,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
 	.net_features = NETIF_F_RXCSUM,
 	.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
 	.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
-	.tsrq = TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3,
+	.tccr_mask = TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3,
 	.rx_max_buf_size = SZ_2K,
 	.internal_delay = 1,
 	.tx_counters = 1,
@@ -2435,7 +2435,7 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.net_features = NETIF_F_RXCSUM,
 	.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
 	.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
-	.tsrq = TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3,
+	.tccr_mask = TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3,
 	.rx_max_buf_size = SZ_2K,
 	.aligned_tx = 1,
 	.gptp = 1,
@@ -2456,7 +2456,7 @@ static const struct ravb_hw_info gbeth_hw_info = {
 	.gstrings_size = sizeof(ravb_gstrings_stats_gbeth),
 	.stats_len = ARRAY_SIZE(ravb_gstrings_stats_gbeth),
 	.max_rx_len = ALIGN(GBETH_RX_BUFF_MAX, RAVB_ALIGN),
-	.tsrq = TCCR_TSRQ0,
+	.tccr_mask = TCCR_TSRQ0,
 	.rx_max_buf_size = SZ_8K,
 	.aligned_tx = 1,
 	.tx_counters = 1,
-- 
2.17.1


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

* [PATCH net-next v3 10/14] ravb: Optimize ravb_emac_init_gbeth function
  2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
                   ` (8 preceding siblings ...)
  2021-10-12 16:36 ` [PATCH net-next v3 09/14] ravb: Rename "tsrq" variable Biju Das
@ 2021-10-12 16:36 ` Biju Das
  2021-10-12 16:36 ` [PATCH net-next v3 11/14] ravb: Rename "nc_queue" feature bit Biju Das
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Biju Das @ 2021-10-12 16:36 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Geert Uytterhoeven, Sergey Shtylyov,
	Adam Ford, Andrew Lunn, Yuusuke Ashizuka, Yoshihiro Shimoda,
	netdev, linux-renesas-soc, Chris Paterson, Biju Das,
	Prabhakar Mahadev Lad

Optimize CXR31 register initialization on ravb_emac_init_gbeth
function.

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>
---
v2->v3:
 * No change
v1->v2:
 * No change
RFC->V1:
 * No Change. Added Sergey's Rb tag.
RFC changes:
 * New patch.
---
 drivers/net/ethernet/renesas/ravb_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index d9b5297e38c8..95ce92eff7eb 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -538,8 +538,7 @@ static void ravb_emac_init_gbeth(struct net_device *ndev)
 	/* E-MAC interrupt enable register */
 	ravb_write(ndev, ECSIPR_ICDIP, ECSIPR);
 
-	ravb_modify(ndev, CXR31, CXR31_SEL_LINK1, 0);
-	ravb_modify(ndev, CXR31, CXR31_SEL_LINK0, CXR31_SEL_LINK0);
+	ravb_modify(ndev, CXR31, CXR31_SEL_LINK0 | CXR31_SEL_LINK1, CXR31_SEL_LINK0);
 }
 
 static void ravb_emac_init_rcar(struct net_device *ndev)
-- 
2.17.1


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

* [PATCH net-next v3 11/14] ravb: Rename "nc_queue" feature bit
  2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
                   ` (9 preceding siblings ...)
  2021-10-12 16:36 ` [PATCH net-next v3 10/14] ravb: Optimize ravb_emac_init_gbeth function Biju Das
@ 2021-10-12 16:36 ` Biju Das
  2021-10-12 16:36 ` [PATCH net-next v3 12/14] ravb: Document PFRI register bit Biju Das
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Biju Das @ 2021-10-12 16:36 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Geert Uytterhoeven, Sergey Shtylyov,
	Adam Ford, Andrew Lunn, Yuusuke Ashizuka, Yoshihiro Shimoda,
	netdev, linux-renesas-soc, Chris Paterson, Biju Das,
	Prabhakar Mahadev Lad

Rename the feature bit "nc_queue" with "nc_queues" as AVB DMAC has
RX and TX NC queues.

There is no functional change.

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>
---
v2->v3:
 * Added Sergey's Rb tag.
v1->v2:
 * No change
v1:
 * New patch.
---
 drivers/net/ethernet/renesas/ravb.h      |  2 +-
 drivers/net/ethernet/renesas/ravb_main.c | 36 ++++++++++++------------
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 99d666a5fb49..5d07732ef35a 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1023,7 +1023,7 @@ struct ravb_hw_info {
 	unsigned multi_irqs:1;		/* AVB-DMAC and E-MAC has multiple irqs */
 	unsigned gptp:1;		/* AVB-DMAC has gPTP support */
 	unsigned ccc_gac:1;		/* AVB-DMAC has gPTP support active in config mode */
-	unsigned nc_queue:1;		/* AVB-DMAC has NC queue */
+	unsigned nc_queues:1;		/* AVB-DMAC has RX and TX NC queues */
 	unsigned magic_pkt:1;		/* E-MAC supports magic packet detection */
 	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
 };
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 95ce92eff7eb..21fb83f209d5 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1176,7 +1176,7 @@ static irqreturn_t ravb_interrupt(int irq, void *dev_id)
 			result = IRQ_HANDLED;
 
 		/* Network control and best effort queue RX/TX */
-		if (info->nc_queue) {
+		if (info->nc_queues) {
 			for (q = RAVB_NC; q >= RAVB_BE; q--) {
 				if (ravb_queue_interrupt(ndev, q))
 					result = IRQ_HANDLED;
@@ -1315,7 +1315,7 @@ static int ravb_poll(struct napi_struct *napi, int budget)
 
 	/* Receive error message handling */
 	priv->rx_over_errors =  priv->stats[RAVB_BE].rx_over_errors;
-	if (info->nc_queue)
+	if (info->nc_queues)
 		priv->rx_over_errors += priv->stats[RAVB_NC].rx_over_errors;
 	if (priv->rx_over_errors != ndev->stats.rx_over_errors)
 		ndev->stats.rx_over_errors = priv->rx_over_errors;
@@ -1566,7 +1566,7 @@ static void ravb_get_ethtool_stats(struct net_device *ndev,
 	int i = 0;
 	int q;
 
-	num_rx_q = info->nc_queue ? NUM_RX_QUEUE : 1;
+	num_rx_q = info->nc_queues ? NUM_RX_QUEUE : 1;
 	/* Device-specific stats */
 	for (q = RAVB_BE; q < num_rx_q; q++) {
 		struct net_device_stats *stats = &priv->stats[q];
@@ -1643,7 +1643,7 @@ static int ravb_set_ringparam(struct net_device *ndev,
 
 		/* Free all the skb's in the RX queue and the DMA buffers. */
 		ravb_ring_free(ndev, RAVB_BE);
-		if (info->nc_queue)
+		if (info->nc_queues)
 			ravb_ring_free(ndev, RAVB_NC);
 	}
 
@@ -1763,7 +1763,7 @@ static int ravb_open(struct net_device *ndev)
 	int error;
 
 	napi_enable(&priv->napi[RAVB_BE]);
-	if (info->nc_queue)
+	if (info->nc_queues)
 		napi_enable(&priv->napi[RAVB_NC]);
 
 	if (!info->multi_irqs) {
@@ -1838,7 +1838,7 @@ static int ravb_open(struct net_device *ndev)
 out_free_irq:
 	free_irq(ndev->irq, ndev);
 out_napi_off:
-	if (info->nc_queue)
+	if (info->nc_queues)
 		napi_disable(&priv->napi[RAVB_NC]);
 	napi_disable(&priv->napi[RAVB_BE]);
 	return error;
@@ -1888,7 +1888,7 @@ static void ravb_tx_timeout_work(struct work_struct *work)
 	}
 
 	ravb_ring_free(ndev, RAVB_BE);
-	if (info->nc_queue)
+	if (info->nc_queues)
 		ravb_ring_free(ndev, RAVB_NC);
 
 	/* Device init */
@@ -2088,7 +2088,7 @@ static struct net_device_stats *ravb_get_stats(struct net_device *ndev)
 	nstats->rx_length_errors = stats0->rx_length_errors;
 	nstats->rx_missed_errors = stats0->rx_missed_errors;
 	nstats->rx_over_errors = stats0->rx_over_errors;
-	if (info->nc_queue) {
+	if (info->nc_queues) {
 		stats1 = &priv->stats[RAVB_NC];
 
 		nstats->rx_packets += stats1->rx_packets;
@@ -2169,13 +2169,13 @@ static int ravb_close(struct net_device *ndev)
 	}
 	free_irq(ndev->irq, ndev);
 
-	if (info->nc_queue)
+	if (info->nc_queues)
 		napi_disable(&priv->napi[RAVB_NC]);
 	napi_disable(&priv->napi[RAVB_BE]);
 
 	/* Free all the skb's in the RX queue and the DMA buffers. */
 	ravb_ring_free(ndev, RAVB_BE);
-	if (info->nc_queue)
+	if (info->nc_queues)
 		ravb_ring_free(ndev, RAVB_NC);
 
 	return 0;
@@ -2415,7 +2415,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
 	.tx_counters = 1,
 	.multi_irqs = 1,
 	.ccc_gac = 1,
-	.nc_queue = 1,
+	.nc_queues = 1,
 	.magic_pkt = 1,
 };
 
@@ -2438,7 +2438,7 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.rx_max_buf_size = SZ_2K,
 	.aligned_tx = 1,
 	.gptp = 1,
-	.nc_queue = 1,
+	.nc_queues = 1,
 	.magic_pkt = 1,
 };
 
@@ -2618,7 +2618,7 @@ static int ravb_probe(struct platform_device *pdev)
 	priv->pdev = pdev;
 	priv->num_tx_ring[RAVB_BE] = BE_TX_RING_SIZE;
 	priv->num_rx_ring[RAVB_BE] = BE_RX_RING_SIZE;
-	if (info->nc_queue) {
+	if (info->nc_queues) {
 		priv->num_tx_ring[RAVB_NC] = NC_TX_RING_SIZE;
 		priv->num_rx_ring[RAVB_NC] = NC_RX_RING_SIZE;
 	}
@@ -2754,7 +2754,7 @@ static int ravb_probe(struct platform_device *pdev)
 	}
 
 	netif_napi_add(ndev, &priv->napi[RAVB_BE], ravb_poll, 64);
-	if (info->nc_queue)
+	if (info->nc_queues)
 		netif_napi_add(ndev, &priv->napi[RAVB_NC], ravb_poll, 64);
 
 	/* Network device register */
@@ -2773,7 +2773,7 @@ static int ravb_probe(struct platform_device *pdev)
 	return 0;
 
 out_napi_del:
-	if (info->nc_queue)
+	if (info->nc_queues)
 		netif_napi_del(&priv->napi[RAVB_NC]);
 
 	netif_napi_del(&priv->napi[RAVB_BE]);
@@ -2814,7 +2814,7 @@ static int ravb_remove(struct platform_device *pdev)
 	ravb_write(ndev, CCC_OPC_RESET, CCC);
 	pm_runtime_put_sync(&pdev->dev);
 	unregister_netdev(ndev);
-	if (info->nc_queue)
+	if (info->nc_queues)
 		netif_napi_del(&priv->napi[RAVB_NC]);
 	netif_napi_del(&priv->napi[RAVB_BE]);
 	ravb_mdio_release(priv);
@@ -2838,7 +2838,7 @@ static int ravb_wol_setup(struct net_device *ndev)
 
 	/* Only allow ECI interrupts */
 	synchronize_irq(priv->emac_irq);
-	if (info->nc_queue)
+	if (info->nc_queues)
 		napi_disable(&priv->napi[RAVB_NC]);
 	napi_disable(&priv->napi[RAVB_BE]);
 	ravb_write(ndev, ECSIPR_MPDIP, ECSIPR);
@@ -2855,7 +2855,7 @@ static int ravb_wol_restore(struct net_device *ndev)
 	const struct ravb_hw_info *info = priv->info;
 	int ret;
 
-	if (info->nc_queue)
+	if (info->nc_queues)
 		napi_enable(&priv->napi[RAVB_NC]);
 	napi_enable(&priv->napi[RAVB_BE]);
 
-- 
2.17.1


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

* [PATCH net-next v3 12/14] ravb: Document PFRI register bit
  2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
                   ` (10 preceding siblings ...)
  2021-10-12 16:36 ` [PATCH net-next v3 11/14] ravb: Rename "nc_queue" feature bit Biju Das
@ 2021-10-12 16:36 ` Biju Das
  2021-10-12 16:36 ` [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth() Biju Das
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Biju Das @ 2021-10-12 16:36 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Geert Uytterhoeven, Sergey Shtylyov,
	Adam Ford, Andrew Lunn, Yuusuke Ashizuka, Yoshihiro Shimoda,
	netdev, linux-renesas-soc, Chris Paterson, Biju Das,
	Prabhakar Mahadev Lad

Document PFRI register bit, as it is documented on R-Car Gen3 and
RZ/G2L hardware manuals.

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>
---
v2->v3:
 * Added Sergey's Rb tag
v1->v2:
 * No change
V1:
 * New patch.
---
 drivers/net/ethernet/renesas/ravb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 5d07732ef35a..69a771526776 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -828,7 +828,7 @@ enum ECSR_BIT {
 	ECSR_MPD	= 0x00000002,
 	ECSR_LCHNG	= 0x00000004,
 	ECSR_PHYI	= 0x00000008,
-	ECSR_PFRI	= 0x00000010,
+	ECSR_PFRI	= 0x00000010,	/* Documented for R-Car Gen3 and RZ/G2L */
 };
 
 /* ECSIPR */
-- 
2.17.1


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

* [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth()
  2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
                   ` (11 preceding siblings ...)
  2021-10-12 16:36 ` [PATCH net-next v3 12/14] ravb: Document PFRI register bit Biju Das
@ 2021-10-12 16:36 ` Biju Das
  2021-10-12 17:34   ` Sergey Shtylyov
  2021-10-12 16:36 ` [PATCH net-next v3 14/14] ravb: Fix typo AVB->DMAC Biju Das
                   ` (2 subsequent siblings)
  15 siblings, 1 reply; 31+ messages in thread
From: Biju Das @ 2021-10-12 16:36 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Sergei Shtylyov, Geert Uytterhoeven,
	Sergey Shtylyov, Adam Ford, Andrew Lunn, Yuusuke Ashizuka,
	Yoshihiro Shimoda, netdev, linux-renesas-soc, Chris Paterson,
	Biju Das, Prabhakar Mahadev Lad

This patch enables Receive/Transmit port of TOE and removes
the setting of promiscuous bit from EMAC configuration mode register.

This patch also update EMAC configuration mode comment from
"PAUSE prohibition" to "EMAC Mode: PAUSE prohibition; Duplex; TX;
RX; CRC Pass Through".

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v2->v3:
 * Enabled TPE/RPE of TOE, as disabling causes loopback test to fail
 * Documented CSR0 register bits
 * Removed PRM setting from EMAC configuration mode
 * Updated EMAC configuration mode.
v1->v2:
 * No change
V1:
 * New patch.
---
 drivers/net/ethernet/renesas/ravb.h      | 6 ++++++
 drivers/net/ethernet/renesas/ravb_main.c | 5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 69a771526776..08062d73df10 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,	/* RZ/G2L only */
 };
 
 
@@ -964,6 +965,11 @@ enum CXR31_BIT {
 	CXR31_SEL_LINK1	= 0x00000008,
 };
 
+enum CSR0_BIT {
+	CSR0_TPE	= 0x00000010,
+	CSR0_RPE	= 0x00000020,
+};
+
 #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 21fb83f209d5..f3f676e433d1 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -519,10 +519,10 @@ static void ravb_emac_init_gbeth(struct net_device *ndev)
 	/* Receive frame limit set register */
 	ravb_write(ndev, GBETH_RX_BUFF_MAX + ETH_FCS_LEN, RFLR);
 
-	/* PAUSE prohibition */
+	/* EMAC Mode: PAUSE prohibition; Duplex; TX; RX; CRC Pass Through */
 	ravb_write(ndev, ECMR_ZPF | ((priv->duplex > 0) ? ECMR_DM : 0) |
 			 ECMR_TE | ECMR_RE | ECMR_RCPT |
-			 ECMR_TXF | ECMR_RXF | ECMR_PRM, ECMR);
+			 ECMR_TXF | ECMR_RXF, ECMR);
 
 	ravb_set_rate_gbeth(ndev);
 
@@ -534,6 +534,7 @@ static void ravb_emac_init_gbeth(struct net_device *ndev)
 
 	/* 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);
-- 
2.17.1


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

* [PATCH net-next v3 14/14] ravb: Fix typo AVB->DMAC
  2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
                   ` (12 preceding siblings ...)
  2021-10-12 16:36 ` [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth() Biju Das
@ 2021-10-12 16:36 ` Biju Das
  2021-10-12 18:19 ` [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Jakub Kicinski
  2021-10-13 16:20 ` patchwork-bot+netdevbpf
  15 siblings, 0 replies; 31+ messages in thread
From: Biju Das @ 2021-10-12 16:36 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Biju Das, Sergey Shtylyov, Geert Uytterhoeven, Sergey Shtylyov,
	Adam Ford, Andrew Lunn, Yuusuke Ashizuka, Yoshihiro Shimoda,
	netdev, linux-renesas-soc, Chris Paterson, Biju Das,
	Prabhakar Mahadev Lad

Fix the typo AVB->DMAC in comment, as the code following the comment
is for DMAC on Gigabit Ethernet IP.

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>
---
v2->v3:
 * Added Sergey's Rb tag.
v1->v2:
 * No change
v1:
 * New patch.
---
 drivers/net/ethernet/renesas/ravb_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index f3f676e433d1..e5243cc87a19 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -588,7 +588,7 @@ static int ravb_dmac_init_gbeth(struct net_device *ndev)
 	/* Descriptor format */
 	ravb_ring_format(ndev, RAVB_BE);
 
-	/* Set AVB RX */
+	/* Set DMAC RX */
 	ravb_write(ndev, 0x60000000, RCR);
 
 	/* Set Max Frame Length (RTC) */
-- 
2.17.1


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

* Re: [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth()
  2021-10-12 16:36 ` [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth() Biju Das
@ 2021-10-12 17:34   ` Sergey Shtylyov
  2021-10-12 17:52     ` Biju Das
  0 siblings, 1 reply; 31+ messages in thread
From: Sergey Shtylyov @ 2021-10-12 17:34 UTC (permalink / raw)
  To: Biju Das, David S. Miller, Jakub Kicinski
  Cc: Sergei Shtylyov, Geert Uytterhoeven, Sergey Shtylyov, Adam Ford,
	Andrew Lunn, Yuusuke Ashizuka, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das,
	Prabhakar Mahadev Lad

On 10/12/21 7:36 PM, Biju Das wrote:

> This patch enables Receive/Transmit port of TOE and removes
> the setting of promiscuous bit from EMAC configuration mode register.
> 
> This patch also update EMAC configuration mode comment from
> "PAUSE prohibition" to "EMAC Mode: PAUSE prohibition; Duplex; TX;
> RX; CRC Pass Through".

   I'm not sure why you set ECMR.RCPT while you don't have the checksum offloaded...

> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> v2->v3:
>  * Enabled TPE/RPE of TOE, as disabling causes loopback test to fail
>  * Documented CSR0 register bits
>  * Removed PRM setting from EMAC configuration mode
>  * Updated EMAC configuration mode.
> v1->v2:
>  * No change
> V1:
>  * New patch.
> ---
>  drivers/net/ethernet/renesas/ravb.h      | 6 ++++++
>  drivers/net/ethernet/renesas/ravb_main.c | 5 +++--
>  2 files changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
> index 69a771526776..08062d73df10 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,	/* RZ/G2L only */
>  };
>  
>  
> @@ -964,6 +965,11 @@ enum CXR31_BIT {
>  	CXR31_SEL_LINK1	= 0x00000008,
>  };
>  
> +enum CSR0_BIT {
> +	CSR0_TPE	= 0x00000010,
> +	CSR0_RPE	= 0x00000020,
> +};
> +

  Is this really needed if you have ECMR.RCPT cleared?

[...]

MBR, Sergey

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

* RE: [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth()
  2021-10-12 17:34   ` Sergey Shtylyov
@ 2021-10-12 17:52     ` Biju Das
  2021-10-12 18:03       ` Sergei Shtylyov
  0 siblings, 1 reply; 31+ messages in thread
From: Biju Das @ 2021-10-12 17:52 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Sergei Shtylyov, Geert Uytterhoeven, Sergey Shtylyov, Adam Ford,
	Andrew Lunn, Yuusuke Ashizuka, Yoshihiro Shimoda, netdev,
	linux-renesas-soc, Chris Paterson, Biju Das,
	Prabhakar Mahadev Lad

Hi Sergey,

Thanks for the feedback.

> Subject: Re: [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth()
> 
> On 10/12/21 7:36 PM, Biju Das wrote:
> 
> > This patch enables Receive/Transmit port of TOE and removes the
> > setting of promiscuous bit from EMAC configuration mode register.
> >
> > This patch also update EMAC configuration mode comment from "PAUSE
> > prohibition" to "EMAC Mode: PAUSE prohibition; Duplex; TX; RX; CRC
> > Pass Through".
> 
>    I'm not sure why you set ECMR.RCPT while you don't have the checksum
> offloaded...
> 
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> > v2->v3:
> >  * Enabled TPE/RPE of TOE, as disabling causes loopback test to fail
> >  * Documented CSR0 register bits
> >  * Removed PRM setting from EMAC configuration mode
> >  * Updated EMAC configuration mode.
> > v1->v2:
> >  * No change
> > V1:
> >  * New patch.
> > ---
> >  drivers/net/ethernet/renesas/ravb.h      | 6 ++++++
> >  drivers/net/ethernet/renesas/ravb_main.c | 5 +++--
> >  2 files changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb.h
> > b/drivers/net/ethernet/renesas/ravb.h
> > index 69a771526776..08062d73df10 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,	/* RZ/G2L only */
> >  };
> >
> >
> > @@ -964,6 +965,11 @@ enum CXR31_BIT {
> >  	CXR31_SEL_LINK1	= 0x00000008,
> >  };
> >
> > +enum CSR0_BIT {
> > +	CSR0_TPE	= 0x00000010,
> > +	CSR0_RPE	= 0x00000020,
> > +};
> > +
> 
>   Is this really needed if you have ECMR.RCPT cleared?

Yes it is required. Please see the current log and log with the changes you suggested

root@smarc-rzg2l:/rzg2l-test-scripts# ./eth_t_001.sh
[   39.646891] ravb 11c20000.ethernet eth0: Link is Down
[   39.715127] ravb 11c30000.ethernet eth1: Link is Down
[   39.895680] Microchip KSZ9131 Gigabit PHY 11c20000.ethernet-ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c20000.ethernet-ffffffff:07, irq=POLL)
[   39.966370] Microchip KSZ9131 Gigabit PHY 11c30000.ethernet-ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c30000.ethernet-ffffffff:07, irq=POLL)
[   42.988573] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   42.995119] ravb 11c20000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off
[   43.052541] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
[   43.055710] ravb 11c30000.ethernet eth1: Link is Up - 1Gbps/Full - flow control off

EXIT|PASS||[422391:43:00] ||

root@smarc-rzg2l:/rzg2l-test-scripts#


with the changes you suggested
----------------------------

root@smarc-rzg2l:/rzg2l-test-scripts# ./eth_t_001.sh
[   23.300520] ravb 11c20000.ethernet eth0: Link is Down
[   23.535604] ravb 11c30000.ethernet eth1: device will be stopped after h/w processes are done.
[   23.547267] ravb 11c30000.ethernet eth1: Link is Down
[   23.802667] Microchip KSZ9131 Gigabit PHY 11c20000.ethernet-ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c20000.ethernet-ffffffff:07, irq=POLL)
[   24.031711] ravb 11c30000.ethernet eth1: failed to switch device to config mode
RTNETLINK answers: Connection timed out

EXIT|FAIL||[422391:42:32] Failed to bring up ETH1||

root@smarc-rzg2l:/rzg2l-test-scripts#



diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index f08d8f2b4d41..b34670a812fd 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -521,7 +521,7 @@ static void ravb_emac_init_gbeth(struct net_device *ndev)
 
        /* EMAC Mode: PAUSE prohibition; Duplex; TX; RX; CRC Pass Through */
        ravb_write(ndev, ECMR_ZPF | ((priv->duplex > 0) ? ECMR_DM : 0) |
-                        ECMR_TE | ECMR_RE | ECMR_RCPT |
+                        ECMR_TE | ECMR_RE | 
                         ECMR_TXF | ECMR_RXF, ECMR);
 
        ravb_set_rate_gbeth(ndev);
@@ -534,7 +534,7 @@ static void ravb_emac_init_gbeth(struct net_device *ndev)
 
        /* E-MAC status register clear */
        ravb_write(ndev, ECSR_ICD | ECSR_LCHNG | ECSR_PFRI, ECSR);
-       ravb_write(ndev, CSR0_TPE | CSR0_RPE, CSR0);
+       //ravb_write(ndev, CSR0_TPE | CSR0_RPE, CSR0);

Regards,
Biju

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

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

* Re: [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth()
  2021-10-12 17:52     ` Biju Das
@ 2021-10-12 18:03       ` Sergei Shtylyov
  2021-10-12 18:23         ` Biju Das
  0 siblings, 1 reply; 31+ messages in thread
From: Sergei Shtylyov @ 2021-10-12 18:03 UTC (permalink / raw)
  To: Biju Das, Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Geert Uytterhoeven, Sergey Shtylyov, Adam Ford, Andrew Lunn,
	Yuusuke Ashizuka, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad

On 10/12/21 8:52 PM, Biju Das wrote:

>>> This patch enables Receive/Transmit port of TOE and removes the
>>> setting of promiscuous bit from EMAC configuration mode register.
>>>
>>> This patch also update EMAC configuration mode comment from "PAUSE
>>> prohibition" to "EMAC Mode: PAUSE prohibition; Duplex; TX; RX; CRC
>>> Pass Through".
>>
>>    I'm not sure why you set ECMR.RCPT while you don't have the checksum
>> offloaded...
>>
>>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
>>> ---
>>> v2->v3:
>>>  * Enabled TPE/RPE of TOE, as disabling causes loopback test to fail
>>>  * Documented CSR0 register bits
>>>  * Removed PRM setting from EMAC configuration mode
>>>  * Updated EMAC configuration mode.
>>> v1->v2:
>>>  * No change
>>> V1:
>>>  * New patch.
>>> ---
>>>  drivers/net/ethernet/renesas/ravb.h      | 6 ++++++
>>>  drivers/net/ethernet/renesas/ravb_main.c | 5 +++--
>>>  2 files changed, 9 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/net/ethernet/renesas/ravb.h
>>> b/drivers/net/ethernet/renesas/ravb.h
>>> index 69a771526776..08062d73df10 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,	/* RZ/G2L only */
>>>  };
>>>
>>>
>>> @@ -964,6 +965,11 @@ enum CXR31_BIT {
>>>  	CXR31_SEL_LINK1	= 0x00000008,
>>>  };
>>>
>>> +enum CSR0_BIT {
>>> +	CSR0_TPE	= 0x00000010,
>>> +	CSR0_RPE	= 0x00000020,
>>> +};
>>> +
>>
>>   Is this really needed if you have ECMR.RCPT cleared?
> 
> Yes it is required. Please see the current log and log with the changes you suggested
> 
> root@smarc-rzg2l:/rzg2l-test-scripts# ./eth_t_001.sh
> [   39.646891] ravb 11c20000.ethernet eth0: Link is Down
> [   39.715127] ravb 11c30000.ethernet eth1: Link is Down
> [   39.895680] Microchip KSZ9131 Gigabit PHY 11c20000.ethernet-ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c20000.ethernet-ffffffff:07, irq=POLL)
> [   39.966370] Microchip KSZ9131 Gigabit PHY 11c30000.ethernet-ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c30000.ethernet-ffffffff:07, irq=POLL)
> [   42.988573] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
> [   42.995119] ravb 11c20000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off
> [   43.052541] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
> [   43.055710] ravb 11c30000.ethernet eth1: Link is Up - 1Gbps/Full - flow control off
> 
> EXIT|PASS||[422391:43:00] ||
> 
> root@smarc-rzg2l:/rzg2l-test-scripts#
> 
> 
> with the changes you suggested
> ----------------------------
> 
> root@smarc-rzg2l:/rzg2l-test-scripts# ./eth_t_001.sh
> [   23.300520] ravb 11c20000.ethernet eth0: Link is Down
> [   23.535604] ravb 11c30000.ethernet eth1: device will be stopped after h/w processes are done.
> [   23.547267] ravb 11c30000.ethernet eth1: Link is Down
> [   23.802667] Microchip KSZ9131 Gigabit PHY 11c20000.ethernet-ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c20000.ethernet-ffffffff:07, irq=POLL)
> [   24.031711] ravb 11c30000.ethernet eth1: failed to switch device to config mode
> RTNETLINK answers: Connection timed out
> 
> EXIT|FAIL||[422391:42:32] Failed to bring up ETH1||
> 
> root@smarc-rzg2l:/rzg2l-test-scripts#

   Hm... :-/
   What if you only clear ECMR.RCPT but continue to set CSR0?

MBR, Sergey

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

* Re: [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver
  2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
                   ` (13 preceding siblings ...)
  2021-10-12 16:36 ` [PATCH net-next v3 14/14] ravb: Fix typo AVB->DMAC Biju Das
@ 2021-10-12 18:19 ` Jakub Kicinski
  2021-10-12 18:28   ` Biju Das
  2021-10-13 16:20 ` patchwork-bot+netdevbpf
  15 siblings, 1 reply; 31+ messages in thread
From: Jakub Kicinski @ 2021-10-12 18:19 UTC (permalink / raw)
  To: Biju Das
  Cc: David S. Miller, Sergey Shtylyov, Sergei Shtylyov, Lad Prabhakar,
	Andrew Lunn, Geert Uytterhoeven, Adam Ford, Yoshihiro Shimoda,
	netdev, linux-renesas-soc, Chris Paterson, Biju Das

On Tue, 12 Oct 2021 17:35:59 +0100 Biju Das wrote:
> set_feature patch will send as separate RFC patch along with rx_checksum
> patch, as it needs further discussion related to HW checksum.

Is this part relating to the crash you observed because of TCP csum
offload?

I'm trying to understand the situation before and after this series.
What makes the crash possible to trigger?

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

* RE: [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth()
  2021-10-12 18:03       ` Sergei Shtylyov
@ 2021-10-12 18:23         ` Biju Das
  2021-10-12 18:25           ` Sergei Shtylyov
  0 siblings, 1 reply; 31+ messages in thread
From: Biju Das @ 2021-10-12 18:23 UTC (permalink / raw)
  To: Sergei Shtylyov, Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Geert Uytterhoeven, Sergey Shtylyov, Adam Ford, Andrew Lunn,
	Yuusuke Ashizuka, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad

Hi Sergey,

> Subject: Re: [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth()
> 
> On 10/12/21 8:52 PM, Biju Das wrote:
> 
> >>> This patch enables Receive/Transmit port of TOE and removes the
> >>> setting of promiscuous bit from EMAC configuration mode register.
> >>>
> >>> This patch also update EMAC configuration mode comment from "PAUSE
> >>> prohibition" to "EMAC Mode: PAUSE prohibition; Duplex; TX; RX; CRC
> >>> Pass Through".
> >>
> >>    I'm not sure why you set ECMR.RCPT while you don't have the
> >> checksum offloaded...
> >>
> >>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> >>> ---
> >>> v2->v3:
> >>>  * Enabled TPE/RPE of TOE, as disabling causes loopback test to fail
> >>>  * Documented CSR0 register bits
> >>>  * Removed PRM setting from EMAC configuration mode
> >>>  * Updated EMAC configuration mode.
> >>> v1->v2:
> >>>  * No change
> >>> V1:
> >>>  * New patch.
> >>> ---
> >>>  drivers/net/ethernet/renesas/ravb.h      | 6 ++++++
> >>>  drivers/net/ethernet/renesas/ravb_main.c | 5 +++--
> >>>  2 files changed, 9 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/drivers/net/ethernet/renesas/ravb.h
> >>> b/drivers/net/ethernet/renesas/ravb.h
> >>> index 69a771526776..08062d73df10 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,	/* RZ/G2L only */
> >>>  };
> >>>
> >>>
> >>> @@ -964,6 +965,11 @@ enum CXR31_BIT {
> >>>  	CXR31_SEL_LINK1	= 0x00000008,
> >>>  };
> >>>
> >>> +enum CSR0_BIT {
> >>> +	CSR0_TPE	= 0x00000010,
> >>> +	CSR0_RPE	= 0x00000020,
> >>> +};
> >>> +
> >>
> >>   Is this really needed if you have ECMR.RCPT cleared?
> >
> > Yes it is required. Please see the current log and log with the
> > changes you suggested
> >
> > root@smarc-rzg2l:/rzg2l-test-scripts# ./eth_t_001.sh
> > [   39.646891] ravb 11c20000.ethernet eth0: Link is Down
> > [   39.715127] ravb 11c30000.ethernet eth1: Link is Down
> > [   39.895680] Microchip KSZ9131 Gigabit PHY 11c20000.ethernet-
> ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c20000.ethernet-
> ffffffff:07, irq=POLL)
> > [   39.966370] Microchip KSZ9131 Gigabit PHY 11c30000.ethernet-
> ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c30000.ethernet-
> ffffffff:07, irq=POLL)
> > [   42.988573] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
> > [   42.995119] ravb 11c20000.ethernet eth0: Link is Up - 1Gbps/Full -
> flow control off
> > [   43.052541] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
> > [   43.055710] ravb 11c30000.ethernet eth1: Link is Up - 1Gbps/Full -
> flow control off
> >
> > EXIT|PASS||[422391:43:00] ||
> >
> > root@smarc-rzg2l:/rzg2l-test-scripts#
> >
> >
> > with the changes you suggested
> > ----------------------------
> >
> > root@smarc-rzg2l:/rzg2l-test-scripts# ./eth_t_001.sh
> > [   23.300520] ravb 11c20000.ethernet eth0: Link is Down
> > [   23.535604] ravb 11c30000.ethernet eth1: device will be stopped after
> h/w processes are done.
> > [   23.547267] ravb 11c30000.ethernet eth1: Link is Down
> > [   23.802667] Microchip KSZ9131 Gigabit PHY 11c20000.ethernet-
> ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c20000.ethernet-
> ffffffff:07, irq=POLL)
> > [   24.031711] ravb 11c30000.ethernet eth1: failed to switch device to
> config mode
> > RTNETLINK answers: Connection timed out
> >
> > EXIT|FAIL||[422391:42:32] Failed to bring up ETH1||
> >
> > root@smarc-rzg2l:/rzg2l-test-scripts#
> 
>    Hm... :-/
>    What if you only clear ECMR.RCPT but continue to set CSR0?

We already seen, RCPT=0, RCSC=1 with similar Hardware checksum function like R-Car,
System crashes.

Regards,
Biju

> 
> MBR, Sergey

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

* Re: [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth()
  2021-10-12 18:23         ` Biju Das
@ 2021-10-12 18:25           ` Sergei Shtylyov
  2021-10-12 18:55             ` Biju Das
  0 siblings, 1 reply; 31+ messages in thread
From: Sergei Shtylyov @ 2021-10-12 18:25 UTC (permalink / raw)
  To: Biju Das, Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Geert Uytterhoeven, Sergey Shtylyov, Adam Ford, Andrew Lunn,
	Yuusuke Ashizuka, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad

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

>>>>> This patch enables Receive/Transmit port of TOE and removes the
>>>>> setting of promiscuous bit from EMAC configuration mode register.
>>>>>
>>>>> This patch also update EMAC configuration mode comment from "PAUSE
>>>>> prohibition" to "EMAC Mode: PAUSE prohibition; Duplex; TX; RX; CRC
>>>>> Pass Through".
>>>>
>>>>    I'm not sure why you set ECMR.RCPT while you don't have the
>>>> checksum offloaded...
>>>>
>>>>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
>>>>> ---
>>>>> v2->v3:
>>>>>  * Enabled TPE/RPE of TOE, as disabling causes loopback test to fail
>>>>>  * Documented CSR0 register bits
>>>>>  * Removed PRM setting from EMAC configuration mode
>>>>>  * Updated EMAC configuration mode.
>>>>> v1->v2:
>>>>>  * No change
>>>>> V1:
>>>>>  * New patch.
>>>>> ---
>>>>>  drivers/net/ethernet/renesas/ravb.h      | 6 ++++++
>>>>>  drivers/net/ethernet/renesas/ravb_main.c | 5 +++--
>>>>>  2 files changed, 9 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/drivers/net/ethernet/renesas/ravb.h
>>>>> b/drivers/net/ethernet/renesas/ravb.h
>>>>> index 69a771526776..08062d73df10 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,	/* RZ/G2L only */
>>>>>  };
>>>>>
>>>>>
>>>>> @@ -964,6 +965,11 @@ enum CXR31_BIT {
>>>>>  	CXR31_SEL_LINK1	= 0x00000008,
>>>>>  };
>>>>>
>>>>> +enum CSR0_BIT {
>>>>> +	CSR0_TPE	= 0x00000010,
>>>>> +	CSR0_RPE	= 0x00000020,
>>>>> +};
>>>>> +
>>>>
>>>>   Is this really needed if you have ECMR.RCPT cleared?
>>>
>>> Yes it is required. Please see the current log and log with the
>>> changes you suggested
>>>
>>> root@smarc-rzg2l:/rzg2l-test-scripts# ./eth_t_001.sh
>>> [   39.646891] ravb 11c20000.ethernet eth0: Link is Down
>>> [   39.715127] ravb 11c30000.ethernet eth1: Link is Down
>>> [   39.895680] Microchip KSZ9131 Gigabit PHY 11c20000.ethernet-
>> ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c20000.ethernet-
>> ffffffff:07, irq=POLL)
>>> [   39.966370] Microchip KSZ9131 Gigabit PHY 11c30000.ethernet-
>> ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c30000.ethernet-
>> ffffffff:07, irq=POLL)
>>> [   42.988573] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
>>> [   42.995119] ravb 11c20000.ethernet eth0: Link is Up - 1Gbps/Full -
>> flow control off
>>> [   43.052541] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
>>> [   43.055710] ravb 11c30000.ethernet eth1: Link is Up - 1Gbps/Full -
>> flow control off
>>>
>>> EXIT|PASS||[422391:43:00] ||
>>>
>>> root@smarc-rzg2l:/rzg2l-test-scripts#
>>>
>>>
>>> with the changes you suggested
>>> ----------------------------
>>>
>>> root@smarc-rzg2l:/rzg2l-test-scripts# ./eth_t_001.sh
>>> [   23.300520] ravb 11c20000.ethernet eth0: Link is Down
>>> [   23.535604] ravb 11c30000.ethernet eth1: device will be stopped after
>> h/w processes are done.
>>> [   23.547267] ravb 11c30000.ethernet eth1: Link is Down
>>> [   23.802667] Microchip KSZ9131 Gigabit PHY 11c20000.ethernet-
>> ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c20000.ethernet-
>> ffffffff:07, irq=POLL)
>>> [   24.031711] ravb 11c30000.ethernet eth1: failed to switch device to
>> config mode
>>> RTNETLINK answers: Connection timed out
>>>
>>> EXIT|FAIL||[422391:42:32] Failed to bring up ETH1||
>>>
>>> root@smarc-rzg2l:/rzg2l-test-scripts#
>>
>>    Hm... :-/
>>    What if you only clear ECMR.RCPT but continue to set CSR0?
> 
> We already seen, RCPT=0, RCSC=1 with similar Hardware checksum function like R-Car,
> System crashes.

   I didn't tell you to set ECMR.RCSC this time. :-)

> Regards,
> Biju

MBR, Sergey

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

* RE: [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver
  2021-10-12 18:19 ` [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Jakub Kicinski
@ 2021-10-12 18:28   ` Biju Das
       [not found]     ` <20211012114125.0a9d71ae@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
  0 siblings, 1 reply; 31+ messages in thread
From: Biju Das @ 2021-10-12 18:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: David S. Miller, Sergey Shtylyov, Sergei Shtylyov,
	Prabhakar Mahadev Lad, Andrew Lunn, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das

Hi Jakub Kicinski,

> -----Original Message-----
> Subject: Re: [PATCH net-next v3 00/14] Add functional support for Gigabit
> Ethernet driver
> 
> On Tue, 12 Oct 2021 17:35:59 +0100 Biju Das wrote:
> > set_feature patch will send as separate RFC patch along with
> > rx_checksum patch, as it needs further discussion related to HW
> checksum.
> 
> Is this part relating to the crash you observed because of TCP csum
> offload?

Yes, you are correct. Sergey, suggested use R-Car RX-HW checksum with RCSC/RCPT and
But the TOE gives either 0x0 or 0xffff as csum output and feeding this value to skb->csum
lead to kernel crash.

Regards,
Biju

> 
> I'm trying to understand the situation before and after this series.
> What makes the crash possible to trigger?

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

* RE: [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver
       [not found]     ` <20211012114125.0a9d71ae@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
@ 2021-10-12 18:53       ` Biju Das
  2021-10-12 20:17         ` Jakub Kicinski
  0 siblings, 1 reply; 31+ messages in thread
From: Biju Das @ 2021-10-12 18:53 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: David S. Miller, Sergey Shtylyov, Sergei Shtylyov,
	Prabhakar Mahadev Lad, Andrew Lunn, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc@vger.kernel.org>,
	Chris Paterson <Chris.Paterson2@renesas.com>,
	Biju Das <biju.das@bp.renesas.com


Hi Jakub Kicinski,

Thanks for the feedback.

> Subject: Re: [PATCH net-next v3 00/14] Add functional support for Gigabit
> Ethernet driver
> 
> On Tue, 12 Oct 2021 18:28:07 +0000 Biju Das wrote:
> > > On Tue, 12 Oct 2021 17:35:59 +0100 Biju Das wrote:
> > > > set_feature patch will send as separate RFC patch along with
> > > > rx_checksum patch, as it needs further discussion related to HW
> > > checksum.
> > >
> > > Is this part relating to the crash you observed because of TCP csum
> > > offload?
> >
> > Yes, you are correct. Sergey, suggested use R-Car RX-HW checksum with
> > RCSC/RCPT and But the TOE gives either 0x0 or 0xffff as csum output
> > and feeding this value to skb->csum lead to kernel crash.
> 
> That's quite concerning. Do you have any of the
> 
> /proc/sys/kernel/panic_on_io_nmi
> /proc/sys/kernel/panic_on_oops
> /proc/sys/kernel/panic_on_rcu_stall
> /proc/sys/kernel/panic_on_unrecovered_nmi
> /proc/sys/kernel/panic_on_warn
> 
> knobs set? I'm guessing we hit do_netdev_rx_csum_fault() when the checksum
> is incorrect, but I'm surprised that causes a panic.
> 

I tested this last week, if I remember correctly It was not panic, rather do_netdev_rx_csum_fault. I will recheck and will send you the stack trace next time. 

> 
> BTW are you seeing 0 / ffff with good or bad checksums? If the device does
> a checksum over the IP pseudo-header + TCP only - 0 and ffff would be
> correct for a packet with has a valid checksum. But you can't set it to
> skb->csum and use CSUM_COMPLETE, you'd need to do something like:
> 
> if (dev_csum == 0 || dev_csum == 0xffff)
> 	skb->ip_summed = CHECKSUM_UNNECESSARY;

Yes, it computes IPv4 header checksum and TCP/UDP/ICMP checksum.

It will set to 0x0 for both csums, if there is no error.

For IPV6, ipv4 header checksum is always set to 0xffff and 0 for TCP/UDP/ICMP checksum.

Ok I will use this logic on next RFC.

Regards,
Biju

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

* RE: [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth()
  2021-10-12 18:25           ` Sergei Shtylyov
@ 2021-10-12 18:55             ` Biju Das
  2021-10-13  6:14               ` Biju Das
  2021-10-13 15:46               ` Sergey Shtylyov
  0 siblings, 2 replies; 31+ messages in thread
From: Biju Das @ 2021-10-12 18:55 UTC (permalink / raw)
  To: Sergei Shtylyov, Sergey Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Geert Uytterhoeven, Sergey Shtylyov, Adam Ford, Andrew Lunn,
	Yuusuke Ashizuka, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad

Hi Sergey,

Thanks for the feedback.

> Subject: Re: [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth()
> 
> On 10/12/21 9:23 PM, Biju Das wrote:
> 
> >>>>> This patch enables Receive/Transmit port of TOE and removes the
> >>>>> setting of promiscuous bit from EMAC configuration mode register.
> >>>>>
> >>>>> This patch also update EMAC configuration mode comment from "PAUSE
> >>>>> prohibition" to "EMAC Mode: PAUSE prohibition; Duplex; TX; RX; CRC
> >>>>> Pass Through".
> >>>>
> >>>>    I'm not sure why you set ECMR.RCPT while you don't have the
> >>>> checksum offloaded...
> >>>>
> >>>>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> >>>>> ---
> >>>>> v2->v3:
> >>>>>  * Enabled TPE/RPE of TOE, as disabling causes loopback test to
> >>>>> fail
> >>>>>  * Documented CSR0 register bits
> >>>>>  * Removed PRM setting from EMAC configuration mode
> >>>>>  * Updated EMAC configuration mode.
> >>>>> v1->v2:
> >>>>>  * No change
> >>>>> V1:
> >>>>>  * New patch.
> >>>>> ---
> >>>>>  drivers/net/ethernet/renesas/ravb.h      | 6 ++++++
> >>>>>  drivers/net/ethernet/renesas/ravb_main.c | 5 +++--
> >>>>>  2 files changed, 9 insertions(+), 2 deletions(-)
> >>>>>
> >>>>> diff --git a/drivers/net/ethernet/renesas/ravb.h
> >>>>> b/drivers/net/ethernet/renesas/ravb.h
> >>>>> index 69a771526776..08062d73df10 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,	/* RZ/G2L only */
> >>>>>  };
> >>>>>
> >>>>>
> >>>>> @@ -964,6 +965,11 @@ enum CXR31_BIT {
> >>>>>  	CXR31_SEL_LINK1	= 0x00000008,
> >>>>>  };
> >>>>>
> >>>>> +enum CSR0_BIT {
> >>>>> +	CSR0_TPE	= 0x00000010,
> >>>>> +	CSR0_RPE	= 0x00000020,
> >>>>> +};
> >>>>> +
> >>>>
> >>>>   Is this really needed if you have ECMR.RCPT cleared?
> >>>
> >>> Yes it is required. Please see the current log and log with the
> >>> changes you suggested
> >>>
> >>> root@smarc-rzg2l:/rzg2l-test-scripts# ./eth_t_001.sh
> >>> [   39.646891] ravb 11c20000.ethernet eth0: Link is Down
> >>> [   39.715127] ravb 11c30000.ethernet eth1: Link is Down
> >>> [   39.895680] Microchip KSZ9131 Gigabit PHY 11c20000.ethernet-
> >> ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c20000.ethernet-
> >> ffffffff:07, irq=POLL)
> >>> [   39.966370] Microchip KSZ9131 Gigabit PHY 11c30000.ethernet-
> >> ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c30000.ethernet-
> >> ffffffff:07, irq=POLL)
> >>> [   42.988573] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
> >>> [   42.995119] ravb 11c20000.ethernet eth0: Link is Up - 1Gbps/Full -
> >> flow control off
> >>> [   43.052541] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
> >>> [   43.055710] ravb 11c30000.ethernet eth1: Link is Up - 1Gbps/Full -
> >> flow control off
> >>>
> >>> EXIT|PASS||[422391:43:00] ||
> >>>
> >>> root@smarc-rzg2l:/rzg2l-test-scripts#
> >>>
> >>>
> >>> with the changes you suggested
> >>> ----------------------------
> >>>
> >>> root@smarc-rzg2l:/rzg2l-test-scripts# ./eth_t_001.sh
> >>> [   23.300520] ravb 11c20000.ethernet eth0: Link is Down
> >>> [   23.535604] ravb 11c30000.ethernet eth1: device will be stopped
> after
> >> h/w processes are done.
> >>> [   23.547267] ravb 11c30000.ethernet eth1: Link is Down
> >>> [   23.802667] Microchip KSZ9131 Gigabit PHY 11c20000.ethernet-
> >> ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c20000.ethernet-
> >> ffffffff:07, irq=POLL)
> >>> [   24.031711] ravb 11c30000.ethernet eth1: failed to switch device to
> >> config mode
> >>> RTNETLINK answers: Connection timed out
> >>>
> >>> EXIT|FAIL||[422391:42:32] Failed to bring up ETH1||
> >>>
> >>> root@smarc-rzg2l:/rzg2l-test-scripts#
> >>
> >>    Hm... :-/
> >>    What if you only clear ECMR.RCPT but continue to set CSR0?
> >
> > We already seen, RCPT=0, RCSC=1 with similar Hardware checksum
> > function like R-Car, System crashes.
> 
>    I didn't tell you to set ECMR.RCSC this time. :-)

Theoretically, It should work as it is. As we are not doing any hardware checksum,

H/W is just passing RX CSUM to TOE without any software intervention.

It is clearly mentioned in data sheet, it is HW controlled.

25 RCPT B’0 R/W Reception CRC Pass Through
1: CRC of received frame is transferred to TOE.
RCSC (auto calculation of checksum of received frame data part) function is disabled
at this time.
0: CRC of received frame is not transferred to TOE.

Regards,
Biju


> 
> > Regards,
> > Biju
> 
> MBR, Sergey

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

* Re: [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver
  2021-10-12 18:53       ` Biju Das
@ 2021-10-12 20:17         ` Jakub Kicinski
  2021-10-13  6:41           ` Biju Das
  0 siblings, 1 reply; 31+ messages in thread
From: Jakub Kicinski @ 2021-10-12 20:17 UTC (permalink / raw)
  To: Biju Das
  Cc: David S. Miller, Sergey Shtylyov, Sergei Shtylyov,
	Prabhakar Mahadev Lad, Andrew Lunn, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc@vger.kernel.org>,
	Chris Paterson  <Chris.Paterson2@renesas.com>,
	Biju Das <biju.das@bp.renesas.com

On Tue, 12 Oct 2021 18:53:50 +0000 Biju Das wrote:
> > > Yes, you are correct. Sergey, suggested use R-Car RX-HW checksum with
> > > RCSC/RCPT and But the TOE gives either 0x0 or 0xffff as csum output
> > > and feeding this value to skb->csum lead to kernel crash.  
> > 
> > That's quite concerning. Do you have any of the
> > 
> > /proc/sys/kernel/panic_on_io_nmi
> > /proc/sys/kernel/panic_on_oops
> > /proc/sys/kernel/panic_on_rcu_stall
> > /proc/sys/kernel/panic_on_unrecovered_nmi
> > /proc/sys/kernel/panic_on_warn
> > 
> > knobs set? I'm guessing we hit do_netdev_rx_csum_fault() when the checksum
> > is incorrect, but I'm surprised that causes a panic.
> 
> I tested this last week, if I remember correctly It was not panic,
> rather do_netdev_rx_csum_fault. I will recheck and will send you the
> stack trace next time. 

Ah, when you say crash you mean a stack trace appears. The machine does
not crash? That's fine, we don't need to see the trace.

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

* RE: [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth()
  2021-10-12 18:55             ` Biju Das
@ 2021-10-13  6:14               ` Biju Das
  2021-10-13 15:46               ` Sergey Shtylyov
  1 sibling, 0 replies; 31+ messages in thread
From: Biju Das @ 2021-10-13  6:14 UTC (permalink / raw)
  To: Biju Das, Sergei Shtylyov, Sergey Shtylyov, David S. Miller,
	Jakub Kicinski
  Cc: Geert Uytterhoeven, Sergey Shtylyov, Adam Ford, Andrew Lunn,
	Yuusuke Ashizuka, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad

Hi Sergey,

> Subject: RE: [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth()
> 
> Hi Sergey,
> 
> Thanks for the feedback.
> 
> > Subject: Re: [PATCH net-next v3 13/14] ravb: Update
> > ravb_emac_init_gbeth()
> >
> > On 10/12/21 9:23 PM, Biju Das wrote:
> >
> > >>>>> This patch enables Receive/Transmit port of TOE and removes the
> > >>>>> setting of promiscuous bit from EMAC configuration mode register.
> > >>>>>
> > >>>>> This patch also update EMAC configuration mode comment from
> > >>>>> "PAUSE prohibition" to "EMAC Mode: PAUSE prohibition; Duplex;
> > >>>>> TX; RX; CRC Pass Through".
> > >>>>
> > >>>>    I'm not sure why you set ECMR.RCPT while you don't have the
> > >>>> checksum offloaded...
> > >>>>
> > >>>>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > >>>>> ---
> > >>>>> v2->v3:
> > >>>>>  * Enabled TPE/RPE of TOE, as disabling causes loopback test to
> > >>>>> fail
> > >>>>>  * Documented CSR0 register bits
> > >>>>>  * Removed PRM setting from EMAC configuration mode
> > >>>>>  * Updated EMAC configuration mode.
> > >>>>> v1->v2:
> > >>>>>  * No change
> > >>>>> V1:
> > >>>>>  * New patch.
> > >>>>> ---
> > >>>>>  drivers/net/ethernet/renesas/ravb.h      | 6 ++++++
> > >>>>>  drivers/net/ethernet/renesas/ravb_main.c | 5 +++--
> > >>>>>  2 files changed, 9 insertions(+), 2 deletions(-)
> > >>>>>
> > >>>>> diff --git a/drivers/net/ethernet/renesas/ravb.h
> > >>>>> b/drivers/net/ethernet/renesas/ravb.h
> > >>>>> index 69a771526776..08062d73df10 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,	/* RZ/G2L only */
> > >>>>>  };
> > >>>>>
> > >>>>>
> > >>>>> @@ -964,6 +965,11 @@ enum CXR31_BIT {
> > >>>>>  	CXR31_SEL_LINK1	= 0x00000008,
> > >>>>>  };
> > >>>>>
> > >>>>> +enum CSR0_BIT {
> > >>>>> +	CSR0_TPE	= 0x00000010,
> > >>>>> +	CSR0_RPE	= 0x00000020,
> > >>>>> +};
> > >>>>> +
> > >>>>
> > >>>>   Is this really needed if you have ECMR.RCPT cleared?
> > >>>
> > >>> Yes it is required. Please see the current log and log with the
> > >>> changes you suggested
> > >>>
> > >>> root@smarc-rzg2l:/rzg2l-test-scripts# ./eth_t_001.sh
> > >>> [   39.646891] ravb 11c20000.ethernet eth0: Link is Down
> > >>> [   39.715127] ravb 11c30000.ethernet eth1: Link is Down
> > >>> [   39.895680] Microchip KSZ9131 Gigabit PHY 11c20000.ethernet-
> > >> ffffffff:07: attached PHY driver
> > >> (mii_bus:phy_addr=11c20000.ethernet-
> > >> ffffffff:07, irq=POLL)
> > >>> [   39.966370] Microchip KSZ9131 Gigabit PHY 11c30000.ethernet-
> > >> ffffffff:07: attached PHY driver
> > >> (mii_bus:phy_addr=11c30000.ethernet-
> > >> ffffffff:07, irq=POLL)
> > >>> [   42.988573] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes
> ready
> > >>> [   42.995119] ravb 11c20000.ethernet eth0: Link is Up - 1Gbps/Full
> -
> > >> flow control off
> > >>> [   43.052541] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes
> ready
> > >>> [   43.055710] ravb 11c30000.ethernet eth1: Link is Up - 1Gbps/Full
> -
> > >> flow control off
> > >>>
> > >>> EXIT|PASS||[422391:43:00] ||
> > >>>
> > >>> root@smarc-rzg2l:/rzg2l-test-scripts#
> > >>>
> > >>>
> > >>> with the changes you suggested
> > >>> ----------------------------
> > >>>
> > >>> root@smarc-rzg2l:/rzg2l-test-scripts# ./eth_t_001.sh
> > >>> [   23.300520] ravb 11c20000.ethernet eth0: Link is Down
> > >>> [   23.535604] ravb 11c30000.ethernet eth1: device will be stopped
> > after
> > >> h/w processes are done.
> > >>> [   23.547267] ravb 11c30000.ethernet eth1: Link is Down
> > >>> [   23.802667] Microchip KSZ9131 Gigabit PHY 11c20000.ethernet-
> > >> ffffffff:07: attached PHY driver
> > >> (mii_bus:phy_addr=11c20000.ethernet-
> > >> ffffffff:07, irq=POLL)
> > >>> [   24.031711] ravb 11c30000.ethernet eth1: failed to switch device
> to
> > >> config mode
> > >>> RTNETLINK answers: Connection timed out
> > >>>
> > >>> EXIT|FAIL||[422391:42:32] Failed to bring up ETH1||
> > >>>
> > >>> root@smarc-rzg2l:/rzg2l-test-scripts#
> > >>
> > >>    Hm... :-/
> > >>    What if you only clear ECMR.RCPT but continue to set CSR0?
> > >
> > > We already seen, RCPT=0, RCSC=1 with similar Hardware checksum
> > > function like R-Car, System crashes.
> >
> >    I didn't tell you to set ECMR.RCSC this time. :-)
> 
> Theoretically, It should work as it is. As we are not doing any hardware
> checksum,
> 
> H/W is just passing RX CSUM to TOE without any software intervention.
> 
> It is clearly mentioned in data sheet, it is HW controlled.
> 
> 25 RCPT B’0 R/W Reception CRC Pass Through
> 1: CRC of received frame is transferred to TOE.
> RCSC (auto calculation of checksum of received frame data part) function
> is disabled at this time.
> 0: CRC of received frame is not transferred to TOE.
> 

The board doesn't boot with NFS, if I take out RCPT. So it is needed

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

* RE: [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver
  2021-10-12 20:17         ` Jakub Kicinski
@ 2021-10-13  6:41           ` Biju Das
  2021-10-13  6:50             ` Biju Das
  0 siblings, 1 reply; 31+ messages in thread
From: Biju Das @ 2021-10-13  6:41 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: David S. Miller, Sergey Shtylyov, Sergei Shtylyov,
	Prabhakar Mahadev Lad, Andrew Lunn, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc@vger.kernel.org>,
	Chris Paterson <Chris.Paterson2@renesas.com>,
	Biju Das <biju.das@bp.renesas.com

Hi Jakub Kicinski,

Thanks for the feedback.

> Subject: Re: [PATCH net-next v3 00/14] Add functional support for Gigabit
> Ethernet driver
> 
> On Tue, 12 Oct 2021 18:53:50 +0000 Biju Das wrote:
> > > > Yes, you are correct. Sergey, suggested use R-Car RX-HW checksum
> > > > with RCSC/RCPT and But the TOE gives either 0x0 or 0xffff as csum
> > > > output and feeding this value to skb->csum lead to kernel crash.
> > >
> > > That's quite concerning. Do you have any of the
> > >
> > > /proc/sys/kernel/panic_on_io_nmi
> > > /proc/sys/kernel/panic_on_oops
> > > /proc/sys/kernel/panic_on_rcu_stall
> > > /proc/sys/kernel/panic_on_unrecovered_nmi
> > > /proc/sys/kernel/panic_on_warn
> > >
> > > knobs set? I'm guessing we hit do_netdev_rx_csum_fault() when the
> > > checksum is incorrect, but I'm surprised that causes a panic.
> >
> > I tested this last week, if I remember correctly It was not panic,
> > rather do_netdev_rx_csum_fault. I will recheck and will send you the
> > stack trace next time.
> 
> Ah, when you say crash you mean a stack trace appears. The machine does
> not crash? That's fine, we don't need to see the trace.

I have rechecked today. It does crash, if you pass bad checksum to skb->csum. Please find the logs.

root@smarc-rzg2l:~# ethtool -K eth0 rx on
Actual changes:
rx-checksum: on
[   34.391956] eth0: hw csum failure
[   34.396044] skb len=168 headroom=142 headlen=168 tailroom=15754
[   34.396044] mac=(128,14) net=(142,20) trans=162
[   34.396044] shinfo(txflags=0 nr_frags=0 gso(size=0 type=0 segs=0))
[   34.396044] csum(0x0 ip_summed=2 complete_sw=0 valid=0 level=0)
[   34.396044] hash(0x0 sw=0 l4=0) proto=0x0800 pkttype=0 iif=0
[   34.425196] dev name=eth0 feat=0x0x0000010000004000
[   34.430231] skb headroom: 00000000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[   34.438064] skb headroom: 00000010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[   34.445863] skb headroom: 00000020: ff ff ff ff ff ff ff ff ff ff ff fe ff ff ff ff
[   34.453660] skb headroom: 00000030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[   34.461453] skb headroom: 00000040: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[   34.469246] skb headroom: 00000050: ff ff ff ff ff fe ff ff ff ff ef ff ff ff ff ff
[   34.477038] skb headroom: 00000060: ff ff ff ff ff ff ff ff fd fe ff ff ff ff ff ff
[   34.484831] skb headroom: 00000070: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff f7
[   34.492629] skb headroom: 00000080: 00 11 22 33 44 55 08 00 27 a0 90 eb 08 00
[   34.499895] skb linear:   00000000: 45 00 00 a8 54 06 40 00 40 06 50 f6 c0 a8 0a 01
[   34.507692] skb linear:   00000010: c0 a8 0a 02 08 01 03 0c 1d aa 76 e1 a3 4b 1c d8
[   34.515488] skb linear:   00000020: 80 18 21 55 72 75 00 00 01 01 08 0a da da 94 96
[   34.523283] skb linear:   00000030: b5 fb f1 40 80 00 00 70 d9 4a 86 c0 00 00 00 01
[   34.531078] skb linear:   00000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[   34.538873] skb linear:   00000050: 00 00 00 00 00 00 00 05 00 00 01 ff 00 00 00 01
[   34.546668] skb linear:   00000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11
[   34.554462] skb linear:   00000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[   34.562260] skb linear:   00000080: 58 9d 6c 79 80 e3 86 f2 00 00 00 00 00 9a 8d 38
[   34.570055] skb linear:   00000090: 61 65 87 ee 22 8c 2f b9 61 4a 17 fb 35 09 00 98
[   34.577850] skb linear:   000000a0: 61 4a 17 fb 35 09 00 98
[   34.583534] skb tailroom: 00000000: 00 00 00 00 21 07 00 b0 63 70 47 f9 42 5f 47 f9
[   34.591329] skb tailroom: 00000010: 21 f8 47 f9 80 74 47 f9 de 60 fc 97 a0 06 00 f9

[   42.262329] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.15.0-rc4-arm64-renesas-01223-g75a50e114cb6-dirty #416
[   42.272370] Hardware name: Renesas SMARC EVK based on r9a07g044l2 (DT)
[   42.278979] Call trace:
[   42.281460]  dump_backtrace+0x0/0x188
[   42.285186]  show_stack+0x14/0x20
[   42.288550]  dump_stack_lvl+0x88/0xb0
[   42.292267]  dump_stack+0x14/0x2c
[   42.295629]  do_netdev_rx_csum_fault+0x44/0x50
[   42.300134]  __skb_gro_checksum_complete+0xb0/0xb8
[   42.304994]  tcp4_gro_receive+0xbc/0x198
[   42.308974]  inet_gro_receive+0x300/0x410
[   42.313039]  dev_gro_receive+0x308/0x898
[   42.317018]  napi_gro_receive+0x88/0x370
[   42.320996]  ravb_rx_gbeth+0x36c/0x568
[   42.324801]  ravb_poll+0xd0/0x278
[   42.328163]  __napi_poll+0x38/0x2e0
[   42.331702]  net_rx_action+0xf4/0x248
[   42.335416]  _stext+0x150/0x5d8
[   42.338604]  irq_exit+0x198/0x1b8
[   42.341970]  handle_domain_irq+0x60/0x88
[   42.345950]  gic_handle_irq+0x50/0x110
[   42.349755]  call_on_irq_stack+0x28/0x3c
[   42.353733]  do_interrupt_handler+0x4c/0x58
[   42.357974]  el1_interrupt+0x2c/0x108
[   42.361688]  el1h_64_irq_handler+0x14/0x20
[   42.365841]  el1h_64_irq+0x74/0x78
[   42.369291]  arch_cpu_idle+0x14/0x20
[   42.372918]  default_idle_call+0x78/0x330
[   42.376984]  do_idle+0x22c/0x278
[   42.380261]  cpu_startup_entry+0x20/0x68
[   42.384239]  rest_init+0x180/0x280
[   42.387689]  arch_call_rest_init+0xc/0x14
[   42.391759]  start_kernel+0x62c/0x664
[   42.395472]  __primary_switched+0xa0/0xa8


Regards,
Biju

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

* RE: [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver
  2021-10-13  6:41           ` Biju Das
@ 2021-10-13  6:50             ` Biju Das
  0 siblings, 0 replies; 31+ messages in thread
From: Biju Das @ 2021-10-13  6:50 UTC (permalink / raw)
  To: Biju Das, Jakub Kicinski
  Cc: David S. Miller, Sergey Shtylyov, Sergei Shtylyov,
	Prabhakar Mahadev Lad, Andrew Lunn, Geert Uytterhoeven,
	Adam Ford, Yoshihiro Shimoda, netdev,
	linux-renesas-soc@vger.kernel.org>,
	Chris Paterson <Chris.Paterson2@renesas.com>,
	Biju Das <biju.das@bp.renesas.com


Sorry for the spam, it is not crash, it is just printing out the stack trace.
I have tested with rx hw checksum turned on by default as well. It boots with NFS, but with that noisy messages, if we pass bad checksum to skb->csum.

Regards,
Biju

> Subject: RE: [PATCH net-next v3 00/14] Add functional support for Gigabit
> Ethernet driver
> 
> Hi Jakub Kicinski,
> 
> Thanks for the feedback.
> 
> > Subject: Re: [PATCH net-next v3 00/14] Add functional support for
> > Gigabit Ethernet driver
> >
> > On Tue, 12 Oct 2021 18:53:50 +0000 Biju Das wrote:
> > > > > Yes, you are correct. Sergey, suggested use R-Car RX-HW checksum
> > > > > with RCSC/RCPT and But the TOE gives either 0x0 or 0xffff as
> > > > > csum output and feeding this value to skb->csum lead to kernel
> crash.
> > > >
> > > > That's quite concerning. Do you have any of the
> > > >
> > > > /proc/sys/kernel/panic_on_io_nmi
> > > > /proc/sys/kernel/panic_on_oops
> > > > /proc/sys/kernel/panic_on_rcu_stall
> > > > /proc/sys/kernel/panic_on_unrecovered_nmi
> > > > /proc/sys/kernel/panic_on_warn
> > > >
> > > > knobs set? I'm guessing we hit do_netdev_rx_csum_fault() when the
> > > > checksum is incorrect, but I'm surprised that causes a panic.
> > >
> > > I tested this last week, if I remember correctly It was not panic,
> > > rather do_netdev_rx_csum_fault. I will recheck and will send you the
> > > stack trace next time.
> >
> > Ah, when you say crash you mean a stack trace appears. The machine
> > does not crash? That's fine, we don't need to see the trace.
> 
> I have rechecked today. It does crash, if you pass bad checksum to skb-
> >csum. Please find the logs.
> 
> root@smarc-rzg2l:~# ethtool -K eth0 rx on Actual changes:
> rx-checksum: on
> [   34.391956] eth0: hw csum failure
> [   34.396044] skb len=168 headroom=142 headlen=168 tailroom=15754
> [   34.396044] mac=(128,14) net=(142,20) trans=162
> [   34.396044] shinfo(txflags=0 nr_frags=0 gso(size=0 type=0 segs=0))
> [   34.396044] csum(0x0 ip_summed=2 complete_sw=0 valid=0 level=0)
> [   34.396044] hash(0x0 sw=0 l4=0) proto=0x0800 pkttype=0 iif=0
> [   34.425196] dev name=eth0 feat=0x0x0000010000004000
> [   34.430231] skb headroom: 00000000: ff ff ff ff ff ff ff ff ff ff ff ff
> ff ff ff ff
> [   34.438064] skb headroom: 00000010: ff ff ff ff ff ff ff ff ff ff ff ff
> ff ff ff ff
> [   34.445863] skb headroom: 00000020: ff ff ff ff ff ff ff ff ff ff ff fe
> ff ff ff ff
> [   34.453660] skb headroom: 00000030: ff ff ff ff ff ff ff ff ff ff ff ff
> ff ff ff ff
> [   34.461453] skb headroom: 00000040: ff ff ff ff ff ff ff ff ff ff ff ff
> ff ff ff ff
> [   34.469246] skb headroom: 00000050: ff ff ff ff ff fe ff ff ff ff ef ff
> ff ff ff ff
> [   34.477038] skb headroom: 00000060: ff ff ff ff ff ff ff ff fd fe ff ff
> ff ff ff ff
> [   34.484831] skb headroom: 00000070: ff ff ff ff ff ff ff ff ff ff ff ff
> ff ff ff f7
> [   34.492629] skb headroom: 00000080: 00 11 22 33 44 55 08 00 27 a0 90 eb
> 08 00
> [   34.499895] skb linear:   00000000: 45 00 00 a8 54 06 40 00 40 06 50 f6
> c0 a8 0a 01
> [   34.507692] skb linear:   00000010: c0 a8 0a 02 08 01 03 0c 1d aa 76 e1
> a3 4b 1c d8
> [   34.515488] skb linear:   00000020: 80 18 21 55 72 75 00 00 01 01 08 0a
> da da 94 96
> [   34.523283] skb linear:   00000030: b5 fb f1 40 80 00 00 70 d9 4a 86 c0
> 00 00 00 01
> [   34.531078] skb linear:   00000040: 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00
> [   34.538873] skb linear:   00000050: 00 00 00 00 00 00 00 05 00 00 01 ff
> 00 00 00 01
> [   34.546668] skb linear:   00000060: 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 11
> [   34.554462] skb linear:   00000070: 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00
> [   34.562260] skb linear:   00000080: 58 9d 6c 79 80 e3 86 f2 00 00 00 00
> 00 9a 8d 38
> [   34.570055] skb linear:   00000090: 61 65 87 ee 22 8c 2f b9 61 4a 17 fb
> 35 09 00 98
> [   34.577850] skb linear:   000000a0: 61 4a 17 fb 35 09 00 98
> [   34.583534] skb tailroom: 00000000: 00 00 00 00 21 07 00 b0 63 70 47 f9
> 42 5f 47 f9
> [   34.591329] skb tailroom: 00000010: 21 f8 47 f9 80 74 47 f9 de 60 fc 97
> a0 06 00 f9
> 
> [   42.262329] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.15.0-rc4-arm64-
> renesas-01223-g75a50e114cb6-dirty #416
> [   42.272370] Hardware name: Renesas SMARC EVK based on r9a07g044l2 (DT)
> [   42.278979] Call trace:
> [   42.281460]  dump_backtrace+0x0/0x188
> [   42.285186]  show_stack+0x14/0x20
> [   42.288550]  dump_stack_lvl+0x88/0xb0
> [   42.292267]  dump_stack+0x14/0x2c
> [   42.295629]  do_netdev_rx_csum_fault+0x44/0x50
> [   42.300134]  __skb_gro_checksum_complete+0xb0/0xb8
> [   42.304994]  tcp4_gro_receive+0xbc/0x198
> [   42.308974]  inet_gro_receive+0x300/0x410
> [   42.313039]  dev_gro_receive+0x308/0x898
> [   42.317018]  napi_gro_receive+0x88/0x370
> [   42.320996]  ravb_rx_gbeth+0x36c/0x568
> [   42.324801]  ravb_poll+0xd0/0x278
> [   42.328163]  __napi_poll+0x38/0x2e0
> [   42.331702]  net_rx_action+0xf4/0x248
> [   42.335416]  _stext+0x150/0x5d8
> [   42.338604]  irq_exit+0x198/0x1b8
> [   42.341970]  handle_domain_irq+0x60/0x88
> [   42.345950]  gic_handle_irq+0x50/0x110
> [   42.349755]  call_on_irq_stack+0x28/0x3c
> [   42.353733]  do_interrupt_handler+0x4c/0x58
> [   42.357974]  el1_interrupt+0x2c/0x108
> [   42.361688]  el1h_64_irq_handler+0x14/0x20
> [   42.365841]  el1h_64_irq+0x74/0x78
> [   42.369291]  arch_cpu_idle+0x14/0x20
> [   42.372918]  default_idle_call+0x78/0x330
> [   42.376984]  do_idle+0x22c/0x278
> [   42.380261]  cpu_startup_entry+0x20/0x68
> [   42.384239]  rest_init+0x180/0x280
> [   42.387689]  arch_call_rest_init+0xc/0x14
> [   42.391759]  start_kernel+0x62c/0x664
> [   42.395472]  __primary_switched+0xa0/0xa8
> 
> 
> Regards,
> Biju

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

* Re: [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth()
  2021-10-12 18:55             ` Biju Das
  2021-10-13  6:14               ` Biju Das
@ 2021-10-13 15:46               ` Sergey Shtylyov
       [not found]                 ` <20211013085704.4a059444@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
  1 sibling, 1 reply; 31+ messages in thread
From: Sergey Shtylyov @ 2021-10-13 15:46 UTC (permalink / raw)
  To: Biju Das, Sergei Shtylyov, David S. Miller, Jakub Kicinski
  Cc: Geert Uytterhoeven, Sergey Shtylyov, Adam Ford, Andrew Lunn,
	Yuusuke Ashizuka, Yoshihiro Shimoda, netdev, linux-renesas-soc,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad

On 10/12/21 9:55 PM, Biju Das wrote:

[...]
>>>>>>> This patch enables Receive/Transmit port of TOE and removes the
>>>>>>> setting of promiscuous bit from EMAC configuration mode register.
>>>>>>>
>>>>>>> This patch also update EMAC configuration mode comment from "PAUSE
>>>>>>> prohibition" to "EMAC Mode: PAUSE prohibition; Duplex; TX; RX; CRC
>>>>>>> Pass Through".
>>>>>>
>>>>>>    I'm not sure why you set ECMR.RCPT while you don't have the
>>>>>> checksum offloaded...
>>>>>>
>>>>>>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
>>>>>>> ---
>>>>>>> v2->v3:
>>>>>>>  * Enabled TPE/RPE of TOE, as disabling causes loopback test to
>>>>>>> fail
>>>>>>>  * Documented CSR0 register bits
>>>>>>>  * Removed PRM setting from EMAC configuration mode
>>>>>>>  * Updated EMAC configuration mode.
>>>>>>> v1->v2:
>>>>>>>  * No change
>>>>>>> V1:
>>>>>>>  * New patch.
>>>>>>> ---
>>>>>>>  drivers/net/ethernet/renesas/ravb.h      | 6 ++++++
>>>>>>>  drivers/net/ethernet/renesas/ravb_main.c | 5 +++--
>>>>>>>  2 files changed, 9 insertions(+), 2 deletions(-)
>>>>>>>
>>>>>>> diff --git a/drivers/net/ethernet/renesas/ravb.h
>>>>>>> b/drivers/net/ethernet/renesas/ravb.h
>>>>>>> index 69a771526776..08062d73df10 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,	/* RZ/G2L only */
>>>>>>>  };
>>>>>>>
>>>>>>>
>>>>>>> @@ -964,6 +965,11 @@ enum CXR31_BIT {
>>>>>>>  	CXR31_SEL_LINK1	= 0x00000008,
>>>>>>>  };
>>>>>>>
>>>>>>> +enum CSR0_BIT {
>>>>>>> +	CSR0_TPE	= 0x00000010,
>>>>>>> +	CSR0_RPE	= 0x00000020,
>>>>>>> +};
>>>>>>> +
>>>>>>
>>>>>>   Is this really needed if you have ECMR.RCPT cleared?
>>>>>
>>>>> Yes it is required. Please see the current log and log with the
>>>>> changes you suggested
>>>>>
>>>>> root@smarc-rzg2l:/rzg2l-test-scripts# ./eth_t_001.sh
>>>>> [   39.646891] ravb 11c20000.ethernet eth0: Link is Down
>>>>> [   39.715127] ravb 11c30000.ethernet eth1: Link is Down
>>>>> [   39.895680] Microchip KSZ9131 Gigabit PHY 11c20000.ethernet-
>>>> ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c20000.ethernet-
>>>> ffffffff:07, irq=POLL)
>>>>> [   39.966370] Microchip KSZ9131 Gigabit PHY 11c30000.ethernet-
>>>> ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c30000.ethernet-
>>>> ffffffff:07, irq=POLL)
>>>>> [   42.988573] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
>>>>> [   42.995119] ravb 11c20000.ethernet eth0: Link is Up - 1Gbps/Full -
>>>> flow control off
>>>>> [   43.052541] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
>>>>> [   43.055710] ravb 11c30000.ethernet eth1: Link is Up - 1Gbps/Full -
>>>> flow control off
>>>>>
>>>>> EXIT|PASS||[422391:43:00] ||
>>>>>
>>>>> root@smarc-rzg2l:/rzg2l-test-scripts#
>>>>>
>>>>>
>>>>> with the changes you suggested
>>>>> ----------------------------
>>>>>
>>>>> root@smarc-rzg2l:/rzg2l-test-scripts# ./eth_t_001.sh
>>>>> [   23.300520] ravb 11c20000.ethernet eth0: Link is Down
>>>>> [   23.535604] ravb 11c30000.ethernet eth1: device will be stopped
>> after
>>>> h/w processes are done.
>>>>> [   23.547267] ravb 11c30000.ethernet eth1: Link is Down
>>>>> [   23.802667] Microchip KSZ9131 Gigabit PHY 11c20000.ethernet-
>>>> ffffffff:07: attached PHY driver (mii_bus:phy_addr=11c20000.ethernet-
>>>> ffffffff:07, irq=POLL)
>>>>> [   24.031711] ravb 11c30000.ethernet eth1: failed to switch device to
>>>> config mode
>>>>> RTNETLINK answers: Connection timed out
>>>>>
>>>>> EXIT|FAIL||[422391:42:32] Failed to bring up ETH1||
>>>>>
>>>>> root@smarc-rzg2l:/rzg2l-test-scripts#
>>>>
>>>>    Hm... :-/
>>>>    What if you only clear ECMR.RCPT but continue to set CSR0?
>>>
>>> We already seen, RCPT=0, RCSC=1 with similar Hardware checksum
>>> function like R-Car, System crashes.
>>
>>    I didn't tell you to set ECMR.RCSC this time. :-)
> 
> Theoretically, It should work as it is. As we are not doing any hardware checksum,
> 
> H/W is just passing RX CSUM to TOE without any software intervention.
> 
> It is clearly mentioned in data sheet, it is HW controlled.
> 
> 25 RCPT B’0 R/W Reception CRC Pass Through
> 1: CRC of received frame is transferred to TOE.
> RCSC (auto calculation of checksum of received frame data part) function is disabled
> at this time.
> 0: CRC of received frame is not transferred to TOE.

   Ah, I think it's the (usual) checksum-vs-CRC mixup. I don't know why TOE needs CRC tho
but it's 4 bytes at the end of a frame, not having much toi do with the 2-byte checksums...

> Regards,
> Biju

[...]

MBR, Sergey

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

* Re: [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth()
       [not found]                 ` <20211013085704.4a059444@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
@ 2021-10-13 16:03                   ` Sergey Shtylyov
  0 siblings, 0 replies; 31+ messages in thread
From: Sergey Shtylyov @ 2021-10-13 16:03 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Biju Das, Sergei Shtylyov, David S. Miller, Geert Uytterhoeven,
	Sergey Shtylyov, Adam Ford, Andrew Lunn, Yuusuke Ashizuka,
	Yoshihiro Shimoda, netdev, linux-renesas-soc@vger.kernel.org",
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad

On 10/13/21 6:57 PM, Jakub Kicinski wrote:

>>    Ah, I think it's the (usual) checksum-vs-CRC mixup. I don't know
>> why TOE needs CRC tho but it's 4 bytes at the end of a frame, not
>> having much toi do with the 2-byte checksums...

   s/toi/to/.

> Meaning v3 is good as is? I'm trying understand if I should apply it ;)

   Yes, I'm giving up (-:

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

MBR, Sergey

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

* Re: [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver
  2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
                   ` (14 preceding siblings ...)
  2021-10-12 18:19 ` [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Jakub Kicinski
@ 2021-10-13 16:20 ` patchwork-bot+netdevbpf
  15 siblings, 0 replies; 31+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-10-13 16:20 UTC (permalink / raw)
  To: Biju Das
  Cc: davem, kuba, s.shtylyov, sergei.shtylyov,
	prabhakar.mahadev-lad.rj, andrew, geert+renesas, aford173,
	yoshihiro.shimoda.uh, netdev, linux-renesas-soc, Chris.Paterson2,
	biju.das

Hello:

This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 12 Oct 2021 17:35:59 +0100 you 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).
> 
> [...]

Here is the summary with links:
  - [net-next,v3,01/14] ravb: Use ALIGN macro for max_rx_len
    https://git.kernel.org/netdev/net-next/c/23144a915684
  - [net-next,v3,02/14] ravb: Add rx_max_buf_size to struct ravb_hw_info
    https://git.kernel.org/netdev/net-next/c/2e95e08ac009
  - [net-next,v3,03/14] ravb: Fillup ravb_alloc_rx_desc_gbeth() stub
    https://git.kernel.org/netdev/net-next/c/3d4e37df882b
  - [net-next,v3,04/14] ravb: Fillup ravb_rx_ring_free_gbeth() stub
    https://git.kernel.org/netdev/net-next/c/2458b8edb887
  - [net-next,v3,05/14] ravb: Fillup ravb_rx_ring_format_gbeth() stub
    https://git.kernel.org/netdev/net-next/c/16a6e245a9f3
  - [net-next,v3,06/14] ravb: Fillup ravb_rx_gbeth() stub
    https://git.kernel.org/netdev/net-next/c/1c59eb678cbd
  - [net-next,v3,07/14] ravb: Add carrier_counters to struct ravb_hw_info
    https://git.kernel.org/netdev/net-next/c/b6a4ee6e74de
  - [net-next,v3,08/14] ravb: Add support to retrieve stats for GbEthernet
    https://git.kernel.org/netdev/net-next/c/0ee65bc14ff2
  - [net-next,v3,09/14] ravb: Rename "tsrq" variable
    https://git.kernel.org/netdev/net-next/c/4ea3167bad27
  - [net-next,v3,10/14] ravb: Optimize ravb_emac_init_gbeth function
    https://git.kernel.org/netdev/net-next/c/030634f37db9
  - [net-next,v3,11/14] ravb: Rename "nc_queue" feature bit
    https://git.kernel.org/netdev/net-next/c/1091da579d7c
  - [net-next,v3,12/14] ravb: Document PFRI register bit
    https://git.kernel.org/netdev/net-next/c/95e99b10482d
  - [net-next,v3,13/14] ravb: Update ravb_emac_init_gbeth()
    https://git.kernel.org/netdev/net-next/c/3d6b24a2ada3
  - [net-next,v3,14/14] ravb: Fix typo AVB->DMAC
    https://git.kernel.org/netdev/net-next/c/940409264647

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-10-13 16:20 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 01/14] ravb: Use ALIGN macro for max_rx_len Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 02/14] ravb: Add rx_max_buf_size to struct ravb_hw_info Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 03/14] ravb: Fillup ravb_alloc_rx_desc_gbeth() stub Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 04/14] ravb: Fillup ravb_rx_ring_free_gbeth() stub Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 05/14] ravb: Fillup ravb_rx_ring_format_gbeth() stub Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 06/14] ravb: Fillup ravb_rx_gbeth() stub Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 07/14] ravb: Add carrier_counters to struct ravb_hw_info Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 08/14] ravb: Add support to retrieve stats for GbEthernet Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 09/14] ravb: Rename "tsrq" variable Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 10/14] ravb: Optimize ravb_emac_init_gbeth function Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 11/14] ravb: Rename "nc_queue" feature bit Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 12/14] ravb: Document PFRI register bit Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth() Biju Das
2021-10-12 17:34   ` Sergey Shtylyov
2021-10-12 17:52     ` Biju Das
2021-10-12 18:03       ` Sergei Shtylyov
2021-10-12 18:23         ` Biju Das
2021-10-12 18:25           ` Sergei Shtylyov
2021-10-12 18:55             ` Biju Das
2021-10-13  6:14               ` Biju Das
2021-10-13 15:46               ` Sergey Shtylyov
     [not found]                 ` <20211013085704.4a059444@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
2021-10-13 16:03                   ` Sergey Shtylyov
2021-10-12 16:36 ` [PATCH net-next v3 14/14] ravb: Fix typo AVB->DMAC Biju Das
2021-10-12 18:19 ` [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Jakub Kicinski
2021-10-12 18:28   ` Biju Das
     [not found]     ` <20211012114125.0a9d71ae@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
2021-10-12 18:53       ` Biju Das
2021-10-12 20:17         ` Jakub Kicinski
2021-10-13  6:41           ` Biju Das
2021-10-13  6:50             ` Biju Das
2021-10-13 16:20 ` patchwork-bot+netdevbpf

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.