/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_SCSI_SCSI_PKT_H
#define _SYS_SCSI_SCSI_PKT_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
/*
* SCSI packet definition.
*
* This structure defines the packet which is allocated by a library
* function and handed to a target driver. The target driver fills
* in some information, and passes it to the library for transport
* to an addressed SCSI device. The host adapter found by
* the library fills in some other information as the command is
* processed. When the command completes (or can be taken no further)
* the function specified in the packet is called with a pointer to
* the packet as it argument. From fields within the packet, the target
* driver can determine the success or failure of the command.
*/
struct scsi_pkt {
/*
* The DDI does not allow a driver to allocate it's own scsi_pkt(9S),
* a driver should not have *any* compiled in dependencies on
* "sizeof (struct scsi_pkt)". If the driver has such dependencies, it
* limits SCSA's ability to evolve. The proper way for an HBA to
* allocate a scsi_pkt is via scsi_hba_pkt_alloc(9F), or the newer
* tran_setup_pkt(9E) interfaces. Allocation rules have been in place
* for many years, unfortunately a significant number of drivers
* are still broken.
*
* NB: Until we can trust drivers to follow DDI scsi_pkt(9S) allocation
* rules, access to all fields below require special consideration.
* Access to these fields is limited to code paths that 'know' correct
* scsi_pkt allocation interfaces must have been used. This means that
* any target driver access to these fields is suspect, since a target
* knows nothing about how an HBA drivers performs scsi_pkt allocation.
*
* NB: A private scsi_pkt_size() interface has been added to simplify
* 'fixing' legacy HBA drivers. Use of scsi_pkt_size() is only
* proper DDI scsi_pkt allocation interfaces is too great given the
* remaining driver life. New HBA drivers should *not* use
* scsi_pkt_size().
*
* NB: While HBA drivers with violations are being fixed, in
* rare cases access conditioned by scsi_pkt_allocated_correctly() is
* permitted.
*/
/* HBA driver only, iff scsi_hba_pkt_alloc(9F)|tran_seup_pkt(9E) used */
/* HBA driver only, iff tran_seup_pkt(9E) used */
/* private: iff scsi_pkt_allocated_correctly() */
/* stage-temporary: iff scsi_pkt_allocated_correctly() */
#ifdef SCSI_SIZE_CLEAN_VERIFY
/*
* Must be last: Building a driver with-and-without
* -DSCSI_SIZE_CLEAN_VERIFY, and checking driver modules for
* differences with a tools like 'wsdiff' allows a developer to verify
* that their driver has no dependencies on scsi*(9S) size.
*/
#endif /* SCSI_SIZE_CLEAN_VERIFY */
};
#endif /* _KERNEL */
/*
* Definitions for the pkt_flags field.
*/
/*
* Following defines are generic.
*/
/* of the HBA driver's queue */
/* callback; command has been completed */
/* upon return from scsi_transport(9F) */
/*
* Following defines are appropriate for SCSI parallel bus.
*/
#define FLAG_RENEGOTIATE_WIDE_SYNC \
0x1000000 /* Do wide and sync renegotiation before */
/* transporting this command to target */
/*
* Following defines are internal i.e. not part of DDI.
*/
#define FLAG_IMMEDIATE_CB \
0x0800 /* Immediate callback on command */
/* completion, ie. do not defer */
/*
* Following defines are for USCSI options.
*/
/*
* pkg_flag for TLR
*/
/*
* Following define is for scsi_vhci.
* NOQUEUE If pHCI cannot transport the command to the device,
* do not queue the pkt in pHCI. Return immediately with
* TRAN_BUSY.
* PATH_INSTANCE Select specific path (pkt_path_instance).
* We need both a pkt_path_instance field and flag bit so
* that a retry after a path failure, which sets
* pkt_path_instance to failed path, does not select the
* failed path.
*/
/*
* Definitions for the pkt_reason field.
*/
/*
* Following defines are generic.
*/
/*
* Following defines are appropriate for SCSI parallel bus.
*/
/* Used by scsi_rname(9F) */
#define CMD_REASON_ASCII { \
"cmplt", "incomplete", "dma_derr", "tran_err", "reset", \
"aborted", "timeout", "data_ovr", "cmd_ovr", "sts_ovr", \
"badmsg", "nomsgout", "xid_fail", "ide_fail", "abort_fail", \
"reject_fail", "nop_fail", "per_fail", "bdr_fail", "id_fail", \
"unexpected_bus_free", "tag reject", "terminated", "", "gone", \
NULL }
/*
* Definitions for the pkt_state field
*/
/*
* Definitions for the pkt_statistics field
*/
/*
* Following defines are generic.
*/
/*
* Following defines are appropriate for SCSI parallel bus.
*/
/*
* Definitions for what scsi_transport returns
*/
#define TRAN_BUSY 0
#ifdef _KERNEL
/*
* Kernel function declarations
*/
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_SCSI_SCSI_PKT_H */