1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
|
'\" te
.\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
.\" 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 or http://www.opensolaris.org/os/licensing. 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]
.TH SCSI_PKT 9S "Jan 11, 2009"
.SH NAME
scsi_pkt \- SCSI packet structure
.SH SYNOPSIS
.LP
.nf
#include <sys/scsi/scsi.h>
.fi
.SH INTERFACE LEVEL
.sp
.LP
Solaris DDI specific (Solaris DDI).
.SH DESCRIPTION
.sp
.LP
A \fBscsi_pkt\fR structure defines the packet that is allocated by
\fBscsi_init_pkt\fR(9F). The target driver fills in some information and passes
it to \fBscsi_transport\fR(9F) for execution on the target. The host bus
adapter (\fBHBA\fR) fills in other information as the command is processed.
When the command completes or can be taken no further, the completion function
specified in the packet is called with a pointer to the packet as its argument.
From fields within the packet, the target driver can determine the success or
failure of the command.
.SH STRUCTURE MEMBERS
.sp
.in +2
.nf
opaque_t pkt_ha_private; /* private data for
host adapter */
struct scsi_address pkt_address; /* destination packet */
opaque_t pkt_private; /* private data
for target driver */
void (*pkt_comp)(struct scsi_pkt *); /* callback */
uint_t pkt_flags; /* flags */
int pkt_time; /* time allotted to
complete command */
uchar_t *pkt_scbp; /* pointer to
status block */
uchar_t *pkt_cdbp; /* pointer to
command block */
ssize_t pkt_resid; /* number of bytes
not transferred */
uint_t pkt_state; /* state of command */
uint_t pkt_statistics; /* statistics */
uchar_t pkt_reason; /* reason completion
called */
uint_t pkt_cdblen; /* length of pkt_cdbp */
uint_t pkt_scdblen; /* length of pkt_scbp */
uint_t pkt_tgtlen; /* length of pkt_private */
uint_t pkt_numcookies; /* number of DMA cookies */
ddi_dma_cookie_t *pkt_cookies; /* array of DMA cookies */
uint_t pkt_dma_flags; /* DMA flags */
.fi
.in -2
.sp
.ne 2
.na
\fB\fBpkt_ha_private\fR\fR
.ad
.RS 18n
Opaque pointer that the HBA uses to reference a private data structure that
transfers \fBscsi_pkt\fR requests.
.RE
.sp
.ne 2
.na
\fB\fBpkt_address\fR\fR
.ad
.RS 18n
Initialized by \fBscsi_init_pkt\fR(9F), \fBpkt_address\fR records the intended
route and the recipient of a request.
.RE
.sp
.ne 2
.na
\fB\fBpkt_private\fR\fR
.ad
.RS 18n
Reserved for the use of the target driver, \fBpkt_private\fR is not changed by
the HBA driver.
.RE
.sp
.ne 2
.na
\fB\fBpkt_comp\fR\fR
.ad
.RS 18n
Specifies the command completion callback routine. When the host adapter driver
has gone as far as it can in transporting a command to a \fBSCSI\fR target, and
the command has either run to completion or can go no further for some other
reason, the host adapter driver calls the function pointed to by this field and
passes a pointer to the packet as argument. The callback routine itself is
called from interrupt context and must not sleep or call any function that
might sleep.
.RE
.sp
.ne 2
.na
\fB\fBpkt_flags\fR\fR
.ad
.RS 18n
Provides additional information about how the target driver expects the command
to be executed. See \fBpkt_flag Definitions\fR.
.RE
.sp
.ne 2
.na
\fB\fBpkt_time\fR\fR
.ad
.RS 18n
Set by the target driver to represent the maximum time allowed in seconds for
this command to complete. Timeout starts when the command is transmitted on the
\fBSCSI\fR bus. The \fBpkt_time\fR may be \fB0\fR if no timeout is required.
.RE
.sp
.ne 2
.na
\fB\fBpkt_scbp\fR\fR
.ad
.RS 18n
Points to either a struct \fBscsi_status\fR(9S) or, if \fBauto-rqsense\fR is
enabled and \fBpkt_state\fR includes \fBSTATE_ARQ_DONE\fR, a struct
\fBscsi_arq_status\fR. If \fBscsi_status\fR is returned, the \fBSCSI\fR status
byte resulting from the requested command is available. If
\fBscsi_arq_status\fR(9S) is returned, the sense information is also available.
.RE
.sp
.ne 2
.na
\fB\fBpkt_cdbp\fR\fR
.ad
.RS 18n
Points to a kernel-addressable buffer with a length specified by a call to the
proper resource allocation routine, \fBscsi_init_pkt\fR(9F).
.RE
.sp
.ne 2
.na
\fB\fBpkt_resid\fR\fR
.ad
.RS 18n
Contains a residual count, either the number of data bytes that have not been
transferred (\fBscsi_transport\fR(9F)) or the number of data bytes for which
DMA resources could not be allocated \fBscsi_init_pkt\fR(9F). In the latter
case, partial DMA resources can be allocated only if \fBscsi_init_pkt\fR(9F) is
called with the \fBPKT_DMA_PARTIAL\fR flag.
.RE
.sp
.ne 2
.na
\fB\fBpkt_state\fR\fR
.ad
.RS 18n
Has bit positions that represent the six most important states that a
\fBSCSI\fR command can go through. See \fBpkt_state Definitions\fR.
.RE
.sp
.ne 2
.na
\fB\fBpkt_statistics\fR\fR
.ad
.RS 18n
Maintains some transport-related statistics. See \fBpkt_statistics
Definitions\fR.
.RE
.sp
.ne 2
.na
\fB\fBpkt_reason\fR\fR
.ad
.RS 18n
Contains a completion code that indicates why the \fBpkt_comp\fR function was
called. See \fBpkt_reason Definitions\fR.
.RE
.sp
.ne 2
.na
\fB\fBpkt_cdblen\fR\fR
.ad
.RS 18n
Length of buffer pointed to by \fBpkt_cdbp\fR. See \fBtran_setup_pkt\fR.
.RE
.sp
.ne 2
.na
\fB\fBpkt_scblen\fR\fR
.ad
.RS 18n
Length of buffer pointed to by \fBpkt_scbp\fR. See \fBtran_setup_pkt\fR.
.RE
.sp
.ne 2
.na
\fB\fBpkt_tgtlen\fR\fR
.ad
.RS 18n
Length of buffer pointed to by \fBpkt_private\fR. See \fBtran_setup_pkt\fR.
.RE
.sp
.ne 2
.na
\fB\fBpkt_numcookies\fR\fR
.ad
.RS 18n
Length \fBpkt_cookies\fR array. See \fBtran_setup_pkt\fR.
.RE
.sp
.ne 2
.na
\fB\fBpkt_cookies\fR\fR
.ad
.RS 18n
Array of DMA cookies. See \fBtran_setup_pkt\fR.
.RE
.sp
.ne 2
.na
\fB\fBpkt_dma_flags\fR\fR
.ad
.RS 18n
DMA flags used, such as \fBDDI_DMA_READ\fR and \fBDDI_DMA_WRITE\fR. See
\fBtran_setup_pkt\fR.
.RE
.sp
.LP
The host adapter driver will update the \fBpkt_resid\fR, \fBpkt_reason\fR,
\fBpkt_state\fR, and \fBpkt_statistics\fR fields.
.SS "\fBpkt_flags\fR Definitions"
.sp
.LP
The appropriate definitions for the structure member \fBpkt_flags\fR are:
.sp
.ne 2
.na
\fB\fBFLAG_NOINTR\fR\fR
.ad
.RS 30n
Run command with no command completion callback. Command is complete upon
return from \fBscsi_transport\fR(9F).
.RE
.sp
.ne 2
.na
\fB\fBFLAG_NODISCON\fR\fR
.ad
.RS 30n
Run command without disconnects.
.RE
.sp
.ne 2
.na
\fB\fBFLAG_NOPARITY\fR\fR
.ad
.RS 30n
Run command without parity checking.
.RE
.sp
.ne 2
.na
\fB\fBFLAG_HTAG\fR\fR
.ad
.RS 30n
Run command as the head-of-queue-tagged command.
.RE
.sp
.ne 2
.na
\fB\fBFLAG_OTAG\fR\fR
.ad
.RS 30n
Run command as an ordered-queue-tagged command.
.RE
.sp
.ne 2
.na
\fB\fBFLAG_STAG\fR\fR
.ad
.RS 30n
Run command as a simple-queue-tagged command.
.RE
.sp
.ne 2
.na
\fB\fBFLAG_SENSING\fR\fR
.ad
.RS 30n
Indicates a request sense command.
.RE
.sp
.ne 2
.na
\fB\fBFLAG_HEAD\fR\fR
.ad
.RS 30n
Place command at the head of the queue.
.RE
.sp
.ne 2
.na
\fB\fBFLAG_RENEGOTIATE_WIDE_SYNC\fR\fR
.ad
.RS 30n
Before transporting this command, the host adapter should initiate the
renegotiation of wide mode and synchronous transfer speed. Normally, the HBA
driver manages negotiations but under certain conditions forcing a
renegotiation is appropriate. Renegotiation is recommended before Request Sense
and Inquiry commands. Refer to the SCSI 2 standard, sections 6.6.21 and 6.6.23.
.sp
This flag should not be set for every packet as this will severely impact
performance.
.RE
.SS "\fBpkt_reason\fR Definitions"
.sp
.LP
The appropriate definitions for the structure member \fBpkt_reason\fR are:
.sp
.ne 2
.na
\fB\fBCMD_CMPLT\fR\fR
.ad
.RS 20n
No transport errors; normal completion.
.RE
.sp
.ne 2
.na
\fB\fBCMD_INCOMPLETE\fR\fR
.ad
.RS 20n
Transport stopped with abnormal state.
.RE
.sp
.ne 2
.na
\fB\fBCMD_DMA_DERR\fR\fR
.ad
.RS 20n
\fBDMA\fRd irection error.
.RE
.sp
.ne 2
.na
\fB\fBCMD_TRAN_ERR\fR\fR
.ad
.RS 20n
Unspecified transport error.
.RE
.sp
.ne 2
.na
\fB\fBCMD_RESET\fR\fR
.ad
.RS 20n
\fBSCSI\fR bus reset destroyed command.
.RE
.sp
.ne 2
.na
\fB\fBCMD_ABORTED\fR\fR
.ad
.RS 20n
Command transport aborted on request.
.RE
.sp
.ne 2
.na
\fB\fBCMD_TIMEOUT\fR\fR
.ad
.RS 20n
Command timed out.
.RE
.sp
.ne 2
.na
\fB\fBCMD_DATA_OVR\fR\fR
.ad
.RS 20n
Data overrun.
.RE
.sp
.ne 2
.na
\fB\fBCMD_CMD_OVR\fR\fR
.ad
.RS 20n
Command overrun.
.RE
.sp
.ne 2
.na
\fB\fBCMD_STS_OVR\fR\fR
.ad
.RS 20n
Status overrun.
.RE
.sp
.ne 2
.na
\fB\fBCMD_BADMSG\fR\fR
.ad
.RS 20n
Message not command complete.
.RE
.sp
.ne 2
.na
\fB\fBCMD_NOMSGOUT\fR\fR
.ad
.RS 20n
Target refused to go to message out phase.
.RE
.sp
.ne 2
.na
\fB\fBCMD_XID_FAIL\fR\fR
.ad
.RS 20n
Extended identify message rejected.
.RE
.sp
.ne 2
.na
\fB\fBCMD_IDE_FAIL\fR\fR
.ad
.RS 20n
"Initiator Detected Error" message rejected.
.RE
.sp
.ne 2
.na
\fB\fBCMD_ABORT_FAIL\fR\fR
.ad
.RS 20n
Abort message rejected.
.RE
.sp
.ne 2
.na
\fB\fBCMD_REJECT_FAIL\fR\fR
.ad
.RS 20n
Reject message rejected.
.RE
.sp
.ne 2
.na
\fB\fBCMD_NOP_FAIL\fR\fR
.ad
.RS 20n
"No Operation" message rejected.
.RE
.sp
.ne 2
.na
\fB\fBCMD_PER_FAIL\fR\fR
.ad
.RS 20n
"Message Parity Error" message rejected.
.RE
.sp
.ne 2
.na
\fB\fBCMD_BDR_FAIL\fR\fR
.ad
.RS 20n
"Bus Device Reset" message rejected.
.RE
.sp
.ne 2
.na
\fB\fBCMD_ID_FAIL\fR\fR
.ad
.RS 20n
Identify message rejected.
.RE
.sp
.ne 2
.na
\fB\fBCMD_UNX_BUS_FREE\fR\fR
.ad
.RS 20n
Unexpected bus free phase.
.RE
.sp
.ne 2
.na
\fB\fBCMD_TAG_REJECT\fR\fR
.ad
.RS 20n
Target rejected the tag message.
.RE
.sp
.ne 2
.na
\fB\fBCMD_DEV_GONE\fR\fR
.ad
.RS 20n
The device has been removed.
.RE
.SS "pkt_state Definitions"
.sp
.LP
The appropriate definitions for the structure member \fBpkt_state\fR are:
.sp
.ne 2
.na
\fB\fBSTATE_GOT_BUS\fR\fR
.ad
.RS 22n
Bus arbitration succeeded.
.RE
.sp
.ne 2
.na
\fB\fBSTATE_GOT_TARGET\fR\fR
.ad
.RS 22n
Target successfully selected.
.RE
.sp
.ne 2
.na
\fB\fBSTATE_SENT_CMD\fR\fR
.ad
.RS 22n
Command successfully sent.
.RE
.sp
.ne 2
.na
\fB\fBSTATE_XFERRED_DATA\fR\fR
.ad
.RS 22n
Data transfer took place.
.RE
.sp
.ne 2
.na
\fB\fBSTATE_GOT_STATUS\fR\fR
.ad
.RS 22n
Status received.
.RE
.sp
.ne 2
.na
\fB\fBSTATE_ARQ_DONE\fR\fR
.ad
.RS 22n
The command resulted in a check condition and the host adapter driver executed
an automatic request sense command.
.RE
.sp
.ne 2
.na
\fB\fBSTATE_XARQ_DONE\fR\fR
.ad
.RS 22n
The command requested in extra sense data using a \fBPKT_XARQ\fR flag got a
check condition. The host adapter driver was able to successfully request and
return this. The \fBscsi_pkt.pkt_scbp->sts_rqpkt_resid\fR returns the sense
data residual based on the \fIstatuslen\fR parameter of the
\fBscsi_init_pkt\fR(9F) call. The sense data begins at
\fBscsi_pkt.pkt_scbp->sts_sensedata\fR.
.RE
.SS "pkt_statistics Definitions"
.sp
.LP
The definitions that are appropriate for the structure member
\fBpkt_statistics\fR are:
.sp
.ne 2
.na
\fB\fBSTAT_DISCON\fR\fR
.ad
.RS 18n
Device disconnect.
.RE
.sp
.ne 2
.na
\fB\fBSTAT_SYNC\fR\fR
.ad
.RS 18n
Command did a synchronous data transfer.
.RE
.sp
.ne 2
.na
\fB\fBSTAT_PERR\fR\fR
.ad
.RS 18n
\fBSCSI\fR parity error.
.RE
.sp
.ne 2
.na
\fB\fBSTAT_BUS_RESET\fR\fR
.ad
.RS 18n
Bus reset.
.RE
.sp
.ne 2
.na
\fB\fBSTAT_DEV_RESET\fR\fR
.ad
.RS 18n
Device reset.
.RE
.sp
.ne 2
.na
\fB\fBSTAT_ABORTED\fR\fR
.ad
.RS 18n
Command was aborted.
.RE
.sp
.ne 2
.na
\fB\fBSTAT_TIMEOUT\fR\fR
.ad
.RS 18n
Command timed out.
.RE
.SH SEE ALSO
.sp
.LP
\fBtran_init_pkt\fR(9E), \fBtran_setup_pkt\fR(9E), \fBscsi_arq_status\fR(9S),
\fBscsi_init_pkt\fR(9F), \fBscsi_transport\fR(9F), \fBscsi_status\fR(9S),
\fBscsi_hba_pkt_comp\fR(9F)
.sp
.LP
\fIWriting Device Drivers\fR
.SH NOTES
.sp
.LP
HBA drivers should signal \fBscsi_pkt\fR completion by calling
\fBscsi_hba_pkt_comp\fR(9F). This is mandatory for HBA drivers that implement
\fBtran_setup_pkt\fR(9E). Failure to comply results in undefined behavior.
|