From: Michael Chan <michael.chan@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [PATCH net-next 04/13] bnxt_en: Add PHY retry logic.
Date: Sun, 5 Aug 2018 16:51:49 -0400 [thread overview]
Message-ID: <1533502318-22359-5-git-send-email-michael.chan@broadcom.com> (raw)
In-Reply-To: <1533502318-22359-1-git-send-email-michael.chan@broadcom.com>
During hotplug, the driver's open function can be called almost
immediately after power on reset. The PHY may not be ready and the
firmware may return failure when the driver tries to update PHY
settings. Add retry logic fired from the driver's timer to retry
the operation for 5 seconds.
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 31 ++++++++++++++++++++++++++++++-
drivers/net/ethernet/broadcom/bnxt/bnxt.h | 4 ++++
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index d9fc905..fd936c5 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -6898,8 +6898,14 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
mutex_lock(&bp->link_lock);
rc = bnxt_update_phy_setting(bp);
mutex_unlock(&bp->link_lock);
- if (rc)
+ if (rc) {
netdev_warn(bp->dev, "failed to update phy settings\n");
+ if (BNXT_SINGLE_PF(bp)) {
+ bp->link_info.phy_retry = true;
+ bp->link_info.phy_retry_expires =
+ jiffies + 5 * HZ;
+ }
+ }
}
if (irq_re_init)
@@ -7583,6 +7589,16 @@ static void bnxt_timer(struct timer_list *t)
set_bit(BNXT_FLOW_STATS_SP_EVENT, &bp->sp_event);
bnxt_queue_sp_work(bp);
}
+
+ if (bp->link_info.phy_retry) {
+ if (time_after(jiffies, bp->link_info.phy_retry_expires)) {
+ bp->link_info.phy_retry = 0;
+ netdev_warn(bp->dev, "failed to update phy settings after maximum retries.\n");
+ } else {
+ set_bit(BNXT_UPDATE_PHY_SP_EVENT, &bp->sp_event);
+ bnxt_queue_sp_work(bp);
+ }
+ }
bnxt_restart_timer:
mod_timer(&bp->timer, jiffies + bp->current_interval);
}
@@ -7670,6 +7686,19 @@ static void bnxt_sp_task(struct work_struct *work)
netdev_err(bp->dev, "SP task can't update link (rc: %x)\n",
rc);
}
+ if (test_and_clear_bit(BNXT_UPDATE_PHY_SP_EVENT, &bp->sp_event)) {
+ int rc;
+
+ mutex_lock(&bp->link_lock);
+ rc = bnxt_update_phy_setting(bp);
+ mutex_unlock(&bp->link_lock);
+ if (rc) {
+ netdev_warn(bp->dev, "update phy settings retry failed\n");
+ } else {
+ bp->link_info.phy_retry = false;
+ netdev_info(bp->dev, "update phy settings retry succeeded\n");
+ }
+ }
if (test_and_clear_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event)) {
mutex_lock(&bp->link_lock);
bnxt_get_port_module_status(bp);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 0d49fe0..47eec14 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -959,6 +959,9 @@ struct bnxt_link_info {
u16 advertising; /* user adv setting */
bool force_link_chng;
+ bool phy_retry;
+ unsigned long phy_retry_expires;
+
/* a copy of phy_qcfg output used to report link
* info to VF
*/
@@ -1344,6 +1347,7 @@ struct bnxt {
#define BNXT_GENEVE_DEL_PORT_SP_EVENT 13
#define BNXT_LINK_SPEED_CHNG_SP_EVENT 14
#define BNXT_FLOW_STATS_SP_EVENT 15
+#define BNXT_UPDATE_PHY_SP_EVENT 16
struct bnxt_hw_resc hw_resc;
struct bnxt_pf_info pf;
--
2.5.1
next prev parent reply other threads:[~2018-08-05 22:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-05 20:51 [PATCH net-next 00/13] bnxt_en: Updates for net-next Michael Chan
2018-08-05 20:51 ` [PATCH net-next 01/13] bnxt_en: Update firmware interface version to 1.9.2.25 Michael Chan
2018-08-05 20:51 ` [PATCH net-next 02/13] bnxt_en: Adjust timer based on ethtool stats-block-usecs settings Michael Chan
2018-08-05 20:51 ` [PATCH net-next 03/13] bnxt_en: Add external loopback test to ethtool selftest Michael Chan
2018-08-05 20:51 ` Michael Chan [this message]
2018-08-05 20:51 ` [PATCH net-next 05/13] bnxt_en: Add new VF resource allocation strategy mode Michael Chan
2018-08-05 20:51 ` [PATCH net-next 06/13] bnxt_en: Update RSS setup and GRO-HW logic according to the latest spec Michael Chan
2018-08-05 20:51 ` [PATCH net-next 07/13] bnxt_en: Add support for ethtool get dump Michael Chan
2018-08-05 20:51 ` [PATCH net-next 08/13] bnxt_en: Add BNXT_NEW_RM() macro Michael Chan
2018-08-05 20:51 ` [PATCH net-next 09/13] bnxt_en: Move firmware related flags to a new fw_cap field in struct bnxt Michael Chan
2018-08-05 20:51 ` [PATCH net-next 10/13] bnxt_en: Notify firmware about IF state changes Michael Chan
2018-08-05 20:51 ` [PATCH net-next 11/13] bnxt_en: Add hwmon sysfs support to read temperature Michael Chan
2018-08-05 20:51 ` [PATCH net-next 12/13] bnxt_en: Add DCBNL DSCP application protocol support Michael Chan
2018-08-05 20:51 ` [PATCH net-next 13/13] bnxt_en: Do not use the CNP CoS queue for networking traffic Michael Chan
2018-08-06 0:37 ` [PATCH net-next 00/13] bnxt_en: Updates for net-next David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1533502318-22359-5-git-send-email-michael.chan@broadcom.com \
--to=michael.chan@broadcom.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox