From: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Date: 2021-02-12 18:01:40
General fixes on amd-xgbe driver are addressed in this series, mostly
on the mailbox communication failures and improving the link stability
of the amd-xgbe device.
Shyam Sundar S K (4):
amd-xgbe: Reset the PHY rx data path when mailbox command timeout
amd-xgbe: Fix NETDEV WATCHDOG transmit queue timeout warning
amd-xgbe: Reset link when the link never comes back
amd-xgbe: Fix network fluctuations when using 1G BELFUSE SFP
drivers/net/ethernet/amd/xgbe/xgbe-common.h | 13 +++++++
drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 1 +
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c | 3 +-
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 39 ++++++++++++++++++++-
4 files changed, 53 insertions(+), 3 deletions(-)
--
2.25.1
From: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Date: 2021-02-12 18:01:51
Normally, auto negotiation and reconnect should be automatically done by
the hardware. But there seems to be an issue where auto negotiation has
to be restarted manually. This happens because of link training and so
even though still connected to the partner the link never "comes back".
This would need a reset to recover.
Also, a change in xgbe-mdio is needed to get ethtool to recognize the
link down and get the link change message.
Signed-off-by: Sudheesh Mavila <redacted>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c | 2 +-
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
@@ -2607,6 +2607,14 @@ static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart)if(reg&MDIO_STAT1_LSTATUS)return1;+if(pdata->phy.autoneg==AUTONEG_ENABLE&&+phy_data->port_mode==XGBE_PORT_MODE_BACKPLANE){+if(!test_bit(XGBE_LINK_INIT,&pdata->dev_state)){+netif_carrier_off(pdata->netdev);+*an_restart=1;+}+}+/* No link, attempt a receiver reset cycle */if(phy_data->rrc_count++>XGBE_RRC_FREQUENCY){phy_data->rrc_count=0;
From: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Date: 2021-02-12 18:01:56
Frequent link up/down events can happen when a Bel Fuse SFP part is
connected to the amd-xgbe device. Try to avoid the frequent link
issues by resetting the PHY as documented in Bel Fuse SFP datasheets.
Signed-off-by: Sudheesh Mavila <redacted>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 6 ++++++
1 file changed, 6 insertions(+)
From: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Date: 2021-02-12 18:02:45
Sometimes mailbox commands timeout when the RX data path becomes
unresponsive. This prevents the submission of new mailbox commands to DXIO.
This patch identifies the timeout and resets the RX data path so that the
next message can be submitted properly.
Signed-off-by: Sudheesh Mavila <redacted>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/net/ethernet/amd/xgbe/xgbe-common.h | 13 +++++++++++
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 25 ++++++++++++++++++++-
2 files changed, 37 insertions(+), 1 deletion(-)
@@ -1953,6 +1953,24 @@ static void xgbe_phy_set_redrv_mode(struct xgbe_prv_data *pdata)xgbe_phy_put_comm_ownership(pdata);}+staticvoidxgbe_phy_rx_reset(structxgbe_prv_data*pdata)+{+intreg;++reg=XMDIO_READ(pdata,MDIO_MMD_PCS,MDIO_PCS_DIGITAL_STAT);+if(reg&XGBE_PCS_PSEQ_STATE_BIT){+/* mailbox command timed out, reset Rx block */+/* Assert reset bit for 8ns and wait for 40us */+XMDIO_WRITE_BITS(pdata,MDIO_MMD_PMAPMD,MDIO_PMA_RX_CTRL1,+XGBE_PMA_RX_RST_0_MASK,XGBE_PMA_RX_RST_0_RESET_ON);+ndelay(20);+XMDIO_WRITE_BITS(pdata,MDIO_MMD_PMAPMD,MDIO_PMA_RX_CTRL1,+XGBE_PMA_RX_RST_0_MASK,XGBE_PMA_RX_RST_0_RESET_OFF);+usleep_range(40,50);+netif_err(pdata,link,pdata->netdev,"firmware mailbox reset performed\n");+}+}+staticvoidxgbe_phy_perform_ratechange(structxgbe_prv_data*pdata,unsignedintcmd,unsignedintsub_cmd){
@@ -1960,9 +1978,11 @@ static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata,unsignedintwait;/* Log if a previous command did not complete */-if(XP_IOREAD_BITS(pdata,XP_DRIVER_INT_RO,STATUS))+if(XP_IOREAD_BITS(pdata,XP_DRIVER_INT_RO,STATUS)){netif_dbg(pdata,link,pdata->netdev,"firmware mailbox not ready for command\n");+xgbe_phy_rx_reset(pdata);+}/* Construct the command */XP_SET_BITS(s0,XP_DRIVER_SCRATCH_0,COMMAND,cmd);
@@ -1984,6 +2004,9 @@ static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata,netif_dbg(pdata,link,pdata->netdev,"firmware mailbox command did not complete\n");++/* Reset on error */+xgbe_phy_rx_reset(pdata);}staticvoidxgbe_phy_rrc(structxgbe_prv_data*pdata)
From: Tom Lendacky <thomas.lendacky@amd.com> Date: 2021-02-12 18:44:45
On 2/12/21 12:00 PM, Shyam Sundar S K wrote:
Sometimes mailbox commands timeout when the RX data path becomes
unresponsive. This prevents the submission of new mailbox commands to DXIO.
This patch identifies the timeout and resets the RX data path so that the
next message can be submitted properly.
Signed-off-by: Sudheesh Mavila <redacted>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
I believe you need a Co-developed-by: before Sudheesh's Signed-off-by:
if he was a co-developer.
@@ -1375,6 +1384,10 @@ #define XGBE_PMA_CDR_TRACK_EN_OFF 0x00 #define XGBE_PMA_CDR_TRACK_EN_ON 0x01+#define XGBE_PMA_RX_RST_0_MASK BIT(4)+#define XGBE_PMA_RX_RST_0_RESET_ON 0x10+#define XGBE_PMA_RX_RST_0_RESET_OFF 0x00+ /* Bit setting and getting macros * The get macro will extract the current bit field value from within * the variable
The PSEQ_STATE field is a 3 bit field and I believe you're looking for a
POWER_GOOD state, so this should be:
reg = XMDIO_READ_BITS(pdata, MDIO_MMD_PCS, MDIO_PCS_DIGITAL_STAT
XGBE_PCS_PSEQ_STATE_MASK);
if (reg == XGBE_PCS_PSEQ_STATE_POWER_GOOD) {
where the constants define in xgbe-common.h should be:
#define XGBE_PCS_PSEQ_STATE_MASK 0x1c
#define XGBE_PCS_PSEQ_STATE_POWER_GOOD 0x10
+ /* mailbox command timed out, reset Rx block */
+ /* Assert reset bit for 8ns and wait for 40us */
Please combine this comment and be sure to capitalize appropriately.
@@ -1960,9 +1978,11 @@ static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata, unsigned int wait; /* Log if a previous command did not complete */- if (XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS))+ if (XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) { netif_dbg(pdata, link, pdata->netdev, "firmware mailbox not ready for command\n");+ xgbe_phy_rx_reset(pdata);
From: Tom Lendacky <thomas.lendacky@amd.com> Date: 2021-02-12 18:49:54
On 2/12/21 12:00 PM, Shyam Sundar S K wrote:
Current driver calls the netif_carrier_off() during the later point in
time to tear down the link which causes the netdev watchdog to timeout.
This is a bit confusing... how about:
The current driver calls netif_carrier_off() late in the link tear down
which can result in a netdev watchdog timeout.
Calling netif_carrier_off() immediately after netif_tx_stop_all_queues()
would avoids the warning.
Frequent link up/down events can happen when a Bel Fuse SFP part is
connected to the amd-xgbe device. Try to avoid the frequent link
issues by resetting the PHY as documented in Bel Fuse SFP datasheets.
Signed-off-by: Sudheesh Mavila <redacted>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 6 ++++++
1 file changed, 6 insertions(+)
@@ -922,6 +922,12 @@ static bool xgbe_phy_belfuse_phy_quirks(struct xgbe_prv_data *pdata)if((phy_id&0xfffffff0)!=0x03625d10)returnfalse;+/* Reset PHY - wait for self-clearing reset bit to clear */+reg=phy_read(phy_data->phydev,0x00);+phy_write(phy_data->phydev,0x00,reg|0x8000);+read_poll_timeout(phy_read,reg,!(reg&0x8000)||reg<0,+10000,50000,true,phy_data->phydev,0x0);
Can you use the standard register definitions from include/linux/mii.h
here? You are doing a software reset of the PHY through the BMCR.RESET
register, so you might as well make that clear.
General fixes on amd-xgbe driver are addressed in this series, mostly
on the mailbox communication failures and improving the link stability
of the amd-xgbe device.
Shyam Sundar S K (4):
amd-xgbe: Reset the PHY rx data path when mailbox command timeout
amd-xgbe: Fix NETDEV WATCHDOG transmit queue timeout warning
amd-xgbe: Reset link when the link never comes back
amd-xgbe: Fix network fluctuations when using 1G BELFUSE SFP
From: Tom Lendacky <thomas.lendacky@amd.com> Date: 2021-02-12 19:02:07
On 2/12/21 12:00 PM, Shyam Sundar S K wrote:
Normally, auto negotiation and reconnect should be automatically done by
the hardware. But there seems to be an issue where auto negotiation has
to be restarted manually. This happens because of link training and so
even though still connected to the partner the link never "comes back".
This would need a reset to recover.
This last sentence is strange. Are you meaning to say this needs to
restart auto-negotiation?
Please mention this pertains only to a backplane connection mode.
Also, a change in xgbe-mdio is needed to get ethtool to recognize the
link down and get the link change message.
Signed-off-by: Sudheesh Mavila <redacted>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Same comment about Co-developed-by: as previous patch.
With those addressed,
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
@@ -2607,6 +2607,14 @@ static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart)if(reg&MDIO_STAT1_LSTATUS)return1;+if(pdata->phy.autoneg==AUTONEG_ENABLE&&+phy_data->port_mode==XGBE_PORT_MODE_BACKPLANE){+if(!test_bit(XGBE_LINK_INIT,&pdata->dev_state)){+netif_carrier_off(pdata->netdev);+*an_restart=1;+}+}+/* No link, attempt a receiver reset cycle */if(phy_data->rrc_count++>XGBE_RRC_FREQUENCY){phy_data->rrc_count=0;
From: Tom Lendacky <thomas.lendacky@amd.com> Date: 2021-02-12 19:06:50
On 2/12/21 12:00 PM, Shyam Sundar S K wrote:
Frequent link up/down events can happen when a Bel Fuse SFP part is
connected to the amd-xgbe device. Try to avoid the frequent link
issues by resetting the PHY as documented in Bel Fuse SFP datasheets.
Signed-off-by: Sudheesh Mavila <redacted>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Same comment about Co-developed-by: tag as previous patch.
With that addressed,
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
Frequent link up/down events can happen when a Bel Fuse SFP part is
connected to the amd-xgbe device. Try to avoid the frequent link
issues by resetting the PHY as documented in Bel Fuse SFP datasheets.
Signed-off-by: Sudheesh Mavila <redacted>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 6 ++++++
1 file changed, 6 insertions(+)
@@ -922,6 +922,12 @@ static bool xgbe_phy_belfuse_phy_quirks(struct xgbe_prv_data *pdata)if((phy_id&0xfffffff0)!=0x03625d10)returnfalse;+/* Reset PHY - wait for self-clearing reset bit to clear */+reg=phy_read(phy_data->phydev,0x00);+phy_write(phy_data->phydev,0x00,reg|0x8000);+read_poll_timeout(phy_read,reg,!(reg&0x8000)||reg<0,+10000,50000,true,phy_data->phydev,0x0);+
Why don't you simply use genphy_soft_reset() ?
Also it's not too nice to use magic register and bit numbers,
there are constants available, e.g. 0x00 = MII_BMCR