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