aac_cam.c (150120) | aac_cam.c (151086) |
---|---|
1/*- 2 * Copyright (c) 2002 Adaptec, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2002 Adaptec, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/dev/aac/aac_cam.c 150120 2005-09-14 05:49:34Z scottl $"); | 28__FBSDID("$FreeBSD: head/sys/dev/aac/aac_cam.c 151086 2005-10-08 15:55:09Z scottl $"); |
29 30/* 31 * CAM front-end for communicating with non-DASD devices 32 */ 33 34#include "opt_aac.h" 35 36#include <sys/param.h> --- 37 unchanged lines hidden (view full) --- 74static int aac_cam_attach(device_t dev); 75static int aac_cam_detach(device_t dev); 76static void aac_cam_action(struct cam_sim *, union ccb *); 77static void aac_cam_poll(struct cam_sim *); 78static void aac_cam_complete(struct aac_command *); 79static u_int32_t aac_cam_reset_bus(struct cam_sim *, union ccb *); 80static u_int32_t aac_cam_abort_ccb(struct cam_sim *, union ccb *); 81static u_int32_t aac_cam_term_io(struct cam_sim *, union ccb *); | 29 30/* 31 * CAM front-end for communicating with non-DASD devices 32 */ 33 34#include "opt_aac.h" 35 36#include <sys/param.h> --- 37 unchanged lines hidden (view full) --- 74static int aac_cam_attach(device_t dev); 75static int aac_cam_detach(device_t dev); 76static void aac_cam_action(struct cam_sim *, union ccb *); 77static void aac_cam_poll(struct cam_sim *); 78static void aac_cam_complete(struct aac_command *); 79static u_int32_t aac_cam_reset_bus(struct cam_sim *, union ccb *); 80static u_int32_t aac_cam_abort_ccb(struct cam_sim *, union ccb *); 81static u_int32_t aac_cam_term_io(struct cam_sim *, union ccb *); |
82static int aac_cam_get_tran_settings(struct aac_softc *, struct ccb_trans_settings *, u_int32_t); | |
83 84static devclass_t aac_pass_devclass; 85 86static device_method_t aac_pass_methods[] = { 87 DEVMETHOD(device_probe, aac_cam_probe), 88 DEVMETHOD(device_attach, aac_cam_attach), 89 DEVMETHOD(device_detach, aac_cam_detach), 90 { 0, 0 } --- 5 unchanged lines hidden (view full) --- 96 sizeof(struct aac_cam) 97}; 98 99DRIVER_MODULE(aacp, aac, aac_pass_driver, aac_pass_devclass, 0, 0); 100MODULE_DEPEND(aacp, cam, 1, 1, 1); 101 102MALLOC_DEFINE(M_AACCAM, "aaccam", "AAC CAM info"); 103 | 82 83static devclass_t aac_pass_devclass; 84 85static device_method_t aac_pass_methods[] = { 86 DEVMETHOD(device_probe, aac_cam_probe), 87 DEVMETHOD(device_attach, aac_cam_attach), 88 DEVMETHOD(device_detach, aac_cam_detach), 89 { 0, 0 } --- 5 unchanged lines hidden (view full) --- 95 sizeof(struct aac_cam) 96}; 97 98DRIVER_MODULE(aacp, aac, aac_pass_driver, aac_pass_devclass, 0, 0); 99MODULE_DEPEND(aacp, cam, 1, 1, 1); 100 101MALLOC_DEFINE(M_AACCAM, "aaccam", "AAC CAM info"); 102 |
103static void 104aac_cam_event(struct aac_softc *sc, struct aac_event *event, void *arg) 105{ 106 struct aac_cam *camsc; 107 108 switch (event->ev_type) { 109 case AAC_EVENT_CMFREE: 110 camsc = arg; 111 free(event, M_AACCAM); 112 xpt_release_simq(camsc->sim, 1); 113 break; 114 default: 115 device_printf(sc->aac_dev, "unknown event %d in aac_cam\n", 116 event->ev_type); 117 break; 118 } 119 120 return; 121} 122 |
|
104static int 105aac_cam_probe(device_t dev) 106{ 107 debug_called(2); 108 109 return (0); 110} 111 --- 134 unchanged lines hidden (view full) --- 246 cpi->unit_number = cam_sim_unit(sim); 247 248 ccb->ccb_h.status = CAM_REQ_CMP; 249 xpt_done(ccb); 250 return; 251 } 252 case XPT_GET_TRAN_SETTINGS: 253 { | 123static int 124aac_cam_probe(device_t dev) 125{ 126 debug_called(2); 127 128 return (0); 129} 130 --- 134 unchanged lines hidden (view full) --- 265 cpi->unit_number = cam_sim_unit(sim); 266 267 ccb->ccb_h.status = CAM_REQ_CMP; 268 xpt_done(ccb); 269 return; 270 } 271 case XPT_GET_TRAN_SETTINGS: 272 { |
254 u_int32_t handle; 255 256 handle = AAC_BTL_TO_HANDLE(camsc->inf->BusNumber, 257 ccb->ccb_h.target_id, ccb->ccb_h.target_lun); 258 ccb->ccb_h.status = aac_cam_get_tran_settings(sc, &ccb->cts, 259 handle); | 273 ccb->cts.flags &= ~(CCB_TRANS_DISC_ENB | CCB_TRANS_TAG_ENB); 274 ccb->cts.valid = CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID; 275 ccb->ccb_h.status = CAM_REQ_CMP; |
260 xpt_done(ccb); 261 return; 262 } 263 case XPT_SET_TRAN_SETTINGS: 264 ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; 265 xpt_done(ccb); 266 return; 267 case XPT_RESET_BUS: --- 19 unchanged lines hidden (view full) --- 287 xpt_done(ccb); 288 return; 289 } 290 291 /* Async ops that require communcation with the controller */ 292 293 mtx_lock(&sc->aac_io_lock); 294 if (aac_alloc_command(sc, &cm)) { | 276 xpt_done(ccb); 277 return; 278 } 279 case XPT_SET_TRAN_SETTINGS: 280 ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; 281 xpt_done(ccb); 282 return; 283 case XPT_RESET_BUS: --- 19 unchanged lines hidden (view full) --- 303 xpt_done(ccb); 304 return; 305 } 306 307 /* Async ops that require communcation with the controller */ 308 309 mtx_lock(&sc->aac_io_lock); 310 if (aac_alloc_command(sc, &cm)) { |
295 mtx_unlock(&sc->aac_io_lock); | 311 struct aac_event *event; 312 |
296 xpt_freeze_simq(sim, 1); 297 ccb->ccb_h.status = CAM_REQUEUE_REQ; 298 xpt_done(ccb); | 313 xpt_freeze_simq(sim, 1); 314 ccb->ccb_h.status = CAM_REQUEUE_REQ; 315 xpt_done(ccb); |
316 event = malloc(sizeof(struct aac_event), M_AACCAM, 317 M_NOWAIT | M_ZERO); 318 if (event == NULL) { 319 device_printf(sc->aac_dev, 320 "Warning, out of memory for event\n"); 321 /* XXX Yuck, what to do here? */ 322 mtx_unlock(&sc->aac_io_lock); 323 return; 324 } 325 event->ev_callback = aac_cam_event; 326 event->ev_arg = camsc; 327 event->ev_type = AAC_EVENT_CMFREE; 328 aac_add_event(sc, event); 329 mtx_unlock(&sc->aac_io_lock); |
|
299 return; 300 } 301 302 fib = cm->cm_fib; 303 srb = (struct aac_srb32 *)&fib->data[0]; 304 cm->cm_datalen = 0; 305 306 switch (ccb->ccb_h.flags & CAM_DIR_MASK) { --- 157 unchanged lines hidden (view full) --- 464 bzero(&ccb->csio.sense_data, scsi_sense_len); 465 sense_len = (srbr->sense_len > 466 scsi_sense_len) ? scsi_sense_len : 467 srbr->sense_len; 468 bcopy(&srbr->sense[0], &ccb->csio.sense_data, 469 srbr->sense_len); 470 ccb->csio.sense_len = sense_len; 471 ccb->ccb_h.status |= CAM_AUTOSNS_VALID; | 330 return; 331 } 332 333 fib = cm->cm_fib; 334 srb = (struct aac_srb32 *)&fib->data[0]; 335 cm->cm_datalen = 0; 336 337 switch (ccb->ccb_h.flags & CAM_DIR_MASK) { --- 157 unchanged lines hidden (view full) --- 495 bzero(&ccb->csio.sense_data, scsi_sense_len); 496 sense_len = (srbr->sense_len > 497 scsi_sense_len) ? scsi_sense_len : 498 srbr->sense_len; 499 bcopy(&srbr->sense[0], &ccb->csio.sense_data, 500 srbr->sense_len); 501 ccb->csio.sense_len = sense_len; 502 ccb->ccb_h.status |= CAM_AUTOSNS_VALID; |
472 scsi_sense_print(&ccb->csio); | 503 // scsi_sense_print(&ccb->csio); |
473 } 474 475 /* If this is an inquiry command, fake things out */ 476 if (ccb->ccb_h.flags & CAM_CDB_POINTER) 477 command = ccb->csio.cdb_io.cdb_ptr[0]; 478 else 479 command = ccb->csio.cdb_io.cdb_bytes[0]; 480 --- 32 unchanged lines hidden (view full) --- 513 camsc = (struct aac_cam *)cam_sim_softc(sim); 514 sc = camsc->inf->aac_sc; 515 516 if (sc == NULL) { 517 printf("Null sc?\n"); 518 return (CAM_REQ_ABORTED); 519 } 520 | 504 } 505 506 /* If this is an inquiry command, fake things out */ 507 if (ccb->ccb_h.flags & CAM_CDB_POINTER) 508 command = ccb->csio.cdb_io.cdb_ptr[0]; 509 else 510 command = ccb->csio.cdb_io.cdb_bytes[0]; 511 --- 32 unchanged lines hidden (view full) --- 544 camsc = (struct aac_cam *)cam_sim_softc(sim); 545 sc = camsc->inf->aac_sc; 546 547 if (sc == NULL) { 548 printf("Null sc?\n"); 549 return (CAM_REQ_ABORTED); 550 } 551 |
552 mtx_lock(&sc->aac_io_lock); |
|
521 aac_alloc_sync_fib(sc, &fib); 522 523 vmi = (struct aac_vmioctl *)&fib->data[0]; 524 bzero(vmi, sizeof(struct aac_vmioctl)); 525 526 vmi->Command = VM_Ioctl; 527 vmi->ObjType = FT_DRIVE; 528 vmi->MethId = sc->scsi_method_id; --- 8 unchanged lines hidden (view full) --- 537 if (e) { 538 device_printf(sc->aac_dev,"Error %d sending ResetBus command\n", 539 e); 540 aac_release_sync_fib(sc); 541 return (CAM_REQ_ABORTED); 542 } 543 544 aac_release_sync_fib(sc); | 553 aac_alloc_sync_fib(sc, &fib); 554 555 vmi = (struct aac_vmioctl *)&fib->data[0]; 556 bzero(vmi, sizeof(struct aac_vmioctl)); 557 558 vmi->Command = VM_Ioctl; 559 vmi->ObjType = FT_DRIVE; 560 vmi->MethId = sc->scsi_method_id; --- 8 unchanged lines hidden (view full) --- 569 if (e) { 570 device_printf(sc->aac_dev,"Error %d sending ResetBus command\n", 571 e); 572 aac_release_sync_fib(sc); 573 return (CAM_REQ_ABORTED); 574 } 575 576 aac_release_sync_fib(sc); |
577 mtx_unlock(&sc->aac_io_lock); |
|
545 return (CAM_REQ_CMP); 546} 547 548static u_int32_t 549aac_cam_abort_ccb(struct cam_sim *sim, union ccb *ccb) 550{ 551 return (CAM_UA_ABORT); 552} 553 554static u_int32_t 555aac_cam_term_io(struct cam_sim *sim, union ccb *ccb) 556{ 557 return (CAM_UA_TERMIO); 558} 559 | 578 return (CAM_REQ_CMP); 579} 580 581static u_int32_t 582aac_cam_abort_ccb(struct cam_sim *sim, union ccb *ccb) 583{ 584 return (CAM_UA_ABORT); 585} 586 587static u_int32_t 588aac_cam_term_io(struct cam_sim *sim, union ccb *ccb) 589{ 590 return (CAM_UA_TERMIO); 591} 592 |
560static int 561aac_cam_get_tran_settings(struct aac_softc *sc, struct ccb_trans_settings *cts, u_int32_t handle) 562{ 563 struct aac_fib *fib; 564 struct aac_vmioctl *vmi; 565 struct aac_vmi_devinfo_resp *vmi_resp; 566 int error; 567 568 aac_alloc_sync_fib(sc, &fib); 569 vmi = (struct aac_vmioctl *)&fib->data[0]; 570 bzero(vmi, sizeof(struct aac_vmioctl)); 571 572 vmi->Command = VM_Ioctl; 573 vmi->ObjType = FT_DRIVE; 574 vmi->MethId = sc->scsi_method_id; 575 vmi->ObjId = handle; 576 vmi->IoctlCmd = GetDeviceProbeInfo; 577 578 error = aac_sync_fib(sc, ContainerCommand, 0, fib, 579 sizeof(struct aac_vmioctl)); 580 if (error) { 581 device_printf(sc->aac_dev, "Error %d sending GetDeviceProbeInfo" 582 " command\n", error); 583 aac_release_sync_fib(sc); 584 return (CAM_REQ_INVALID); 585 } 586 587 vmi_resp = (struct aac_vmi_devinfo_resp *)&fib->data[0]; 588 if (vmi_resp->Status != ST_OK) { 589 /* 590 * The only reason why this command will return an error is 591 * if the requested device doesn't exist. 592 */ 593 debug(1, "GetDeviceProbeInfo returned %d\n", vmi_resp->Status); 594 aac_release_sync_fib(sc); 595 return (CAM_DEV_NOT_THERE); 596 } 597 598 cts->bus_width = ((vmi_resp->Inquiry7 & 0x60) >> 5); 599 cts->valid = CCB_TRANS_BUS_WIDTH_VALID; 600 601 if (vmi_resp->ScsiRate) { 602 cts->sync_period = 603 scsi_calc_syncparam((10000 / vmi_resp->ScsiRate)); 604 cts->sync_offset = vmi_resp->ScsiOffset; 605 cts->valid |= CCB_TRANS_SYNC_RATE_VALID | 606 CCB_TRANS_SYNC_OFFSET_VALID; 607 } 608 609 cts->flags &= ~(CCB_TRANS_DISC_ENB | CCB_TRANS_TAG_ENB); 610 cts->valid |= CCB_TRANS_DISC_VALID | 611 CCB_TRANS_TQ_VALID; 612 613 aac_release_sync_fib(sc); 614 return (CAM_REQ_CMP); 615} | |