Deleted Added
full compact
camcontrol.c (199101) camcontrol.c (199747)
1/*
2 * Copyright (c) 1997-2007 Kenneth D. Merry
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

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

22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1997-2007 Kenneth D. Merry
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

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

22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sbin/camcontrol/camcontrol.c 199101 2009-11-09 19:47:46Z mav $");
30__FBSDID("$FreeBSD: head/sbin/camcontrol/camcontrol.c 199747 2009-11-24 12:47:58Z mav $");
31
32#include <sys/ioctl.h>
33#include <sys/stdint.h>
34#include <sys/types.h>
35#include <sys/endian.h>
36
37#include <stdio.h>
38#include <stdlib.h>

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

221 char *combinedopt, int retry_count, int timeout);
222static int scsireportluns(struct cam_device *device, int argc, char **argv,
223 char *combinedopt, int retry_count, int timeout);
224static int scsireadcapacity(struct cam_device *device, int argc, char **argv,
225 char *combinedopt, int retry_count, int timeout);
226static int atapm(struct cam_device *device, int argc, char **argv,
227 char *combinedopt, int retry_count, int timeout);
228#endif /* MINIMALISTIC */
31
32#include <sys/ioctl.h>
33#include <sys/stdint.h>
34#include <sys/types.h>
35#include <sys/endian.h>
36
37#include <stdio.h>
38#include <stdlib.h>

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

