netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] ftgmac100: Rework batch 5 - Features
@ 2017-04-12 22:44 Benjamin Herrenschmidt
  2017-04-12 22:44 ` [PATCH 1/8] ftgmac100: Add ethtool n-way reset call Benjamin Herrenschmidt
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-12 22:44 UTC (permalink / raw)
  To: netdev

This is fifth and last batch of updates to the ftgmac100 driver.

This contains a few additional "features" such as:

 - Support for ethtool n-way reset
 - Multicast filtering & promisc support
 - Vlan offload
 - netpoll

And a couple of misc bits. This also adds the device-tree binding
documentation.

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

* [PATCH 1/8] ftgmac100: Add ethtool n-way reset call
  2017-04-12 22:44 [PATCH 0/8] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
@ 2017-04-12 22:44 ` Benjamin Herrenschmidt
  2017-04-13  0:00   ` Florian Fainelli
  2017-04-12 22:44 ` [PATCH 2/8] ftgmac100: Add pause frames configuration and support Benjamin Herrenschmidt
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-12 22:44 UTC (permalink / raw)
  To: netdev; +Cc: Benjamin Herrenschmidt

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/net/ethernet/faraday/ftgmac100.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 796b37e..bbeb8e7 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1043,11 +1043,11 @@ static void ftgmac100_get_drvinfo(struct net_device *netdev,
 	strlcpy(info->bus_info, dev_name(&netdev->dev), sizeof(info->bus_info));
 }
 
