Skip to contentSkip to conversation

net: systemport: couple fixes

PATCH Superseded Florian Fainelli 2 participants 4 messages May 7, 2014 – May 9, 2014

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover net: systemport: couple fixes

This patch set fixes a few minor issues found in the SYSTEMPORT driver while doing some more testing with its switching hardware.

Florian Fainelli (2):
net: systemport: only update UMAC_CMD if something changed
net: systemport: pad packets to a minimum of 64 bytes

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

PATCH v3 1/2 net: systemport: only update UMAC_CMD if something changed

The link adjustment callback can be called as frequently as desired by the PHY library, as such, let's avoid doing a Read/Modify/Write sequence if nothing changed, which is more than likely since we are interfaced with a switch device.

---
Changes in v3:
- make sure the second and third line after CMD_SPEED_MASK are aligned properly

Changes in v2:
- rebased

 drivers/net/ethernet/broadcom/bcmsysport.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/net/ethernet/broadcom/bcmsysport.c +8 -7
index 4dc8d1e9829b..e118e7411ca4 100644
@@ -959,15 +959,16 @@ static void bcm_sysport_adj_link(struct net_device *dev)
 	if (!phydev->pause)
 		cmd_bits |= CMD_RX_PAUSE_IGNORE | CMD_TX_PAUSE_IGNORE;
 
-	reg = umac_readl(priv, UMAC_CMD);
-	reg &= ~((CMD_SPEED_MASK << CMD_SPEED_SHIFT) |
-			CMD_HD_EN | CMD_RX_PAUSE_IGNORE |
-			CMD_TX_PAUSE_IGNORE);
-	reg |= cmd_bits;
-	umac_writel(priv, reg, UMAC_CMD);
+	if (changed) {
+		reg = umac_readl(priv, UMAC_CMD);
+		reg &= ~((CMD_SPEED_MASK << CMD_SPEED_SHIFT) |
+				CMD_HD_EN | CMD_RX_PAUSE_IGNORE |
+				CMD_TX_PAUSE_IGNORE);
+		reg |= cmd_bits;
+		umac_writel(priv, reg, UMAC_CMD);
 
-	if (changed)
 		phy_print_status(priv->phydev);
+	}
 }
 
 static int bcm_sysport_init_tx_ring(struct bcm_sysport_priv *priv,
Signature · 1 line
1.9.1
maintainer
#2 lore raw

Re: [PATCH net-next v3 1/2] net: systemport: only update UMAC_CMD if something changed

From: Florian Fainelli <[email protected]>
Date: Wed, 7 May 2014 14:36:03 -0700

Quoted 3 lines

Changes in v3:
- make sure the second and third line after CMD_SPEED_MASK are aligned properly

...

drivers/net/ethernet/broadcom/bcmsysport.c static void bcm_sysport_adj_link(struct net_device *dev) · line 966

Quoted 3 lines
drivers/net/ethernet/broadcom/bcmsysport.c +3 -0
+		reg &= ~((CMD_SPEED_MASK << CMD_SPEED_SHIFT) |
+				CMD_HD_EN | CMD_RX_PAUSE_IGNORE |
+				CMD_TX_PAUSE_IGNORE);

Still not right, in fact it looks like you didn't change anything at all.

It should look like:

		reg &= ~((CMD_SPEED_MASK << CMD_SPEED_SHIFT) |
			 CMD_HD_EN | CMD_RX_PAUSE_IGNORE |
			 CMD_TX_PAUSE_IGNORE);
#3 lore raw

PATCH v3 2/2 net: systemport: pad packets to a minimum of 64 bytes

In reply to Florian Fainelli

The switch fabric which is used behind the Broadcom SYSTEMPORT Ethernet controller will discard any incoming packet that is not 64 bytes or more. Since the UniMAC hardware transmits up to the specified size, just make sure that we properly pad the end of the packet with zeroes using skb_padto() and set a minimum packet length of 64 bytes.

---
Changes in v3:
- reword the commit message and comment to explain the special hardware requirements
- print skb_len instead of skb->len in the DMA map failure error

Changes in v2:
- add missing skb_padto() to zero-out packets

 drivers/net/ethernet/broadcom/bcmsysport.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bcmsysport.c +17 -4
index e118e7411ca4..413366570c7e 100644
@@ -821,6 +821,7 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb,
 	struct bcm_sysport_cb *cb;
 	struct netdev_queue *txq;
 	struct dma_desc *desc;
+	unsigned int skb_len;
 	dma_addr_t mapping;
 	u32 len_status;
 	u16 queue;
@@ -848,10 +849,22 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb,
 		}
 	}
 
-	mapping = dma_map_single(kdev, skb->data, skb->len, DMA_TO_DEVICE);
+	/* The Ethernet switch we are interfaced with needs packets to be at
+	 * least 64 bytes otherwise they will be discarded when they enter
+	 * the switch port logic. The UniMAC hardware transmits up to the
+	 * specified length.
+	 */
+	if (skb_padto(skb, 64)) {
+		ret = NETDEV_TX_OK;
+		goto out;
+	}
+
+	skb_len = skb->len < 64 ? 64 : skb->len;
+
+	mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE);
 	if (dma_mapping_error(kdev, mapping)) {
 		netif_err(priv, tx_err, dev, "DMA map failed at %p (len=%d)\n",
-				skb->data, skb->len);
+				skb->data, skb_len);
 		ret = NETDEV_TX_OK;
 		goto out;
 	}
@@ -860,14 +873,14 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb,
 	cb = &ring->cbs[ring->curr_desc];
 	cb->skb = skb;
 	dma_unmap_addr_set(cb, dma_addr, mapping);
-	dma_unmap_len_set(cb, dma_len, skb->len);
+	dma_unmap_len_set(cb, dma_len, skb_len);
 
 	/* Fetch a descriptor entry from our pool */
 	desc = ring->desc_cpu;
 
 	desc->addr_lo = lower_32_bits(mapping);
 	len_status = upper_32_bits(mapping) & DESC_ADDR_HI_MASK;
-	len_status |= (skb->len << DESC_LEN_SHIFT);
+	len_status |= (skb_len << DESC_LEN_SHIFT);
 	len_status |= (DESC_SOP | DESC_EOP | TX_STATUS_APP_CRC) <<
 			DESC_STATUS_SHIFT;
 	if (skb->ip_summed == CHECKSUM_PARTIAL)
Signature · 1 line
1.9.1