Author: np
Date: Sat Aug 12 14:02:19 2017
New Revision: 322425
URL: https://svnweb.freebsd.org/changeset/base/322425

Log:
  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

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/common/t4_hw.c
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/adapter.h
==============================================================================
--- head/sys/dev/cxgbe/adapter.h        Sat Aug 12 12:17:38 2017        
(r322424)
+++ head/sys/dev/cxgbe/adapter.h        Sat Aug 12 14:02:19 2017        
(r322425)
@@ -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 *);

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==============================================================================
--- head/sys/dev/cxgbe/common/t4_hw.c   Sat Aug 12 12:17:38 2017        
(r322424)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Sat Aug 12 14:02:19 2017        
(r322425)
@@ -7715,7 +7715,7 @@ int t4_handle_fw_rpl(struct adapter *adap, const __be6
                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 __be6
                }
 
                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);

Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c        Sat Aug 12 12:17:38 2017        
(r322424)
+++ head/sys/dev/cxgbe/t4_main.c        Sat Aug 12 14:02:19 2017        
(r322425)
@@ -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_pt
 }
 
 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;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to