4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
25 */
26
27 #include <sys/note.h>
28
29 /*
30 * Generic SCSI Host Bus Adapter interface implementation
31 */
32 #include <sys/scsi/scsi.h>
33 #include <sys/scsi/generic/sas.h>
34 #include <sys/file.h>
35 #include <sys/disp.h> /* for minclsyspri */
36 #include <sys/ddi_impldefs.h>
37 #include <sys/ndi_impldefs.h>
38 #include <sys/sunndi.h>
39 #include <sys/ddi.h>
40 #include <sys/sunmdi.h>
41 #include <sys/mdi_impldefs.h>
42 #include <sys/callb.h>
43 #include <sys/epm.h>
44 #include <sys/damap.h>
949 tran_ext = kmem_zalloc(length,
950 (flags & SCSI_HBA_CANSLEEP) ? KM_SLEEP : KM_NOSLEEP);
951 if (tran_ext != NULL) {
952 tran->tran_extension = tran_ext;
953 ret = DDI_SUCCESS;
954 }
955 return (ret);
956 }
957
958 void
959 scsi_tran_ext_free(
960 scsi_hba_tran_t *tran,
961 size_t length)
962 {
963 if (tran->tran_extension != NULL) {
964 kmem_free(tran->tran_extension, length);
965 tran->tran_extension = NULL;
966 }
967 }
968
969 /*
970 * Obsolete: Called by an HBA to attach an instance of the driver
971 * Implement this older interface in terms of the new.
972 */
973 /*ARGSUSED*/
974 int
975 scsi_hba_attach(
976 dev_info_t *self,
977 ddi_dma_lim_t *hba_lim,
978 scsi_hba_tran_t *tran,
979 int flags,
980 void *hba_options)
981 {
982 ddi_dma_attr_t hba_dma_attr;
983
984 bzero(&hba_dma_attr, sizeof (ddi_dma_attr_t));
985 hba_dma_attr.dma_attr_burstsizes = hba_lim->dlim_burstsizes;
986 hba_dma_attr.dma_attr_minxfer = hba_lim->dlim_minxfer;
987
988 return (scsi_hba_attach_setup(self, &hba_dma_attr, tran, flags));
989 }
990
991 /*
992 * Common nexus teardown code: used by both scsi_hba_detach() on SCSA HBA node
993 * and iport_postdetach_tran_scsi_device() on a SCSA HBA iport node (and for
994 * failure cleanup). Undo scsa_nexus_setup in reverse order.
995 *
996 * NOTE: Since we are in the Solaris IO framework, we can depend on
997 * undocumented cleanup operations performed by other parts of the framework:
998 * like detach_node() calling ddi_prop_remove_all() and
999 * ddi_remove_minor_node(,NULL).
1000 */
1001 static void
1002 scsa_nexus_teardown(dev_info_t *self, scsi_hba_tran_t *tran)
1003 {
1004 /* Teardown FMA. */
1005 if (tran->tran_hba_flags & SCSI_HBA_SCSA_FM) {
1006 ddi_fm_fini(self);
1007 tran->tran_hba_flags &= ~SCSI_HBA_SCSA_FM;
1008 }
1009 }
1010
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
25 */
26
27 #include <sys/note.h>
28
29 /*
30 * Generic SCSI Host Bus Adapter interface implementation
31 */
32 #include <sys/scsi/scsi.h>
33 #include <sys/scsi/generic/sas.h>
34 #include <sys/file.h>
35 #include <sys/disp.h> /* for minclsyspri */
36 #include <sys/ddi_impldefs.h>
37 #include <sys/ndi_impldefs.h>
38 #include <sys/sunndi.h>
39 #include <sys/ddi.h>
40 #include <sys/sunmdi.h>
41 #include <sys/mdi_impldefs.h>
42 #include <sys/callb.h>
43 #include <sys/epm.h>
44 #include <sys/damap.h>
949 tran_ext = kmem_zalloc(length,
950 (flags & SCSI_HBA_CANSLEEP) ? KM_SLEEP : KM_NOSLEEP);
951 if (tran_ext != NULL) {
952 tran->tran_extension = tran_ext;
953 ret = DDI_SUCCESS;
954 }
955 return (ret);
956 }
957
958 void
959 scsi_tran_ext_free(
960 scsi_hba_tran_t *tran,
961 size_t length)
962 {
963 if (tran->tran_extension != NULL) {
964 kmem_free(tran->tran_extension, length);
965 tran->tran_extension = NULL;
966 }
967 }
968
969 /*
970 * Common nexus teardown code: used by both scsi_hba_detach() on SCSA HBA node
971 * and iport_postdetach_tran_scsi_device() on a SCSA HBA iport node (and for
972 * failure cleanup). Undo scsa_nexus_setup in reverse order.
973 *
974 * NOTE: Since we are in the Solaris IO framework, we can depend on
975 * undocumented cleanup operations performed by other parts of the framework:
976 * like detach_node() calling ddi_prop_remove_all() and
977 * ddi_remove_minor_node(,NULL).
978 */
979 static void
980 scsa_nexus_teardown(dev_info_t *self, scsi_hba_tran_t *tran)
981 {
982 /* Teardown FMA. */
983 if (tran->tran_hba_flags & SCSI_HBA_SCSA_FM) {
984 ddi_fm_fini(self);
985 tran->tran_hba_flags &= ~SCSI_HBA_SCSA_FM;
986 }
987 }
988
|