linux/drivers/staging/i2o/debug.c
<<
>>
Prefs
   1#include <linux/module.h>
   2#include <linux/kernel.h>
   3#include <linux/pci.h>
   4#include "i2o.h"
   5
   6static void i2o_report_util_cmd(u8 cmd);
   7static void i2o_report_exec_cmd(u8 cmd);
   8static void i2o_report_fail_status(u8 req_status, u32 *msg);
   9static void i2o_report_common_status(u8 req_status);
  10static void i2o_report_common_dsc(u16 detailed_status);
  11
  12/*
  13 * Used for error reporting/debugging purposes.
  14 * Report Cmd name, Request status, Detailed Status.
  15 */
  16void i2o_report_status(const char *severity, const char *str,
  17                       struct i2o_message *m)
  18{
  19        u32 *msg = (u32 *) m;
  20        u8 cmd = (msg[1] >> 24) & 0xFF;
  21        u8 req_status = (msg[4] >> 24) & 0xFF;
  22        u16 detailed_status = msg[4] & 0xFFFF;
  23
  24        if (cmd == I2O_CMD_UTIL_EVT_REGISTER)
  25                return;         /* No status in this reply */
  26
  27        printk("%s%s: ", severity, str);
  28
  29        if (cmd < 0x1F)         // Utility cmd
  30                i2o_report_util_cmd(cmd);
  31
  32        else if (cmd >= 0xA0 && cmd <= 0xEF)    // Executive cmd
  33                i2o_report_exec_cmd(cmd);
  34        else
  35                printk("Cmd = %0#2x, ", cmd);   // Other cmds
  36
  37        if (msg[0] & MSG_FAIL) {
  38                i2o_report_fail_status(req_status, msg);
  39                return;
  40        }
  41
  42        i2o_report_common_status(req_status);
  43
  44        if (cmd < 0x1F || (cmd >= 0xA0 && cmd <= 0xEF))
  45                i2o_report_common_dsc(detailed_status);
  46        else
  47                printk(" / DetailedStatus = %0#4x.\n",
  48                       detailed_status);
  49}
  50
  51/* Used to dump a message to syslog during debugging */
  52void i2o_dump_message(struct i2o_message *m)
  53{
  54#ifdef DEBUG
  55        u32 *msg = (u32 *) m;
  56        int i;
  57
  58        printk(KERN_INFO "Dumping I2O message size %d @ %p\n",
  59               msg[0] >> 16 & 0xffff, msg);
  60        for (i = 0; i < ((msg[0] >> 16) & 0xffff); i++)
  61                printk(KERN_INFO "  msg[%d] = %0#10x\n", i, msg[i]);
  62#endif
  63}
  64
  65/*
  66 * Used for error reporting/debugging purposes.
  67 * Following fail status are common to all classes.
  68 * The preserved message must be handled in the reply handler.
  69 */
  70static void i2o_report_fail_status(u8 req_status, u32 *msg)
  71{
  72        static char *FAIL_STATUS[] = {
  73                "0x80",         /* not used */
  74                "SERVICE_SUSPENDED",    /* 0x81 */
  75                "SERVICE_TERMINATED",   /* 0x82 */
  76                "CONGESTION",
  77                "FAILURE",
  78                "STATE_ERROR",
  79                "TIME_OUT",
  80                "ROUTING_FAILURE",
  81                "INVALID_VERSION",
  82                "INVALID_OFFSET",
  83                "INVALID_MSG_FLAGS",
  84                "FRAME_TOO_SMALL",
  85                "FRAME_TOO_LARGE",
  86                "INVALID_TARGET_ID",
  87                "INVALID_INITIATOR_ID",
  88                "INVALID_INITIATOR_CONTEX",     /* 0x8F */
  89                "UNKNOWN_FAILURE"       /* 0xFF */
  90        };
  91
  92        if (req_status == I2O_FSC_TRANSPORT_UNKNOWN_FAILURE)
  93                printk("TRANSPORT_UNKNOWN_FAILURE (%0#2x).\n",
  94                       req_status);
  95        else
  96                printk("TRANSPORT_%s.\n",
  97                       FAIL_STATUS[req_status & 0x0F]);
  98
  99        /* Dump some details */
 100
 101        printk(KERN_ERR "  InitiatorId = %d, TargetId = %d\n",
 102               (msg[1] >> 12) & 0xFFF, msg[1] & 0xFFF);
 103        printk(KERN_ERR "  LowestVersion = 0x%02X, HighestVersion = 0x%02X\n",
 104               (msg[4] >> 8) & 0xFF, msg[4] & 0xFF);
 105        printk(KERN_ERR "  FailingHostUnit = 0x%04X,  FailingIOP = 0x%03X\n",
 106               msg[5] >> 16, msg[5] & 0xFFF);
 107
 108        printk(KERN_ERR "  Severity:  0x%02X\n", (msg[4] >> 16) & 0xFF);
 109        if (msg[4] & (1 << 16))
 110                printk(KERN_DEBUG "(FormatError), "
 111                       "this msg can never be delivered/processed.\n");
 112        if (msg[4] & (1 << 17))
 113                printk(KERN_DEBUG "(PathError), "
 114                       "this msg can no longer be delivered/processed.\n");
 115        if (msg[4] & (1 << 18))
 116                printk(KERN_DEBUG "(PathState), "
 117                       "the system state does not allow delivery.\n");
 118        if (msg[4] & (1 << 19))
 119                printk(KERN_DEBUG
 120                       "(Congestion), resources temporarily not available;"
 121                       "do not retry immediately.\n");
 122}
 123
 124/*
 125 * Used for error reporting/debugging purposes.
 126 * Following reply status are common to all classes.
 127 */
 128static void i2o_report_common_status(u8 req_status)
 129{
 130        static char *REPLY_STATUS[] = {
 131                "SUCCESS",
 132                "ABORT_DIRTY",
 133                "ABORT_NO_DATA_TRANSFER",
 134                "ABORT_PARTIAL_TRANSFER",
 135                "ERROR_DIRTY",
 136                "ERROR_NO_DATA_TRANSFER",
 137                "ERROR_PARTIAL_TRANSFER",
 138                "PROCESS_ABORT_DIRTY",
 139                "PROCESS_ABORT_NO_DATA_TRANSFER",
 140                "PROCESS_ABORT_PARTIAL_TRANSFER",
 141                "TRANSACTION_ERROR",
 142                "PROGRESS_REPORT"
 143        };
 144
 145        if (req_status >= ARRAY_SIZE(REPLY_STATUS))
 146                printk("RequestStatus = %0#2x", req_status);
 147        else
 148                printk("%s", REPLY_STATUS[req_status]);
 149}
 150
 151/*
 152 * Used for error reporting/debugging purposes.
 153 * Following detailed status are valid  for executive class,
 154 * utility class, DDM class and for transaction error replies.
 155 */
 156static void i2o_report_common_dsc(u16 detailed_status)
 157{
 158        static char *COMMON_DSC[] = {
 159                "SUCCESS",
 160                "0x01",         // not used
 161                "BAD_KEY",
 162                "TCL_ERROR",
 163                "REPLY_BUFFER_FULL",
 164                "NO_SUCH_PAGE",
 165                "INSUFFICIENT_RESOURCE_SOFT",
 166                "INSUFFICIENT_RESOURCE_HARD",
 167                "0x08",         // not used
 168                "CHAIN_BUFFER_TOO_LARGE",
 169                "UNSUPPORTED_FUNCTION",
 170                "DEVICE_LOCKED",
 171                "DEVICE_RESET",
 172                "INAPPROPRIATE_FUNCTION",
 173                "INVALID_INITIATOR_ADDRESS",
 174                "INVALID_MESSAGE_FLAGS",
 175                "INVALID_OFFSET",
 176                "INVALID_PARAMETER",
 177                "INVALID_REQUEST",
 178                "INVALID_TARGET_ADDRESS",
 179                "MESSAGE_TOO_LARGE",
 180                "MESSAGE_TOO_SMALL",
 181                "MISSING_PARAMETER",
 182                "TIMEOUT",
 183                "UNKNOWN_ERROR",
 184                "UNKNOWN_FUNCTION",
 185                "UNSUPPORTED_VERSION",
 186                "DEVICE_BUSY",
 187                "DEVICE_NOT_AVAILABLE"
 188        };
 189
 190        if (detailed_status > I2O_DSC_DEVICE_NOT_AVAILABLE)
 191                printk(" / DetailedStatus = %0#4x.\n",
 192                       detailed_status);
 193        else
 194                printk(" / %s.\n", COMMON_DSC[detailed_status]);
 195}
 196
 197/*
 198 * Used for error reporting/debugging purposes
 199 */
 200static void i2o_report_util_cmd(u8 cmd)
 201{
 202        switch (cmd) {
 203        case I2O_CMD_UTIL_NOP:
 204                printk("UTIL_NOP, ");
 205                break;
 206        case I2O_CMD_UTIL_ABORT:
 207                printk("UTIL_ABORT, ");
 208                break;
 209        case I2O_CMD_UTIL_CLAIM:
 210                printk("UTIL_CLAIM, ");
 211                break;
 212        case I2O_CMD_UTIL_RELEASE:
 213                printk("UTIL_CLAIM_RELEASE, ");
 214                break;
 215        case I2O_CMD_UTIL_CONFIG_DIALOG:
 216                printk("UTIL_CONFIG_DIALOG, ");
 217                break;
 218        case I2O_CMD_UTIL_DEVICE_RESERVE:
 219                printk("UTIL_DEVICE_RESERVE, ");
 220                break;
 221        case I2O_CMD_UTIL_DEVICE_RELEASE:
 222                printk("UTIL_DEVICE_RELEASE, ");
 223                break;
 224        case I2O_CMD_UTIL_EVT_ACK:
 225                printk("UTIL_EVENT_ACKNOWLEDGE, ");
 226                break;
 227        case I2O_CMD_UTIL_EVT_REGISTER:
 228                printk("UTIL_EVENT_REGISTER, ");
 229                break;
 230        case I2O_CMD_UTIL_LOCK:
 231                printk("UTIL_LOCK, ");
 232                break;
 233        case I2O_CMD_UTIL_LOCK_RELEASE:
 234                printk("UTIL_LOCK_RELEASE, ");
 235                break;
 236        case I2O_CMD_UTIL_PARAMS_GET:
 237                printk("UTIL_PARAMS_GET, ");
 238                break;
 239        case I2O_CMD_UTIL_PARAMS_SET:
 240                printk("UTIL_PARAMS_SET, ");
 241                break;
 242        case I2O_CMD_UTIL_REPLY_FAULT_NOTIFY:
 243                printk("UTIL_REPLY_FAULT_NOTIFY, ");
 244                break;
 245        default:
 246                printk("Cmd = %0#2x, ", cmd);
 247        }
 248}
 249
 250/*
 251 * Used for error reporting/debugging purposes
 252 */
 253static void i2o_report_exec_cmd(u8 cmd)
 254{
 255        switch (cmd) {
 256        case I2O_CMD_ADAPTER_ASSIGN:
 257                printk("EXEC_ADAPTER_ASSIGN, ");
 258                break;
 259        case I2O_CMD_ADAPTER_READ:
 260                printk("EXEC_ADAPTER_READ, ");
 261                break;
 262        case I2O_CMD_ADAPTER_RELEASE:
 263                printk("EXEC_ADAPTER_RELEASE, ");
 264                break;
 265        case I2O_CMD_BIOS_INFO_SET:
 266                printk("EXEC_BIOS_INFO_SET, ");
 267                break;
 268        case I2O_CMD_BOOT_DEVICE_SET:
 269                printk("EXEC_BOOT_DEVICE_SET, ");
 270                break;
 271        case I2O_CMD_CONFIG_VALIDATE:
 272                printk("EXEC_CONFIG_VALIDATE, ");
 273                break;
 274        case I2O_CMD_CONN_SETUP:
 275                printk("EXEC_CONN_SETUP, ");
 276                break;
 277        case I2O_CMD_DDM_DESTROY:
 278                printk("EXEC_DDM_DESTROY, ");
 279                break;
 280        case I2O_CMD_DDM_ENABLE:
 281                printk("EXEC_DDM_ENABLE, ");
 282                break;
 283        case I2O_CMD_DDM_QUIESCE:
 284                printk("EXEC_DDM_QUIESCE, ");
 285                break;
 286        case I2O_CMD_DDM_RESET:
 287                printk("EXEC_DDM_RESET, ");
 288                break;
 289        case I2O_CMD_DDM_SUSPEND:
 290                printk("EXEC_DDM_SUSPEND, ");
 291                break;
 292        case I2O_CMD_DEVICE_ASSIGN:
 293                printk("EXEC_DEVICE_ASSIGN, ");
 294                break;
 295        case I2O_CMD_DEVICE_RELEASE:
 296                printk("EXEC_DEVICE_RELEASE, ");
 297                break;
 298        case I2O_CMD_HRT_GET:
 299                printk("EXEC_HRT_GET, ");
 300                break;
 301        case I2O_CMD_ADAPTER_CLEAR:
 302                printk("EXEC_IOP_CLEAR, ");
 303                break;
 304        case I2O_CMD_ADAPTER_CONNECT:
 305                printk("EXEC_IOP_CONNECT, ");
 306                break;
 307        case I2O_CMD_ADAPTER_RESET:
 308                printk("EXEC_IOP_RESET, ");
 309                break;
 310        case I2O_CMD_LCT_NOTIFY:
 311                printk("EXEC_LCT_NOTIFY, ");
 312                break;
 313        case I2O_CMD_OUTBOUND_INIT:
 314                printk("EXEC_OUTBOUND_INIT, ");
 315                break;
 316        case I2O_CMD_PATH_ENABLE:
 317                printk("EXEC_PATH_ENABLE, ");
 318                break;
 319        case I2O_CMD_PATH_QUIESCE:
 320                printk("EXEC_PATH_QUIESCE, ");
 321                break;
 322        case I2O_CMD_PATH_RESET:
 323                printk("EXEC_PATH_RESET, ");
 324                break;
 325        case I2O_CMD_STATIC_MF_CREATE:
 326                printk("EXEC_STATIC_MF_CREATE, ");
 327                break;
 328        case I2O_CMD_STATIC_MF_RELEASE:
 329                printk("EXEC_STATIC_MF_RELEASE, ");
 330                break;
 331        case I2O_CMD_STATUS_GET:
 332                printk("EXEC_STATUS_GET, ");
 333                break;
 334        case I2O_CMD_SW_DOWNLOAD:
 335                printk("EXEC_SW_DOWNLOAD, ");
 336                break;
 337        case I2O_CMD_SW_UPLOAD:
 338                printk("EXEC_SW_UPLOAD, ");
 339                break;
 340        case I2O_CMD_SW_REMOVE:
 341                printk("EXEC_SW_REMOVE, ");
 342                break;
 343        case I2O_CMD_SYS_ENABLE:
 344                printk("EXEC_SYS_ENABLE, ");
 345                break;
 346        case I2O_CMD_SYS_MODIFY:
 347                printk("EXEC_SYS_MODIFY, ");
 348                break;
 349        case I2O_CMD_SYS_QUIESCE:
 350                printk("EXEC_SYS_QUIESCE, ");
 351                break;
 352        case I2O_CMD_SYS_TAB_SET:
 353                printk("EXEC_SYS_TAB_SET, ");
 354                break;
 355        default:
 356                printk("Cmd = %#02x, ", cmd);
 357        }
 358}
 359
 360void i2o_debug_state(struct i2o_controller *c)
 361{
 362        printk(KERN_INFO "%s: State = ", c->name);
 363        switch (((i2o_status_block *) c->status_block.virt)->iop_state) {
 364        case 0x01:
 365                printk("INIT\n");
 366                break;
 367        case 0x02:
 368                printk("RESET\n");
 369                break;
 370        case 0x04:
 371                printk("HOLD\n");
 372                break;
 373        case 0x05:
 374                printk("READY\n");
 375                break;
 376        case 0x08:
 377                printk("OPERATIONAL\n");
 378                break;
 379        case 0x10:
 380                printk("FAILED\n");
 381                break;
 382        case 0x11:
 383                printk("FAULTED\n");
 384                break;
 385        default:
 386                printk("%x (unknown !!)\n",
 387                       ((i2o_status_block *) c->status_block.virt)->iop_state);
 388        }
 389};
 390
 391void i2o_dump_hrt(struct i2o_controller *c)
 392{
 393        u32 *rows = (u32 *) c->hrt.virt;
 394        u8 *p = (u8 *) c->hrt.virt;
 395        u8 *d;
 396        int count;
 397        int length;
 398        int i;
 399        int state;
 400
 401        if (p[3] != 0) {
 402                printk(KERN_ERR
 403                       "%s: HRT table for controller is too new a version.\n",
 404                       c->name);
 405                return;
 406        }
 407
 408        count = p[0] | (p[1] << 8);
 409        length = p[2];
 410
 411        printk(KERN_INFO "%s: HRT has %d entries of %d bytes each.\n",
 412               c->name, count, length << 2);
 413
 414        rows += 2;
 415
 416        for (i = 0; i < count; i++) {
 417                printk(KERN_INFO "Adapter %08X: ", rows[0]);
 418                p = (u8 *) (rows + 1);
 419                d = (u8 *) (rows + 2);
 420                state = p[1] << 8 | p[0];
 421
 422                printk("TID %04X:[", state & 0xFFF);
 423                state >>= 12;
 424                if (state & (1 << 0))
 425                        printk("H");    /* Hidden */
 426                if (state & (1 << 2)) {
 427                        printk("P");    /* Present */
 428                        if (state & (1 << 1))
 429                                printk("C");    /* Controlled */
 430                }
 431                if (state > 9)
 432                        printk("*");    /* Hard */
 433
 434                printk("]:");
 435
 436                switch (p[3] & 0xFFFF) {
 437                case 0:
 438                        /* Adapter private bus - easy */
 439                        printk("Local bus %d: I/O at 0x%04X Mem 0x%08X", p[2],
 440                               d[1] << 8 | d[0], *(u32 *) (d + 4));
 441                        break;
 442                case 1:
 443                        /* ISA bus */
 444                        printk("ISA %d: CSN %d I/O at 0x%04X Mem 0x%08X", p[2],
 445                               d[2], d[1] << 8 | d[0], *(u32 *) (d + 4));
 446                        break;
 447
 448                case 2: /* EISA bus */
 449                        printk("EISA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
 450                               p[2], d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
 451                        break;
 452
 453                case 3: /* MCA bus */
 454                        printk("MCA %d: Slot %d I/O at 0x%04X Mem 0x%08X", p[2],
 455                               d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
 456                        break;
 457
 458                case 4: /* PCI bus */
 459                        printk("PCI %d: Bus %d Device %d Function %d", p[2],
 460                               d[2], d[1], d[0]);
 461                        break;
 462
 463                case 0x80:      /* Other */
 464                default:
 465                        printk("Unsupported bus type.");
 466                        break;
 467                }
 468                printk("\n");
 469                rows += length;
 470        }
 471}
 472
 473EXPORT_SYMBOL(i2o_dump_message);
 474