221 char *combinedopt, int retry_count, int timeout);
222static int scsireportluns(struct cam_device *device, int argc, char **argv,
223 char *combinedopt, int retry_count, int timeout);
224static int scsireadcapacity(struct cam_device *device, int argc, char **argv,
225 char *combinedopt, int retry_count, int timeout);
226static int atapm(struct cam_device *device, int argc, char **argv,
227 char *combinedopt, int retry_count, int timeout);
228#endif /* MINIMALISTIC */
229#ifndef min
230#define min(a,b) (((a)<(b))?(a):(b))
231#endif
232#ifndef max
233#define max(a,b) (((a)>(b))?(a):(b))
234#endif
229
230camcontrol_optret
231getoption(char *arg, cam_cmdmask *cmdnum, cam_argmask *argnum,
232 const char **subopt)
233{
234 struct camcontrol_opts *opts;
235 int num_matches = 0;
236

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

945 if (fc->valid & CTS_FC_VALID_SPEED)
946 speed = fc->bitrate;
947 } else if (ccb->cts.transport == XPORT_SAS) {
948 struct ccb_trans_settings_sas *sas =
949 &ccb->cts.xport_specific.sas;
950
951 if (sas->valid & CTS_SAS_VALID_SPEED)
952 speed = sas->bitrate;
235
236camcontrol_optret
237getoption(char *arg, cam_cmdmask *cmdnum, cam_argmask *argnum,
238 const char **subopt)
239{
240 struct camcontrol_opts *opts;
241 int num_matches = 0;
242

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

951 if (fc->valid & CTS_FC_VALID_SPEED)
952 speed = fc->bitrate;
953 } else if (ccb->cts.transport == XPORT_SAS) {
954 struct ccb_trans_settings_sas *sas =
955 &ccb->cts.xport_specific.sas;
956
957 if (sas->valid & CTS_SAS_VALID_SPEED)
958 speed = sas->bitrate;
959 } else if (ccb->cts.transport == XPORT_ATA) {
960 struct ccb_trans_settings_ata *ata =
961 &ccb->cts.xport_specific.ata;
962
963 if (ata->valid & CTS_ATA_VALID_MODE)
964 speed = ata_mode2speed(ata->mode);
953 } else if (ccb->cts.transport == XPORT_SATA) {
965 } else if (ccb->cts.transport == XPORT_SATA) {
954 struct ccb_trans_settings_sata *sata =
966 struct ccb_trans_settings_sata *sata =
955 &ccb->cts.xport_specific.sata;
956
967 &ccb->cts.xport_specific.sata;
968
957 if (sata->valid & CTS_SATA_VALID_SPEED)
958 speed = sata->bitrate;
969 if (sata->valid & CTS_SATA_VALID_REVISION)
970 speed = ata_revision2speed(sata->revision);
959 }
960
961 mb = speed / 1000;
962 if (mb > 0) {
971 }
972
973 mb = speed / 1000;
974 if (mb > 0) {
963 fprintf(stdout, "%s%d: %d.%03dMB/s transfers ",
975 fprintf(stdout, "%s%d: %d.%03dMB/s transfers",
964 device->device_name, device->dev_unit_num,
965 mb, speed % 1000);
966 } else {
976 device->device_name, device->dev_unit_num,
977 mb, speed % 1000);
978 } else {
967 fprintf(stdout, "%s%d: %dKB/s transfers ",
979 fprintf(stdout, "%s%d: %dKB/s transfers",
968 device->device_name, device->dev_unit_num,
969 speed);
970 }
971
972 if (ccb->cts.transport == XPORT_SPI) {
973 struct ccb_trans_settings_spi *spi =
974 &ccb->cts.xport_specific.spi;
975
976 if (((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) != 0)
977 && (spi->sync_offset != 0))
980 device->device_name, device->dev_unit_num,
981 speed);
982 }
983
984 if (ccb->cts.transport == XPORT_SPI) {
985 struct ccb_trans_settings_spi *spi =
986 &ccb->cts.xport_specific.spi;
987
988 if (((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) != 0)
989 && (spi->sync_offset != 0))
978 fprintf(stdout, "(%d.%03dMHz, offset %d", freq / 1000,
990 fprintf(stdout, " (%d.%03dMHz, offset %d", freq / 1000,
979 freq % 1000, spi->sync_offset);
980
981 if (((spi->valid & CTS_SPI_VALID_BUS_WIDTH) != 0)
982 && (spi->bus_width > 0)) {
983 if (((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) != 0)
984 && (spi->sync_offset != 0)) {
985 fprintf(stdout, ", ");
986 } else {
987 fprintf(stdout, " (");
988 }
989 fprintf(stdout, "%dbit)", 8 * (0x01 << spi->bus_width));
990 } else if (((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) != 0)
991 && (spi->sync_offset != 0)) {
992 fprintf(stdout, ")");
993 }
994 } else if (ccb->cts.transport == XPORT_ATA) {
995 struct ccb_trans_settings_ata *ata =
996 &ccb->cts.xport_specific.ata;
997
991 freq % 1000, spi->sync_offset);
992
993 if (((spi->valid & CTS_SPI_VALID_BUS_WIDTH) != 0)
994 && (spi->bus_width > 0)) {
995 if (((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) != 0)
996 && (spi->sync_offset != 0)) {
997 fprintf(stdout, ", ");
998 } else {
999 fprintf(stdout, " (");
1000 }
1001 fprintf(stdout, "%dbit)", 8 * (0x01 << spi->bus_width));
1002 } else if (((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) != 0)
1003 && (spi->sync_offset != 0)) {
1004 fprintf(stdout, ")");
1005 }
1006 } else if (ccb->cts.transport == XPORT_ATA) {
1007 struct ccb_trans_settings_ata *ata =
1008 &ccb->cts.xport_specific.ata;
1009
998 if (ata->valid & CTS_ATA_VALID_BYTECOUNT) {
999 fprintf(stdout, "(PIO size %dbytes)",
1000 ata->bytecount);
1001 }
1010 printf(" (");
1011 if (ata->valid & CTS_ATA_VALID_MODE)
1012 printf("%s, ", ata_mode2string(ata->mode));
1013 if (ata->valid & CTS_ATA_VALID_BYTECOUNT)
1014 printf("PIO size %dbytes", ata->bytecount);
1015 printf(")");
1002 } else if (ccb->cts.transport == XPORT_SATA) {
1003 struct ccb_trans_settings_sata *sata =
1004 &ccb->cts.xport_specific.sata;
1005
1016 } else if (ccb->cts.transport == XPORT_SATA) {
1017 struct ccb_trans_settings_sata *sata =
1018 &ccb->cts.xport_specific.sata;
1019
1006 if (sata->valid & CTS_SATA_VALID_BYTECOUNT) {
1007 fprintf(stdout, "(PIO size %dbytes)",
1008 sata->bytecount);
1009 }
1020 printf(" (");
1021 if (sata->valid & CTS_SATA_VALID_REVISION)
1022 printf("SATA %d.x, ", sata->revision);
1023 if (sata->valid & CTS_SATA_VALID_MODE)
1024 printf("%s, ", ata_mode2string(sata->mode));
1025 if (sata->valid & CTS_SATA_VALID_BYTECOUNT)
1026 printf("PIO size %dbytes", sata->bytecount);
1027 printf(")");
1010 }
1011
1012 if (ccb->cts.protocol == PROTO_SCSI) {
1013 struct ccb_trans_settings_scsi *scsi =
1014 &ccb->cts.proto_specific.scsi;
1015 if (scsi->valid & CTS_SCSI_VALID_TQ) {
1016 if (scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) {
1017 fprintf(stdout, ", Command Queueing Enabled");

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

2752 }
2753
2754 if (spi->valid & CTS_SPI_VALID_DISC) {
2755 fprintf(stdout, "%sdisconnection is %s\n", pathstr,
2756 (spi->flags & CTS_SPI_FLAGS_DISC_ENB) ?
2757 "enabled" : "disabled");
2758 }
2759 }
1028 }
1029
1030 if (ccb->cts.protocol == PROTO_SCSI) {
1031 struct ccb_trans_settings_scsi *scsi =
1032 &ccb->cts.proto_specific.scsi;
1033 if (scsi->valid & CTS_SCSI_VALID_TQ) {
1034 if (scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) {
1035 fprintf(stdout, ", Command Queueing Enabled");

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

2770 }
2771
2772 if (spi->valid & CTS_SPI_VALID_DISC) {
2773 fprintf(stdout, "%sdisconnection is %s\n", pathstr,
2774 (spi->flags & CTS_SPI_FLAGS_DISC_ENB) ?
2775 "enabled" : "disabled");
2776 }
2777 }
2778 if (cts->transport == XPORT_ATA) {
2779 struct ccb_trans_settings_ata *ata =
2780 &cts->xport_specific.ata;
2760
2781
2782 if ((ata->valid & CTS_ATA_VALID_MODE) != 0) {
2783 fprintf(stdout, "%sATA mode: %s\n", pathstr,
2784 ata_mode2string(ata->mode));
2785 }
2786 if ((ata->valid & CTS_ATA_VALID_BYTECOUNT) != 0) {
2787 fprintf(stdout, "%sPIO transaction length: %d\n",
2788 pathstr, ata->bytecount);
2789 }
2790 }
2791 if (cts->transport == XPORT_SATA) {
2792 struct ccb_trans_settings_sata *sata =
2793 &cts->xport_specific.sata;
2794
2795 if ((sata->valid & CTS_SATA_VALID_REVISION) != 0) {
2796 fprintf(stdout, "%sSATA revision: %d.x\n", pathstr,
2797 sata->revision);
2798 }
2799 if ((sata->valid & CTS_SATA_VALID_MODE) != 0) {
2800 fprintf(stdout, "%sATA mode: %s\n", pathstr,
2801 ata_mode2string(sata->mode));
2802 }
2803 if ((sata->valid & CTS_SATA_VALID_BYTECOUNT) != 0) {
2804 fprintf(stdout, "%sPIO transaction length: %d\n",
2805 pathstr, sata->bytecount);
2806 }
2807 if ((sata->valid & CTS_SATA_VALID_PM) != 0) {
2808 fprintf(stdout, "%sPMP presence: %d\n", pathstr,
2809 sata->pm_present);
2810 }
2811 if ((sata->valid & CTS_SATA_VALID_TAGS) != 0) {
2812 fprintf(stdout, "%sNumber of tags: %d\n", pathstr,
2813 sata->tags);
2814 }
2815 }
2761 if (cts->protocol == PROTO_SCSI) {
2762 struct ccb_trans_settings_scsi *scsi=
2763 &cts->proto_specific.scsi;
2764
2765 if (scsi->valid & CTS_SCSI_VALID_TQ) {
2766 fprintf(stdout, "%stagged queueing is %s\n", pathstr,
2767 (scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) ?
2768 "enabled" : "disabled");

--- 1912 unchanged lines hidden ---
2816 if (cts->protocol == PROTO_SCSI) {
2817 struct ccb_trans_settings_scsi *scsi=
2818 &cts->proto_specific.scsi;
2819
2820 if (scsi->valid & CTS_SCSI_VALID_TQ) {
2821 fprintf(stdout, "%stagged queueing is %s\n", pathstr,
2822 (scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) ?
2823 "enabled" : "disabled");

--- 1912 unchanged lines hidden ---