Skip to contentSkip to conversation

net: systemport: misc fixes

PATCH In review Florian Fainelli 2 participants 5 messages Jun 26, 2014 – Jul 2, 2014

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

v2 cover net: systemport: misc fixes

Hi David,

This patch set contains 3 small fixes for the SYSTEM PORT driver

Thanks!

Florian Fainelli (3):
net: systemport: do not clear IFF_MULTICAST flag
net: systemport: fix UniMAC reset logic
net: systemport: fix TX NAPI work done return value

 drivers/net/ethernet/broadcom/bcmsysport.c | 43 ++++++++----------------------
 1 file changed, 11 insertions(+), 32 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/3 net: systemport: do not clear IFF_MULTICAST flag

The SYSTEMPORT Ethernet MAC supports multicast just fine, it just lacks any sort of Unicast/Broadcast/Multicasting filtering at the Ethernet MAC level since that is handled by the front end Ethernet switch, but that is properly handled by bcm_sysport_set_rx_mode().

Some user-space applications might be relying on the presence of this flag to prevent using multicast sockets, this also prevents that interface from joining the IPv6 all-router mcast group.

---
Changes in v2:
- rebased

 drivers/net/ethernet/broadcom/bcmsysport.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/net/ethernet/broadcom/bcmsysport.c +0 -6
index 141160ef249a..f6bccd847ee6 100644
@@ -1589,12 +1589,6 @@ static int bcm_sysport_probe(struct platform_device *pdev)
 	BUILD_BUG_ON(sizeof(struct bcm_tsb) != 8);
 	dev->needed_headroom += sizeof(struct bcm_tsb);
 
-	/* We are interfaced to a switch which handles the multicast
-	 * filtering for us, so we do not support programming any
-	 * multicast hash table in this Ethernet MAC.
-	 */
-	dev->flags &= ~IFF_MULTICAST;
-
 	/* libphy will adjust the link state accordingly */
 	netif_carrier_off(dev);
 
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 2/3 net: systemport: fix UniMAC reset logic

In reply to Florian Fainelli

The UniMAC CMD_SW_RESET bit is not a self-clearing bit, so we need to assert it, wait a bit and clear it manually. As a result, umac_reset() is updated not to return any value. The previous version of the code simply wrote 0 to the CMD register, which would make the busy-waiting loop exit immediately, having zero effect.

By writing 0 to the CMD register, we were clearing all bits in the CMD register, and not using the hardware reset default values which are set on purpose.

---
Changes in v2:
- clarify the commit message and make it accurate with what the code did before

 drivers/net/ethernet/broadcom/bcmsysport.c | 33 ++++++++----------------------
 1 file changed, 9 insertions(+), 24 deletions(-)
drivers/net/ethernet/broadcom/bcmsysport.c +9 -24
index f6bccd847ee6..d31f7d239064 100644
@@ -1254,28 +1254,17 @@ static inline void umac_enable_set(struct bcm_sysport_priv *priv,
 		usleep_range(1000, 2000);
 }
 
-static inline int umac_reset(struct bcm_sysport_priv *priv)
+static inline void umac_reset(struct bcm_sysport_priv *priv)
 {
-	unsigned int timeout = 0;
 	u32 reg;
-	int ret = 0;
-
-	umac_writel(priv, 0, UMAC_CMD);
-	while (timeout++ < 1000) {
-		reg = umac_readl(priv, UMAC_CMD);
-		if (!(reg & CMD_SW_RESET))
-			break;
-
-		udelay(1);
-	}
-
-	if (timeout == 1000) {
-		dev_err(&priv->pdev->dev,
-			"timeout waiting for MAC to come out of reset\n");
-		ret = -ETIMEDOUT;
-	}
 
-	return ret;
+	reg = umac_readl(priv, UMAC_CMD);
+	reg |= CMD_SW_RESET;
+	umac_writel(priv, reg, UMAC_CMD);
+	udelay(10);
+	reg = umac_readl(priv, UMAC_CMD);
+	reg &= ~CMD_SW_RESET;
+	umac_writel(priv, reg, UMAC_CMD);
 }
 
 static void umac_set_hw_addr(struct bcm_sysport_priv *priv,
@@ -1303,11 +1292,7 @@ static int bcm_sysport_open(struct net_device *dev)
 	int ret;
 
 	/* Reset UniMAC */
-	ret = umac_reset(priv);
-	if (ret) {
-		netdev_err(dev, "UniMAC reset failed\n");
-		return ret;
-	}
+	umac_reset(priv);
 
 	/* Flush TX and RX FIFOs at TOPCTRL level */
 	topctrl_flush(priv);
Signature · 1 line
1.9.1
#3 lore raw

PATCH v2 3/3 net: systemport: fix TX NAPI work done return value

In reply to Florian Fainelli

Although we do not limit the number of packets the TX completion function bcm_sysport_tx_reclaim() is allowed to reclaim, we were still using its return value as-is. This means that we could hit the WARN() in net/core/dev.c where work_done >= budget.

Make sure we do exit the NAPI context when the TX ring is empty, and pretend there was no work to do.

---
New patch in v2

 drivers/net/ethernet/broadcom/bcmsysport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bcmsysport.c +2 -2
index d31f7d239064..5776e503e4c5 100644
@@ -654,13 +654,13 @@ static int bcm_sysport_tx_poll(struct napi_struct *napi, int budget)
 
 	work_done = bcm_sysport_tx_reclaim(ring->priv, ring);
 
-	if (work_done < budget) {
+	if (work_done == 0) {
 		napi_complete(napi);
 		/* re-enable TX interrupt */
 		intrl2_1_mask_clear(ring->priv, BIT(ring->index));
 	}
 
-	return work_done;
+	return 0;
 }
 
 static void bcm_sysport_tx_reclaim_all(struct bcm_sysport_priv *priv)
Signature · 1 line
1.9.1