Skip to contentSkip to conversation

net: ethernet: ti: am65-cpsw: update and enable sr2.0 soc

PATCH In review Grygorii Strashko 2 participants 8 messages Jun 26, 2020 – Jun 30, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover net: ethernet: ti: am65-cpsw: update and enable sr2.0 soc

Hi

This series contains set of improvements for TI AM654x/J721E CPSW2G driver and adds support for TI AM654x SR2.0 SoC.

Patch 1: adds vlans restoration after "if down/up"
Patches 2-5: improvments
Patch 6: adds support for TI AM654x SR2.0 SoC which allows to disable errata i2027 W/A. By default, errata i2027 W/A (TX csum offload disabled) is enabled on AM654x SoC for backward compatibility, unless SR2.0 SoC is identified using SOC BUS framework.

Grygorii Strashko (6):
net: ethernet: ti: am65-cpsw-nuss: restore vlan configuration while
down/up
net: ethernet: ti: am65-cpsw: move to pf_p0_rx_ptype_rrobin init in
probe
net: ethernet: ti: am65-cpsw-nuss: fix ports mac sl initialization
net: ethernet: ti: am65-cpsw-ethtool: skip hw cfg when change
p0-rx-ptype-rrobin
net: ethernet: ti: am65-cpsw-ethtool: configured critical setting only
when no running netdevs
net: ethernet: ti: am65-cpsw-nuss: enable am65x sr2.0 support

 drivers/net/ethernet/ti/am65-cpsw-ethtool.c |  6 +-
 drivers/net/ethernet/ti/am65-cpsw-nuss.c    | 77 +++++++++++++++++----
 drivers/net/ethernet/ti/am65-cpsw-nuss.h    |  2 +-
 3 files changed, 69 insertions(+), 16 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/6 net: ethernet: ti: am65-cpsw-nuss: restore vlan configuration while down/up

The vlan configuration is not restored after interface down/up sequence.

Steps to check:

 # ip link add link eth0 name eth0.100 type vlan id 100
 # ifconfig eth0 down
 # ifconfig eth0 up

This patch fixes it, restoring vlan ALE entries on .ndo_open().

Fixes 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/net/ethernet/ti/am65-cpsw-nuss.c +19 -0
index 1492648247d9..82d3b1f20890 100644
@@ -223,6 +223,9 @@ static int am65_cpsw_nuss_ndo_slave_add_vid(struct net_device *ndev,
 	u32 port_mask, unreg_mcast = 0;
 	int ret;
 
+	if (!netif_running(ndev) || !vid)
+		return 0;
+
 	ret = pm_runtime_get_sync(common->dev);
 	if (ret < 0) {
 		pm_runtime_put_noidle(common->dev);
@@ -246,6 +249,9 @@ static int am65_cpsw_nuss_ndo_slave_kill_vid(struct net_device *ndev,
 	struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
 	int ret;
 
+	if (!netif_running(ndev) || !vid)
+		return 0;
+
 	ret = pm_runtime_get_sync(common->dev);
 	if (ret < 0) {
 		pm_runtime_put_noidle(common->dev);
@@ -571,6 +577,16 @@ static int am65_cpsw_nuss_ndo_slave_stop(struct net_device *ndev)
 	return 0;
 }
 
+static int cpsw_restore_vlans(struct net_device *vdev, int vid, void *arg)
+{
+	struct am65_cpsw_port *port = arg;
+
+	if (!vdev)
+		return 0;
+
+	return am65_cpsw_nuss_ndo_slave_add_vid(port->ndev, 0, vid);
+}
+
 static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev)
 {
 	struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
@@ -644,6 +660,9 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev)
 		}
 	}
 
+	/* restore vlan configurations */
+	vlan_for_each(ndev, cpsw_restore_vlans, port);
+
 	phy_attached_info(port->slave.phy);
 	phy_start(port->slave.phy);
 
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/6 net: ethernet: ti: am65-cpsw: move to pf_p0_rx_ptype_rrobin init in probe

In reply to Grygorii Strashko

The pf_p0_rx_ptype_rrobin is global parameter so move its initialization in probe.

---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/ti/am65-cpsw-nuss.c +1 -2
index 82d3b1f20890..89ea29a26c3a 100644
@@ -1894,8 +1894,6 @@ static int am65_cpsw_nuss_init_ndev_2g(struct am65_cpsw_common *common)
 	netif_napi_add(port->ndev, &common->napi_rx,
 		       am65_cpsw_nuss_rx_poll, NAPI_POLL_WEIGHT);
 
-	common->pf_p0_rx_ptype_rrobin = false;
-
 	return ret;
 }
 
@@ -2038,6 +2036,7 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
 	common->rx_flow_id_base = -1;
 	init_completion(&common->tdown_complete);
 	common->tx_ch_num = 1;
