17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 58faf39b2Staylor * Common Development and Distribution License (the "License"). 68faf39b2Staylor * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*f6715e51Ssrivijitha dugganapalli * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 231e32c0dcScth * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_SCSI_SCSI_RESOURCE_H 277c478bd9Sstevel@tonic-gate #define _SYS_SCSI_SCSI_RESOURCE_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate 308faf39b2Staylor #ifdef __lock_lint 318faf39b2Staylor #include <note.h> 328faf39b2Staylor #endif 337c478bd9Sstevel@tonic-gate #include <sys/scsi/scsi_types.h> 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifdef __cplusplus 367c478bd9Sstevel@tonic-gate extern "C" { 377c478bd9Sstevel@tonic-gate #endif 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate /* 401e32c0dcScth * SCSI Resource Function Declarations 417c478bd9Sstevel@tonic-gate */ 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate /* 447c478bd9Sstevel@tonic-gate * Defines for stating preferences in resource allocation 457c478bd9Sstevel@tonic-gate */ 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate #define NULL_FUNC ((int (*)())0) 487c478bd9Sstevel@tonic-gate #define SLEEP_FUNC ((int (*)())1) 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate #ifdef _KERNEL 517c478bd9Sstevel@tonic-gate /* 527c478bd9Sstevel@tonic-gate * Defines for the flags to scsi_init_pkt() 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate #define PKT_CONSISTENT 0x0001 /* this is an 'iopb' packet */ 557c478bd9Sstevel@tonic-gate #define PKT_DMA_PARTIAL 0x040000 /* partial xfer ok */ 5630ab6db6Slh195018 #define PKT_XARQ 0x080000 /* request for extra sense */ 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* 597c478bd9Sstevel@tonic-gate * Old PKT_CONSISTENT value for binary compatibility with x86 2.1 607c478bd9Sstevel@tonic-gate */ 617c478bd9Sstevel@tonic-gate #define PKT_CONSISTENT_OLD 0x001000 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate /* 647c478bd9Sstevel@tonic-gate * Kernel function declarations 657c478bd9Sstevel@tonic-gate */ 661e32c0dcScth struct buf *scsi_alloc_consistent_buf(struct scsi_address *, 677c478bd9Sstevel@tonic-gate struct buf *, size_t, uint_t, int (*)(caddr_t), caddr_t); 681e32c0dcScth struct scsi_pkt *scsi_init_pkt(struct scsi_address *, 697c478bd9Sstevel@tonic-gate struct scsi_pkt *, struct buf *, int, int, int, int, 707c478bd9Sstevel@tonic-gate int (*)(caddr_t), caddr_t); 711e32c0dcScth void scsi_destroy_pkt(struct scsi_pkt *); 721e32c0dcScth void scsi_free_consistent_buf(struct buf *); 73602ca9eaScth int scsi_pkt_allocated_correctly(struct scsi_pkt *); 741e32c0dcScth struct scsi_pkt *scsi_dmaget(struct scsi_pkt *, opaque_t, int (*)(void)); 751e32c0dcScth void scsi_dmafree(struct scsi_pkt *); 761e32c0dcScth void scsi_sync_pkt(struct scsi_pkt *); 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate /* 79cab28b2dStaylor * Private wrapper for scsi_pkt's allocated via scsi_init_cache_pkt() 80cab28b2dStaylor */ 81cab28b2dStaylor struct scsi_pkt_cache_wrapper { 82cab28b2dStaylor struct scsi_pkt pcw_pkt; 83602ca9eaScth int pcw_magic; 848faf39b2Staylor uint_t pcw_total_xfer; 858faf39b2Staylor uint_t pcw_curwin; 868faf39b2Staylor uint_t pcw_totalwin; 878faf39b2Staylor uint_t pcw_granular; 888faf39b2Staylor struct buf *pcw_bp; 898faf39b2Staylor ddi_dma_cookie_t pcw_cookie; 908faf39b2Staylor uint_t pcw_flags; 91cab28b2dStaylor }; 92cab28b2dStaylor 938faf39b2Staylor #ifdef __lock_lint 941fad2c0eSXiao Raymond Li _NOTE(SCHEME_PROTECTS_DATA("unique per packet", 951fad2c0eSXiao Raymond Li scsi_pkt_cache_wrapper::pcw_bp 961fad2c0eSXiao Raymond Li scsi_pkt_cache_wrapper::pcw_curwin 971fad2c0eSXiao Raymond Li scsi_pkt_cache_wrapper::pcw_flags 981fad2c0eSXiao Raymond Li scsi_pkt_cache_wrapper::pcw_granular 991fad2c0eSXiao Raymond Li scsi_pkt_cache_wrapper::pcw_total_xfer 1001fad2c0eSXiao Raymond Li scsi_pkt_cache_wrapper::pcw_totalwin)) 1018faf39b2Staylor #endif 1028faf39b2Staylor struct buf *scsi_pkt2bp(struct scsi_pkt *); 1038faf39b2Staylor 1048faf39b2Staylor #define PCW_NEED_EXT_CDB 0x0001 1058faf39b2Staylor #define PCW_NEED_EXT_TGT 0x0002 1068faf39b2Staylor #define PCW_NEED_EXT_SCB 0x0004 1078faf39b2Staylor #define PCW_BOUND 0x0020 108cab28b2dStaylor 109cab28b2dStaylor /* 110cab28b2dStaylor * Private defines i.e. not part of the DDI. 111cab28b2dStaylor */ 112cab28b2dStaylor #define DEFAULT_CDBLEN 16 113cab28b2dStaylor #define DEFAULT_PRIVLEN 0 114cab28b2dStaylor #define DEFAULT_SCBLEN (sizeof (struct scsi_arq_status)) 115cab28b2dStaylor 116602ca9eaScth /* Private functions */ 117602ca9eaScth size_t scsi_pkt_size(); 118602ca9eaScth void scsi_size_clean(dev_info_t *); 119602ca9eaScth 120602ca9eaScth /* Obsolete kernel functions: */ 121602ca9eaScth struct scsi_pkt *scsi_pktalloc(struct scsi_address *, int, int, int (*)(void)); 122602ca9eaScth struct scsi_pkt *scsi_resalloc(struct scsi_address *, int, 123602ca9eaScth int, opaque_t, int (*)(void)); 124602ca9eaScth void scsi_resfree(struct scsi_pkt *); 1257c478bd9Sstevel@tonic-gate #define scsi_pktfree scsi_resfree 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1307c478bd9Sstevel@tonic-gate } 1317c478bd9Sstevel@tonic-gate #endif 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate #endif /* _SYS_SCSI_SCSI_RESOURCE_H */ 134