aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/cxgbe
diff options
context:
space:
mode:
authorNavdeep Parhar <np@FreeBSD.org>2016-03-08 08:59:34 +0000
committerNavdeep Parhar <np@FreeBSD.org>2016-03-08 08:59:34 +0000
commitf799998f84090c3036d1fe4181ed75d7f60517e2 (patch)
treee6bf1abc2fe9bee5f0919df91b4f390c6d31912a /sys/dev/cxgbe
parent448f746eb6a984e1f2ae51bbe7bdf58892dceb8f (diff)
downloadsrc-f799998f84090c3036d1fe4181ed75d7f60517e2.tar.gz
src-f799998f84090c3036d1fe4181ed75d7f60517e2.zip
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.
Notes
Notes: svn path=/head/; revision=296493
Diffstat (limited to 'sys/dev/cxgbe')
-rw-r--r--sys/dev/cxgbe/common/common.h1
-rw-r--r--sys/dev/cxgbe/common/t4_hw.c25
-rw-r--r--sys/dev/cxgbe/t4_main.c8
3 files changed, 27 insertions, 7 deletions
diff --git a/sys/dev/cxgbe/common/common.h b/sys/dev/cxgbe/common/common.h
index 77143d616471..edad0bc322f3 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 ff4e2ceba747..de14318abf92 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 a4dd431c9e3b..340a81558777 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);