+	common->pf_p0_rx_ptype_rrobin = false;
 
 	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(48));
 	if (ret) {
Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/6 net: ethernet: ti: am65-cpsw-nuss: fix ports mac sl initialization

In reply to Grygorii Strashko

The MAC SL has to be initialized for each port otherwise am65_cpsw_nuss_slave_disable_unused() will crash for disabled ports.

---
Not critical as current driver supports one port only.

 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/ti/am65-cpsw-nuss.c +4 -4
index 89ea29a26c3a..7a921a480f29 100644
@@ -1768,6 +1768,10 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
 				common->cpsw_base + AM65_CPSW_NU_FRAM_BASE +
 				(AM65_CPSW_NU_FRAM_PORT_OFFSET * (port_id - 1));
 
+		port->slave.mac_sl = cpsw_sl_get("am65", dev, port->port_base);
+		if (IS_ERR(port->slave.mac_sl))
+			return PTR_ERR(port->slave.mac_sl);
+
 		port->disabled = !of_device_is_available(port_np);
 		if (port->disabled)
 			continue;
@@ -1811,10 +1815,6 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
 			return ret;
 		}
 
-		port->slave.mac_sl = cpsw_sl_get("am65", dev, port->port_base);
-		if (IS_ERR(port->slave.mac_sl))
-			return PTR_ERR(port->slave.mac_sl);
-
 		mac_addr = of_get_mac_address(port_np);
 		if (!IS_ERR(mac_addr)) {
 			ether_addr_copy(port->slave.mac_addr, mac_addr);
Signature · 1 line
2.17.1
#4 lore raw

PATCH 4/6 net: ethernet: ti: am65-cpsw-ethtool: skip hw cfg when change p0-rx-ptype-rrobin

In reply to Grygorii Strashko

Skip HW configuration when p0-rx-ptype-rrobin is changed as it will be done by .ndev_open(),

---
 drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/ethernet/ti/am65-cpsw-ethtool.c +0 -1
index 8c4690f3ebcb..f7b33875a385 100644
@@ -741,7 +741,6 @@ static int am65_cpsw_set_ethtool_priv_flags(struct net_device *ndev, u32 flags)
 	}
 
 	common->pf_p0_rx_ptype_rrobin = rrobin;
-	am65_cpsw_nuss_set_p0_ptype(common);
 
 	return 0;
 }
Signature · 1 line
2.17.1
#5 lore raw

PATCH 5/6 net: ethernet: ti: am65-cpsw-ethtool: configured critical setting only when no running netdevs

In reply to Grygorii Strashko

Ensure that critical setting can only be configured when there are no running netdevs - all ports are down.

---
 drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/ti/am65-cpsw-ethtool.c +4 -1
index f7b33875a385..496dafb25128 100644
@@ -445,7 +445,7 @@ static int am65_cpsw_set_channels(struct net_device *ndev,
 	/* Check if interface is up. Can change the num queues when
 	 * the interface is down.
 	 */
-	if (netif_running(ndev))
+	if (common->usage_count)
 		return -EBUSY;
 
 	am65_cpsw_nuss_remove_tx_chns(common);
@@ -734,6 +734,9 @@ static int am65_cpsw_set_ethtool_priv_flags(struct net_device *ndev, u32 flags)
 
 	rrobin = !!(flags & AM65_CPSW_PRIV_P0_RX_PTYPE_RROBIN);
 
+	if (common->usage_count)
+		return -EBUSY;
+
 	if (common->est_enabled && rrobin) {
 		netdev_err(ndev,
 			   "p0-rx-ptype-rrobin flag conflicts with QOS\n");
Signature · 1 line
2.17.1
#6 lore raw

PATCH 6/6 net: ethernet: ti: am65-cpsw-nuss: enable am65x sr2.0 support

In reply to Grygorii Strashko

The AM65x SR2.0 MCU CPSW has fixed errata i2027 "CPSW: CPSW Does Not Support CPPI Receive Checksum (Host to Ethernet) Offload Feature". This errata also fixed for J271E SoC.

Use SOC bus data for K3 SoC identification and apply i2027 errata w/a only for the AM65x SR1.0 SoC.

---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 47 ++++++++++++++++++++----
 drivers/net/ethernet/ti/am65-cpsw-nuss.h |  2 +-
 2 files changed, 41 insertions(+), 8 deletions(-)
drivers/net/ethernet/ti/am65-cpsw-nuss.c +40 -7
index 7a921a480f29..9fdcd90e8323 100644
@@ -23,6 +23,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/mfd/syscon.h>
+#include <linux/sys_soc.h>
 #include <linux/dma/ti-cppi5.h>
 #include <linux/dma/k3-udma-glue.h>
 
@@ -148,10 +149,11 @@ static void am65_cpsw_nuss_get_ver(struct am65_cpsw_common *common)
 	common->nuss_ver = readl(common->ss_base);
 	common->cpsw_ver = readl(common->cpsw_base);
 	dev_info(common->dev,
-		 "initializing am65 cpsw nuss version 0x%08X, cpsw version 0x%08X Ports: %u\n",
+		 "initializing am65 cpsw nuss version 0x%08X, cpsw version 0x%08X Ports: %u quirks:%08x\n",
 		common->nuss_ver,
 		common->cpsw_ver,
-		common->port_num + 1);
+		common->port_num + 1,
+		common->pdata.quirks);
 }
 
 void am65_cpsw_nuss_adjust_link(struct net_device *ndev)
