Print this page
4546 mpt_sas needs enhancing to support LSI MPI2.5

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/mdb/common/modules/mpt_sas/mpt_sas.c
          +++ new/usr/src/cmd/mdb/common/modules/mpt_sas/mpt_sas.c
↓ open down ↓ 142 lines elided ↑ open up ↑
 143  143                          break;
 144  144                  default:
 145  145                          mdb_printf(" invalid state");
 146  146                          break;
 147  147          }
 148  148          mdb_printf("\n");
 149  149          return (0);
 150  150  }
 151  151  
 152  152  void
 153      -mdi_info(struct mptsas m, int target)
      153 +mdi_info(struct mptsas *mp, int target)
 154  154  {
 155  155          struct  dev_info        d;
 156  156          struct  mdi_phci        p;
 157  157  
 158      -        if (mdb_vread(&d, sizeof (d), (uintptr_t)m.m_dip) == -1) {
      158 +        if (mdb_vread(&d, sizeof (d), (uintptr_t)mp->m_dip) == -1) {
 159  159                  mdb_warn("couldn't read m_dip");
 160  160                  return;
 161  161          }
 162  162  
 163  163          if (MDI_PHCI(&d)) {
 164  164                  if (mdb_vread(&p, sizeof (p), (uintptr_t)d.devi_mdi_xhci)
 165  165                      == -1) {
 166  166                          mdb_warn("couldn't read m_dip.devi_mdi_xhci");
 167  167                          return;
 168  168                  }
↓ open down ↓ 125 lines elided ↑ open up ↑
 294  294  
 295  295          kop = klp - mh.rh_link_off;
 296  296          rp = mdb_alloc(mh.rh_obj_size, UM_SLEEP);
 297  297          mdb_vread(rp, mh.rh_obj_size, kop);
 298  298  
 299  299          mdb_free(prev, mh.rh_obj_size);
 300  300          return (rp);
 301  301  }
 302  302  
 303  303  void
 304      -display_targets(struct mptsas *mp)
      304 +display_targets(struct mptsas *mp, uint_t verbose)
 305  305  {
 306  306          mptsas_target_t *ptgt;
 307  307          mptsas_smp_t *psmp;
      308 +        int loop, comma;
 308  309  
 309  310          mdb_printf("\n");
 310      -        mdb_printf("The SCSI target information\n");
 311      -        for (ptgt = (mptsas_target_t *)krefhash_first((uintptr_t)mp->m_targets);
 312      -            ptgt != NULL;
 313      -            ptgt = krefhash_next((uintptr_t)mp->m_targets, ptgt)) {
 314      -                mdb_printf("\n");
 315      -                mdb_printf("devhdl %x, sasaddress %"PRIx64", phymask %x,"
 316      -                    "devinfo %x\n", ptgt->m_devhdl, ptgt->m_addr.mta_wwn,
 317      -                    ptgt->m_addr.mta_phymask, ptgt->m_deviceinfo);
 318      -                mdb_printf("throttle %x, dr_flag %x, m_t_ncmds %x, "
 319      -                    "enclosure %x, slot_num %x\n", ptgt->m_t_throttle,
 320      -                    ptgt->m_dr_flag, ptgt->m_t_ncmds, ptgt->m_enclosure,
 321      -                    ptgt->m_slot_num);
 322      -        }
 323      -
 324      -        mdb_printf("\n");
 325      -        mdb_printf("The smp child information\n");
 326      -        for (psmp = (mptsas_smp_t *)krefhash_first(
 327      -            (uintptr_t)mp->m_smp_targets);
 328      -            psmp != NULL;
 329      -            psmp = krefhash_next((uintptr_t)mp->m_smp_targets, psmp)) {
 330      -                mdb_printf("\n");
 331      -                mdb_printf("devhdl %x, sasaddress %"PRIx64", phymask %x \n",
 332      -                    psmp->m_devhdl, psmp->m_addr.mta_wwn,
 333      -                    psmp->m_addr.mta_phymask);
 334      -        }
 335      -        mdb_printf("\n");
 336      -#if 0
 337      -        mdb_printf("targ         wwn      ncmds throttle "
 338      -            "dr_flag  timeout  dups\n");
      311 +        mdb_printf("slot devhdl      wwn     ncmds throttle   "
      312 +            "dr_flag  dups\n");
 339  313          mdb_printf("-------------------------------"
 340  314              "--------------------------------\n");
 341      -        for (i = 0; i < MPTSAS_MAX_TARGETS; i++) {
 342      -                if (s->m_target[i].m_addr.mta_wwn ||
 343      -                    s->m_target[i].m_deviceinfo) {
 344      -                        mdb_printf("%4d ", i);
 345      -                        if (s->m_target[i].m_addr.mta_wwn)
      315 +        for (ptgt = (mptsas_target_t *)krefhash_first(
      316 +            (uintptr_t)mp->m_targets);
      317 +            ptgt != NULL;
      318 +            ptgt = krefhash_next((uintptr_t)mp->m_targets, ptgt)) {
      319 +                if (ptgt->m_addr.mta_wwn ||
      320 +                    ptgt->m_deviceinfo) {
      321 +                        mdb_printf("%4d ", ptgt->m_slot_num);
      322 +                        mdb_printf("%4d ", ptgt->m_devhdl);
      323 +                        if (ptgt->m_addr.mta_wwn)
 346  324                                  mdb_printf("%"PRIx64" ",
 347      -                                    s->m_target[i].m_addr.mta_wwn);
 348      -                        mdb_printf("%3d", s->m_target[i].m_t_ncmds);
 349      -                        switch (s->m_target[i].m_t_throttle) {
      325 +                                    ptgt->m_addr.mta_wwn);
      326 +                        mdb_printf("%3d", ptgt->m_t_ncmds);
      327 +                        switch (ptgt->m_t_throttle) {
 350  328                                  case QFULL_THROTTLE:
 351  329                                          mdb_printf("   QFULL ");
 352  330                                          break;
 353  331                                  case DRAIN_THROTTLE:
 354  332                                          mdb_printf("   DRAIN ");
 355  333                                          break;
 356  334                                  case HOLD_THROTTLE:
 357  335                                          mdb_printf("    HOLD ");
 358  336                                          break;
 359  337                                  case MAX_THROTTLE:
 360  338                                          mdb_printf("     MAX ");
 361  339                                          break;
 362      -                                case CHOKE_THROTTLE:
 363      -                                        mdb_printf("   CHOKE ");
 364      -                                        break;
 365  340                                  default:
 366  341                                          mdb_printf("%8d ",
 367      -                                            s->m_target[i].m_t_throttle);
      342 +                                            ptgt->m_t_throttle);
 368  343                          }
 369      -                        switch (s->m_target[i].m_dr_flag) {
      344 +                        switch (ptgt->m_dr_flag) {
 370  345                                  case MPTSAS_DR_INACTIVE:
 371  346                                          mdb_printf("  INACTIVE ");
 372  347                                          break;
 373      -                                case MPTSAS_DR_PRE_OFFLINE_TIMEOUT:
 374      -                                        mdb_printf("   TIMEOUT ");
 375      -                                        break;
 376      -                                case MPTSAS_DR_PRE_OFFLINE_TIMEOUT_NO_CANCEL:
 377      -                                        mdb_printf("TIMEOUT_NC ");
 378      -                                        break;
 379      -                                case MPTSAS_DR_OFFLINE_IN_PROGRESS:
 380      -                                        mdb_printf(" OFFLINING ");
 381      -                                        break;
 382      -                                case MPTSAS_DR_ONLINE_IN_PROGRESS:
 383      -                                        mdb_printf("  ONLINING ");
      348 +                                case MPTSAS_DR_INTRANSITION:
      349 +                                        mdb_printf("TRANSITION ");
 384  350                                          break;
 385  351                                  default:
 386  352                                          mdb_printf("   UNKNOWN ");
 387  353                                          break;
 388  354                                  }
 389      -                        mdb_printf("%3d/%-3d   %d/%d\n",
 390      -                            s->m_target[i].m_dr_timeout, m.m_offline_delay,
 391      -                            s->m_target[i].m_dr_online_dups,
 392      -                            s->m_target[i].m_dr_offline_dups);
      355 +                        mdb_printf("%d\n", ptgt->m_dups);
 393  356  
 394  357                          if (verbose) {
 395  358                                  mdb_inc_indent(5);
 396      -                                if ((s->m_target[i].m_deviceinfo &
      359 +                                if ((ptgt->m_deviceinfo &
 397  360                                      MPI2_SAS_DEVICE_INFO_MASK_DEVICE_TYPE) ==
 398  361                                      MPI2_SAS_DEVICE_INFO_FANOUT_EXPANDER)
 399  362                                          mdb_printf("Fanout expander: ");
 400      -                                if ((s->m_target[i].m_deviceinfo &
      363 +                                if ((ptgt->m_deviceinfo &
 401  364                                      MPI2_SAS_DEVICE_INFO_MASK_DEVICE_TYPE) ==
 402  365                                      MPI2_SAS_DEVICE_INFO_EDGE_EXPANDER)
 403  366                                          mdb_printf("Edge expander: ");
 404      -                                if ((s->m_target[i].m_deviceinfo &
      367 +                                if ((ptgt->m_deviceinfo &
 405  368                                      MPI2_SAS_DEVICE_INFO_MASK_DEVICE_TYPE) ==
 406  369                                      MPI2_SAS_DEVICE_INFO_END_DEVICE)
 407  370                                          mdb_printf("End device: ");
 408      -                                if ((s->m_target[i].m_deviceinfo &
      371 +                                if ((ptgt->m_deviceinfo &
 409  372                                      MPI2_SAS_DEVICE_INFO_MASK_DEVICE_TYPE) ==
 410  373                                      MPI2_SAS_DEVICE_INFO_NO_DEVICE)
 411  374                                          mdb_printf("No device ");
 412  375  
 413  376                                  for (loop = 0, comma = 0;
 414  377                                      loop < (sizeof (devinfo_array) /
 415  378                                      sizeof (devinfo_array[0])); loop++) {
 416      -                                        if (s->m_target[i].m_deviceinfo &
      379 +                                        if (ptgt->m_deviceinfo &
 417  380                                              devinfo_array[loop].value) {
 418  381                                                  mdb_printf("%s%s",
 419  382                                                      (comma ? ", " : ""),
 420  383                                                      devinfo_array[loop].text);
 421  384                                                  comma++;
 422  385                                          }
 423  386                                  }
 424  387                                  mdb_printf("\n");
 425      -
 426      -                                if (s->m_target[i].m_tgt_dip) {
      388 +#if 0
      389 +                                if (ptgt->m_tgt_dip) {
      390 +                                        char    target_path[PATH_MAX];
 427  391                                          *target_path = 0;
 428  392                                          if (construct_path((uintptr_t)
 429      -                                            s->m_target[i].m_tgt_dip,
      393 +                                            ptgt->m_tgt_dip,
 430  394                                              target_path)
 431  395                                              == DCMD_OK)
 432  396                                                  mdb_printf("%s\n", target_path);
 433  397                                  }
 434      -                                mdi_info(m, i);
      398 +#endif
      399 +                                mdi_info(mp, ptgt->m_slot_num);
 435  400                                  mdb_dec_indent(5);
 436  401                          }
 437  402                  }
 438  403          }
 439      -#endif
      404 +
      405 +        mdb_printf("\n");
      406 +        mdb_printf("The smp child information\n");
      407 +        for (psmp = (mptsas_smp_t *)krefhash_first(
      408 +            (uintptr_t)mp->m_smp_targets);
      409 +            psmp != NULL;
      410 +            psmp = krefhash_next((uintptr_t)mp->m_smp_targets, psmp)) {
      411 +                mdb_printf("\n");
      412 +                mdb_printf("devhdl %x, sasaddress %"PRIx64", phymask %x \n",
      413 +                    psmp->m_devhdl, psmp->m_addr.mta_wwn,
      414 +                    psmp->m_addr.mta_phymask);
      415 +        }
 440  416  }
 441  417  
 442  418  int
 443      -display_slotinfo()
      419 +display_slotinfo(struct mptsas *mp, struct mptsas_slots *s)
 444  420  {
 445      -#if 0
 446      -        int     i, nslots;
 447      -        struct  mptsas_cmd              c, *q, *slots;
 448      -        int     header_output = 0;
 449      -        int     rv = DCMD_OK;
 450      -        int     slots_in_use = 0;
 451      -        int     tcmds = 0;
 452      -        int     mismatch = 0;
 453      -        int     wq, dq;
 454      -        int     ncmds = 0;
 455      -        ulong_t saved_indent;
      421 +        int                     i, nslots;
      422 +        struct mptsas_cmd       c, *q, *slots;
      423 +        mptsas_target_t         *ptgt;
      424 +        int                     header_output = 0;
      425 +        int                     rv = DCMD_OK;
      426 +        int                     slots_in_use = 0;
      427 +        int                     tcmds = 0;
      428 +        int                     mismatch = 0;
      429 +        int                     wq, dq;
      430 +        int                     ncmds = 0;
      431 +        ulong_t                 saved_indent;
 456  432  
 457  433          nslots = s->m_n_normal;
 458      -
 459  434          slots = mdb_alloc(sizeof (mptsas_cmd_t) * nslots, UM_SLEEP);
 460  435  
 461  436          for (i = 0; i < nslots; i++)
 462  437                  if (s->m_slot[i]) {
 463  438                          slots_in_use++;
 464  439                          if (mdb_vread(&slots[i], sizeof (mptsas_cmd_t),
 465  440                              (uintptr_t)s->m_slot[i]) == -1) {
 466  441                                  mdb_warn("couldn't read slot");
 467  442                                  s->m_slot[i] = NULL;
 468  443                          }
 469  444                          if ((slots[i].cmd_flags & CFLAG_CMDIOC) == 0)
 470  445                                  tcmds++;
 471  446                          if (i != slots[i].cmd_slot)
 472  447                                  mismatch++;
 473  448                  }
 474  449  
 475      -        for (q = m.m_waitq, wq = 0; q; q = c.cmd_linkp, wq++)
      450 +        for (q = mp->m_waitq, wq = 0; q; q = c.cmd_linkp, wq++)
 476  451                  if (mdb_vread(&c, sizeof (mptsas_cmd_t), (uintptr_t)q) == -1) {
 477  452                          mdb_warn("couldn't follow m_waitq");
 478  453                          rv = DCMD_ERR;
 479  454                          goto exit;
 480  455                  }
 481  456  
 482      -        for (q = m.m_doneq, dq = 0; q; q = c.cmd_linkp, dq++)
      457 +        for (q = mp->m_doneq, dq = 0; q; q = c.cmd_linkp, dq++)
 483  458                  if (mdb_vread(&c, sizeof (mptsas_cmd_t), (uintptr_t)q) == -1) {
 484  459                          mdb_warn("couldn't follow m_doneq");
 485  460                          rv = DCMD_ERR;
 486  461                          goto exit;
 487  462                  }
 488  463  
 489      -        for (i = 0; i < MPTSAS_MAX_TARGETS; i++)
 490      -                ncmds += s->m_target[i].m_t_ncmds;
      464 +        for (ptgt = (mptsas_target_t *)krefhash_first(
      465 +            (uintptr_t)mp->m_targets);
      466 +            ptgt != NULL;
      467 +            ptgt = krefhash_next((uintptr_t)mp->m_targets, ptgt)) {
      468 +                if (ptgt->m_addr.mta_wwn ||
      469 +                    ptgt->m_deviceinfo) {
      470 +                        ncmds += ptgt->m_t_ncmds;
      471 +                }
      472 +        }
 491  473  
 492  474          mdb_printf("\n");
 493  475          mdb_printf("   mpt.  slot               mptsas_slots     slot");
 494  476          mdb_printf("\n");
 495  477          mdb_printf("m_ncmds total"
 496  478              " targ throttle m_t_ncmds targ_tot wq dq");
 497  479          mdb_printf("\n");
 498  480          mdb_printf("----------------------------------------------------");
 499  481          mdb_printf("\n");
 500  482  
 501      -        mdb_printf("%7d ", m.m_ncmds);
 502      -        mdb_printf("%s", (m.m_ncmds == slots_in_use ? "  " : "!="));
      483 +        mdb_printf("%7d ", mp->m_ncmds);
      484 +        mdb_printf("%s", (mp->m_ncmds == slots_in_use ? "  " : "!="));
 503  485          mdb_printf("%3d               total %3d ", slots_in_use, ncmds);
 504  486          mdb_printf("%s", (tcmds == ncmds ? "     " : "   !="));
 505  487          mdb_printf("%3d %2d %2d\n", tcmds, wq, dq);
 506  488  
 507  489          saved_indent = mdb_dec_indent(0);
 508  490          mdb_dec_indent(saved_indent);
 509  491  
 510  492          for (i = 0; i < s->m_n_normal; i++)
 511  493                  if (s->m_slot[i]) {
 512  494                          if (!header_output) {
↓ open down ↓ 12 lines elided ↑ open up ↑
 525  507                              (i == slots[i].cmd_slot?"   ":"BAD"),
 526  508                              slots[i].cmd_slot,
 527  509                              slots[i].cmd_flags,
 528  510                              slots[i].cmd_pkt_flags,
 529  511                              slots[i].cmd_pkt);
 530  512                          (void) print_cdb(&slots[i]);
 531  513                  }
 532  514  
 533  515          /* print the wait queue */
 534  516  
 535      -        for (q = m.m_waitq; q; q = c.cmd_linkp) {
 536      -                if (q == m.m_waitq)
      517 +        for (q = mp->m_waitq; q; q = c.cmd_linkp) {
      518 +                if (q == mp->m_waitq)
 537  519                          mdb_printf("\n");
 538  520                  if (mdb_vread(&c, sizeof (mptsas_cmd_t), (uintptr_t)q)
 539  521                      == -1) {
 540  522                          mdb_warn("couldn't follow m_waitq");
 541  523                          rv = DCMD_ERR;
 542  524                          goto exit;
 543  525                  }
 544  526                  mdb_printf("%16p wait n/a %4d  %8x      %8x %16p ",
 545  527                      q, c.cmd_slot, c.cmd_flags, c.cmd_pkt_flags,
 546  528                      c.cmd_pkt);
 547  529                  print_cdb(&c);
 548  530          }
 549  531  
 550  532          /* print the done queue */
 551  533  
 552      -        for (q = m.m_doneq; q; q = c.cmd_linkp) {
 553      -                if (q == m.m_doneq)
      534 +        for (q = mp->m_doneq; q; q = c.cmd_linkp) {
      535 +                if (q == mp->m_doneq)
 554  536                          mdb_printf("\n");
 555  537                  if (mdb_vread(&c, sizeof (mptsas_cmd_t), (uintptr_t)q)
 556  538                      == -1) {
 557  539                          mdb_warn("couldn't follow m_doneq");
 558  540                          rv = DCMD_ERR;
 559  541                          goto exit;
 560  542                  }
 561  543                  mdb_printf("%16p done  n/a %4d  %8x      %8x %16p ",
 562  544                      q, c.cmd_slot, c.cmd_flags, c.cmd_pkt_flags,
 563  545                      c.cmd_pkt);
 564  546                  print_cdb(&c);
 565  547          }
 566  548  
 567  549          mdb_inc_indent(saved_indent);
 568  550  
 569      -        if (m.m_ncmds != slots_in_use)
      551 +        if (mp->m_ncmds != slots_in_use)
 570  552                  mdb_printf("WARNING: mpt.m_ncmds does not match the number of "
 571  553                      "slots in use\n");
 572  554  
 573  555          if (tcmds != ncmds)
 574  556                  mdb_printf("WARNING: the total of m_target[].m_t_ncmds does "
 575  557                      "not match the slots in use\n");
 576  558  
 577  559          if (mismatch)
 578  560                  mdb_printf("WARNING: corruption in slot table, "
 579  561                      "m_slot[].cmd_slot incorrect\n");
 580  562  
 581  563          /* now check for corruptions */
 582  564  
 583      -        for (q = m.m_waitq; q; q = c.cmd_linkp) {
      565 +        for (q = mp->m_waitq; q; q = c.cmd_linkp) {
 584  566                  for (i = 0; i < nslots; i++)
 585  567                          if (s->m_slot[i] == q)
 586  568                                  mdb_printf("WARNING: m_waitq entry"
 587  569                                      "(mptsas_cmd_t) %p is in m_slot[%i]\n",
 588  570                                      q, i);
 589  571  
 590  572                  if (mdb_vread(&c, sizeof (mptsas_cmd_t), (uintptr_t)q) == -1) {
 591  573                          mdb_warn("couldn't follow m_waitq");
 592  574                          rv = DCMD_ERR;
 593  575                          goto exit;
 594  576                  }
 595  577          }
 596  578  
 597      -        for (q = m.m_doneq; q; q = c.cmd_linkp) {
      579 +        for (q = mp->m_doneq; q; q = c.cmd_linkp) {
 598  580                  for (i = 0; i < nslots; i++)
 599  581                          if (s->m_slot[i] == q)
 600  582                                  mdb_printf("WARNING: m_doneq entry "
 601  583                                  "(mptsas_cmd_t) %p is in m_slot[%i]\n", q, i);
 602  584  
 603  585                  if (mdb_vread(&c, sizeof (mptsas_cmd_t), (uintptr_t)q) == -1) {
 604  586                          mdb_warn("couldn't follow m_doneq");
 605  587                          rv = DCMD_ERR;
 606  588                          goto exit;
 607  589                  }
↓ open down ↓ 7 lines elided ↑ open up ↑
 615  597                          mdb_printf("WARNING: m_doneq entry (mptsas_cmd_t) %p "
 616  598                              "should not have CFLAG_CMDARQ set\n", q);
 617  599                  if (c.cmd_flags & CFLAG_COMPLETED)
 618  600                          mdb_printf("WARNING: m_doneq entry (mptsas_cmd_t) %p "
 619  601                              "should not have CFLAG_COMPLETED set\n", q);
 620  602          }
 621  603  
 622  604  exit:
 623  605          mdb_free(slots, sizeof (mptsas_cmd_t) * nslots);
 624  606          return (rv);
 625      -#endif
 626      -        mdb_printf("\n");
 627      -        mdb_printf("The slot information is not implemented yet\n");
 628      -        return (0);
 629  607  }
 630  608  
 631  609  void
 632  610  display_deviceinfo(struct mptsas *mp)
 633  611  {
 634  612          char    device_path[PATH_MAX];
 635  613  
 636  614          *device_path = 0;
 637  615          if (construct_path((uintptr_t)mp->m_dip, device_path) != DCMD_OK) {
 638  616                  strcpy(device_path, "couldn't determine device path");
 639  617          }
 640  618  
 641  619          mdb_printf("\n");
 642      -        mdb_printf("Path in device tree %s\n", device_path);
 643      -#if 0
 644  620          mdb_printf("base_wwid          phys "
 645      -            "mptid prodid  devid        revid   ssid\n");
      621 +            " prodid  devid          revid   ssid\n");
 646  622          mdb_printf("-----------------------------"
 647  623              "----------------------------------\n");
 648      -        mdb_printf("%"PRIx64"     %2d   %3d "
 649      -            "0x%04x 0x%04x ", m.un.m_base_wwid, m.m_num_phys, m.m_mptid,
 650      -            m.m_productid, m.m_devid);
 651      -        switch (m.m_devid) {
 652      -                case MPTSAS_909:
 653      -                        mdb_printf("(909)   ");
 654      -                        break;
 655      -                case MPTSAS_929:
 656      -                        mdb_printf("(929)   ");
 657      -                        break;
 658      -                case MPTSAS_919:
 659      -                        mdb_printf("(919)   ");
 660      -                        break;
 661      -                case MPTSAS_1030:
 662      -                        mdb_printf("(1030)  ");
 663      -                        break;
 664      -                case MPTSAS_1064:
 665      -                        mdb_printf("(1064)  ");
 666      -                        break;
 667      -                case MPTSAS_1068:
 668      -                        mdb_printf("(1068)  ");
 669      -                        break;
 670      -                case MPTSAS_1064E:
 671      -                        mdb_printf("(1064E) ");
 672      -                        break;
 673      -                case MPTSAS_1068E:
 674      -                        mdb_printf("(1068E) ");
      624 +        mdb_printf("%"PRIx64"     %2d  "
      625 +            "0x%04x 0x%04x ", mp->un.m_base_wwid, mp->m_num_phys,
      626 +            mp->m_productid, mp->m_devid);
      627 +        switch (mp->m_devid) {
      628 +                case MPI2_MFGPAGE_DEVID_SAS2004:
      629 +                        mdb_printf("(SAS2004) ");
      630 +                        break;
      631 +                case MPI2_MFGPAGE_DEVID_SAS2008:
      632 +                        mdb_printf("(SAS2008) ");
      633 +                        break;
      634 +                case MPI2_MFGPAGE_DEVID_SAS2108_1:
      635 +                case MPI2_MFGPAGE_DEVID_SAS2108_2:
      636 +                case MPI2_MFGPAGE_DEVID_SAS2108_3:
      637 +                        mdb_printf("(SAS2108) ");
      638 +                        break;
      639 +                case MPI2_MFGPAGE_DEVID_SAS2116_1:
      640 +                case MPI2_MFGPAGE_DEVID_SAS2116_2:
      641 +                        mdb_printf("(SAS2116) ");
      642 +                        break;
      643 +                case MPI2_MFGPAGE_DEVID_SAS2208_1:
      644 +                case MPI2_MFGPAGE_DEVID_SAS2208_2:
      645 +                case MPI2_MFGPAGE_DEVID_SAS2208_3:
      646 +                case MPI2_MFGPAGE_DEVID_SAS2208_4:
      647 +                case MPI2_MFGPAGE_DEVID_SAS2208_5:
      648 +                case MPI2_MFGPAGE_DEVID_SAS2208_6:
      649 +#if 0
      650 +                /* Same as 2308_1/2 ?? */
      651 +                case MPI2_MFGPAGE_DEVID_SAS2208_7:
      652 +                case MPI2_MFGPAGE_DEVID_SAS2208_8:
      653 +#endif
      654 +                        mdb_printf("(SAS2208) ");
 675  655                          break;
 676  656                  default:
 677      -                        mdb_printf("(?????) ");
      657 +                        mdb_printf("(SAS????) ");
 678  658                          break;
 679  659          }
 680      -        mdb_printf("0x%02x 0x%04x\n", m.m_revid, m.m_ssid);
      660 +        mdb_printf("0x%02x 0x%04x\n", mp->m_revid, mp->m_ssid);
 681  661          mdb_printf("%s\n", device_path);
 682  662  
      663 +#if 0
 683  664          for (i = 0; i < MAX_MPI2_PORTS; i++) {
 684  665                  if (i%4 == 0)
 685  666                          mdb_printf("\n");
 686  667  
 687  668                  mdb_printf("%d:", i);
 688  669  
 689      -                switch (m.m_port_type[i]) {
      670 +                switch (mp->m_port_type[i]) {
 690  671                          case MPI2_PORTFACTS_PORTTYPE_INACTIVE:
 691  672                                  mdb_printf("inactive     ",
 692      -                                    m.m_protocol_flags[i]);
      673 +                                    mp->m_protocol_flags[i]);
 693  674                                  break;
 694  675                          case MPI2_PORTFACTS_PORTTYPE_SCSI:
 695  676                                  mdb_printf("SCSI (0x%1x)   ",
 696      -                                    m.m_protocol_flags[i]);
      677 +                                    mp->m_protocol_flags[i]);
 697  678                                  break;
 698  679                          case MPI2_PORTFACTS_PORTTYPE_FC:
 699  680                                  mdb_printf("FC (0x%1x)     ",
 700      -                                    m.m_protocol_flags[i]);
      681 +                                    mp->m_protocol_flags[i]);
 701  682                                  break;
 702  683                          case MPI2_PORTFACTS_PORTTYPE_ISCSI:
 703  684                                  mdb_printf("iSCSI (0x%1x)  ",
 704      -                                    m.m_protocol_flags[i]);
      685 +                                    mp->m_protocol_flags[i]);
 705  686                                  break;
 706  687                          case MPI2_PORTFACTS_PORTTYPE_SAS:
 707  688                                  mdb_printf("SAS (0x%1x)    ",
 708      -                                    m.m_protocol_flags[i]);
      689 +                                    mp->m_protocol_flags[i]);
 709  690                                  break;
 710  691                          default:
 711  692                                  mdb_printf("unknown      ");
 712  693                  }
 713  694          }
      695 +        mdb_printf("\n");
 714  696  #endif
      697 +}
      698 +
      699 +void
      700 +dump_debug_log(struct mptsas *mp)
      701 +{
      702 +        uint_t  idx;
      703 +        char    *logbuf;
      704 +        int     i;
      705 +
      706 +        if (mdb_readsym(&idx, sizeof (uint_t),
      707 +                "mptsas_dbglog_idx") == -1) {
      708 +                mdb_warn("No debug log buffer present");
      709 +                return;
      710 +        }
      711 +        logbuf = mdb_alloc(16*256, UM_SLEEP);
      712 +        if (idx == 0) {
      713 +                mdb_warn("Logging turned off");
      714 +                return;
      715 +        }
      716 +        
      717 +        if (mdb_readsym(logbuf, 16*256,
      718 +                "mptsas_dbglog_bufs") == -1) {
      719 +                mdb_warn("No debug log buffer present");
      720 +                return;
      721 +        }
 715  722          mdb_printf("\n");
      723 +        idx &= 0xf;
      724 +        for (i = 0; i < 16; i++) {
      725 +                mdb_printf("%s\n", &logbuf[idx*256]);
      726 +                idx = (idx+1) & 0xf;
      727 +        }
      728 +        mdb_free(logbuf, 16*256);
 716  729  }
 717  730  
 718  731  static int
 719  732  mptsas_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 720  733  {
 721  734          struct mptsas           m;
 722  735          struct mptsas_slots     *s;
 723  736  
 724  737          int                     nslots;
 725  738          int                     slot_size = 0;
 726  739          uint_t                  verbose = FALSE;
 727  740          uint_t                  target_info = FALSE;
 728  741          uint_t                  slot_info = FALSE;
 729  742          uint_t                  device_info = FALSE;
 730  743          uint_t                  port_info = FALSE;
      744 +        uint_t                  debug_log = FALSE;
 731  745          int                     rv = DCMD_OK;
 732      -        void                    *mptsas_state;
 733  746  
 734  747          if (!(flags & DCMD_ADDRSPEC)) {
 735      -                mptsas_state = NULL;
      748 +                void            *mptsas_state = NULL;
      749 +
 736  750                  if (mdb_readvar(&mptsas_state, "mptsas_state") == -1) {
 737  751                          mdb_warn("can't read mptsas_state");
 738  752                          return (DCMD_ERR);
 739  753                  }
 740      -                if (mdb_pwalk_dcmd("genunix`softstate", "mpt_sas`mptsas", argc,
 741      -                    argv, (uintptr_t)mptsas_state) == -1) {
      754 +                if (mdb_pwalk_dcmd("genunix`softstate",
      755 +                        "mpt_sas`mptsas", argc,
      756 +                        argv, (uintptr_t)mptsas_state) == -1) {
 742  757                          mdb_warn("mdb_pwalk_dcmd failed");
 743  758                          return (DCMD_ERR);
 744  759                  }
 745  760                  return (DCMD_OK);
 746  761          }
 747  762  
 748  763          if (mdb_getopts(argc, argv,
 749  764              's', MDB_OPT_SETBITS, TRUE, &slot_info,
 750  765              'd', MDB_OPT_SETBITS, TRUE, &device_info,
 751  766              't', MDB_OPT_SETBITS, TRUE, &target_info,
 752  767              'p', MDB_OPT_SETBITS, TRUE, &port_info,
 753  768              'v', MDB_OPT_SETBITS, TRUE, &verbose,
      769 +            'D', MDB_OPT_SETBITS, TRUE, &debug_log,
 754  770              NULL) != argc)
 755  771                  return (DCMD_USAGE);
 756  772  
 757  773  
 758  774          if (mdb_vread(&m, sizeof (m), addr) == -1) {
 759  775                  mdb_warn("couldn't read mpt struct at 0x%p", addr);
 760  776                  return (DCMD_ERR);
 761  777          }
 762  778  
 763  779          s = mdb_alloc(sizeof (mptsas_slots_t), UM_SLEEP);
↓ open down ↓ 52 lines elided ↑ open up ↑
 816  832                          mdb_printf("OFF=D3 ");
 817  833                          break;
 818  834                  default:
 819  835                          mdb_printf("INVALD ");
 820  836          }
 821  837          mdb_printf("\n");
 822  838  
 823  839          mdb_inc_indent(17);
 824  840  
 825  841          if (target_info)
 826      -                display_targets(&m);
      842 +                display_targets(&m, verbose);
 827  843  
 828  844          if (port_info)
 829  845                  display_ports(&m);
 830  846  
 831  847          if (device_info)
 832  848                  display_deviceinfo(&m);
 833  849  
 834  850          if (slot_info)
 835      -                display_slotinfo();
      851 +                display_slotinfo(&m, s);
      852 +
      853 +        if (debug_log)
      854 +                dump_debug_log(&m);
 836  855  
 837  856          mdb_dec_indent(17);
 838  857  
 839  858          mdb_free(s, slot_size);
 840  859  
 841  860          return (rv);
 842  861  }
 843  862  
 844  863  void
 845  864  mptsas_help()
 846  865  {
 847  866          mdb_printf("Prints summary information about each mpt_sas instance, "
 848  867              "including warning\nmessages when slot usage doesn't match "
 849  868              "summary information.\n"
 850  869              "Without the address of a \"struct mptsas\", prints every "
 851  870              "instance.\n\n"
 852  871              "Switches:\n"
 853      -            "  -t   includes information about targets\n"
 854      -            "  -p   includes information about port\n"
 855      -            "  -d   includes information about the hardware\n");
      872 +            "  -t[v]  includes information about targets, v = be more verbose\n"
      873 +            "  -p     includes information about port\n"
      874 +            "  -s     includes information about mpt slots\n"
      875 +            "  -d     includes information about the hardware\n"
      876 +            "  -D     print the mptsas specific debug log\n");
 856  877  }
 857  878  
 858  879  static const mdb_dcmd_t dcmds[] = {
 859      -        { "mptsas", "?[-tpd]", "print mpt_sas information", mptsas_dcmd,
      880 +        { "mptsas", "?[-tpsdD]", "print mpt_sas information", mptsas_dcmd,
 860  881              mptsas_help}, { NULL }
 861  882  };
 862  883  
 863  884  static const mdb_modinfo_t modinfo = {
 864  885          MDB_API_VERSION, dcmds, NULL
 865  886  };
 866  887  
 867  888  const mdb_modinfo_t *
 868  889  _mdb_init(void)
 869  890  {
 870  891          return (&modinfo);
 871  892  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX