stmf.c revision fcf3ce441efd61da9bb2884968af01cb7c1452cc
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/dditypes.h>
#include <sys/mdb_modapi.h>
#include <stmf_impl.h>
#include <lun_map.h>
#include <stmf_state.h>
#include <fct_impl.h>
#include "cmd_options.h"
static int
{
struct stmf_state state;
"stmf_state") == -1) {
mdb_warn("failed to read stmf_state");
return (WALK_ERR);
}
}
return (WALK_NEXT);
}
static int
{
return (WALK_DONE);
mdb_warn("failed to read stmf_i_local_port_t at %p",
return (WALK_ERR);
}
if (wsp->walk_callback)
wsp->walk_cbdata);
return (status);
}
static void
{
}
static int
{
return (DCMD_OK);
if (verbose) {
/* here assume the alias is maximumly 1024 bytes */
char alias[255];
struct stmf_local_port lport;
struct stmf_i_local_port ilport;
== -1) {
mdb_warn("failed to read stmf_i_local_port at %p",
ilportp);
return (DCMD_ERR);
}
mdb_warn("failed to read stmf_local_port at %p",
return (DCMD_ERR);
}
mdb_warn("failed to read memory at %p",
return (DCMD_ERR);
}
if (lport.lport_alias)
}
return (DCMD_OK);
}
/*ARGSUSED*/
static int
{
int i;
int verbose = 0;
for (i = 0; i < argc; i++) {
if (ptr[0] == '-')
ptr++;
while (*ptr) {
if (*ptr == 'v')
verbose = 1;
ptr++;
}
}
return (DCMD_ERR);
return (DCMD_OK);
}
struct stmf_i_local_port *
{
return (NULL);
}
}
return (NULL);
}
}
/*ARGSUSED*/
static int
{
struct stmf_i_local_port iport;
struct stmf_i_scsi_session *issp;
struct stmf_i_scsi_session iss;
int i;
int verbose = 0;
for (i = 0; i < argc; i++) {
if (ptr[0] == '-')
ptr++;
while (*ptr) {
if (*ptr == 'v')
verbose = 1;
ptr++;
}
}
mdb_warn("address of stmf_i_local_port should be specified\n");
return (DCMD_ERR);
}
/*
* Input should be stmf_i_local_port_t.
*/
!= sizeof (struct stmf_i_local_port)) {
return (DCMD_ERR);
}
while (issp) {
mdb_warn("failed to read stmf_i_scsi_session_t at %p",
issp);
return (DCMD_ERR);
}
if (verbose) {
}
}
return (DCMD_OK);
}
/*ARGSUSED*/
static int
{
struct stmf_state state;
int i;
int verbose = 0;
for (i = 0; i < argc; i++) {
if (ptr[0] == '-')
ptr++;
while (*ptr) {
if (*ptr == 'v')
verbose = 1;
ptr++;
}
}
== -1) {
mdb_warn("failed to read stmf_state");
return (DCMD_ERR);
}
while (ilup) {
== -1) {
return (DCMD_ERR);
}
if (verbose) {
/* XXX lu_alias? what is its size? */
}
}
return (DCMD_OK);
}
/*ARGSUSED*/
static int
{
struct stmf_state state;
struct stmf_i_lu_provider ilp;
struct stmf_i_lu_provider *ilpp;
int i;
int verbose = 0;
for (i = 0; i < argc; i++) {
if (ptr[0] == '-')
ptr++;
while (*ptr) {
if (*ptr == 'v')
verbose = 1;
ptr++;
}
}
== -1) {
mdb_warn("failed to read stmf_state");
return (DCMD_ERR);
}
while (ilpp) {
mdb_warn("failed to read stmf_i_lu_provider_t at %p",
ilpp);
return (DCMD_ERR);
}
if (verbose) {
}
}
return (DCMD_OK);
}
/*ARGSUSED*/
static int
{
struct stmf_state state;
struct stmf_i_port_provider ipp;
struct stmf_i_port_provider *ippp;
int i;
int verbose = 0;
for (i = 0; i < argc; i++) {
if (ptr[0] == '-')
ptr++;
while (*ptr) {
if (*ptr == 'v')
verbose = 1;
ptr++;
}
}
== -1) {
mdb_warn("failed to read stmf_state");
return (DCMD_ERR);
}
while (ippp) {
mdb_warn("failed to read stmf_i_port_provider_t at %p",
ippp);
return (DCMD_ERR);
}
if (verbose) {
}
}
return (DCMD_OK);
}
static uint16_t port_max_logins;
static int rp_index;
/*
* Cervert stmf_i_local_port to fct_i_local_port
*/
/*ARGSUSED*/
static struct fct_i_local_port *
{
struct stmf_i_local_port iport;
struct stmf_local_port lport;
struct fct_local_port fport;
if (!(flags & DCMD_ADDRSPEC)) {
mdb_warn("stmf_i_local_port address should be specified");
return (NULL);
}
/*
* Input should be stmf_i_local_port_t.
*/
!= sizeof (struct stmf_i_local_port)) {
mdb_warn("Unable to read in stmf_i_local_port\n");
return (NULL);
}
mdb_warn("Unable to read in stmf_local_port\n");
return (NULL);
}
!= sizeof (fct_local_port_t)) {
mdb_warn("Unable to read in fct_local_port\n");
return (NULL);
}
return (fport.port_fct_private);
}
static int
{
struct fct_i_local_port *iportp;
int i;
int verbose = 0;
for (i = 0; i < argc; i++) {
if (ptr[0] == '-')
ptr++;
while (*ptr) {
if (*ptr == 'v')
verbose = 1;
ptr++;
}
}
if (iportp) {
if (verbose) {
struct fct_i_local_port iport;
/* is the alias always 16 bytes in size ? */
char alias[16];
!= sizeof (fct_i_local_port_t)) {
mdb_warn("Unable to read in fct_i_local_port"
"at %p\n", iportp);
return (DCMD_ERR);
}
if (iport.iport_alias &&
!= sizeof (alias)) {
mdb_warn("Unable to read in memory at %p",
return (DCMD_ERR);
}
if (iport.iport_alias)
}
}
return (DCMD_OK);
}
/*
* by wwn, we can only find one local port
*/
static struct stmf_i_local_port *
{
struct stmf_i_local_port *siport;
struct fct_i_local_port *fiport;
struct fct_i_local_port iport;
struct fct_local_port fport;
0, NULL);
return (NULL);
!= sizeof (fct_i_local_port_t)) {
mdb_warn("Unable to read in fct_i_local_port\n");
return (NULL);
}
!= sizeof (fct_local_port_t)) {
mdb_warn("Unable to read in fct_local_port\n");
return (NULL);
}
#if 0
mdb_printf("pwwn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
#endif
return (siport);
}
}
return (NULL);
}
/*ARGSUSED*/
static int
{
struct find_options *options;
struct stmf_i_local_port *siport;
/* need to free options manually ? */
mdb_printf("lpname=<wwn.12345678 or 12345678> "
"should be specified\n");
return (DCMD_OK);
}
return (DCMD_OK);
}
static int
{
struct fct_local_port port;
struct fct_i_local_port iport;
mdb_warn("Can not perform global walk");
return (WALK_ERR);
}
/*
* Input should be fct_i_local_port_t.
*/
!= sizeof (struct fct_i_local_port)) {
mdb_warn("Unable to read in fct_i_local_port\n");
return (WALK_ERR);
}
!= sizeof (struct fct_local_port)) {
mdb_warn("Unable to read in fct_local_port\n");
return (WALK_ERR);
}
rp_index = 0;
return (WALK_NEXT);
}
static int
{
return (WALK_DONE);
if (rp_index++ >= port_max_logins)
return (WALK_DONE);
mdb_warn("failed to read address of fct_i_remote_port_t at %p",
return (WALK_DONE);
}
wsp->walk_cbdata);
return (status);
}
static void
{
}
/*
* to set remote_port
*/
/*ARGSUSED*/
static int
{
return (WALK_NEXT);
}
static int
{
int i;
int verbose = 0;
for (i = 0; i < argc; i++) {
if (ptr[0] == '-')
ptr++;
while (*ptr) {
if (*ptr == 'v')
verbose = 1;
ptr++;
}
}
if (!(flags & DCMD_ADDRSPEC)) {
mdb_warn("fct_i_local_port_t address should be specified");
return (DCMD_ERR);
}
fct_irp_walk_i(&ws);
if (irpp) {
if (verbose) {
mdb_warn("Unable to read in "
"fct_i_remote_port at %p\n", irpp);
return (DCMD_ERR);
}
}
}
}
fct_irp_walk_f(&ws);
return (DCMD_OK);
}
static fct_i_remote_port_t *
{
int ret;
fct_irp_walk_f(&ws);
return (NULL);
}
fct_irp_walk_f(&ws);
return (NULL);
}
}
return (irp);
}
}
fct_irp_walk_f(&ws);
/*
* If it is WALK_DONE, there may be one remote port there
*/
return (irp);
}
return (NULL);
}
static struct stmf_i_local_port *
{
struct fct_i_remote_port irp;
struct fct_remote_port rp;
struct fct_local_port port;
struct stmf_local_port lport;
!= sizeof (struct fct_i_remote_port)) {
mdb_warn("Unable to read in fct_i_remote_port\n");
return (NULL);
}
!= sizeof (struct fct_remote_port)) {
mdb_warn("Unable to read in fct_remote_port\n");
return (NULL);
}
!= sizeof (struct fct_local_port)) {
mdb_warn("Unable to read in fct_local_port\n");
return (NULL);
}
!= sizeof (struct stmf_local_port)) {
mdb_warn("Unable to read in stmf_local_port\n");
return (NULL);
}
return (lport.lport_stmf_private);
}
/*
* by wwn, we may find more than one remote port, so we need to know its
* corresponding local port
*/
static struct fct_i_remote_port *
{
struct fct_i_local_port *fiport;
struct fct_i_remote_port irp;
struct fct_remote_port rp;
return (NULL);
!= sizeof (struct fct_i_remote_port)) {
mdb_warn("Unable to read in fct_i_remote_port\n");
break;
}
!= sizeof (struct fct_remote_port)) {
mdb_warn("Unable to read in fct_remote_port\n");
break;
}
break;
}
}
return (ret);
}
/*ARGSUSED*/
static int
{
struct stmf_i_local_port *siport;
struct find_options *options;
/* need to free options manually ? */
options->rp_defined == 0)) {
mdb_printf("rpname=<wwn.12345678> or rp=<3000586778734>"
" should be specified\n");
return (DCMD_OK);
}
mdb_printf("rpname=<wwn.12345678> or rp=<3000586778734>"
" should be specified, but not both\n");
return (DCMD_OK);
}
if (options->rp_defined) {
mdb_printf("stmf_i_local_port=%p,"
" fct_i_remote_port=%p\n",
return (DCMD_OK);
}
/* if options->rpname_defined */
mdb_printf("stmf_i_local_port=%p, "
"fct_i_remote_port=%p\n",
}
return (DCMD_OK);
}
typedef void (*cmd_filter_t) (struct fct_i_cmd *,
struct find_options *, void *);
/*ARGSUSED*/
static void
{
mdb_warn("Unable to read in fct_i_cmd\n");
return;
}
mdb_warn("Unable to read in fct_cmd\n");
return;
}
int colon_printed = 0;
!= sizeof (struct scsi_task)) {
mdb_warn("Unable to read in scsi_task\n");
return;
}
if (options->show_task_flags) {
mdb_printf(":");
colon_printed = 1;
}
if (options->show_lport) {
if (colon_printed == 0) {
mdb_printf(":");
colon_printed = 1;
}
}
mdb_printf("\n");
}
}
static void
void *arg)
{
mdb_warn("Unable to read in fct_i_cmd\n");
return;
}
mdb_warn("Unable to read in fct_cmd\n");
return;
}
/* arg is a pointer to fct_i_remote_port */
mdb_warn("Unable to read in fct_i_remote_port\n");
return;
}
int colon_printed = 0;
!= sizeof (struct scsi_task)) {
mdb_warn("Unable to read in scsi_task\n");
return;
}
if (options->show_task_flags) {
mdb_printf(":");
colon_printed = 1;
}
if (options->show_lport) {
if (colon_printed == 0) {
mdb_printf(":");
colon_printed = 1;
}
}
mdb_printf("\n");
}
}
/*ARGSUSED*/
static void
{
}
/*
* find outstanding cmds (fct_i_cmd) on local port
*/
static int
{
struct fct_i_local_port *iportp;
struct fct_i_local_port iport;
struct fct_local_port port;
struct fct_cmd_slot *slotp;
struct fct_cmd_slot slot;
int i;
return (DCMD_ERR);
mdb_warn("Unable to read in fct_i_local_port\n");
return (DCMD_ERR);
}
mdb_warn("Unable to read in fct_local_port\n");
return (DCMD_ERR);
}
for (i = 0; i < port.port_max_xchges; i++) {
mdb_warn("Unable to read in fct_cmd_slot\n");
return (DCMD_ERR);
}
else
}
slotp ++;
}
return (DCMD_OK);
}
/*ARGSUSED*/
static int
{
struct find_options *options;
struct stmf_i_local_port *siport;
mdb_printf("lpname=<wwn.12345678> or rpname=<wwn.12345678>"
" should be specified\n");
return (DCMD_OK);
}
if (options->lpname_defined) {
return (DCMD_ERR);
return (DCMD_OK);
}
if (options->rpname_defined) {
!= NULL) {
}
}
}
return (DCMD_OK);
}
/*ARGSUSED*/
static int
{
struct find_options *options;
struct stmf_i_local_port *siport;
mdb_printf("lpname=<wwn.12345678> should be specified\n");
return (DCMD_OK);
}
return (DCMD_ERR);
return (DCMD_OK);
}
static int
{
struct fct_i_local_port iport;
int i;
int verbose = 0;
for (i = 0; i < argc; i++) {
if (ptr[0] == '-')
ptr++;
while (*ptr) {
if (*ptr == 'v')
verbose = 1;
ptr++;
}
}
if (!(flags & DCMD_ADDRSPEC)) {
mdb_warn("fct_i_local_port_t address should be specified");
return (DCMD_ERR);
}
!= sizeof (struct fct_i_local_port)) {
return (DCMD_ERR);
}
while (icmdp) {
return (DCMD_ERR);
}
if (verbose) {
}
}
return (DCMD_OK);
}
struct find_options *
{
int i;
struct find_options *options;
int len;
char *ptr;
int ret;
if (argc == 0)
return (NULL);
for (i = 0; i < argc; i++) {
case MDB_TYPE_STRING:
break;
case MDB_TYPE_IMMEDIATE:
case MDB_TYPE_CHAR:
mdb_printf("unknown type\n");
}
mdb_printf("invalid argument: %s\n",
goto out;
}
ptr++; /* point to value now */
ptr += 4;
if (ret == -1)
goto out;
#if 0
mdb_printf("wwn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
#endif
(void *)(unsigned long)mdb_strtoull(ptr);
ptr += 4;
if (ret == -1)
goto out;
char *s;
int l;
for (;;) {
if (s)
l = s - ptr;
else
if (l == strlen("task_flags") &&
else if (l == strlen("lport") &&
else {
mdb_printf("unknown shower: %s\n",
ptr);
goto out;
}
if (s == NULL)
break;
ptr = s + 1;
}
} else {
mdb_printf("unknown argument: %s\n",
goto out;
}
}
return (options);
out:
return (NULL);
}
int
{
int i;
char tmp[17];
char *p;
if (strlen(s) > 16) {
mdb_printf("invalid wwn %s\n", s);
return (-1);
}
/* figure out wwn from the tail to beginning */
wwn[i] = mdb_strtoull(p);
*p = 0;
}
return (0);
}
void
fct_find_cmds_help(void)
{
"Find all cached fct_i_cmd_t for a local port. If a local port \n"
"name is specified, find all pending cmds for it and print the \n"
"address. Example:\n"
" fct_find_cmds lpname=<wwn.12345678 or 12345678>\n");
}
void
stmf_find_ilport_help(void)
{
"Find the fct_i_local_port if local port name is "
"specified. Example:\n"
" stmf_find_ilport lpname=<wwn.12345678 or 12345678>\n");
}
void
stmf_find_fct_irp_help(void)
{
"If a remote port name or stmf_i_remote_port_t address is\n"
"specified, loop through all local ports, to which this remote \n"
"port has logged in, print address for stmf_i_local_port_t and \n"
"stmf_i_remote_port. Example:\n"
" stmf_find_fct_irp rpname=<wwn.12345678 or 12345678>\n"
" stmf_find_fct_irp rp=<3000586778734>\n");
}
void
stmf_find_tasks_help(void)
{
"remote port. Various different fields for each task are printed\n"
"depending on what is requested. Example:\n"
" stmf_find_tasks rpname=<wwn.12345678 or 12345678>\n"
" stmf_find_tasks lpname=<wwn.12345678 or 12345678> "
"show=task_flags,lport\n");
}
static const mdb_dcmd_t dcmds[] = {
{ "stmf_ilports", "[-v]",
"Print a list of stmf_i_local_port", stmf_ilports },
{ "ilport2iport", "?[-v]",
"Convert stmf_i_local_port to corresponding fct_i_local_port",
ilport2iport },
{ "stmf_iss", "?[-v]",
"List all active sessions for a given local port",
stmf_iss },
{ "stmf_i_lu_providers", "[-v]",
"Print a list of stmf_i_lu_provider", stmf_i_lu_providers },
{ "stmf_i_port_providers", "[-v]",
"Print a list of stmf_i_port_provider", stmf_i_port_providers },
{ "fct_irps", "?[-v]",
"Print all fct_i_remote_port for a given fct_i_local_port",
fct_irps },
{ "fct_icmds", "?[-v]",
"Print all cached fct_i_cmd_t on fct_i_local_port",
fct_icmds },
{ "fct_find_cmds", "lpname",
"Find all fct_i_cmd_t for a given local port",
{ "stmf_find_ilport", "lpname",
"Find local port information based on its wwn",
{ "stmf_find_fct_irp", "rpname|rp",
"Print fct remote port information based on its wwn",
{ "stmf_find_tasks", "lpname|rpname [show]",
"Find all pending task for a local port or remote port",
{ NULL }
};
static const mdb_walker_t walkers[] = {
{ NULL }
};
static const mdb_modinfo_t modinfo = {
};
const mdb_modinfo_t *
_mdb_init(void)
{
return (&modinfo);
}