2015-05-06 16:58:06

by Harini Katakam

[permalink] [raw]
Subject: [net-next PATCH v3 1/4] devicetree: Add compatible string for Zynq Ultrascale+ MPSoC

Add "cdns,zynqmp-gem" to be used for Zynq Ultrascale+ MPSoC.

Signed-off-by: Harini Katakam <[email protected]>
Reviewed-by: Punnaiah Choudary Kalluri <[email protected]>
---

v3:
No changes

v2:
Updated SoC name

---
Documentation/devicetree/bindings/net/macb.txt | 1 +
1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/net/macb.txt b/Documentation/devicetree/bindings/net/macb.txt
index ba19d67..8ec5fdf 100644
--- a/Documentation/devicetree/bindings/net/macb.txt
+++ b/Documentation/devicetree/bindings/net/macb.txt
@@ -9,6 +9,7 @@ Required properties:
the Cadence GEM, or the generic form: "cdns,gem".
Use "cdns,sama5d3-gem" for the Gigabit IP available on Atmel sama5d3 SoCs.
Use "cdns,sama5d4-gem" for the Gigabit IP available on Atmel sama5d4 SoCs.
+ Use "cdns,zynqmp-gem" for Zynq Ultrascale+ MPSoC.
- reg: Address and length of the register set for the device
- interrupts: Should contain macb interrupt
- phy-mode: See ethernet.txt file in the same directory.
--
1.7.9.5


2015-05-06 16:57:47

by Harini Katakam

[permalink] [raw]
Subject: [net-next PATCH v3 2/4] net: macb: Add compatible string for Zynq Ultrascale+ MPSoC

Add compatible string and config structure for Zynq Ultrascale+ MPSoC

Signed-off-by: Harini Katakam <[email protected]>
Reviewed-by: Punnaiah Choudary Kalluri <[email protected]>
---

Added in v3

---
drivers/net/ethernet/cadence/macb.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 4104d49..bbe5656 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -2684,6 +2684,13 @@ static const struct macb_config emac_config = {
.init = at91ether_init,
};

+static const struct macb_config zynqmp_config = {
+ .caps = MACB_CAPS_SG_DISABLED | MACB_CAPS_GIGABIT_MODE_AVAILABLE,
+ .dma_burst_length = 16,
+ .clk_init = macb_clk_init,
+ .init = macb_init,
+};
+
static const struct of_device_id macb_dt_ids[] = {
{ .compatible = "cdns,at32ap7000-macb" },
{ .compatible = "cdns,at91sam9260-macb", .data = &at91sam9260_config },
@@ -2694,6 +2701,7 @@ static const struct of_device_id macb_dt_ids[] = {
{ .compatible = "atmel,sama5d4-gem", .data = &sama5d4_config },
{ .compatible = "cdns,at91rm9200-emac", .data = &emac_config },
{ .compatible = "cdns,emac", .data = &emac_config },
+ { .compatible = "cdns,zynqmp-gem", .data = &zynqmp_config},
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, macb_dt_ids);
--
1.7.9.5

2015-05-06 17:12:01

by Harini Katakam

[permalink] [raw]
Subject: [net-next PATCH v3 3/4] net: macb: Add support for jumbo frames

Enable jumbo frame support for Zynq Ultrascale+ MPSoC.
Update the NWCFG register and descriptor length masks accordingly.
Jumbo max length register should be set according to support in SoC; it is
set to 10240 for Zynq Ultrascale+ MPSoC.

Signed-off-by: Harini Katakam <[email protected]>
Reviewed-by: Punnaiah Choudary Kalluri <[email protected]>
---

v3:
Use macb_config for declaring jumbo capability and max size.

v2:
Add constant definition and update SoC name

---
drivers/net/ethernet/cadence/macb.c | 22 ++++++++++++++++++----
drivers/net/ethernet/cadence/macb.h | 9 +++++++++
2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index bbe5656..cb84587 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -782,7 +782,7 @@ static int gem_rx(struct macb *bp, int budget)
}
/* now everything is ready for receiving packet */
bp->rx_skbuff[entry] = NULL;
- len = MACB_BFEXT(RX_FRMLEN, ctrl);
+ len = ctrl & bp->rx_frm_len_mask;

netdev_vdbg(bp->dev, "gem_rx %u (len %u)\n", entry, len);

@@ -828,7 +828,7 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
struct macb_dma_desc *desc;

desc = macb_rx_desc(bp, last_frag);
- len = MACB_BFEXT(RX_FRMLEN, desc->ctrl);
+ len = desc->ctrl & bp->rx_frm_len_mask;

