iprconfig command line fixes. Add some more debug tools
This commit is contained in:
parent
630b7a860b
commit
c9b2c9ad01
7 changed files with 302 additions and 67 deletions
11
debug/Makefile
Normal file
11
debug/Makefile
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
INCLUDEDIR = -I. -I..
|
||||
CC = gcc
|
||||
CFLAGS = -g -Wall $(IPR_DEFINES)
|
||||
|
||||
all : $(patsubst %.c,%,$(wildcard *.c))
|
||||
|
||||
% : %.c
|
||||
$(CC) $(CFLAGS) $(INCLUDEDIR) -o $@ ../iprlib.o $< -lsysfs
|
||||
|
||||
clean:
|
||||
rm -f iprcache iprperf iprshutdown iprtest iprwritebuffer
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* $Header: /cvsroot/iprdd/iprutils/debug/iprcache.c,v 1.1 2005/09/26 20:19:36 brking Exp $
|
||||
* $Header: /cvsroot/iprdd/iprutils/debug/iprcache.c,v 1.2 2005/12/16 17:04:41 brking Exp $
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
|
@ -84,7 +84,6 @@ static int set_caching_page(struct ipr_dev *dev)
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct ipr_dev *dev;
|
||||
int rc;
|
||||
|
||||
openlog("iprcache", LOG_PERROR | LOG_PID | LOG_CONS, LOG_USER);
|
||||
tool_init(1);
|
||||
|
|
|
|||
84
debug/iprluns.c
Normal file
84
debug/iprluns.c
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/**
|
||||
* IBM IPR adapter initialization utility
|
||||
*
|
||||
* (C) Copyright 2005
|
||||
* International Business Machines Corporation and others.
|
||||
* All Rights Reserved. This program and the accompanying
|
||||
* materials are made available under the terms of the
|
||||
* Common Public License v1.0 which accompanies this distribution.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $Header: /cvsroot/iprdd/iprutils/debug/iprluns.c,v 1.1 2005/12/16 17:04:41 brking Exp $
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <scsi/sg.h>
|
||||
#include <scsi/scsi.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifndef iprlib_h
|
||||
#include "iprlib.h"
|
||||
#endif
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
char *tool_name = "iprluns";
|
||||
|
||||
static int ipr_report_luns(struct ipr_dev *dev)
|
||||
{
|
||||
u8 cdb[IPR_CCB_CDB_LEN];
|
||||
int fd, rc, i, len;
|
||||
char buf[100];
|
||||
char *name = dev->gen_name;
|
||||
struct sense_data_t sense_data;
|
||||
|
||||
if (strlen(dev->dev_name))
|
||||
name = dev->dev_name;
|
||||
|
||||
fd = open(name, O_RDWR);
|
||||
if (fd <= 1) {
|
||||
if (!strcmp(tool_name, "iprconfig") || ipr_debug)
|
||||
syslog(LOG_ERR, "Could not open %s. %m\n", name);
|
||||
return errno;
|
||||
}
|
||||
|
||||
memset(cdb, 0, IPR_CCB_CDB_LEN);
|
||||
|
||||
cdb[0] = REPORT_LUNS;
|
||||
cdb[9] = 100;
|
||||
|
||||
rc = sg_ioctl(fd, cdb, buf,
|
||||
100, SG_DXFER_FROM_DEV,
|
||||
&sense_data, IPR_INTERNAL_DEV_TIMEOUT);
|
||||
|
||||
close(fd);
|
||||
|
||||
if (rc)
|
||||
scsi_err(dev, "Report LUNS failed. %m\n");
|
||||
|
||||
len = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
|
||||
|
||||
syslog(LOG_ERR, "Total report luns len: %d\n", len);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct ipr_dev *dev;
|
||||
|
||||
tool_init(1);
|
||||
check_current_config(false);
|
||||
dev = find_blk_dev(argv[1]);
|
||||
if (!dev)
|
||||
dev = find_gen_dev(argv[1]);
|
||||
if (!dev) {
|
||||
fprintf(stderr, "Cannot find device: %s\n", argv[1]);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return ipr_report_luns(dev);
|
||||
}
|
||||
130
debug/iprqioac.c
Executable file
130
debug/iprqioac.c
Executable file
|
|
@ -0,0 +1,130 @@
|
|||
/**
|
||||
* IBM IPR adapter shutdown utility
|
||||
*
|
||||
* (C) Copyright 2005
|
||||
* International Business Machines Corporation and others.
|
||||
* All Rights Reserved. This program and the accompanying
|
||||
* materials are made available under the terms of the
|
||||
* Common Public License v1.0 which accompanies this distribution.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $Header: /cvsroot/iprdd/iprutils/debug/iprqioac.c,v 1.1 2005/12/16 17:04:41 brking Exp $
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <scsi/sg.h>
|
||||
#include <scsi/scsi.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifndef iprlib_h
|
||||
#include "iprlib.h"
|
||||
#endif
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
char *tool_name = "iprqioac";
|
||||
#define IPR_QUERY_IOA_CONFIG 0xC5
|
||||
|
||||
|
||||
struct ipr_config_table_entry {
|
||||
u8 service_level;
|
||||
u8 array_id;
|
||||
u8 flags;
|
||||
#define IPR_IS_IOA_RESOURCE 0x80
|
||||
#define IPR_IS_ARRAY_MEMBER 0x20
|
||||
#define IPR_IS_HOT_SPARE 0x10
|
||||
|
||||
u8 rsvd_subtype;
|
||||
#define IPR_RES_SUBTYPE(res) (((res)->cfgte.rsvd_subtype) & 0x0f)
|
||||
#define IPR_SUBTYPE_AF_DASD 0
|
||||
#define IPR_SUBTYPE_GENERIC_SCSI 1
|
||||
#define IPR_SUBTYPE_VOLUME_SET 2
|
||||
|
||||
struct ipr_res_addr res_addr;
|
||||
u32 res_handle;
|
||||
u32 reserved4[2];
|
||||
struct ipr_std_inq_data std_inq_data;
|
||||
}__attribute__ ((packed, aligned (4)));
|
||||
|
||||
struct ipr_config_table_hdr {
|
||||
u8 num_entries;
|
||||
u8 flags;
|
||||
#define IPR_UCODE_DOWNLOAD_REQ 0x10
|
||||
u16 reserved;
|
||||
}__attribute__((packed, aligned (4)));
|
||||
|
||||
struct ipr_config_table {
|
||||
struct ipr_config_table_hdr hdr;
|
||||
struct ipr_config_table_entry dev[192];
|
||||
}__attribute__((packed, aligned (4)));
|
||||
|
||||
static void dump_config_table(struct ipr_config_table *cfg)
|
||||
{
|
||||
int i;
|
||||
u32 *buf = (u32 *)cfg;
|
||||
|
||||
for (i = 0; i < sizeof(*cfg); i += 16, buf += 4) {
|
||||
if (!buf[0] && !buf[1] && !buf[2] && !buf[3])
|
||||
continue;
|
||||
printf("[%04X] %08X %08X %08X %08X\n",
|
||||
i, ntohl(buf[0]), ntohl(buf[1]),
|
||||
ntohl(buf[2]), ntohl(buf[3]));
|
||||
}
|
||||
}
|
||||
|
||||
static int ipr_ioa_flush(struct ipr_ioa *ioa)
|
||||
{
|
||||
int fd;
|
||||
u8 cdb[IPR_CCB_CDB_LEN];
|
||||
struct sense_data_t sense_data;
|
||||
struct ipr_config_table cfg;
|
||||
int rc;
|
||||
|
||||
memset(&cfg, 0, sizeof(cfg));
|
||||
|
||||
if (strlen(ioa->ioa.gen_name) == 0)
|
||||
return -ENOENT;
|
||||
|
||||
fd = open(ioa->ioa.gen_name, O_RDWR);
|
||||
if (fd <= 1) {
|
||||
syslog(LOG_ERR, "Could not open %s. %m\n", ioa->ioa.gen_name);
|
||||
return errno;
|
||||
}
|
||||
|
||||
memset(cdb, 0, IPR_CCB_CDB_LEN);
|
||||
|
||||
cdb[0] = IPR_QUERY_IOA_CONFIG;
|
||||
cdb[7] = (sizeof(cfg) >> 8) & 0xff;
|
||||
cdb[8] = sizeof(cfg) & 0xff;
|
||||
|
||||
rc = sg_ioctl(fd, cdb, &cfg,
|
||||
sizeof(cfg), SG_DXFER_FROM_DEV,
|
||||
&sense_data, IPR_ARRAY_CMD_TIMEOUT);
|
||||
|
||||
if (rc != 0)
|
||||
ioa_cmd_err(ioa, &sense_data, IPR_QUERY_IOA_CONFIG, rc);
|
||||
else
|
||||
dump_config_table(&cfg);
|
||||
|
||||
close(fd);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct ipr_ioa *ioa;
|
||||
|
||||
tool_init(1);
|
||||
check_current_config(false);
|
||||
for_each_ioa(ioa) {
|
||||
if (!strcmp(ioa->ioa.gen_name, argv[1])) {
|
||||
ipr_ioa_flush(ioa);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* $Header: /cvsroot/iprdd/iprutils/debug/iprshutdown.c,v 1.1 2005/09/26 20:19:36 brking Exp $
|
||||
* $Header: /cvsroot/iprdd/iprutils/debug/iprshutdown.c,v 1.2 2005/12/16 17:04:41 brking Exp $
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
|
@ -27,16 +27,6 @@
|
|||
|
||||
char *tool_name = "iprshutdown";
|
||||
|
||||
static void init_all()
|
||||
{
|
||||
struct ipr_ioa *ioa;
|
||||
|
||||
tool_init(1);
|
||||
check_current_config(false);
|
||||
for_each_ioa(ioa)
|
||||
ipr_init_ioa(ioa);
|
||||
}
|
||||
|
||||
static int ipr_ioa_flush(struct ipr_ioa *ioa)
|
||||
{
|
||||
int fd;
|
||||
|
|
@ -63,7 +53,7 @@ static int ipr_ioa_flush(struct ipr_ioa *ioa)
|
|||
&sense_data, IPR_ARRAY_CMD_TIMEOUT);
|
||||
|
||||
if (rc != 0)
|
||||
ioa_cmd_err(ioa, &sense_data, 0xF7, rc);
|
||||
ioa_cmd_err(ioa, &sense_data, "IOA Shutdown", rc);
|
||||
|
||||
close(fd);
|
||||
return rc;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* $Header: /cvsroot/iprdd/iprutils/debug/iprwritebuffer.c,v 1.1 2005/09/26 20:19:36 brking Exp $
|
||||
* $Header: /cvsroot/iprdd/iprutils/debug/iprwritebuffer.c,v 1.2 2005/12/16 17:04:41 brking Exp $
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
|
@ -37,7 +37,7 @@ static int ipr_update_ucode(struct ipr_dev *dev, char *fname)
|
|||
|
||||
if (fd < 0) {
|
||||
syslog_dbg("Could not open firmware file %s.\n", fname);
|
||||
return;
|
||||
return fd;
|
||||
}
|
||||
|
||||
rc = fstat(fd, &ucode_stats);
|
||||
|
|
|
|||
123
iprconfig.c
123
iprconfig.c
|
|
@ -130,6 +130,62 @@ char *__print_device(struct ipr_dev *, char *, char *, int, int, int, int, int);
|
|||
for (i = 0; i < 2; i++) \
|
||||
(buf)[i] = print_device(dev, (buf)[i], fmt, type);
|
||||
|
||||
static int is_format_allowed(struct ipr_dev *dev)
|
||||
{
|
||||
int rc;
|
||||
struct ipr_cmd_status cmd_status;
|
||||
struct ipr_cmd_status_record *status_record;
|
||||
struct sense_data_t sense_data;
|
||||
|
||||
if (ipr_is_af_dasd_device(dev)) {
|
||||
rc = ipr_query_command_status(dev, &cmd_status);
|
||||
if (rc == 0 && cmd_status.num_records != 0) {
|
||||
status_record = cmd_status.record;
|
||||
if ((status_record->status != IPR_CMD_STATUS_SUCCESSFUL) &&
|
||||
(status_record->status != IPR_CMD_STATUS_FAILED))
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
rc = ipr_test_unit_ready(dev, &sense_data);
|
||||
|
||||
if (rc == CHECK_CONDITION && (sense_data.error_code & 0x7F) == 0x70) {
|
||||
if (sense_data.add_sense_code == 0x31 &&
|
||||
sense_data.add_sense_code_qual == 0x00)
|
||||
return 1;
|
||||
else if ((sense_data.sense_key & 0x0F) == 0x02)
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int can_format_for_raid(struct ipr_dev *dev)
|
||||
{
|
||||
if (dev->ioa->is_secondary)
|
||||
return 0;
|
||||
if (!ipr_is_gscsi(dev) && !ipr_is_af_dasd_device(dev))
|
||||
return 0;
|
||||
if (ipr_is_hot_spare(dev) || !device_supported(dev))
|
||||
return 0;
|
||||
if (ipr_is_array_member(dev) && !dev->dev_rcd->no_cfgte_vol)
|
||||
return 0;
|
||||
if (ipr_is_af_dasd_device(dev) && ipr_device_is_zeroed(dev))
|
||||
return 0;
|
||||
if (!ipr_is_af_dasd_device(dev)) {
|
||||
/* If on a JBOD adapter */
|
||||
if (!dev->ioa->qac_data->num_records)
|
||||
return 0;
|
||||
if (is_af_blocked(dev, 0))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!is_format_allowed(dev))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* not needed after screen_driver can do menus */
|
||||
static void flush_stdscr()
|
||||
{
|
||||
|
|
@ -1146,6 +1202,7 @@ static int __complete_screen_driver_curses(s_node *n_screen, char *complete, int
|
|||
static int __complete_screen_driver(s_node *n_screen, char *complete, int allow_exit)
|
||||
{
|
||||
fprintf(stdout, "\r%s", complete);
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1190,37 +1247,6 @@ static int time_screen_driver(s_node *n_screen, unsigned long seconds, int allow
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int is_format_allowed(struct ipr_dev *dev)
|
||||
{
|
||||
int rc;
|
||||
struct ipr_cmd_status cmd_status;
|
||||
struct ipr_cmd_status_record *status_record;
|
||||
struct sense_data_t sense_data;
|
||||
|
||||
if (ipr_is_af_dasd_device(dev)) {
|
||||
rc = ipr_query_command_status(dev, &cmd_status);
|
||||
if (rc == 0 && cmd_status.num_records != 0) {
|
||||
status_record = cmd_status.record;
|
||||
if ((status_record->status != IPR_CMD_STATUS_SUCCESSFUL) &&
|
||||
(status_record->status != IPR_CMD_STATUS_FAILED))
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
rc = ipr_test_unit_ready(dev, &sense_data);
|
||||
|
||||
if (rc == CHECK_CONDITION && (sense_data.error_code & 0x7F) == 0x70) {
|
||||
if (sense_data.add_sense_code == 0x31 &&
|
||||
sense_data.add_sense_code_qual == 0x00)
|
||||
return 1;
|
||||
else if ((sense_data.sense_key & 0x0F) == 0x02)
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void evaluate_device(struct ipr_dev *ipr_dev, struct ipr_ioa *ioa,
|
||||
int new_block_size)
|
||||
{
|
||||
|
|
@ -5312,9 +5338,11 @@ int send_dev_inits(i_container *i_con)
|
|||
int max_y, max_x;
|
||||
u8 length;
|
||||
|
||||
getmaxyx(stdscr,max_y,max_x);
|
||||
mvaddstr(max_y-1,0,wait_for_next_screen);
|
||||
refresh();
|
||||
if (use_curses) {
|
||||
getmaxyx(stdscr,max_y,max_x);
|
||||
mvaddstr(max_y-1,0,wait_for_next_screen);
|
||||
refresh();
|
||||
}
|
||||
|
||||
for_each_dev_to_init(cur_dev_init) {
|
||||
if (cur_dev_init->do_init &&
|
||||
|
|
@ -8884,10 +8912,17 @@ static int format_for_jbod(char **args, int num_args)
|
|||
static int format_for_raid(char **args, int num_args)
|
||||
{
|
||||
int i;
|
||||
struct ipr_dev *dev;
|
||||
|
||||
for (i = 0; i < num_args; i++) {
|
||||
if (raid_create_add_dev(args[i]))
|
||||
return -EIO;
|
||||
dev = find_and_add_dev(args[i]);
|
||||
if (!dev || !can_format_for_raid(dev)) {
|
||||
fprintf(stderr, "Invalid device: %s\n", args[i]);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
add_format_device(dev, dev->ioa->af_block_size);
|
||||
dev_init_tail->do_init = 1;
|
||||
}
|
||||
|
||||
send_dev_inits(NULL);
|
||||
|
|
@ -10388,21 +10423,7 @@ static int query_format_for_raid(char **args, int num_args)
|
|||
|
||||
for_each_primary_ioa(ioa) {
|
||||
for_each_disk(ioa, dev) {
|
||||
if (ipr_is_hot_spare(dev) || !device_supported(dev))
|
||||
continue;
|
||||
if (ipr_is_array_member(dev) && !dev->dev_rcd->no_cfgte_vol)
|
||||
continue;
|
||||
if (ipr_is_af_dasd_device(dev) && ipr_device_is_zeroed(dev))
|
||||
continue;
|
||||
if (!ipr_is_af_dasd_device(dev)) {
|
||||
/* If on a JBOD adapter */
|
||||
if (!ioa->qac_data->num_records)
|
||||
continue;
|
||||
if (is_af_blocked(dev, 0))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!is_format_allowed(dev))
|
||||
if (!can_format_for_raid(dev))
|
||||
continue;
|
||||
|
||||
if (!hdr) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue