Date   

[PATCH 5.10.y-cip 26/61] ravb: Factorise ravb_rx function

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit d5d95c11365bc880669bbc52786b176cf60dcd92 upstream.

R-Car uses an extended descriptor in RX whereas, RZ/G2L uses
normal descriptor in RX. Factorise the ravb_rx function to
support the later SoC.

Signed-off-by: Biju Das <biju.das.jz@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb.h | 1 +
drivers/net/ethernet/renesas/ravb_main.c | 14 ++++++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index e06ae4e0f758..6a3d377f1d24 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -984,6 +984,7 @@ struct ravb_hw_info {
void (*rx_ring_free)(struct net_device *ndev, int q);
void (*rx_ring_format)(struct net_device *ndev, int q);
void *(*alloc_rx_desc)(struct net_device *ndev, int q);
+ bool (*receive)(struct net_device *ndev, int *quota, int q);
const char (*gstrings_stats)[ETH_GSTRING_LEN];
size_t gstrings_size;
netdev_features_t net_hw_features;
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 172fb0f6b648..1c2294789d2d 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -560,8 +560,7 @@ static void ravb_rx_csum(struct sk_buff *skb)
skb_trim(skb, skb->len - sizeof(__sum16));
}

-/* Packet receive function for Ethernet AVB */
-static bool ravb_rx(struct net_device *ndev, int *quota, int q)
+static bool ravb_rcar_rx(struct net_device *ndev, int *quota, int q)
{
struct ravb_private *priv = netdev_priv(ndev);
const struct ravb_hw_info *info = priv->info;
@@ -675,6 +674,15 @@ static bool ravb_rx(struct net_device *ndev, int *quota, int q)
return boguscnt <= 0;
}

