ctl.c (268144) | ctl.c (268145) |
---|---|
1/*- 2 * Copyright (c) 2003-2009 Silicon Graphics International Corp. 3 * Copyright (c) 2012 The FreeBSD Foundation 4 * All rights reserved. 5 * 6 * Portions of this software were developed by Edward Tomasz Napierala 7 * under sponsorship from the FreeBSD Foundation. 8 * --- 28 unchanged lines hidden (view full) --- 37 * CAM Target Layer, a SCSI device emulation subsystem. 38 * 39 * Author: Ken Merry <ken@FreeBSD.org> 40 */ 41 42#define _CTL_C 43 44#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2003-2009 Silicon Graphics International Corp. 3 * Copyright (c) 2012 The FreeBSD Foundation 4 * All rights reserved. 5 * 6 * Portions of this software were developed by Edward Tomasz Napierala 7 * under sponsorship from the FreeBSD Foundation. 8 * --- 28 unchanged lines hidden (view full) --- 37 * CAM Target Layer, a SCSI device emulation subsystem. 38 * 39 * Author: Ken Merry <ken@FreeBSD.org> 40 */ 41 42#define _CTL_C 43 44#include <sys/cdefs.h> |
45__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl.c 268144 2014-07-02 10:36:04Z mav $"); | 45__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl.c 268145 2014-07-02 10:37:22Z mav $"); |
46 47#include <sys/param.h> 48#include <sys/systm.h> 49#include <sys/kernel.h> 50#include <sys/types.h> 51#include <sys/kthread.h> 52#include <sys/bio.h> 53#include <sys/fcntl.h> --- 9244 unchanged lines hidden (view full) --- 9298{ 9299 struct scsi_vpd_device_id *devid_ptr; 9300 struct scsi_vpd_id_descriptor *desc, *desc1; 9301 struct scsi_vpd_id_descriptor *desc2, *desc3; /* for types 4h and 5h */ 9302 struct scsi_vpd_id_t10 *t10id; 9303 struct ctl_softc *ctl_softc; 9304 struct ctl_lun *lun; 9305 struct ctl_frontend *fe; | 46 47#include <sys/param.h> 48#include <sys/systm.h> 49#include <sys/kernel.h> 50#include <sys/types.h> 51#include <sys/kthread.h> 52#include <sys/bio.h> 53#include <sys/fcntl.h> --- 9244 unchanged lines hidden (view full) --- 9298{ 9299 struct scsi_vpd_device_id *devid_ptr; 9300 struct scsi_vpd_id_descriptor *desc, *desc1; 9301 struct scsi_vpd_id_descriptor *desc2, *desc3; /* for types 4h and 5h */ 9302 struct scsi_vpd_id_t10 *t10id; 9303 struct ctl_softc *ctl_softc; 9304 struct ctl_lun *lun; 9305 struct ctl_frontend *fe; |
9306 char *val; |
|
9306#ifndef CTL_USE_BACKEND_SN 9307 char tmpstr[32]; 9308#endif /* CTL_USE_BACKEND_SN */ 9309 int devid_len; 9310 9311 ctl_softc = control_softc; 9312 9313 mtx_lock(&ctl_softc->ctl_lock); --- 77 unchanged lines hidden (view full) --- 9391 mtx_unlock(&ctl_softc->ctl_lock); 9392 9393 /* 9394 * We're using a LUN association here. i.e., this device ID is a 9395 * per-LUN identifier. 9396 */ 9397 desc->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_LUN | SVPD_ID_TYPE_T10; 9398 desc->length = sizeof(*t10id) + CTL_DEVID_LEN; | 9307#ifndef CTL_USE_BACKEND_SN 9308 char tmpstr[32]; 9309#endif /* CTL_USE_BACKEND_SN */ 9310 int devid_len; 9311 9312 ctl_softc = control_softc; 9313 9314 mtx_lock(&ctl_softc->ctl_lock); --- 77 unchanged lines hidden (view full) --- 9392 mtx_unlock(&ctl_softc->ctl_lock); 9393 9394 /* 9395 * We're using a LUN association here. i.e., this device ID is a 9396 * per-LUN identifier. 9397 */ 9398 desc->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_LUN | SVPD_ID_TYPE_T10; 9399 desc->length = sizeof(*t10id) + CTL_DEVID_LEN; |
9399 strncpy((char *)t10id->vendor, CTL_VENDOR, sizeof(t10id->vendor)); | 9400 if (lun == NULL || (val = ctl_get_opt(lun->be_lun, "vendor")) == NULL) { 9401 strncpy((char *)t10id->vendor, CTL_VENDOR, sizeof(t10id->vendor)); 9402 } else { 9403 memset(t10id->vendor, ' ', sizeof(t10id->vendor)); 9404 strncpy(t10id->vendor, val, 9405 min(sizeof(t10id->vendor), strlen(val))); 9406 } |
9400 9401 /* 9402 * desc1 is for the WWPN which is a port asscociation. 9403 */ 9404 desc1->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_PORT | SVPD_ID_TYPE_NAA; 9405 desc1->length = CTL_WWPN_LEN; 9406 /* XXX Call Reggie's get_WWNN func here then add port # to the end */ 9407 /* For testing just create the WWPN */ --- 221 unchanged lines hidden (view full) --- 9629 9630static int 9631ctl_inquiry_std(struct ctl_scsiio *ctsio) 9632{ 9633 struct scsi_inquiry_data *inq_ptr; 9634 struct scsi_inquiry *cdb; 9635 struct ctl_softc *ctl_softc; 9636 struct ctl_lun *lun; | 9407 9408 /* 9409 * desc1 is for the WWPN which is a port asscociation. 9410 */ 9411 desc1->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_PORT | SVPD_ID_TYPE_NAA; 9412 desc1->length = CTL_WWPN_LEN; 9413 /* XXX Call Reggie's get_WWNN func here then add port # to the end */ 9414 /* For testing just create the WWPN */ --- 221 unchanged lines hidden (view full) --- 9636 9637static int 9638ctl_inquiry_std(struct ctl_scsiio *ctsio) 9639{ 9640 struct scsi_inquiry_data *inq_ptr; 9641 struct scsi_inquiry *cdb; 9642 struct ctl_softc *ctl_softc; 9643 struct ctl_lun *lun; |
9644 char *val; |
|
9637 uint32_t alloc_len; 9638 int is_fc; 9639 9640 ctl_softc = control_softc; 9641 9642 /* 9643 * Figure out whether we're talking to a Fibre Channel port or not. 9644 * We treat the ioctl front end, and any SCSI adapters, as packetized --- 128 unchanged lines hidden (view full) --- 9773 if ((lun == NULL) 9774 || (lun->be_lun->lun_type != T_PROCESSOR)) 9775 inq_ptr->flags |= SID_CmdQue; 9776 /* 9777 * Per SPC-3, unused bytes in ASCII strings are filled with spaces. 9778 * We have 8 bytes for the vendor name, and 16 bytes for the device 9779 * name and 4 bytes for the revision. 9780 */ | 9645 uint32_t alloc_len; 9646 int is_fc; 9647 9648 ctl_softc = control_softc; 9649 9650 /* 9651 * Figure out whether we're talking to a Fibre Channel port or not. 9652 * We treat the ioctl front end, and any SCSI adapters, as packetized --- 128 unchanged lines hidden (view full) --- 9781 if ((lun == NULL) 9782 || (lun->be_lun->lun_type != T_PROCESSOR)) 9783 inq_ptr->flags |= SID_CmdQue; 9784 /* 9785 * Per SPC-3, unused bytes in ASCII strings are filled with spaces. 9786 * We have 8 bytes for the vendor name, and 16 bytes for the device 9787 * name and 4 bytes for the revision. 9788 */ |
9781 strncpy(inq_ptr->vendor, CTL_VENDOR, sizeof(inq_ptr->vendor)); | 9789 if (lun == NULL || (val = ctl_get_opt(lun->be_lun, "vendor")) == NULL) { 9790 strcpy(inq_ptr->vendor, CTL_VENDOR); 9791 } else { 9792 memset(inq_ptr->vendor, ' ', sizeof(inq_ptr->vendor)); 9793 strncpy(inq_ptr->vendor, val, 9794 min(sizeof(inq_ptr->vendor), strlen(val))); 9795 } |
9782 if (lun == NULL) { 9783 strcpy(inq_ptr->product, CTL_DIRECT_PRODUCT); | 9796 if (lun == NULL) { 9797 strcpy(inq_ptr->product, CTL_DIRECT_PRODUCT); |
9784 } else { | 9798 } else if ((val = ctl_get_opt(lun->be_lun, "product")) == NULL) { |
9785 switch (lun->be_lun->lun_type) { 9786 case T_DIRECT: 9787 strcpy(inq_ptr->product, CTL_DIRECT_PRODUCT); 9788 break; 9789 case T_PROCESSOR: 9790 strcpy(inq_ptr->product, CTL_PROCESSOR_PRODUCT); 9791 break; 9792 default: 9793 strcpy(inq_ptr->product, CTL_UNKNOWN_PRODUCT); 9794 break; 9795 } | 9799 switch (lun->be_lun->lun_type) { 9800 case T_DIRECT: 9801 strcpy(inq_ptr->product, CTL_DIRECT_PRODUCT); 9802 break; 9803 case T_PROCESSOR: 9804 strcpy(inq_ptr->product, CTL_PROCESSOR_PRODUCT); 9805 break; 9806 default: 9807 strcpy(inq_ptr->product, CTL_UNKNOWN_PRODUCT); 9808 break; 9809 } |
9810 } else { 9811 memset(inq_ptr->product, ' ', sizeof(inq_ptr->product)); 9812 strncpy(inq_ptr->product, val, 9813 min(sizeof(inq_ptr->product), strlen(val))); |
|
9796 } 9797 9798 /* 9799 * XXX make this a macro somewhere so it automatically gets 9800 * incremented when we make changes. 9801 */ | 9814 } 9815 9816 /* 9817 * XXX make this a macro somewhere so it automatically gets 9818 * incremented when we make changes. 9819 */ |
9802 strncpy(inq_ptr->revision, "0001", sizeof(inq_ptr->revision)); | 9820 if (lun == NULL || (val = ctl_get_opt(lun->be_lun, "revision")) == NULL) { 9821 strncpy(inq_ptr->revision, "0001", sizeof(inq_ptr->revision)); 9822 } else { 9823 memset(inq_ptr->revision, ' ', sizeof(inq_ptr->revision)); 9824 strncpy(inq_ptr->revision, val, 9825 min(sizeof(inq_ptr->revision), strlen(val))); 9826 } |
9803 9804 /* 9805 * For parallel SCSI, we support double transition and single 9806 * transition clocking. We also support QAS (Quick Arbitration 9807 * and Selection) and Information Unit transfers on both the 9808 * control and array devices. 9809 */ 9810 if (is_fc == 0) --- 3676 unchanged lines hidden --- | 9827 9828 /* 9829 * For parallel SCSI, we support double transition and single 9830 * transition clocking. We also support QAS (Quick Arbitration 9831 * and Selection) and Information Unit transfers on both the 9832 * control and array devices. 9833 */ 9834 if (is_fc == 0) --- 3676 unchanged lines hidden --- |