diff options
author | np <np@FreeBSD.org> | 2016-03-08 08:59:34 +0000 |
---|---|---|
committer | np <np@FreeBSD.org> | 2016-03-08 08:59:34 +0000 |
commit | 077b368018cc5188632e39a021b1784cc1c543cf (patch) | |
tree | e6bf1abc2fe9bee5f0919df91b4f390c6d31912a | |
parent | 1e3bce6245a4b8342f502e4caf3cd0f532c14eaa (diff) | |
download | FreeBSD-src-077b368018cc5188632e39a021b1784cc1c543cf.zip FreeBSD-src-077b368018cc5188632e39a021b1784cc1c543cf.tar.gz |
cxgbe(4): Use t4_link_down_rc_str in shared code to decode the reason
the link is down, instead of doing it in OS specific code.
-rw-r--r-- | sys/dev/cxgbe/common/common.h | 1 | ||||
-rw-r--r-- | sys/dev/cxgbe/common/t4_hw.c | 25 | ||||
-rw-r--r-- | sys/dev/cxgbe/t4_main.c | 8 |
3 files changed, 27 insertions, 7 deletions
diff --git a/sys/dev/cxgbe/common/common.h b/sys/dev/cxgbe/common/common.h index 77143d6..edad0bc 100644 --- a/sys/dev/cxgbe/common/common.h +++ b/sys/dev/cxgbe/common/common.h @@ -692,6 +692,7 @@ int t4_sge_ctxt_rd(struct adapter *adap, unsigned int mbox, unsigned int cid, int t4_sge_ctxt_rd_bd(struct adapter *adap, unsigned int cid, enum ctxt_type ctype, u32 *data); int t4_sge_ctxt_flush(struct adapter *adap, unsigned int mbox); +const char *t4_link_down_rc_str(unsigned char link_down_rc); int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl); int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox, u32 addr, u32 val); int t4_sched_config(struct adapter *adapter, int type, int minmaxen, diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c index ff4e2ce..de14318 100644 --- a/sys/dev/cxgbe/common/t4_hw.c +++ b/sys/dev/cxgbe/common/t4_hw.c @@ -7430,6 +7430,31 @@ int t4_ofld_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf, } /** + * t4_link_down_rc_str - return a string for a Link Down Reason Code + * @link_down_rc: Link Down Reason Code + * + * Returns a string representation of the Link Down Reason Code. + */ +const char *t4_link_down_rc_str(unsigned char link_down_rc) +{ + static const char *reason[] = { + "Link Down", + "Remote Fault", + "Auto-negotiation Failure", + "Reserved3", + "Insufficient Airflow", + "Unable To Determine Reason", + "No RX Signal Detected", + "Reserved7", + }; + + if (link_down_rc >= ARRAY_SIZE(reason)) + return "Bad Reason Code"; + + return reason[link_down_rc]; +} + +/** * t4_handle_fw_rpl - process a FW reply message * @adap: the adapter * @rpl: start of the FW message diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index a4dd431..340a815 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -6020,10 +6020,6 @@ sysctl_linkdnrc(SYSCTL_HANDLER_ARGS) int rc = 0; struct port_info *pi = arg1; struct sbuf *sb; - static const char *linkdnreasons[] = { - "non-specific", "remote fault", "autoneg failed", "reserved3", - "PHY overheated", "unknown", "rx los", "reserved7" - }; rc = sysctl_wire_old_buffer(req, 0); if (rc != 0) @@ -6034,10 +6030,8 @@ sysctl_linkdnrc(SYSCTL_HANDLER_ARGS) if (pi->linkdnrc < 0) sbuf_printf(sb, "n/a"); - else if (pi->linkdnrc < nitems(linkdnreasons)) - sbuf_printf(sb, "%s", linkdnreasons[pi->linkdnrc]); else - sbuf_printf(sb, "%d", pi->linkdnrc); + sbuf_printf(sb, "%s", t4_link_down_rc_str(pi->linkdnrc)); rc = sbuf_finish(sb); sbuf_delete(sb); |