-static int ftgmac100_nway_reset(struct net_device *ndev)
+static int ftgmac100_nway_reset(struct net_device *netdev)
 {
-	if (!ndev->phydev)
+	if (!netdev->phydev)
 		return -ENXIO;
-	return phy_start_aneg(ndev->phydev);
+	return phy_start_aneg(netdev->phydev);
 }
 
 static void ftgmac100_get_ringparam(struct net_device *netdev,
@@ -1088,6 +1088,7 @@ static const struct ethtool_ops ftgmac100_ethtool_ops = {
 	.get_link		= ethtool_op_get_link,
 	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
 	.set_link_ksettings	= phy_ethtool_set_link_ksettings,
+	.nway_reset		= ftgmac100_nway_reset,
 	.get_ringparam		= ftgmac100_get_ringparam,
 	.set_ringparam		= ftgmac100_set_ringparam,
 };
-- 
2.9.3

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

* [PATCH 2/8] ftgmac100: Add pause frames configuration and support
  2017-04-12 22:44 [PATCH 0/8] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
  2017-04-12 22:44 ` [PATCH 1/8] ftgmac100: Add ethtool n-way reset call Benjamin Herrenschmidt
@ 2017-04-12 22:44 ` Benjamin Herrenschmidt
  2017-04-12 22:44 ` [PATCH 3/8] ftgmac100: Add ndo_set_rx_mode() and support for multicast & promisc Benjamin Herrenschmidt
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-12 22:44 UTC (permalink / raw)
  To: netdev; +Cc: Benjamin Herrenschmidt

Hopefully my understanding of how the hardware works is correct,
as the documentation isn't completely clear. So far I have seen
no obvious issue. Pause seem to also work with NC-SI.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/net/ethernet/faraday/ftgmac100.c | 96 +++++++++++++++++++++++++++++++-
 drivers/net/ethernet/faraday/ftgmac100.h |  7 +++
 2 files changed, 102 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index bbeb8e7..4f3ec2c 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -97,6 +97,11 @@ struct ftgmac100 {
 	int cur_duplex;
 	bool use_ncsi;
 
+	/* Flow control settings */
+	bool tx_pause;
+	bool rx_pause;
+	bool aneg_pause;
+
 	/* Misc */
 	bool need_mac_restart;
 	bool is_aspeed;
@@ -217,6 +222,23 @@ static int ftgmac100_set_mac_addr(struct net_device *dev, void *p)
 	return 0;
 }
 
+static void ftgmac100_config_pause(struct ftgmac100 *priv)
+{
+	u32 fcr = FTGMAC100_FCR_PAUSE_TIME(16);
+
+	/* Throttle tx queue when receiving pause frames */
+	if (priv->rx_pause)
+		fcr |= FTGMAC100_FCR_FC_EN;
+
+	/* Enables sending pause frames when the RX queue is past a
+	 * certain threshold.
+	 */
+	if (priv->tx_pause)
+		fcr |= FTGMAC100_FCR_FCTHR_EN;
+
+	iowrite32(fcr, priv->base + FTGMAC100_OFFSET_FCR);
+}
+
 static void ftgmac100_init_hw(struct ftgmac100 *priv)
 {
 	u32 reg, rfifo_sz, tfifo_sz;
@@ -910,6 +932,7 @@ static void ftgmac100_adjust_link(struct net_device *netdev)
 {
 	struct ftgmac100 *priv = netdev_priv(netdev);
 	struct phy_device *phydev = netdev->phydev;
+	bool tx_pause, rx_pause;
 	int new_speed;
 
 	/* We store "no link" as speed 0 */
@@ -918,8 +941,21 @@ static void ftgmac100_adjust_link(struct net_device *netdev)
 	else
 		new_speed = phydev->speed;
 
+	/* Grab pause settings from PHY if configured to do so */
+	if (priv->aneg_pause) {
+		rx_pause = tx_pause = phydev->pause;
+		if (phydev->asym_pause)
+			tx_pause = !rx_pause;
+	} else {
+		rx_pause = priv->rx_pause;
+		tx_pause = priv->tx_pause;
+	}
+
+	/* Link hasn't changed, do nothing */
 	if (phydev->speed == priv->cur_speed &&
-	    phydev->duplex == priv->cur_duplex)
+	    phydev->duplex == priv->cur_duplex &&
+	    rx_pause == priv->rx_pause &&
+	    tx_pause == priv->tx_pause)
 		return;
 
 	/* Print status if we have a link or we had one and just lost it,
@@ -930,6 +966,8 @@ static void ftgmac100_adjust_link(struct net_device *netdev)
 
 	priv->cur_speed = new_speed;
 	priv->cur_duplex = phydev->duplex;
+	priv->rx_pause = rx_pause;
+	priv->tx_pause = tx_pause;
 
 	/* Link is down, do nothing else */
 	if (!new_speed)
@@ -961,6 +999,12 @@ static int ftgmac100_mii_probe(struct ftgmac100 *priv)
 		return PTR_ERR(phydev);
 	}
 
+	/* Indicate that we support PAUSE frames (see comment in
+	 * Documentation/networking/phy.txt)
+	 */
+	phydev->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
+	phydev->advertising = phydev->supported;
+
 	return 0;
 }
 
@@ -1083,6 +1127,48 @@ static int ftgmac100_set_ringparam(struct net_device *netdev,
 	return 0;
 }
 
+static void ftgmac100_get_pauseparam(struct net_device *netdev,
+				     struct ethtool_pauseparam *pause)
+{
+	struct ftgmac100 *priv = netdev_priv(netdev);
+
+	pause->autoneg = priv->aneg_pause;
+	pause->tx_pause = priv->tx_pause;
+	pause->rx_pause = priv->rx_pause;
+}
+
+static int ftgmac100_set_pauseparam(struct net_device *netdev,
+				    struct ethtool_pauseparam *pause)
+{
+	struct ftgmac100 *priv = netdev_priv(netdev);
+	struct phy_device *phydev = netdev->phydev;
+
+	priv->aneg_pause = pause->autoneg;
+	priv->tx_pause = pause->tx_pause;
+	priv->rx_pause = pause->rx_pause;
+
+	if (phydev) {
+		phydev->advertising &= ~ADVERTISED_Pause;
+		phydev->advertising &= ~ADVERTISED_Asym_Pause;
+
+		if (pause->rx_pause) {
+			phydev->advertising |= ADVERTISED_Pause;
+			phydev->advertising |= ADVERTISED_Asym_Pause;
+		}
+
+		if (pause->tx_pause)
+			phydev->advertising ^= ADVERTISED_Asym_Pause;
+	}
+	if (netif_running(netdev)) {
+		if (phydev && priv->aneg_pause)
+			phy_start_aneg(phydev);
+		else
+			ftgmac100_config_pause(priv);
+	}
+
+	return 0;
+}
+
 static const struct ethtool_ops ftgmac100_ethtool_ops = {
 	.get_drvinfo		= ftgmac100_get_drvinfo,
 	.get_link		= ethtool_op_get_link,
@@ -1091,6 +1177,8 @@ static const struct ethtool_ops ftgmac100_ethtool_ops = {
 	.nway_reset		= ftgmac100_nway_reset,
 	.get_ringparam		= ftgmac100_get_ringparam,
 	.set_ringparam		= ftgmac100_set_ringparam,
+	.get_pauseparam		= ftgmac100_get_pauseparam,
+	.set_pauseparam		= ftgmac100_set_pauseparam,
 };
 
 static irqreturn_t ftgmac100_interrupt(int irq, void *dev_id)
@@ -1222,6 +1310,7 @@ static int ftgmac100_init_all(struct ftgmac100 *priv, bool ignore_alloc_err)
 
 	/* Reinit and restart HW */
 	ftgmac100_init_hw(priv);
+	ftgmac100_config_pause(priv);
 	ftgmac100_start_hw(priv);
 
 	/* Re-enable the device */
@@ -1551,6 +1640,11 @@ static int ftgmac100_probe(struct platform_device *pdev)
 
 	netdev->irq = irq;
 
+	/* Enable pause */
+	priv->tx_pause = true;
+	priv->rx_pause = true;
+	priv->aneg_pause = true;
+
 	/* MAC address from chip or random one */
 	ftgmac100_initial_mac(priv);
 
diff --git a/drivers/net/ethernet/faraday/ftgmac100.h b/drivers/net/ethernet/faraday/ftgmac100.h
index 97912c4..0653d81 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.h
+++ b/drivers/net/ethernet/faraday/ftgmac100.h
@@ -199,6 +199,13 @@
 #define FTGMAC100_PHYDATA_MIIRDATA(phydata)	(((phydata) >> 16) & 0xffff)
 
 /*
+ * Flow control register
+ */
+#define FTGMAC100_FCR_FC_EN		(1 << 0)
+#define FTGMAC100_FCR_FCTHR_EN		(1 << 2)
+#define FTGMAC100_FCR_PAUSE_TIME(x)	(((x) & 0xffff) << 16)
+
+/*
  * Transmit descriptor, aligned to 16 bytes
  */
 struct ftgmac100_txdes {
-- 
2.9.3

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

* [PATCH 3/8] ftgmac100: Add ndo_set_rx_mode() and support for multicast & promisc
  2017-04-12 22:44 [PATCH 0/8] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
  2017-04-12 22:44 ` [PATCH 1/8] ftgmac100: Add ethtool n-way reset call Benjamin Herrenschmidt
  2017-04-12 22:44 ` [PATCH 2/8] ftgmac100: Add pause frames configuration and support Benjamin Herrenschmidt
@ 2017-04-12 22:44 ` Benjamin Herrenschmidt
  2017-04-12 22:44 ` [PATCH 4/8] ftgmac100: Add vlan HW offload Benjamin Herrenschmidt
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-12 22:44 UTC (permalink / raw)
  To: netdev; +Cc: Benjamin Herrenschmidt

This adds the ndo_set_rx_mode() callback to configure the
multicast filters, promisc and allmulti options.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/net/ethernet/faraday/ftgmac100.c | 52 ++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 4f3ec2c..d86b27f 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -30,6 +30,7 @@
 #include <linux/netdevice.h>
 #include <linux/phy.h>
 #include <linux/platform_device.h>
+#include <linux/crc32.h>
 #include <net/ip.h>
 #include <net/ncsi.h>
 
@@ -97,6 +98,10 @@ struct ftgmac100 {
 	int cur_duplex;
 	bool use_ncsi;
 
+	/* Multicast filter settings */
+	u32 maht0;
+	u32 maht1;
+
 	/* Flow control settings */
 	bool tx_pause;
 	bool rx_pause;
@@ -264,6 +269,10 @@ static void ftgmac100_init_hw(struct ftgmac100 *priv)
 	/* Write MAC address */
 	ftgmac100_write_mac_addr(priv, priv->netdev->dev_addr);
 
+	/* Write multicast filter */
+	iowrite32(priv->maht0, priv->base + FTGMAC100_OFFSET_MAHT0);
+	iowrite32(priv->maht1, priv->base + FTGMAC100_OFFSET_MAHT1);
+
 	/* Configure descriptor sizes and increase burst sizes according
 	 * to values in Aspeed SDK. The FIFO arbitration is enabled and
 	 * the thresholds set based on the recommended values in the
@@ -317,6 +326,12 @@ static void ftgmac100_start_hw(struct ftgmac100 *priv)
 	/* Add other bits as needed */
 	if (priv->cur_duplex == DUPLEX_FULL)
 		maccr |= FTGMAC100_MACCR_FULLDUP;
+	if (priv->netdev->flags & IFF_PROMISC)
+		maccr |= FTGMAC100_MACCR_RX_ALL;
+	if (priv->netdev->flags & IFF_ALLMULTI)
+		maccr |= FTGMAC100_MACCR_RX_MULTIPKT;
+	else if (netdev_mc_count(priv->netdev))
+		maccr |= FTGMAC100_MACCR_HT_MULTI_EN;
 
 	/* Hit the HW */
 	iowrite32(maccr, priv->base + FTGMAC100_OFFSET_MACCR);
@@ -327,6 +342,42 @@ static void ftgmac100_stop_hw(struct ftgmac100 *priv)
 	iowrite32(0, priv->base + FTGMAC100_OFFSET_MACCR);
 }
 
+static void ftgmac100_calc_mc_hash(struct ftgmac100 *priv)
+{
+	struct netdev_hw_addr *ha;
+
+	priv->maht1 = 0;
+	priv->maht0 = 0;
+	netdev_for_each_mc_addr(ha, priv->netdev) {
+		u32 crc_val = ether_crc_le(ETH_ALEN, ha->addr);
+
+		crc_val = (~(crc_val >> 2)) & 0x3f;
+		if (crc_val >= 32)
+			priv->maht1 |= 1ul << (crc_val - 32);
+		else
+			priv->maht0 |= 1ul << (crc_val);
+	}
+}
+
+static void ftgmac100_set_rx_mode(struct net_device *netdev)
+{
+	struct ftgmac100 *priv = netdev_priv(netdev);
+
+	/* Setup the hash filter */
+	ftgmac100_calc_mc_hash(priv);
+
+	/* Interface down ? that's all there is to do */
+	if (!netif_running(netdev))
+		return;
+
+	/* Update the HW */
+	iowrite32(priv->maht0, priv->base + FTGMAC100_OFFSET_MAHT0);
+	iowrite32(priv->maht1, priv->base + FTGMAC100_OFFSET_MAHT1);
+
+	/* Reconfigure MACCR */
+	ftgmac100_start_hw(priv);
+}
+
 static int ftgmac100_alloc_rx_buf(struct ftgmac100 *priv, unsigned int entry,
 				  struct ftgmac100_rxdes *rxdes, gfp_t gfp)
 {
@@ -1508,6 +1559,7 @@ static const struct net_device_ops ftgmac100_netdev_ops = {
 	.ndo_validate_addr	= eth_validate_addr,
 	.ndo_do_ioctl		= ftgmac100_do_ioctl,
 	.ndo_tx_timeout		= ftgmac100_tx_timeout,
+	.ndo_set_rx_mode	= ftgmac100_set_rx_mode,
 };
 
 static int ftgmac100_setup_mdio(struct net_device *netdev)
-- 
2.9.3

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

* [PATCH 4/8] ftgmac100: Add vlan HW offload
  2017-04-12 22:44 [PATCH 0/8] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
                   ` (2 preceding siblings ...)
  2017-04-12 22:44 ` [PATCH 3/8] ftgmac100: Add ndo_set_rx_mode() and support for multicast & promisc Benjamin Herrenschmidt
@ 2017-04-12 22:44 ` Benjamin Herrenschmidt
  2017-04-12 22:44 ` [PATCH 5/8] ftgmac100: Add netpoll support Benjamin Herrenschmidt
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-12 22:44 UTC (permalink / raw)
  To: netdev; +Cc: Benjamin Herrenschmidt

The chip supports HW vlan tag insertion and extraction. Add support
for it.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/net/ethernet/faraday/ftgmac100.c | 46 +++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index d86b27f..ded3447 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -31,6 +31,7 @@
 #include <linux/phy.h>
 #include <linux/platform_device.h>
 #include <linux/crc32.h>
+#include <linux/if_vlan.h>
 #include <net/ip.h>
 #include <net/ncsi.h>
 
@@ -333,6 +334,10 @@ static void ftgmac100_start_hw(struct ftgmac100 *priv)
 	else if (netdev_mc_count(priv->netdev))
 		maccr |= FTGMAC100_MACCR_HT_MULTI_EN;
 
+	/* Vlan filtering enabled */
+	if (priv->netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
+		maccr |= FTGMAC100_MACCR_RM_VLAN;
+
 	/* Hit the HW */
 	iowrite32(maccr, priv->base + FTGMAC100_OFFSET_MACCR);
 }
@@ -528,6 +533,12 @@ static bool ftgmac100_rx_packet(struct ftgmac100 *priv, int *processed)
 	/* Transfer received size to skb */
 	skb_put(skb, size);
 
+	/* Extract vlan tag */
+	if ((netdev->features & NETIF_F_HW_VLAN_CTAG_RX) &&
+	    (csum_vlan & FTGMAC100_RXDES1_VLANTAG_AVAIL))
+		__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
+				       csum_vlan & 0xffff);
+
 	/* Tear down DMA mapping, do necessary cache management */
 	map = le32_to_cpu(rxdes->rxdes3);
 
@@ -752,6 +763,13 @@ static int ftgmac100_hard_start_xmit(struct sk_buff *skb,
 	if (skb->ip_summed == CHECKSUM_PARTIAL &&
 	    !ftgmac100_prep_tx_csum(skb, &csum_vlan))
 		goto drop;
+
+	/* Add VLAN tag */
+	if (skb_vlan_tag_present(skb)) {
+		csum_vlan |= FTGMAC100_TXDES1_INS_VLANTAG;
+		csum_vlan |= skb_vlan_tag_get(skb) & 0xffff;
+	}
+
 	txdes->txdes1 = cpu_to_le32(csum_vlan);
 
 	/* Next descriptor */
@@ -1551,6 +1569,30 @@ static void ftgmac100_tx_timeout(struct net_device *netdev)
 	schedule_work(&priv->reset_task);
 }
 
+static int ftgmac100_set_features(struct net_device *netdev,
+				  netdev_features_t features)
+{
+	struct ftgmac100 *priv = netdev_priv(netdev);
+	netdev_features_t changed = netdev->features ^ features;
+
+	if (!netif_running(netdev))
+		return 0;
+
+	/* Update the vlan filtering bit */
+	if (changed & NETIF_F_HW_VLAN_CTAG_RX) {
+		u32 maccr;
+
+		maccr = ioread32(priv->base + FTGMAC100_OFFSET_MACCR);
+		if (priv->netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
+			maccr |= FTGMAC100_MACCR_RM_VLAN;
+		else
+			maccr &= ~FTGMAC100_MACCR_RM_VLAN;
+		iowrite32(maccr, priv->base + FTGMAC100_OFFSET_MACCR);
+	}
+
+	return 0;
+}
+
 static const struct net_device_ops ftgmac100_netdev_ops = {
 	.ndo_open		= ftgmac100_open,
 	.ndo_stop		= ftgmac100_stop,
@@ -1560,6 +1602,7 @@ static const struct net_device_ops ftgmac100_netdev_ops = {
 	.ndo_do_ioctl		= ftgmac100_do_ioctl,
 	.ndo_tx_timeout		= ftgmac100_tx_timeout,
 	.ndo_set_rx_mode	= ftgmac100_set_rx_mode,
+	.ndo_set_features	= ftgmac100_set_features,
 };
 
 static int ftgmac100_setup_mdio(struct net_device *netdev)
@@ -1735,7 +1778,8 @@ static int ftgmac100_probe(struct platform_device *pdev)
 
 	/* Base feature set */
 	netdev->hw_features = NETIF_F_RXCSUM | NETIF_F_HW_CSUM |
-		NETIF_F_GRO | NETIF_F_SG;
+		NETIF_F_GRO | NETIF_F_SG | NETIF_F_HW_VLAN_CTAG_RX |
+		NETIF_F_HW_VLAN_CTAG_TX;
 
 	/* AST2400  doesn't have working HW checksum generation */
 	if (np && (of_device_is_compatible(np, "aspeed,ast2400-mac")))
-- 
2.9.3

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

* [PATCH 5/8] ftgmac100: Add netpoll support
  2017-04-12 22:44 [PATCH 0/8] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
                   ` (3 preceding siblings ...)
  2017-04-12 22:44 ` [PATCH 4/8] ftgmac100: Add vlan HW offload Benjamin Herrenschmidt
@ 2017-04-12 22:44 ` Benjamin Herrenschmidt
  2017-04-12 22:44 ` [PATCH 6/8] ftgmac100: Allow configuration of phy interface via device-tree Benjamin Herrenschmidt
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-12 22:44 UTC (permalink / raw)
  To: netdev; +Cc: Benjamin Herrenschmidt

Just call the interrupt handler with interrupts locally disabled

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/net/ethernet/faraday/ftgmac100.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index ded3447..e71b9c4 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1593,6 +1593,17 @@ static int ftgmac100_set_features(struct net_device *netdev,
 	return 0;
 }
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void ftgmac100_poll_controller(struct net_device *netdev)
+{
+	unsigned long flags;
+
+	local_irq_save(flags);
+	ftgmac100_interrupt(netdev->irq, netdev);
+	local_irq_restore(flags);
+}
+#endif
+
 static const struct net_device_ops ftgmac100_netdev_ops = {
 	.ndo_open		= ftgmac100_open,
 	.ndo_stop		= ftgmac100_stop,
@@ -1603,6 +1614,9 @@ static const struct net_device_ops ftgmac100_netdev_ops = {
 	.ndo_tx_timeout		= ftgmac100_tx_timeout,
 	.ndo_set_rx_mode	= ftgmac100_set_rx_mode,
 	.ndo_set_features	= ftgmac100_set_features,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	.ndo_poll_controller	= ftgmac100_poll_controller,
+#endif
 };
 
 static int ftgmac100_setup_mdio(struct net_device *netdev)
-- 
2.9.3

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

* [PATCH 6/8] ftgmac100: Allow configuration of phy interface via device-tree
  2017-04-12 22:44 [PATCH 0/8] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
                   ` (4 preceding siblings ...)
  2017-04-12 22:44 ` [PATCH 5/8] ftgmac100: Add netpoll support Benjamin Herrenschmidt
@ 2017-04-12 22:44 ` Benjamin Herrenschmidt
  2017-04-13 13:40   ` Andrew Lunn
  2017-04-12 22:44 ` [PATCH 7/8] ftgmac100: Display the discovered PHY device info Benjamin Herrenschmidt
  2017-04-12 22:44 ` [PATCH 8/8] ftgmac100: Document device-tree binding Benjamin Herrenschmidt
  7 siblings, 1 reply; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-12 22:44 UTC (permalink / raw)
  To: netdev; +Cc: Benjamin Herrenschmidt

This uses the standard phy-mode property

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/net/ethernet/faraday/ftgmac100.c | 42 +++++++++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index e71b9c4..c1afda8 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -32,6 +32,7 @@
 #include <linux/platform_device.h>
 #include <linux/crc32.h>
 #include <linux/if_vlan.h>
+#include <linux/of_net.h>
 #include <net/ip.h>
 #include <net/ncsi.h>
 
@@ -1049,7 +1050,7 @@ static void ftgmac100_adjust_link(struct net_device *netdev)
 	schedule_work(&priv->reset_task);
 }
 
-static int ftgmac100_mii_probe(struct ftgmac100 *priv)
+static int ftgmac100_mii_probe(struct ftgmac100 *priv, phy_interface_t intf)
 {
 	struct net_device *netdev = priv->netdev;
 	struct phy_device *phydev;
@@ -1061,7 +1062,7 @@ static int ftgmac100_mii_probe(struct ftgmac100 *priv)
 	}
 
 	phydev = phy_connect(netdev, phydev_name(phydev),
-			     &ftgmac100_adjust_link, PHY_INTERFACE_MODE_GMII);
+			     &ftgmac100_adjust_link, intf);
 
 	if (IS_ERR(phydev)) {
 		netdev_err(netdev, "%s: Could not attach to PHY\n", netdev->name);
@@ -1623,6 +1624,8 @@ static int ftgmac100_setup_mdio(struct net_device *netdev)
 {
 	struct ftgmac100 *priv = netdev_priv(netdev);
 	struct platform_device *pdev = to_platform_device(priv->dev);
+	int phy_intf = PHY_INTERFACE_MODE_RGMII;
+	struct device_node *np = pdev->dev.of_node;
 	int i, err = 0;
 	u32 reg;
 
@@ -1638,6 +1641,39 @@ static int ftgmac100_setup_mdio(struct net_device *netdev)
 		iowrite32(reg, priv->base + FTGMAC100_OFFSET_REVR);
 	};
 
+	/* Get PHY mode from device-tree */
+	if (np) {
+		/* Default to RGMII. It's a gigabit part after all */
+		phy_intf = of_get_phy_mode(np);
+		if (phy_intf < 0)
+			phy_intf = PHY_INTERFACE_MODE_RGMII;
+
+		/* Aspeed only supports these. I don't know about other IP
+		 * block vendors so I'm going to just let them through for
+		 * now. Note that this is only a warning if for some obscure
+		 * reason the DT really means to lie about it or it's a newer
+		 * part we don't know about.
+		 *
+		 * On the Aspeed SoC there are additionally straps and SCU
+		 * control bits that could tell us what the interface is
+		 * (or allow us to configure it while the IP block is held
+		 * in reset). For now I chose to keep this driver away from
+		 * those SoC specific bits and assume the device-tree is
+		 * right and the SCU has been configured properly by pinmux
+		 * or the firmware.
+		 */
+		if (priv->is_aspeed &&
+		    phy_intf != PHY_INTERFACE_MODE_RMII &&
+		    phy_intf != PHY_INTERFACE_MODE_RGMII &&
+		    phy_intf != PHY_INTERFACE_MODE_RGMII_ID &&
+		    phy_intf != PHY_INTERFACE_MODE_RGMII_RXID &&
+		    phy_intf != PHY_INTERFACE_MODE_RGMII_TXID) {
+			netdev_warn(netdev,
+				   "Unsupported PHY mode %s !\n",
+				   phy_modes(phy_intf));
+		}
+	}
+
 	priv->mii_bus->name = "ftgmac100_mdio";
 	snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%d",
 		 pdev->name, pdev->id);
@@ -1654,7 +1690,7 @@ static int ftgmac100_setup_mdio(struct net_device *netdev)
 		goto err_register_mdiobus;
 	}
 
-	err = ftgmac100_mii_probe(priv);
+	err = ftgmac100_mii_probe(priv, phy_intf);
 	if (err) {
 		dev_err(priv->dev, "MII Probe failed!\n");
 		goto err_mii_probe;
-- 
2.9.3

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

* [PATCH 7/8] ftgmac100: Display the discovered PHY device info
  2017-04-12 22:44 [PATCH 0/8] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
                   ` (5 preceding siblings ...)
  2017-04-12 22:44 ` [PATCH 6/8] ftgmac100: Allow configuration of phy interface via device-tree Benjamin Herrenschmidt
@ 2017-04-12 22:44 ` Benjamin Herrenschmidt
  2017-04-13 13:40   ` Andrew Lunn
  2017-04-12 22:44 ` [PATCH 8/8] ftgmac100: Document device-tree binding Benjamin Herrenschmidt
  7 siblings, 1 reply; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-12 22:44 UTC (permalink / raw)
  To: netdev; +Cc: Benjamin Herrenschmidt

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/net/ethernet/faraday/ftgmac100.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index c1afda8..d04ad31 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1075,6 +1075,9 @@ static int ftgmac100_mii_probe(struct ftgmac100 *priv, phy_interface_t intf)
 	phydev->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
 	phydev->advertising = phydev->supported;
 
+	/* Display what we found */
+	phy_attached_info(phydev);
+
 	return 0;
 }
 
