scsi_enc.c (238894) | scsi_enc.c (239213) |
---|---|
1/*- 2 * Copyright (c) 2000 Matthew Jacob 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 --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2000 Matthew Jacob 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 --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_enc.c 238894 2012-07-30 03:00:58Z bz $"); | 28__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_enc.c 239213 2012-08-12 17:01:07Z mjacob $"); |
29 30#include <sys/param.h> 31 32#include <sys/conf.h> 33#include <sys/errno.h> 34#include <sys/fcntl.h> 35#include <sys/kernel.h> 36#include <sys/kthread.h> --- 18 unchanged lines hidden (view full) --- 55#include <cam/scsi/scsi_message.h> 56#include <cam/scsi/scsi_enc.h> 57#include <cam/scsi/scsi_enc_internal.h> 58 59MALLOC_DEFINE(M_SCSIENC, "SCSI ENC", "SCSI ENC buffers"); 60 61/* Enclosure type independent driver */ 62 | 29 30#include <sys/param.h> 31 32#include <sys/conf.h> 33#include <sys/errno.h> 34#include <sys/fcntl.h> 35#include <sys/kernel.h> 36#include <sys/kthread.h> --- 18 unchanged lines hidden (view full) --- 55#include <cam/scsi/scsi_message.h> 56#include <cam/scsi/scsi_enc.h> 57#include <cam/scsi/scsi_enc_internal.h> 58 59MALLOC_DEFINE(M_SCSIENC, "SCSI ENC", "SCSI ENC buffers"); 60 61/* Enclosure type independent driver */ 62 |
63#define SEN_ID "UNISYS SUN_SEN" 64#define SEN_ID_LEN 24 65 | |
66static d_open_t enc_open; 67static d_close_t enc_close; 68static d_ioctl_t enc_ioctl; 69static periph_init_t enc_init; 70static periph_ctor_t enc_ctor; 71static periph_oninv_t enc_oninvalidate; 72static periph_dtor_t enc_dtor; 73static periph_start_t enc_start; --- 551 unchanged lines hidden (view full) --- 625 * The code after this point runs on many platforms, 626 * so forgive the slightly awkward and nonconforming 627 * appearance. 628 */ 629 630/* 631 * Is this a device that supports enclosure services? 632 * | 63static d_open_t enc_open; 64static d_close_t enc_close; 65static d_ioctl_t enc_ioctl; 66static periph_init_t enc_init; 67static periph_ctor_t enc_ctor; 68static periph_oninv_t enc_oninvalidate; 69static periph_dtor_t enc_dtor; 70static periph_start_t enc_start; --- 551 unchanged lines hidden (view full) --- 622 * The code after this point runs on many platforms, 623 * so forgive the slightly awkward and nonconforming 624 * appearance. 625 */ 626 627/* 628 * Is this a device that supports enclosure services? 629 * |
633 * It's a a pretty simple ruleset- if it is device type 0x0D (13), it's 634 * an ENC device. If it happens to be an old UNISYS SEN device, we can 635 * handle that too. | 630 * It's a a pretty simple ruleset- if it is device type 631 * 0x0D (13), it's an ENCLOSURE device. |
636 */ 637 638#define SAFTE_START 44 639#define SAFTE_END 50 640#define SAFTE_LEN SAFTE_END-SAFTE_START 641 642static enctyp 643enc_type(struct ccb_getdev *cgd) --- 10 unchanged lines hidden (view full) --- 654 return (ENC_NONE); 655 656 } else if (cgd->protocol != PROTO_SCSI) 657 return (ENC_NONE); 658 659 iqd = (unsigned char *)&cgd->inq_data; 660 buflen = min(sizeof(cgd->inq_data), 661 SID_ADDITIONAL_LENGTH(&cgd->inq_data)); | 632 */ 633 634#define SAFTE_START 44 635#define SAFTE_END 50 636#define SAFTE_LEN SAFTE_END-SAFTE_START 637 638static enctyp 639enc_type(struct ccb_getdev *cgd) --- 10 unchanged lines hidden (view full) --- 650 return (ENC_NONE); 651 652 } else if (cgd->protocol != PROTO_SCSI) 653 return (ENC_NONE); 654 655 iqd = (unsigned char *)&cgd->inq_data; 656 buflen = min(sizeof(cgd->inq_data), 657 SID_ADDITIONAL_LENGTH(&cgd->inq_data)); |
662 if (buflen < 8+SEN_ID_LEN) 663 return (ENC_NONE); | |
664 665 if ((iqd[0] & 0x1f) == T_ENCLOSURE) { | 658 659 if ((iqd[0] & 0x1f) == T_ENCLOSURE) { |
666 if (STRNCMP(&iqd[8], SEN_ID, SEN_ID_LEN) == 0) { 667 return (ENC_SEN); 668 } else if ((iqd[2] & 0x7) > 2) { | 660 if ((iqd[2] & 0x7) > 2) { |
669 return (ENC_SES); 670 } else { 671 return (ENC_SES_SCSI2); 672 } 673 return (ENC_NONE); 674 } 675 676#ifdef ENC_ENABLE_PASSTHROUGH --- 238 unchanged lines hidden (view full) --- 915 case ENC_SES_PASSTHROUGH: 916 case ENC_SEMB_SES: 917 err = ses_softc_init(enc); 918 break; 919 case ENC_SAFT: 920 case ENC_SEMB_SAFT: 921 err = safte_softc_init(enc); 922 break; | 661 return (ENC_SES); 662 } else { 663 return (ENC_SES_SCSI2); 664 } 665 return (ENC_NONE); 666 } 667 668#ifdef ENC_ENABLE_PASSTHROUGH --- 238 unchanged lines hidden (view full) --- 907 case ENC_SES_PASSTHROUGH: 908 case ENC_SEMB_SES: 909 err = ses_softc_init(enc); 910 break; 911 case ENC_SAFT: 912 case ENC_SEMB_SAFT: 913 err = safte_softc_init(enc); 914 break; |
923 case ENC_SEN: | |
924 case ENC_NONE: 925 default: 926 ENC_FREE(enc); 927 return (CAM_REQ_CMP_ERR); 928 } 929 930 if (err) { 931 xpt_print(periph->path, "error %d initializing\n", err); --- 60 unchanged lines hidden (view full) --- 992 tname = "SCSI-2 ENC Device"; 993 break; 994 case ENC_SES: 995 tname = "SCSI-3 ENC Device"; 996 break; 997 case ENC_SES_PASSTHROUGH: 998 tname = "ENC Passthrough Device"; 999 break; | 915 case ENC_NONE: 916 default: 917 ENC_FREE(enc); 918 return (CAM_REQ_CMP_ERR); 919 } 920 921 if (err) { 922 xpt_print(periph->path, "error %d initializing\n", err); --- 60 unchanged lines hidden (view full) --- 983 tname = "SCSI-2 ENC Device"; 984 break; 985 case ENC_SES: 986 tname = "SCSI-3 ENC Device"; 987 break; 988 case ENC_SES_PASSTHROUGH: 989 tname = "ENC Passthrough Device"; 990 break; |
1000 case ENC_SEN: 1001 tname = "UNISYS SEN Device (NOT HANDLED YET)"; 1002 break; | |
1003 case ENC_SAFT: 1004 tname = "SAF-TE Compliant Device"; 1005 break; 1006 case ENC_SEMB_SES: 1007 tname = "SEMB SES Device"; 1008 break; 1009 case ENC_SEMB_SAFT: 1010 tname = "SEMB SAF-TE Device"; 1011 break; 1012 } 1013 xpt_announce_periph(periph, tname); 1014 status = CAM_REQ_CMP; 1015 1016out: 1017 if (status != CAM_REQ_CMP) 1018 enc_dtor(periph); 1019 return (status); 1020} 1021 | 991 case ENC_SAFT: 992 tname = "SAF-TE Compliant Device"; 993 break; 994 case ENC_SEMB_SES: 995 tname = "SEMB SES Device"; 996 break; 997 case ENC_SEMB_SAFT: 998 tname = "SEMB SAF-TE Device"; 999 break; 1000 } 1001 xpt_announce_periph(periph, tname); 1002 status = CAM_REQ_CMP; 1003 1004out: 1005 if (status != CAM_REQ_CMP) 1006 enc_dtor(periph); 1007 return (status); 1008} 1009 |