stmf_sbd.c revision dea05b66b1fa2d0242e78345542e72df4f14a55f
/*
* 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
*/
/*
*/
#include <sys/dditypes.h>
#include <sys/mdb_modapi.h>
#include <lpif.h>
#include <stmf.h>
#include <stmf_ioctl.h>
#include <portif.h>
#include <stmf_sbd.h>
#include <sbd_impl.h>
#define STMF_SBD_FLAG_ARY_SZ 32
#define STMF_SBD_STR_MAX 2048
#define STMF_SBD_VERBOSE 0x00000001
/* structure to pass arguments to mdb_walker callback function */
typedef struct stmf_sbd_cb_s {
"FIBRE_CHANNEL", /* PROTOCOL_FIBRE_CHANNEL 0 */
"PARALLEL_SCSI", /* PROTOCOL_PARALLEL_SCSI 1 */
"SSA", /* PROTOCOL_SSA 2 */
"IEEE_1394", /* PROTOCOL_IEEE_1394 3 */
"SRP", /* PROTOCOL_SRP 4 */
"iSCSI", /* PROTOCOL_iSCSI 5 */
"SAS", /* PROTOCOL_SAS 6 */
"ADT", /* PROTOCOL_ADT 7 */
"ATAPI", /* PROTOCOL_ATAPI 8 */
};
/*
* Support functions.
*/
/*
* Variable 'bits' is a collection of flags for which a corresponding
* description string is available at flag_ary.
* So flag_ary should be an ary of strings with total_bits + 1 strings.
*/
static void
int i, delim = 0;
for (i = 0; i < total_bits; i++) {
delim = 1;
}
curbit <<= 1;
}
mdb_printf("\n");
}
static void
{
"SBD_PGR_APTPL", /* 0x01 */
"SBD_PGR_RSVD_ONE", /* 0x02 */
"SBD_PGR_RSVD_ALL_REGISTRANTS", /* 0x04 */
"SBD_PGR_ALL_KEYS_HAS_IT" /* 0x08 */
};
"Write Exclusive", /* 0x1 */
"ILLEGAL",
"Exclusive Access", /* 0x3 */
"Write Exclusive, Registrants Only", /* 0x5 */
"Exclusive Access, Registrants Only", /* 0x6 */
"Write Exclusive, All Registrants", /* 0x7 */
"Exclusive Access, All Registrants" /* 0x8 */
};
char *type_str = pgr_type_desc[0];
mdb_printf("PGR flags: ");
mdb_printf("Reservation Details \n");
mdb_printf("\tReservation holder: ");
if (pgr->pgr_rsvholder)
else
mdb_printf("All Registrants\n");
mdb_printf("\t type : %d => %s\n",
} else {
mdb_printf("No reservations.\n");
}
}
void
{
return;
}
} else {
mdb_printf("%s(Can not recognize ident data)\n", s);
}
mdb_printf("\n");
}
void
{
"Prints info about pgr keys and reservations on the given lun.\n\n"
"Usage: <addr>::stmf_sbd_pgr_key [-akv]\n"
" where <addr> represent the address of\n"
" sbd_lu_t by default\n"
" or\n"
" sbd_pgr_key_t if '-a' option is specified.\n"
"Options:\n"
" -a if specified, <addr> represents address of sbd_pgr_key_t\n"
" -k if specified, only prints key information\n"
" -v verbose output\n");
}
/*
* MDB WALKERS implementations
*/
static int
{
mdb_warn("failed to read sbd_lu_list\n");
return (WALK_ERR);
}
}
return (WALK_NEXT);
}
static int
{
return (WALK_DONE);
return (WALK_ERR);
}
}
char *
return (str);
}
static int
{
char str[STMF_SBD_STR_MAX];
mdb_printf("\tsl_meta_filename: %-?p %s\n",
mdb_printf("\tsl_data_filename: %-?p %s\n",
mdb_printf("\n");
} else {
}
return (WALK_NEXT);
}
static int
{
mdb_warn("<pgr_key_list addr>::walk stmf_sbd_pgr_key\n");
return (WALK_ERR);
}
return (WALK_NEXT);
}
static int
{
return (WALK_DONE);
return (WALK_ERR);
}
}
static int
{
"SBD_PGR_KEY_ALL_TG_PT", /* 0x01 */
"SBD_PGR_KEY_TPT_ID_FLAG", /* 0x02 */
};
mdb_printf("\tKey Flags: ");
mdb_printf("\tLocal Device ID: %?-p\n",
mdb_printf("\tRemote scsi devid desc: %?-p\n",
} else {
}
return (WALK_NEXT);
}
static int
{
mdb_warn("<sbd_it_list addr>::walk stmf_sbd_pgr_key\n");
return (WALK_ERR);
}
return (WALK_NEXT);
}
static int
{
return (WALK_DONE);
return (WALK_ERR);
}
}
static int
{
"SBD_IT_HAS_SCSI2_RESERVATION", /* 0x0001 */
"SBD_IT_PGR_REGISTERED", /* 0x0002 */
"SBD_IT_PGR_EXCLUSIVE_RSV_HOLDER", /* 0x0004 */
"SBD_IT_PGR_CHECK_FLAG", /* 0x0008 */
};
mdb_printf("\tIT Flags: ");
mdb_printf("\n");
} else {
}
return (WALK_NEXT);
}
/*
* MDB DCMDS implementations.
*/
int
{
stmf_sbd_cb_t cb_st = {0};
!= argc)
return (DCMD_USAGE);
if (verbose)
if (flags & DCMD_ADDRSPEC) {
return (DCMD_ERR);
}
return (DCMD_ERR);
} else {
&cb_st) == -1) {
mdb_warn("failed to walk sbd_lu_list\n");
return (DCMD_ERR);
}
}
return (DCMD_OK);
}
static int
{
stmf_sbd_cb_t cb_st = {0};
if (!(flags & DCMD_ADDRSPEC))
return (DCMD_USAGE);
return (DCMD_USAGE);
if (pgrkeyaddr || verbose)
/* If address of pgr_key is given, just print that key and return */
if (pgrkeyaddr) {
return (DCMD_ERR);
}
return (DCMD_ERR);
}
return (DCMD_OK);
} else {
return (DCMD_ERR);
}
}
if (verbose) {
}
/* Just a sanity check, not necessarily needed */
if (verbose)
return (DCMD_OK);
}
return (DCMD_ERR);
}
if (!keyonly)
if (verbose)
mdb_printf("No registered pgr keys found\n");
return (DCMD_OK);
} else {
if (!keyonly)
mdb_printf("\nKeys\n");
}
mdb_warn("failed to walk pgr_keylist\n");
return (DCMD_ERR);
}
return (DCMD_OK);
}
static int
{
stmf_sbd_cb_t cb_st = {0};
if (!(flags & DCMD_ADDRSPEC))
return (DCMD_USAGE);
return (DCMD_USAGE);
if (verbose) {
}
/* If address of pgr_key is given, just print that key and return */
return (DCMD_ERR);
}
/* Just a sanity check, not necessarily needed */
if (verbose)
return (DCMD_OK);
}
mdb_warn("failed to walk sbd_lu_it_list\n");
return (DCMD_ERR);
}
return (DCMD_OK);
}
/*
* MDB dmcds and walkers definitions
*/
static const mdb_dcmd_t dcmds[] = {
{ "stmf_sbd_lu", "?[-v]", "Print the list of sbd_lu_t",
stmf_sbd_lu, NULL },
{ "stmf_sbd_it", ":[-v]", "Print the list of sbd_it_data for given lu",
stmf_sbd_it, NULL },
{ "stmf_sbd_pgr_key", ":[-kov]", "Print the list of pgr keys",
{ NULL }
};
static const mdb_walker_t walkers[] = {
{ "stmf_sbd_lu", "walk list of stmf_sbd_lu structures",
{ "stmf_sbd_pgr_key", "walk the pgr keys of the given pgr key list",
{ "stmf_sbd_it", "walk the sbd_it_data for the given it list",
{ NULL }
};
static const mdb_modinfo_t modinfo = {
};
const mdb_modinfo_t *
_mdb_init(void)
{
return (&modinfo);
}