-- 
2.9.3

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

* [PATCH 8/8] ftgmac100: Document device-tree binding
  2017-04-12 22:44 [PATCH 0/8] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
                   ` (6 preceding siblings ...)
  2017-04-12 22:44 ` [PATCH 7/8] ftgmac100: Display the discovered PHY device info Benjamin Herrenschmidt
@ 2017-04-12 22:44 ` Benjamin Herrenschmidt
  2017-04-13 13:42   ` Andrew Lunn
  7 siblings, 1 reply; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-12 22:44 UTC (permalink / raw)
  To: netdev; +Cc: Benjamin Herrenschmidt

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 .../devicetree/bindings/net/ftgmac100.txt          | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/ftgmac100.txt

diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt b/Documentation/devicetree/bindings/net/ftgmac100.txt
new file mode 100644
index 0000000..68a694a
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
@@ -0,0 +1,36 @@
+* Faraday Technology FTGMAC100 gigabit ethernet controller
+
+Required properties:
+- compatible: "faraday,ftgmac100"
+
+  Must also contain one of these if used as part of an Aspeed AST2400
+  or 2500 family SoC as they have some subtle tweaks to the
+  implementation:
+
+     - "aspeed,ast2400-mac"
+     - "aspeed,ast2500-mac"
+
+- reg: Address and length of the register set for the device
+- interrupts: Should contain ethernet controller interrupt
+
+Optional properties:
+- phy-mode: See ethernet.txt file in the same directory. If the property is
+  absent, "rgmii" is assumed. Supported values are "rgmii" and "rmii"
+- use-ncsi: Use the NC-SI stack instead of an MDIO PHY. Currently assumes
+  rmii (100bT) but kept as a separate property in case NC-SI grows support
+  for a gigabit link.
+- no-hw-checksum: Used to disable HW checksum support. Here for backward
+  compatibility as the driver now should have correct defaults based on
+  the SoC.
+
+Example:
+
+	mac0: ethernet@1e660000 {
+		compatible = "aspeed,ast2500-mac", "faraday,ftgmac100";
+		reg = <0x1e660000 0x180>;
+		interrupts = <2>;
+		status = "okay";
+		use-ncsi;
+	};
+
+
-- 
2.9.3

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

