1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2000 Michael Smith
5 * Copyright (c) 2000 BSDi
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29 /*-
30 * Copyright (c) 2002 Eric Moore
31 * Copyright (c) 2002 LSI Logic Corporation
32 * All rights reserved.
33 *
34 * Redistribution and use in source and binary forms, with or without
35 * modification, are permitted provided that the following conditions
36 * are met:
37 * 1. Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * 2. Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
42 * 3. The party using or redistributing the source code and binary forms
43 * agrees to the disclaimer below and the terms and conditions set forth
44 * herein.
45 *
46 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
47 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
50 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 * SUCH DAMAGE.
57 */
58
59 #include <sys/cdefs.h>
60 #include <sys/param.h>
61 #include <sys/systm.h>
62 #include <sys/malloc.h>
63 #include <sys/kernel.h>
64 #include <sys/module.h>
65
66 #include <sys/bio.h>
67 #include <sys/bus.h>
68 #include <sys/conf.h>
69 #include <sys/stat.h>
70
71 #include <cam/cam.h>
72 #include <cam/cam_ccb.h>
73 #include <cam/cam_sim.h>
74 #include <cam/cam_xpt.h>
75 #include <cam/cam_xpt_sim.h>
76 #include <cam/cam_debug.h>
77 #include <cam/scsi/scsi_all.h>
78 #include <cam/scsi/scsi_message.h>
79
80 #include <machine/resource.h>
81 #include <machine/bus.h>
82
83 #include <dev/amr/amrreg.h>
84 #include <dev/amr/amrvar.h>
85
86 static int amr_cam_probe(device_t dev);
87 static int amr_cam_attach(device_t dev);
88 static int amr_cam_detach(device_t dev);
89 static void amr_cam_action(struct cam_sim *sim, union ccb *ccb);
90 static void amr_cam_poll(struct cam_sim *sim);
91 static void amr_cam_complete(struct amr_command *ac);
92 static int amr_cam_command(struct amr_softc *sc, struct amr_command **acp);
93
94 static devclass_t amr_pass_devclass;
95
96 static device_method_t amr_pass_methods[] = {
97 DEVMETHOD(device_probe, amr_cam_probe),
98 DEVMETHOD(device_attach, amr_cam_attach),
99 DEVMETHOD(device_detach, amr_cam_detach),
100 { 0, 0 }
101 };
102
103 static driver_t amr_pass_driver = {
104 "amrp",
105 amr_pass_methods,
106 0
107 };
108
109 DRIVER_MODULE(amrp, amr, amr_pass_driver, amr_pass_devclass, 0, 0);
110 MODULE_DEPEND(amrp, cam, 1, 1, 1);
111
112 static MALLOC_DEFINE(M_AMRCAM, "amrcam", "AMR CAM memory");
113
114 /***********************************************************************
115 * Enqueue/dequeue functions
116 */
117 static __inline void
amr_enqueue_ccb(struct amr_softc * sc,union ccb * ccb)118 amr_enqueue_ccb(struct amr_softc *sc, union ccb *ccb)
119 {
120
121 TAILQ_INSERT_TAIL(&sc->amr_cam_ccbq, &ccb->ccb_h, sim_links.tqe);
122 }
123
124 static __inline void
amr_requeue_ccb(struct amr_softc * sc,union ccb * ccb)125 amr_requeue_ccb(struct amr_softc *sc, union ccb *ccb)
126 {
127
128 TAILQ_INSERT_HEAD(&sc->amr_cam_ccbq, &ccb->ccb_h, sim_links.tqe);
129 }
130
131 static __inline union ccb *
amr_dequeue_ccb(struct amr_softc * sc)132 amr_dequeue_ccb(struct amr_softc *sc)
133 {
134 union ccb *ccb;
135
136 if ((ccb = (union ccb *)TAILQ_FIRST(&sc->amr_cam_ccbq)) != NULL)
137 TAILQ_REMOVE(&sc->amr_cam_ccbq, &ccb->ccb_h, sim_links.tqe);
138 return(ccb);
139 }
140
141 static int
amr_cam_probe(device_t dev)142 amr_cam_probe(device_t dev)
143 {
144 return (0);
145 }
146
147 /********************************************************************************
148 * Attach our 'real' SCSI channels to CAM
149 */
150 static int
amr_cam_attach(device_t dev)151 amr_cam_attach(device_t dev)
152 {
153 struct amr_softc *sc;
154 struct cam_devq *devq;
155 int chn, error;
156
157 sc = device_get_softc(dev);
158
159 /* initialise the ccb queue */
160 TAILQ_INIT(&sc->amr_cam_ccbq);
161
162 /*
163 * Allocate a devq for all our channels combined. This should
164 * allow for the maximum number of SCSI commands we will accept
165 * at one time. Save the pointer in the softc so we can find it later
166 * during detach.
167 */
168 if ((devq = cam_simq_alloc(AMR_MAX_SCSI_CMDS)) == NULL)
169 return(ENOMEM);
170 sc->amr_cam_devq = devq;
171
172 /*
173 * Iterate over our channels, registering them with CAM
174 */
175 for (chn = 0; chn < sc->amr_maxchan; chn++) {
176 /* allocate a sim */
177 if ((sc->amr_cam_sim[chn] = cam_sim_alloc(amr_cam_action,
178 amr_cam_poll, "amr", sc, device_get_unit(sc->amr_dev),
179 &sc->amr_list_lock, 1, AMR_MAX_SCSI_CMDS, devq)) == NULL) {
180 cam_simq_free(devq);
181 device_printf(sc->amr_dev, "CAM SIM attach failed\n");
182 return(ENOMEM);
183 }
184
185 /* register the bus ID so we can get it later */
186 mtx_lock(&sc->amr_list_lock);
187 error = xpt_bus_register(sc->amr_cam_sim[chn], sc->amr_dev,chn);
188 mtx_unlock(&sc->amr_list_lock);
189 if (error) {
190 device_printf(sc->amr_dev,
191 "CAM XPT bus registration failed\n");
192 return(ENXIO);
193 }
194 }
195 /*
196 * XXX we should scan the config and work out which devices are
197 * actually protected.
198 */
199 sc->amr_cam_command = amr_cam_command;
200 return(0);
201 }
202
203 /********************************************************************************
204 * Disconnect ourselves from CAM
205 */
206 static int
amr_cam_detach(device_t dev)207 amr_cam_detach(device_t dev)
208 {
209 struct amr_softc *sc;
210 int chn;
211
212 sc = device_get_softc(dev);
213 mtx_lock(&sc->amr_list_lock);
214 for (chn = 0; chn < sc->amr_maxchan; chn++) {
215 /*
216 * If a sim was allocated for this channel, free it
217 */
218 if (sc->amr_cam_sim[chn] != NULL) {
219 xpt_bus_deregister(cam_sim_path(sc->amr_cam_sim[chn]));
220 cam_sim_free(sc->amr_cam_sim[chn], FALSE);
221 }
222 }
223 mtx_unlock(&sc->amr_list_lock);
224
225 /* Now free the devq */
226 if (sc->amr_cam_devq != NULL)
227 cam_simq_free(sc->amr_cam_devq);
228
229 return (0);
230 }
231
232 /***********************************************************************
233 ***********************************************************************
234 CAM passthrough interface
235 ***********************************************************************
236 ***********************************************************************/
237
238 /***********************************************************************
239 * Handle a request for action from CAM
240 */
241 static void
amr_cam_action(struct cam_sim * sim,union ccb * ccb)242 amr_cam_action(struct cam_sim *sim, union ccb *ccb)
243 {
244 struct amr_softc *sc = cam_sim_softc(sim);
245
246 switch(ccb->ccb_h.func_code) {
247 /*
248 * Perform SCSI I/O to a physical device.
249 */
250 case XPT_SCSI_IO:
251 {
252 struct ccb_hdr *ccbh = &ccb->ccb_h;
253 struct ccb_scsiio *csio = &ccb->csio;
254
255 /* Validate the CCB */
256 ccbh->status = CAM_REQ_INPROG;
257
258 /* check the CDB length */
259 if (csio->cdb_len > AMR_MAX_EXTCDB_LEN)
260 ccbh->status = CAM_REQ_INVALID;
261
262 if ((csio->cdb_len > AMR_MAX_CDB_LEN) &&
263 (sc->support_ext_cdb == 0))
264 ccbh->status = CAM_REQ_INVALID;
265
266 /* check that the CDB pointer is not to a physical address */
267 if ((ccbh->flags & CAM_CDB_POINTER) &&
268 (ccbh->flags & CAM_CDB_PHYS))
269 ccbh->status = CAM_REQ_INVALID;
270 /*
271 * if there is data transfer, it must be to/from a virtual
272 * address
273 */
274 if ((ccbh->flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
275 if ((ccbh->flags & CAM_DATA_MASK) != CAM_DATA_VADDR)
276 /* we can't map it */
277 ccbh->status = CAM_REQ_INVALID;
278 }
279
280 /*
281 * If the command is to a LUN other than 0, fail it.
282 * This is probably incorrect, but during testing the
283 * firmware did not seem to respect the LUN field, and thus
284 * devices appear echoed.
285 */
286 if (csio->ccb_h.target_lun != 0)
287 ccbh->status = CAM_DEV_NOT_THERE;
288
289 /* if we're happy with the request, queue it for attention */
290 if (ccbh->status == CAM_REQ_INPROG) {
291 /* save the channel number in the ccb */
292 csio->ccb_h.sim_priv.entries[0].field= cam_sim_bus(sim);
293
294 amr_enqueue_ccb(sc, ccb);
295 amr_startio(sc);
296 return;
297 }
298 break;
299 }
300
301 case XPT_CALC_GEOMETRY:
302 {
303 cam_calc_geometry(&ccb->ccg, /*extended*/1);
304 break;
305 }
306
307 /*
308 * Return path stats. Some of these should probably be amended.
309 */
310 case XPT_PATH_INQ:
311 {
312 struct ccb_pathinq *cpi = & ccb->cpi;
313
314 debug(3, "XPT_PATH_INQ");
315 cpi->version_num = 1; /* XXX??? */
316 cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE|PI_WIDE_16;
317 cpi->target_sprt = 0;
318 cpi->hba_misc = PIM_NOBUSRESET|PIM_SEQSCAN;
319 cpi->hba_eng_cnt = 0;
320 cpi->max_target = AMR_MAX_TARGETS;
321 cpi->max_lun = 0 /* AMR_MAX_LUNS*/;
322 cpi->initiator_id = 7; /* XXX variable? */
323 strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
324 strlcpy(cpi->hba_vid, "LSI", HBA_IDLEN);
325 strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
326 cpi->unit_number = cam_sim_unit(sim);
327 cpi->bus_id = cam_sim_bus(sim);
328 cpi->base_transfer_speed = 132 * 1024; /* XXX */
329 cpi->transport = XPORT_SPI;
330 cpi->transport_version = 2;
331 cpi->protocol = PROTO_SCSI;
332 cpi->protocol_version = SCSI_REV_2;
333 cpi->ccb_h.status = CAM_REQ_CMP;
334
335 break;
336 }
337
338 case XPT_RESET_BUS:
339 {
340 struct ccb_pathinq *cpi = & ccb->cpi;
341
342 debug(1, "XPT_RESET_BUS");
343 cpi->ccb_h.status = CAM_REQ_CMP;
344 break;
345 }
346
347 case XPT_RESET_DEV:
348 {
349 debug(1, "XPT_RESET_DEV");
350 ccb->ccb_h.status = CAM_REQ_CMP;
351 break;
352 }
353
354 case XPT_GET_TRAN_SETTINGS:
355 {
356 struct ccb_trans_settings *cts = &(ccb->cts);
357
358 debug(3, "XPT_GET_TRAN_SETTINGS");
359
360 struct ccb_trans_settings_scsi *scsi;
361 struct ccb_trans_settings_spi *spi;
362
363 scsi = &cts->proto_specific.scsi;
364 spi = &cts->xport_specific.spi;
365
366 cts->protocol = PROTO_SCSI;
367 cts->protocol_version = SCSI_REV_2;
368 cts->transport = XPORT_SPI;
369 cts->transport_version = 2;
370
371 if (cts->type == CTS_TYPE_USER_SETTINGS) {
372 ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
373 break;
374 }
375
376 spi->flags = CTS_SPI_FLAGS_DISC_ENB;
377 spi->bus_width = MSG_EXT_WDTR_BUS_32_BIT;
378 spi->sync_period = 6; /* 40MHz how wide is this bus? */
379 spi->sync_offset = 31; /* How to extract this from board? */
380
381 spi->valid = CTS_SPI_VALID_SYNC_RATE
382 | CTS_SPI_VALID_SYNC_OFFSET
383 | CTS_SPI_VALID_BUS_WIDTH
384 | CTS_SPI_VALID_DISC;
385 scsi->valid = CTS_SCSI_VALID_TQ;
386 ccb->ccb_h.status = CAM_REQ_CMP;
387 break;
388 }
389
390 case XPT_SET_TRAN_SETTINGS:
391 debug(3, "XPT_SET_TRAN_SETTINGS");
392 ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
393 break;
394
395 /*
396 * Reject anything else as unsupported.
397 */
398 default:
399 /* we can't do this */
400 ccb->ccb_h.status = CAM_REQ_INVALID;
401 break;
402 }
403
404 mtx_assert(&sc->amr_list_lock, MA_OWNED);
405 xpt_done(ccb);
406 }
407
408 /***********************************************************************
409 * Convert a CAM CCB off the top of the CCB queue to a passthrough SCSI
410 * command.
411 */
412 static int
amr_cam_command(struct amr_softc * sc,struct amr_command ** acp)413 amr_cam_command(struct amr_softc *sc, struct amr_command **acp)
414 {
415 struct amr_command *ac;
416 struct amr_passthrough *ap;
417 struct amr_ext_passthrough *aep;
418 struct ccb_scsiio *csio;
419 int bus, target, error;
420
421 error = 0;
422 ac = NULL;
423 ap = NULL;
424 aep = NULL;
425
426 /* check to see if there is a ccb for us to work with */
427 if ((csio = (struct ccb_scsiio *)amr_dequeue_ccb(sc)) == NULL)
428 goto out;
429
430 /* get bus/target, XXX validate against protected devices? */
431 bus = csio->ccb_h.sim_priv.entries[0].field;
432 target = csio->ccb_h.target_id;
433
434 /*
435 * Build a passthrough command.
436 */
437
438 /* construct command */
439 if ((ac = amr_alloccmd(sc)) == NULL) {
440 error = ENOMEM;
441 goto out;
442 }
443
444 /* construct passthrough */
445 if (sc->support_ext_cdb ) {
446 aep = &ac->ac_ccb->ccb_epthru;
447 aep->ap_timeout = 2;
448 aep->ap_ars = 1;
449 aep->ap_request_sense_length = 14;
450 aep->ap_islogical = 0;
451 aep->ap_channel = bus;
452 aep->ap_scsi_id = target;
453 aep->ap_logical_drive_no = csio->ccb_h.target_lun;
454 aep->ap_cdb_length = csio->cdb_len;
455 aep->ap_data_transfer_length = csio->dxfer_len;
456 if (csio->ccb_h.flags & CAM_CDB_POINTER) {
457 bcopy(csio->cdb_io.cdb_ptr, aep->ap_cdb, csio->cdb_len);
458 } else {
459 bcopy(csio->cdb_io.cdb_bytes, aep->ap_cdb,
460 csio->cdb_len);
461 }
462 /*
463 * we leave the data s/g list and s/g count to the map routine
464 * later
465 */
466
467 debug(2, " COMMAND %x/%d+%d to %d:%d:%d", aep->ap_cdb[0],
468 aep->ap_cdb_length, csio->dxfer_len, aep->ap_channel,
469 aep->ap_scsi_id, aep->ap_logical_drive_no);
470
471 } else {
472 ap = &ac->ac_ccb->ccb_pthru;
473 ap->ap_timeout = 0;
474 ap->ap_ars = 1;
475 ap->ap_request_sense_length = 14;
476 ap->ap_islogical = 0;
477 ap->ap_channel = bus;
478 ap->ap_scsi_id = target;
479 ap->ap_logical_drive_no = csio->ccb_h.target_lun;
480 ap->ap_cdb_length = csio->cdb_len;
481 ap->ap_data_transfer_length = csio->dxfer_len;
482 if (csio->ccb_h.flags & CAM_CDB_POINTER) {
483 bcopy(csio->cdb_io.cdb_ptr, ap->ap_cdb, csio->cdb_len);
484 } else {
485 bcopy(csio->cdb_io.cdb_bytes, ap->ap_cdb,
486 csio->cdb_len);
487 }
488 /*
489 * we leave the data s/g list and s/g count to the map routine
490 * later
491 */
492
493 debug(2, " COMMAND %x/%d+%d to %d:%d:%d", ap->ap_cdb[0],
494 ap->ap_cdb_length, csio->dxfer_len, ap->ap_channel,
495 ap->ap_scsi_id, ap->ap_logical_drive_no);
496 }
497
498 ac->ac_flags |= AMR_CMD_CCB;
499
500 ac->ac_data = csio->data_ptr;
501 ac->ac_length = csio->dxfer_len;
502 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)
503 ac->ac_flags |= AMR_CMD_DATAIN;
504 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT)
505 ac->ac_flags |= AMR_CMD_DATAOUT;
506
507 ac->ac_private = csio;
508 ac->ac_complete = amr_cam_complete;
509 if ( sc->support_ext_cdb ) {
510 ac->ac_mailbox.mb_command = AMR_CMD_EXTPASS;
511 } else {
512 ac->ac_mailbox.mb_command = AMR_CMD_PASS;
513 }
514
515 out:
516 if (error != 0) {
517 if (ac != NULL)
518 amr_releasecmd(ac);
519 if (csio != NULL)
520 /* put it back and try again later */
521 amr_requeue_ccb(sc, (union ccb *)csio);
522 }
523 *acp = ac;
524 return(error);
525 }
526
527 /***********************************************************************
528 * Check for interrupt status
529 */
530 static void
amr_cam_poll(struct cam_sim * sim)531 amr_cam_poll(struct cam_sim *sim)
532 {
533
534 amr_done(cam_sim_softc(sim));
535 }
536
537 /**********************************************************************
538 * Handle completion of a command submitted via CAM.
539 */
540 static void
amr_cam_complete(struct amr_command * ac)541 amr_cam_complete(struct amr_command *ac)
542 {
543 struct amr_passthrough *ap;
544 struct amr_ext_passthrough *aep;
545 struct ccb_scsiio *csio;
546 struct scsi_inquiry_data *inq;
547 int scsi_status, cdb0;
548
549 ap = &ac->ac_ccb->ccb_pthru;
550 aep = &ac->ac_ccb->ccb_epthru;
551 csio = (struct ccb_scsiio *)ac->ac_private;
552 inq = (struct scsi_inquiry_data *)csio->data_ptr;
553
554 if (ac->ac_mailbox.mb_command == AMR_CMD_EXTPASS)
555 scsi_status = aep->ap_scsi_status;
556 else
557 scsi_status = ap->ap_scsi_status;
558 debug(1, "status 0x%x AP scsi_status 0x%x", ac->ac_status,
559 scsi_status);
560
561 /* Make sure the status is sane */
562 if ((ac->ac_status != AMR_STATUS_SUCCESS) && (scsi_status == 0)) {
563 csio->ccb_h.status = CAM_REQ_CMP_ERR;
564 goto out;
565 }
566
567 /*
568 * Hide disks from CAM so that they're not picked up and treated as
569 * 'normal' disks.
570 *
571 * If the configuration provides a mechanism to mark a disk a "not
572 * managed", we could add handling for that to allow disks to be
573 * selectively visible.
574 */
575
576 /* handle passthrough SCSI status */
577 switch(scsi_status) {
578 case 0: /* completed OK */
579 if (ac->ac_mailbox.mb_command == AMR_CMD_EXTPASS)
580 cdb0 = aep->ap_cdb[0];
581 else
582 cdb0 = ap->ap_cdb[0];
583 if ((cdb0 == INQUIRY) && (SID_TYPE(inq) == T_DIRECT))
584 inq->device = (inq->device & 0xe0) | T_NODEVICE;
585 csio->ccb_h.status = CAM_REQ_CMP;
586 break;
587
588 case 0x02:
589 csio->ccb_h.status = CAM_SCSI_STATUS_ERROR;
590 csio->scsi_status = SCSI_STATUS_CHECK_COND;
591 if (ac->ac_mailbox.mb_command == AMR_CMD_EXTPASS)
592 bcopy(aep->ap_request_sense_area, &csio->sense_data,
593 AMR_MAX_REQ_SENSE_LEN);
594 else
595 bcopy(ap->ap_request_sense_area, &csio->sense_data,
596 AMR_MAX_REQ_SENSE_LEN);
597 csio->sense_len = AMR_MAX_REQ_SENSE_LEN;
598 csio->ccb_h.status |= CAM_AUTOSNS_VALID;
599 break;
600
601 case 0x08:
602 csio->ccb_h.status = CAM_SCSI_BUSY;
603 break;
604
605 case 0xf0:
606 case 0xf4:
607 default:
608 /*
609 * Non-zero LUNs are already filtered, so there's no need
610 * to return CAM_DEV_NOT_THERE.
611 */
612 csio->ccb_h.status = CAM_SEL_TIMEOUT;
613 break;
614 }
615
616 out:
617 if ((csio->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE)
618 debug(2, "%*D\n", imin(csio->dxfer_len, 16), csio->data_ptr,
619 " ");
620
621 mtx_lock(&ac->ac_sc->amr_list_lock);
622 xpt_done((union ccb *)csio);
623 amr_releasecmd(ac);
624 mtx_unlock(&ac->ac_sc->amr_list_lock);
625 }
626