* [PATCH v3 0/9] ftgmac100: Rework batch 5 - Features
@ 2017-04-17 22:36 Benjamin Herrenschmidt
2017-04-17 22:36 ` [PATCH v3 1/9] ftgmac100: Add ethtool n-way reset call Benjamin Herrenschmidt
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-17 22:36 UTC (permalink / raw)
To: netdev
This is the third spin of the 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.
v2. - Addresses review comments and adds a new patch fixing a
theorical ordering issue in my new NAPI poll implementation
- Add a bug fix (Patch 8/9) for a potential ordering issue
in the new NAPI poll code.
v3. - Rebase on net-next (fix conflict with an unrelated #include
change series)
- Update DT bindings better describing accepted phy-mode values
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v3 1/9] ftgmac100: Add ethtool n-way reset call
2017-04-17 22:36 [PATCH v3 0/9] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
@ 2017-04-17 22:36 ` Benjamin Herrenschmidt
2017-04-17 22:36 ` [PATCH v3 2/9] ftgmac100: Add pause frames configuration and support Benjamin Herrenschmidt
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-17 22:36 UTC (permalink / raw)
To: netdev; +Cc: Benjamin Herrenschmidt
A non-wired up implementation accidentally made its way in
a previous patch (Make ring sizes configurable via ethtool).
This removes it and wires up the generic phy_ethtool_nway_reset
instead.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
--
v2. - Use phy_ethtool_nway_reset() instead of custom implementation
---
drivers/net/ethernet/faraday/ftgmac100.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 2153c5b..4cdd25a 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1045,13 +1045,6 @@ 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)
-{
- if (!ndev->phydev)
- return -ENXIO;
- return phy_start_aneg(ndev->phydev);
-}
-
static void ftgmac100_get_ringparam(struct net_device *netdev,
struct ethtool_ringparam *ering)
{
@@ -1090,6 +1083,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 = phy_ethtool_nway_reset,
.get_ringparam = ftgmac100_get_ringparam,
.set_ringparam = ftgmac100_set_ringparam,
};
--
2.9.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 2/9] ftgmac100: Add pause frames configuration and support
2017-04-17 22:36 [PATCH v3 0/9] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
2017-04-17 22:36 ` [PATCH v3 1/9] ftgmac100: Add ethtool n-way reset call Benjamin Herrenschmidt
@ 2017-04-17 22:36 ` Benjamin Herrenschmidt
2017-04-17 22:37 ` [PATCH v3 3/9] ftgmac100: Add ndo_set_rx_mode() and support for multicast & promisc Benjamin Herrenschmidt
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-17 22:36 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 4cdd25a..949b48c 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -99,6 +99,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;
@@ -219,6 +224,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;
@@ -912,6 +934,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 */
@@ -920,8 +943,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,
@@ -932,6 +968,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)
@@ -963,6 +1001,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;
}
@@ -1078,6 +1122,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,
@@ -1086,6 +1172,8 @@ static const struct ethtool_ops ftgmac100_ethtool_ops = {
.nway_reset = phy_ethtool_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)
@@ -1217,6 +1305,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 */
@@ -1546,6 +1635,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] 11+ messages in thread
* [PATCH v3 3/9] ftgmac100: Add ndo_set_rx_mode() and support for multicast & promisc
2017-04-17 22:36 [PATCH v3 0/9] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
2017-04-17 22:36 ` [PATCH v3 1/9] ftgmac100: Add ethtool n-way reset call Benjamin Herrenschmidt
2017-04-17 22:36 ` [PATCH v3 2/9] ftgmac100: Add pause frames configuration and support Benjamin Herrenschmidt
@ 2017-04-17 22:37 ` Benjamin Herrenschmidt
2017-04-17 22:37 ` [PATCH v3 4/9] ftgmac100: Add vlan HW offload Benjamin Herrenschmidt
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-17 22:37 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>
--
v3. - Rebase to fix conflict with #include changes
---
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 949b48c..f4db6e2 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -32,6 +32,7 @@
#include <linux/phy.h>
#include <linux/platform_device.h>
#include <linux/property.h>
+#include <linux/crc32.h>
#include <net/ip.h>
#include <net/ncsi.h>
@@ -99,6 +100,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;
@@ -266,6 +271,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
@@ -319,6 +328,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);
@@ -329,6 +344,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)
{
@@ -1503,6 +1554,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] 11+ messages in thread
* [PATCH v3 4/9] ftgmac100: Add vlan HW offload
2017-04-17 22:36 [PATCH v3 0/9] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
` (2 preceding siblings ...)
2017-04-17 22:37 ` [PATCH v3 3/9] ftgmac100: Add ndo_set_rx_mode() and support for multicast & promisc Benjamin Herrenschmidt
@ 2017-04-17 22:37 ` Benjamin Herrenschmidt
2017-04-17 22:37 ` [PATCH v3 5/9] ftgmac100: Add netpoll support Benjamin Herrenschmidt
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-17 22:37 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 f4db6e2..40a03d5 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -33,6 +33,7 @@
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/crc32.h>
+#include <linux/if_vlan.h>
#include <net/ip.h>
#include <net/ncsi.h>
@@ -335,6 +336,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);
}
@@ -530,6 +535,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);
@@ -754,6 +765,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 */
@@ -1546,6 +1564,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,
@@ -1555,6 +1597,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)
@@ -1730,7 +1773,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] 11+ messages in thread
* [PATCH v3 5/9] ftgmac100: Add netpoll support
2017-04-17 22:36 [PATCH v3 0/9] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
` (3 preceding siblings ...)
2017-04-17 22:37 ` [PATCH v3 4/9] ftgmac100: Add vlan HW offload Benjamin Herrenschmidt
@ 2017-04-17 22:37 ` Benjamin Herrenschmidt
2017-04-17 22:37 ` [PATCH v3 6/9] ftgmac100: Allow configuration of phy interface via device-tree Benjamin Herrenschmidt
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-17 22:37 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 40a03d5..f76765e 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1588,6 +1588,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,
@@ -1598,6 +1609,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] 11+ messages in thread
* [PATCH v3 6/9] ftgmac100: Allow configuration of phy interface via device-tree
2017-04-17 22:36 [PATCH v3 0/9] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
` (4 preceding siblings ...)
2017-04-17 22:37 ` [PATCH v3 5/9] ftgmac100: Add netpoll support Benjamin Herrenschmidt
@ 2017-04-17 22:37 ` Benjamin Herrenschmidt
2017-04-17 22:37 ` [PATCH v3 7/9] ftgmac100: Display the discovered PHY device info Benjamin Herrenschmidt
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-17 22:37 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 f76765e..7721c2a 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -34,6 +34,7 @@
#include <linux/property.h>
#include <linux/crc32.h>
#include <linux/if_vlan.h>
+#include <linux/of_net.h>
#include <net/ip.h>
#include <net/ncsi.h>
@@ -1051,7 +1052,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;
@@ -1063,7 +1064,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);
@@ -1618,6 +1619,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;
@@ -1633,6 +1636,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);
@@ -1649,7 +1685,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] 11+ messages in thread
* [PATCH v3 7/9] ftgmac100: Display the discovered PHY device info
2017-04-17 22:36 [PATCH v3 0/9] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
` (5 preceding siblings ...)
2017-04-17 22:37 ` [PATCH v3 6/9] ftgmac100: Allow configuration of phy interface via device-tree Benjamin Herrenschmidt
@ 2017-04-17 22:37 ` Benjamin Herrenschmidt
2017-04-17 22:37 ` [PATCH v3 8/9] ftgmac100: Fix potential ordering issue in NAPI poll Benjamin Herrenschmidt
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-17 22:37 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 7721c2a..45b8267 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1077,6 +1077,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] 11+ messages in thread
* [PATCH v3 8/9] ftgmac100: Fix potential ordering issue in NAPI poll
2017-04-17 22:36 [PATCH v3 0/9] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
` (6 preceding siblings ...)
2017-04-17 22:37 ` [PATCH v3 7/9] ftgmac100: Display the discovered PHY device info Benjamin Herrenschmidt
@ 2017-04-17 22:37 ` Benjamin Herrenschmidt
2017-04-17 22:37 ` [PATCH v3 9/9] ftgmac100: Document device-tree binding Benjamin Herrenschmidt
2017-04-18 18:11 ` [PATCH v3 0/9] ftgmac100: Rework batch 5 - Features David Miller
9 siblings, 0 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-17 22:37 UTC (permalink / raw)
To: netdev; +Cc: Benjamin Herrenschmidt
We need to ensure the loads from the descriptor are done after the
MMIO store clearing the interrupts has completed, otherwise we
might still miss work.
A read back from the MMIO register will "push" the posted store and
ioread32 has a barrier on weakly aordered architectures that will
order subsequent accesses.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
drivers/net/ethernet/faraday/ftgmac100.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 45b8267..95bf5e8 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1349,6 +1349,13 @@ static int ftgmac100_poll(struct napi_struct *napi, int budget)
*/
iowrite32(FTGMAC100_INT_RXTX,
priv->base + FTGMAC100_OFFSET_ISR);
+
+ /* Push the above (and provides a barrier vs. subsequent
+ * reads of the descriptor).
+ */
+ ioread32(priv->base + FTGMAC100_OFFSET_ISR);
+
+ /* Check RX and TX descriptors for more work to do */
if (ftgmac100_check_rx(priv) ||
ftgmac100_tx_buf_cleanable(priv))
return budget;
--
2.9.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 9/9] ftgmac100: Document device-tree binding
2017-04-17 22:36 [PATCH v3 0/9] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
` (7 preceding siblings ...)
2017-04-17 22:37 ` [PATCH v3 8/9] ftgmac100: Fix potential ordering issue in NAPI poll Benjamin Herrenschmidt
@ 2017-04-17 22:37 ` Benjamin Herrenschmidt
2017-04-18 18:11 ` [PATCH v3 0/9] ftgmac100: Rework batch 5 - Features David Miller
9 siblings, 0 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2017-04-17 22:37 UTC (permalink / raw)
To: netdev; +Cc: Benjamin Herrenschmidt
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
--
v3. - Update supported values for phy-mode
---
.../devicetree/bindings/net/ftgmac100.txt | 37 ++++++++++++++++++++++
1 file changed, 37 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..fceeede
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
@@ -0,0 +1,37 @@
+* 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" for
+ aspeed parts. Other (unknown) parts will accept any value.
+- 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] 11+ messages in thread
* Re: [PATCH v3 0/9] ftgmac100: Rework batch 5 - Features
2017-04-17 22:36 [PATCH v3 0/9] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
` (8 preceding siblings ...)
2017-04-17 22:37 ` [PATCH v3 9/9] ftgmac100: Document device-tree binding Benjamin Herrenschmidt
@ 2017-04-18 18:11 ` David Miller
9 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2017-04-18 18:11 UTC (permalink / raw)
To: benh; +Cc: netdev
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: Tue, 18 Apr 2017 08:36:57 +1000
> This is the third spin of the 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.
>
> v2. - Addresses review comments and adds a new patch fixing a
> theorical ordering issue in my new NAPI poll implementation
> - Add a bug fix (Patch 8/9) for a potential ordering issue
> in the new NAPI poll code.
>
> v3. - Rebase on net-next (fix conflict with an unrelated #include
> change series)
> - Update DT bindings better describing accepted phy-mode values
Series applied, thanks Ben.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2017-04-18 18:11 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-17 22:36 [PATCH v3 0/9] ftgmac100: Rework batch 5 - Features Benjamin Herrenschmidt
2017-04-17 22:36 ` [PATCH v3 1/9] ftgmac100: Add ethtool n-way reset call Benjamin Herrenschmidt
2017-04-17 22:36 ` [PATCH v3 2/9] ftgmac100: Add pause frames configuration and support Benjamin Herrenschmidt
2017-04-17 22:37 ` [PATCH v3 3/9] ftgmac100: Add ndo_set_rx_mode() and support for multicast & promisc Benjamin Herrenschmidt
2017-04-17 22:37 ` [PATCH v3 4/9] ftgmac100: Add vlan HW offload Benjamin Herrenschmidt
2017-04-17 22:37 ` [PATCH v3 5/9] ftgmac100: Add netpoll support Benjamin Herrenschmidt
2017-04-17 22:37 ` [PATCH v3 6/9] ftgmac100: Allow configuration of phy interface via device-tree Benjamin Herrenschmidt
2017-04-17 22:37 ` [PATCH v3 7/9] ftgmac100: Display the discovered PHY device info Benjamin Herrenschmidt
2017-04-17 22:37 ` [PATCH v3 8/9] ftgmac100: Fix potential ordering issue in NAPI poll Benjamin Herrenschmidt
2017-04-17 22:37 ` [PATCH v3 9/9] ftgmac100: Document device-tree binding Benjamin Herrenschmidt
2017-04-18 18:11 ` [PATCH v3 0/9] ftgmac100: Rework batch 5 - Features David Miller
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).