2 .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
3 .\" 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.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" 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]
6 .TH SCSI_PKT 9S "Jan 11, 2009"
8 scsi_pkt \- SCSI packet structure
12 #include <sys/scsi/scsi.h>
18 Solaris DDI specific (Solaris DDI).
22 A \fBscsi_pkt\fR structure defines the packet that is allocated by
23 \fBscsi_init_pkt\fR(9F). The target driver fills in some information and passes
24 it to \fBscsi_transport\fR(9F) for execution on the target. The host bus
25 adapter (\fBHBA\fR) fills in other information as the command is processed.
26 When the command completes or can be taken no further, the completion function
27 specified in the packet is called with a pointer to the packet as its argument.
28 From fields within the packet, the target driver can determine the success or
29 failure of the command.
34 opaque_t pkt_ha_private; /* private data for
36 struct scsi_address pkt_address; /* destination packet */
37 opaque_t pkt_private; /* private data
39 void (*pkt_comp)(struct scsi_pkt *); /* callback */
40 uint_t pkt_flags; /* flags */
41 int pkt_time; /* time allotted to
43 uchar_t *pkt_scbp; /* pointer to
45 uchar_t *pkt_cdbp; /* pointer to
47 ssize_t pkt_resid; /* number of bytes
49 uint_t pkt_state; /* state of command */
50 uint_t pkt_statistics; /* statistics */
51 uchar_t pkt_reason; /* reason completion
53 uint_t pkt_cdblen; /* length of pkt_cdbp */
54 uint_t pkt_scdblen; /* length of pkt_scbp */
55 uint_t pkt_tgtlen; /* length of pkt_private */
56 uint_t pkt_numcookies; /* number of DMA cookies */
57 ddi_dma_cookie_t *pkt_cookies; /* array of DMA cookies */
58 uint_t pkt_dma_flags; /* DMA flags */
65 \fB\fBpkt_ha_private\fR\fR
68 Opaque pointer that the HBA uses to reference a private data structure that
69 transfers \fBscsi_pkt\fR requests.
75 \fB\fBpkt_address\fR\fR
78 Initialized by \fBscsi_init_pkt\fR(9F), \fBpkt_address\fR records the intended
79 route and the recipient of a request.
85 \fB\fBpkt_private\fR\fR
88 Reserved for the use of the target driver, \fBpkt_private\fR is not changed by
98 Specifies the command completion callback routine. When the host adapter driver
99 has gone as far as it can in transporting a command to a \fBSCSI\fR target, and
100 the command has either run to completion or can go no further for some other
101 reason, the host adapter driver calls the function pointed to by this field and
102 passes a pointer to the packet as argument. The callback routine itself is
103 called from interrupt context and must not sleep or call any function that
110 \fB\fBpkt_flags\fR\fR
113 Provides additional information about how the target driver expects the command
114 to be executed. See \fBpkt_flag Definitions\fR.
123 Set by the target driver to represent the maximum time allowed in seconds for
124 this command to complete. Timeout starts when the command is transmitted on the
125 \fBSCSI\fR bus. The \fBpkt_time\fR may be \fB0\fR if no timeout is required.
134 Points to either a struct \fBscsi_status\fR(9S) or, if \fBauto-rqsense\fR is
135 enabled and \fBpkt_state\fR includes \fBSTATE_ARQ_DONE\fR, a struct
136 \fBscsi_arq_status\fR. If \fBscsi_status\fR is returned, the \fBSCSI\fR status
137 byte resulting from the requested command is available. If
138 \fBscsi_arq_status\fR(9S) is returned, the sense information is also available.
147 Points to a kernel-addressable buffer with a length specified by a call to the
148 proper resource allocation routine, \fBscsi_init_pkt\fR(9F).
154 \fB\fBpkt_resid\fR\fR
157 Contains a residual count, either the number of data bytes that have not been
158 transferred (\fBscsi_transport\fR(9F)) or the number of data bytes for which
159 DMA resources could not be allocated \fBscsi_init_pkt\fR(9F). In the latter
160 case, partial DMA resources can be allocated only if \fBscsi_init_pkt\fR(9F) is
161 called with the \fBPKT_DMA_PARTIAL\fR flag.
167 \fB\fBpkt_state\fR\fR
170 Has bit positions that represent the six most important states that a
171 \fBSCSI\fR command can go through. See \fBpkt_state Definitions\fR.
177 \fB\fBpkt_statistics\fR\fR
180 Maintains some transport-related statistics. See \fBpkt_statistics
187 \fB\fBpkt_reason\fR\fR
190 Contains a completion code that indicates why the \fBpkt_comp\fR function was
191 called. See \fBpkt_reason Definitions\fR.
197 \fB\fBpkt_cdblen\fR\fR
200 Length of buffer pointed to by \fBpkt_cdbp\fR. See \fBtran_setup_pkt\fR.
206 \fB\fBpkt_scblen\fR\fR
209 Length of buffer pointed to by \fBpkt_scbp\fR. See \fBtran_setup_pkt\fR.
215 \fB\fBpkt_tgtlen\fR\fR
218 Length of buffer pointed to by \fBpkt_private\fR. See \fBtran_setup_pkt\fR.
224 \fB\fBpkt_numcookies\fR\fR
227 Length \fBpkt_cookies\fR array. See \fBtran_setup_pkt\fR.
233 \fB\fBpkt_cookies\fR\fR
236 Array of DMA cookies. See \fBtran_setup_pkt\fR.
242 \fB\fBpkt_dma_flags\fR\fR
245 DMA flags used, such as \fBDDI_DMA_READ\fR and \fBDDI_DMA_WRITE\fR. See
246 \fBtran_setup_pkt\fR.
251 The host adapter driver will update the \fBpkt_resid\fR, \fBpkt_reason\fR,
252 \fBpkt_state\fR, and \fBpkt_statistics\fR fields.
253 .SS "\fBpkt_flags\fR Definitions"
256 The appropriate definitions for the structure member \fBpkt_flags\fR are:
260 \fB\fBFLAG_NOINTR\fR\fR
263 Run command with no command completion callback. Command is complete upon
264 return from \fBscsi_transport\fR(9F).
270 \fB\fBFLAG_NODISCON\fR\fR
273 Run command without disconnects.
279 \fB\fBFLAG_NOPARITY\fR\fR
282 Run command without parity checking.
288 \fB\fBFLAG_HTAG\fR\fR
291 Run command as the head-of-queue-tagged command.
297 \fB\fBFLAG_OTAG\fR\fR
300 Run command as an ordered-queue-tagged command.
306 \fB\fBFLAG_STAG\fR\fR
309 Run command as a simple-queue-tagged command.
315 \fB\fBFLAG_SENSING\fR\fR
318 Indicates a request sense command.
324 \fB\fBFLAG_HEAD\fR\fR
327 Place command at the head of the queue.
333 \fB\fBFLAG_RENEGOTIATE_WIDE_SYNC\fR\fR
336 Before transporting this command, the host adapter should initiate the
337 renegotiation of wide mode and synchronous transfer speed. Normally, the HBA
338 driver manages negotiations but under certain conditions forcing a
339 renegotiation is appropriate. Renegotiation is recommended before Request Sense
340 and Inquiry commands. Refer to the SCSI 2 standard, sections 6.6.21 and 6.6.23.
342 This flag should not be set for every packet as this will severely impact
346 .SS "\fBpkt_reason\fR Definitions"
349 The appropriate definitions for the structure member \fBpkt_reason\fR are:
353 \fB\fBCMD_CMPLT\fR\fR
356 No transport errors; normal completion.
362 \fB\fBCMD_INCOMPLETE\fR\fR
365 Transport stopped with abnormal state.
371 \fB\fBCMD_DMA_DERR\fR\fR
374 \fBDMA\fRd irection error.
380 \fB\fBCMD_TRAN_ERR\fR\fR
383 Unspecified transport error.
389 \fB\fBCMD_RESET\fR\fR
392 \fBSCSI\fR bus reset destroyed command.
398 \fB\fBCMD_ABORTED\fR\fR
401 Command transport aborted on request.
407 \fB\fBCMD_TIMEOUT\fR\fR
416 \fB\fBCMD_DATA_OVR\fR\fR
425 \fB\fBCMD_CMD_OVR\fR\fR
434 \fB\fBCMD_STS_OVR\fR\fR
443 \fB\fBCMD_BADMSG\fR\fR
446 Message not command complete.
452 \fB\fBCMD_NOMSGOUT\fR\fR
455 Target refused to go to message out phase.
461 \fB\fBCMD_XID_FAIL\fR\fR
464 Extended identify message rejected.
470 \fB\fBCMD_IDE_FAIL\fR\fR
473 "Initiator Detected Error" message rejected.
479 \fB\fBCMD_ABORT_FAIL\fR\fR
482 Abort message rejected.
488 \fB\fBCMD_REJECT_FAIL\fR\fR
491 Reject message rejected.
497 \fB\fBCMD_NOP_FAIL\fR\fR
500 "No Operation" message rejected.
506 \fB\fBCMD_PER_FAIL\fR\fR
509 "Message Parity Error" message rejected.
515 \fB\fBCMD_BDR_FAIL\fR\fR
518 "Bus Device Reset" message rejected.
524 \fB\fBCMD_ID_FAIL\fR\fR
527 Identify message rejected.
533 \fB\fBCMD_UNX_BUS_FREE\fR\fR
536 Unexpected bus free phase.
542 \fB\fBCMD_TAG_REJECT\fR\fR
545 Target rejected the tag message.
551 \fB\fBCMD_DEV_GONE\fR\fR
554 The device has been removed.
557 .SS "pkt_state Definitions"
560 The appropriate definitions for the structure member \fBpkt_state\fR are:
564 \fB\fBSTATE_GOT_BUS\fR\fR
567 Bus arbitration succeeded.
573 \fB\fBSTATE_GOT_TARGET\fR\fR
576 Target successfully selected.
582 \fB\fBSTATE_SENT_CMD\fR\fR
585 Command successfully sent.
591 \fB\fBSTATE_XFERRED_DATA\fR\fR
594 Data transfer took place.
600 \fB\fBSTATE_GOT_STATUS\fR\fR
609 \fB\fBSTATE_ARQ_DONE\fR\fR
612 The command resulted in a check condition and the host adapter driver executed
613 an automatic request sense command.
619 \fB\fBSTATE_XARQ_DONE\fR\fR
622 The command requested in extra sense data using a \fBPKT_XARQ\fR flag got a
623 check condition. The host adapter driver was able to successfully request and
624 return this. The \fBscsi_pkt.pkt_scbp->sts_rqpkt_resid\fR returns the sense
625 data residual based on the \fIstatuslen\fR parameter of the
626 \fBscsi_init_pkt\fR(9F) call. The sense data begins at
627 \fBscsi_pkt.pkt_scbp->sts_sensedata\fR.
630 .SS "pkt_statistics Definitions"
633 The definitions that are appropriate for the structure member
634 \fBpkt_statistics\fR are:
638 \fB\fBSTAT_DISCON\fR\fR
647 \fB\fBSTAT_SYNC\fR\fR
650 Command did a synchronous data transfer.
656 \fB\fBSTAT_PERR\fR\fR
659 \fBSCSI\fR parity error.
665 \fB\fBSTAT_BUS_RESET\fR\fR
674 \fB\fBSTAT_DEV_RESET\fR\fR
683 \fB\fBSTAT_ABORTED\fR\fR
692 \fB\fBSTAT_TIMEOUT\fR\fR
701 \fBtran_init_pkt\fR(9E), \fBtran_setup_pkt\fR(9E), \fBscsi_arq_status\fR(9S),
702 \fBscsi_init_pkt\fR(9F), \fBscsi_transport\fR(9F), \fBscsi_status\fR(9S),
703 \fBscsi_hba_pkt_comp\fR(9F)
706 \fIWriting Device Drivers\fR
710 HBA drivers should signal \fBscsi_pkt\fR completion by calling
711 \fBscsi_hba_pkt_comp\fR(9F). This is mandatory for HBA drivers that implement
712 \fBtran_setup_pkt\fR(9E). Failure to comply results in undefined behavior.