@@ -1877,7 +1879,7 @@ static int am65_cpsw_nuss_init_ndev_2g(struct am65_cpsw_common *common)
 	port->ndev->ethtool_ops = &am65_cpsw_ethtool_ops_slave;
 
 	/* Disable TX checksum offload by default due to HW bug */
-	if (common->pdata->quirks & AM65_CPSW_QUIRK_I2027_NO_TX_CSUM)
+	if (common->pdata.quirks & AM65_CPSW_QUIRK_I2027_NO_TX_CSUM)
 		port->ndev->features &= ~NETIF_F_HW_CSUM;
 
 	ndev_priv->stats = netdev_alloc_pcpu_stats(struct am65_cpsw_ndev_stats);
@@ -1981,21 +1983,50 @@ static void am65_cpsw_nuss_cleanup_ndev(struct am65_cpsw_common *common)
 	}
 }
 
+struct am65_cpsw_soc_pdata {
+	u32	quirks_dis;
+};
+
+static const struct am65_cpsw_soc_pdata am65x_soc_sr2_0 = {
+	.quirks_dis = AM65_CPSW_QUIRK_I2027_NO_TX_CSUM,
+};
+
+static const struct soc_device_attribute am65_cpsw_socinfo[] = {
+	{ .family = "AM65X",
+	  .revision = "SR2.0",
+	  .data = &am65x_soc_sr2_0
+	},
+	{/* sentinel */}
+};
+
 static const struct am65_cpsw_pdata am65x_sr1_0 = {
 	.quirks = AM65_CPSW_QUIRK_I2027_NO_TX_CSUM,
 };
 
-static const struct am65_cpsw_pdata j721e_sr1_0 = {
+static const struct am65_cpsw_pdata j721e_pdata = {
 	.quirks = 0,
 };
 
 static const struct of_device_id am65_cpsw_nuss_of_mtable[] = {
-	{ .compatible = "ti,am654-cpsw-nuss", .data = &am65x_sr1_0 },
-	{ .compatible = "ti,j721e-cpsw-nuss", .data = &j721e_sr1_0 },
+	{ .compatible = "ti,am654-cpsw-nuss", .data = &am65x_sr1_0},
+	{ .compatible = "ti,j721e-cpsw-nuss", .data = &j721e_pdata},
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, am65_cpsw_nuss_of_mtable);
 
+static void am65_cpsw_nuss_apply_socinfo(struct am65_cpsw_common *common)
+{
+	const struct soc_device_attribute *soc;
+
+	soc = soc_device_match(am65_cpsw_socinfo);
+	if (soc && soc->data) {
+		const struct am65_cpsw_soc_pdata *socdata = soc->data;
+
+		/* disable quirks */
+		common->pdata.quirks &= ~socdata->quirks_dis;
+	}
+}
+
 static int am65_cpsw_nuss_probe(struct platform_device *pdev)
 {
 	struct cpsw_ale_params ale_params = { 0 };
@@ -2014,7 +2045,9 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
 	of_id = of_match_device(am65_cpsw_nuss_of_mtable, dev);
 	if (!of_id)
 		return -EINVAL;
-	common->pdata = of_id->data;
+	common->pdata = *(const struct am65_cpsw_pdata *)of_id->data;
+
+	am65_cpsw_nuss_apply_socinfo(common);
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cpsw_nuss");
 	common->ss_base = devm_ioremap_resource(&pdev->dev, res);
drivers/net/ethernet/ti/am65-cpsw-nuss.h +1 -1
index 9faf4fb1409b..94f666ea0e53 100644
@@ -82,7 +82,7 @@ struct am65_cpsw_pdata {
 struct am65_cpsw_common {
 	struct device		*dev;
 	struct device		*mdio_dev;
-	const struct am65_cpsw_pdata *pdata;
+	struct am65_cpsw_pdata	pdata;
 
 	void __iomem		*ss_base;
 	void __iomem		*cpsw_base;
Signature · 1 line
2.17.1
maintainer
#7 lore raw
In reply to Grygorii Strashko

From: Grygorii Strashko <[email protected]>
Date: Fri, 26 Jun 2020 21:17:03 +0300

Quoted 8 lines

This series contains set of improvements for TI AM654x/J721E CPSW2G driver and adds support for TI AM654x SR2.0 SoC.

Patch 1: adds vlans restoration after "if down/up"
Patches 2-5: improvments
Patch 6: adds support for TI AM654x SR2.0 SoC which allows to disable errata i2027 W/A. By default, errata i2027 W/A (TX csum offload disabled) is enabled on AM654x SoC for backward compatibility, unless SR2.0 SoC is identified using SOC BUS framework.

Series applied to net-next, thank you.