mfi_show.c (b09e402ad00e359eb5509a07d9685869c78a6e49) mfi_show.c (98be0dfebdc49a0ff7f4eceff40785c421720dde)
1/*-
2 * Copyright (c) 2008, 2009 Yahoo!, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 558 unchanged lines hidden (view full) ---

567show_firmware(int ac, char **av)
568{
569 struct mfi_ctrl_info info;
570 struct mfi_info_component header;
571 int error, fd;
572 u_int i;
573
574 if (ac != 1) {
1/*-
2 * Copyright (c) 2008, 2009 Yahoo!, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 558 unchanged lines hidden (view full) ---

567show_firmware(int ac, char **av)
568{
569 struct mfi_ctrl_info info;
570 struct mfi_info_component header;
571 int error, fd;
572 u_int i;
573
574 if (ac != 1) {
575 warnx("show drives: extra arguments");
575 warnx("show firmware: extra arguments");
576 return (EINVAL);
577 }
578
579 fd = mfi_open(mfi_unit);
580 if (fd < 0) {
581 error = errno;
582 warn("mfi_open");
583 return (error);

--- 28 unchanged lines hidden (view full) ---

612 for (i = 0; i < info.pending_image_component_count; i++)
613 display_firmware(&info.pending_image_component[i], "pending");
614
615 close(fd);
616
617 return (0);
618}
619MFI_COMMAND(show, firmware, show_firmware);
576 return (EINVAL);
577 }
578
579 fd = mfi_open(mfi_unit);
580 if (fd < 0) {
581 error = errno;
582 warn("mfi_open");
583 return (error);

--- 28 unchanged lines hidden (view full) ---

612 for (i = 0; i < info.pending_image_component_count; i++)
613 display_firmware(&info.pending_image_component[i], "pending");
614
615 close(fd);
616
617 return (0);
618}
619MFI_COMMAND(show, firmware, show_firmware);
620
621static int
622show_progress(int ac, char **av)
623{
624 struct mfi_ld_list llist;
625 struct mfi_pd_list *plist;
626 struct mfi_ld_info linfo;
627 struct mfi_pd_info pinfo;
628 int busy, error, fd;
629 u_int i;
630
631 uint16_t device_id;
632 uint8_t target_id;
633
634 if (ac != 1) {
635 warnx("show progress: extra arguments");
636 return (EINVAL);
637 }
638
639 fd = mfi_open(mfi_unit);
640 if (fd < 0) {
641 error = errno;
642 warn("mfi_open");
643 return (error);
644 }
645 busy = 0;
646
647 if (mfi_ld_get_list(fd, &llist, NULL) < 0) {
648 error = errno;
649 warn("Failed to get volume list");
650 return (error);
651 }
652 if (mfi_pd_get_list(fd, &plist, NULL) < 0) {
653 error = errno;
654 warn("Failed to get drive list");
655 return (error);
656 }
657
658 for (i = 0; i < llist.ld_count; i++) {
659 target_id = llist.ld_list[i].ld.v.target_id;
660 if (mfi_ld_get_info(fd, target_id, &linfo, NULL) < 0) {
661 error = errno;
662 warn("Failed to get info for volume %s",
663 mfi_volume_name(fd, target_id));
664 return (error);
665 }
666 if (linfo.progress.active & MFI_LD_PROGRESS_CC) {
667 printf("volume %s ", mfi_volume_name(fd, target_id));
668 mfi_display_progress("Consistency Check",
669 &linfo.progress.cc);
670 busy = 1;
671 }
672 if (linfo.progress.active & MFI_LD_PROGRESS_BGI) {
673 printf("volume %s ", mfi_volume_name(fd, target_id));
674 mfi_display_progress("Background Init",
675 &linfo.progress.bgi);
676 busy = 1;
677 }
678 if (linfo.progress.active & MFI_LD_PROGRESS_FGI) {
679 printf("volume %s ", mfi_volume_name(fd, target_id));
680 mfi_display_progress("Foreground Init",
681 &linfo.progress.fgi);
682 busy = 1;
683 }
684 if (linfo.progress.active & MFI_LD_PROGRESS_RECON) {
685 printf("volume %s ", mfi_volume_name(fd, target_id));
686 mfi_display_progress("Reconstruction",
687 &linfo.progress.recon);
688 busy = 1;
689 }
690 }
691
692 for (i = 0; i < plist->count; i++) {
693 if (plist->addr[i].scsi_dev_type != 0)
694 continue;
695
696 device_id = plist->addr[i].device_id;
697 if (mfi_pd_get_info(fd, device_id, &pinfo, NULL) < 0) {
698 error = errno;
699 warn("Failed to fetch info for drive %u", device_id);
700 return (error);
701 }
702
703 if (pinfo.prog_info.active & MFI_PD_PROGRESS_REBUILD) {
704 printf("drive %u ", device_id);
705 mfi_display_progress("Rebuild", &pinfo.prog_info.rbld);
706 busy = 1;
707 }
708 if (pinfo.prog_info.active & MFI_PD_PROGRESS_PATROL) {
709 printf("drive %u ", device_id);
710 mfi_display_progress("Patrol Read",
711 &pinfo.prog_info.patrol);
712 busy = 1;
713 }
714 if (pinfo.prog_info.active & MFI_PD_PROGRESS_CLEAR) {
715 printf("drive %u ", device_id);
716 mfi_display_progress("Clear", &pinfo.prog_info.clear);
717 busy = 1;
718 }
719 }
720
721 close(fd);
722
723 if (!busy)
724 printf("No activity in progress for adapter mfi%d\n", mfi_unit);
725
726 return (0);
727}
728MFI_COMMAND(show, progress, show_progress);