+/* Packet receive function for Ethernet AVB */
+static bool ravb_rx(struct net_device *ndev, int *quota, int q)
+{
+ struct ravb_private *priv = netdev_priv(ndev);
+ const struct ravb_hw_info *info = priv->info;
+
+ return info->receive(ndev, quota, q);
+}
+
static void ravb_rcv_snd_disable(struct net_device *ndev)
{
/* Disable TX and RX */
@@ -1967,6 +1975,7 @@ 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,
+ .receive = ravb_rcar_rx,
.gstrings_stats = ravb_gstrings_stats,
.gstrings_size = sizeof(ravb_gstrings_stats),
.net_hw_features = NETIF_F_RXCSUM,
@@ -1983,6 +1992,7 @@ 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,
+ .receive = ravb_rcar_rx,
.gstrings_stats = ravb_gstrings_stats,
.gstrings_size = sizeof(ravb_gstrings_stats),
.net_hw_features = NETIF_F_RXCSUM,
--
2.17.1


[PATCH 5.10.y-cip 25/61] ravb: Factorise ravb_ring_init function

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit 7870a41848abf8ae634e2de54effbbf32d2a472d upstream.

The ravb_ring_init function uses an extended descriptor in RX for
R-Car and normal descriptor for RZ/G2L. Add a helper function
for RX ring buffer allocation to support later SoC.

Signed-off-by: Biju Das <biju.das.jz@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb.h | 1 +
drivers/net/ethernet/renesas/ravb_main.c | 21 ++++++++++++++++-----
2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index f9e54be7fd67..e06ae4e0f758 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -983,6 +983,7 @@ struct ravb_ptp {
struct ravb_hw_info {
void (*rx_ring_free)(struct net_device *ndev, int q);
void (*rx_ring_format)(struct net_device *ndev, int q);
+ void *(*alloc_rx_desc)(struct net_device *ndev, int q);
const char (*gstrings_stats)[ETH_GSTRING_LEN];
size_t gstrings_size;
netdev_features_t net_hw_features;
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 5722b0235cef..172fb0f6b648 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -353,6 +353,19 @@ static void ravb_ring_format(struct net_device *ndev, int q)
desc->dptr = cpu_to_le32((u32)priv->tx_desc_dma[q]);
}

+static void *ravb_alloc_rx_desc(struct net_device *ndev, int q)
+{
+ struct ravb_private *priv = netdev_priv(ndev);
+ unsigned int ring_size;
+
+ ring_size = sizeof(struct ravb_ex_rx_desc) * (priv->num_rx_ring[q] + 1);
+
+ priv->rx_ring[q] = dma_alloc_coherent(ndev->dev.parent, ring_size,
+ &priv->rx_desc_dma[q],
+ GFP_KERNEL);
+ return priv->rx_ring[q];
+}
+
/* Init skb and descriptor buffer for Ethernet AVB */
static int ravb_ring_init(struct net_device *ndev, int q)
{
@@ -388,11 +401,7 @@ static int ravb_ring_init(struct net_device *ndev, int q)
}

/* Allocate all RX descriptors. */
- ring_size = sizeof(struct ravb_ex_rx_desc) * (priv->num_rx_ring[q] + 1);
- priv->rx_ring[q] = dma_alloc_coherent(ndev->dev.parent, ring_size,
- &priv->rx_desc_dma[q],
- GFP_KERNEL);
- if (!priv->rx_ring[q])
+ if (!info->alloc_rx_desc(ndev, q))
goto error;

priv->dirty_rx[q] = 0;
@@ -1957,6 +1966,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,
.gstrings_stats = ravb_gstrings_stats,
.gstrings_size = sizeof(ravb_gstrings_stats),
.net_hw_features = NETIF_F_RXCSUM,
@@ -1972,6 +1982,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,
.gstrings_stats = ravb_gstrings_stats,
.gstrings_size = sizeof(ravb_gstrings_stats),
.net_hw_features = NETIF_F_RXCSUM,
--
2.17.1


[PATCH 5.10.y-cip 24/61] ravb: Factorise ravb_ring_format function

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit 1ae22c19e75cfbd36b24b43f9d8649b1988a4dff upstream.

The ravb_ring_format function uses an extended descriptor in RX
for R-Car compared to the normal descriptor for RZ/G2L. Factorise
RX ring buffer buildup to extend the support for later SoC.

Signed-off-by: Biju Das <biju.das.jz@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb.h | 1 +
drivers/net/ethernet/renesas/ravb_main.c | 35 ++++++++++++++++--------
2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 0ba4d220fb9b..f9e54be7fd67 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -982,6 +982,7 @@ struct ravb_ptp {

struct ravb_hw_info {
void (*rx_ring_free)(struct net_device *ndev, int q);
+ void (*rx_ring_format)(struct net_device *ndev, int q);
const char (*gstrings_stats)[ETH_GSTRING_LEN];
size_t gstrings_size;
netdev_features_t net_hw_features;
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index c7259e103da2..5722b0235cef 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -280,25 +280,14 @@ static void ravb_ring_free(struct net_device *ndev, int q)
priv->tx_skb[q] = NULL;
}

-/* Format skb and descriptor buffer for Ethernet AVB */
-static void ravb_ring_format(struct net_device *ndev, int q)
+static void ravb_rx_ring_format(struct net_device *ndev, int q)
{
struct ravb_private *priv = netdev_priv(ndev);
- unsigned int num_tx_desc = priv->num_tx_desc;
struct ravb_ex_rx_desc *rx_desc;
- struct ravb_tx_desc *tx_desc;
- struct ravb_desc *desc;
unsigned int rx_ring_size = sizeof(*rx_desc) * priv->num_rx_ring[q];
- unsigned int tx_ring_size = sizeof(*tx_desc) * priv->num_tx_ring[q] *
- num_tx_desc;
dma_addr_t dma_addr;
unsigned int i;

- priv->cur_rx[q] = 0;
- priv->cur_tx[q] = 0;
- priv->dirty_rx[q] = 0;
- priv->dirty_tx[q] = 0;
-
memset(priv->rx_ring[q], 0, rx_ring_size);
/* Build RX ring buffer */
for (i = 0; i < priv->num_rx_ring[q]; i++) {
@@ -319,6 +308,26 @@ static void ravb_ring_format(struct net_device *ndev, int q)
rx_desc = &priv->rx_ring[q][i];
rx_desc->dptr = cpu_to_le32((u32)priv->rx_desc_dma[q]);
rx_desc->die_dt = DT_LINKFIX; /* type */
+}
+
+/* Format skb and descriptor buffer for Ethernet AVB */
+static void ravb_ring_format(struct net_device *ndev, int q)
+{
+ struct ravb_private *priv = netdev_priv(ndev);
+ const struct ravb_hw_info *info = priv->info;
+ unsigned int num_tx_desc = priv->num_tx_desc;
+ struct ravb_tx_desc *tx_desc;
+ struct ravb_desc *desc;
+ unsigned int tx_ring_size = sizeof(*tx_desc) * priv->num_tx_ring[q] *
+ num_tx_desc;
+ unsigned int i;
+
+ priv->cur_rx[q] = 0;
+ priv->cur_tx[q] = 0;
+ priv->dirty_rx[q] = 0;
+ priv->dirty_tx[q] = 0;
+
+ info->rx_ring_format(ndev, q);

memset(priv->tx_ring[q], 0, tx_ring_size);
/* Build TX ring buffer */
@@ -1947,6 +1956,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,
.gstrings_stats = ravb_gstrings_stats,
.gstrings_size = sizeof(ravb_gstrings_stats),
.net_hw_features = NETIF_F_RXCSUM,
@@ -1961,6 +1971,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,
.gstrings_stats = ravb_gstrings_stats,
.gstrings_size = sizeof(ravb_gstrings_stats),
.net_hw_features = NETIF_F_RXCSUM,
--
2.17.1


[PATCH 5.10.y-cip 23/61] ravb: Factorise ravb_ring_free function

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit bf46b7578404f6fbde0bc2e1ea60fe0fd6f207a8 upstream.

R-Car uses extended descriptor in RX, whereas RZ/G2L uses normal
descriptor. Factorise ravb_ring_free function so that it can
support later SoC.

Signed-off-by: Biju Das <biju.das.jz@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb.h | 1 +
drivers/net/ethernet/renesas/ravb_main.c | 47 +++++++++++++++---------
2 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index a0220b48c122..0ba4d220fb9b 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -981,6 +981,7 @@ struct ravb_ptp {
};

struct ravb_hw_info {
+ void (*rx_ring_free)(struct net_device *ndev, int q);
const char (*gstrings_stats)[ETH_GSTRING_LEN];
size_t gstrings_size;
netdev_features_t net_hw_features;
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index de691dd91cf4..c7259e103da2 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -214,31 +214,42 @@ static int ravb_tx_free(struct net_device *ndev, int q, bool free_txed_only)
return free_num;
}

+static void ravb_rx_ring_free(struct net_device *ndev, int q)
+{
+ struct ravb_private *priv = netdev_priv(ndev);
+ unsigned int ring_size;
+ unsigned int i;
+
+ if (!priv->rx_ring[q])
+ return;
+
+ for (i = 0; i < priv->num_rx_ring[q]; i++) {
+ struct ravb_ex_rx_desc *desc = &priv->rx_ring[q][i];
+
+ if (!dma_mapping_error(ndev->dev.parent,
+ le32_to_cpu(desc->dptr)))
+ dma_unmap_single(ndev->dev.parent,
+ le32_to_cpu(desc->dptr),
+ RX_BUF_SZ,
+ DMA_FROM_DEVICE);
+ }
+ ring_size = sizeof(struct ravb_ex_rx_desc) *
+ (priv->num_rx_ring[q] + 1);
+ dma_free_coherent(ndev->dev.parent, ring_size, priv->rx_ring[q],
+ priv->rx_desc_dma[q]);
+ priv->rx_ring[q] = NULL;
+}
+
/* Free skb's and DMA buffers for Ethernet AVB */
static void ravb_ring_free(struct net_device *ndev, int q)
{
struct ravb_private *priv = netdev_priv(ndev);
+ const struct ravb_hw_info *info = priv->info;
unsigned int num_tx_desc = priv->num_tx_desc;
unsigned int ring_size;
unsigned int i;

- if (priv->rx_ring[q]) {
- for (i = 0; i < priv->num_rx_ring[q]; i++) {
- struct ravb_ex_rx_desc *desc = &priv->rx_ring[q][i];
-
- if (!dma_mapping_error(ndev->dev.parent,
- le32_to_cpu(desc->dptr)))
- dma_unmap_single(ndev->dev.parent,
- le32_to_cpu(desc->dptr),
- RX_BUF_SZ,
- DMA_FROM_DEVICE);
- }
- ring_size = sizeof(struct ravb_ex_rx_desc) *
- (priv->num_rx_ring[q] + 1);
- dma_free_coherent(ndev->dev.parent, ring_size, priv->rx_ring[q],
- priv->rx_desc_dma[q]);
- priv->rx_ring[q] = NULL;
- }
+ info->rx_ring_free(ndev, q);

if (priv->tx_ring[q]) {
ravb_tx_free(ndev, q, false);
@@ -1935,6 +1946,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,
.gstrings_stats = ravb_gstrings_stats,
.gstrings_size = sizeof(ravb_gstrings_stats),
.net_hw_features = NETIF_F_RXCSUM,
@@ -1948,6 +1960,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,
.gstrings_stats = ravb_gstrings_stats,
.gstrings_size = sizeof(ravb_gstrings_stats),
.net_hw_features = NETIF_F_RXCSUM,
--
2.17.1


[PATCH 5.10.y-cip 22/61] ravb: Add ptp_cfg_active to struct ravb_hw_info

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit a69a3d094de38007ce54e4e1411b5769ed66a426 upstream.

There are some H/W differences for the gPTP feature between
R-Car Gen3, R-Car Gen2, and RZ/G2L as below.

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

Add a ptp_cfg_active hw feature bit to struct ravb_hw_info for
supporting gPTP active in config mode for R-Car Gen3.
This patch also removes enum ravb_chip_id, chip_id from both
struct ravb_hw_info and struct ravb_private, as it is unused.

Signed-off-by: Biju Das <biju.das.jz@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb.h | 8 +-------
drivers/net/ethernet/renesas/ravb_main.c | 12 +++++-------
2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 9d818c26bba5..a0220b48c122 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -980,17 +980,11 @@ struct ravb_ptp {
struct ravb_ptp_perout perout[N_PER_OUT];
};

-enum ravb_chip_id {
- RCAR_GEN2,
- RCAR_GEN3,
-};
-
struct ravb_hw_info {
const char (*gstrings_stats)[ETH_GSTRING_LEN];
size_t gstrings_size;
netdev_features_t net_hw_features;
netdev_features_t net_features;
- enum ravb_chip_id chip_id;
int stats_len;
size_t max_rx_len;
unsigned aligned_tx: 1;
@@ -1000,6 +994,7 @@ struct ravb_hw_info {
unsigned tx_counters:1; /* E-MAC has TX counters */
unsigned multi_irqs:1; /* AVB-DMAC and E-MAC has multiple irqs */
unsigned no_ptp_cfg_active:1; /* AVB-DMAC does not support gPTP active in config mode */
+ unsigned ptp_cfg_active:1; /* AVB-DMAC has gPTP support active in config mode */
};

struct ravb_private {
@@ -1043,7 +1038,6 @@ struct ravb_private {
int msg_enable;
int speed;
int emac_irq;
- enum ravb_chip_id chip_id;
int rx_irqs[NUM_RX_QUEUE];
int tx_irqs[NUM_TX_QUEUE];

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index bdeb6a757559..de691dd91cf4 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1939,12 +1939,12 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
.gstrings_size = sizeof(ravb_gstrings_stats),
.net_hw_features = NETIF_F_RXCSUM,
.net_features = NETIF_F_RXCSUM,
- .chip_id = RCAR_GEN3,
.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
.internal_delay = 1,
.tx_counters = 1,
.multi_irqs = 1,
+ .ptp_cfg_active = 1,
};

static const struct ravb_hw_info ravb_gen2_hw_info = {
@@ -1952,7 +1952,6 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
.gstrings_size = sizeof(ravb_gstrings_stats),
.net_hw_features = NETIF_F_RXCSUM,
.net_features = NETIF_F_RXCSUM,
- .chip_id = RCAR_GEN2,
.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
.aligned_tx = 1,
@@ -2150,8 +2149,6 @@ static int ravb_probe(struct platform_device *pdev)
}
}

- priv->chip_id = info->chip_id;
-
priv->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(priv->clk)) {
error = PTR_ERR(priv->clk);
@@ -2214,7 +2211,7 @@ static int ravb_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&priv->ts_skb_list);

/* Initialise PTP Clock driver */
- if (info->chip_id != RCAR_GEN2)
+ if (info->ptp_cfg_active)
ravb_ptp_init(ndev, pdev);

/* Debug message level */
@@ -2262,7 +2259,7 @@ static int ravb_probe(struct platform_device *pdev)
priv->desc_bat_dma);

/* Stop PTP Clock driver */
- if (info->chip_id != RCAR_GEN2)
+ if (info->ptp_cfg_active)
ravb_ptp_stop(ndev);
out_disable_refclk:
clk_disable_unprepare(priv->refclk);
@@ -2278,9 +2275,10 @@ static int ravb_remove(struct platform_device *pdev)
{
struct net_device *ndev = platform_get_drvdata(pdev);
struct ravb_private *priv = netdev_priv(ndev);
+ const struct ravb_hw_info *info = priv->info;

/* Stop PTP Clock driver */
- if (priv->chip_id != RCAR_GEN2)
+ if (info->ptp_cfg_active)
ravb_ptp_stop(ndev);

clk_disable_unprepare(priv->refclk);
--
2.17.1


[PATCH 5.10.y-cip 21/61] ravb: Add no_ptp_cfg_active to struct ravb_hw_info

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit 8f27219a6191679333e703daf8bb66e5a1241aed upstream.

There are some H/W differences for the gPTP feature between
R-Car Gen3, R-Car Gen2, and RZ/G2L as below.

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

Add a no_ptp_cfg_active hw feature bit to struct ravb_hw_info for
handling gPTP for R-Car Gen2.

Signed-off-by: Biju Das <biju.das.jz@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb.h | 1 +
drivers/net/ethernet/renesas/ravb_main.c | 20 ++++++++++++--------
2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index a74bd63ba3be..9d818c26bba5 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -999,6 +999,7 @@ struct ravb_hw_info {
unsigned internal_delay:1; /* AVB-DMAC has internal delays */
unsigned tx_counters:1; /* E-MAC has TX counters */
unsigned multi_irqs:1; /* AVB-DMAC and E-MAC has multiple irqs */
+ unsigned no_ptp_cfg_active:1; /* AVB-DMAC does not support gPTP active in config mode */
};

struct ravb_private {
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 5e41c2b04083..bdeb6a757559 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1203,6 +1203,7 @@ static int ravb_set_ringparam(struct net_device *ndev,
struct ethtool_ringparam *ring)
{
struct ravb_private *priv = netdev_priv(ndev);
+ const struct ravb_hw_info *info = priv->info;
int error;

if (ring->tx_pending > BE_TX_RING_MAX ||
@@ -1216,7 +1217,7 @@ static int ravb_set_ringparam(struct net_device *ndev,
if (netif_running(ndev)) {
netif_device_detach(ndev);
/* Stop PTP Clock driver */
- if (priv->chip_id == RCAR_GEN2)
+ if (info->no_ptp_cfg_active)
ravb_ptp_stop(ndev);
/* Wait for DMA stopping */
error = ravb_stop_dma(ndev);
@@ -1248,7 +1249,7 @@ static int ravb_set_ringparam(struct net_device *ndev,
ravb_emac_init(ndev);

/* Initialise PTP Clock driver */
- if (priv->chip_id == RCAR_GEN2)
+ if (info->no_ptp_cfg_active)
ravb_ptp_init(ndev, priv->pdev);

netif_device_attach(ndev);
@@ -1388,7 +1389,7 @@ static int ravb_open(struct net_device *ndev)
ravb_emac_init(ndev);

/* Initialise PTP Clock driver */
- if (priv->chip_id == RCAR_GEN2)
+ if (info->no_ptp_cfg_active)
ravb_ptp_init(ndev, priv->pdev);

netif_tx_start_all_queues(ndev);
@@ -1402,7 +1403,7 @@ static int ravb_open(struct net_device *ndev)

out_ptp_stop:
/* Stop PTP Clock driver */
- if (priv->chip_id == RCAR_GEN2)
+ if (info->no_ptp_cfg_active)
ravb_ptp_stop(ndev);
out_free_irq_nc_tx:
if (!info->multi_irqs)
@@ -1443,13 +1444,14 @@ static void ravb_tx_timeout_work(struct work_struct *work)
{
struct ravb_private *priv = container_of(work, struct ravb_private,
work);
+ const struct ravb_hw_info *info = priv->info;
struct net_device *ndev = priv->ndev;
int error;

netif_tx_stop_all_queues(ndev);

/* Stop PTP Clock driver */
- if (priv->chip_id == RCAR_GEN2)
+ if (info->no_ptp_cfg_active)
ravb_ptp_stop(ndev);

/* Wait for DMA stopping */
@@ -1484,7 +1486,7 @@ static void ravb_tx_timeout_work(struct work_struct *work)

out:
/* Initialise PTP Clock driver */
- if (priv->chip_id == RCAR_GEN2)
+ if (info->no_ptp_cfg_active)
ravb_ptp_init(ndev, priv->pdev);

netif_tx_start_all_queues(ndev);
@@ -1693,7 +1695,7 @@ static int ravb_close(struct net_device *ndev)
ravb_write(ndev, 0, TIC);

/* Stop PTP Clock driver */
- if (priv->chip_id == RCAR_GEN2)
+ if (info->no_ptp_cfg_active)
ravb_ptp_stop(ndev);

/* Set the config mode to stop the AVB-DMAC's processes */
@@ -1954,6 +1956,7 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
.aligned_tx = 1,
+ .no_ptp_cfg_active = 1,
};

static const struct of_device_id ravb_match_table[] = {
@@ -1994,8 +1997,9 @@ static int ravb_set_gti(struct net_device *ndev)
static void ravb_set_config_mode(struct net_device *ndev)
{
struct ravb_private *priv = netdev_priv(ndev);
+ const struct ravb_hw_info *info = priv->info;

- if (priv->chip_id == RCAR_GEN2) {
+ if (info->no_ptp_cfg_active) {
ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG);
/* Set CSEL value */
ravb_modify(ndev, CCC, CCC_CSEL, CCC_CSEL_HPB);
--
2.17.1


[PATCH 5.10.y-cip 20/61] ravb: Add multi_irq to struct ravb_hw_info

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit 6de19fa0e9f7d8d1033810df1e53ae5b0c7b0d65 upstream.

R-Car Gen3 supports separate interrupts for E-MAC and DMA queues,
whereas R-Car Gen2 and RZ/G2L have a single interrupt instead.

Add a multi_irq hw feature bit to struct ravb_hw_info to enable
this only for R-Car Gen3.

Signed-off-by: Biju Das <biju.das.jz@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb.h | 1 +
drivers/net/ethernet/renesas/ravb_main.c | 22 ++++++++++++++--------
drivers/net/ethernet/renesas/ravb_ptp.c | 8 +++++---
3 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index a0e19a45b2a0..a74bd63ba3be 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -998,6 +998,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 multi_irqs:1; /* AVB-DMAC and E-MAC has multiple irqs */
};

struct ravb_private {
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index a8007c5cdd35..5e41c2b04083 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -425,6 +425,7 @@ static void ravb_emac_init(struct net_device *ndev)
static int ravb_dmac_init(struct net_device *ndev)
{
struct ravb_private *priv = netdev_priv(ndev);
+ const struct ravb_hw_info *info = priv->info;
int error;

/* Set CONFIG mode */
@@ -456,7 +457,7 @@ static int ravb_dmac_init(struct net_device *ndev)
ravb_write(ndev, TCCR_TFEN, TCCR);

/* Interrupt init: */
- if (priv->chip_id == RCAR_GEN3) {
+ if (info->multi_irqs) {
/* Clear DIL.DPLx */
ravb_write(ndev, 0, DIL);
/* Set queue specific interrupt */
@@ -756,6 +757,7 @@ static void ravb_error_interrupt(struct net_device *ndev)
static bool ravb_queue_interrupt(struct net_device *ndev, int q)
{
struct ravb_private *priv = netdev_priv(ndev);
+ const struct ravb_hw_info *info = priv->info;
u32 ris0 = ravb_read(ndev, RIS0);
u32 ric0 = ravb_read(ndev, RIC0);
u32 tis = ravb_read(ndev, TIS);
@@ -764,7 +766,7 @@ static bool ravb_queue_interrupt(struct net_device *ndev, int q)
if (((ris0 & ric0) & BIT(q)) || ((tis & tic) & BIT(q))) {
if (napi_schedule_prep(&priv->napi[q])) {
/* Mask RX and TX interrupts */
- if (priv->chip_id == RCAR_GEN2) {
+ if (!info->multi_irqs) {
ravb_write(ndev, ric0 & ~BIT(q), RIC0);
ravb_write(ndev, tic & ~BIT(q), TIC);
} else {
@@ -907,6 +909,7 @@ 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;
unsigned long flags;
int q = napi - priv->napi;
int mask = BIT(q);
@@ -930,7 +933,7 @@ static int ravb_poll(struct napi_struct *napi, int budget)

/* Re-enable RX/TX interrupts */
spin_lock_irqsave(&priv->lock, flags);
- if (priv->chip_id == RCAR_GEN2) {
+ if (!info->multi_irqs) {
ravb_modify(ndev, RIC0, mask, mask);
ravb_modify(ndev, TIC, mask, mask);
} else {
@@ -1336,6 +1339,7 @@ static inline int ravb_hook_irq(unsigned int irq, irq_handler_t handler,
static int ravb_open(struct net_device *ndev)
{
struct ravb_private *priv = netdev_priv(ndev);
+ const struct ravb_hw_info *info = priv->info;
struct platform_device *pdev = priv->pdev;
struct device *dev = &pdev->dev;
int error;
@@ -1343,7 +1347,7 @@ static int ravb_open(struct net_device *ndev)
napi_enable(&priv->napi[RAVB_BE]);
napi_enable(&priv->napi[RAVB_NC]);

- if (priv->chip_id == RCAR_GEN2) {
+ if (!info->multi_irqs) {
error = request_irq(ndev->irq, ravb_interrupt, IRQF_SHARED,
ndev->name, ndev);
if (error) {
@@ -1401,7 +1405,7 @@ static int ravb_open(struct net_device *ndev)
if (priv->chip_id == RCAR_GEN2)
ravb_ptp_stop(ndev);
out_free_irq_nc_tx:
- if (priv->chip_id == RCAR_GEN2)
+ if (!info->multi_irqs)
goto out_free_irq;
free_irq(priv->tx_irqs[RAVB_NC], ndev);
out_free_irq_nc_rx:
@@ -1678,6 +1682,7 @@ static int ravb_close(struct net_device *ndev)
{
struct device_node *np = ndev->dev.parent->of_node;
struct ravb_private *priv = netdev_priv(ndev);
+ const struct ravb_hw_info *info = priv->info;
struct ravb_tstamp_skb *ts_skb, *ts_skb2;

netif_tx_stop_all_queues(ndev);
@@ -1711,7 +1716,7 @@ static int ravb_close(struct net_device *ndev)
of_phy_deregister_fixed_link(np);
}

- if (priv->chip_id != RCAR_GEN2) {
+ if (info->multi_irqs) {
free_irq(priv->tx_irqs[RAVB_NC], ndev);
free_irq(priv->rx_irqs[RAVB_NC], ndev);
free_irq(priv->tx_irqs[RAVB_BE], ndev);
@@ -1937,6 +1942,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
.internal_delay = 1,
.tx_counters = 1,
+ .multi_irqs = 1,
};

static const struct ravb_hw_info ravb_gen2_hw_info = {
@@ -2075,7 +2081,7 @@ static int ravb_probe(struct platform_device *pdev)
pm_runtime_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev);

- if (info->chip_id == RCAR_GEN3)
+ if (info->multi_irqs)
irq = platform_get_irq_byname(pdev, "ch22");
else
irq = platform_get_irq(pdev, 0);
@@ -2115,7 +2121,7 @@ static int ravb_probe(struct platform_device *pdev)
priv->avb_link_active_low =
of_property_read_bool(np, "renesas,ether-link-active-low");

- if (info->chip_id == RCAR_GEN3) {
+ if (info->multi_irqs) {
irq = platform_get_irq_byname(pdev, "ch24");
if (irq < 0) {
error = irq;
diff --git a/drivers/net/ethernet/renesas/ravb_ptp.c b/drivers/net/ethernet/renesas/ravb_ptp.c
index 6984bd5b7da9..c099656dd75b 100644
--- a/drivers/net/ethernet/renesas/ravb_ptp.c
+++ b/drivers/net/ethernet/renesas/ravb_ptp.c
@@ -179,6 +179,7 @@ static int ravb_ptp_extts(struct ptp_clock_info *ptp,
{
struct ravb_private *priv = container_of(ptp, struct ravb_private,
ptp.info);
+ const struct ravb_hw_info *info = priv->info;
struct net_device *ndev = priv->ndev;
unsigned long flags;

@@ -197,7 +198,7 @@ static int ravb_ptp_extts(struct ptp_clock_info *ptp,
priv->ptp.extts[req->index] = on;

spin_lock_irqsave(&priv->lock, flags);
- if (priv->chip_id == RCAR_GEN2)
+ if (!info->multi_irqs)
ravb_modify(ndev, GIC, GIC_PTCE, on ? GIC_PTCE : 0);
else if (on)
ravb_write(ndev, GIE_PTCS, GIE);
@@ -213,6 +214,7 @@ static int ravb_ptp_perout(struct ptp_clock_info *ptp,
{
struct ravb_private *priv = container_of(ptp, struct ravb_private,
ptp.info);
+ const struct ravb_hw_info *info = priv->info;
struct net_device *ndev = priv->ndev;
struct ravb_ptp_perout *perout;
unsigned long flags;
@@ -252,7 +254,7 @@ static int ravb_ptp_perout(struct ptp_clock_info *ptp,
error = ravb_ptp_update_compare(priv, (u32)start_ns);
if (!error) {
/* Unmask interrupt */
- if (priv->chip_id == RCAR_GEN2)
+ if (!info->multi_irqs)
ravb_modify(ndev, GIC, GIC_PTME, GIC_PTME);
else
ravb_write(ndev, GIE_PTMS0, GIE);
@@ -264,7 +266,7 @@ static int ravb_ptp_perout(struct ptp_clock_info *ptp,
perout->period = 0;

/* Mask interrupt */
- if (priv->chip_id == RCAR_GEN2)
+ if (!info->multi_irqs)
ravb_modify(ndev, GIC, GIC_PTME, 0);
else
ravb_write(ndev, GID_PTMD0, GID);
--
2.17.1


[PATCH 5.10.y-cip 19/61] ravb: Remove the macros NUM_TX_DESC_GEN[23]

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit c81d894226b94439c543e9cfac406c8024172fd7 upstream.

For addressing 4 bytes alignment restriction on transmission
buffer for R-Car Gen2 we use 2 descriptors whereas it is a single
descriptor for other cases.
Replace the macros NUM_TX_DESC_GEN[23] with magic number and
add a comment to explain it.

Signed-off-by: Biju Das <biju.das.jz@...>
Suggested-by: Geert Uytterhoeven <geert+renesas@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb.h | 4 ----
drivers/net/ethernet/renesas/ravb_main.c | 8 ++++++--
2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 3d87fb40b5c8..a0e19a45b2a0 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -957,10 +957,6 @@ enum RAVB_QUEUE {

#define RX_BUF_SZ (2048 - ETH_FCS_LEN + sizeof(__sum16))

-/* TX descriptors per packet */
-#define NUM_TX_DESC_GEN2 2
-#define NUM_TX_DESC_GEN3 1
-
struct ravb_tstamp_skb {
struct list_head list;
struct sk_buff *skb;
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index b16c179ba44c..a8007c5cdd35 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2158,8 +2158,12 @@ static int ravb_probe(struct platform_device *pdev)
ndev->max_mtu = 2048 - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN);
ndev->min_mtu = ETH_MIN_MTU;

- priv->num_tx_desc = info->aligned_tx ?
- NUM_TX_DESC_GEN2 : NUM_TX_DESC_GEN3;
+ /* FIXME: R-Car Gen2 has 4byte alignment restriction for tx buffer
+ * Use two descriptor to handle such situation. First descriptor to
+ * handle aligned data buffer and second descriptor to handle the
+ * overflow data because of alignment.
+ */
+ priv->num_tx_desc = info->aligned_tx ? 2 : 1;

/* Set function */
ndev->netdev_ops = &ravb_netdev_ops;
--
2.17.1


[PATCH 5.10.y-cip 18/61] ravb: Add tx_counters to struct ravb_hw_info

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit 0b81d67311676c9119ed3b027d1518e974dbca8e upstream.

The register for retrieving TX counters is present only on R-Car Gen3
and RZ/G2L; it is not present on R-Car Gen2.

Add the tx_counters hw feature bit to struct ravb_hw_info, to enable this
feature specifically for R-Car Gen3 now and later extend it to RZ/G2L.

Signed-off-by: Biju Das <biju.das.jz@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Reviewed-by: Andrew Lunn <andrew@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb.h | 1 +
drivers/net/ethernet/renesas/ravb_main.c | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 9aee46e23105..3d87fb40b5c8 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1001,6 +1001,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 */
};

struct ravb_private {
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 838badff3c19..b16c179ba44c 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1630,13 +1630,14 @@ static u16 ravb_select_queue(struct net_device *ndev, struct sk_buff *skb,
static struct net_device_stats *ravb_get_stats(struct net_device *ndev)
{
struct ravb_private *priv = netdev_priv(ndev);
+ const struct ravb_hw_info *info = priv->info;
struct net_device_stats *nstats, *stats0, *stats1;

nstats = &ndev->stats;
stats0 = &priv->stats[RAVB_BE];
stats1 = &priv->stats[RAVB_NC];

- if (priv->chip_id == RCAR_GEN3) {
+ if (info->tx_counters) {
nstats->tx_dropped += ravb_read(ndev, TROCR);
ravb_write(ndev, 0, TROCR); /* (write clear) */
}
@@ -1935,6 +1936,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,
.internal_delay = 1,
+ .tx_counters = 1,
};

static const struct ravb_hw_info ravb_gen2_hw_info = {
--
2.17.1


[PATCH 5.10.y-cip 17/61] ravb: Add internal delay hw feature to struct ravb_hw_info

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit 8bc4caa0abafd83e25df2a3b1b03480aab071ee1 upstream.

R-Car Gen3 supports TX and RX clock internal delay modes, whereas R-Car
Gen2 and RZ/G2L do not support it.
Add an internal_delay hw feature bit to struct ravb_hw_info to enable this
only for R-Car Gen3.

Signed-off-by: Biju Das <biju.das.jz@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Reviewed-by: Andrew Lunn <andrew@...>
Reviewed-by: Sergei Shtylyov <sergei.shtylyov@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb.h | 3 +++
drivers/net/ethernet/renesas/ravb_main.c | 6 ++++--
2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 0d0c27ad4e3b..9aee46e23105 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -998,6 +998,9 @@ struct ravb_hw_info {
int stats_len;
size_t max_rx_len;
unsigned aligned_tx: 1;
+
+ /* hardware features */
+ unsigned internal_delay:1; /* AVB-DMAC has internal delays */
};

struct ravb_private {
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index f2e6dc7b5551..838badff3c19 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1934,6 +1934,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
.chip_id = RCAR_GEN3,
.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
+ .internal_delay = 1,
};

static const struct ravb_hw_info ravb_gen2_hw_info = {
@@ -2173,7 +2174,7 @@ static int ravb_probe(struct platform_device *pdev)
/* Request GTI loading */
ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI);

- if (priv->chip_id != RCAR_GEN2) {
+ if (info->internal_delay) {
ravb_parse_delay_mode(np, ndev);
ravb_set_delay_mode(ndev);
}
@@ -2346,6 +2347,7 @@ static int __maybe_unused ravb_resume(struct device *dev)
{
struct net_device *ndev = dev_get_drvdata(dev);
struct ravb_private *priv = netdev_priv(ndev);
+ const struct ravb_hw_info *info = priv->info;
int ret = 0;

/* If WoL is enabled set reset mode to rearm the WoL logic */
@@ -2368,7 +2370,7 @@ static int __maybe_unused ravb_resume(struct device *dev)
/* Request GTI loading */
ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI);

- if (priv->chip_id != RCAR_GEN2)
+ if (info->internal_delay)
ravb_set_delay_mode(ndev);

/* Restore descriptor base address table */
--
2.17.1


[PATCH 5.10.y-cip 16/61] ravb: Add net_features and net_hw_features to struct ravb_hw_info

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit 8912ed25daf6fc811c71ac30794822c824017c0f upstream.

On R-Car the checksum calculation on RX frames is done by the E-MAC
module, whereas on RZ/G2L it is done by the TOE.

TOE calculates the checksum of received frames from E-MAC and outputs it to
DMAC. TOE also calculates the checksum of transmission frames from DMAC and
outputs it E-MAC.

Add net_features and net_hw_features to struct ravb_hw_info, to support
subsequent SoCs without any code changes in the ravb_probe function.

Signed-off-by: Biju Das <biju.das.jz@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Reviewed-by: Andrew Lunn <andrew@...>
Reviewed-by: Sergei Shtylyov <sergei.shtylyov@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb.h | 2 ++
drivers/net/ethernet/renesas/ravb_main.c | 12 ++++++++----
2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index dccf64fcbe1f..0d0c27ad4e3b 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -992,6 +992,8 @@ enum ravb_chip_id {
struct ravb_hw_info {
const char (*gstrings_stats)[ETH_GSTRING_LEN];
size_t gstrings_size;
+ netdev_features_t net_hw_features;
+ netdev_features_t net_features;
enum ravb_chip_id chip_id;
int stats_len;
size_t max_rx_len;
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 8bfdc5b1d1f4..f2e6dc7b5551 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1929,6 +1929,8 @@ static int ravb_mdio_release(struct ravb_private *priv)
static const struct ravb_hw_info ravb_gen3_hw_info = {
.gstrings_stats = ravb_gstrings_stats,
.gstrings_size = sizeof(ravb_gstrings_stats),
+ .net_hw_features = NETIF_F_RXCSUM,
+ .net_features = NETIF_F_RXCSUM,
.chip_id = RCAR_GEN3,
.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
@@ -1937,6 +1939,8 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
static const struct ravb_hw_info ravb_gen2_hw_info = {
.gstrings_stats = ravb_gstrings_stats,
.gstrings_size = sizeof(ravb_gstrings_stats),
+ .net_hw_features = NETIF_F_RXCSUM,
+ .net_features = NETIF_F_RXCSUM,
.chip_id = RCAR_GEN2,
.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
@@ -2060,14 +2064,14 @@ static int ravb_probe(struct platform_device *pdev)
if (!ndev)
return -ENOMEM;

- ndev->features = NETIF_F_RXCSUM;
- ndev->hw_features = NETIF_F_RXCSUM;
+ info = of_device_get_match_data(&pdev->dev);
+
+ ndev->features = info->net_features;
+ ndev->hw_features = info->net_hw_features;

pm_runtime_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev);

- info = of_device_get_match_data(&pdev->dev);
-
if (info->chip_id == RCAR_GEN3)
irq = platform_get_irq_byname(pdev, "ch22");
else
--
2.17.1


[PATCH 5.10.y-cip 15/61] ravb: Add gstrings_stats and gstrings_size to struct ravb_hw_info

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit 896a818e0e1d4a2065e210de88b3d0535bbeac1c upstream.

The device stats strings for R-Car and RZ/G2L are different.

R-Car provides 30 device stats, whereas RZ/G2L provides only 15. In
addition, RZ/G2L has stats "rx_queue_0_csum_offload_errors" instead of
"rx_queue_0_missed_errors".

Add structure variables gstrings_stats and gstrings_size to struct
ravb_hw_info, so that subsequent SoCs can be added without any code
changes in the ravb_get_strings function.

Signed-off-by: Biju Das <biju.das.jz@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Reviewed-by: Andrew Lunn <andrew@...>
Reviewed-by: Sergei Shtylyov <sergei.shtylyov@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb.h | 2 ++
drivers/net/ethernet/renesas/ravb_main.c | 9 ++++++++-
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index b782977a837a..dccf64fcbe1f 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -990,6 +990,8 @@ enum ravb_chip_id {
};

struct ravb_hw_info {
+ const char (*gstrings_stats)[ETH_GSTRING_LEN];
+ size_t gstrings_size;
enum ravb_chip_id chip_id;
int stats_len;
size_t max_rx_len;
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 6f89adff8bf9..8bfdc5b1d1f4 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1175,9 +1175,12 @@ static void ravb_get_ethtool_stats(struct net_device *ndev,

static void ravb_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
{
+ struct ravb_private *priv = netdev_priv(ndev);
+ const struct ravb_hw_info *info = priv->info;
+
switch (stringset) {
case ETH_SS_STATS:
- memcpy(data, ravb_gstrings_stats, sizeof(ravb_gstrings_stats));
+ memcpy(data, info->gstrings_stats, info->gstrings_size);
break;
}
}
@@ -1924,12 +1927,16 @@ static int ravb_mdio_release(struct ravb_private *priv)
}

static const struct ravb_hw_info ravb_gen3_hw_info = {
+ .gstrings_stats = ravb_gstrings_stats,
+ .gstrings_size = sizeof(ravb_gstrings_stats),
.chip_id = RCAR_GEN3,
.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
};

static const struct ravb_hw_info ravb_gen2_hw_info = {
+ .gstrings_stats = ravb_gstrings_stats,
+ .gstrings_size = sizeof(ravb_gstrings_stats),
.chip_id = RCAR_GEN2,
.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
--
2.17.1


[PATCH 5.10.y-cip 14/61] ravb: Add stats_len to struct ravb_hw_info

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit 25154301fc2bcc1d949a42218e4dfb870f0f1794 upstream.

R-Car provides 30 device stats, whereas RZ/G2L provides only 15. In
addition, RZ/G2L has stats "rx_queue_0_csum_offload_errors" instead of
"rx_queue_0_missed_errors".

Replace RAVB_STATS_LEN macro with a structure variable stats_len to
struct ravb_hw_info, to support subsequent SoCs without any code changes
to the ravb_get_sset_count function.

Signed-off-by: Biju Das <biju.das.jz@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Reviewed-by: Sergei Shtylyov <sergei.shtylyov@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb.h | 1 +
drivers/net/ethernet/renesas/ravb_main.c | 9 ++++++---
2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 546d662b1935..b782977a837a 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -991,6 +991,7 @@ enum ravb_chip_id {

struct ravb_hw_info {
enum ravb_chip_id chip_id;
+ int stats_len;
size_t max_rx_len;
unsigned aligned_tx: 1;
};
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 62708c838ae9..6f89adff8bf9 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1131,13 +1131,14 @@ static const char ravb_gstrings_stats[][ETH_GSTRING_LEN] = {
"rx_queue_1_over_errors",
};

-#define RAVB_STATS_LEN ARRAY_SIZE(ravb_gstrings_stats)
-
static int ravb_get_sset_count(struct net_device *netdev, int sset)
{
+ struct ravb_private *priv = netdev_priv(netdev);
+ const struct ravb_hw_info *info = priv->info;
+
switch (sset) {
case ETH_SS_STATS:
- return RAVB_STATS_LEN;
+ return info->stats_len;
default:
return -EOPNOTSUPP;
}
@@ -1924,11 +1925,13 @@ static int ravb_mdio_release(struct ravb_private *priv)

static const struct ravb_hw_info ravb_gen3_hw_info = {
.chip_id = RCAR_GEN3,
+ .stats_len = ARRAY_SIZE(ravb_gstrings_stats),
.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
};

static const struct ravb_hw_info ravb_gen2_hw_info = {
.chip_id = RCAR_GEN2,
+ .stats_len = ARRAY_SIZE(ravb_gstrings_stats),
.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
.aligned_tx = 1,
};
--
2.17.1


[PATCH 5.10.y-cip 13/61] ravb: Add max_rx_len to struct ravb_hw_info

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit cb01c672c2a7aded88915e475463fe1128dc76d7 upstream.

The maximum descriptor size that can be specified on the reception side for
R-Car is 2048 bytes, whereas for RZ/G2L it is 8096.

Add the max_rx_len variable to struct ravb_hw_info for allocating different
RX skb buffer sizes for R-Car and RZ/G2L using the netdev_alloc_skb
function.

Signed-off-by: Biju Das <biju.das.jz@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Reviewed-by: Andrew Lunn <andrew@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb.h | 1 +
drivers/net/ethernet/renesas/ravb_main.c | 10 ++++++----
2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 830a3e4a9606..546d662b1935 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -991,6 +991,7 @@ enum ravb_chip_id {

struct ravb_hw_info {
enum ravb_chip_id chip_id;
+ size_t max_rx_len;
unsigned aligned_tx: 1;
};

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 60acb53eaa81..62708c838ae9 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -337,6 +337,7 @@ static void ravb_ring_format(struct net_device *ndev, int q)
static int ravb_ring_init(struct net_device *ndev, int q)
{
struct ravb_private *priv = netdev_priv(ndev);
+ const struct ravb_hw_info *info = priv->info;
unsigned int num_tx_desc = priv->num_tx_desc;
unsigned int ring_size;
struct sk_buff *skb;
@@ -351,7 +352,7 @@ static int ravb_ring_init(struct net_device *ndev, int q)
goto error;

for (i = 0; i < priv->num_rx_ring[q]; i++) {
- skb = netdev_alloc_skb(ndev, RX_BUF_SZ + RAVB_ALIGN - 1);
+ skb = netdev_alloc_skb(ndev, info->max_rx_len);
if (!skb)
goto error;
ravb_set_buffer_align(skb);
@@ -533,6 +534,7 @@ static void ravb_rx_csum(struct sk_buff *skb)
static bool ravb_rx(struct net_device *ndev, int *quota, int q)
{
struct ravb_private *priv = netdev_priv(ndev);
+ const struct ravb_hw_info *info = priv->info;
int entry = priv->cur_rx[q] % priv->num_rx_ring[q];
int boguscnt = (priv->dirty_rx[q] + priv->num_rx_ring[q]) -
priv->cur_rx[q];
@@ -617,9 +619,7 @@ static bool ravb_rx(struct net_device *ndev, int *quota, int q)
desc->ds_cc = cpu_to_le16(RX_BUF_SZ);

if (!priv->rx_skb[q][entry]) {
- skb = netdev_alloc_skb(ndev,
- RX_BUF_SZ +
- RAVB_ALIGN - 1);
+ skb = netdev_alloc_skb(ndev, info->max_rx_len);
if (!skb)
break; /* Better luck next round. */
ravb_set_buffer_align(skb);
@@ -1924,10 +1924,12 @@ static int ravb_mdio_release(struct ravb_private *priv)

static const struct ravb_hw_info ravb_gen3_hw_info = {
.chip_id = RCAR_GEN3,
+ .max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
};

static const struct ravb_hw_info ravb_gen2_hw_info = {
.chip_id = RCAR_GEN2,
+ .max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
.aligned_tx = 1,
};

--
2.17.1


[PATCH 5.10.y-cip 12/61] ravb: Add aligned_tx to struct ravb_hw_info

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit 68ca3c923213b908c14a673f6c3ec808664fae1f upstream.

R-Car Gen2 needs a 4byte aligned address for the transmission buffer,
whereas R-Car Gen3 doesn't have any such restriction.

Add aligned_tx to struct ravb_hw_info to select the driver to choose
between aligned and unaligned tx buffers.

Signed-off-by: Biju Das <biju.das.jz@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb.h | 1 +
drivers/net/ethernet/renesas/ravb_main.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 9c228fa8e2a4..830a3e4a9606 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -991,6 +991,7 @@ enum ravb_chip_id {

struct ravb_hw_info {
enum ravb_chip_id chip_id;
+ unsigned aligned_tx: 1;
};

struct ravb_private {
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 0bf787896521..60acb53eaa81 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1928,6 +1928,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {

static const struct ravb_hw_info ravb_gen2_hw_info = {
.chip_id = RCAR_GEN2,
+ .aligned_tx = 1,
};

static const struct of_device_id ravb_match_table[] = {
@@ -2138,7 +2139,7 @@ static int ravb_probe(struct platform_device *pdev)
ndev->max_mtu = 2048 - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN);
ndev->min_mtu = ETH_MIN_MTU;

- priv->num_tx_desc = info->chip_id == RCAR_GEN2 ?
+ priv->num_tx_desc = info->aligned_tx ?
NUM_TX_DESC_GEN2 : NUM_TX_DESC_GEN3;

/* Set function */
--
2.17.1


[PATCH 5.10.y-cip 11/61] ravb: Add struct ravb_hw_info to driver data

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit ebb091461a9e146f8afd750cb7eddc5b4c8d47be upstream.

The DMAC and EMAC blocks of Gigabit Ethernet IP found on RZ/G2L SoC are
similar to the R-Car Ethernet AVB IP. With a few changes in the driver we
can support both IPs.

This patch adds the struct ravb_hw_info to hold hw features, driver data
and function pointers to support both the IPs. It also replaces the driver
data chip type with struct ravb_hw_info by moving chip type to it.

Signed-off-by: Biju Das <biju.das.jz@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Reviewed-by: Andrew Lunn <andrew@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb.h | 6 ++++
drivers/net/ethernet/renesas/ravb_main.c | 35 +++++++++++++++---------
2 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index ccc9471897f3..9c228fa8e2a4 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -989,6 +989,10 @@ enum ravb_chip_id {
RCAR_GEN3,
};

+struct ravb_hw_info {
+ enum ravb_chip_id chip_id;
+};
+
struct ravb_private {
struct net_device *ndev;
struct platform_device *pdev;
@@ -1041,6 +1045,8 @@ struct ravb_private {
unsigned txcidm:1; /* TX Clock Internal Delay Mode */
unsigned rgmii_override:1; /* Deprecated rgmii-*id behavior */
unsigned int num_tx_desc; /* TX descriptors per packet */
+
+ const struct ravb_hw_info *info;
};

static inline u32 ravb_read(struct net_device *ndev, enum ravb_reg reg)
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 1566009489e3..0bf787896521 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1922,12 +1922,20 @@ static int ravb_mdio_release(struct ravb_private *priv)
return 0;
}

+static const struct ravb_hw_info ravb_gen3_hw_info = {
+ .chip_id = RCAR_GEN3,
+};
+
+static const struct ravb_hw_info ravb_gen2_hw_info = {
+ .chip_id = RCAR_GEN2,
+};
+
static const struct of_device_id ravb_match_table[] = {
- { .compatible = "renesas,etheravb-r8a7790", .data = (void *)RCAR_GEN2 },
- { .compatible = "renesas,etheravb-r8a7794", .data = (void *)RCAR_GEN2 },
- { .compatible = "renesas,etheravb-rcar-gen2", .data = (void *)RCAR_GEN2 },
- { .compatible = "renesas,etheravb-r8a7795", .data = (void *)RCAR_GEN3 },
- { .compatible = "renesas,etheravb-rcar-gen3", .data = (void *)RCAR_GEN3 },
+ { .compatible = "renesas,etheravb-r8a7790", .data = &ravb_gen2_hw_info },
+ { .compatible = "renesas,etheravb-r8a7794", .data = &ravb_gen2_hw_info },
+ { .compatible = "renesas,etheravb-rcar-gen2", .data = &ravb_gen2_hw_info },
+ { .compatible = "renesas,etheravb-r8a7795", .data = &ravb_gen3_hw_info },
+ { .compatible = "renesas,etheravb-rcar-gen3", .data = &ravb_gen3_hw_info },
{ }
};
MODULE_DEVICE_TABLE(of, ravb_match_table);
@@ -2021,8 +2029,8 @@ static void ravb_set_delay_mode(struct net_device *ndev)
static int ravb_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
+ const struct ravb_hw_info *info;
struct ravb_private *priv;
- enum ravb_chip_id chip_id;
struct net_device *ndev;
int error, irq, q;
struct resource *res;
@@ -2045,9 +2053,9 @@ static int ravb_probe(struct platform_device *pdev)
pm_runtime_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev);

- chip_id = (enum ravb_chip_id)of_device_get_match_data(&pdev->dev);
+ info = of_device_get_match_data(&pdev->dev);

- if (chip_id == RCAR_GEN3)
+ if (info->chip_id == RCAR_GEN3)
irq = platform_get_irq_byname(pdev, "ch22");
else
irq = platform_get_irq(pdev, 0);
@@ -2060,6 +2068,7 @@ static int ravb_probe(struct platform_device *pdev)
SET_NETDEV_DEV(ndev, &pdev->dev);

priv = netdev_priv(ndev);
+ priv->info = info;
priv->ndev = ndev;
priv->pdev = pdev;
priv->num_tx_ring[RAVB_BE] = BE_TX_RING_SIZE;
@@ -2086,7 +2095,7 @@ static int ravb_probe(struct platform_device *pdev)
priv->avb_link_active_low =
of_property_read_bool(np, "renesas,ether-link-active-low");

- if (chip_id == RCAR_GEN3) {
+ if (info->chip_id == RCAR_GEN3) {
irq = platform_get_irq_byname(pdev, "ch24");
if (irq < 0) {
error = irq;
@@ -2111,7 +2120,7 @@ static int ravb_probe(struct platform_device *pdev)
}
}

- priv->chip_id = chip_id;
+ priv->chip_id = info->chip_id;

priv->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(priv->clk)) {
@@ -2129,7 +2138,7 @@ static int ravb_probe(struct platform_device *pdev)
ndev->max_mtu = 2048 - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN);
ndev->min_mtu = ETH_MIN_MTU;

- priv->num_tx_desc = chip_id == RCAR_GEN2 ?
+ priv->num_tx_desc = info->chip_id == RCAR_GEN2 ?
NUM_TX_DESC_GEN2 : NUM_TX_DESC_GEN3;

/* Set function */
@@ -2171,7 +2180,7 @@ static int ravb_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&priv->ts_skb_list);

/* Initialise PTP Clock driver */
- if (chip_id != RCAR_GEN2)
+ if (info->chip_id != RCAR_GEN2)
ravb_ptp_init(ndev, pdev);

/* Debug message level */
@@ -2219,7 +2228,7 @@ static int ravb_probe(struct platform_device *pdev)
priv->desc_bat_dma);

/* Stop PTP Clock driver */
- if (chip_id != RCAR_GEN2)
+ if (info->chip_id != RCAR_GEN2)
ravb_ptp_stop(ndev);
out_disable_refclk:
clk_disable_unprepare(priv->refclk);
--
2.17.1


[PATCH 5.10.y-cip 10/61] ravb: Use unsigned int for num_tx_desc variable in struct ravb_private

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit cb537b241725f5261e752add954e08837348edad upstream.

The number of TX descriptors per packet is an unsigned value and
the variable for holding this information should be unsigned.

This patch replaces the data type of num_tx_desc variable in struct
ravb_private from 'int' to 'unsigned int'.
This patch also updates the data type of local variables to unsigned int,
where the local variables are evaluated using num_tx_desc.

Signed-off-by: Biju Das <biju.das.jz@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb.h | 2 +-
drivers/net/ethernet/renesas/ravb_main.c | 28 ++++++++++++------------
2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index ff363797bd2b..ccc9471897f3 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1040,7 +1040,7 @@ struct ravb_private {
unsigned rxcidm:1; /* RX Clock Internal Delay Mode */
unsigned txcidm:1; /* TX Clock Internal Delay Mode */
unsigned rgmii_override:1; /* Deprecated rgmii-*id behavior */
- int num_tx_desc; /* TX descriptors per packet */
+ unsigned int num_tx_desc; /* TX descriptors per packet */
};

static inline u32 ravb_read(struct net_device *ndev, enum ravb_reg reg)
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 541f4ebf7135..1566009489e3 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -175,10 +175,10 @@ static int ravb_tx_free(struct net_device *ndev, int q, bool free_txed_only)
{
struct ravb_private *priv = netdev_priv(ndev);
struct net_device_stats *stats = &priv->stats[q];
- int num_tx_desc = priv->num_tx_desc;
+ unsigned int num_tx_desc = priv->num_tx_desc;
struct ravb_tx_desc *desc;
+ unsigned int entry;
int free_num = 0;
- int entry;
u32 size;

for (; priv->cur_tx[q] - priv->dirty_tx[q] > 0; priv->dirty_tx[q]++) {
@@ -218,9 +218,9 @@ static int ravb_tx_free(struct net_device *ndev, int q, bool free_txed_only)
static void ravb_ring_free(struct net_device *ndev, int q)
{
struct ravb_private *priv = netdev_priv(ndev);
- int num_tx_desc = priv->num_tx_desc;
- int ring_size;
- int i;
+ unsigned int num_tx_desc = priv->num_tx_desc;
+ unsigned int ring_size;
+ unsigned int i;

if (priv->rx_ring[q]) {
for (i = 0; i < priv->num_rx_ring[q]; i++) {
@@ -273,15 +273,15 @@ static void ravb_ring_free(struct net_device *ndev, int q)
static void ravb_ring_format(struct net_device *ndev, int q)
{
struct ravb_private *priv = netdev_priv(ndev);
- int num_tx_desc = priv->num_tx_desc;
+ unsigned int num_tx_desc = priv->num_tx_desc;
struct ravb_ex_rx_desc *rx_desc;
struct ravb_tx_desc *tx_desc;
struct ravb_desc *desc;
- int rx_ring_size = sizeof(*rx_desc) * priv->num_rx_ring[q];
- int tx_ring_size = sizeof(*tx_desc) * priv->num_tx_ring[q] *
- num_tx_desc;
+ unsigned int rx_ring_size = sizeof(*rx_desc) * priv->num_rx_ring[q];
+ unsigned int tx_ring_size = sizeof(*tx_desc) * priv->num_tx_ring[q] *
+ num_tx_desc;
dma_addr_t dma_addr;
- int i;
+ unsigned int i;

priv->cur_rx[q] = 0;
priv->cur_tx[q] = 0;
@@ -337,10 +337,10 @@ static void ravb_ring_format(struct net_device *ndev, int q)
static int ravb_ring_init(struct net_device *ndev, int q)
{
struct ravb_private *priv = netdev_priv(ndev);
- int num_tx_desc = priv->num_tx_desc;
+ unsigned int num_tx_desc = priv->num_tx_desc;
+ unsigned int ring_size;
struct sk_buff *skb;
- int ring_size;
- int i;
+ unsigned int i;

/* Allocate RX and TX skb rings */
priv->rx_skb[q] = kcalloc(priv->num_rx_ring[q],
@@ -1486,7 +1486,7 @@ static void ravb_tx_timeout_work(struct work_struct *work)
static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev)
{
struct ravb_private *priv = netdev_priv(ndev);
- int num_tx_desc = priv->num_tx_desc;
+ unsigned int num_tx_desc = priv->num_tx_desc;
u16 q = skb_get_queue_mapping(skb);
struct ravb_tstamp_skb *ts_skb;
struct ravb_tx_desc *desc;
--
2.17.1


[PATCH 5.10.y-cip 09/61] ravb: Remove checks for unsupported internal delay modes

Lad Prabhakar
 

From: Geert Uytterhoeven <geert+renesas@...>

commit 44e5d08812805bcb0f37e18f6c4eab1174a9d053 upstream.

The EtherAVB instances on the R-Car E3/D3 and RZ/G2E SoCs do not support
TX clock internal delay modes, and the EtherAVB driver prints a warning
if an unsupported "rgmii-*id" PHY mode is specified, to catch buggy
DTBs.

Commit a6f51f2efa742df0 ("ravb: Add support for explicit internal
clock delay configuration") deprecated deriving the internal delay mode
from the PHY mode, in favor of explicit configuration using the now
mandatory "rx-internal-delay-ps" and "tx-internal-delay-ps" properties,
thus delegating the warning to the legacy fallback code.

Since explicit configuration of a (valid) internal clock delay
configuration is enforced by validating device tree source files against
DT binding files, and all upstream DTS files have been converted as of
commit a5200e63af57d05e ("arm64: dts: renesas: rzg2: Convert EtherAVB to
explicit delay handling"), the checks in the legacy fallback code can be
removed.

Signed-off-by: Geert Uytterhoeven <geert+renesas@...>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@...>
Link: https://lore.kernel.org/r/2037542ac56e99413b9807e24049711553cc88a9.1628696778.git.geert+renesas@glider.be
Signed-off-by: Jakub Kicinski <kuba@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb_main.c | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 267533123140..541f4ebf7135 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1971,13 +1971,6 @@ static void ravb_set_config_mode(struct net_device *ndev)
}
}

-static const struct soc_device_attribute ravb_delay_mode_quirk_match[] = {
- { .soc_id = "r8a774c0" },
- { .soc_id = "r8a77990" },
- { .soc_id = "r8a77995" },
- { /* sentinel */ }
-};
-
/* Set tx and rx clock internal delay modes */
static void ravb_parse_delay_mode(struct device_node *np, struct net_device *ndev)
{
@@ -2008,12 +2001,8 @@ static void ravb_parse_delay_mode(struct device_node *np, struct net_device *nde

if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
priv->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) {
- if (!WARN(soc_device_match(ravb_delay_mode_quirk_match),
- "phy-mode %s requires TX clock internal delay mode which is not supported by this hardware revision. Please update device tree",
- phy_modes(priv->phy_interface))) {
- priv->txcidm = 1;
- priv->rgmii_override = 1;
- }
+ priv->txcidm = 1;
+ priv->rgmii_override = 1;
}
}

--
2.17.1


[PATCH 5.10.y-cip 08/61] ravb: Fix a typo in comment

Lad Prabhakar
 

From: Biju Das <biju.das.jz@...>

commit 291d0a2c1fa6ff437c8f1156646fdd2525714c80 upstream.

Fix the typo RX->TX in comment, as the code following the comment
process TX and not RX.

Signed-off-by: Biju Das <biju.das.jz@...>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
Reviewed-by: Sergei Shtylyov <sergei.shtylyov@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
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 c9233cd4a68d..267533123140 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -918,7 +918,7 @@ static int ravb_poll(struct napi_struct *napi, int budget)
if (ravb_rx(ndev, &quota, q))
goto out;

- /* Processing RX Descriptor Ring */
+ /* Processing TX Descriptor Ring */
spin_lock_irqsave(&priv->lock, flags);
/* Clear TX interrupt */
ravb_write(ndev, ~(mask | TIS_RESERVED), TIS);
--
2.17.1


[PATCH 5.10.y-cip 07/61] net: ethernet: ravb: Use devm_platform_get_and_ioremap_resource()

Lad Prabhakar
 

From: Yang Yingliang <yangyingliang@...>

commit e89a2cdb1cca513a3f431c9f404fe220dfbf949c upstream.

Use devm_platform_get_and_ioremap_resource() to simplify
code.

Signed-off-by: Yang Yingliang <yangyingliang@...>
Reviewed-by: Sergei Shtylyov <sergei.shtylyov@...>
Signed-off-by: David S. Miller <davem@...>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...>
---
drivers/net/ethernet/renesas/ravb_main.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index e36f52c9da42..c9233cd4a68d 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2045,13 +2045,6 @@ static int ravb_probe(struct platform_device *pdev)
return -EINVAL;
}

- /* Get base address */
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(&pdev->dev, "invalid resource\n");
- return -EINVAL;
- }
-
ndev = alloc_etherdev_mqs(sizeof(struct ravb_private),
NUM_TX_QUEUE, NUM_RX_QUEUE);
if (!ndev)
@@ -2063,9 +2056,6 @@ static int ravb_probe(struct platform_device *pdev)
pm_runtime_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev);

- /* The Ether-specific entries in the device structure. */
- ndev->base_addr = res->start;
-
chip_id = (enum ravb_chip_id)of_device_get_match_data(&pdev->dev);

if (chip_id == RCAR_GEN3)
@@ -2087,12 +2077,15 @@ static int ravb_probe(struct platform_device *pdev)
priv->num_rx_ring[RAVB_BE] = BE_RX_RING_SIZE;
priv->num_tx_ring[RAVB_NC] = NC_TX_RING_SIZE;
priv->num_rx_ring[RAVB_NC] = NC_RX_RING_SIZE;
- priv->addr = devm_ioremap_resource(&pdev->dev, res);
+ priv->addr = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(priv->addr)) {
error = PTR_ERR(priv->addr);
goto out_release;
}

+ /* The Ether-specific entries in the device structure. */
+ ndev->base_addr = res->start;
+
spin_lock_init(&priv->lock);
INIT_WORK(&priv->work, ravb_tx_timeout_work);

--
2.17.1

2781 - 2800 of 10169