From 5d973bad2a362df755dce26a951df73e244d1f5f Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Sat, 12 Aug 2017 14:02:19 +0000 Subject: [PATCH] cxgbe(4): Save the last reported link parameters and compare them with the current state to determine whether to generate a link-state change notification. This fixes a bug introduced in r321063 that caused the driver to sometimes skip these notifications. Reported by: Jason Eggleston @ LLNW MFC after: 3 days Sponsored by: Chelsio Communications --- sys/dev/cxgbe/adapter.h | 5 +++-- sys/dev/cxgbe/common/t4_hw.c | 17 +++++++++-------- sys/dev/cxgbe/t4_main.c | 8 ++++---- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index cdedca3e6471..1e4c98dde149 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -287,6 +287,7 @@ struct port_info { uint8_t rx_chan_map; /* rx MPS channel bitmap */ struct link_config link_cfg; + struct link_config old_link_cfg; struct timeval last_refreshed; struct port_stats stats; @@ -1124,8 +1125,8 @@ extern device_method_t cxgbe_methods[]; int t4_os_find_pci_capability(struct adapter *, int); int t4_os_pci_save_state(struct adapter *); int t4_os_pci_restore_state(struct adapter *); -void t4_os_portmod_changed(struct port_info *, int, int, struct link_config *); -void t4_os_link_changed(struct port_info *, struct link_config *); +void t4_os_portmod_changed(struct port_info *); +void t4_os_link_changed(struct port_info *); void t4_iterate(void (*)(struct adapter *, void *), void *); void t4_init_devnames(struct adapter *); void t4_add_adapter(struct adapter *); diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c index 862e4dc5d830..444a0927a0ab 100644 --- a/sys/dev/cxgbe/common/t4_hw.c +++ b/sys/dev/cxgbe/common/t4_hw.c @@ -7715,7 +7715,7 @@ int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl) int i, old_ptype, old_mtype; int chan = G_FW_PORT_CMD_PORTID(be32_to_cpu(p->op_to_portid)); struct port_info *pi = NULL; - struct link_config *lc, old_lc; + struct link_config *lc, *old_lc; for_each_port(adap, i) { pi = adap2pinfo(adap, i); @@ -7724,19 +7724,20 @@ int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl) } lc = &pi->link_cfg; - old_lc = *lc; + old_lc = &pi->old_link_cfg; old_ptype = pi->port_type; old_mtype = pi->mod_type; handle_port_info(pi, &p->u.info); if (old_ptype != pi->port_type || old_mtype != pi->mod_type) { - t4_os_portmod_changed(pi, old_ptype, old_mtype, - &old_lc); + t4_os_portmod_changed(pi); } - if (old_lc.link_ok != lc->link_ok || - old_lc.speed != lc->speed || - old_lc.fc != lc->fc) { - t4_os_link_changed(pi, &old_lc); + if (old_lc->link_ok != lc->link_ok || + old_lc->speed != lc->speed || + old_lc->fec != lc->fec || + old_lc->fc != lc->fc) { + t4_os_link_changed(pi); + *old_lc = *lc; } } else { CH_WARN_RATELIMIT(adap, "Unknown firmware reply %d\n", opcode); diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 64bdf4a78f79..9243589e8834 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -4335,7 +4335,8 @@ cxgbe_uninit_synchronized(struct vi_info *vi) pi->link_cfg.link_ok = 0; pi->link_cfg.speed = 0; pi->link_cfg.link_down_rc = 255; - t4_os_link_changed(pi, NULL); + t4_os_link_changed(pi); + pi->old_link_cfg = pi->link_cfg; return (0); } @@ -9274,8 +9275,7 @@ t4_os_pci_restore_state(struct adapter *sc) } void -t4_os_portmod_changed(struct port_info *pi, int old_ptype, int old_mtype, - struct link_config *old_lc) +t4_os_portmod_changed(struct port_info *pi) { struct vi_info *vi; struct ifnet *ifp; @@ -9312,7 +9312,7 @@ t4_os_portmod_changed(struct port_info *pi, int old_ptype, int old_mtype, } void -t4_os_link_changed(struct port_info *pi, struct link_config *old_lc) +t4_os_link_changed(struct port_info *pi) { struct vi_info *vi; struct ifnet *ifp;