scsi_pt.c revision 46625
1/*
2 * Implementation of SCSI Processor Target Peripheral driver for CAM.
3 *
4 * Copyright (c) 1998 Justin T. Gibbs.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions, and the following disclaimer,
12 *    without modification, immediately at the beginning of the file.
13 * 2. The name of the author may not be used to endorse or promote products
14 *    derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 *      $Id: scsi_pt.c,v 1.5 1999/02/10 00:03:15 ken Exp $
29 */
30
31#include <sys/param.h>
32#include <sys/queue.h>
33#include <sys/systm.h>
34#include <sys/kernel.h>
35#include <sys/types.h>
36#include <sys/buf.h>
37#include <sys/devicestat.h>
38#include <sys/malloc.h>
39#include <sys/conf.h>
40
41#include <cam/cam.h>
42#include <cam/cam_ccb.h>
43#include <cam/cam_extend.h>
44#include <cam/cam_periph.h>
45#include <cam/cam_xpt_periph.h>
46#include <cam/cam_debug.h>
47
48#include <cam/scsi/scsi_all.h>
49#include <cam/scsi/scsi_message.h>
50#include <cam/scsi/scsi_pt.h>
51
52typedef enum {
53	PT_STATE_PROBE,
54	PT_STATE_NORMAL
55} pt_state;
56
57typedef enum {
58	PT_FLAG_NONE		= 0x00,
59	PT_FLAG_OPEN		= 0x01,
60	PT_FLAG_DEVICE_INVALID	= 0x02,
61	PT_FLAG_RETRY_UA	= 0x04
62} pt_flags;
63
64typedef enum {
65	PT_CCB_BUFFER_IO	= 0x01,
66	PT_CCB_WAITING		= 0x02,
67	PT_CCB_RETRY_UA		= 0x04,
68	PT_CCB_BUFFER_IO_UA	= PT_CCB_BUFFER_IO|PT_CCB_RETRY_UA
69} pt_ccb_state;
70
71/* Offsets into our private area for storing information */
72#define ccb_state	ppriv_field0
73#define ccb_bp		ppriv_ptr1
74
75struct pt_softc {
76	struct	 buf_queue_head buf_queue;
77	struct	 devstat device_stats;
78	LIST_HEAD(, ccb_hdr) pending_ccbs;
79	pt_state state;
80	pt_flags flags;
81	union	 ccb saved_ccb;
82};
83
84static	d_open_t	ptopen;
85static	d_close_t	ptclose;
86static	d_strategy_t	ptstrategy;
87static	periph_init_t	ptinit;
88static	void		ptasync(void *callback_arg, u_int32_t code,
89				struct cam_path *path, void *arg);
90static	periph_ctor_t	ptctor;
91static	periph_oninv_t	ptoninvalidate;
92static	periph_dtor_t	ptdtor;
93static	periph_start_t	ptstart;
94static	void		ptdone(struct cam_periph *periph,
95			       union ccb *done_ccb);
96static  int		pterror(union ccb *ccb, u_int32_t cam_flags,
97				u_int32_t sense_flags);
98
99void	scsi_send_receive(struct ccb_scsiio *csio, u_int32_t retries,
100			  void (*cbfcnp)(struct cam_periph *, union ccb *),
101			  u_int tag_action, int readop, u_int byte2,
102			  u_int32_t xfer_len, u_int8_t *data_ptr,
103			  u_int8_t sense_len, u_int32_t timeout);
104
105static struct periph_driver ptdriver =
106{
107	ptinit, "pt",
108	TAILQ_HEAD_INITIALIZER(ptdriver.units), /* generation */ 0
109};
110
111DATA_SET(periphdriver_set, ptdriver);
112
113#define PT_CDEV_MAJOR 61
114
115static struct cdevsw pt_cdevsw =
116{
117	/*d_open*/	ptopen,
118	/*d_close*/	ptclose,
119	/*d_read*/	physread,
120	/*d_write*/	physwrite,
121	/*d_ioctl*/	noioctl,
122	/*d_stop*/	nostop,
123	/*d_reset*/	noreset,
124	/*d_devtotty*/	nodevtotty,
125	/*d_poll*/	seltrue,
126	/*d_mmap*/	nommap,
127	/*d_strategy*/	ptstrategy,
128	/*d_name*/	"pt",
129	/*d_spare*/	NULL,
130	/*d_maj*/	-1,
131	/*d_dump*/	nodump,
132	/*d_psize*/	nopsize,
133	/*d_flags*/	0,
134	/*d_maxio*/	0,
135	/*b_maj*/	-1
136};
137
138static struct extend_array *ptperiphs;
139
140static int
141ptopen(dev_t dev, int flags, int fmt, struct proc *p)
142{
143	struct cam_periph *periph;
144	struct pt_softc *softc;
145	int unit;
146	int error;
147	int s;
148
149	unit = minor(dev);
150	periph = cam_extend_get(ptperiphs, unit);
151	if (periph == NULL)
152		return (ENXIO);
153
154	softc = (struct pt_softc *)periph->softc;
155
156	s = splsoftcam();
157	if (softc->flags & PT_FLAG_DEVICE_INVALID) {
158		splx(s);
159		return(ENXIO);
160	}
161
162	CAM_DEBUG(periph->path, CAM_DEBUG_TRACE,
163	    ("ptopen: dev=0x%x (unit %d)\n", dev, unit));
164
165	if ((error = cam_periph_lock(periph, PRIBIO|PCATCH)) != 0) {
166		splx(s);
167		return (error); /* error code from tsleep */
168	}
169
170	splx(s);
171
172	if ((softc->flags & PT_FLAG_OPEN) == 0) {
173		if (cam_periph_acquire(periph) != CAM_REQ_CMP)
174			error = ENXIO;
175		else
176			softc->flags |= PT_FLAG_OPEN;
177	} else
178		error = EBUSY;
179
180	cam_periph_unlock(periph);
181	return (error);
182}
183
184static int
185ptclose(dev_t dev, int flag, int fmt, struct proc *p)
186{
187	struct	cam_periph *periph;
188	struct	pt_softc *softc;
189	int	unit;
190	int	error;
191
192	unit = minor(dev);
193	periph = cam_extend_get(ptperiphs, unit);
194	if (periph == NULL)
195		return (ENXIO);
196
197	softc = (struct pt_softc *)periph->softc;
198
199	if ((error = cam_periph_lock(periph, PRIBIO)) != 0)
200		return (error); /* error code from tsleep */
201
202	softc->flags &= ~PT_FLAG_OPEN;
203	cam_periph_unlock(periph);
204	cam_periph_release(periph);
205	return (0);
206}
207
208/*
209 * Actually translate the requested transfer into one the physical driver
210 * can understand.  The transfer is described by a buf and will include
211 * only one physical transfer.
212 */
213static void
214ptstrategy(struct buf *bp)
215{
216	struct cam_periph *periph;
217	struct pt_softc *softc;
218	u_int  unit;
219	int    s;
220
221	unit = minor(bp->b_dev);
222	periph = cam_extend_get(ptperiphs, unit);
223	if (periph == NULL) {
224		bp->b_error = ENXIO;
225		goto bad;
226	}
227	softc = (struct pt_softc *)periph->softc;
228
229	/*
230	 * Mask interrupts so that the pack cannot be invalidated until
231	 * after we are in the queue.  Otherwise, we might not properly
232	 * clean up one of the buffers.
233	 */
234	s = splbio();
235
236	/*
237	 * If the device has been made invalid, error out
238	 */
239	if ((softc->flags & PT_FLAG_DEVICE_INVALID)) {
240		splx(s);
241		bp->b_error = ENXIO;
242		goto bad;
243	}
244
245	/*
246	 * Place it in the queue of disk activities for this disk
247	 */
248	bufq_insert_tail(&softc->buf_queue, bp);
249
250	splx(s);
251
252	/*
253	 * Schedule ourselves for performing the work.
254	 */
255	xpt_schedule(periph, /* XXX priority */1);
256
257	return;
258bad:
259	bp->b_flags |= B_ERROR;
260
261	/*
262	 * Correctly set the buf to indicate a completed xfer
263	 */
264	bp->b_resid = bp->b_bcount;
265	biodone(bp);
266}
267
268static void
269ptinit(void)
270{
271	cam_status status;
272	struct cam_path *path;
273
274	/*
275	 * Create our extend array for storing the devices we attach to.
276	 */
277	ptperiphs = cam_extend_new();
278	if (ptperiphs == NULL) {
279		printf("pt: Failed to alloc extend array!\n");
280		return;
281	}
282
283	/*
284	 * Install a global async callback.  This callback will
285	 * receive async callbacks like "new device found".
286	 */
287	status = xpt_create_path(&path, /*periph*/NULL, CAM_XPT_PATH_ID,
288				 CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD);
289
290	if (status == CAM_REQ_CMP) {
291		struct ccb_setasync csa;
292
293                xpt_setup_ccb(&csa.ccb_h, path, /*priority*/5);
294                csa.ccb_h.func_code = XPT_SASYNC_CB;
295                csa.event_enable = AC_FOUND_DEVICE;
296                csa.callback = ptasync;
297                csa.callback_arg = NULL;
298                xpt_action((union ccb *)&csa);
299		status = csa.ccb_h.status;
300                xpt_free_path(path);
301        }
302
303	if (status != CAM_REQ_CMP) {
304		printf("pt: Failed to attach master async callback "
305		       "due to status 0x%x!\n", status);
306	} else {
307		/* If we were successfull, register our devsw */
308		dev_t dev;
309
310		dev = makedev(PT_CDEV_MAJOR, 0);
311		cdevsw_add(&dev,&pt_cdevsw, NULL);
312	}
313}
314
315static cam_status
316ptctor(struct cam_periph *periph, void *arg)
317{
318	struct pt_softc *softc;
319	struct ccb_setasync csa;
320	struct ccb_getdev *cgd;
321
322	cgd = (struct ccb_getdev *)arg;
323	if (periph == NULL) {
324		printf("ptregister: periph was NULL!!\n");
325		return(CAM_REQ_CMP_ERR);
326	}
327
328	if (cgd == NULL) {
329		printf("ptregister: no getdev CCB, can't register device\n");
330		return(CAM_REQ_CMP_ERR);
331	}
332
333	softc = (struct pt_softc *)malloc(sizeof(*softc),M_DEVBUF,M_NOWAIT);
334
335	if (softc == NULL) {
336		printf("daregister: Unable to probe new device. "
337		       "Unable to allocate softc\n");
338		return(CAM_REQ_CMP_ERR);
339	}
340
341	bzero(softc, sizeof(*softc));
342	LIST_INIT(&softc->pending_ccbs);
343	softc->state = PT_STATE_NORMAL;
344	bufq_init(&softc->buf_queue);
345
346	periph->softc = softc;
347
348	cam_extend_set(ptperiphs, periph->unit_number, periph);
349
350	/*
351	 * The DA driver supports a blocksize, but
352	 * we don't know the blocksize until we do
353	 * a read capacity.  So, set a flag to
354	 * indicate that the blocksize is
355	 * unavailable right now.  We'll clear the
356	 * flag as soon as we've done a read capacity.
357	 */
358	devstat_add_entry(&softc->device_stats, "pt",
359			  periph->unit_number, 0,
360			  DEVSTAT_NO_BLOCKSIZE,
361			  cgd->pd_type | DEVSTAT_TYPE_IF_SCSI,
362			  DEVSTAT_PRIORITY_OTHER);
363
364	/*
365	 * Add async callbacks for bus reset and
366	 * bus device reset calls.  I don't bother
367	 * checking if this fails as, in most cases,
368	 * the system will function just fine without
369	 * them and the only alternative would be to
370	 * not attach the device on failure.
371	 */
372	xpt_setup_ccb(&csa.ccb_h, periph->path, /*priority*/5);
373	csa.ccb_h.func_code = XPT_SASYNC_CB;
374	csa.event_enable = AC_SENT_BDR | AC_BUS_RESET | AC_LOST_DEVICE;
375	csa.callback = ptasync;
376	csa.callback_arg = periph;
377	xpt_action((union ccb *)&csa);
378
379	/* Tell the user we've attached to the device */
380	xpt_announce_periph(periph, NULL);
381
382	return(CAM_REQ_CMP);
383}
384
385static void
386ptoninvalidate(struct cam_periph *periph)
387{
388	int s;
389	struct pt_softc *softc;
390	struct buf *q_bp;
391	struct ccb_setasync csa;
392
393	softc = (struct pt_softc *)periph->softc;
394
395	/*
396	 * De-register any async callbacks.
397	 */
398	xpt_setup_ccb(&csa.ccb_h, periph->path,
399		      /* priority */ 5);
400	csa.ccb_h.func_code = XPT_SASYNC_CB;
401	csa.event_enable = 0;
402	csa.callback = ptasync;
403	csa.callback_arg = periph;
404	xpt_action((union ccb *)&csa);
405
406	softc->flags |= PT_FLAG_DEVICE_INVALID;
407
408	/*
409	 * Although the oninvalidate() routines are always called at
410	 * splsoftcam, we need to be at splbio() here to keep the buffer
411	 * queue from being modified while we traverse it.
412	 */
413	s = splbio();
414
415	/*
416	 * Return all queued I/O with ENXIO.
417	 * XXX Handle any transactions queued to the card
418	 *     with XPT_ABORT_CCB.
419	 */
420	while ((q_bp = bufq_first(&softc->buf_queue)) != NULL){
421		bufq_remove(&softc->buf_queue, q_bp);
422		q_bp->b_resid = q_bp->b_bcount;
423		q_bp->b_error = ENXIO;
424		q_bp->b_flags |= B_ERROR;
425		biodone(q_bp);
426	}
427
428	splx(s);
429
430	xpt_print_path(periph->path);
431	printf("lost device\n");
432}
433
434static void
435ptdtor(struct cam_periph *periph)
436{
437	struct pt_softc *softc;
438
439	softc = (struct pt_softc *)periph->softc;
440
441	devstat_remove_entry(&softc->device_stats);
442
443	cam_extend_release(ptperiphs, periph->unit_number);
444	xpt_print_path(periph->path);
445	printf("removing device entry\n");
446	free(softc, M_DEVBUF);
447}
448
449static void
450ptasync(void *callback_arg, u_int32_t code, struct cam_path *path, void *arg)
451{
452	struct cam_periph *periph;
453
454	periph = (struct cam_periph *)callback_arg;
455	switch (code) {
456	case AC_FOUND_DEVICE:
457	{
458		struct ccb_getdev *cgd;
459		cam_status status;
460
461		cgd = (struct ccb_getdev *)arg;
462
463		if (cgd->pd_type != T_PROCESSOR)
464			break;
465
466		/*
467		 * Allocate a peripheral instance for
468		 * this device and start the probe
469		 * process.
470		 */
471		status = cam_periph_alloc(ptctor, ptoninvalidate, ptdtor,
472					  ptstart, "pt", CAM_PERIPH_BIO,
473					  cgd->ccb_h.path, ptasync,
474					  AC_FOUND_DEVICE, cgd);
475
476		if (status != CAM_REQ_CMP
477		 && status != CAM_REQ_INPROG)
478			printf("ptasync: Unable to attach to new device "
479				"due to status 0x%x\n", status);
480		break;
481	}
482	case AC_LOST_DEVICE:
483	{
484		cam_periph_invalidate(periph);
485		break;
486	}
487	case AC_SENT_BDR:
488	case AC_BUS_RESET:
489	{
490		struct pt_softc *softc;
491		struct ccb_hdr *ccbh;
492		int s;
493
494		softc = (struct pt_softc *)periph->softc;
495		s = splsoftcam();
496		/*
497		 * Don't fail on the expected unit attention
498		 * that will occur.
499		 */
500		softc->flags |= PT_FLAG_RETRY_UA;
501		for (ccbh = LIST_FIRST(&softc->pending_ccbs);
502		     ccbh != NULL; ccbh = LIST_NEXT(ccbh, periph_links.le))
503			ccbh->ccb_state |= PT_CCB_RETRY_UA;
504		splx(s);
505		break;
506	}
507	case AC_TRANSFER_NEG:
508	case AC_SCSI_AEN:
509	case AC_UNSOL_RESEL:
510	default:
511		break;
512	}
513}
514
515static void
516ptstart(struct cam_periph *periph, union ccb *start_ccb)
517{
518	struct pt_softc *softc;
519	struct buf *bp;
520	int s;
521
522	softc = (struct pt_softc *)periph->softc;
523
524	/*
525	 * See if there is a buf with work for us to do..
526	 */
527	s = splbio();
528	bp = bufq_first(&softc->buf_queue);
529	if (periph->immediate_priority <= periph->pinfo.priority) {
530		CAM_DEBUG_PRINT(CAM_DEBUG_SUBTRACE,
531				("queuing for immediate ccb\n"));
532		start_ccb->ccb_h.ccb_state = PT_CCB_WAITING;
533		SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h,
534				  periph_links.sle);
535		periph->immediate_priority = CAM_PRIORITY_NONE;
536		splx(s);
537		wakeup(&periph->ccb_list);
538	} else if (bp == NULL) {
539		splx(s);
540		xpt_release_ccb(start_ccb);
541	} else {
542		int oldspl;
543
544		bufq_remove(&softc->buf_queue, bp);
545
546		devstat_start_transaction(&softc->device_stats);
547
548		scsi_send_receive(&start_ccb->csio,
549				  /*retries*/4,
550				  ptdone,
551				  MSG_SIMPLE_Q_TAG,
552				  bp->b_flags & B_READ,
553				  /*byte2*/0,
554				  bp->b_bcount,
555				  bp->b_data,
556				  /*sense_len*/SSD_FULL_SIZE,
557				  /*timeout*/10000);
558
559		start_ccb->ccb_h.ccb_state = PT_CCB_BUFFER_IO;
560
561		/*
562		 * Block out any asyncronous callbacks
563		 * while we touch the pending ccb list.
564		 */
565		oldspl = splcam();
566		LIST_INSERT_HEAD(&softc->pending_ccbs, &start_ccb->ccb_h,
567				 periph_links.le);
568		splx(oldspl);
569
570		start_ccb->ccb_h.ccb_bp = bp;
571		bp = bufq_first(&softc->buf_queue);
572		splx(s);
573
574		xpt_action(start_ccb);
575
576		if (bp != NULL) {
577			/* Have more work to do, so ensure we stay scheduled */
578			xpt_schedule(periph, /* XXX priority */1);
579		}
580	}
581}
582
583static void
584ptdone(struct cam_periph *periph, union ccb *done_ccb)
585{
586	struct pt_softc *softc;
587	struct ccb_scsiio *csio;
588
589	softc = (struct pt_softc *)periph->softc;
590	csio = &done_ccb->csio;
591	switch (csio->ccb_h.ccb_state) {
592	case PT_CCB_BUFFER_IO:
593	case PT_CCB_BUFFER_IO_UA:
594	{
595		struct buf *bp;
596		int    oldspl;
597
598		bp = (struct buf *)done_ccb->ccb_h.ccb_bp;
599		if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
600			int error;
601			int s;
602			int sf;
603
604			if ((csio->ccb_h.ccb_state & PT_CCB_RETRY_UA) != 0)
605				sf = SF_RETRY_UA;
606			else
607				sf = 0;
608
609			if ((error = pterror(done_ccb, 0, sf)) == ERESTART) {
610				/*
611				 * A retry was scheuled, so
612				 * just return.
613				 */
614				return;
615			}
616			if (error != 0) {
617				struct buf *q_bp;
618
619				s = splbio();
620
621				if (error == ENXIO) {
622					/*
623					 * Catastrophic error.  Mark our device
624					 * as invalid.
625					 */
626					xpt_print_path(periph->path);
627					printf("Invalidating device\n");
628					softc->flags |= PT_FLAG_DEVICE_INVALID;
629				}
630
631				/*
632				 * return all queued I/O with EIO, so that
633				 * the client can retry these I/Os in the
634				 * proper order should it attempt to recover.
635				 */
636				while ((q_bp = bufq_first(&softc->buf_queue))
637					!= NULL) {
638					bufq_remove(&softc->buf_queue, q_bp);
639					q_bp->b_resid = q_bp->b_bcount;
640					q_bp->b_error = EIO;
641					q_bp->b_flags |= B_ERROR;
642					biodone(q_bp);
643				}
644				splx(s);
645				bp->b_error = error;
646				bp->b_resid = bp->b_bcount;
647				bp->b_flags |= B_ERROR;
648			} else {
649				bp->b_resid = csio->resid;
650				bp->b_error = 0;
651				if (bp->b_resid != 0) {
652					/* Short transfer ??? */
653					bp->b_flags |= B_ERROR;
654				}
655			}
656			if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0)
657				cam_release_devq(done_ccb->ccb_h.path,
658						 /*relsim_flags*/0,
659						 /*reduction*/0,
660						 /*timeout*/0,
661						 /*getcount_only*/0);
662		} else {
663			bp->b_resid = csio->resid;
664			if (bp->b_resid != 0)
665				bp->b_flags |= B_ERROR;
666		}
667
668		/*
669		 * Block out any asyncronous callbacks
670		 * while we touch the pending ccb list.
671		 */
672		oldspl = splcam();
673		LIST_REMOVE(&done_ccb->ccb_h, periph_links.le);
674		splx(oldspl);
675
676		devstat_end_transaction(&softc->device_stats,
677					bp->b_bcount - bp->b_resid,
678					done_ccb->csio.tag_action & 0xf,
679					(bp->b_flags & B_READ) ? DEVSTAT_READ
680							       : DEVSTAT_WRITE);
681
682		biodone(bp);
683		break;
684	}
685	case PT_CCB_WAITING:
686		/* Caller will release the CCB */
687		wakeup(&done_ccb->ccb_h.cbfcnp);
688		return;
689	}
690	xpt_release_ccb(done_ccb);
691}
692
693static int
694pterror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags)
695{
696	struct pt_softc	  *softc;
697	struct cam_periph *periph;
698
699	periph = xpt_path_periph(ccb->ccb_h.path);
700	softc = (struct pt_softc *)periph->softc;
701
702	return(cam_periph_error(ccb, cam_flags, sense_flags,
703				&softc->saved_ccb));
704}
705
706void
707scsi_send_receive(struct ccb_scsiio *csio, u_int32_t retries,
708		  void (*cbfcnp)(struct cam_periph *, union ccb *),
709		  u_int tag_action, int readop, u_int byte2,
710		  u_int32_t xfer_len, u_int8_t *data_ptr, u_int8_t sense_len,
711		  u_int32_t timeout)
712{
713	struct scsi_send_receive *scsi_cmd;
714
715	scsi_cmd = (struct scsi_send_receive *)&csio->cdb_io.cdb_bytes;
716	scsi_cmd->opcode = readop ? RECEIVE : SEND;
717	scsi_cmd->byte2 = byte2;
718	scsi_ulto3b(xfer_len, scsi_cmd->xfer_len);
719	scsi_cmd->control = 0;
720
721	cam_fill_csio(csio,
722		      retries,
723		      cbfcnp,
724		      /*flags*/readop ? CAM_DIR_IN : CAM_DIR_OUT,
725		      tag_action,
726		      data_ptr,
727		      xfer_len,
728		      sense_len,
729		      sizeof(*scsi_cmd),
730		      timeout);
731}
732