summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@joyent.com>2016-06-06 22:32:15 -0700
committerRobert Mustacchi <rm@joyent.com>2016-07-20 08:56:10 -0700
commit20c06695f48b938258cc8a122e3e3f602bd0b9a3 (patch)
tree460592c6ce0ef2a5b58100e7393625154b46374b
parent5b91507b1aabcd9611f3f4a651feb6450520b1d4 (diff)
downloadillumos-joyent-20c06695f48b938258cc8a122e3e3f602bd0b9a3.tar.gz
7098 ::prtconf could filter by attached driver name
Reviewed by: Joshua M. Clulow <jmc@joyent.com> Approved by: Matthew Ahrens <mahrens@delphix.com>
-rw-r--r--usr/src/cmd/mdb/common/modules/genunix/devinfo.c65
-rw-r--r--usr/src/cmd/mdb/common/modules/genunix/devinfo.h2
-rw-r--r--usr/src/cmd/mdb/common/modules/genunix/genunix.c5
-rw-r--r--usr/src/cmd/mdb/common/modules/genunix/hotplug.c1
4 files changed, 57 insertions, 16 deletions
diff --git a/usr/src/cmd/mdb/common/modules/genunix/devinfo.c b/usr/src/cmd/mdb/common/modules/genunix/devinfo.c
index 513103a682..d5da280040 100644
--- a/usr/src/cmd/mdb/common/modules/genunix/devinfo.c
+++ b/usr/src/cmd/mdb/common/modules/genunix/devinfo.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2016 Joyent, Inc.
*/
#include <sys/types.h>
@@ -74,9 +75,10 @@ prtconf_help(void)
"with an address, prints the parents of, "
"and all children of, that address.\n\n"
"Switches:\n"
- " -v be verbose - print device property lists\n"
- " -p only print the ancestors of the given node\n"
- " -c only print the children of the given node\n");
+ " -v be verbose - print device property lists\n"
+ " -p only print the ancestors of the given node\n"
+ " -c only print the children of the given node\n"
+ " -d driver only print instances of driver\n");
}
void
@@ -580,7 +582,8 @@ is_printable_string(unsigned char *prop_value)
}
static void
-devinfo_print_props_type(int type) {
+devinfo_print_props_type(int type)
+{
char *type_str = NULL;
switch (type) {
@@ -612,7 +615,7 @@ devinfo_print_props_type(int type) {
static void
devinfo_print_props_value(int elem_size, int nelem,
- unsigned char *prop_value, int prop_value_len)
+ unsigned char *prop_value, int prop_value_len)
{
int i;
@@ -839,7 +842,8 @@ next:
}
static void
-devinfo_pathinfo_state(mdi_pathinfo_state_t state) {
+devinfo_pathinfo_state(mdi_pathinfo_state_t state)
+{
char *type_str = NULL;
switch (state) {
@@ -866,7 +870,8 @@ devinfo_pathinfo_state(mdi_pathinfo_state_t state) {
}
static void
-devinfo_print_pathing(int mdi_component, void *mdi_client) {
+devinfo_print_pathing(int mdi_component, void *mdi_client)
+{
mdi_client_t mdi_c;
struct mdi_pathinfo *pip;
@@ -898,7 +903,7 @@ devinfo_print_pathing(int mdi_component, void *mdi_client) {
/* read in the pathinfo structure */
if (mdb_vread((void*)&pi, sizeof (pi),
- (uintptr_t)pip) == -1) {
+ (uintptr_t)pip) == -1) {
mdb_warn("failed to read mdi_pathinfo at %p",
(uintptr_t)pip);
goto exit;
@@ -906,7 +911,7 @@ devinfo_print_pathing(int mdi_component, void *mdi_client) {
/* read in the pchi (path host adapter) info */
if (mdb_vread((void*)&ph, sizeof (ph),
- (uintptr_t)pi.pi_phci) == -1) {
+ (uintptr_t)pi.pi_phci) == -1) {
mdb_warn("failed to read mdi_pchi at %p",
(uintptr_t)pi.pi_phci);
goto exit;
@@ -914,13 +919,13 @@ devinfo_print_pathing(int mdi_component, void *mdi_client) {
/* read in the dip of the phci so we can get it's name */
if (mdb_vread((void*)&ph_di, sizeof (ph_di),
- (uintptr_t)ph.ph_dip) == -1) {
+ (uintptr_t)ph.ph_dip) == -1) {
mdb_warn("failed to read mdi_pchi at %p",
(uintptr_t)ph.ph_dip);
goto exit;
}
if (mdb_vread(binding_name, sizeof (binding_name),
- (uintptr_t)ph_di.devi_binding_name) == -1) {
+ (uintptr_t)ph_di.devi_binding_name) == -1) {
mdb_warn("failed to read binding_name at %p",
(uintptr_t)ph_di.devi_binding_name);
goto exit;
@@ -932,7 +937,7 @@ devinfo_print_pathing(int mdi_component, void *mdi_client) {
/* print out the pathing info */
mdb_inc_indent(DEVINFO_PROP_INDENT);
if (mdb_pwalk_dcmd(NVPAIR_WALKER_FQNAME, NVPAIR_DCMD_FQNAME,
- 0, NULL, (uintptr_t)pi.pi_prop) != 0) {
+ 0, NULL, (uintptr_t)pi.pi_prop) != 0) {
mdb_dec_indent(DEVINFO_PROP_INDENT);
goto exit;
}
@@ -954,6 +959,7 @@ devinfo_print(uintptr_t addr, struct dev_info *dev, devinfo_cb_data_t *data)
char dname[MODMAXNAMELEN + 1];
devinfo_node_t *din = (devinfo_node_t *)dev;
ddi_prop_t *global_props = NULL;
+ boolean_t hdname = B_FALSE;
if (mdb_readstr(binding_name, sizeof (binding_name),
(uintptr_t)dev->devi_binding_name) == -1) {
@@ -974,6 +980,30 @@ devinfo_print(uintptr_t addr, struct dev_info *dev, devinfo_cb_data_t *data)
global_props = plist.prop_list;
}
+ if (dev->devi_node_state > DS_ATTACHED) {
+ if (mdb_devinfo2driver(addr, dname, sizeof (dname)) == 0)
+ hdname = B_TRUE;
+ }
+
+ /*
+ * If a filter is installed and we don't have the driver's name, we
+ * always skip it. Also if the filter doesn't match, then we'll also
+ * skip the driver.
+ */
+ if (data->di_filter != NULL &&
+ (!hdname || strcmp(data->di_filter, dname) != 0)) {
+ return (WALK_NEXT);
+ }
+
+ /*
+ * If we are output to a pipe, we only print the address of the
+ * devinfo_t.
+ */
+ if (data->di_flags & DEVINFO_PIPE) {
+ mdb_printf("%-0?p\n", addr);
+ return (WALK_NEXT);
+ }
+
mdb_inc_indent(din->din_depth * DEVINFO_TREE_INDENT);
if ((addr == data->di_base) || (data->di_flags & DEVINFO_ALLBOLD))
mdb_printf("%<b>");
@@ -985,7 +1015,7 @@ devinfo_print(uintptr_t addr, struct dev_info *dev, devinfo_cb_data_t *data)
if (dev->devi_node_state < DS_ATTACHED)
mdb_printf(" (driver not attached)");
- else if (mdb_devinfo2driver(addr, dname, sizeof (dname)) != 0)
+ else if (hdname == B_FALSE)
mdb_printf(" (could not determine driver name)");
else
mdb_printf(" (driver name: %s)", dname);
@@ -1017,8 +1047,13 @@ prtconf(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
int status;
data.di_flags = DEVINFO_PARENT | DEVINFO_CHILD;
+ data.di_filter = NULL;
+
+ if (flags & DCMD_PIPE_OUT)
+ data.di_flags |= DEVINFO_PIPE;
if (mdb_getopts(argc, argv,
+ 'd', MDB_OPT_STR, &data.di_filter,
'v', MDB_OPT_SETBITS, DEVINFO_VERBOSE, &data.di_flags,
'p', MDB_OPT_CLRBITS, DEVINFO_CHILD, &data.di_flags,
'c', MDB_OPT_CLRBITS, DEVINFO_PARENT, &data.di_flags, NULL) != argc)
@@ -1036,7 +1071,8 @@ prtconf(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
}
data.di_base = addr;
- mdb_printf("%<u>%-?s %-50s%</u>\n", "DEVINFO", "NAME");
+ if (!(flags & DCMD_PIPE_OUT))
+ mdb_printf("%<u>%-?s %-50s%</u>\n", "DEVINFO", "NAME");
if ((data.di_flags & (DEVINFO_PARENT | DEVINFO_CHILD)) ==
(DEVINFO_PARENT | DEVINFO_CHILD)) {
@@ -1118,6 +1154,7 @@ devinfo(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
data.di_flags = DEVINFO_VERBOSE;
data.di_base = addr;
+ data.di_filter = NULL;
if (mdb_getopts(argc, argv,
'q', MDB_OPT_CLRBITS, DEVINFO_VERBOSE, &data.di_flags,
diff --git a/usr/src/cmd/mdb/common/modules/genunix/devinfo.h b/usr/src/cmd/mdb/common/modules/genunix/devinfo.h
index a279faf215..438fc2268f 100644
--- a/usr/src/cmd/mdb/common/modules/genunix/devinfo.h
+++ b/usr/src/cmd/mdb/common/modules/genunix/devinfo.h
@@ -42,10 +42,12 @@ extern "C" {
#define DEVINFO_ALLBOLD 0x8
#define DEVINFO_SUMMARY 0x10
#define DEVINFO_HP_PHYSICAL 0x20
+#define DEVINFO_PIPE 0x40
typedef struct devinfo_cb_data {
uintptr_t di_base;
uint_t di_flags;
+ char *di_filter;
} devinfo_cb_data_t;
extern int devinfo_walk_init(mdb_walk_state_t *);
diff --git a/usr/src/cmd/mdb/common/modules/genunix/genunix.c b/usr/src/cmd/mdb/common/modules/genunix/genunix.c
index 5a8deb8994..0ba14e436e 100644
--- a/usr/src/cmd/mdb/common/modules/genunix/genunix.c
+++ b/usr/src/cmd/mdb/common/modules/genunix/genunix.c
@@ -21,7 +21,7 @@
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2015 Joyent, Inc.
+ * Copyright 2016 Joyent, Inc.
* Copyright (c) 2013 by Delphix. All rights reserved.
*/
@@ -4030,7 +4030,8 @@ static const mdb_dcmd_t dcmds[] = {
modctl2devinfo },
{ "name2major", "<dev-name>", "convert dev name to major number",
name2major },
- { "prtconf", "?[-vpc]", "print devinfo tree", prtconf, prtconf_help },
+ { "prtconf", "?[-vpc] [-d driver]", "print devinfo tree", prtconf,
+ prtconf_help },
{ "softstate", ":<instance>", "retrieve soft-state pointer",
softstate },
{ "devinfo_fm", ":", "devinfo fault managment configuration",
diff --git a/usr/src/cmd/mdb/common/modules/genunix/hotplug.c b/usr/src/cmd/mdb/common/modules/genunix/hotplug.c
index 12b70b3669..a6a21d4f82 100644
--- a/usr/src/cmd/mdb/common/modules/genunix/hotplug.c
+++ b/usr/src/cmd/mdb/common/modules/genunix/hotplug.c
@@ -114,6 +114,7 @@ hotplug(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
int status;
data.di_flags = 0;
+ data.di_filter = NULL;
if (mdb_getopts(argc, argv,
'p', MDB_OPT_SETBITS, DEVINFO_HP_PHYSICAL, &data.di_flags, NULL)
!= argc)