Skip to contentSkip to conversation

net: qcom/emac: configure the external phy to allow pause frames

PATCH In review Timur Tabi 2 participants 7 messages Nov 1, 2016

Subsystems (3)
lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

PATCH 1/2 net: qcom/emac: configure the external phy to allow pause frames

Pause frames are used to enable flow control. A MAC can send and receive pause frames in order to throttle traffic. However, the PHY must be configured to allow those frames to pass through.

---
 drivers/net/ethernet/qualcomm/emac/emac-mac.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/ethernet/qualcomm/emac/emac-mac.c +6 -0
index 6fb3bee..70a55dc 100644
@@ -1003,6 +1003,12 @@ int emac_mac_up(struct emac_adapter *adpt)
 	writel((u32)~DIS_INT, adpt->base + EMAC_INT_STATUS);
 	writel(adpt->irq.mask, adpt->base + EMAC_INT_MASK);
 
+	/* Enable pause frames.  Without this feature, the EMAC has been shown
+	 * to receive (and drop) frames with FCS errors at gigabit connections.
+	 */
+	adpt->phydev->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
+	adpt->phydev->advertising |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
+
 	adpt->phydev->irq = PHY_IGNORE_INTERRUPT;
 	phy_start(adpt->phydev);
 
Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
author
#1 lore raw

PATCH 2/2 net: qcom/emac: enable flow control if requested

If the PHY has been configured to allow pause frames, then the MAC should be configured to generate and/or accept those frames.

---
 drivers/net/ethernet/qualcomm/emac/emac-mac.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/ethernet/qualcomm/emac/emac-mac.c +6 -4
index 70a55dc..46e19e9 100644
@@ -575,10 +575,12 @@ void emac_mac_start(struct emac_adapter *adpt)
 
 	mac |= TXEN | RXEN;     /* enable RX/TX */
 
-	/* We don't have ethtool support yet, so force flow-control mode
-	 * to 'full' always.
-	 */
-	mac |= TXFC | RXFC;
+	/* Configure MAC flow control to patch the PHY's settings */
+	if (phydev->pause)
+		mac |= RXFC;
+
+	if (!phydev->pause && phydev->asym_pause)
+		mac |= TXFC;
 
 	/* setup link speed */
 	mac &= ~SPEED_MASK;
Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
author
#3 lore raw

Re: [PATCH 2/2] net: qcom/emac: enable flow control if requested

In reply to Timur Tabi

drivers/net/ethernet/qualcomm/emac/emac-mac.c void emac_mac_start(struct emac_adapter *adpt) · line 583

Quoted 2 lines · Timur Tabi
drivers/net/ethernet/qualcomm/emac/emac-mac.c +2 -0
+	if (!phydev->pause && phydev->asym_pause)
+		mac |= TXFC;

I think this might be wrong, and nb8800_pause_config() has it right. This should be:

	if (!phydev->pause != !phydev->asym_pause)

which is a logical-xor.

Do you concur?

Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
author
#5 lore raw
In reply to Timur Tabi
Quoted 5 lines · Timur Tabi

Pause frames are used to enable flow control. A MAC can send and receive pause frames in order to throttle traffic. However, the PHY must be configured to allow those frames to pass through.

Ugh, I forgot to include an introductory post. Coming right up.

Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
author
#6 lore raw

cover net: qcom/emac: the emac driver requires pause frames

In reply to Timur Tabi

The qcom emac driver experiences significant packet loss (through frame check sequence errors) if flow control is not enabled and the phy is not configured to allow pause frames to pass through it. Therefore, we need to force enable flow control and force the phy to pass pause frames.

Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.