fctl.c revision 585995d5d19489bf178112c08c8c61ffc049ff6e
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/mdb_modapi.h>
#include <time.h>
/*
* If we #include <string.h> then other definitions fail. This is
* the easiest way of getting access to the function
*/
/* we need 26 bytes for the cftime() call */
#define TIMESTAMPSIZE 26 * sizeof (char)
/* for backward compatibility */
typedef struct fc_trace_dmsgv1 {
int id_size;
int id_flag;
struct fc_trace_dmsgv1 *id_next;
static struct pwwn_hash *fp_pwwn_table;
static struct d_id_hash *fp_did_table;
static uint32_t pd_hash_index;
struct fc_local_port port;
/*
*/
/*
* Initialize the fc_fca_port_t walker by either using the given starting
* address, or reading the value of the kernel's fctl_fca_portlist pointer.
* We also allocate a fc_fca_port_t for storage, and save this using the
* walk_data pointer.
*/
static int
{
mdb_warn("failed to read 'fctl_fca_portlist'");
return (WALK_ERR);
}
return (WALK_NEXT);
}
/*
* At each step, read a fc_fca_port_t into our private storage, and then invoke
* the callback function. We terminate when we reach a NULL p_next pointer.
*/
static int
{
int status;
return (WALK_DONE);
== -1) {
return (WALK_DONE);
}
wsp->walk_cbdata);
return (status);
}
/*
* The walker's fini function is invoked at the end of each walk. Since we
* dynamically allocated a fc_fca_port_t in port_walk_i, we must free it now.
*/
static void
{
}
static int
{
if (argc > 1) {
return (DCMD_USAGE);
}
return (DCMD_USAGE);
}
if (!(flags & DCMD_ADDRSPEC)) {
if (longlist == 0) {
mdb_warn("failed to walk 'fctl_fca_portlist'");
return (DCMD_ERR);
}
} else {
mdb_warn("failed to walk 'fctl_fca_portlist'");
return (DCMD_ERR);
}
}
return (DCMD_OK);
}
/*
* If this is the first invocation of the command, print a nice
* header line for the output that will follow.
*/
if (DCMD_HDRSPEC(flags))
mdb_printf("%16s %-2s %4s %-4s%16s %16s %16s\n",
"Port", "I#", "State", "Soft", "FCA Handle",
"Port DIP", "FCA Port DIP");
/*
* For each port, we just need to read the fc_fca_port_t struct, read
* the port_handle
*/
sizeof (fc_fca_port_t)) {
/*
* Now read that port in
*/
mdb_printf("%16p %2d %4x %4x %16p %16p %16p\n",
} else
mdb_warn("failed to read port at %p",
} else
return (DCMD_OK);
}
/*
*/
static int
{
mdb_warn("failed to read 'fctl_ulp_list'");
return (WALK_ERR);
}
return (WALK_NEXT);
}
static int
{
int status;
return (WALK_DONE);
== -1) {
return (WALK_DONE);
}
wsp->walk_cbdata);
return (status);
}
static void
{
}
static int
{
char ulp_name[30];
if (argc != 0) {
return (DCMD_USAGE);
}
/*
* If no fc_ulp_list_t address was specified on the command line, we can
* print out all processes by invoking the walker, using this
* dcmd itself as the callback.
*/
if (!(flags & DCMD_ADDRSPEC)) {
mdb_warn("failed to walk 'fc_ulp_list_t'");
return (DCMD_ERR);
}
return (DCMD_OK);
}
/*
* If this is the first invocation of the command, print a nice
* header line for the output that will follow.
*/
if (DCMD_HDRSPEC(flags))
/*
* For each port, we just need to read the fc_fca_port_t struct, read
* the port_handle
*/
sizeof (fc_ulp_list_t)) {
/*
* Now read that port in
*/
mdb_printf("%30s %4x %8x\n",
}
} else
mdb_warn("failed to read ulp at %p",
} else
return (DCMD_OK);
}
/*
*/
static int
{
mdb_warn("failed to read 'fctl_ulp_modules'");
return (WALK_ERR);
}
return (WALK_NEXT);
}
static int
{
int status;
return (WALK_DONE);
== -1) {
return (WALK_DONE);
}
wsp->walk_cbdata);
return (status);
}
static void
{
}
static int
{
if (argc != 0) {
return (DCMD_USAGE);
}
if (!(flags & DCMD_ADDRSPEC)) {
== -1) {
mdb_warn("failed to walk 'fc_ulp_module_t'");
return (DCMD_ERR);
}
return (DCMD_OK);
}
/*
* If this is the first invocation of the command, print a nice
* header line for the output that will follow.
*/
if (DCMD_HDRSPEC(flags))
mdb_printf("%4s %16s %8s %8s\n",
"Type", "Port Handle", "dstate", "statec");
/*
* For each port, we just need to read the fc_fca_port_t struct, read
* the port_handle
*/
sizeof (fc_ulp_module_t)) {
/*
* Now read that module info in
*/
/* Now read all the ports for this module */
sizeof (fc_ulp_ports_t)) {
mdb_printf("%4x %16p %8x %8x\n",
break;
sizeof (fc_ulp_ports_t),
}
}
} else
mdb_warn("failed to read modinfo at %p",
} else
return (DCMD_OK);
}
/*
* Display an fc_local_port_t struct
*/
static int
{
int idx;
int first = 1;
int walking_fc_fca_portlist = 0;
if (argc != 0) {
int result;
if (argc != 1)
return (DCMD_USAGE);
return (DCMD_USAGE);
}
if (!(flags & DCMD_ADDRSPEC)) {
mdb_printf("Sorry, you must provide an address\n");
return (DCMD_ERR);
}
if (walking_fc_fca_portlist) {
/*
* Must read the fc_fca_portlist to get the fc_local_port addr
*/
sizeof (fc_fca_port_t)) {
}
}
/*
* For each port, we just need to read the fc_local_port_t struct
*/
addr) == sizeof (fc_local_port_t)) {
mdb_printf(" fp_port_id : 0x%-06x\n",
mdb_printf(" fp_soft_state : 0x%-4x\n",
mdb_printf(" fp_statec_busy : 0x%-8x\n",
mdb_printf(" fp_bind_state : 0x%-8x\n",
mdb_printf(" fp_port_type : 0x%-2x\n",
break;
}
if (idx != 16) {
mdb_printf(" fp_ip_addr : %-2x:%-2x:%-2x:%-2x:"
"%-2x:%-2x:%-2x:%-2x:%-2x:%-2x:%-2x:%-2x:%-2x:%-2x"
":%-2x:%-2x\n",
} else {
mdb_printf(" fp_ip_addr : N/A\n");
}
mdb_printf(" fp_fc4_types : ");
if (first) {
mdb_printf("%d",
first = 0;
} else {
mdb_printf(", %d",
}
}
}
if (first) {
mdb_printf("None\n");
} else {
mdb_printf("\n");
}
mdb_printf(" fp_pm_busy_nocomp : 0x%-8x\n",
mdb_printf(" fp_hard_addr : 0x%-6x\n",
mdb_printf(" fp_sym_port_name : \"%s\"\n",
mdb_printf(" fp_sym_node_name : \"%s\"\n",
} else {
}
mdb_printf("\n");
return (DCMD_OK);
}
/*
*/
/*
* We need to be given the address of a port structure in order to start
* walking. From that, we can read the pwwn table.
*/
static int
{
mdb_warn("pd_by_pwwn walk doesn't support global walks\n");
return (WALK_ERR);
}
/*
* Allocate space for the pwwn_hash table
*/
/*
* Input should be an fc_local_port_t, so read it to get the pwwn
* table's head
*/
sizeof (fc_local_port_t)) {
mdb_warn("Unable to read in the port structure address\n");
return (WALK_ERR);
}
mdb_warn("Unable to read in the pwwn hash table\n");
return (WALK_ERR);
}
pd_hash_index = 0;
}
return (WALK_NEXT);
}
/*
* At each step, read a fc_remote_port_t into our private storage, and then
* invoke the callback function. We terminate when we reach a NULL p_next
* pointer.
*/
static int
{
int status;
return (WALK_DONE);
}
== -1) {
return (WALK_DONE);
}
wsp->walk_cbdata);
/*
* Try the next hash list, if there is one.
*/
}
if (pd_hash_index == PWWN_HASH_TABLE_SIZE) {
/* We're done */
return (status);
}
}
return (status);
}
/*
* The walker's fini function is invoked at the end of each walk.
*/
static void
{
}
/*
* This is the same walker as pd_by_pwwn, but we walk the D_ID hash table
*/
static int
{
mdb_warn("pd_by_did walk doesn't support global walks\n");
return (WALK_ERR);
}
/*
* Allocate space for the did_hash table
*/
/*
* Input should be an fc_local_port_t, so read it to get the d_id
* table's head
*/
sizeof (fc_local_port_t)) {
mdb_warn("Unable to read in the port structure address\n");
return (WALK_ERR);
}
mdb_warn("Unable to read in the D_ID hash table\n");
return (WALK_ERR);
}
pd_hash_index = 0;
}
return (WALK_NEXT);
}
/*
* At each step, read a fc_remote_port_t into our private storage, and then
* invoke the callback function. We terminate when we reach a NULL p_next
* pointer.
*/
static int
{
int status;
return (WALK_DONE);
}
== -1) {
return (WALK_DONE);
}
wsp->walk_cbdata);
/*
* Try the next hash list, if there is one.
*/
}
if (pd_hash_index == D_ID_HASH_TABLE_SIZE) {
/* We're done */
return (status);
}
}
return (status);
}
/*
* The walker's fini function is invoked at the end of each walk.
*/
static void
{
fp_did_table = NULL;
}
/*
* Display a remote_port structure
*/
static int
{
int idx;
int first = 1;
if (argc > 0) {
return (DCMD_USAGE);
}
if (!(flags & DCMD_ADDRSPEC)) {
mdb_printf("Sorry, you must provide an address\n");
return (DCMD_ERR);
}
sizeof (fc_remote_port_t)) {
return (DCMD_ERR);
}
mdb_printf(" port_name : 0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
case PORT_DEVICE_INVALID:
mdb_printf("(invalid)\n");
break;
case PORT_DEVICE_VALID:
mdb_printf("(valid)\n");
break;
case PORT_DEVICE_LOGGED_IN:
mdb_printf("(logged in)\n");
break;
default:
mdb_printf("(Unknown state)\n");
}
case PORT_DEVICE_NOCHANGE:
mdb_printf("(No change)\n");
break;
case PORT_DEVICE_NEW:
mdb_printf("(New)\n");
break;
case PORT_DEVICE_OLD:
mdb_printf("(Old)\n");
break;
case PORT_DEVICE_CHANGED:
mdb_printf("(Changed)\n");
break;
case PORT_DEVICE_DELETE:
mdb_printf("(Delete)\n");
break;
case PORT_DEVICE_USER_LOGIN:
mdb_printf("(User login)\n");
break;
case PORT_DEVICE_USER_LOGOUT:
mdb_printf("(User logout)\n");
break;
case PORT_DEVICE_USER_CREATE:
mdb_printf("(User create)\n");
break;
case PORT_DEVICE_USER_DELETE:
mdb_printf("(User delete)\n");
break;
default:
mdb_printf("(Unknown type)\n");
}
case PD_IDLE:
mdb_printf("(Idle)\n");
break;
case PD_ELS_IN_PROGRESS:
mdb_printf("(ELS in progress)\n");
break;
case PD_ELS_MARK:
mdb_printf("(Mark)\n");
break;
default:
mdb_printf("(Unknown flag value)\n");
}
first = 1;
mdb_printf("(IN_DID_QUEUE");
first = 0;
}
if (first) {
mdb_printf("(DISABLE_RELOGIN");
} else {
mdb_printf(", DISABLE_RELOGIN");
}
first = 0;
}
if (first) {
mdb_printf("(NEEDS_REMOVAL");
} else {
mdb_printf(", NEEDS_REMOVAL");
}
first = 0;
}
if (first) {
mdb_printf("(LOGGED_OUT");
} else {
mdb_printf(", LOGGED_OUT");
}
first = 0;
}
if (first) {
mdb_printf("(GIVEN_TO_ULPS");
} else {
mdb_printf(", GIVEN_TO_ULPS");
}
first = 0;
}
if (first == 0) {
mdb_printf(")\n");
} else {
mdb_printf("\n");
}
mdb_printf("\n");
return (DCMD_OK);
}
int
{
char merge[1024];
char *tmpbuf; /* for tokenising the buffer */
sizeof (msg)) {
mdb_warn("failed to read message pointer in kernel");
return (DCMD_ERR);
}
mdb_warn("failed to read buffer contents"
" in kernel");
return (DCMD_ERR);
}
if (buf[0] == '\n') {
mdb_printf("There is a problem in"
"the buffer\n");
}
/* funky packet processing stuff */
/* find the equals sign, and put a null there */
*tmpbuf = 0;
"[%Y:%03d:%03d:%03d] %s",
(*printed) ++;
}
}
}
return (DCMD_OK);
}
int
{
char merge[1024];
char *tmpbuf; /* for tokenising the buffer */
sizeof (msg)) {
mdb_warn("failed to read message pointer in kernel");
return (DCMD_ERR);
}
mdb_warn("failed to read buffer contents"
" in kernel");
return (DCMD_ERR);
}
if (buf[0] == '\n') {
mdb_printf("There is a problem in"
"the buffer\n");
}
/* funky packet processing stuff */
*tmpbuf = 0;
(*printed) ++;
}
}
}
return (DCMD_OK);
}
int
{
mdb_warn("Failed to read log queue in kernel");
return (DCMD_ERR);
}
return (DCMD_USAGE);
}
return (DCMD_USAGE);
}
} else {
}
return (rval);
}
if (printed == 0) {
mdb_printf("No packets in the buffer match the"
" criteria given");
}
return (rval);
}
int
{
mdb_warn("failed to read fp_logq");
return (DCMD_ERR);
}
if (DCMD_HDRSPEC(flags)) {
mdb_printf("fp trace buffer contents\n");
}
}
int
{
mdb_warn("failed to read fcp_logq");
return (DCMD_ERR);
}
if (DCMD_HDRSPEC(flags)) {
mdb_printf("fcp trace buffer contents\n");
}
}
/*
*/
/*
* We need to be given the address of a local port structure in order to start
* walking. From that, we can read the job_request list.
*/
static int
{
mdb_warn("The address of a fc_local_port"
" structure must be given\n");
return (WALK_ERR);
}
/*
* Input should be a fc_local_port_t, so read it to get the job_request
* lists's head
*/
sizeof (fc_local_port_t)) {
mdb_warn("Failed to read in the fc_local_port"
return (WALK_ERR);
}
return (WALK_NEXT);
}
static int
{
int status;
return (WALK_DONE);
mdb_warn("Failed to read in the job_request at 0x%p\n",
return (WALK_DONE);
}
wsp->walk_cbdata);
return (status);
}
/*
* The walker's fini function is invoked at the end of each walk.
*/
static void
{
}
/*
*/
/*
* We need to be given the address of a port structure in order to start
* walking. From that, we can read the orphan list.
*/
static int
{
mdb_warn("The address of a fc_local_port"
" structure must be given\n");
return (WALK_ERR);
}
/*
* Input should be a fc_local_port_t, so read it to get the orphan
* lists's head
*/
sizeof (fc_local_port_t)) {
mdb_warn("Failed to read in the fc_local_port"
return (WALK_ERR);
}
return (WALK_NEXT);
}
static int
{
int status;
return (WALK_DONE);
mdb_warn("Failed to read in the fc_orphan at 0x%p\n",
return (WALK_DONE);
}
wsp->walk_cbdata);
return (status);
}
/*
* The walker's fini function is invoked at the end of each walk.
*/
static void
{
}
/*
* MDB module linkage information:
*
* We declare a list of structures describing our dcmds, a list of structures
* describing our walkers, and a function named _mdb_init to return a pointer
* to our module information.
*/
static const mdb_dcmd_t dcmds[] = {
fcport },
remote_port },
{ "fcptrace", "[-s m][-e n] (m < n)", "Dump the fcp trace buffer, "
"optionally supplying starting and ending packet numbers.",
fcp_trace_dump, NULL },
{ "fptrace", "[-s m][-e n] (m < n)", "Dump the fp trace buffer, "
"optionally supplying starting and ending packet numbers.",
fp_trace_dump, NULL },
{ NULL }
};
static const mdb_walker_t walkers[] = {
{ "ports", "walk list of Leadville port structures",
{ "ulps", "walk list of Leadville ULP structures",
{ "ulpmods", "walk list of Leadville ULP module structures",
{ "pd_by_pwwn", "walk list of fc_remote_port structures hashed by PWWN",
{ "pd_by_did", "walk list of fc_remote_port structures hashed by D_ID",
{ "job_request", "walk list of job_request structures for a local port",
{ "orphan", "walk list of orphan structures for a local port",
{ NULL }
};
static const mdb_modinfo_t modinfo = {
};
const mdb_modinfo_t *
_mdb_init(void)
{
return (&modinfo);
}