svn commit: r296493 - in head/sys/dev/cxgbe: . common
Navdeep Parhar
np at FreeBSD.org
Tue Mar 8 08:59:36 UTC 2016
Author: np
Date: Tue Mar 8 08:59:34 2016
New Revision: 296493
URL: https://svnweb.freebsd.org/changeset/base/296493
Log:
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.
Modified:
head/sys/dev/cxgbe/common/common.h
head/sys/dev/cxgbe/common/t4_hw.c
head/sys/dev/cxgbe/t4_main.c
Modified: head/sys/dev/cxgbe/common/common.h
==============================================================================
--- head/sys/dev/cxgbe/common/common.h Tue Mar 8 08:57:53 2016 (r296492)
+++ head/sys/dev/cxgbe/common/common.h Tue Mar 8 08:59:34 2016 (r296493)
@@ -692,6 +692,7 @@ int t4_sge_ctxt_rd(struct adapter *adap,
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,
Modified: head/sys/dev/cxgbe/common/t4_hw.c
==============================================================================
--- head/sys/dev/cxgbe/common/t4_hw.c Tue Mar 8 08:57:53 2016 (r296492)
+++ head/sys/dev/cxgbe/common/t4_hw.c Tue Mar 8 08:59:34 2016 (r296493)
@@ -7430,6 +7430,31 @@ int t4_ofld_eq_free(struct adapter *adap
}
/**
+ * 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
Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c Tue Mar 8 08:57:53 2016 (r296492)
+++ head/sys/dev/cxgbe/t4_main.c Tue Mar 8 08:59:34 2016 (r296493)
@@ -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);
More information about the svn-src-all
mailing list