netdev_vdbg(bp->dev, "macb_rx_frame frags %u - %u (len %u)\n",
macb_rx_ring_wrap(first_frag),
@@ -1633,7 +1633,10 @@ static void macb_init_hw(struct macb *bp)
config |= MACB_BF(RBOF, NET_IP_ALIGN); /* Make eth data aligned */
config |= MACB_BIT(PAE); /* PAuse Enable */
config |= MACB_BIT(DRFCS); /* Discard Rx FCS */
- config |= MACB_BIT(BIG); /* Receive oversized frames */
+ if (bp->caps | MACB_CAPS_JUMBO)
+ config |= MACB_BIT(JFRAME); /* Enable jumbo frames */
+ else
+ config |= MACB_BIT(BIG); /* Receive oversized frames */
if (bp->dev->flags & IFF_PROMISC)
config |= MACB_BIT(CAF); /* Copy All Frames */
else if (macb_is_gem(bp) && bp->dev->features & NETIF_F_RXCSUM)
@@ -1642,8 +1645,13 @@ static void macb_init_hw(struct macb *bp)
config |= MACB_BIT(NBC); /* No BroadCast */
config |= macb_dbw(bp);
macb_writel(bp, NCFGR, config);
+ if ((bp->caps | MACB_CAPS_JUMBO) && bp->jumbo_max_len)
+ gem_writel(bp, JML, bp->jumbo_max_len);
bp->speed = SPEED_10;
bp->duplex = DUPLEX_HALF;
+ bp->rx_frm_len_mask = MACB_RX_FRMLEN_MASK;
+ if (bp->caps | MACB_CAPS_JUMBO)
+ bp->rx_frm_len_mask = MACB_RX_JFRMLEN_MASK;

macb_configure_dma(bp);

@@ -2685,10 +2693,12 @@ static const struct macb_config emac_config = {
};

static const struct macb_config zynqmp_config = {
- .caps = MACB_CAPS_SG_DISABLED | MACB_CAPS_GIGABIT_MODE_AVAILABLE,
+ .caps = MACB_CAPS_SG_DISABLED | MACB_CAPS_GIGABIT_MODE_AVAILABLE |
+ MACB_CAPS_JUMBO,
.dma_burst_length = 16,
.clk_init = macb_clk_init,
.init = macb_init,
+ .jumbo_max_len = 10240,
};

static const struct of_device_id macb_dt_ids[] = {
@@ -2770,6 +2780,10 @@ static int macb_probe(struct platform_device *pdev)
bp->pclk = pclk;
bp->hclk = hclk;
bp->tx_clk = tx_clk;
+ if (macb_config->jumbo_max_len) {
+ bp->jumbo_max_len = macb_config->jumbo_max_len;
+ }
+
spin_lock_init(&bp->lock);

/* setup capabilities */
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index eb7d76f..7d4ef51 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -71,6 +71,7 @@
#define GEM_NCFGR 0x0004 /* Network Config */
#define GEM_USRIO 0x000c /* User IO */
#define GEM_DMACFG 0x0010 /* DMA Configuration */
+#define GEM_JML 0x0048 /* Jumbo Max Length */
#define GEM_HRB 0x0080 /* Hash Bottom */
#define GEM_HRT 0x0084 /* Hash Top */
#define GEM_SA1B 0x0088 /* Specific1 Bottom */
@@ -397,6 +398,7 @@
#define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x20000000
#define MACB_CAPS_SG_DISABLED 0x40000000
#define MACB_CAPS_MACB_IS_GEM 0x80000000
+#define MACB_CAPS_JUMBO 0x00000008

/* Bit manipulation macros */
#define MACB_BIT(name) \
@@ -514,6 +516,9 @@ struct macb_dma_desc {
#define MACB_RX_BROADCAST_OFFSET 31
#define MACB_RX_BROADCAST_SIZE 1

+#define MACB_RX_FRMLEN_MASK 0xFFF
+#define MACB_RX_JFRMLEN_MASK 0x3FFF
+
/* RX checksum offload disabled: bit 24 clear in NCFGR */
#define GEM_RX_TYPEID_MATCH_OFFSET 22
#define GEM_RX_TYPEID_MATCH_SIZE 2
@@ -757,6 +762,7 @@ struct macb_config {
int (*clk_init)(struct platform_device *pdev, struct clk **pclk,
struct clk **hclk, struct clk **tx_clk);
int (*init)(struct platform_device *pdev);
+ int jumbo_max_len;
};

struct macb_queue {
@@ -826,6 +832,9 @@ struct macb {
unsigned int max_tx_length;

u64 ethtool_stats[GEM_STATS_LEN];
+
+ unsigned int rx_frm_len_mask;
+ unsigned int jumbo_max_len;
};

static inline bool macb_is_gem(struct macb *bp)
--
1.7.9.5

2015-05-06 17:15:04

by Harini Katakam

[permalink] [raw]
Subject: [net-next PATCH v3 4/4] net: macb: Add change_mtu callback with jumbo support

Add macb_change_mtu callback; if jumbo frame support is present allow
mtu size changes upto (jumbo max length allowed - headers).

Signed-off-by: Harini Katakam <[email protected]>
Reviewed-by: Punnaiah Choudary Kalluri <[email protected]>
---

v3:
Check for jumbo capability in macb_config.

v2:
Move constant definition.

---
drivers/net/ethernet/cadence/macb.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index cb84587..97c6646 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -54,6 +54,8 @@
#define MACB_MAX_TX_LEN ((unsigned int)((1 << MACB_TX_FRMLEN_SIZE) - 1))
#define GEM_MAX_TX_LEN ((unsigned int)((1 << GEM_TX_FRMLEN_SIZE) - 1))

+#define GEM_MTU_MIN_SIZE 68
+
/*
* Graceful stop timeouts in us. We should allow up to
* 1 frame time (10 Mbits/s, full-duplex, ignoring collisions)
@@ -1855,6 +1857,26 @@ static int macb_close(struct net_device *dev)
return 0;
}

+static int macb_change_mtu(struct net_device *dev, int new_mtu)
+{
+ struct macb *bp = netdev_priv(dev);
+ u32 max_mtu;
+
+ if (netif_running(dev))
+ return -EBUSY;
+
+ max_mtu = ETH_DATA_LEN;
+ if (bp->caps | MACB_CAPS_JUMBO)
+ max_mtu = gem_readl(bp, JML) - ETH_HLEN - ETH_FCS_LEN;
+
+ if ((new_mtu > max_mtu) || (new_mtu < GEM_MTU_MIN_SIZE))
+ return -EINVAL;
+
+ dev->mtu = new_mtu;
+
+ return 0;
+}
+
static void gem_update_stats(struct macb *bp)
{
int i;
@@ -2131,7 +2153,7 @@ static const struct net_device_ops macb_netdev_ops = {
.ndo_get_stats = macb_get_stats,
.ndo_do_ioctl = macb_ioctl,
.ndo_validate_addr = eth_validate_addr,
- .ndo_change_mtu = eth_change_mtu,
+ .ndo_change_mtu = macb_change_mtu,
.ndo_set_mac_address = eth_mac_addr,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = macb_poll_controller,
--
1.7.9.5

2015-05-09 21:43:15

by David Miller

[permalink] [raw]
Subject: Re: [net-next PATCH v3 1/4] devicetree: Add compatible string for Zynq Ultrascale+ MPSoC

From: Harini Katakam <[email protected]>
Date: Wed, 6 May 2015 22:27:15 +0530

> Add "cdns,zynqmp-gem" to be used for Zynq Ultrascale+ MPSoC.
>
> Signed-off-by: Harini Katakam <[email protected]>
> Reviewed-by: Punnaiah Choudary Kalluri <[email protected]>

Applied.

2015-05-09 21:43:22

by David Miller

[permalink] [raw]
Subject: Re: [net-next PATCH v3 2/4] net: macb: Add compatible string for Zynq Ultrascale+ MPSoC

From: Harini Katakam <[email protected]>
Date: Wed, 6 May 2015 22:27:16 +0530

> Add compatible string and config structure for Zynq Ultrascale+ MPSoC
>
> Signed-off-by: Harini Katakam <[email protected]>
> Reviewed-by: Punnaiah Choudary Kalluri <[email protected]>

Applied.

2015-05-09 21:43:32

by David Miller

[permalink] [raw]
Subject: Re: [net-next PATCH v3 3/4] net: macb: Add support for jumbo frames

From: Harini Katakam <[email protected]>
Date: Wed, 6 May 2015 22:27:17 +0530

> Enable jumbo frame support for Zynq Ultrascale+ MPSoC.
> Update the NWCFG register and descriptor length masks accordingly.
> Jumbo max length register should be set according to support in SoC; it is
> set to 10240 for Zynq Ultrascale+ MPSoC.
>
> Signed-off-by: Harini Katakam <[email protected]>
> Reviewed-by: Punnaiah Choudary Kalluri <[email protected]>

Applied.

2015-05-09 21:43:51

by David Miller

[permalink] [raw]
Subject: Re: [net-next PATCH v3 4/4] net: macb: Add change_mtu callback with jumbo support

From: Harini Katakam <[email protected]>
Date: Wed, 6 May 2015 22:27:18 +0530

> Add macb_change_mtu callback; if jumbo frame support is present allow
> mtu size changes upto (jumbo max length allowed - headers).
>
> Signed-off-by: Harini Katakam <[email protected]>
> Reviewed-by: Punnaiah Choudary Kalluri <[email protected]>

Applied.

2015-05-11 07:43:31

by Nicolas Ferre

[permalink] [raw]
Subject: Re: [net-next PATCH v3 1/4] devicetree: Add compatible string for Zynq Ultrascale+ MPSoC

Le 06/05/2015 18:57, Harini Katakam a ?crit :
> Add "cdns,zynqmp-gem" to be used for Zynq Ultrascale+ MPSoC.
>
> Signed-off-by: Harini Katakam <[email protected]>
> Reviewed-by: Punnaiah Choudary Kalluri <[email protected]>

I know it's too late, but for the record:
Acked-by: Nicolas Ferre <[email protected]>

Thanks for having re-spinned this series Harini.

Bye,


> ---
>
> v3:
> No changes
>
> v2:
> Updated SoC name
>
> ---
> Documentation/devicetree/bindings/net/macb.txt | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/net/macb.txt b/Documentation/devicetree/bindings/net/macb.txt
> index ba19d67..8ec5fdf 100644
> --- a/Documentation/devicetree/bindings/net/macb.txt
> +++ b/Documentation/devicetree/bindings/net/macb.txt
> @@ -9,6 +9,7 @@ Required properties:
> the Cadence GEM, or the generic form: "cdns,gem".
> Use "cdns,sama5d3-gem" for the Gigabit IP available on Atmel sama5d3 SoCs.
> Use "cdns,sama5d4-gem" for the Gigabit IP available on Atmel sama5d4 SoCs.
> + Use "cdns,zynqmp-gem" for Zynq Ultrascale+ MPSoC.
> - reg: Address and length of the register set for the device
> - interrupts: Should contain macb interrupt
> - phy-mode: See ethernet.txt file in the same directory.
>


--
Nicolas Ferre

2015-05-11 08:29:36

by Harini Katakam

[permalink] [raw]
Subject: Re: [net-next PATCH v3 1/4] devicetree: Add compatible string for Zynq Ultrascale+ MPSoC

On Mon, May 11, 2015 at 1:11 PM, Nicolas Ferre <[email protected]> wrote:
> Le 06/05/2015 18:57, Harini Katakam a écrit :
>> Add "cdns,zynqmp-gem" to be used for Zynq Ultrascale+ MPSoC.
>>
>> Signed-off-by: Harini Katakam <[email protected]>
>> Reviewed-by: Punnaiah Choudary Kalluri <[email protected]>
>
> I know it's too late, but for the record:
> Acked-by: Nicolas Ferre <[email protected]>

Thanks!

Regards,
Harini

>
> Thanks for having re-spinned this series Harini.
>
> Bye,
>
>
>> ---
>>
>> v3:
>> No changes
>>
>> v2:
>> Updated SoC name
>>
>> ---
>> Documentation/devicetree/bindings/net/macb.txt | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/Documentation/devicetree/bindings/net/macb.txt b/Documentation/devicetree/bindings/net/macb.txt
>> index ba19d67..8ec5fdf 100644
>> --- a/Documentation/devicetree/bindings/net/macb.txt
>> +++ b/Documentation/devicetree/bindings/net/macb.txt
>> @@ -9,6 +9,7 @@ Required properties:
>> the Cadence GEM, or the generic form: "cdns,gem".
>> Use "cdns,sama5d3-gem" for the Gigabit IP available on Atmel sama5d3 SoCs.
>> Use "cdns,sama5d4-gem" for the Gigabit IP available on Atmel sama5d4 SoCs.
>> + Use "cdns,zynqmp-gem" for Zynq Ultrascale+ MPSoC.
>> - reg: Address and length of the register set for the device
>> - interrupts: Should contain macb interrupt
>> - phy-mode: See ethernet.txt file in the same directory.
>>
>
>
> --
> Nicolas Ferre