svn commit: r253701 - head/sys/dev/cxgbe
Navdeep Parhar
np at FreeBSD.org
Sat Jul 27 07:43:44 UTC 2013
Author: np
Date: Sat Jul 27 07:43:43 2013
New Revision: 253701
URL: http://svnweb.freebsd.org/changeset/base/253701
Log:
Display a string instead of a numeric code in the linkdnrc sysctl.
Submitted by: gnn@
Modified:
head/sys/dev/cxgbe/t4_main.c
Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c Sat Jul 27 05:32:26 2013 (r253700)
+++ head/sys/dev/cxgbe/t4_main.c Sat Jul 27 07:43:43 2013 (r253701)
@@ -392,6 +392,7 @@ static int sysctl_devlog(SYSCTL_HANDLER_
static int sysctl_fcoe_stats(SYSCTL_HANDLER_ARGS);
static int sysctl_hw_sched(SYSCTL_HANDLER_ARGS);
static int sysctl_lb_stats(SYSCTL_HANDLER_ARGS);
+static int sysctl_linkdnrc(SYSCTL_HANDLER_ARGS);
static int sysctl_meminfo(SYSCTL_HANDLER_ARGS);
static int sysctl_mps_tcam(SYSCTL_HANDLER_ARGS);
static int sysctl_path_mtus(SYSCTL_HANDLER_ARGS);
@@ -4439,8 +4440,8 @@ 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");
+ SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "linkdnrc", CTLTYPE_STRING |
+ CTLFLAG_RD, pi, 0, sysctl_linkdnrc, "A", "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",
@@ -5486,6 +5487,37 @@ sysctl_lb_stats(SYSCTL_HANDLER_ARGS)
return (rc);
}
+static int
+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)
+ return(rc);
+ sb = sbuf_new_for_sysctl(NULL, NULL, 64, req);
+ if (sb == NULL)
+ return (ENOMEM);
+
+ 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);
+
+ rc = sbuf_finish(sb);
+ sbuf_delete(sb);
+
+ return (rc);
+}
+
struct mem_desc {
unsigned int base;
unsigned int limit;
More information about the svn-src-all
mailing list