* Re: [PATCH 1/8] ftgmac100: Add ethtool n-way reset call
  2017-04-12 22:44 ` [PATCH 1/8] ftgmac100: Add ethtool n-way reset call Benjamin Herrenschmidt
@ 2017-04-13  0:00   ` Florian Fainelli
  2017-04-13  0:59     ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 15+ messages in thread
From: Florian Fainelli @ 2017-04-13  0:00 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, netdev

On 04/12/2017 03:44 PM, Benjamin Herrenschmidt wrote:
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
>  drivers/net/ethernet/faraday/ftgmac100.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
> index 796b37e..bbeb8e7 100644
> --- a/drivers/net/ethernet/faraday/ftgmac100.c
> +++ b/drivers/net/ethernet/faraday/ftgmac100.c
> @@ -1043,11 +1043,11 @@ static void ftgmac100_get_drvinfo(struct net_device *netdev,
>  	strlcpy(info->bus_info, dev_name(&netdev->dev), sizeof(info->bus_info));
>  }
>  
> -static int ftgmac100_nway_reset(struct net_device *ndev)
> +static int ftgmac100_nway_reset(struct net_device *netdev)
>  {
> -	if (!ndev->phydev)
> +	if (!netdev->phydev)
>  		return -ENXIO;
> -	return phy_start_aneg(ndev->phydev);
> +	return phy_start_aneg(netdev->phydev);

Can you use phy_ethtool_nway_reset() which does that (and also checks if
phydev->drv is NULL which would be the case after an unbind).

>  }
>  
>  static void ftgmac100_get_ringparam(struct net_device *netdev,
> @@ -1088,6 +1088,7 @@ static const struct ethtool_ops ftgmac100_ethtool_ops = {
>  	.get_link		= ethtool_op_get_link,
>  	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
>  	.set_link_ksettings	= phy_ethtool_set_link_ksettings,
> +	.nway_reset		= ftgmac100_nway_reset,
>  	.get_ringparam		= ftgmac100_get_ringparam,
>  	.set_ringparam		= ftgmac100_set_ringparam,
>  };
> 


-- 
Florian

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

* Re: [PATCH 1/8] ftgmac100: Add ethtool n-way reset call
  2017-04-13  0:00   ` Florian Fainelli
@ 2017-04-13  0:59     ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-13  0:59 UTC (permalink / raw)
  To: Florian Fainelli, netdev

On Wed, 2017-04-12 at 17:00 -0700, Florian Fainelli wrote:
> > -static int ftgmac100_nway_reset(struct net_device *ndev)
> > +static int ftgmac100_nway_reset(struct net_device *netdev)
> >   {
> > -     if (!ndev->phydev)
> > +     if (!netdev->phydev)
> >                return -ENXIO;
> > -     return phy_start_aneg(ndev->phydev);
> > +     return phy_start_aneg(netdev->phydev);
> 
> Can you use phy_ethtool_nway_reset() which does that (and also checks
> if phydev->drv is NULL which would be the case after an unbind).

Ah sure, I didn't notice that one, grepped the wrong driver :-)

I'll respin later today.

Thanks !

Cheers,
Ben.

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

* Re: [PATCH 6/8] ftgmac100: Allow configuration of phy interface via device-tree
  2017-04-12 22:44 ` [PATCH 6/8] ftgmac100: Allow configuration of phy interface via device-tree Benjamin Herrenschmidt
@ 2017-04-13 13:40   ` Andrew Lunn
  0 siblings, 0 replies; 15+ messages in thread
From: Andrew Lunn @ 2017-04-13 13:40 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: netdev

On Thu, Apr 13, 2017 at 08:44:41AM +1000, Benjamin Herrenschmidt wrote:
> This uses the standard phy-mode property
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH 7/8] ftgmac100: Display the discovered PHY device info
  2017-04-12 22:44 ` [PATCH 7/8] ftgmac100: Display the discovered PHY device info Benjamin Herrenschmidt
@ 2017-04-13 13:40   ` Andrew Lunn
  0 siblings, 0 replies; 15+ messages in thread
From: Andrew Lunn @ 2017-04-13 13:40 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: netdev

On Thu, Apr 13, 2017 at 08:44:42AM +1000, Benjamin Herrenschmidt wrote:
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH 8/8] ftgmac100: Document device-tree binding
  2017-04-12 22:44 ` [PATCH 8/8] ftgmac100: Document device-tree binding Benjamin Herrenschmidt
@ 2017-04-13 13:42   ` Andrew Lunn
  2017-04-13 13:58     ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 15+ messages in thread
From: Andrew Lunn @ 2017-04-13 13:42 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: netdev

> +- phy-mode: See ethernet.txt file in the same directory. If the property is
> +  absent, "rgmii" is assumed. Supported values are "rgmii" and "rmii"

You might want to say rgmii*, or similar, it indicate the delayed
versions are accepted as well.

	 Andrew

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

* Re: [PATCH 8/8] ftgmac100: Document device-tree binding
  2017-04-13 13:42   ` Andrew Lunn
@ 2017-04-13 13:58     ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-13 13:58 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: netdev

On Thu, 2017-04-13 at 15:42 +0200, Andrew Lunn wrote:
> > +- phy-mode: See ethernet.txt file in the same directory. If the
> > property is
> > +  absent, "rgmii" is assumed. Supported values are "rgmii" and
> > "rmii"
> 
> You might want to say rgmii*, or similar, it indicate the delayed
> versions are accepted as well.

You are right. I originally didn't accept them, then fixed that
up in the code but forgot to update the binding.

Dave, if that's the only issue, I'd rather send a separate later
tomorrow or so patch to amend the binding rather than send the whole
series all over again as this is rather a minor detail.

Cheers,
Ben.

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

end of thread, other threads:[~2017-04-13 13:59 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-12 22:44 [PATCH 0/8] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
2017-04-12 22:44 ` [PATCH 1/8] ftgmac100: Add ethtool n-way reset call Benjamin Herrenschmidt
2017-04-13  0:00   ` Florian Fainelli
2017-04-13  0:59     ` Benjamin Herrenschmidt
2017-04-12 22:44 ` [PATCH 2/8] ftgmac100: Add pause frames configuration and support Benjamin Herrenschmidt
2017-04-12 22:44 ` [PATCH 3/8] ftgmac100: Add ndo_set_rx_mode() and support for multicast & promisc Benjamin Herrenschmidt
2017-04-12 22:44 ` [PATCH 4/8] ftgmac100: Add vlan HW offload Benjamin Herrenschmidt
2017-04-12 22:44 ` [PATCH 5/8] ftgmac100: Add netpoll support Benjamin Herrenschmidt
2017-04-12 22:44 ` [PATCH 6/8] ftgmac100: Allow configuration of phy interface via device-tree Benjamin Herrenschmidt
2017-04-13 13:40   ` Andrew Lunn
2017-04-12 22:44 ` [PATCH 7/8] ftgmac100: Display the discovered PHY device info Benjamin Herrenschmidt
2017-04-13 13:40   ` Andrew Lunn
2017-04-12 22:44 ` [PATCH 8/8] ftgmac100: Document device-tree binding Benjamin Herrenschmidt
2017-04-13 13:42   ` Andrew Lunn
2017-04-13 13:58     ` Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).