Author: np
Date: Fri Jul  5 01:53:51 2013
New Revision: 252747
URL: http://svnweb.freebsd.org/changeset/base/252747

Log:
  - Show the reason why link is down if this information is available.
  - Display the temperature and PHY firmware version of the BT PHY.
  
  MFC after:    1 day

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        Fri Jul  5 01:49:20 2013        
(r252746)
+++ head/sys/dev/cxgbe/adapter.h        Fri Jul  5 01:53:51 2013        
(r252747)
@@ -218,6 +218,7 @@ struct port_info {
        int qsize_rxq;
        int qsize_txq;
 
+       int linkdnrc;
        struct link_config link_cfg;
        struct port_stats stats;
 
@@ -776,7 +777,7 @@ int t4_os_find_pci_capability(struct ada
 int t4_os_pci_save_state(struct adapter *);
 int t4_os_pci_restore_state(struct adapter *);
 void t4_os_portmod_changed(const struct adapter *, int);
-void t4_os_link_changed(struct adapter *, int, int);
+void t4_os_link_changed(struct adapter *, int, int, int);
 void t4_iterate(void (*)(struct adapter *, void *), void *);
 int t4_register_cpl_handler(struct adapter *, int, cpl_handler_t);
 int t4_register_an_handler(struct adapter *, an_handler_t);

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==============================================================================
--- head/sys/dev/cxgbe/common/t4_hw.c   Fri Jul  5 01:49:20 2013        
(r252746)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Fri Jul  5 01:53:51 2013        
(r252747)
@@ -5351,11 +5351,18 @@ int t4_handle_fw_rpl(struct adapter *ada
 
                if (link_ok != lc->link_ok || speed != lc->speed ||
                    fc != lc->fc) {                    /* something changed */
+                       int reason;
+
+                       if (!link_ok && lc->link_ok)
+                               reason = G_FW_PORT_CMD_LINKDNRC(stat);
+                       else
+                               reason = -1;
+
                        lc->link_ok = link_ok;
                        lc->speed = speed;
                        lc->fc = fc;
                        lc->supported = ntohs(p->u.info.pcap);
-                       t4_os_link_changed(adap, i, link_ok);
+                       t4_os_link_changed(adap, i, link_ok, reason);
                }
                if (mod != pi->mod_type) {
                        pi->mod_type = mod;

Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c        Fri Jul  5 01:49:20 2013        
(r252746)
+++ head/sys/dev/cxgbe/t4_main.c        Fri Jul  5 01:53:51 2013        
(r252747)
@@ -373,6 +373,7 @@ static int t4_sysctls(struct adapter *);
 static int cxgbe_sysctls(struct port_info *);
 static int sysctl_int_array(SYSCTL_HANDLER_ARGS);
 static int sysctl_bitfield(SYSCTL_HANDLER_ARGS);
+static int sysctl_btphy(SYSCTL_HANDLER_ARGS);
 static int sysctl_holdoff_tmr_idx(SYSCTL_HANDLER_ARGS);
 static int sysctl_holdoff_pktc_idx(SYSCTL_HANDLER_ARGS);
 static int sysctl_qsize_rxq(SYSCTL_HANDLER_ARGS);
@@ -679,6 +680,7 @@ t4_attach(device_t dev)
                }
 
                pi->xact_addr_filt = -1;
+               pi->linkdnrc = -1;
 
                pi->qsize_rxq = t4_qsize_rxq;
                pi->qsize_txq = t4_qsize_txq;
@@ -2931,7 +2933,8 @@ cxgbe_uninit_synchronized(struct port_in
 
        pi->link_cfg.link_ok = 0;
        pi->link_cfg.speed = 0;
-       t4_os_link_changed(sc, pi->port_id, 0);
+       pi->linkdnrc = -1;
+       t4_os_link_changed(sc, pi->port_id, 0, -1);
 
        return (0);
 }
@@ -4408,6 +4411,16 @@ cxgbe_sysctls(struct port_info *pi)
        oid = device_get_sysctl_tree(pi->dev);
        children = SYSCTL_CHILDREN(oid);
 
+       SYSCTL_ADD_INT(ctx, children, OID_AUTO, "linkdnrc", CTLFLAG_RD,
+           &pi->linkdnrc, 0, "reason why link is down");
+       if (pi->port_type == FW_PORT_TYPE_BT_XAUI) {
+               SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "temperature",
+                   CTLTYPE_INT | CTLFLAG_RD, pi, 0, sysctl_btphy, "I",
+                   "PHY temperature (in Celsius)");
+               SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "fw_version",
+                   CTLTYPE_INT | CTLFLAG_RD, pi, 1, sysctl_btphy, "I",
+                   "PHY firmware version");
+       }
        SYSCTL_ADD_INT(ctx, children, OID_AUTO, "nrxq", CTLFLAG_RD,
            &pi->nrxq, 0, "# of rx queues");
        SYSCTL_ADD_INT(ctx, children, OID_AUTO, "ntxq", CTLFLAG_RD,
@@ -4645,6 +4658,31 @@ sysctl_bitfield(SYSCTL_HANDLER_ARGS)
 }
 
 static int
+sysctl_btphy(SYSCTL_HANDLER_ARGS)
+{
+       struct port_info *pi = arg1;
+       int op = arg2;
+       struct adapter *sc = pi->adapter;
+       u_int v;
+       int rc;
+
+       rc = begin_synchronized_op(sc, pi, SLEEP_OK | INTR_OK, "t4btt");
+       if (rc)
+               return (rc);
+       /* XXX: magic numbers */
+       rc = -t4_mdio_rd(sc, sc->mbox, pi->mdio_addr, 0x1e, op ? 0x20 : 0xc820,
+           &v);
+       end_synchronized_op(sc, 0);
+       if (rc)
+               return (rc);
+       if (op == 0)
+               v /= 256;
+
+       rc = sysctl_handle_int(oidp, &v, 0, req);
+       return (rc);
+}
+
+static int
 sysctl_holdoff_tmr_idx(SYSCTL_HANDLER_ARGS)
 {
        struct port_info *pi = arg1;
@@ -7191,16 +7229,20 @@ t4_os_portmod_changed(const struct adapt
 }
 
 void
-t4_os_link_changed(struct adapter *sc, int idx, int link_stat)
+t4_os_link_changed(struct adapter *sc, int idx, int link_stat, int reason)
 {
        struct port_info *pi = sc->port[idx];
        struct ifnet *ifp = pi->ifp;
 
        if (link_stat) {
+               pi->linkdnrc = -1;
                ifp->if_baudrate = IF_Mbps(pi->link_cfg.speed);
                if_link_state_change(ifp, LINK_STATE_UP);
-       } else
+       } else {
+               if (reason >= 0)
+                       pi->linkdnrc = reason;
                if_link_state_change(ifp, LINK_STATE_DOWN);
+       }
 }
 
 void
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to