Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../.././../../../usr/man/man9f/scsi_init_pkt.9f
Real path: /usr/share/man/man9f/scsi_init_pkt.9f
Zurück
'\" te .\" Copyright (c) 2006, 2020, Oracle and/or its affiliates. .TH scsi_init_pkt 9F "23 Jun 2020" "Oracle Solaris 11.4" "Kernel Functions" .SH NAME scsi_init_pkt \- prepare a complete SCSI packet .SH SYNOPSIS .LP .nf #include <sys/scsi/scsi.h> \fBstruct scsi_pkt *\fR\fBscsi_init_pkt\fR(\fBstruct scsi_address *\fR\fIap\fR, \fBstruct scsi_pkt *\fR\fIpktp\fR, \fBstruct buf *\fR\fIbp\fR, \fBint\fR \fIcmdlen\fR, \fBint\fR \fIstatuslen\fR, \fBint\fR \fIprivatelen\fR, \fBint\fR \fIflags\fR, \fBint\fR \fB(*\fRcallback\fB)(caddr_t)\fR, \fBcaddr_t\fR \fIarg\fR); .fi .SH INTERFACE LEVEL .sp .LP Solaris DDI specific (Solaris DDI). .SH PARAMETERS .sp .ne 2 .mk .na \fB\fIap\fR\fR .ad .br .sp .6 .RS 4n Pointer to a \fBscsi_address\fR(9S) structure. .RE .sp .ne 2 .mk .na \fB\fIpktp\fR\fR .ad .br .sp .6 .RS 4n A pointer to a \fBscsi_pkt\fR(9S) structure. .RE .sp .ne 2 .mk .na \fB\fIbp\fR\fR .ad .br .sp .6 .RS 4n Pointer to a \fBbuf\fR(9S) structure. .RE .sp .ne 2 .mk .na \fB\fIcmdlen\fR\fR .ad .br .sp .6 .RS 4n The required length for the \fBSCSI \fRcommand descriptor block (\fBCDB\fR) in bytes. .RE .sp .ne 2 .mk .na \fB\fIstatuslen\fR\fR .ad .br .sp .6 .RS 4n The required length for the \fBSCSI \fRstatus completion block (\fBSCB\fR) in bytes. Valid values are: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .br .sp .6 .RS 4n No status back. .RE .sp .ne 2 .mk .na \fB\fB1\fR\fR .ad .br .sp .6 .RS 4n Return SCSI status byte. .RE .sp .ne 2 .mk .na \fB\fBsizeof(struct scsi_arq_status)\fR\fR .ad .br .sp .6 .RS 4n Return status information in a \fBscsi_arq_status\fR structure. This will include up to \fBSENSE_LENGTH\fR bytes of sense data. Please refer to \fBscsi_arq_status\fR(9S) for more information. .sp For extra sense length packets (\fBPKT_XARQ\fR flag asserted), set \fIstatuslen\fR to be a greater number like, (\fIN\fR + \fBsizeof(struct scsi_arq_status)\fR) where \fIN\fR is the number of extra bytes beyond the default \fBSENSE_LENGTH\fR. For example, \fIN\fR=1 requests SENSE_LENGTH + 1 bytes of sense. .RE .RE .sp .ne 2 .mk .na \fB\fIprivatelen\fR\fR .ad .br .sp .6 .RS 4n The required length for the \fIpkt_private\fR area. .RE .sp .ne 2 .mk .na \fB\fIflags\fR\fR .ad .br .sp .6 .RS 4n Flags modifier. .RE .sp .ne 2 .mk .na \fB\fIcallback\fR\fR .ad .br .sp .6 .RS 4n A pointer to a callback function, \fBNULL_FUNC\fR, or \fBSLEEP_FUNC\fR. .RE .sp .ne 2 .mk .na \fB\fIarg\fR\fR .ad .br .sp .6 .RS 4n The \fIcallback\fR function argument. .RE .SH DESCRIPTION .sp .LP Target drivers use \fBscsi_init_pkt()\fR to request the transport layer to allocate and initialize a packet for a \fBSCSI\fR command which possibly includes a data transfer. If \fIpktp\fR is \fINULL,\fR a new \fBscsi_pkt\fR(9S) is allocated using the \fBHBA\fR driver's packet allocator. The \fIbp\fR is a pointer to a \fBbuf\fR(9S) structure. If \fIbp\fR is non-\fINULL\fR and contains a valid byte count, the \fBbuf\fR(9S) structure is also set up for \fBDMA \fRtransfer using the \fBHBA\fR driver \fBDMA\fR resources allocator. When \fIbp\fR is allocated by \fBscsi_alloc_consistent_buf\fR(9F), the \fBPKT_CONSISTENT\fR bit must be set in the \fIflags\fR argument to ensure proper operation. If \fIprivatelen\fR is non-zero then additional space is allocated for the \fIpkt_private\fR area of the \fBscsi_pkt\fR(9S). On return \fIpkt_private\fR points to this additional space. Otherwise \fIpkt_private\fR is a pointer that is typically used to store the \fIbp\fR during execution of the command. In this case \fIpkt_private\fR is \fINULL\fR on return. .sp .LP The \fIflags\fR argument is a set of bit flags. Possible bits include: .sp .ne 2 .mk .na \fB\fBPKT_CONSISTENT\fR\fR .ad .br .sp .6 .RS 4n This must be set if the \fBDMA\fR buffer was allocated using \fBscsi_alloc_consistent_buf\fR(9F). In this case, the \fBHBA\fR driver will guarantee that the data transfer is properly synchronized before performing the target driver's command completion callback. .RE .sp .ne 2 .mk .na \fB\fBPKT_DMA_PARTIAL\fR\fR .ad .br .sp .6 .RS 4n This may be set if the driver can accept a partial \fBDMA\fR mapping. If set, \fBscsi_init_pkt()\fR will allocate \fBDMA\fR resources with the \fBDDI_DMA_PARTIAL\fR bit set in the \fBdmar_flag\fR element of the \fBddi_dma_req\fR(9S) structure. The \fBpkt_resid\fR field of the \fBscsi_pkt\fR(9S) structure may be returned with a non-zero value, which indicates the number of bytes for which \fBscsi_init_pkt()\fR was unable to allocate DMA resources. In this case, a subsequent call to \fBscsi_init_pkt()\fR may be made for the same \fIpktp\fR and \fIbp\fR to adjust the DMA resources to the next portion of the transfer. This sequence should be repeated until the \fBpkt_resid\fR field is returned with a zero value, which indicates that with transport of this final portion the entire original request will have been satisfied. .RE .sp .ne 2 .mk .na \fB\fBPKT_XARQ\fR\fR .ad .br .sp .6 .RS 4n Setting this flag requests that the \fBHBA\fR return extra sense data for this \fBscsi_pkt\fR(9S). The default auto request sense mechanism returns up to \fBSENSE_LENGTH\fR bytes. More than \fBSENSE_LENGTH\fR bytes of sense data can be requested by setting this flag and setting the \fIstatuslen\fR correctly. Set the \fIstatuslen\fR to be the \fBsizeof(struct scsi_arq_status)\fR plus the number of sense bytes needed beyond \fBSENSE_LENGTH\fR. For example, set statuslen to be \fB(SENSE_LENGTH + 5)\fR for extra 5 bytes of sense. .RE .sp .LP When calling \fBscsi_init_pkt()\fR to move already-allocated \fBDMA\fR resources, the \fIcmdlen\fR, \fIstatuslen\fR, and \fIprivatelen\fR fields are ignored. .sp .LP The last argument \fIarg\fR is supplied to the \fIcallback\fR function when it is invoked. .sp .LP \fIcallback\fR indicates what the allocator routines should do when resources are not available: .sp .ne 2 .mk .na \fB\fBNULL_FUNC\fR\fR .ad .RS 16n .rt Do not wait for resources. Return a \fINULL\fR pointer. .RE .sp .ne 2 .mk .na \fB\fBSLEEP_FUNC\fR\fR .ad .RS 16n .rt Wait indefinitely for resources. .RE .sp .ne 2 .mk .na \fBOther Values\fR .ad .RS 16n .rt \fIcallback\fR points to a function which is called when resources may have become available. \fIcallback\fR must return either \fB0\fR (indicating that it attempted to allocate resources but again failed to do so), in which case it is put back on a list to be called again later, or \fB1\fR indicating either success in allocating resources or indicating that it no longer cares for a retry. .RE .sp .LP When allocating \fBDMA\fR resources, \fBscsi_init_pkt()\fR returns the \fBscsi_pkt\fR field \fBpkt_resid\fR as the number of residual bytes for which the system was unable to allocate \fBDMA\fR resources. A \fBpkt_resid\fR of \fB0\fR means that all necessary \fBDMA\fR resources were allocated. .SH RETURN VALUES .sp .LP The \fBscsi_init_pkt()\fR function returns \fINULL\fR if the packet or \fBDMA\fR resources could not be allocated. Otherwise, it returns a pointer to an initialized \fBscsi_pkt\fR(9S). If \fIpktp\fR was not \fINULL\fR the return value will be \fIpktp\fR on successful initialization of the packet. .SH CONTEXT .sp .LP If \fIcallback\fR is \fBSLEEP_FUNC\fR, then this routine can be called only from user or kernel context. Otherwise, it can be called from user, interrupt, or kernel context. The \fIcallback\fR function may not block or call routines that block. .SH EXAMPLES .LP \fBExample 1\fR Allocating a Packet Without \fBDMA\fR Resources Attached .sp .LP To allocate a packet without \fBDMA\fR resources attached, use: .sp .in +2 .nf pkt = scsi_init_pkt(&devp->sd_address, NULL, NULL, CDB_GROUP1, 1, sizeof (struct my_pkt_private *), 0, sd_runout, sd_unit); .fi .in -2 .sp .LP \fBExample 2\fR Allocating a Packet With \fBDMA\fR Resources Attached .sp .LP To allocate a packet with \fBDMA\fR resources attached use: .sp .in +2 .nf pkt = scsi_init_pkt(&devp->sd_address, NULL, bp, CDB_GROUP1, sizeof(struct scsi_arq_status), 0, 0, NULL_FUNC, NULL); .fi .in -2 .sp .LP \fBExample 3\fR Attaching \fBDMA\fR Resources to a Preallocated Packet .sp .LP To attach \fBDMA\fR resources to a preallocated packet, use: .sp .in +2 .nf pkt = scsi_init_pkt(&devp->sd_address, old_pkt, bp, 0, 0, 0, 0, sd_runout, (caddr_t) sd_unit); .fi .in -2 .sp .LP \fBExample 4\fR Allocating a Packet with Consistent \fBDMA\fR Resources Attached .sp .LP Since the packet is already allocated, the \fIcmdlen\fR, \fIstatuslen\fR and \fIprivatelen\fR are \fB0\fR. To allocate a packet with consistent \fBDMA\fR resources attached, use: .sp .in +2 .nf bp = scsi_alloc_consistent_buf(&devp->sd_address, NULL, SENSE_LENGTH, B_READ, SLEEP_FUNC, NULL); pkt = scsi_init_pkt(&devp->sd_address, NULL, bp, CDB_GROUP0, sizeof(struct scsi_arq_status), sizeof (struct my_pkt_private *), PKT_CONSISTENT, SLEEP_FUNC, NULL); .fi .in -2 .sp .LP \fBExample 5\fR Allocating a Packet with Partial \fBDMA\fR Resources Attached .sp .LP To allocate a packet with partial \fBDMA\fR resources attached, use: .sp .in +2 .nf my_pkt = scsi_init_pkt(&devp->sd_address, NULL, bp, CDB_GROUP0, 1, sizeof (struct buf *), PKT_DMA_PARTIAL, SLEEP_FUNC, NULL); .fi .in -2 .sp .SH SEE ALSO .sp .LP \fBscsi_alloc_consistent_buf\fR(9F), \fBscsi_destroy_pkt\fR(9F), \fBscsi_dmaget\fR(9F), \fBscsi_pktalloc\fR(9F), \fBbuf\fR(9S), \fBddi_dma_req\fR(9S), \fBscsi_address\fR(9S), \fBscsi_pkt\fR(9S) .sp .LP \fIWriting Device Drivers in Oracle Solaris 11.4\fR .SH NOTES .sp .LP If a \fBDMA\fR allocation request fails with \fBDDI_DMA_NOMAPPING\fR, the \fBB_ERROR\fR flag will be set in \fIbp\fR, and the \fBb_error\fR field will be set to \fBEFAULT\fR. .sp .LP If a \fBDMA\fR allocation request fails with \fBDDI_DMA_TOOBIG\fR, the \fBB_ERROR\fR flag will be set in \fIbp\fR, and the \fBb_error\fR field will be set to \fBEINVAL\fR.