101a4eb82SKenneth D. Merry.\" 201a4eb82SKenneth D. Merry.\" Copyright (c) 1998 Kenneth D. Merry. 301a4eb82SKenneth D. Merry.\" All rights reserved. 401a4eb82SKenneth D. Merry.\" 501a4eb82SKenneth D. Merry.\" Redistribution and use in source and binary forms, with or without 601a4eb82SKenneth D. Merry.\" modification, are permitted provided that the following conditions 701a4eb82SKenneth D. Merry.\" are met: 801a4eb82SKenneth D. Merry.\" 1. Redistributions of source code must retain the above copyright 901a4eb82SKenneth D. Merry.\" notice, this list of conditions and the following disclaimer. 1001a4eb82SKenneth D. Merry.\" 2. Redistributions in binary form must reproduce the above copyright 1101a4eb82SKenneth D. Merry.\" notice, this list of conditions and the following disclaimer in the 1201a4eb82SKenneth D. Merry.\" documentation and/or other materials provided with the distribution. 1301a4eb82SKenneth D. Merry.\" 3. The name of the author may not be used to endorse or promote products 1401a4eb82SKenneth D. Merry.\" derived from this software without specific prior written permission. 1501a4eb82SKenneth D. Merry.\" 1601a4eb82SKenneth D. Merry.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1701a4eb82SKenneth D. Merry.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1801a4eb82SKenneth D. Merry.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1901a4eb82SKenneth D. Merry.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2001a4eb82SKenneth D. Merry.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2101a4eb82SKenneth D. Merry.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2201a4eb82SKenneth D. Merry.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2301a4eb82SKenneth D. Merry.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2401a4eb82SKenneth D. Merry.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2501a4eb82SKenneth D. Merry.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2601a4eb82SKenneth D. Merry.\" SUCH DAMAGE. 2701a4eb82SKenneth D. Merry.\" 287f3dea24SPeter Wemm.\" $FreeBSD$ 2901a4eb82SKenneth D. Merry.\" 3001a4eb82SKenneth D. Merry.\" This man page borrows heavily from the old scsi(3) man page, which had 3101a4eb82SKenneth D. Merry.\" the following copyright: 3201a4eb82SKenneth D. Merry.\" 3301a4eb82SKenneth D. Merry.\" Copyright (c) 1994 HD Associates (hd@world.std.com) 3401a4eb82SKenneth D. Merry.\" All rights reserved. 3501a4eb82SKenneth D. Merry.\" 3601a4eb82SKenneth D. Merry.\" Redistribution and use in source and binary forms, with or without 3701a4eb82SKenneth D. Merry.\" modification, are permitted provided that the following conditions 3801a4eb82SKenneth D. Merry.\" are met: 3901a4eb82SKenneth D. Merry.\" 1. Redistributions of source code must retain the above copyright 4001a4eb82SKenneth D. Merry.\" notice, this list of conditions and the following disclaimer. 4101a4eb82SKenneth D. Merry.\" 2. Redistributions in binary form must reproduce the above copyright 4201a4eb82SKenneth D. Merry.\" notice, this list of conditions and the following disclaimer in the 4301a4eb82SKenneth D. Merry.\" documentation and/or other materials provided with the distribution. 4401a4eb82SKenneth D. Merry.\" 3. All advertising materials mentioning features or use of this software 4501a4eb82SKenneth D. Merry.\" must display the following acknowledgement: 4601a4eb82SKenneth D. Merry.\" This product includes software developed by HD Associates 4701a4eb82SKenneth D. Merry.\" 4. Neither the name of the HD Associates nor the names of its contributors 4801a4eb82SKenneth D. Merry.\" may be used to endorse or promote products derived from this software 4901a4eb82SKenneth D. Merry.\" without specific prior written permission. 5001a4eb82SKenneth D. Merry.\" 5101a4eb82SKenneth D. Merry.\" THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES``AS IS'' AND 5201a4eb82SKenneth D. Merry.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 5301a4eb82SKenneth D. Merry.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 5401a4eb82SKenneth D. Merry.\" ARE DISCLAIMED. IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE 5501a4eb82SKenneth D. Merry.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 5601a4eb82SKenneth D. Merry.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 5701a4eb82SKenneth D. Merry.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 5801a4eb82SKenneth D. Merry.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 5901a4eb82SKenneth D. Merry.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 6001a4eb82SKenneth D. Merry.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 6101a4eb82SKenneth D. Merry.\" SUCH DAMAGE. 6201a4eb82SKenneth D. Merry.\" 6301a4eb82SKenneth D. Merry.\" 6401a4eb82SKenneth D. Merry.Dd October 13, 1998 65a307d598SRuslan Ermilov.Os 6601a4eb82SKenneth D. Merry.Dt CAM_CDBPARSE 3 6701a4eb82SKenneth D. Merry.Sh NAME 6801a4eb82SKenneth D. Merry.Nm csio_build , 6901a4eb82SKenneth D. Merry.Nm csio_build_visit , 7001a4eb82SKenneth D. Merry.Nm csio_decode , 7101a4eb82SKenneth D. Merry.Nm csio_decode_visit , 7201a4eb82SKenneth D. Merry.Nm buff_decode , 7301a4eb82SKenneth D. Merry.Nm buff_decode_visit , 7401a4eb82SKenneth D. Merry.Nm csio_encode , 7501a4eb82SKenneth D. Merry.Nm csio_encode_visit , 7601a4eb82SKenneth D. Merry.Nm buff_encode_visit 7701a4eb82SKenneth D. Merry.Nd CAM user library SCSI buffer parsing routines 78c8baaf18SAlexey Zelkin.Sh LIBRARY 79c8baaf18SAlexey Zelkin.Lb libcam 8001a4eb82SKenneth D. Merry.Sh SYNOPSIS 8132eef9aeSRuslan Ermilov.In stdio.h 8232eef9aeSRuslan Ermilov.In camlib.h 8301a4eb82SKenneth D. Merry.Ft int 8401a4eb82SKenneth D. Merry.Fo csio_build 8501a4eb82SKenneth D. Merry.Fa "struct ccb_scsiio *csio" 8601a4eb82SKenneth D. Merry.Fa "u_int8_t *data_ptr" 8701a4eb82SKenneth D. Merry.Fa "u_int32_t dxfer_len" 8801a4eb82SKenneth D. Merry.Fa "u_int32_t flags" 8901a4eb82SKenneth D. Merry.Fa "int retry_count" 9001a4eb82SKenneth D. Merry.Fa "int timeout" 9101a4eb82SKenneth D. Merry.Fa "char *cmd_spec" 9201a4eb82SKenneth D. Merry.Fa "..." 9301a4eb82SKenneth D. Merry.Fc 9401a4eb82SKenneth D. Merry.Ft int 9501a4eb82SKenneth D. Merry.Fo csio_build_visit 9601a4eb82SKenneth D. Merry.Fa "struct ccb_scsiio *csio" 9701a4eb82SKenneth D. Merry.Fa "u_int8_t *data_ptr" 9801a4eb82SKenneth D. Merry.Fa "u_int32_t dxfer_len" 9901a4eb82SKenneth D. Merry.Fa "u_int32_t flags" 10001a4eb82SKenneth D. Merry.Fa "int retry_count" 10101a4eb82SKenneth D. Merry.Fa "int timeout" 10201a4eb82SKenneth D. Merry.Fa "char *cmd_spec" 10301a4eb82SKenneth D. Merry.Fa "int (*arg_get)(void *hook, char *field_name)" 10401a4eb82SKenneth D. Merry.Fa "void *gethook" 10501a4eb82SKenneth D. Merry.Fc 10601a4eb82SKenneth D. Merry.Ft int 10701a4eb82SKenneth D. Merry.Fo csio_decode 10801a4eb82SKenneth D. Merry.Fa "struct ccb_scsiio *csio" 10901a4eb82SKenneth D. Merry.Fa "char *fmt" 11001a4eb82SKenneth D. Merry.Fa "..." 11101a4eb82SKenneth D. Merry.Fc 11201a4eb82SKenneth D. Merry.Ft int 11301a4eb82SKenneth D. Merry.Fo csio_decode_visit 11401a4eb82SKenneth D. Merry.Fa "struct ccb_scsiio *csio" 11501a4eb82SKenneth D. Merry.Fa "char *fmt" 11601a4eb82SKenneth D. Merry.Fa "void (*arg_put)(void *hook" 11701a4eb82SKenneth D. Merry.Fa "int letter" 11801a4eb82SKenneth D. Merry.Fa "void *val" 11901a4eb82SKenneth D. Merry.Fa "int count" 12001a4eb82SKenneth D. Merry.Fa "char *name)" 12101a4eb82SKenneth D. Merry.Fa "void *puthook" 12201a4eb82SKenneth D. Merry.Fc 12301a4eb82SKenneth D. Merry.Ft int 12401a4eb82SKenneth D. Merry.Fo buff_decode 12501a4eb82SKenneth D. Merry.Fa "u_int8_t *buff" 12601a4eb82SKenneth D. Merry.Fa "size_t len" 12701a4eb82SKenneth D. Merry.Fa "char *fmt" 12801a4eb82SKenneth D. Merry.Fa "..." 12901a4eb82SKenneth D. Merry.Fc 13001a4eb82SKenneth D. Merry.Ft int 13101a4eb82SKenneth D. Merry.Fo buff_decode_visit 13201a4eb82SKenneth D. Merry.Fa "u_int8_t *buff" 13301a4eb82SKenneth D. Merry.Fa "size_t len" 13401a4eb82SKenneth D. Merry.Fa "char *fmt" 13501a4eb82SKenneth D. Merry.Fa "void (*arg_put)(void *, int, void *, int, char *)" 13601a4eb82SKenneth D. Merry.Fa "void *puthook" 13701a4eb82SKenneth D. Merry.Fc 13801a4eb82SKenneth D. Merry.Ft int 13901a4eb82SKenneth D. Merry.Fo csio_encode 14001a4eb82SKenneth D. Merry.Fa "struct ccb_scsiio *csio" 14101a4eb82SKenneth D. Merry.Fa "char *fmt" 14201a4eb82SKenneth D. Merry.Fa "..." 14301a4eb82SKenneth D. Merry.Fc 14401a4eb82SKenneth D. Merry.Ft int 14501a4eb82SKenneth D. Merry.Fo csio_encode_visit 14601a4eb82SKenneth D. Merry.Fa "struct ccb_scsiio *csio" 14701a4eb82SKenneth D. Merry.Fa "char *fmt" 14801a4eb82SKenneth D. Merry.Fa "int (*arg_get)(void *hook, char *field_name)" 14901a4eb82SKenneth D. Merry.Fa "void *gethook" 15001a4eb82SKenneth D. Merry.Fc 15101a4eb82SKenneth D. Merry.Ft int 15201a4eb82SKenneth D. Merry.Fo buff_encode_visit 15301a4eb82SKenneth D. Merry.Fa "u_int8_t *buff" 15401a4eb82SKenneth D. Merry.Fa "size_t len" 15501a4eb82SKenneth D. Merry.Fa "char *fmt" 15601a4eb82SKenneth D. Merry.Fa "int (*arg_get)(void *hook, char *field_name)" 15701a4eb82SKenneth D. Merry.Fa "void *gethook" 15801a4eb82SKenneth D. Merry.Fc 15901a4eb82SKenneth D. Merry.Sh DESCRIPTION 16001a4eb82SKenneth D. MerryThe CAM buffer/CDB encoding and decoding routines provide a relatively easy 16101a4eb82SKenneth D. Merrymigration path for userland 16201a4eb82SKenneth D. Merry.Tn SCSI 16301a4eb82SKenneth D. Merryapplications written with the similarly-named 16401a4eb82SKenneth D. Merry.Va scsireq_ Ns * 165b5c508fbSRuslan Ermilovfunctions from the old 166b5c508fbSRuslan Ermilov.Fx 16701a4eb82SKenneth D. Merry.Tn SCSI 16801a4eb82SKenneth D. Merrylayer. 16901a4eb82SKenneth D. Merry.Pp 17001a4eb82SKenneth D. MerryThese functions may be used in new applications, but users may find it 17101a4eb82SKenneth D. Merryeasier to use the various SCSI CCB building functions included with the 17201a4eb82SKenneth D. Merry.Xr cam 3 17357e4378bSRuslan Ermilovlibrary. (e.g.\& 17401a4eb82SKenneth D. Merry.Fn cam_fill_csio , 17501a4eb82SKenneth D. Merry.Fn scsi_start_stop , 17601a4eb82SKenneth D. Merryand 17701a4eb82SKenneth D. Merry.Fn scsi_read_write ) 17801a4eb82SKenneth D. Merry.Pp 17901a4eb82SKenneth D. Merry.Fn csio_build 18001a4eb82SKenneth D. Merrybuilds up a 18101a4eb82SKenneth D. Merry.Va ccb_scsiio 18201a4eb82SKenneth D. Merrystructure based on the information provided in 18301a4eb82SKenneth D. Merrythe variable argument list. 18401a4eb82SKenneth D. MerryIt gracefully handles a NULL 18501a4eb82SKenneth D. Merry.Fa data_ptr 18601a4eb82SKenneth D. Merryargument passed to it. 18701a4eb82SKenneth D. Merry.Pp 18801a4eb82SKenneth D. Merry.Fa dxfer_len 18901a4eb82SKenneth D. Merryis the length of the data phase; the data transfer direction is 19001a4eb82SKenneth D. Merrydetermined by the 19101a4eb82SKenneth D. Merry.Fa flags 19201a4eb82SKenneth D. Merryargument. 19301a4eb82SKenneth D. Merry.Pp 19401a4eb82SKenneth D. Merry.Fa data_ptr 19501a4eb82SKenneth D. Merryis the data buffer used during the 19601a4eb82SKenneth D. Merry.Tn SCSI 19701a4eb82SKenneth D. Merrydata phase. If no data is to be 19801a4eb82SKenneth D. Merrytransferred for the 19901a4eb82SKenneth D. Merry.Tn SCSI 20001a4eb82SKenneth D. Merrycommand in question, this should be set to NULL. If there is data to 20101a4eb82SKenneth D. Merrytransfer for the command, this buffer must be at least 20201a4eb82SKenneth D. Merry.Fa dxfer_len 20301a4eb82SKenneth D. Merrylong. 20401a4eb82SKenneth D. Merry.Pp 20501a4eb82SKenneth D. Merry.Fa flags 20601a4eb82SKenneth D. Merryare the flags defined in 20701a4eb82SKenneth D. Merry.Aq Pa cam/cam_ccb.h : 20801a4eb82SKenneth D. Merry.Bd -literal 20901a4eb82SKenneth D. Merry/* Common CCB header */ 21001a4eb82SKenneth D. Merry/* CAM CCB flags */ 21101a4eb82SKenneth D. Merrytypedef enum { 21201a4eb82SKenneth D. Merry CAM_CDB_POINTER = 0x00000001,/* The CDB field is a pointer */ 21301a4eb82SKenneth D. Merry CAM_QUEUE_ENABLE = 0x00000002,/* SIM queue actions are enabled */ 21401a4eb82SKenneth D. Merry CAM_CDB_LINKED = 0x00000004,/* CCB contains a linked CDB */ 21501a4eb82SKenneth D. Merry CAM_SCATTER_VALID = 0x00000010,/* Scatter/gather list is valid */ 21601a4eb82SKenneth D. Merry CAM_DIS_AUTOSENSE = 0x00000020,/* Disable autosense feature */ 21701a4eb82SKenneth D. Merry CAM_DIR_RESV = 0x00000000,/* Data direction (00:reserved) */ 21801a4eb82SKenneth D. Merry CAM_DIR_IN = 0x00000040,/* Data direction (01:DATA IN) */ 21901a4eb82SKenneth D. Merry CAM_DIR_OUT = 0x00000080,/* Data direction (10:DATA OUT) */ 22001a4eb82SKenneth D. Merry CAM_DIR_NONE = 0x000000C0,/* Data direction (11:no data) */ 22101a4eb82SKenneth D. Merry CAM_DIR_MASK = 0x000000C0,/* Data direction Mask */ 22201a4eb82SKenneth D. Merry CAM_SOFT_RST_OP = 0x00000100,/* Use Soft reset alternative */ 22301a4eb82SKenneth D. Merry CAM_ENG_SYNC = 0x00000200,/* Flush resid bytes on complete */ 22401a4eb82SKenneth D. Merry CAM_DEV_QFRZDIS = 0x00000400,/* Disable DEV Q freezing */ 22501a4eb82SKenneth D. Merry CAM_DEV_QFREEZE = 0x00000800,/* Freeze DEV Q on execution */ 22601a4eb82SKenneth D. Merry CAM_HIGH_POWER = 0x00001000,/* Command takes a lot of power */ 22701a4eb82SKenneth D. Merry CAM_SENSE_PTR = 0x00002000,/* Sense data is a pointer */ 22801a4eb82SKenneth D. Merry CAM_SENSE_PHYS = 0x00004000,/* Sense pointer is physical addr*/ 22901a4eb82SKenneth D. Merry CAM_TAG_ACTION_VALID = 0x00008000,/* Use the tag action in this ccb*/ 23001a4eb82SKenneth D. Merry CAM_PASS_ERR_RECOVER = 0x00010000,/* Pass driver does err. recovery*/ 23101a4eb82SKenneth D. Merry CAM_DIS_DISCONNECT = 0x00020000,/* Disable disconnect */ 23201a4eb82SKenneth D. Merry CAM_SG_LIST_PHYS = 0x00040000,/* SG list has physical addrs. */ 23301a4eb82SKenneth D. Merry CAM_MSG_BUF_PHYS = 0x00080000,/* Message buffer ptr is physical*/ 23401a4eb82SKenneth D. Merry CAM_SNS_BUF_PHYS = 0x00100000,/* Autosense data ptr is physical*/ 23501a4eb82SKenneth D. Merry CAM_DATA_PHYS = 0x00200000,/* SG/Buffer data ptrs are phys. */ 23601a4eb82SKenneth D. Merry CAM_CDB_PHYS = 0x00400000,/* CDB poiner is physical */ 23701a4eb82SKenneth D. Merry CAM_ENG_SGLIST = 0x00800000,/* SG list is for the HBA engine */ 23801a4eb82SKenneth D. Merry 23901a4eb82SKenneth D. Merry/* Phase cognizant mode flags */ 24001a4eb82SKenneth D. Merry CAM_DIS_AUTOSRP = 0x01000000,/* Diable autosave/restore ptrs */ 24101a4eb82SKenneth D. Merry CAM_DIS_AUTODISC = 0x02000000,/* Disable auto disconnect */ 24201a4eb82SKenneth D. Merry CAM_TGT_CCB_AVAIL = 0x04000000,/* Target CCB available */ 24301a4eb82SKenneth D. Merry CAM_TGT_PHASE_MODE = 0x08000000,/* The SIM runs in phase mode */ 24401a4eb82SKenneth D. Merry CAM_MSGB_VALID = 0x20000000,/* Message buffer valid */ 24501a4eb82SKenneth D. Merry CAM_STATUS_VALID = 0x40000000,/* Status buffer valid */ 24601a4eb82SKenneth D. Merry CAM_DATAB_VALID = 0x80000000,/* Data buffer valid */ 24701a4eb82SKenneth D. Merry 24801a4eb82SKenneth D. Merry/* Host target Mode flags */ 24901a4eb82SKenneth D. Merry CAM_TERM_IO = 0x20000000,/* Terminate I/O Message sup. */ 25001a4eb82SKenneth D. Merry CAM_DISCONNECT = 0x40000000,/* Disconnects are mandatory */ 25101a4eb82SKenneth D. Merry CAM_SEND_STATUS = 0x80000000,/* Send status after data phase */ 25201a4eb82SKenneth D. Merry} ccb_flags; 25301a4eb82SKenneth D. Merry.Ed 25401a4eb82SKenneth D. Merry.Pp 25501a4eb82SKenneth D. MerryMultiple flags should be ORed together. Any of the CCB flags may be used, 25601a4eb82SKenneth D. Merryalthough it is worth noting several important ones here: 25701a4eb82SKenneth D. Merry.Pp 25801a4eb82SKenneth D. Merry.Bl -tag -width CAM_PASS_ERR_RECOVER 25901a4eb82SKenneth D. Merry.It Dv CAM_DIR_IN 26001a4eb82SKenneth D. MerryThis indicates that the operation in question is a read operation. i.e., 26101a4eb82SKenneth D. Merrydata is being read from the 26201a4eb82SKenneth D. Merry.Tn SCSI 26301a4eb82SKenneth D. Merrydevice to the user-supplied buffer. 26401a4eb82SKenneth D. Merry.It Dv CAM_DIR_OUT 26501a4eb82SKenneth D. MerryThis indicates that the operation is a write operation. i.e. data is being 26601a4eb82SKenneth D. Merrywritten from the user-supplied buffer to the device. 26701a4eb82SKenneth D. Merry.It Dv CAM_DIR_NONE 26801a4eb82SKenneth D. MerryThis indicates that there is no data to be transferred for this command. 26901a4eb82SKenneth D. Merry.It Dv CAM_DEV_QFRZDIS 27001a4eb82SKenneth D. MerryThis flag disables device queue freezing as an error recovery mechanism. 27101a4eb82SKenneth D. Merry.It Dv CAM_PASS_ERR_RECOVER 27201a4eb82SKenneth D. MerryThis flag tells the 27301a4eb82SKenneth D. Merry.Xr pass 4 27401a4eb82SKenneth D. Merrydriver to enable error recovery. The default is to not perform error 27501a4eb82SKenneth D. Merryrecovery, which means that the retry count won't be honored without this 27601a4eb82SKenneth D. Merryflag, among other things. 27701a4eb82SKenneth D. Merry.It Dv CAM_DATA_PHYS 27801a4eb82SKenneth D. MerryThis indicates that the address contained in 27901a4eb82SKenneth D. Merry.Fa data_ptr 28001a4eb82SKenneth D. Merryis a physical address, not a virtual address. 28101a4eb82SKenneth D. Merry.El 28201a4eb82SKenneth D. Merry.Pp 28301a4eb82SKenneth D. MerryThe 28401a4eb82SKenneth D. Merry.Fa retry_count 28501a4eb82SKenneth D. Merrytells the kernel how many times to retry the command in question. The 28601a4eb82SKenneth D. Merryretry count is ignored unless the 28701a4eb82SKenneth D. Merry.Xr pass 4 28801a4eb82SKenneth D. Merrydriver is told to enable error recovery via the 28901a4eb82SKenneth D. Merry.Dv CAM_PASS_ERR_RECOVER 29001a4eb82SKenneth D. Merryflag. 29101a4eb82SKenneth D. Merry.Pp 29201a4eb82SKenneth D. MerryThe 29301a4eb82SKenneth D. Merry.Fa timeout 29401a4eb82SKenneth D. Merrytells the kernel how long to wait for the given command to complete. If 29501a4eb82SKenneth D. Merrythe timeout expires and the command hasn't completed, the CCB will be 29601a4eb82SKenneth D. Merryreturned from the kernel with an appropriate error status. 29701a4eb82SKenneth D. Merry.Pp 29801a4eb82SKenneth D. Merry.Fa cmd_spec 29901a4eb82SKenneth D. Merryis a CDB format specifier used to build up the SCSI CDB. 30001a4eb82SKenneth D. MerryThis text string is made up of a list of field specifiers. Field 30101a4eb82SKenneth D. Merryspecifiers specify the value for each CDB field (including indicating 30201a4eb82SKenneth D. Merrythat the value be taken from the next argument in the 30301a4eb82SKenneth D. Merryvariable argument list), the width 30401a4eb82SKenneth D. Merryof the field in bits or bytes, and an optional name. White space is 30501a4eb82SKenneth D. Merryignored, and the pound sign ('#') introduces a comment that ends at the 30601a4eb82SKenneth D. Merryend of the current line. 30701a4eb82SKenneth D. Merry.Pp 30801a4eb82SKenneth D. MerryThe optional name is the first part of a field specifier and 30901a4eb82SKenneth D. Merryis in curly braces. The text in curly braces in this example are 31001a4eb82SKenneth D. Merrythe names: 311953ae31aSAlexander Langer.Dl "{PS} v:b1 {Reserved} 0:b1 {Page Code} v:b6 # Mode select page" 31201a4eb82SKenneth D. Merry.Pp 31301a4eb82SKenneth D. MerryThis field specifier has two one bit fields and one six bit field. 31401a4eb82SKenneth D. MerryThe second one bit field is the constant value 0 and the first 31501a4eb82SKenneth D. Merryone bit field and the six bit field are taken from the variable 31601a4eb82SKenneth D. Merryargument list. 31701a4eb82SKenneth D. MerryMulti byte fields are swapped into the SCSI byte order in the 31801a4eb82SKenneth D. MerryCDB and white space is ignored. 31901a4eb82SKenneth D. Merry.Pp 32001a4eb82SKenneth D. MerryWhen the field is a hex value or the letter v, (e.g., 32101a4eb82SKenneth D. Merry.Fa "1A" 32201a4eb82SKenneth D. Merryor 32301a4eb82SKenneth D. Merry.Fa "v" ) 32401a4eb82SKenneth D. Merrythen a single byte value 32501a4eb82SKenneth D. Merryis copied to the next unused byte of the CDB. 32601a4eb82SKenneth D. MerryWhen the letter 32701a4eb82SKenneth D. Merry.Fa v 32801a4eb82SKenneth D. Merryis used the next integer argument is taken from the variable argument list 32901a4eb82SKenneth D. Merryand that value used. 33001a4eb82SKenneth D. Merry.Pp 33101a4eb82SKenneth D. MerryA constant hex value followed by a field width specifier or the letter 33201a4eb82SKenneth D. Merry.Fa v 33301a4eb82SKenneth D. Merryfollowed by a field width specifier (e.g., 33401a4eb82SKenneth D. Merry.Fa 3:4 , 33501a4eb82SKenneth D. Merry.Fa 3:b4 , 33601a4eb82SKenneth D. Merry.Fa 3:i3 , 337382114daSRuslan Ermilov.Fa v:i3 ) 33801a4eb82SKenneth D. Merryspecifies a field of a given bit or byte width. 33901a4eb82SKenneth D. MerryEither the constant value or (for the V specifier) the next integer value from 34001a4eb82SKenneth D. Merrythe variable argument list is copied to the next unused 34101a4eb82SKenneth D. Merrybits or bytes of the CDB. 34201a4eb82SKenneth D. Merry.Pp 34301a4eb82SKenneth D. MerryA decimal number or the letter 34401a4eb82SKenneth D. Merry.Fa b 34501a4eb82SKenneth D. Merryfollowed by a decimal number field width indicates a bit field of that width. 34601a4eb82SKenneth D. MerryThe bit fields are packed as tightly as possible beginning with the 34701a4eb82SKenneth D. Merryhigh bit (so that it reads the same as the SCSI spec), and a new byte of 34801a4eb82SKenneth D. Merrythe CDB is started whenever a byte fills completely or when an 34901a4eb82SKenneth D. Merry.Fa i 35001a4eb82SKenneth D. Merryfield is encountered. 35101a4eb82SKenneth D. Merry.Pp 35201a4eb82SKenneth D. MerryA field width specifier consisting of the letter 35301a4eb82SKenneth D. Merry.Fa i 35401a4eb82SKenneth D. Merryfollowed by either 35501a4eb82SKenneth D. Merry1, 2, 3 or 4 indicates a 1, 2, 3 or 4 byte integral value that must 35601a4eb82SKenneth D. Merrybe swapped into SCSI byte order (MSB first). 35701a4eb82SKenneth D. Merry.Pp 35801a4eb82SKenneth D. MerryFor the 35901a4eb82SKenneth D. Merry.Fa v 36001a4eb82SKenneth D. Merryfield specifier the next integer argument is taken from the variable argument 36101a4eb82SKenneth D. Merrylist and that value is used swapped into SCSI byte order. 36201a4eb82SKenneth D. Merry.Pp 36301a4eb82SKenneth D. Merry.Fn csio_build_visit 36401a4eb82SKenneth D. Merryoperates similarly to 36501a4eb82SKenneth D. Merry.Fn csio_build , 36601a4eb82SKenneth D. Merryexcept that the values to substitute for variable arguments in 36701a4eb82SKenneth D. Merry.Fa cmd_spec 36801a4eb82SKenneth D. Merryare retrieved via the 36901a4eb82SKenneth D. Merry.Fn arg_get 37001a4eb82SKenneth D. Merryfunction passed in to 37101a4eb82SKenneth D. Merry.Fn csio_build_visit 37201a4eb82SKenneth D. Merryinstead of via 37301a4eb82SKenneth D. Merry.Xr stdarg 3 . 37401a4eb82SKenneth D. MerryThe 37501a4eb82SKenneth D. Merry.Fn arg_get 37601a4eb82SKenneth D. Merryfunction takes two arguments: 37701a4eb82SKenneth D. Merry.Bl -tag -width field_name 37801a4eb82SKenneth D. Merry.It Fa gethook 37901a4eb82SKenneth D. Merryis passed into the 38001a4eb82SKenneth D. Merry.Fn arg_get 38101a4eb82SKenneth D. Merryfunction at each invocation. This enables the 38201a4eb82SKenneth D. Merry.Fn arg_get 38301a4eb82SKenneth D. Merryfunction to keep some state in between calls without using global or static 38401a4eb82SKenneth D. Merryvariables. 38501a4eb82SKenneth D. Merry.It Fa field_name 38601a4eb82SKenneth D. Merryis the field name supplied in 38701a4eb82SKenneth D. Merry.Fa fmt , 38801a4eb82SKenneth D. Merryif any. 38901a4eb82SKenneth D. Merry.El 39001a4eb82SKenneth D. Merry.Pp 39101a4eb82SKenneth D. Merry.Fn csio_decode 39201a4eb82SKenneth D. Merryis used to decode information from the data in phase of the SCSI 39301a4eb82SKenneth D. Merrytransfer. 39401a4eb82SKenneth D. Merry.Pp 39501a4eb82SKenneth D. MerryThe decoding is similar to 39601a4eb82SKenneth D. Merrythe command specifier processing of 39701a4eb82SKenneth D. Merry.Fn csio_build 39801a4eb82SKenneth D. Merryexcept that the data is extracted from the data pointed to by 39901a4eb82SKenneth D. Merry.Fa csio->data_ptr . 40001a4eb82SKenneth D. MerryThe stdarg list should be pointers to integers instead of integer 40101a4eb82SKenneth D. Merryvalues. 40201a4eb82SKenneth D. MerryA seek field type and a suppression modifier are added. 40301a4eb82SKenneth D. MerryThe 40401a4eb82SKenneth D. Merry.Fa * 40501a4eb82SKenneth D. Merrysuppression modifier (e.g., 40601a4eb82SKenneth D. Merry.Fa *i3 40701a4eb82SKenneth D. Merryor 40801a4eb82SKenneth D. Merry.Fa *b4 ) 40901a4eb82SKenneth D. Merrysuppresses assignment from the field and can be used to skip 41001a4eb82SKenneth D. Merryover bytes or bits in the data, without having to copy 41101a4eb82SKenneth D. Merrythem to a dummy variable in the arg list. 41201a4eb82SKenneth D. Merry.Pp 41301a4eb82SKenneth D. MerryThe seek field type 41401a4eb82SKenneth D. Merry.Fa s 41501a4eb82SKenneth D. Merrypermits you to skip over data. 41694ba280cSRuslan ErmilovThis seeks to an absolute position 41794ba280cSRuslan Ermilov.Pq Fa s3 41894ba280cSRuslan Ermilovor a relative position 41994ba280cSRuslan Ermilov.Pq Fa s+3 42001a4eb82SKenneth D. Merryin the data, based on whether or not the presence of the '+' sign. 42101a4eb82SKenneth D. MerryThe seek value can be specified as 42201a4eb82SKenneth D. Merry.Fa v 42301a4eb82SKenneth D. Merryand the next integer value from the argument list will be 42401a4eb82SKenneth D. Merryused as the seek value. 42501a4eb82SKenneth D. Merry.Pp 42601a4eb82SKenneth D. Merry.Fn csio_decode_visit 42701a4eb82SKenneth D. Merryoperates like 42801a4eb82SKenneth D. Merry.Fn csio_decode 42901a4eb82SKenneth D. Merryexcept that instead of placing the decoded contents of the buffer in 43001a4eb82SKenneth D. Merryvarardic arguments, the decoded buffer contents are returned to the user 43101a4eb82SKenneth D. Merryvia the 43201a4eb82SKenneth D. Merry.Fn arg_put 43301a4eb82SKenneth D. Merryfunction that is passed in. 43401a4eb82SKenneth D. MerryThe 43501a4eb82SKenneth D. Merry.Fn arg_put 43601a4eb82SKenneth D. Merryfunction takes several arguments: 43701a4eb82SKenneth D. Merry.Bl -tag -width letter 43801a4eb82SKenneth D. Merry.It Fa hook 43901a4eb82SKenneth D. MerryThe "hook" is a mechanism to allow the 44001a4eb82SKenneth D. Merry.Fn arg_put 44101a4eb82SKenneth D. Merryfunction to save state in between calls. 44201a4eb82SKenneth D. Merry.It Fa letter 44301a4eb82SKenneth D. Merryis the letter describing the format of the argument being passed into the 44401a4eb82SKenneth D. Merryfunction. 44501a4eb82SKenneth D. Merry.It Fa val 44601a4eb82SKenneth D. Merryis a void pointer to the value being passed into the function. 44701a4eb82SKenneth D. Merry.It Fa count 4487e32b20dSKelly Yanceyis the size of the value being passed into the 44901a4eb82SKenneth D. Merry.Fn arg_put 4507e32b20dSKelly Yanceyfunction. The argument format determines the unit of measure. 45101a4eb82SKenneth D. Merry.It Fa name 45201a4eb82SKenneth D. MerryThis is a text description of the field, if one was provided in the 45301a4eb82SKenneth D. Merry.Fa fmt . 45401a4eb82SKenneth D. Merry.El 45501a4eb82SKenneth D. Merry.Pp 45601a4eb82SKenneth D. Merry.Fn buff_decode 45701a4eb82SKenneth D. Merrydecodes an arbitrary data buffer using the method 45801a4eb82SKenneth D. Merrydescribed above for 45901a4eb82SKenneth D. Merry.Fn csio_decode . 46001a4eb82SKenneth D. Merry.Pp 46101a4eb82SKenneth D. Merry.Fn buff_decode_visit 46201a4eb82SKenneth D. Merrydecodes an arbitrary data buffer using the method described above for 46301a4eb82SKenneth D. Merry.Fn csio_decode_visit . 46401a4eb82SKenneth D. Merry.Pp 46501a4eb82SKenneth D. Merry.Fn csio_encode 46601a4eb82SKenneth D. Merryencodes the 46701a4eb82SKenneth D. Merry.Fa data_ptr 46801a4eb82SKenneth D. Merryportion (not the CDB!) of a 46901a4eb82SKenneth D. Merry.Va ccb_scsiio 47001a4eb82SKenneth D. Merrystructure, using the method described above for 47101a4eb82SKenneth D. Merry.Fn csio_build . 47201a4eb82SKenneth D. Merry.Pp 47301a4eb82SKenneth D. Merry.Fn csio_encode_visit 47401a4eb82SKenneth D. Merryencodes the 47501a4eb82SKenneth D. Merry.Fa data_ptr 47601a4eb82SKenneth D. Merryportion (not the CDB!) of a 47701a4eb82SKenneth D. Merry.Va ccb_scsiio 47801a4eb82SKenneth D. Merrystructure, using the method described above for 47901a4eb82SKenneth D. Merry.Fn csio_build_visit . 48001a4eb82SKenneth D. Merry.Pp 48101a4eb82SKenneth D. Merry.Fn buff_encode_visit 48201a4eb82SKenneth D. Merryencodes an arbitrary data pointer, using the method described 48301a4eb82SKenneth D. Merryabove for 48401a4eb82SKenneth D. Merry.Fn csio_build_visit . 48501a4eb82SKenneth D. Merry.Sh RETURN VALUES 48601a4eb82SKenneth D. Merry.Fn csio_build , 48701a4eb82SKenneth D. Merry.Fn csio_build_visit , 48801a4eb82SKenneth D. Merry.Fn csio_encode , 48901a4eb82SKenneth D. Merry.Fn csio_encode_visit , 49001a4eb82SKenneth D. Merryand 49101a4eb82SKenneth D. Merry.Fn buff_encode_visit 49201a4eb82SKenneth D. Merryreturn the number of fields processed. 49301a4eb82SKenneth D. Merry.Pp 49401a4eb82SKenneth D. Merry.Fn csio_decode , 49501a4eb82SKenneth D. Merry.Fn csio_decode_visit , 49601a4eb82SKenneth D. Merry.Fn buff_decode , 49701a4eb82SKenneth D. Merryand 49801a4eb82SKenneth D. Merry.Fn buff_decode_visit 49901a4eb82SKenneth D. Merryreturn the number of assignments performed. 50001a4eb82SKenneth D. Merry.Sh SEE ALSO 50101a4eb82SKenneth D. Merry.Xr cam 3 , 50201a4eb82SKenneth D. Merry.Xr pass 4 , 50301a4eb82SKenneth D. Merry.Xr camcontrol 8 50401a4eb82SKenneth D. Merry.Sh HISTORY 50501a4eb82SKenneth D. MerryThe CAM versions of these functions are based upon similar functions 506b5c508fbSRuslan Ermilovimplemented for the old 507b5c508fbSRuslan Ermilov.Fx 50801a4eb82SKenneth D. Merry.Tn SCSI 50901a4eb82SKenneth D. Merrylayer. The encoding/decoding functions in the old 51001a4eb82SKenneth D. Merry.Tn SCSI 51101a4eb82SKenneth D. Merrycode were written by Peter Dufault. 51201a4eb82SKenneth D. Merry.Pp 51301a4eb82SKenneth D. MerryMany systems have comparable interfaces to permit a user to construct a 51401a4eb82SKenneth D. MerrySCSI command in user space. 51501a4eb82SKenneth D. Merry.Pp 51601a4eb82SKenneth D. MerryThe old 51701a4eb82SKenneth D. Merry.Va scsireq 51801a4eb82SKenneth D. Merrydata structure was almost identical to the SGI /dev/scsi data 51901a4eb82SKenneth D. Merrystructure. If anyone knows the name of the authors it should 52001a4eb82SKenneth D. Merrygo here; Peter Dufault first read about it in a 1989 Sun Expert magazine. 52101a4eb82SKenneth D. Merry.Pp 52201a4eb82SKenneth D. MerryThe new CCB data structures are derived from the CAM-2 and CAM-3 52301a4eb82SKenneth D. Merryspecifications. 52401a4eb82SKenneth D. Merry.Pp 525753d686dSRuslan Ermilov.An Peter Dufault 526753d686dSRuslan Ermilovimplemented a clone of SGI's interface in 527753d686dSRuslan Ermilov.Bx 386 528753d686dSRuslan Ermilovthat 529b5c508fbSRuslan Ermilovled to the original 530b5c508fbSRuslan Ermilov.Fx 53101a4eb82SKenneth D. Merry.Tn SCSI 53201a4eb82SKenneth D. Merrylibrary and the related kernel ioctl. 53301a4eb82SKenneth D. MerryIf anyone needs that for compatibility contact dufault@hda.com. 53401a4eb82SKenneth D. Merry.Sh AUTHORS 53501a4eb82SKenneth D. MerryKenneth Merry implemented the CAM versions of these encoding and decoding 53601a4eb82SKenneth D. Merryfunctions. This current work is based upon earlier work by Peter Dufault. 53701a4eb82SKenneth D. Merry.Sh BUGS 53801a4eb82SKenneth D. MerryThere should probably be a function that encodes both the CDB and the data 53901a4eb82SKenneth D. Merrybuffer portions of a 54001a4eb82SKenneth D. Merry.Tn SCSI 54101a4eb82SKenneth D. MerryCCB. I discovered this while implementing the arbitrary command execution 54201a4eb82SKenneth D. Merrycode in 54301a4eb82SKenneth D. Merry.Xr camcontrol 8 , 54401a4eb82SKenneth D. Merrybut I haven't yet had time to implement such a function. 54501a4eb82SKenneth D. Merry.Pp 54601a4eb82SKenneth D. MerrySome of the CCB flag descriptions really don't belong here. Rather they 54701a4eb82SKenneth D. Merrybelong in a generic CCB man page. Since that man page hasn't yet been 54801a4eb82SKenneth D. Merrywritten, the shorter descriptions here will have to suffice. 549