wrsmstat.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 (c) 2001 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Display WRSM kstat data.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <kstat.h>
#include <libintl.h>
#include <values.h>
#include <locale.h>
#include <sys/wci_common.h>
#ifndef lint
#include <sys/wci_cmmu.h>
#else
typedef union {
struct {
} bit;
#endif /* lint */
#define ERR_NO_ERR 0
#define ERR_UNKNOWN 1
#define ERR_USAGE 2
#define ERR_KSOPEN 3
#define ERR_KSLOOKUP 4
#define ERR_KSREAD 5
/* Error messages */
/* WCI kstat messages */
/* Route kstat messages */
/* Controller kstat messages */
#define NOT_FOUND 0xffffffff
#define NOT_FOUND64 0xffffffffffffffff
static void show_usage();
kstat_ctl_t *kc);
int
{
int c;
int controller_id = -1;
int wrsm_instance = -1;
int wrsm_id = -1;
int start;
int end;
char *set_argument = NULL;
char *disp_kstat;
int retval;
char *endptr;
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
if (argc < 2) {
/* Not enough arguments */
show_usage();
return (ERR_USAGE);
}
/* which kstat we are displaying */
!= EOF) {
switch (c) {
case 'c':
} else {
}
break;
case 'i':
break;
case 'h':
break;
case 'v':
break;
case 's':
break;
case 'e':
break;
case 'w':
break;
case 'p':
break;
case 'x':
}
break;
default:
show_usage();
return (ERR_USAGE);
}
if (check_endptr) {
show_usage();
return (ERR_USAGE);
}
}
}
/* initialize kstat control structure */
return (ERR_KSOPEN);
}
} else {
/* unless we find something, return error */
RSM_KS_NAME) == 0)) {
}
}
}
/* unless we find something, return error */
if (msg_test) {
nodename = "?";
}
== 0) {
chain->ks_instance)) {
kc);
}
}
}
}
(void) printf(MSG_CONTROLLER_FAIL);
(void) printf(MSG_ROUTE_FAIL);
}
} else if (wrsm_id != -1) {
} else {
/* unless we find something, return error */
WRSM_KSTAT_STATUS) == 0)) {
print_errors, kc);
}
}
}
if (set_argument == NULL ||
show_usage();
return (ERR_USAGE);
}
if (wrsm_instance != -1) {
} else {
/* unless we find something, return error */
WRSM_KSTAT_STATUS) == 0)) {
}
}
}
(void) printf(MSG_WRONG_ARGUMENT);
(void) printf(MSG_ERROR_ARGUMENTS);
(void) printf(MSG_KSTAT_OPEN_FAIL);
(void) printf(MSG_KSTAT_NO_DATA);
(void) printf(MSG_WRSM_FAIL);
(void) printf(MSG_ROUTE_FAIL);
(void) printf(MSG_CONTROLLER_FAIL);
(void) printf(MSG_SUB_NOT_IMPL);
(void) printf(MSG_BAD_SUB);
return (0);
} else {
show_usage();
return (ERR_USAGE);
}
(void) kstat_close(kc);
return (retval);
}
int
{
continue;
}
continue;
}
if (private) {
}
return (ERR_NO_ERR);
} else {
print_errors, kc));
}
}
}
}
return (ERR_KSLOOKUP);
}
int
{
int i;
char ks_name[25];
if (msg_test) {
(void) printf("\n");
(void) printf("-------------\n");
(void) printf(MSG_WCI_NOT_BELONG);
(void) printf(MSG_WCI_IN_LOOPBACK);
(void) printf("\n");
(void) printf(MSG_LINK_NOT_PRES, 0);
(void) printf(MSG_LINK_STATE);
(void) printf(MSG_STATE_UP);
(void) printf(MSG_LINK_STATE);
(void) printf(MSG_STATE_DOWN);
(void) printf(MSG_LINK_STATE);
(void) printf(MSG_STATE_NO_PAROLI);
(void) printf(MSG_LINK_STATE);
(void) printf(MSG_STATE_WAIT_DOWN);
(void) printf(MSG_LINK_STATE);
(void) printf(MSG_STATE_WAIT_UP);
(void) printf(MSG_LINK_STATE);
(void) printf(MSG_STATE_ERR_DOWN);
(void) printf(MSG_LINK_STATE);
(void) printf(MSG_UNKNOWN);
(void) printf(MSG_PHYS_STATE);
(void) printf(MSG_STATE_OFF);
(void) printf(MSG_PHYS_STATE);
(void) printf(MSG_STATE_FAILOVER);
(void) printf(MSG_PHYS_STATE);
(void) printf(MSG_STATE_SEEK);
(void) printf(MSG_PHYS_STATE);
(void) printf(MSG_STATE_IN_USE);
(void) printf(MSG_PHYS_STATE);
(void) printf(MSG_UNKNOWN);
(void) printf("\n");
return (0);
}
WRSM_KSTAT_STATUS)) == NULL) {
return (ERR_KSLOOKUP);
}
return (ERR_KSREAD);
}
(void) printf("\n");
(void) printf("-------------\n");
(void) printf(MSG_WCI_NOT_BELONG);
(void) printf(MSG_WCI_IN_LOOPBACK);
} else {
(void) printf("\n");
}
if (check_links) {
for (i = 0; i < WCI_NUM_LINKS; i++) {
if (value == WRSMKS_LINK_NOT_PRESENT) {
(void) printf(MSG_LINK_NOT_PRES, i);
continue;
}
(void) printf(MSG_LINK_ID, i);
(void) printf(MSG_LINK_STATE);
(void) printf(MSG_STATE_UP);
(void) printf(MSG_STATE_DOWN);
else if (value == lc_not_there)
(void) printf(MSG_STATE_NO_PAROLI);
else if (value == sc_wait_down)
(void) printf(MSG_STATE_WAIT_DOWN);
else if (value == sc_wait_up)
(void) printf(MSG_STATE_WAIT_UP);
else if (value == sc_wait_errdown)
(void) printf(MSG_STATE_ERR_DOWN);
else
(void) printf(MSG_UNKNOWN);
(void) printf(MSG_PHYS_STATE);
(void) printf(MSG_STATE_OFF);
else if (value == phys_failover)
(void) printf(MSG_STATE_FAILOVER);
(void) printf(MSG_STATE_SEEK);
else if (value == phys_in_use)
(void) printf(MSG_STATE_IN_USE);
else
(void) printf(MSG_UNKNOWN);
i);
i);
}
}
if (v) {
}
(void) printf("\n");
return (ERR_NO_ERR);
}
int
{
int i, j;
char ks_name[25];
if (msg_test) {
(void) printf("------------------------\n");
(void) printf(MSG_ROUTE_MH);
(void) printf(MSG_ROUTE_PT);
(void) printf(MSG_ROUTE_LINKID, 0);
(void) printf("\n");
return (0);
}
if ((kstats =
fm_node_name)) == NULL) {
return (ERR_KSLOOKUP);
}
return (ERR_KSREAD);
}
(void) printf("------------------------\n");
if (value == 0) {
(void) printf(MSG_ROUTE_MH);
} else {
(void) printf(MSG_ROUTE_PT);
}
for (i = 0; i < numwcis; i++) {
(void) printf("WCI #%d\n", i);
for (j = 0; j < numlinks; j++) {
if (value2 < 16) {
} else {
}
}
}
(void) printf("\n");
return (ERR_NO_ERR);
}
int
{
char *value_char;
if (msg_test) {
(void) printf("----------\n");
(void) printf(MSG_CTLR_STATE);
(void) printf(MSG_CTLR_NOT_AVAIL);
(void) printf(MSG_CTLR_STATE);
(void) printf(MSG_CTLR_UP);
(void) printf(MSG_CTLR_STATE);
(void) printf(MSG_CTLR_DOWN);
(void) printf("\n");
return (0);
}
if ((kstats =
== NULL) {
return (ERR_KSLOOKUP);
}
return (ERR_KSREAD);
}
if (private) {
return (ERR_NO_ERR);
}
(void) printf("----------\n");
/* rsmpi components */
/* not printing kstat, to ease translation for language localization */
(void) printf(MSG_CTLR_STATE);
if (value_char == NULL) {
(void) printf(MSG_CTLR_NOT_AVAIL);
(void) printf(MSG_CTLR_UP);
} else {
(void) printf(MSG_CTLR_DOWN);
}
/* wrsm specific components */
(void) printf("\n");
return (ERR_NO_ERR);
}
static uint32_t
{
int counter;
return (NOT_FOUND);
}
kna++;
}
return (NOT_FOUND);
}
static uint64_t
{
int counter;
return (NOT_FOUND64);
}
kna++;
}
return (NOT_FOUND64);
}
static char *
{
int counter;
return (NULL);
}
kna++;
}
return (NULL);
}
static void show_usage()
{
"\twrsmstat set [ -i <%s> ] -c cmmu -s <%s> -e <%s>\n",
}
int
{
int i;
int retval;
int fd;
int port;
char devname[32];
WRSM_KSTAT_STATUS)) == NULL) {
return (ERR_KSLOOKUP);
}
return (ERR_KSREAD);
}
return (ERR_KSREAD);
}
if (fd < 0) {
perror("set");
return (-1);
}
/* Enable all */
start = 1;
/* Disable all */
start = 1;
} else {
/* Enable the specified range */
if (end > MAX_CMMU_ENTRIES) {
}
if (start == 0) {
/* Entry 0 is read-only */
start = 1;
}
}
args[1] = 0;
args[2] = i;
if (retval) {
/*
* Walked off end of memory, CMMU might not be
* fully populated, and that's OK.
*/
return (ERR_NO_ERR);
}
perror("set");
return (errno);
}
}
return (ERR_NO_ERR);
}